7 Bug-Reported-by: Wiley Young <wyeth2485@gmail.com>
8 Bug-Reference-ID: <CAGnujaPrPV9hgbvdtG=fOs+L1zVGEahT9d3Aw0e1y3Qj8D8stw@mail.gmail.com>
9 Bug-Reference-URL: https://lists.gnu.org/archive/html/bug-bash/2023-05/msg00146.html
13 If we parse a compound assignment during an alias expansion, it's possible
14 to have the current input string popped out from underneath the parse. In
15 this case, we should not restore the input we were using when we began to
16 parse the compound assignment.
18 Patch (apply with `patch -p0'):
20 *** ../bash-5.2-patched/parse.y Fri May 26 16:57:03 2023
21 --- parse.y Thu Jun 1 16:30:19 2023
26 ! int tok, orig_line_number, assignok;
30 orig_line_number = line_number;
34 ! int tok, orig_line_number, assignok, ea, restore_pushed_strings;
39 orig_line_number = line_number;
43 esacs_needed_count = expecting_in_token = 0;
45 + /* We're not pushing any new input here, we're reading from the current input
46 + source. If that's an alias, we have to be prepared for the alias to get
47 + popped out from underneath us. */
48 + ss = (ea = expanding_alias ()) ? pushed_string_list : (STRING_SAVER *)NULL;
49 + restore_pushed_strings = 0;
51 while ((tok = read_token (READ)) != ')')
58 + /* Check whether or not an alias got popped out from underneath us and
59 + fix up after restore_parser_state. */
60 + if (ea && ss && ss != pushed_string_list)
62 + restore_pushed_strings = 1;
63 + ss = pushed_string_list;
65 restore_parser_state (&ps);
66 + if (restore_pushed_strings)
67 + pushed_string_list = ss;
69 if (wl == &parse_string_error)
70 *** ../bash-5.2-patched/y.tab.c Mon Sep 23 10:02:46 2024
71 --- y.tab.c Mon Sep 23 10:02:49 2024
77 ! int tok, orig_line_number, assignok;
81 orig_line_number = line_number;
82 save_parser_state (&ps);
87 ! int tok, orig_line_number, assignok, ea, restore_pushed_strings;
92 orig_line_number = line_number;
93 save_parser_state (&ps);
98 esacs_needed_count = expecting_in_token = 0;
100 + /* We're not pushing any new input here, we're reading from the current input
101 + source. If that's an alias, we have to be prepared for the alias to get
102 + popped out from underneath us. */
103 + ss = (ea = expanding_alias ()) ? pushed_string_list : (STRING_SAVER *)NULL;
104 + restore_pushed_strings = 0;
106 while ((tok = read_token (READ)) != ')')
108 if (tok == '\n') /* Allow newlines in compound assignments */
112 wl = make_word_list (yylval.word, wl);
115 + /* Check whether or not an alias got popped out from underneath us and
116 + fix up after restore_parser_state. */
117 + if (ea && ss && ss != pushed_string_list)
119 + restore_pushed_strings = 1;
120 + ss = pushed_string_list;
122 restore_parser_state (&ps);
123 + if (restore_pushed_strings)
124 + pushed_string_list = ss;
126 if (wl == &parse_string_error)
129 *** ../bash-5.2/patchlevel.h 2020-06-22 14:51:03.000000000 -0400
130 --- patchlevel.h 2020-10-01 11:01:28.000000000 -0400
133 looks for to find the patch level (for the sccs version string). */
135 ! #define PATCHLEVEL 33
137 #endif /* _PATCHLEVEL_H_ */
139 looks for to find the patch level (for the sccs version string). */
141 ! #define PATCHLEVEL 34
143 #endif /* _PATCHLEVEL_H_ */