aboutsummaryrefslogtreecommitdiffstats
path: root/src/lexer.c
diff options
context:
space:
mode:
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 &&