summaryrefslogtreecommitdiffstats
path: root/source/a/bash/bash-5.2-patches/bash52-012
blob: 2791542c96e073bde45f5b1c4350088d02aee5b4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
			     BASH PATCH REPORT
			     =================

Bash-Release:	5.2
Patch-ID:	bash52-012

Bug-Reported-by:	Kerin Millar <kfm@plushkava.net>
Bug-Reference-ID:	<20221002095107.89561bc811e549b55644df11@plushkava.net>
Bug-Reference-URL:	https://lists.gnu.org/archive/html/bug-bash/2022-10/msg00001.html

Bug-Description:

When running in bash compatibility mode, nested command substitutions can
leave the `extglob' option enabled.

Patch (apply with `patch -p0'):

*** /fs1/chet/scratch/bash-5.2.12/builtins/shopt.def	2022-11-07 10:31:42.000000000 -0500
--- builtins/shopt.def	2022-10-14 09:30:11.000000000 -0400
***************
*** 150,153 ****
--- 150,158 ----
  #endif
  
+ #if defined (EXTENDED_GLOB)
+ int extglob_flag = EXTGLOB_DEFAULT;
+ static int shopt_set_extglob PARAMS((char *, int));
+ #endif
+ 
  int expaliases_flag = 0;
  static int shopt_set_expaliases PARAMS((char *, int));
***************
*** 207,211 ****
  #endif
  #if defined (EXTENDED_GLOB)
!   { "extglob", &extended_glob, (shopt_set_func_t *)NULL },
  #endif
    { "extquote", &extended_quote, (shopt_set_func_t *)NULL },
--- 212,216 ----
  #endif
  #if defined (EXTENDED_GLOB)
!   { "extglob", &extglob_flag, shopt_set_extglob },
  #endif
    { "extquote", &extended_quote, (shopt_set_func_t *)NULL },
***************
*** 378,382 ****
  
  #if defined (EXTENDED_GLOB)
!   extended_glob = EXTGLOB_DEFAULT;
  #endif
  
--- 383,387 ----
  
  #if defined (EXTENDED_GLOB)
!   extended_glob = extglob_flag = EXTGLOB_DEFAULT;
  #endif
  
***************
*** 644,647 ****
--- 649,663 ----
  }
  
+ #if defined (EXTENDED_GLOB)
+ static int
+ shopt_set_extglob (option_name, mode)
+      char *option_name;
+      int mode;
+ {
+   extended_glob = extglob_flag;
+   return 0;
+ }
+ #endif
+ 
  #if defined (READLINE)
  static int
*** /fs1/chet/scratch/bash-5.2.12/builtins/common.h	2022-11-07 10:31:42.000000000 -0500
--- builtins/common.h	2022-10-14 09:29:25.000000000 -0400
***************
*** 258,261 ****
--- 258,265 ----
  #endif
  
+ #if defined (EXTENDED_GLOB)
+ extern int extglob_flag;
+ #endif
+ 
  extern int expaliases_flag;
  
*** /fs1/chet/scratch/bash-5.2.12/execute_cmd.c	2022-11-07 10:31:42.000000000 -0500
--- execute_cmd.c	2022-11-02 16:32:12.000000000 -0400
***************
*** 3991,4001 ****
  #endif /* COND_REGEXP */
  	{
- 	  int oe;
- 	  oe = extended_glob;
  	  extended_glob = 1;
  	  result = binary_test (cond->op->word, arg1, arg2, TEST_PATMATCH|TEST_ARITHEXP|TEST_LOCALE)
  				  ? EXECUTION_SUCCESS
  				  : EXECUTION_FAILURE;
! 	  extended_glob = oe;
  	}
        if (arg1 != nullstr)
--- 4015,4023 ----
  #endif /* COND_REGEXP */
  	{
  	  extended_glob = 1;
  	  result = binary_test (cond->op->word, arg1, arg2, TEST_PATMATCH|TEST_ARITHEXP|TEST_LOCALE)
  				  ? EXECUTION_SUCCESS
  				  : EXECUTION_FAILURE;
! 	  extended_glob = extglob_flag;
  	}
        if (arg1 != nullstr)
