Bash-5.2 patch 34: fix for parsing compound assignment while expanding alias

This commit is contained in:
Chet Ramey committed 2024-09-23 18:14:07 -04:00
1 parent 37b7e91d64
commit 2abedfbddb
5 files changed
+35 -24634

No files matched your search

+17 -1
View File
@@ -8804,9 +8804,10 @@ parse_compound_assignment (retlenp)
int *retlenp;
{
WORD_LIST *wl, *rl;
int tok, orig_line_number, assignok;
int tok, orig_line_number, assignok, ea, restore_pushed_strings;
sh_parser_state_t ps;
char *ret;
STRING_SAVER *ss;
orig_line_number = line_number;
save_parser_state (&ps);
@@ -8829,6 +8830,12 @@ parse_compound_assignment (retlenp)
esacs_needed_count = expecting_in_token = 0;
/* We're not pushing any new input here, we're reading from the current input
source. If that's an alias, we have to be prepared for the alias to get
popped out from underneath us. */
ss = (ea = expanding_alias ()) ? pushed_string_list : (STRING_SAVER *)NULL;
restore_pushed_strings = 0;
while ((tok = read_token (READ)) != ')')
{
if (tok == '\n') /* Allow newlines in compound assignments */
@@ -8852,7 +8859,16 @@ parse_compound_assignment (retlenp)
wl = make_word_list (yylval.word, wl);
}
/* Check whether or not an alias got popped out from underneath us and
fix up after restore_parser_state. */
if (ea && ss && ss != pushed_string_list)
{
restore_pushed_strings = 1;
ss = pushed_string_list;
}
restore_parser_state (&ps);
if (restore_pushed_strings)
pushed_string_list = ss;
if (wl == &parse_string_error)
{