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

This commit is contained in:
Chet Ramey
2024-09-23 18:14:07 -04:00
parent 37b7e91d64
commit 2abedfbddb
5 changed files with 35 additions and 24634 deletions
-1326
View File
File diff suppressed because it is too large Load Diff
-23305
View File
File diff suppressed because it is too large Load Diff
+17 -1
View File
@@ -6489,9 +6489,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);
@@ -6514,6 +6515,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 */
@@ -6537,7 +6544,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)
{
+1 -1
View File
@@ -25,6 +25,6 @@
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
looks for to find the patch level (for the sccs version string). */
#define PATCHLEVEL 33
#define PATCHLEVEL 34
#endif /* _PATCHLEVEL_H_ */
+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)
{