source: patches/bash-4.2-branch_update-3.patch@ d01d386

clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since d01d386 was d01d386, checked in by Jonathan Norman <jon@…>, 13 years ago

Updated Bash update to -3

  • Property mode set to 100644
File size: 22.3 KB
RevLine 
[d01d386]1Submitted By: Jonathan Norman (jonathan at bluesquarelinux dot co dot uk)
2Date: 15-02-2012
[b36b9f9]3Initial Package Version: 4.2
4Origin: Upstream
[b369f3c]5Upstream Status: Applied
[d01d386]6Description: Contains all upstream patches up to 4.2-020
[b36b9f9]7
[d01d386]8diff -Naur bash-4.2.orig/assoc.c bash-4.2/assoc.c
9--- bash-4.2.orig/assoc.c 2009-08-06 00:19:40.000000000 +0000
10+++ bash-4.2/assoc.c 2012-02-15 17:04:56.844640185 +0000
11@@ -77,6 +77,11 @@
12 b = hash_search (key, hash, HASH_CREATE);
13 if (b == 0)
14 return -1;
15+ /* If we are overwriting an existing element's value, we're not going to
16+ use the key. Nothing in the array assignment code path frees the key
17+ string, so we can free it here to avoid a memory leak. */
18+ if (b->key != key)
19+ free (key);
20 FREE (b->data);
21 b->data = value ? savestring (value) : (char *)0;
22 return (0);
23diff -Naur bash-4.2.orig/builtins/declare.def bash-4.2/builtins/declare.def
24--- bash-4.2.orig/builtins/declare.def 2010-05-30 22:25:21.000000000 +0000
25+++ bash-4.2/builtins/declare.def 2012-02-15 17:05:08.352946800 +0000
26@@ -513,6 +513,11 @@
27 *subscript_start = '['; /* ] */
28 var = assign_array_element (name, value, 0); /* XXX - not aflags */
29 *subscript_start = '\0';
30+ if (var == 0) /* some kind of assignment error */
31+ {
32+ assign_error++;
33+ NEXT_VARIABLE ();
34+ }
35 }
36 else if (simple_array_assign)
37 {
[b369f3c]38diff -Naur bash-4.2.orig/builtins/fc.def bash-4.2/builtins/fc.def
39--- bash-4.2.orig/builtins/fc.def 2010-05-30 22:25:38.000000000 +0000
[d01d386]40+++ bash-4.2/builtins/fc.def 2012-02-15 17:04:54.028565156 +0000
[b369f3c]41@@ -304,7 +304,7 @@
42 last_hist = i - rh - hist_last_line_added;
43
44 /* XXX */
45- if (saved_command_line_count > 0 && i == last_hist && hlist[last_hist] == 0)
46+ if (i == last_hist && hlist[last_hist] == 0)
47 while (last_hist >= 0 && hlist[last_hist] == 0)
48 last_hist--;
49 if (last_hist < 0)
50@@ -475,7 +475,7 @@
51 HIST_ENTRY **hlist;
52 {
53 int sign, n, clen, rh;
54- register int i, j;
55+ register int i, j, last_hist;
56 register char *s;
57
58 sign = 1;
59@@ -495,7 +495,15 @@
60 has been enabled (interactive or not) should use it in the last_hist
61 calculation as if it were on. */
62 rh = remember_on_history || ((subshell_environment & SUBSHELL_COMSUB) && enable_history_list);
63- i -= rh + hist_last_line_added;
64+ last_hist = i - rh - hist_last_line_added;
65+
66+ if (i == last_hist && hlist[last_hist] == 0)
67+ while (last_hist >= 0 && hlist[last_hist] == 0)
68+ last_hist--;
69+ if (last_hist < 0)
70+ return (-1);
71+
72+ i = last_hist;
73
74 /* No specification defaults to most recent command. */
75 if (command == NULL)
[b36b9f9]76diff -Naur bash-4.2.orig/builtins/printf.def bash-4.2/builtins/printf.def
[b369f3c]77--- bash-4.2.orig/builtins/printf.def 2010-11-23 15:02:55.000000000 +0000
[d01d386]78+++ bash-4.2/builtins/printf.def 2012-02-15 17:04:48.484417444 +0000
[b36b9f9]79@@ -465,6 +465,9 @@
80 secs = shell_start_time; /* roughly $SECONDS */
81 else
82 secs = arg;
83+#if defined (HAVE_TZSET)
84+ sv_tz ("TZ"); /* XXX -- just make sure */
85+#endif
86 tm = localtime (&secs);
87 n = strftime (timebuf, sizeof (timebuf), timefmt, tm);
88 free (timefmt);
[d01d386]89diff -Naur bash-4.2.orig/builtins/read.def bash-4.2/builtins/read.def
90--- bash-4.2.orig/builtins/read.def 2011-01-04 16:43:36.000000000 +0000
91+++ bash-4.2/builtins/read.def 2012-02-15 17:05:05.540871876 +0000
92@@ -642,6 +642,12 @@
93 xfree (input_string);
94 return EXECUTION_FAILURE; /* readonly or noassign */
95 }
96+ if (assoc_p (var))
97+ {
98+ builtin_error (_("%s: cannot convert associative to indexed array"), arrayname);
99+ xfree (input_string);
100+ return EXECUTION_FAILURE; /* existing associative array */
101+ }
102 array_flush (array_cell (var));
103
104 alist = list_string (input_string, ifs_chars, 0);
105diff -Naur bash-4.2.orig/execute_cmd.c bash-4.2/execute_cmd.c
106--- bash-4.2.orig/execute_cmd.c 2011-02-09 22:32:25.000000000 +0000
107+++ bash-4.2/execute_cmd.c 2012-02-15 17:05:06.964909819 +0000
108@@ -2196,6 +2196,7 @@
109 if (ignore_return && cmd)
110 cmd->flags |= CMD_IGNORE_RETURN;
111
112+#if defined (JOB_CONTROL)
113 lastpipe_flag = 0;
114 begin_unwind_frame ("lastpipe-exec");
115 lstdin = -1;
116@@ -2215,15 +2216,19 @@
117 lastpipe_jid = stop_pipeline (0, (COMMAND *)NULL); /* XXX */
118 add_unwind_protect (lastpipe_cleanup, lastpipe_jid);
119 }
120- cmd->flags |= CMD_LASTPIPE;
121+ if (cmd)
122+ cmd->flags |= CMD_LASTPIPE;
123 }
124 if (prev >= 0)
125 add_unwind_protect (close, prev);
126+#endif
127
128 exec_result = execute_command_internal (cmd, asynchronous, prev, pipe_out, fds_to_close);
129
130+#if defined (JOB_CONTROL)
131 if (lstdin > 0)
132 restore_stdin (lstdin);
133+#endif
134
135 if (prev >= 0)
136 close (prev);
137diff -Naur bash-4.2.orig/expr.c bash-4.2/expr.c
138--- bash-4.2.orig/expr.c 2010-12-21 16:12:13.000000000 +0000
139+++ bash-4.2/expr.c 2012-02-15 17:05:02.424788857 +0000
140@@ -476,19 +476,23 @@
141
142 if (special)
143 {
144+ if ((op == DIV || op == MOD) && value == 0)
145+ {
146+ if (noeval == 0)
147+ evalerror (_("division by 0"));
148+ else
149+ value = 1;
150+ }
151+
152 switch (op)
153 {
154 case MUL:
155 lvalue *= value;
156 break;
157 case DIV:
158- if (value == 0)
159- evalerror (_("division by 0"));
160 lvalue /= value;
161 break;
162 case MOD:
163- if (value == 0)
164- evalerror (_("division by 0"));
165 lvalue %= value;
166 break;
167 case PLUS:
168@@ -804,7 +808,12 @@
169 val2 = exppower ();
170
171 if (((op == DIV) || (op == MOD)) && (val2 == 0))
172- evalerror (_("division by 0"));
173+ {
174+ if (noeval == 0)
175+ evalerror (_("division by 0"));
176+ else
177+ val2 = 1;
178+ }
179
180 if (op == MUL)
181 val1 *= val2;
[b36b9f9]182diff -Naur bash-4.2.orig/lib/glob/gmisc.c bash-4.2/lib/glob/gmisc.c
[b369f3c]183--- bash-4.2.orig/lib/glob/gmisc.c 2011-02-05 21:11:17.000000000 +0000
[d01d386]184+++ bash-4.2/lib/glob/gmisc.c 2012-02-15 17:04:45.660342203 +0000
[b36b9f9]185@@ -77,8 +77,8 @@
186 wchar_t *wpat;
187 size_t wmax;
188 {
189- wchar_t wc, *wbrack;
190- int matlen, t, in_cclass, in_collsym, in_equiv;
191+ wchar_t wc;
192+ int matlen, bracklen, t, in_cclass, in_collsym, in_equiv;
193
194 if (*wpat == 0)
195 return (0);
196@@ -118,58 +118,80 @@
197 break;
198 case L'[':
199 /* scan for ending `]', skipping over embedded [:...:] */
200- wbrack = wpat;
201+ bracklen = 1;
202 wc = *wpat++;
203 do
204 {
205 if (wc == 0)
206 {
207- matlen += wpat - wbrack - 1; /* incremented below */
208- break;
209+ wpat--; /* back up to NUL */
210+ matlen += bracklen;
211+ goto bad_bracket;
212 }
213 else if (wc == L'\\')
214 {
215- wc = *wpat++;
216- if (*wpat == 0)
217- break;
218+ /* *wpat == backslash-escaped character */
219+ bracklen++;
220+ /* If the backslash or backslash-escape ends the string,
221+ bail. The ++wpat skips over the backslash escape */
222+ if (*wpat == 0 || *++wpat == 0)
223+ {
224+ matlen += bracklen;
225+ goto bad_bracket;
226+ }
227 }
228 else if (wc == L'[' && *wpat == L':') /* character class */
229 {
230 wpat++;
231+ bracklen++;
232 in_cclass = 1;
233 }
234 else if (in_cclass && wc == L':' && *wpat == L']')
235 {
236 wpat++;
237+ bracklen++;
238 in_cclass = 0;
239 }
240 else if (wc == L'[' && *wpat == L'.') /* collating symbol */
241 {
242 wpat++;
243+ bracklen++;
244 if (*wpat == L']') /* right bracket can appear as collating symbol */
245- wpat++;
246+ {
247+ wpat++;
248+ bracklen++;
249+ }
250 in_collsym = 1;
251 }
252 else if (in_collsym && wc == L'.' && *wpat == L']')
253 {
254 wpat++;
255+ bracklen++;
256 in_collsym = 0;
257 }
258 else if (wc == L'[' && *wpat == L'=') /* equivalence class */
259 {
260 wpat++;
261+ bracklen++;
262 if (*wpat == L']') /* right bracket can appear as equivalence class */
263- wpat++;
264+ {
265+ wpat++;
266+ bracklen++;
267+ }
268 in_equiv = 1;
269 }
270 else if (in_equiv && wc == L'=' && *wpat == L']')
271 {
272 wpat++;
273+ bracklen++;
274 in_equiv = 0;
275 }
276+ else
277+ bracklen++;
278 }
279 while ((wc = *wpat++) != L']');
280 matlen++; /* bracket expression can only match one char */
281+bad_bracket:
282 break;
283 }
284 }
285@@ -213,8 +235,8 @@
286 char *pat;
287 size_t max;
288 {
289- char c, *brack;
290- int matlen, t, in_cclass, in_collsym, in_equiv;
291+ char c;
292+ int matlen, bracklen, t, in_cclass, in_collsym, in_equiv;
293
294 if (*pat == 0)
295 return (0);
296@@ -254,58 +276,80 @@
297 break;
298 case '[':
299 /* scan for ending `]', skipping over embedded [:...:] */
300- brack = pat;
301+ bracklen = 1;
302 c = *pat++;
303 do
304 {
305 if (c == 0)
306 {
307- matlen += pat - brack - 1; /* incremented below */
308- break;
309+ pat--; /* back up to NUL */
310+ matlen += bracklen;
311+ goto bad_bracket;
312 }
313 else if (c == '\\')
314 {
315- c = *pat++;
316- if (*pat == 0)
317- break;
318+ /* *pat == backslash-escaped character */
319+ bracklen++;
320+ /* If the backslash or backslash-escape ends the string,
321+ bail. The ++pat skips over the backslash escape */
322+ if (*pat == 0 || *++pat == 0)
323+ {
324+ matlen += bracklen;
325+ goto bad_bracket;
326+ }
327 }
328 else if (c == '[' && *pat == ':') /* character class */
329 {
330 pat++;
331+ bracklen++;
332 in_cclass = 1;
333 }
334 else if (in_cclass && c == ':' && *pat == ']')
335 {
336 pat++;
337+ bracklen++;
338 in_cclass = 0;
339 }
340 else if (c == '[' && *pat == '.') /* collating symbol */
341 {
342 pat++;
343+ bracklen++;
344 if (*pat == ']') /* right bracket can appear as collating symbol */
345- pat++;
346+ {
347+ pat++;
348+ bracklen++;
349+ }
350 in_collsym = 1;
351 }
352 else if (in_collsym && c == '.' && *pat == ']')
353 {
354 pat++;
355+ bracklen++;
356 in_collsym = 0;
357 }
358 else if (c == '[' && *pat == '=') /* equivalence class */
359 {
360 pat++;
361+ bracklen++;
362 if (*pat == ']') /* right bracket can appear as equivalence class */
363- pat++;
364+ {
365+ pat++;
366+ bracklen++;
367+ }
368 in_equiv = 1;
369 }
370 else if (in_equiv && c == '=' && *pat == ']')
371 {
372 pat++;
373+ bracklen++;
374 in_equiv = 0;
375 }
376+ else
377+ bracklen++;
378 }
379 while ((c = *pat++) != ']');
380 matlen++; /* bracket expression can only match one char */
381+bad_bracket:
382 break;
383 }
384 }
385diff -Naur bash-4.2.orig/lib/readline/callback.c bash-4.2/lib/readline/callback.c
[b369f3c]386--- bash-4.2.orig/lib/readline/callback.c 2010-06-06 16:18:58.000000000 +0000
[d01d386]387+++ bash-4.2/lib/readline/callback.c 2012-02-15 17:04:43.812292965 +0000
[b36b9f9]388@@ -148,6 +148,9 @@
389 eof = _rl_vi_domove_callback (_rl_vimvcxt);
390 /* Should handle everything, including cleanup, numeric arguments,
391 and turning off RL_STATE_VIMOTION */
392+ if (RL_ISSTATE (RL_STATE_NUMERICARG) == 0)
393+ _rl_internal_char_cleanup ();
394+
395 return;
396 }
397 #endif
398diff -Naur bash-4.2.orig/lib/readline/vi_mode.c bash-4.2/lib/readline/vi_mode.c
[b369f3c]399--- bash-4.2.orig/lib/readline/vi_mode.c 2010-11-21 00:51:39.000000000 +0000
[d01d386]400+++ bash-4.2/lib/readline/vi_mode.c 2012-02-15 17:04:43.812292965 +0000
[b36b9f9]401@@ -1114,7 +1114,7 @@
402 rl_beg_of_line (1, c);
403 _rl_vi_last_motion = c;
404 RL_UNSETSTATE (RL_STATE_VIMOTION);
405- return (0);
406+ return (vidomove_dispatch (m));
407 }
408 #if defined (READLINE_CALLBACKS)
409 /* XXX - these need to handle rl_universal_argument bindings */
410diff -Naur bash-4.2.orig/parse.y bash-4.2/parse.y
[b369f3c]411--- bash-4.2.orig/parse.y 2011-01-02 20:48:11.000000000 +0000
[d01d386]412+++ bash-4.2/parse.y 2012-02-15 17:05:04.008831060 +0000
413@@ -2499,7 +2499,7 @@
414 We do this only if it is time to do so. Notice that only here
415 is the mail alarm reset; nothing takes place in check_mail ()
416 except the checking of mail. Please don't change this. */
417- if (prompt_is_ps1 && time_to_check_mail ())
418+ if (prompt_is_ps1 && parse_and_execute_level == 0 && time_to_check_mail ())
419 {
420 check_mail ();
421 reset_mail_timer ();
422@@ -3842,6 +3842,7 @@
423 int flags;
424 {
425 sh_parser_state_t ps;
426+ sh_input_line_state_t ls;
427 int orig_ind, nc, sflags;
428 char *ret, *s, *ep, *ostring;
429
430@@ -3849,10 +3850,12 @@
431 orig_ind = *indp;
432 ostring = string;
433
434+/*itrace("xparse_dolparen: size = %d shell_input_line = `%s'", shell_input_line_size, shell_input_line);*/
435 sflags = SEVAL_NONINT|SEVAL_NOHIST|SEVAL_NOFREE;
436 if (flags & SX_NOLONGJMP)
437 sflags |= SEVAL_NOLONGJMP;
438 save_parser_state (&ps);
439+ save_input_line_state (&ls);
440
441 /*(*/
442 parser_state |= PST_CMDSUBST|PST_EOFTOKEN; /* allow instant ')' */ /*(*/
443@@ -3861,6 +3864,8 @@
444
445 restore_parser_state (&ps);
446 reset_parser ();
447+ /* reset_parser clears shell_input_line and associated variables */
448+ restore_input_line_state (&ls);
449 if (interactive)
450 token_to_read = 0;
451
452@@ -5135,6 +5140,9 @@
[b36b9f9]453 case 'A':
454 /* Make the current time/date into a string. */
455 (void) time (&the_time);
456+#if defined (HAVE_TZSET)
457+ sv_tz ("TZ"); /* XXX -- just make sure */
458+#endif
459 tm = localtime (&the_time);
460
461 if (c == 'd')
[d01d386]462@@ -5905,6 +5913,12 @@
463 ps->expand_aliases = expand_aliases;
464 ps->echo_input_at_read = echo_input_at_read;
465
466+ ps->token = token;
467+ ps->token_buffer_size = token_buffer_size;
468+ /* Force reallocation on next call to read_token_word */
469+ token = 0;
470+ token_buffer_size = 0;
471+
472 return (ps);
473 }
474
475@@ -5946,6 +5960,42 @@
476
477 expand_aliases = ps->expand_aliases;
478 echo_input_at_read = ps->echo_input_at_read;
479+
480+ FREE (token);
481+ token = ps->token;
482+ token_buffer_size = ps->token_buffer_size;
483+}
484+
485+sh_input_line_state_t *
486+save_input_line_state (ls)
487+ sh_input_line_state_t *ls;
488+{
489+ if (ls == 0)
490+ ls = (sh_input_line_state_t *)xmalloc (sizeof (sh_input_line_state_t));
491+ if (ls == 0)
492+ return ((sh_input_line_state_t *)NULL);
493+
494+ ls->input_line = shell_input_line;
495+ ls->input_line_size = shell_input_line_size;
496+ ls->input_line_len = shell_input_line_len;
497+ ls->input_line_index = shell_input_line_index;
498+
499+ /* force reallocation */
500+ shell_input_line = 0;
501+ shell_input_line_size = shell_input_line_len = shell_input_line_index = 0;
502+}
503+
504+void
505+restore_input_line_state (ls)
506+ sh_input_line_state_t *ls;
507+{
508+ FREE (shell_input_line);
509+ shell_input_line = ls->input_line;
510+ shell_input_line_size = ls->input_line_size;
511+ shell_input_line_len = ls->input_line_len;
512+ shell_input_line_index = ls->input_line_index;
513+
514+ set_line_mbstate ();
515 }
516
517 /************************************************
[b36b9f9]518diff -Naur bash-4.2.orig/patchlevel.h bash-4.2/patchlevel.h
[b369f3c]519--- bash-4.2.orig/patchlevel.h 2010-06-13 00:14:48.000000000 +0000
[d01d386]520+++ bash-4.2/patchlevel.h 2012-02-15 17:05:09.844986552 +0000
[b36b9f9]521@@ -25,6 +25,6 @@
522 regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
523 looks for to find the patch level (for the sccs version string). */
524
525-#define PATCHLEVEL 0
[d01d386]526+#define PATCHLEVEL 20
[b36b9f9]527
528 #endif /* _PATCHLEVEL_H_ */
[d01d386]529diff -Naur bash-4.2.orig/pathexp.c bash-4.2/pathexp.c
530--- bash-4.2.orig/pathexp.c 2010-08-14 03:21:57.000000000 +0000
531+++ bash-4.2/pathexp.c 2012-02-15 17:05:01.036751874 +0000
532@@ -196,7 +196,7 @@
533 {
534 if ((qflags & QGLOB_FILENAME) && pathname[i+1] == '/')
535 continue;
536- if ((qflags & QGLOB_REGEXP) && ere_char (pathname[i+1]) == 0)
537+ if (pathname[i+1] != CTLESC && (qflags & QGLOB_REGEXP) && ere_char (pathname[i+1]) == 0)
538 continue;
539 temp[j++] = '\\';
540 i++;
[b369f3c]541diff -Naur bash-4.2.orig/print_cmd.c bash-4.2/print_cmd.c
542--- bash-4.2.orig/print_cmd.c 2010-05-30 22:34:08.000000000 +0000
[d01d386]543+++ bash-4.2/print_cmd.c 2012-02-15 17:04:55.440602777 +0000
[b369f3c]544@@ -315,6 +315,7 @@
545 cprintf ("( ");
546 skip_this_indent++;
547 make_command_string_internal (command->value.Subshell->command);
548+ PRINT_DEFERRED_HEREDOCS ("");
549 cprintf (" )");
550 break;
551
552@@ -592,6 +593,7 @@
553 newline ("do\n");
554 indentation += indentation_amount;
555 make_command_string_internal (arith_for_command->action);
556+ PRINT_DEFERRED_HEREDOCS ("");
557 semicolon ();
558 indentation -= indentation_amount;
559 newline ("done");
560@@ -653,6 +655,7 @@
561 }
562
563 make_command_string_internal (group_command->command);
564+ PRINT_DEFERRED_HEREDOCS ("");
565
566 if (inside_function_def)
567 {
[d01d386]568diff -Naur bash-4.2.orig/shell.h bash-4.2/shell.h
569--- bash-4.2.orig/shell.h 2011-01-07 03:16:55.000000000 +0000
570+++ bash-4.2/shell.h 2012-02-15 17:04:58.268678125 +0000
571@@ -136,6 +136,9 @@
572 int parser_state;
573 int *token_state;
574
575+ char *token;
576+ int token_buffer_size;
577+
578 /* input line state -- line number saved elsewhere */
579 int input_line_terminator;
580 int eof_encountered;
581@@ -166,6 +169,16 @@
582
583 } sh_parser_state_t;
584
585+typedef struct _sh_input_line_state_t {
586+ char *input_line;
587+ int input_line_index;
588+ int input_line_size;
589+ int input_line_len;
590+} sh_input_line_state_t;
591+
592 /* Let's try declaring these here. */
593 extern sh_parser_state_t *save_parser_state __P((sh_parser_state_t *));
594 extern void restore_parser_state __P((sh_parser_state_t *));
595+
596+extern sh_input_line_state_t *save_input_line_state __P((sh_input_line_state_t *));
597+extern void restore_input_line_state __P((sh_input_line_state_t *));
[b36b9f9]598diff -Naur bash-4.2.orig/sig.c bash-4.2/sig.c
[b369f3c]599--- bash-4.2.orig/sig.c 2010-11-23 13:21:22.000000000 +0000
[d01d386]600+++ bash-4.2/sig.c 2012-02-15 17:04:52.644528282 +0000
[b36b9f9]601@@ -46,6 +46,7 @@
602
603 #if defined (READLINE)
604 # include "bashline.h"
605+# include <readline/readline.h>
606 #endif
607
608 #if defined (HISTORY)
609@@ -62,6 +63,7 @@
610 #if defined (HISTORY)
611 extern int history_lines_this_session;
612 #endif
613+extern int no_line_editing;
614
615 extern void initialize_siglist ();
616
617@@ -505,7 +507,10 @@
618 {
619 #if defined (HISTORY)
620 /* XXX - will inhibit history file being written */
621- history_lines_this_session = 0;
622+# if defined (READLINE)
623+ if (interactive_shell == 0 || interactive == 0 || (sig != SIGHUP && sig != SIGTERM) || no_line_editing || (RL_ISSTATE (RL_STATE_READCMD) == 0))
624+# endif
625+ history_lines_this_session = 0;
626 #endif
627 terminate_immediately = 0;
628 termsig_handler (sig);
629diff -Naur bash-4.2.orig/subst.c bash-4.2/subst.c
[b369f3c]630--- bash-4.2.orig/subst.c 2011-01-02 21:12:51.000000000 +0000
[d01d386]631+++ bash-4.2/subst.c 2012-02-15 17:04:59.656715107 +0000
[b36b9f9]632@@ -1379,10 +1379,12 @@
633 slen = strlen (string + *sindex) + *sindex;
634
635 /* The handling of dolbrace_state needs to agree with the code in parse.y:
636- parse_matched_pair() */
637- dolbrace_state = 0;
638- if (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))
639- dolbrace_state = (flags & SX_POSIXEXP) ? DOLBRACE_QUOTE : DOLBRACE_PARAM;
640+ parse_matched_pair(). The different initial value is to handle the
641+ case where this function is called to parse the word in
642+ ${param op word} (SX_WORD). */
643+ dolbrace_state = (flags & SX_WORD) ? DOLBRACE_WORD : DOLBRACE_PARAM;
644+ if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && (flags & SX_POSIXEXP))
645+ dolbrace_state = DOLBRACE_QUOTE;
646
647 i = *sindex;
648 while (c = string[i])
649@@ -3371,7 +3373,7 @@
650 if (string == 0 || *string == '\0')
651 return (WORD_LIST *)NULL;
652
653- td.flags = 0;
654+ td.flags = W_NOSPLIT2; /* no splitting, remove "" and '' */
655 td.word = string;
656 tresult = call_expand_word_internal (&td, quoted, 1, dollar_at_p, has_dollar_at);
657 return (tresult);
[d01d386]658@@ -3704,7 +3706,10 @@
659 break;
660 }
661 else if (string[i] == CTLNUL)
662- i++;
663+ {
664+ i++;
665+ continue;
666+ }
667
668 prev_i = i;
669 ADVANCE_CHAR (string, slen, i);
670@@ -4607,6 +4612,7 @@
[b36b9f9]671 if (ifs_firstc == 0)
672 #endif
673 word->flags |= W_NOSPLIT;
674+ word->flags |= W_NOSPLIT2;
675 result = call_expand_word_internal (word, quoted, 0, (int *)NULL, (int *)NULL);
676 expand_no_split_dollar_star = 0;
677
[d01d386]678@@ -7176,7 +7182,7 @@
[b36b9f9]679 {
680 /* Extract the contents of the ${ ... } expansion
681 according to the Posix.2 rules. */
682- value = extract_dollar_brace_string (string, &sindex, quoted, (c == '%' || c == '#') ? SX_POSIXEXP : 0);
683+ value = extract_dollar_brace_string (string, &sindex, quoted, (c == '%' || c == '#' || c =='/' || c == '^' || c == ',' || c ==':') ? SX_POSIXEXP|SX_WORD : SX_WORD);
684 if (string[sindex] == RBRACE)
685 sindex++;
686 else
687diff -Naur bash-4.2.orig/subst.h bash-4.2/subst.h
[b369f3c]688--- bash-4.2.orig/subst.h 2010-12-03 01:21:29.000000000 +0000
[d01d386]689+++ bash-4.2/subst.h 2012-02-15 17:04:42.280252148 +0000
[b36b9f9]690@@ -56,6 +56,7 @@
691 #define SX_NOLONGJMP 0x0040 /* don't longjmp on fatal error */
692 #define SX_ARITHSUB 0x0080 /* extracting $(( ... )) (currently unused) */
693 #define SX_POSIXEXP 0x0100 /* extracting new Posix pattern removal expansions in extract_dollar_brace_string */
694+#define SX_WORD 0x0200 /* extracting word in ${param op word} */
695
696 /* Remove backslashes which are quoting backquotes from STRING. Modifies
697 STRING, and returns a pointer to it. */
[d01d386]698diff -Naur bash-4.2.orig/support/shobj-conf bash-4.2/support/shobj-conf
699--- bash-4.2.orig/support/shobj-conf 2009-10-28 13:20:21.000000000 +0000
700+++ bash-4.2/support/shobj-conf 2012-02-15 17:05:09.844986552 +0000
701@@ -157,7 +157,7 @@
702 ;;
703
704 # Darwin/MacOS X
705-darwin[89]*|darwin10*)
706+darwin[89]*|darwin1[012]*)
707 SHOBJ_STATUS=supported
708 SHLIB_STATUS=supported
709
710@@ -186,7 +186,7 @@
711 SHLIB_LIBSUFF='dylib'
712
713 case "${host_os}" in
714- darwin[789]*|darwin10*) SHOBJ_LDFLAGS=''
715+ darwin[789]*|darwin1[012]*) SHOBJ_LDFLAGS=''
716 SHLIB_XLDFLAGS='-dynamiclib -arch_only `/usr/bin/arch` -install_name $(libdir)/$@ -current_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -compatibility_version $(SHLIB_MAJOR) -v'
717 ;;
718 *) SHOBJ_LDFLAGS='-dynamic'
[b36b9f9]719diff -Naur bash-4.2.orig/variables.c bash-4.2/variables.c
[b369f3c]720--- bash-4.2.orig/variables.c 2011-01-25 01:07:48.000000000 +0000
[d01d386]721+++ bash-4.2/variables.c 2012-02-15 17:04:49.868454320 +0000
[b36b9f9]722@@ -3653,6 +3653,22 @@
723 return n;
724 }
725
726+int
727+chkexport (name)
728+ char *name;
729+{
730+ SHELL_VAR *v;
731+
732+ v = find_variable (name);
733+ if (v && exported_p (v))
734+ {
735+ array_needs_making = 1;
736+ maybe_make_export_env ();
737+ return 1;
738+ }
739+ return 0;
740+}
741+
742 void
743 maybe_make_export_env ()
744 {
745@@ -4214,7 +4230,7 @@
746 { "TEXTDOMAIN", sv_locale },
747 { "TEXTDOMAINDIR", sv_locale },
748
749-#if defined (HAVE_TZSET) && defined (PROMPT_STRING_DECODE)
750+#if defined (HAVE_TZSET)
751 { "TZ", sv_tz },
752 #endif
753
754@@ -4558,12 +4574,13 @@
755 }
756 #endif /* HISTORY */
757
758-#if defined (HAVE_TZSET) && defined (PROMPT_STRING_DECODE)
759+#if defined (HAVE_TZSET)
760 void
761 sv_tz (name)
762 char *name;
763 {
764- tzset ();
765+ if (chkexport (name))
766+ tzset ();
767 }
768 #endif
769
770diff -Naur bash-4.2.orig/variables.h bash-4.2/variables.h
[b369f3c]771--- bash-4.2.orig/variables.h 2010-12-03 01:22:01.000000000 +0000
[d01d386]772+++ bash-4.2/variables.h 2012-02-15 17:04:48.476417232 +0000
[b36b9f9]773@@ -313,6 +313,7 @@
774
775 extern void sort_variables __P((SHELL_VAR **));
776
777+extern int chkexport __P((char *));
778 extern void maybe_make_export_env __P((void));
779 extern void update_export_env_inplace __P((char *, int, char *));
780 extern void put_command_name_into_env __P((char *));
Note: See TracBrowser for help on using the repository browser.