*** /fs1/chet/scratch/bash-5.2.9/parse.y	2022-11-07 10:31:47.000000000 -0500
--- parse.y	2022-11-14 11:27:22.000000000 -0500
***************
*** 126,130 ****
  
  #if defined (EXTENDED_GLOB)
! extern int extended_glob;
  #endif
  
--- 126,130 ----
  
  #if defined (EXTENDED_GLOB)
! extern int extended_glob, extglob_flag;
  #endif
  
***************
*** 3305,3309 ****
    /* Reset to global value of extended glob */
    if (parser_state & (PST_EXTPAT|PST_CMDSUBST))
!     extended_glob = global_extglob;
  #endif
    if (parser_state & (PST_CMDSUBST|PST_STRING))
--- 3321,3325 ----
    /* Reset to global value of extended glob */
    if (parser_state & (PST_EXTPAT|PST_CMDSUBST))
!     extended_glob = extglob_flag;
  #endif
    if (parser_state & (PST_CMDSUBST|PST_STRING))
***************
*** 4125,4132 ****
  #if defined (EXTENDED_GLOB)
    /* If (parser_state & PST_EXTPAT), we're parsing an extended pattern for a
!      conditional command and have already set global_extglob appropriately. */
    if (shell_compatibility_level <= 51 && was_extpat == 0)
      {
!       local_extglob = global_extglob = extended_glob;
        extended_glob = 1;
      }
--- 4143,4150 ----
  #if defined (EXTENDED_GLOB)
    /* If (parser_state & PST_EXTPAT), we're parsing an extended pattern for a
!      conditional command and have already set extended_glob appropriately. */
    if (shell_compatibility_level <= 51 && was_extpat == 0)
      {
!       local_extglob = extended_glob;
        extended_glob = 1;
      }
***************
*** 4236,4240 ****
    sh_parser_state_t ps;
    sh_input_line_state_t ls;
!   int orig_ind, nc, sflags, start_lineno;
    char *ret, *ep, *ostring;
  
--- 4256,4260 ----
    sh_parser_state_t ps;
    sh_input_line_state_t ls;
!   int orig_ind, nc, sflags, start_lineno, local_extglob;
    char *ret, *ep, *ostring;
  
***************
*** 4279,4283 ****
    expand_aliases = 0;
  #if defined (EXTENDED_GLOB)
!   global_extglob = extended_glob;		/* for reset_parser() */
  #endif
  
--- 4299,4303 ----
    expand_aliases = 0;
  #if defined (EXTENDED_GLOB)
!   local_extglob = extended_glob;
  #endif
  
***************
*** 4297,4300 ****
--- 4317,4323 ----
    restore_parser_state (&ps);
  
+ #if defined (EXTENDED_GLOB)
+   extended_glob = local_extglob;
+ #endif
    token_to_read = 0;
  
***************
*** 4732,4741 ****
--- 4755,4768 ----
  
        /* rhs */
+ #if defined (EXTENDED_GLOB)
        local_extglob = extended_glob;
        if (parser_state & PST_EXTPAT)
  	extended_glob = 1;
+ #endif
        tok = read_token (READ);
+ #if defined (EXTENDED_GLOB)
        if (parser_state & PST_EXTPAT)
  	extended_glob = local_extglob;
+ #endif
        parser_state &= ~(PST_REGEXP|PST_EXTPAT);
  
***************
*** 4784,4788 ****
    COND_COM *cexp;
  
-   global_extglob = extended_glob;
    cexp = cond_expr ();
    return (make_cond_command (cexp));
--- 4811,4814 ----
*** y.tab.c.save	2022-11-07 10:31:47.000000000 -0500
--- y.tab.c	2022-11-18 15:58:03.000000000 -0500
***************
*** 176,180 ****
  
  #if defined (EXTENDED_GLOB)
