summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/cmd-parse.y
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2024-11-18 08:29:36 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2024-11-18 08:29:36 +0000
commit85f9fc6ccbc56c4224aba5691ddf913cffa886a7 (patch)
treebede7a2a9a2493d6270c5e79c83852fcd82432ac /usr.bin/tmux/cmd-parse.y
parentb35de996e97878b59d04658758823f3c4327a104 (diff)
Check all %if in the list when deciding whether to process an
assignment, not just the most recent.
Diffstat (limited to 'usr.bin/tmux/cmd-parse.y')
-rw-r--r--usr.bin/tmux/cmd-parse.y24
1 files changed, 19 insertions, 5 deletions
diff --git a/usr.bin/tmux/cmd-parse.y b/usr.bin/tmux/cmd-parse.y
index 6565d2d2797..c519e22a52d 100644
--- a/usr.bin/tmux/cmd-parse.y
+++ b/usr.bin/tmux/cmd-parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-parse.y,v 1.51 2024/08/04 09:42:23 nicm Exp $ */
+/* $OpenBSD: cmd-parse.y,v 1.52 2024/11/18 08:29:35 nicm Exp $ */
/*
* Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -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);
}