aboutsummaryrefslogtreecommitdiffstats
path: root/src/lexer.c
diff options
context:
space:
mode:
authorDouglas B. Rumbaugh <doug@douglasrumbaugh.com>2025-11-01 13:35:36 -0400
committerDouglas B. Rumbaugh <doug@douglasrumbaugh.com>2025-11-01 13:35:36 -0400
commit406889ed5c780f0e28703b143c72bbf035280b25 (patch)
tree9158054087bda207eed65e13e3e706ceb8467388 /src/lexer.c
parent1c2f33050478e5c859fa7be390681b39ee7311b2 (diff)
downloadhush-406889ed5c780f0e28703b143c72bbf035280b25.tar.gz
Got pipelining fully working
Diffstat (limited to 'src/lexer.c')
-rw-r--r--src/lexer.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/lexer.c b/src/lexer.c
index a6af008..38ae558 100644
--- a/src/lexer.c
+++ b/src/lexer.c
@@ -153,6 +153,7 @@ token *validate_command(token *cmd) {
bool infile_defined = false;
bool outfile_defined = false;
bool looking_for_file = false;
+ bool reads_from_pipe = false;
for (token *tkn = cmd; tkn; tkn = tkn->next) {
if (!prev) {
@@ -183,6 +184,15 @@ token *validate_command(token *cmd) {
}
arg_cnt = 0;
+ reads_from_pipe = true;
+
+ if (infile_defined) {
+ return tkn;
+ }
+
+ infile_defined = false;
+ outfile_defined = false;
+
} else if (tkn->type == TKN_IN_REDIR || tkn->type == TKN_OUT_REDIR) {
if (prev->type == TKN_PIPE || prev->type == TKN_IN_REDIR ||
prev->type == TKN_OUT_REDIR) {
@@ -196,6 +206,10 @@ token *validate_command(token *cmd) {
if (prev->type != TKN_VARKEY) {
return tkn;
}
+ } else if (tkn->type == TKN_PIPE) {
+ if (outfile_defined) {
+ return tkn;
+ }
}
if (looking_for_file &&