mirror of
https://github.com/zsh-users/zsh
synced 2024-10-02 22:24:37 +00:00
users/28338: command substitution with alias edge case.
See added regression test.
This commit is contained in:
parent
188c5cd518
commit
298919f43a
|
@ -1,3 +1,8 @@
|
|||
2022-11-08 Peter Stephenson <p.stephenson@samsung.com>
|
||||
|
||||
* users/28338: Src/lex.c, Test/D08cmdsubst.ztst: edge case of an
|
||||
edge case in command expansion of alias.
|
||||
|
||||
2022-11-06 Bart Schaefer <schaefer@zsh.org>
|
||||
|
||||
* 50874: Src/jobs.c: fix handling of tty signals for jobs in
|
||||
|
|
|
@ -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.");
|
||||
|
|
|
@ -177,3 +177,11 @@
|
|||
0:Alias expansion needed in parsing substitutions
|
||||
>hi
|
||||
>bye
|
||||
|
||||
# This should silently print a blank line; the original problem was
|
||||
# a parse error as the last character of the unexpanded alias
|
||||
# was erased, symptom: "command not found: W"
|
||||
alias WI='while {false}'
|
||||
eval 'echo $(WI blah)'
|
||||
0:Aliases with braces in command substitution can cause havoc
|
||||
>
|
||||
|
|
Loading…
Reference in a new issue