From a3ede3106aea03f09415b7fc760c70ac9c81f671 Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 18 Nov 2024 08:29:35 +0000 Subject: [PATCH] Check all %if in the list when deciding whether to process an assignment, not just the most recent. --- cmd-parse.y | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/cmd-parse.y b/cmd-parse.y index 02e30550..fbed727b 100644 --- a/cmd-parse.y +++ b/cmd-parse.y @@ -223,9 +223,16 @@ assignment : EQUALS { struct cmd_parse_state *ps = &parse_state; int flags = ps->input->flags; + int flag = 1; + struct cmd_parse_scope *scope; - if ((~flags & CMD_PARSE_PARSEONLY) && - (ps->scope == NULL || ps->scope->flag)) + if (ps->scope != NULL) { + flag = ps->scope->flag; + TAILQ_FOREACH(scope, &ps->stack, entry) + flag = flag && scope->flag; + } + + if ((~flags & CMD_PARSE_PARSEONLY) && flag) environ_put(global_environ, $1, 0); free($1); } @@ -234,9 +241,16 @@ hidden_assignment : HIDDEN EQUALS { struct cmd_parse_state *ps = &parse_state; int flags = ps->input->flags; + int flag = 1; + struct cmd_parse_scope *scope; - if ((~flags & CMD_PARSE_PARSEONLY) && - (ps->scope == NULL || ps->scope->flag)) + if (ps->scope != NULL) { + flag = ps->scope->flag; + TAILQ_FOREACH(scope, &ps->stack, entry) + flag = flag && scope->flag; + } + + if ((~flags & CMD_PARSE_PARSEONLY) && flag) environ_put(global_environ, $2, ENVIRON_HIDDEN); free($2); }