! extern int extended_glob;
  #endif
  
--- 176,180 ----
  
  #if defined (EXTENDED_GLOB)
! extern int extended_glob, extglob_flag;
  #endif
  
***************
*** 5616,5620 ****
    /* Reset to global value of extended glob */
    if (parser_state & (PST_EXTPAT|PST_CMDSUBST))
!     extended_glob = global_extglob;
  #endif
    if (parser_state & (PST_CMDSUBST|PST_STRING))
--- 5616,5620 ----
    /* Reset to global value of extended glob */
    if (parser_state & (PST_EXTPAT|PST_CMDSUBST))
!     extended_glob = extglob_flag;
  #endif
    if (parser_state & (PST_CMDSUBST|PST_STRING))
***************
*** 6436,6443 ****
  #if defined (EXTENDED_GLOB)
    /* If (parser_state & PST_EXTPAT), we're parsing an extended pattern for a
!      conditional command and have already set global_extglob appropriately. */
    if (shell_compatibility_level <= 51 && was_extpat == 0)
      {
!       local_extglob = global_extglob = extended_glob;
        extended_glob = 1;
      }
--- 6436,6443 ----
  #if defined (EXTENDED_GLOB)
    /* If (parser_state & PST_EXTPAT), we're parsing an extended pattern for a
!      conditional command and have already set extended_glob appropriately. */
    if (shell_compatibility_level <= 51 && was_extpat == 0)
      {
!       local_extglob = extended_glob;
        extended_glob = 1;
      }
***************
*** 6547,6551 ****
    sh_parser_state_t ps;
    sh_input_line_state_t ls;
!   int orig_ind, nc, sflags, start_lineno;
    char *ret, *ep, *ostring;
  
--- 6547,6551 ----
    sh_parser_state_t ps;
    sh_input_line_state_t ls;
!   int orig_ind, nc, sflags, start_lineno, local_extglob;
    char *ret, *ep, *ostring;
  
***************
*** 6590,6594 ****
    expand_aliases = 0;
  #if defined (EXTENDED_GLOB)
!   global_extglob = extended_glob;		/* for reset_parser() */
  #endif
  
--- 6590,6594 ----
    expand_aliases = 0;
  #if defined (EXTENDED_GLOB)
!   local_extglob = extended_glob;
  #endif
  
***************
*** 6608,6611 ****
--- 6608,6614 ----
    restore_parser_state (&ps);
  
+ #if defined (EXTENDED_GLOB)
+   extended_glob = local_extglob;
+ #endif
    token_to_read = 0;
  
***************
*** 7043,7052 ****
--- 7046,7059 ----
  
        /* rhs */
+ #if defined (EXTENDED_GLOB)
        local_extglob = extended_glob;
        if (parser_state & PST_EXTPAT)
  	extended_glob = 1;
+ #endif
        tok = read_token (READ);
+ #if defined (EXTENDED_GLOB)
        if (parser_state & PST_EXTPAT)
  	extended_glob = local_extglob;
+ #endif
        parser_state &= ~(PST_REGEXP|PST_EXTPAT);
  
***************
*** 7095,7099 ****
    COND_COM *cexp;
  
-   global_extglob = extended_glob;
    cexp = cond_expr ();
    return (make_cond_command (cexp));
--- 7102,7105 ----
*** ../bash-5.2/patchlevel.h	2020-06-22 14:51:03.000000000 -0400
--- patchlevel.h	2020-10-01 11:01:28.000000000 -0400
***************
*** 26,30 ****
     looks for to find the patch level (for the sccs version string). */
  
! #define PATCHLEVEL 11
  
  #endif /* _PATCHLEVEL_H_ */
--- 26,30 ----
     looks for to find the patch level (for the sccs version string). */
  
! #define PATCHLEVEL 12
  
  #endif /* _PATCHLEVEL_H_ */