7 Bug-Reported-by: Kerin Millar <kfm@plushkava.net>
8 Bug-Reference-ID: <20221002095107.89561bc811e549b55644df11@plushkava.net>
9 Bug-Reference-URL: https://lists.gnu.org/archive/html/bug-bash/2022-10/msg00001.html
13 When running in bash compatibility mode, nested command substitutions can
14 leave the `extglob' option enabled.
16 Patch (apply with `patch -p0'):
18 *** /fs1/chet/scratch/bash-5.2.12/builtins/shopt.def 2022-11-07 10:31:42.000000000 -0500
19 --- builtins/shopt.def 2022-10-14 09:30:11.000000000 -0400
25 + #if defined (EXTENDED_GLOB)
26 + int extglob_flag = EXTGLOB_DEFAULT;
27 + static int shopt_set_extglob PARAMS((char *, int));
30 int expaliases_flag = 0;
31 static int shopt_set_expaliases PARAMS((char *, int));
35 #if defined (EXTENDED_GLOB)
36 ! { "extglob", &extended_glob, (shopt_set_func_t *)NULL },
38 { "extquote", &extended_quote, (shopt_set_func_t *)NULL },
41 #if defined (EXTENDED_GLOB)
42 ! { "extglob", &extglob_flag, shopt_set_extglob },
44 { "extquote", &extended_quote, (shopt_set_func_t *)NULL },
48 #if defined (EXTENDED_GLOB)
49 ! extended_glob = EXTGLOB_DEFAULT;
54 #if defined (EXTENDED_GLOB)
55 ! extended_glob = extglob_flag = EXTGLOB_DEFAULT;
63 + #if defined (EXTENDED_GLOB)
65 + shopt_set_extglob (option_name, mode)
69 + extended_glob = extglob_flag;
74 #if defined (READLINE)
76 *** /fs1/chet/scratch/bash-5.2.12/builtins/common.h 2022-11-07 10:31:42.000000000 -0500
77 --- builtins/common.h 2022-10-14 09:29:25.000000000 -0400
83 + #if defined (EXTENDED_GLOB)
84 + extern int extglob_flag;
87 extern int expaliases_flag;
89 *** /fs1/chet/scratch/bash-5.2.12/execute_cmd.c 2022-11-07 10:31:42.000000000 -0500
90 --- execute_cmd.c 2022-11-02 16:32:12.000000000 -0400
93 #endif /* COND_REGEXP */
98 result = binary_test (cond->op->word, arg1, arg2, TEST_PATMATCH|TEST_ARITHEXP|TEST_LOCALE)
101 ! extended_glob = oe;
105 #endif /* COND_REGEXP */
108 result = binary_test (cond->op->word, arg1, arg2, TEST_PATMATCH|TEST_ARITHEXP|TEST_LOCALE)
111 ! extended_glob = extglob_flag;
114 *** /fs1/chet/scratch/bash-5.2.9/parse.y 2022-11-07 10:31:47.000000000 -0500
115 --- parse.y 2022-11-14 11:27:22.000000000 -0500
119 #if defined (EXTENDED_GLOB)
120 ! extern int extended_glob;
125 #if defined (EXTENDED_GLOB)
126 ! extern int extended_glob, extglob_flag;
131 /* Reset to global value of extended glob */
132 if (parser_state & (PST_EXTPAT|PST_CMDSUBST))
133 ! extended_glob = global_extglob;
135 if (parser_state & (PST_CMDSUBST|PST_STRING))
137 /* Reset to global value of extended glob */
138 if (parser_state & (PST_EXTPAT|PST_CMDSUBST))
139 ! extended_glob = extglob_flag;
141 if (parser_state & (PST_CMDSUBST|PST_STRING))
144 #if defined (EXTENDED_GLOB)
145 /* If (parser_state & PST_EXTPAT), we're parsing an extended pattern for a
146 ! conditional command and have already set global_extglob appropriately. */
147 if (shell_compatibility_level <= 51 && was_extpat == 0)
149 ! local_extglob = global_extglob = extended_glob;
153 #if defined (EXTENDED_GLOB)
154 /* If (parser_state & PST_EXTPAT), we're parsing an extended pattern for a
155 ! conditional command and have already set extended_glob appropriately. */
156 if (shell_compatibility_level <= 51 && was_extpat == 0)
158 ! local_extglob = extended_glob;
163 sh_parser_state_t ps;
164 sh_input_line_state_t ls;
165 ! int orig_ind, nc, sflags, start_lineno;
166 char *ret, *ep, *ostring;
169 sh_parser_state_t ps;
170 sh_input_line_state_t ls;
171 ! int orig_ind, nc, sflags, start_lineno, local_extglob;
172 char *ret, *ep, *ostring;
177 #if defined (EXTENDED_GLOB)
178 ! global_extglob = extended_glob; /* for reset_parser() */
183 #if defined (EXTENDED_GLOB)
184 ! local_extglob = extended_glob;
190 restore_parser_state (&ps);
192 + #if defined (EXTENDED_GLOB)
193 + extended_glob = local_extglob;
202 + #if defined (EXTENDED_GLOB)
203 local_extglob = extended_glob;
204 if (parser_state & PST_EXTPAT)
207 tok = read_token (READ);
208 + #if defined (EXTENDED_GLOB)
209 if (parser_state & PST_EXTPAT)
210 extended_glob = local_extglob;
212 parser_state &= ~(PST_REGEXP|PST_EXTPAT);
218 - global_extglob = extended_glob;
220 return (make_cond_command (cexp));
222 *** y.tab.c.save 2022-11-07 10:31:47.000000000 -0500
223 --- y.tab.c 2022-11-18 15:58:03.000000000 -0500
227 #if defined (EXTENDED_GLOB)
228 ! extern int extended_glob;
233 #if defined (EXTENDED_GLOB)
234 ! extern int extended_glob, extglob_flag;
239 /* Reset to global value of extended glob */
240 if (parser_state & (PST_EXTPAT|PST_CMDSUBST))
241 ! extended_glob = global_extglob;
243 if (parser_state & (PST_CMDSUBST|PST_STRING))
245 /* Reset to global value of extended glob */
246 if (parser_state & (PST_EXTPAT|PST_CMDSUBST))
247 ! extended_glob = extglob_flag;
249 if (parser_state & (PST_CMDSUBST|PST_STRING))
252 #if defined (EXTENDED_GLOB)
253 /* If (parser_state & PST_EXTPAT), we're parsing an extended pattern for a
254 ! conditional command and have already set global_extglob appropriately. */
255 if (shell_compatibility_level <= 51 && was_extpat == 0)
257 ! local_extglob = global_extglob = extended_glob;
261 #if defined (EXTENDED_GLOB)
262 /* If (parser_state & PST_EXTPAT), we're parsing an extended pattern for a
263 ! conditional command and have already set extended_glob appropriately. */
264 if (shell_compatibility_level <= 51 && was_extpat == 0)
266 ! local_extglob = extended_glob;
271 sh_parser_state_t ps;
272 sh_input_line_state_t ls;
273 ! int orig_ind, nc, sflags, start_lineno;
274 char *ret, *ep, *ostring;
277 sh_parser_state_t ps;
278 sh_input_line_state_t ls;
279 ! int orig_ind, nc, sflags, start_lineno, local_extglob;
280 char *ret, *ep, *ostring;
285 #if defined (EXTENDED_GLOB)
286 ! global_extglob = extended_glob; /* for reset_parser() */
291 #if defined (EXTENDED_GLOB)
292 ! local_extglob = extended_glob;
298 restore_parser_state (&ps);
300 + #if defined (EXTENDED_GLOB)
301 + extended_glob = local_extglob;
310 + #if defined (EXTENDED_GLOB)
311 local_extglob = extended_glob;
312 if (parser_state & PST_EXTPAT)
315 tok = read_token (READ);
316 + #if defined (EXTENDED_GLOB)
317 if (parser_state & PST_EXTPAT)
318 extended_glob = local_extglob;
320 parser_state &= ~(PST_REGEXP|PST_EXTPAT);
326 - global_extglob = extended_glob;
328 return (make_cond_command (cexp));
330 *** ../bash-5.2/patchlevel.h 2020-06-22 14:51:03.000000000 -0400
331 --- patchlevel.h 2020-10-01 11:01:28.000000000 -0400
334 looks for to find the patch level (for the sccs version string). */
336 ! #define PATCHLEVEL 11
338 #endif /* _PATCHLEVEL_H_ */
340 looks for to find the patch level (for the sccs version string). */
342 ! #define PATCHLEVEL 12
344 #endif /* _PATCHLEVEL_H_ */