From 298919f43a565cc2e130c8cb3f67773f7a54fca1 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Tue, 8 Nov 2022 14:12:01 +0000 Subject: users/28338: command substitution with alias edge case. See added regression test. --- Src/lex.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'Src/lex.c') 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."); -- cgit 1.4.1