about summary refs log tree commit diff
path: root/Src/lex.c
diff options
context:
space:
mode:
authorPeter Stephenson <p.stephenson@samsung.com>2022-11-08 14:12:01 +0000
committerPeter Stephenson <p.stephenson@samsung.com>2022-11-08 14:12:01 +0000
commit298919f43a565cc2e130c8cb3f67773f7a54fca1 (patch)
tree76c81841550752479c536db1f35e04516a243a9c /Src/lex.c
parent188c5cd518b512073d3fd1dbf09c91b7968efcaa (diff)
downloadzsh-298919f43a565cc2e130c8cb3f67773f7a54fca1.tar.gz
zsh-298919f43a565cc2e130c8cb3f67773f7a54fca1.tar.xz
zsh-298919f43a565cc2e130c8cb3f67773f7a54fca1.zip
users/28338: command substitution with alias edge case.
See added regression test.
Diffstat (limited to 'Src/lex.c')
-rw-r--r--Src/lex.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/Src/lex.c b/Src/lex.c
index ece02659e..e2f8bcfb1 100644
--- a/Src/lex.c
+++ b/Src/lex.c
@@ -1429,10 +1429,18 @@ gettokstr(int c, int sub)
 	       peek == STRING && lexbuf.ptr[-1] == '}' &&
 	       lexbuf.ptr[-2] != Bnull) {
 	/* hack to get {foo} command syntax work */
+	/*
+	 * Alias expansion when parsing command substitution means that
+	 * the case for raw lexical analysis may not be the same.
+	 * (Just go with it, OK?)
+	 */
+	int lar = lex_add_raw;
+	lex_add_raw = lexbuf_raw.len > 0 && lexbuf_raw.ptr[-1] == '}';
 	lexbuf.ptr--;
 	lexbuf.len--;
 	lexstop = 0;
 	hungetc('}');
+	lex_add_raw = lar;
     }
     *lexbuf.ptr = '\0';
     DPUTS(cmdsp != ocmdsp, "BUG: gettok: cmdstack changed.");