source: patches/bash-3.2-branch_update-1.patch@ 152baa0

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since 152baa0 was d849dd4, checked in by Jim Gifford <clfs@…>, 16 years ago

Changed Patches to Bash

  • Property mode set to 100644
File size: 74.5 KB
RevLine 
[d849dd4]1Submitted By: Jim Gifford (jim at cross-lfs dot org)
2Date: 01-08-2009
3Initial Package Version: 3.2
4Origin: Upstream
5Upstream Status: Applied
6Description: Contains all upstream patches up to 3.2-048
7
8diff -Naur bash-3.2.orig/array.c bash-3.2/array.c
9--- bash-3.2.orig/array.c 2005-06-01 13:39:22.000000000 -0700
10+++ bash-3.2/array.c 2009-01-08 16:16:08.000000000 -0800
11@@ -120,7 +120,6 @@
12 return(a1);
13 }
14
15-#ifdef INCLUDE_UNUSED
16 /*
17 * Make and return a new array composed of the elements in array A from
18 * S to E, inclusive.
19@@ -141,13 +140,12 @@
20 for (p = s, i = 0; p != e; p = element_forw(p), i++) {
21 n = array_create_element (element_index(p), element_value(p));
22 ADD_BEFORE(a->head, n);
23- mi = element_index(ae);
24+ mi = element_index(n);
25 }
26 a->num_elements = i;
27 a->max_index = mi;
28 return a;
29 }
30-#endif
31
32 /*
33 * Walk the array, calling FUNC once for each element, with the array
34@@ -300,6 +298,23 @@
35 return array;
36 }
37
38+ARRAY *
39+array_quote_escapes(array)
40+ARRAY *array;
41+{
42+ ARRAY_ELEMENT *a;
43+ char *t;
44+
45+ if (array == 0 || array_head(array) == 0 || array_empty(array))
46+ return (ARRAY *)NULL;
47+ for (a = element_forw(array->head); a != array->head; a = element_forw(a)) {
48+ t = quote_escapes (a->value);
49+ FREE(a->value);
50+ a->value = t;
51+ }
52+ return array;
53+}
54+
55 /*
56 * Return a string whose elements are the members of array A beginning at
57 * index START and spanning NELEM members. Null elements are counted.
58@@ -311,9 +326,10 @@
59 arrayind_t start, nelem;
60 int starsub, quoted;
61 {
62+ ARRAY *a2;
63 ARRAY_ELEMENT *h, *p;
64 arrayind_t i;
65- char *ifs, sep[2];
66+ char *ifs, sep[2], *t;
67
68 p = a ? array_head (a) : 0;
69 if (p == 0 || array_empty (a) || start > array_max_index(a))
70@@ -336,6 +352,13 @@
71 for (i = 0, h = p; p != a->head && i < nelem; i++, p = element_forw(p))
72 ;
73
74+ a2 = array_slice(a, h, p);
75+
76+ if (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT))
77+ array_quote(a2);
78+ else
79+ array_quote_escapes(a2);
80+
81 if (starsub && (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT))) {
82 ifs = getifs();
83 sep[0] = ifs ? *ifs : '\0';
84@@ -343,7 +366,10 @@
85 sep[0] = ' ';
86 sep[1] = '\0';
87
88- return (array_to_string_internal (h, p, sep, quoted));
89+ t = array_to_string (a2, sep, 0);
90+ array_dispose(a2);
91+
92+ return t;
93 }
94
95 char *
96@@ -367,7 +393,9 @@
97 }
98
99 if (mflags & MATCH_QUOTED)
100- array_quote (a2);
101+ array_quote(a2);
102+ else
103+ array_quote_escapes(a2);
104 if (mflags & MATCH_STARSUB) {
105 ifs = getifs();
106 sifs[0] = ifs ? *ifs : '\0';
107@@ -655,7 +683,7 @@
108 is = inttostr (element_index(ae), indstr, sizeof(indstr));
109 valstr = element_value (ae) ? sh_double_quote (element_value(ae))
110 : (char *)NULL;
111- elen = STRLEN (indstr) + 8 + STRLEN (valstr);
112+ elen = STRLEN (is) + 8 + STRLEN (valstr);
113 RESIZE_MALLOCED_BUFFER (result, rlen, (elen + 1), rsize, rsize);
114
115 result[rlen++] = '[';
116diff -Naur bash-3.2.orig/array.h bash-3.2/array.h
117--- bash-3.2.orig/array.h 2003-06-01 12:50:30.000000000 -0700
118+++ bash-3.2/array.h 2009-01-08 16:15:21.000000000 -0800
119@@ -55,6 +55,7 @@
120 extern ARRAY_ELEMENT *array_unshift_element __P((ARRAY *));
121 extern int array_shift_element __P((ARRAY *, char *));
122 extern ARRAY *array_quote __P((ARRAY *));
123+extern ARRAY *array_quote_escapes __P((ARRAY *));
124
125 extern char *array_subrange __P((ARRAY *, arrayind_t, arrayind_t, int, int));
126 extern char *array_patsub __P((ARRAY *, char *, char *, int));
127diff -Naur bash-3.2.orig/arrayfunc.c bash-3.2/arrayfunc.c
128--- bash-3.2.orig/arrayfunc.c 2006-07-27 06:37:59.000000000 -0700
129+++ bash-3.2/arrayfunc.c 2009-01-08 16:15:51.000000000 -0800
130@@ -618,6 +618,8 @@
131 if (expok == 0)
132 {
133 last_command_exit_value = EXECUTION_FAILURE;
134+
135+ top_level_cleanup ();
136 jump_to_top_level (DISCARD);
137 }
138 return val;
139@@ -720,7 +722,7 @@
140 if (ALL_ELEMENT_SUB (t[0]) && t[1] == ']')
141 {
142 if (rtype)
143- *rtype = 1;
144+ *rtype = (t[0] == '*') ? 1 : 2;
145 if (allow_all == 0)
146 {
147 err_badarraysub (s);
148diff -Naur bash-3.2.orig/bashhist.c bash-3.2/bashhist.c
149--- bash-3.2.orig/bashhist.c 2005-12-26 10:31:16.000000000 -0800
150+++ bash-3.2/bashhist.c 2009-01-08 16:16:09.000000000 -0800
151@@ -80,6 +80,7 @@
152 list. This is different than the user-controlled behaviour; this
153 becomes zero when we read lines from a file, for example. */
154 int remember_on_history = 1;
155+int enable_history_list = 1; /* value for `set -o history' */
156
157 /* The number of lines that Bash has added to this history session. The
158 difference between the number of the top element in the history list
159@@ -234,7 +235,7 @@
160 history_expansion = interact != 0;
161 history_expansion_inhibited = 1;
162 #endif
163- remember_on_history = interact != 0;
164+ remember_on_history = enable_history_list = interact != 0;
165 history_inhibit_expansion_function = bash_history_inhibit_expansion;
166 }
167
168diff -Naur bash-3.2.orig/bashhist.h bash-3.2/bashhist.h
169--- bash-3.2.orig/bashhist.h 2005-07-01 12:44:41.000000000 -0700
170+++ bash-3.2/bashhist.h 2009-01-08 16:16:09.000000000 -0800
171@@ -31,6 +31,9 @@
172 #define HC_IGNBOTH (HC_IGNSPACE|HC_IGNDUPS)
173
174 extern int remember_on_history;
175+extern int enable_history_list; /* value for `set -o history' */
176+extern int literal_history; /* controlled by `shopt lithist' */
177+extern int force_append_history;
178 extern int history_lines_this_session;
179 extern int history_lines_in_file;
180 extern int history_expansion;
181diff -Naur bash-3.2.orig/bashline.c bash-3.2/bashline.c
182--- bash-3.2.orig/bashline.c 2006-07-29 13:39:30.000000000 -0700
183+++ bash-3.2/bashline.c 2009-01-08 16:16:03.000000000 -0800
184@@ -2357,7 +2357,7 @@
185 if (should_expand_dirname)
186 {
187 new_dirname = savestring (local_dirname);
188- wl = expand_prompt_string (new_dirname, 0); /* does the right thing */
189+ wl = expand_prompt_string (new_dirname, 0, W_NOCOMSUB); /* does the right thing */
190 if (wl)
191 {
192 *dirname = string_list (wl);
193diff -Naur bash-3.2.orig/builtins/common.c bash-3.2/builtins/common.c
194--- bash-3.2.orig/builtins/common.c 2006-07-27 06:39:51.000000000 -0700
195+++ bash-3.2/builtins/common.c 2009-01-08 16:15:30.000000000 -0800
196@@ -1,4 +1,4 @@
197-/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
198+/* Copyright (C) 1987-2007 Free Software Foundation, Inc.
199
200 This file is part of GNU Bash, the Bourne Again SHell.
201
202@@ -131,6 +131,7 @@
203 if (list)
204 {
205 builtin_error (_("too many arguments"));
206+ top_level_cleanup ();
207 jump_to_top_level (DISCARD);
208 }
209 }
210@@ -395,7 +396,10 @@
211 if (fatal)
212 throw_to_top_level ();
213 else
214- jump_to_top_level (DISCARD);
215+ {
216+ top_level_cleanup ();
217+ jump_to_top_level (DISCARD);
218+ }
219 }
220 no_args (list->next);
221 }
222@@ -475,7 +479,11 @@
223
224 if (the_current_working_directory == 0)
225 {
226+#if defined (GETCWD_BROKEN)
227+ the_current_working_directory = getcwd (0, PATH_MAX);
228+#else
229 the_current_working_directory = getcwd (0, 0);
230+#endif
231 if (the_current_working_directory == 0)
232 {
233 fprintf (stderr, _("%s: error retrieving current directory: %s: %s\n"),
234diff -Naur bash-3.2.orig/builtins/evalstring.c bash-3.2/builtins/evalstring.c
235--- bash-3.2.orig/builtins/evalstring.c 2006-07-28 12:12:16.000000000 -0700
236+++ bash-3.2/builtins/evalstring.c 2009-01-08 16:16:26.000000000 -0800
237@@ -67,6 +67,14 @@
238
239 static int cat_file __P((REDIRECT *));
240
241+#if defined (HISTORY)
242+static void
243+set_history_remembering ()
244+{
245+ remember_on_history = enable_history_list;
246+}
247+#endif
248+
249 /* How to force parse_and_execute () to clean up after itself. */
250 void
251 parse_and_execute_cleanup ()
252@@ -115,7 +123,10 @@
253 lreset = flags & SEVAL_RESETLINE;
254
255 #if defined (HISTORY)
256- unwind_protect_int (remember_on_history); /* can be used in scripts */
257+ if (parse_and_execute_level == 0)
258+ add_unwind_protect (set_history_remembering, (char *)NULL);
259+ else
260+ unwind_protect_int (remember_on_history); /* can be used in scripts */
261 # if defined (BANG_HISTORY)
262 if (interactive_shell)
263 {
264@@ -237,6 +248,7 @@
265 * parse_and_execute has not been called recursively AND
266 * we're not running a trap AND
267 * we have parsed the full command (string == '\0') AND
268+ * we're not going to run the exit trap AND
269 * we have a simple command without redirections AND
270 * the command is not being timed AND
271 * the command's return status is not being inverted
272@@ -247,7 +259,8 @@
273 running_trap == 0 &&
274 *bash_input.location.string == '\0' &&
275 command->type == cm_simple &&
276- !command->redirects && !command->value.Simple->redirects &&
277+ signal_is_trapped (EXIT_TRAP) == 0 &&
278+ command->redirects == 0 && command->value.Simple->redirects == 0 &&
279 ((command->flags & CMD_TIME_PIPELINE) == 0) &&
280 ((command->flags & CMD_INVERT_RETURN) == 0))
281 {
282diff -Naur bash-3.2.orig/builtins/printf.def bash-3.2/builtins/printf.def
283--- bash-3.2.orig/builtins/printf.def 2006-09-18 05:48:42.000000000 -0700
284+++ bash-3.2/builtins/printf.def 2009-01-08 16:15:18.000000000 -0800
285@@ -1,7 +1,7 @@
286 This file is printf.def, from which is created printf.c.
287 It implements the builtin "printf" in Bash.
288
289-Copyright (C) 1997-2005 Free Software Foundation, Inc.
290+Copyright (C) 1997-2007 Free Software Foundation, Inc.
291
292 This file is part of GNU Bash, the Bourne Again SHell.
293
294@@ -49,6 +49,12 @@
295 # define INT_MIN (-2147483647-1)
296 #endif
297
298+#if defined (PREFER_STDARG)
299+# include <stdarg.h>
300+#else
301+# include <varargs.h>
302+#endif
303+
304 #include <stdio.h>
305 #include <chartypes.h>
306
307@@ -64,6 +70,10 @@
308 #include "bashgetopt.h"
309 #include "common.h"
310
311+#if defined (PRI_MACROS_BROKEN)
312+# undef PRIdMAX
313+#endif
314+
315 #if !defined (PRIdMAX)
316 # if HAVE_LONG_LONG
317 # define PRIdMAX "lld"
318@@ -151,6 +161,10 @@
319 #define SKIP1 "#'-+ 0"
320 #define LENMODS "hjlLtz"
321
322+#ifndef HAVE_ASPRINTF
323+extern int asprintf __P((char **, const char *, ...)) __attribute__((__format__ (printf, 2, 3)));
324+#endif
325+
326 static void printf_erange __P((char *));
327 static int printstr __P((char *, char *, int, int, int));
328 static int tescape __P((char *, char *, int *));
329diff -Naur bash-3.2.orig/builtins/read.def bash-3.2/builtins/read.def
330--- bash-3.2.orig/builtins/read.def 2006-09-19 05:45:48.000000000 -0700
331+++ bash-3.2/builtins/read.def 2009-01-08 16:16:04.000000000 -0800
332@@ -127,14 +127,14 @@
333 WORD_LIST *list;
334 {
335 register char *varname;
336- int size, i, nr, pass_next, saw_escape, eof, opt, retval, code;
337- int input_is_tty, input_is_pipe, unbuffered_read;
338+ int size, i, nr, pass_next, saw_escape, eof, opt, retval, code, print_ps2;
339+ int input_is_tty, input_is_pipe, unbuffered_read, skip_ctlesc, skip_ctlnul;
340 int raw, edit, nchars, silent, have_timeout, fd;
341 unsigned int tmout;
342 intmax_t intval;
343 char c;
344 char *input_string, *orig_input_string, *ifs_chars, *prompt, *arrayname;
345- char *e, *t, *t1;
346+ char *e, *t, *t1, *ps2, *tofree;
347 struct stat tsb;
348 SHELL_VAR *var;
349 #if defined (ARRAY_VARS)
350@@ -148,6 +148,7 @@
351 USE_VAR(size);
352 USE_VAR(i);
353 USE_VAR(pass_next);
354+ USE_VAR(print_ps2);
355 USE_VAR(saw_escape);
356 USE_VAR(input_is_pipe);
357 /* USE_VAR(raw); */
358@@ -163,6 +164,7 @@
359 USE_VAR(rlind);
360 #endif
361 USE_VAR(list);
362+ USE_VAR(ps2);
363
364 i = 0; /* Index into the string that we are reading. */
365 raw = edit = 0; /* Not reading raw input by default. */
366@@ -386,7 +388,8 @@
367 setmode (0, O_TEXT);
368 #endif
369
370- for (eof = retval = 0;;)
371+ ps2 = 0;
372+ for (print_ps2 = eof = retval = 0;;)
373 {
374 #if defined (READLINE)
375 if (edit)
376@@ -412,6 +415,15 @@
377 {
378 #endif
379
380+ if (print_ps2)
381+ {
382+ if (ps2 == 0)
383+ ps2 = get_string_value ("PS2");
384+ fprintf (stderr, "%s", ps2 ? ps2 : "");
385+ fflush (stderr);
386+ print_ps2 = 0;
387+ }
388+
389 if (unbuffered_read)
390 retval = zread (fd, &c, 1);
391 else
392@@ -440,7 +452,11 @@
393 {
394 pass_next = 0;
395 if (c == '\n')
396- i--; /* back up over the CTLESC */
397+ {
398+ i--; /* back up over the CTLESC */
399+ if (interactive && input_is_tty && raw == 0)
400+ print_ps2 = 1;
401+ }
402 else
403 goto add_char;
404 continue;
405@@ -658,12 +674,13 @@
406 #else
407 /* Check whether or not the number of fields is exactly the same as the
408 number of variables. */
409+ tofree = NULL;
410 if (*input_string)
411 {
412 t1 = input_string;
413 t = get_word_from_string (&input_string, ifs_chars, &e);
414 if (*input_string == 0)
415- input_string = t;
416+ tofree = input_string = t;
417 else
418 input_string = strip_trailing_ifs_whitespace (t1, ifs_chars, saw_escape);
419 }
420@@ -678,6 +695,8 @@
421 else
422 var = bind_read_variable (list->word->word, input_string);
423 stupidly_hack_special_variables (list->word->word);
424+ FREE (tofree);
425+
426 if (var)
427 VUNSETATTR (var, att_invisible);
428 xfree (orig_input_string);
429diff -Naur bash-3.2.orig/builtins/set.def bash-3.2/builtins/set.def
430--- bash-3.2.orig/builtins/set.def 2006-07-27 06:41:43.000000000 -0700
431+++ bash-3.2/builtins/set.def 2009-01-08 16:16:09.000000000 -0800
432@@ -189,7 +189,7 @@
433 { "histexpand", 'H', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL },
434 #endif /* BANG_HISTORY */
435 #if defined (HISTORY)
436- { "history", '\0', &remember_on_history, bash_set_history, (setopt_get_func_t *)NULL },
437+ { "history", '\0', &enable_history_list, bash_set_history, (setopt_get_func_t *)NULL },
438 #endif
439 { "ignoreeof", '\0', &ignoreeof, set_ignoreeof, (setopt_get_func_t *)NULL },
440 { "interactive-comments", '\0', &interactive_comments, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL },
441@@ -381,13 +381,17 @@
442 {
443 if (on_or_off == FLAG_ON)
444 {
445+ enable_history_list = 1;
446 bash_history_enable ();
447 if (history_lines_this_session == 0)
448 load_history ();
449 }
450 else
451- bash_history_disable ();
452- return (1 - remember_on_history);
453+ {
454+ enable_history_list = 0;
455+ bash_history_disable ();
456+ }
457+ return (1 - enable_history_list);
458 }
459 #endif
460
461@@ -565,7 +569,7 @@
462 reset_shell_options ()
463 {
464 #if defined (HISTORY)
465- remember_on_history = 1;
466+ remember_on_history = enable_history_list = 1;
467 #endif
468 ignoreeof = 0;
469 }
470diff -Naur bash-3.2.orig/builtins/shopt.def bash-3.2/builtins/shopt.def
471--- bash-3.2.orig/builtins/shopt.def 2005-02-19 14:25:03.000000000 -0800
472+++ bash-3.2/builtins/shopt.def 2009-01-08 16:16:06.000000000 -0800
473@@ -101,11 +101,14 @@
474
475 static int set_shellopts_after_change __P((int));
476
477+static int set_compatibility_level __P((int));
478+
479 #if defined (RESTRICTED_SHELL)
480 static int set_restricted_shell __P((int));
481 #endif
482
483 static int shopt_login_shell;
484+static int shopt_compat31;
485
486 typedef int shopt_set_func_t __P((int));
487
488@@ -121,6 +124,7 @@
489 #if defined (HISTORY)
490 { "cmdhist", &command_oriented_history, (shopt_set_func_t *)NULL },
491 #endif
492+ { "compat31", &shopt_compat31, set_compatibility_level },
493 { "dotglob", &glob_dot_filenames, (shopt_set_func_t *)NULL },
494 { "execfail", &no_exit_on_failed_exec, (shopt_set_func_t *)NULL },
495 { "expand_aliases", &expand_aliases, (shopt_set_func_t *)NULL },
496@@ -459,6 +463,18 @@
497 return (0);
498 }
499
500+static int
501+set_compatibility_level (mode)
502+ int mode;
503+{
504+ /* Need to change logic here as we add more compatibility levels */
505+ if (shopt_compat31)
506+ shell_compatibility_level = 31;
507+ else
508+ shell_compatibility_level = 32;
509+ return 0;
510+}
511+
512 #if defined (RESTRICTED_SHELL)
513 /* Don't allow the value of restricted_shell to be modified. */
514
515diff -Naur bash-3.2.orig/config-bot.h bash-3.2/config-bot.h
516--- bash-3.2.orig/config-bot.h 2006-09-12 13:43:04.000000000 -0700
517+++ bash-3.2/config-bot.h 2009-01-08 16:15:16.000000000 -0800
518@@ -1,7 +1,7 @@
519 /* config-bot.h */
520 /* modify settings or make new ones based on what autoconf tells us. */
521
522-/* Copyright (C) 1989-2002 Free Software Foundation, Inc.
523+/* Copyright (C) 1989-2007 Free Software Foundation, Inc.
524
525 This file is part of GNU Bash, the Bourne Again SHell.
526
527@@ -70,9 +70,11 @@
528 # define TERMIOS_MISSING
529 #endif
530
531-/* If we have a getcwd(3), but it calls popen(), #undef HAVE_GETCWD so
532- the replacement in getcwd.c will be built. */
533-#if defined (HAVE_GETCWD) && defined (GETCWD_BROKEN)
534+/* If we have a getcwd(3), but one that does not dynamically allocate memory,
535+ #undef HAVE_GETCWD so the replacement in getcwd.c will be built. We do
536+ not do this on Solaris, because their implementation of loopback mounts
537+ breaks the traditional file system assumptions that getcwd uses. */
538+#if defined (HAVE_GETCWD) && defined (GETCWD_BROKEN) && !defined (SOLARIS)
539 # undef HAVE_GETCWD
540 #endif
541
542diff -Naur bash-3.2.orig/config.h.in bash-3.2/config.h.in
543--- bash-3.2.orig/config.h.in 2006-09-12 13:00:54.000000000 -0700
544+++ bash-3.2/config.h.in 2009-01-08 16:15:18.000000000 -0800
545@@ -1,6 +1,6 @@
546 /* config.h -- Configuration file for bash. */
547
548-/* Copyright (C) 1987-2006 Free Software Foundation, Inc.
549+/* Copyright (C) 1987-2007 Free Software Foundation, Inc.
550
551 This file is part of GNU Bash, the Bourne Again SHell.
552
553@@ -413,6 +413,8 @@
554
555 #undef HAVE_DECL_STRTOLD
556
557+#undef PRI_MACROS_BROKEN
558+
559 #undef STRTOLD_BROKEN
560
561 /* Define if WCONTINUED is defined in system headers, but rejected by waitpid */
562@@ -1006,6 +1008,9 @@
563 /* Define if you have the `dcgettext' function. */
564 #undef HAVE_DCGETTEXT
565
566+/* Define if you have the `localeconv' function. */
567+#undef HAVE_LOCALECONV
568+
569 /* Define if your system has a working `malloc' function. */
570 /* #undef HAVE_MALLOC */
571
572diff -Naur bash-3.2.orig/configure bash-3.2/configure
573--- bash-3.2.orig/configure 2006-09-26 08:06:01.000000000 -0700
574+++ bash-3.2/configure 2009-01-08 16:15:40.000000000 -0800
575@@ -4871,7 +4871,7 @@
576 # static version specified as -llibname to override the
577 # dynamic version
578 case "${host_os}" in
579- darwin8*) READLINE_LIB='${READLINE_LIBRARY}' ;;
580+ darwin[89]*) READLINE_LIB='${READLINE_LIBRARY}' ;;
581 *) READLINE_LIB=-lreadline ;;
582 esac
583 fi
584@@ -27316,7 +27316,8 @@
585 sco3.2v4*) LOCAL_CFLAGS="-DMUST_UNBLOCK_CHLD -DPATH_MAX=1024" ;;
586 sco3.2*) LOCAL_CFLAGS=-DMUST_UNBLOCK_CHLD ;;
587 sunos4*) LOCAL_CFLAGS=-DSunOS4 ;;
588-solaris2.5*) LOCAL_CFLAGS=-DSunOS5 ;;
589+solaris2.5*) LOCAL_CFLAGS="-DSunOS5 -DSOLARIS" ;;
590+solaris2*) LOCAL_CFLAGS=-DSOLARIS ;;
591 lynxos*) LOCAL_CFLAGS=-DRECYCLES_PIDS ;;
592 linux*) LOCAL_LDFLAGS=-rdynamic # allow dynamic loading
593 case "`uname -r`" in
594diff -Naur bash-3.2.orig/configure.in bash-3.2/configure.in
595--- bash-3.2.orig/configure.in 2006-09-26 08:05:45.000000000 -0700
596+++ bash-3.2/configure.in 2009-01-08 16:15:40.000000000 -0800
597@@ -5,7 +5,7 @@
598 dnl
599 dnl Process this file with autoconf to produce a configure script.
600
601-# Copyright (C) 1987-2006 Free Software Foundation, Inc.
602+# Copyright (C) 1987-2007 Free Software Foundation, Inc.
603
604 # This program is free software; you can redistribute it and/or modify
605 # it under the terms of the GNU General Public License as published by
606@@ -518,7 +518,7 @@
607 # static version specified as -llibname to override the
608 # dynamic version
609 case "${host_os}" in
610- darwin8*) READLINE_LIB='${READLINE_LIBRARY}' ;;
611+ darwin[[89]]*) READLINE_LIB='${READLINE_LIBRARY}' ;;
612 *) READLINE_LIB=-lreadline ;;
613 esac
614 fi
615@@ -991,7 +991,8 @@
616 sco3.2v4*) LOCAL_CFLAGS="-DMUST_UNBLOCK_CHLD -DPATH_MAX=1024" ;;
617 sco3.2*) LOCAL_CFLAGS=-DMUST_UNBLOCK_CHLD ;;
618 sunos4*) LOCAL_CFLAGS=-DSunOS4 ;;
619-solaris2.5*) LOCAL_CFLAGS=-DSunOS5 ;;
620+solaris2.5*) LOCAL_CFLAGS="-DSunOS5 -DSOLARIS" ;;
621+solaris2*) LOCAL_CFLAGS=-DSOLARIS ;;
622 lynxos*) LOCAL_CFLAGS=-DRECYCLES_PIDS ;;
623 linux*) LOCAL_LDFLAGS=-rdynamic # allow dynamic loading
624 case "`uname -r`" in
625diff -Naur bash-3.2.orig/doc/bash.1 bash-3.2/doc/bash.1
626--- bash-3.2.orig/doc/bash.1 2006-10-03 05:54:26.000000000 -0700
627+++ bash-3.2/doc/bash.1 2009-01-08 16:16:06.000000000 -0800
628@@ -7977,6 +7977,12 @@
629 command in the same history entry. This allows
630 easy re-editing of multi-line commands.
631 .TP 8
632+.B compat31
633+If set,
634+.B bash
635+changes its behavior to that of version 3.1 with respect to quoted
636+arguments to the conditional command's =~ operator.
637+.TP 8
638 .B dotglob
639 If set,
640 .B bash
641diff -Naur bash-3.2.orig/doc/bashref.texi bash-3.2/doc/bashref.texi
642--- bash-3.2.orig/doc/bashref.texi 2006-09-28 07:25:28.000000000 -0700
643+++ bash-3.2/doc/bashref.texi 2009-01-08 16:16:06.000000000 -0800
644@@ -3598,6 +3598,11 @@
645 command in the same history entry. This allows
646 easy re-editing of multi-line commands.
647
648+@item compat31
649+If set, Bash
650+changes its behavior to that of version 3.1 with respect to quoted
651+arguments to the conditional command's =~ operator.
652+
653 @item dotglob
654 If set, Bash includes filenames beginning with a `.' in
655 the results of filename expansion.
656diff -Naur bash-3.2.orig/execute_cmd.c bash-3.2/execute_cmd.c
657--- bash-3.2.orig/execute_cmd.c 2006-08-25 21:23:17.000000000 -0700
658+++ bash-3.2/execute_cmd.c 2009-01-08 16:16:16.000000000 -0800
659@@ -1,6 +1,6 @@
660 /* execute_cmd.c -- Execute a COMMAND structure. */
661
662-/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
663+/* Copyright (C) 1987-2007 Free Software Foundation, Inc.
664
665 This file is part of GNU Bash, the Bourne Again SHell.
666
667@@ -501,8 +501,15 @@
668 volatile int last_pid;
669 volatile int save_line_number;
670
671+#if 0
672 if (command == 0 || breaking || continuing || read_but_dont_execute)
673 return (EXECUTION_SUCCESS);
674+#else
675+ if (breaking || continuing)
676+ return (last_command_exit_value);
677+ if (command == 0 || read_but_dont_execute)
678+ return (EXECUTION_SUCCESS);
679+#endif
680
681 QUIT;
682 run_pending_traps ();
683@@ -614,7 +621,7 @@
684 cleanup_redirects (redirection_undo_list);
685 redirection_undo_list = (REDIRECT *)NULL;
686 dispose_exec_redirects ();
687- return (EXECUTION_FAILURE);
688+ return (last_command_exit_value = EXECUTION_FAILURE);
689 }
690
691 if (redirection_undo_list)
692@@ -2546,7 +2553,8 @@
693 arg1 = cond_expand_word (cond->left->op, 0);
694 if (arg1 == 0)
695 arg1 = nullstr;
696- arg2 = cond_expand_word (cond->right->op, patmatch||rmatch);
697+ arg2 = cond_expand_word (cond->right->op,
698+ (rmatch && shell_compatibility_level > 31) ? 2 : (patmatch ? 1 : 0));
699 if (arg2 == 0)
700 arg2 = nullstr;
701
702@@ -3050,6 +3058,11 @@
703 if (command_line == 0)
704 command_line = savestring (the_printed_command_except_trap);
705
706+#if defined (PROCESS_SUBSTITUTION)
707+ if ((subshell_environment & SUBSHELL_COMSUB) && (simple_command->flags & CMD_NO_FORK) && fifos_pending() > 0)
708+ simple_command->flags &= ~CMD_NO_FORK;
709+#endif
710+
711 execute_disk_command (words, simple_command->redirects, command_line,
712 pipe_in, pipe_out, async, fds_to_close,
713 simple_command->flags);
714@@ -3875,6 +3888,8 @@
715 shell_variables = shell_variables->down;
716
717 clear_unwind_protect_list (0);
718+ /* XXX -- are there other things we should be resetting here? */
719+ parse_and_execute_level = 0; /* nothing left to restore it */
720
721 /* We're no longer inside a shell function. */
722 variable_context = return_catch_flag = 0;
723diff -Naur bash-3.2.orig/expr.c bash-3.2/expr.c
724--- bash-3.2.orig/expr.c 2005-12-28 14:47:03.000000000 -0800
725+++ bash-3.2/expr.c 2009-01-08 16:16:11.000000000 -0800
726@@ -286,6 +286,8 @@
727 free (expr_stack[expr_depth]);
728 }
729 free (expr_stack[expr_depth]); /* free the allocated EXPR_CONTEXT */
730+
731+ noeval = 0; /* XXX */
732 }
733
734 static void
735@@ -319,6 +321,7 @@
736 procenv_t oevalbuf;
737
738 val = 0;
739+ noeval = 0;
740
741 FASTCOPY (evalbuf, oevalbuf, sizeof (evalbuf));
742
743@@ -517,7 +520,8 @@
744 set_noeval = 1;
745 noeval++;
746 }
747- val2 = explor ();
748+
749+ val2 = expcond ();
750 if (set_noeval)
751 noeval--;
752 rval = cval ? val1 : val2;
753@@ -929,6 +933,7 @@
754 if (interactive_shell)
755 {
756 expr_unwind ();
757+ top_level_cleanup ();
758 jump_to_top_level (DISCARD);
759 }
760 else
761diff -Naur bash-3.2.orig/findcmd.c bash-3.2/findcmd.c
762--- bash-3.2.orig/findcmd.c 2005-08-17 13:49:54.000000000 -0700
763+++ bash-3.2/findcmd.c 2009-01-08 16:15:11.000000000 -0800
764@@ -308,7 +308,7 @@
765 if (hashed_file && (posixly_correct || check_hashed_filenames))
766 {
767 st = file_status (hashed_file);
768- if ((st ^ (FS_EXISTS | FS_EXECABLE)) != 0)
769+ if ((st & (FS_EXISTS|FS_EXECABLE)) != (FS_EXISTS|FS_EXECABLE))
770 {
771 phash_remove (pathname);
772 free (hashed_file);
773diff -Naur bash-3.2.orig/jobs.c bash-3.2/jobs.c
774--- bash-3.2.orig/jobs.c 2006-07-29 13:40:48.000000000 -0700
775+++ bash-3.2/jobs.c 2009-01-08 16:15:59.000000000 -0800
776@@ -250,6 +250,7 @@
777 static int job_exit_signal __P((int));
778 static int set_job_status_and_cleanup __P((int));
779
780+static WAIT job_signal_status __P((int));
781 static WAIT raw_job_exit_status __P((int));
782
783 static void notify_of_job_status __P((void));
784@@ -783,11 +784,13 @@
785 if (jobs[js.j_firstj] == 0)
786 {
787 old = js.j_firstj++;
788+ if (old >= js.j_jobslots)
789+ old = js.j_jobslots - 1;
790 while (js.j_firstj != old)
791 {
792 if (js.j_firstj >= js.j_jobslots)
793 js.j_firstj = 0;
794- if (jobs[js.j_firstj])
795+ if (jobs[js.j_firstj] || js.j_firstj == old) /* needed if old == 0 */
796 break;
797 js.j_firstj++;
798 }
799@@ -797,11 +800,13 @@
800 if (jobs[js.j_lastj] == 0)
801 {
802 old = js.j_lastj--;
803+ if (old < 0)
804+ old = 0;
805 while (js.j_lastj != old)
806 {
807 if (js.j_lastj < 0)
808 js.j_lastj = js.j_jobslots - 1;
809- if (jobs[js.j_lastj])
810+ if (jobs[js.j_lastj] || js.j_lastj == old) /* needed if old == js.j_jobslots */
811 break;
812 js.j_lastj--;
813 }
814@@ -963,7 +968,11 @@
815 reap_dead_jobs ();
816 realloc_jobs_list ();
817
818- return (js.j_lastj);
819+#ifdef DEBUG
820+ itrace("compact_jobs_list: returning %d", (js.j_lastj || jobs[js.j_lastj]) ? js.j_lastj + 1 : 0);
821+#endif
822+
823+ return ((js.j_lastj || jobs[js.j_lastj]) ? js.j_lastj + 1 : 0);
824 }
825
826 /* Delete the job at INDEX from the job list. Must be called
827@@ -984,8 +993,6 @@
828 temp = jobs[job_index];
829 if (temp == 0)
830 return;
831- if (job_index == js.j_current || job_index == js.j_previous)
832- reset_current ();
833
834 if ((dflags & DEL_NOBGPID) == 0)
835 {
836@@ -1028,6 +1035,9 @@
837 js.j_firstj = js.j_lastj = 0;
838 else if (jobs[js.j_firstj] == 0 || jobs[js.j_lastj] == 0)
839 reset_job_indices ();
840+
841+ if (job_index == js.j_current || job_index == js.j_previous)
842+ reset_current ();
843 }
844
845 /* Must be called with SIGCHLD blocked. */
846@@ -2210,6 +2220,26 @@
847 return (EXECUTION_SUCCESS);
848 }
849
850+static WAIT
851+job_signal_status (job)
852+ int job;
853+{
854+ register PROCESS *p;
855+ WAIT s;
856+
857+ p = jobs[job]->pipe;
858+ do
859+ {
860+ s = p->status;
861+ if (WIFSIGNALED(s) || WIFSTOPPED(s))
862+ break;
863+ p = p->next;
864+ }
865+ while (p != jobs[job]->pipe);
866+
867+ return s;
868+}
869+
870 /* Return the exit status of the last process in the pipeline for job JOB.
871 This is the exit status of the entire job. */
872 static WAIT
873@@ -2292,11 +2322,14 @@
874 to finish. We don't want the shell to exit if an interrupt is
875 received, only if one of the jobs run is killed via SIGINT. If
876 job control is not set, the job will be run in the same pgrp as
877- the shell, and the shell will see any signals the job gets. */
878+ the shell, and the shell will see any signals the job gets. In
879+ fact, we want this set every time the waiting shell and the waited-
880+ for process are in the same process group, including command
881+ substitution. */
882
883 /* This is possibly a race condition -- should it go in stop_pipeline? */
884 wait_sigint_received = 0;
885- if (job_control == 0)
886+ if (job_control == 0 || (subshell_environment&SUBSHELL_COMSUB))
887 {
888 old_sigint_handler = set_signal_handler (SIGINT, wait_sigint_handler);
889 if (old_sigint_handler == SIG_IGN)
890@@ -2442,15 +2475,7 @@
891 to a signal. We might want to change this later to just check
892 the last process in the pipeline. If no process exits due to a
893 signal, S is left as the status of the last job in the pipeline. */
894- p = jobs[job]->pipe;
895- do
896- {
897- s = p->status;
898- if (WIFSIGNALED(s) || WIFSTOPPED(s))
899- break;
900- p = p->next;
901- }
902- while (p != jobs[job]->pipe);
903+ s = job_signal_status (job);
904
905 if (WIFSIGNALED (s) || WIFSTOPPED (s))
906 {
907@@ -2484,6 +2509,24 @@
908 }
909 }
910 }
911+ else if ((subshell_environment & SUBSHELL_COMSUB) && wait_sigint_received)
912+ {
913+ /* If waiting for a job in a subshell started to do command
914+ substitution, simulate getting and being killed by the SIGINT to
915+ pass the status back to our parent. */
916+ s = job_signal_status (job);
917+
918+ if (WIFSIGNALED (s) && WTERMSIG (s) == SIGINT && signal_is_trapped (SIGINT) == 0)
919+ {
920+ UNBLOCK_CHILD (oset);
921+ restore_sigint_handler ();
922+ old_sigint_handler = set_signal_handler (SIGINT, SIG_DFL);
923+ if (old_sigint_handler == SIG_IGN)
924+ restore_sigint_handler ();
925+ else
926+ kill (getpid (), SIGINT);
927+ }
928+ }
929
930 /* Moved here from set_job_status_and_cleanup, which is in the SIGCHLD
931 signal handler path */
932diff -Naur bash-3.2.orig/lib/readline/complete.c bash-3.2/lib/readline/complete.c
933--- bash-3.2.orig/lib/readline/complete.c 2006-07-28 08:35:49.000000000 -0700
934+++ bash-3.2/lib/readline/complete.c 2009-01-08 16:15:29.000000000 -0800
935@@ -428,7 +428,7 @@
936 return (1);
937 if (c == 'n' || c == 'N' || c == RUBOUT)
938 return (0);
939- if (c == ABORT_CHAR)
940+ if (c == ABORT_CHAR || c < 0)
941 _rl_abort_internal ();
942 if (for_pager && (c == NEWLINE || c == RETURN))
943 return (2);
944diff -Naur bash-3.2.orig/lib/readline/display.c bash-3.2/lib/readline/display.c
945--- bash-3.2.orig/lib/readline/display.c 2006-09-14 11:20:12.000000000 -0700
946+++ bash-3.2/lib/readline/display.c 2009-01-08 16:16:14.000000000 -0800
947@@ -391,14 +391,14 @@
948 t = ++p;
949 local_prompt = expand_prompt (p, &prompt_visible_length,
950 &prompt_last_invisible,
951- (int *)NULL,
952+ &prompt_invis_chars_first_line,
953 &prompt_physical_chars);
954 c = *t; *t = '\0';
955 /* The portion of the prompt string up to and including the
956 final newline is now null-terminated. */
957 local_prompt_prefix = expand_prompt (prompt, &prompt_prefix_length,
958 (int *)NULL,
959- &prompt_invis_chars_first_line,
960+ (int *)NULL,
961 (int *)NULL);
962 *t = c;
963 local_prompt_len = local_prompt ? strlen (local_prompt) : 0;
964@@ -561,6 +561,17 @@
965 wrap_offset = prompt_invis_chars_first_line = 0;
966 }
967
968+#if defined (HANDLE_MULTIBYTE)
969+#define CHECK_INV_LBREAKS() \
970+ do { \
971+ if (newlines >= (inv_lbsize - 2)) \
972+ { \
973+ inv_lbsize *= 2; \
974+ inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \
975+ _rl_wrapped_line = (int *)xrealloc (_rl_wrapped_line, inv_lbsize * sizeof (int)); \
976+ } \
977+ } while (0)
978+#else
979 #define CHECK_INV_LBREAKS() \
980 do { \
981 if (newlines >= (inv_lbsize - 2)) \
982@@ -569,6 +580,7 @@
983 inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \
984 } \
985 } while (0)
986+#endif /* HANDLE_MULTIBYTE */
987
988 #if defined (HANDLE_MULTIBYTE)
989 #define CHECK_LPOS() \
990@@ -898,6 +910,10 @@
991 second and subsequent lines start at inv_lbreaks[N], offset by
992 OFFSET (which has already been calculated above). */
993
994+#define INVIS_FIRST() (prompt_physical_chars > _rl_screenwidth ? prompt_invis_chars_first_line : wrap_offset)
995+#define WRAP_OFFSET(line, offset) ((line == 0) \
996+ ? (offset ? INVIS_FIRST() : 0) \
997+ : ((line == prompt_last_screen_line) ? wrap_offset-prompt_invis_chars_first_line : 0))
998 #define W_OFFSET(line, offset) ((line) == 0 ? offset : 0)
999 #define VIS_LLEN(l) ((l) > _rl_vis_botlin ? 0 : (vis_lbreaks[l+1] - vis_lbreaks[l]))
1000 #define INV_LLEN(l) (inv_lbreaks[l+1] - inv_lbreaks[l])
1001@@ -932,7 +948,13 @@
1002 _rl_last_c_pos != o_cpos &&
1003 _rl_last_c_pos > wrap_offset &&
1004 o_cpos < prompt_last_invisible)
1005- _rl_last_c_pos -= wrap_offset;
1006+ _rl_last_c_pos -= prompt_invis_chars_first_line; /* XXX - was wrap_offset */
1007+ else if (linenum == prompt_last_screen_line && prompt_physical_chars > _rl_screenwidth &&
1008+ (MB_CUR_MAX > 1 && rl_byte_oriented == 0) &&
1009+ cpos_adjusted == 0 &&
1010+ _rl_last_c_pos != o_cpos &&
1011+ _rl_last_c_pos > (prompt_last_invisible - _rl_screenwidth - prompt_invis_chars_first_line))
1012+ _rl_last_c_pos -= (wrap_offset-prompt_invis_chars_first_line);
1013
1014 /* If this is the line with the prompt, we might need to
1015 compensate for invisible characters in the new line. Do
1016@@ -1036,7 +1058,7 @@
1017 tx = _rl_col_width (&visible_line[pos], 0, nleft) - visible_wrap_offset;
1018 else
1019 tx = nleft;
1020- if (_rl_last_c_pos > tx)
1021+ if (tx >= 0 && _rl_last_c_pos > tx)
1022 {
1023 _rl_backspace (_rl_last_c_pos - tx); /* XXX */
1024 _rl_last_c_pos = tx;
1025@@ -1192,7 +1214,7 @@
1026 int current_line, omax, nmax, inv_botlin;
1027 {
1028 register char *ofd, *ols, *oe, *nfd, *nls, *ne;
1029- int temp, lendiff, wsatend, od, nd;
1030+ int temp, lendiff, wsatend, od, nd, twidth, o_cpos;
1031 int current_invis_chars;
1032 int col_lendiff, col_temp;
1033 #if defined (HANDLE_MULTIBYTE)
1034@@ -1208,7 +1230,7 @@
1035 if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
1036 temp = _rl_last_c_pos;
1037 else
1038- temp = _rl_last_c_pos - W_OFFSET(_rl_last_v_pos, visible_wrap_offset);
1039+ temp = _rl_last_c_pos - WRAP_OFFSET (_rl_last_v_pos, visible_wrap_offset);
1040 if (temp == _rl_screenwidth && _rl_term_autowrap && !_rl_horizontal_scroll_mode
1041 && _rl_last_v_pos == current_line - 1)
1042 {
1043@@ -1453,6 +1475,8 @@
1044 _rl_last_c_pos = lendiff;
1045 }
1046
1047+ o_cpos = _rl_last_c_pos;
1048+
1049 /* When this function returns, _rl_last_c_pos is correct, and an absolute
1050 cursor postion in multibyte mode, but a buffer index when not in a
1051 multibyte locale. */
1052@@ -1462,7 +1486,9 @@
1053 /* We need to indicate that the cursor position is correct in the presence of
1054 invisible characters in the prompt string. Let's see if setting this when
1055 we make sure we're at the end of the drawn prompt string works. */
1056- if (current_line == 0 && MB_CUR_MAX > 1 && rl_byte_oriented == 0 && _rl_last_c_pos == prompt_physical_chars)
1057+ if (current_line == 0 && MB_CUR_MAX > 1 && rl_byte_oriented == 0 &&
1058+ (_rl_last_c_pos > 0 || o_cpos > 0) &&
1059+ _rl_last_c_pos == prompt_physical_chars)
1060 cpos_adjusted = 1;
1061 #endif
1062 #endif
1063@@ -1506,11 +1532,31 @@
1064 {
1065 /* Non-zero if we're increasing the number of lines. */
1066 int gl = current_line >= _rl_vis_botlin && inv_botlin > _rl_vis_botlin;
1067+ /* If col_lendiff is > 0, implying that the new string takes up more
1068+ screen real estate than the old, but lendiff is < 0, meaning that it
1069+ takes fewer bytes, we need to just output the characters starting
1070+ from the first difference. These will overwrite what is on the
1071+ display, so there's no reason to do a smart update. This can really
1072+ only happen in a multibyte environment. */
1073+ if (lendiff < 0)
1074+ {
1075+ _rl_output_some_chars (nfd, temp);
1076+ _rl_last_c_pos += _rl_col_width (nfd, 0, temp);
1077+ /* If nfd begins before any invisible characters in the prompt,
1078+ adjust _rl_last_c_pos to account for wrap_offset and set
1079+ cpos_adjusted to let the caller know. */
1080+ if (current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible))
1081+ {
1082+ _rl_last_c_pos -= wrap_offset;
1083+ cpos_adjusted = 1;
1084+ }
1085+ return;
1086+ }
1087 /* Sometimes it is cheaper to print the characters rather than
1088 use the terminal's capabilities. If we're growing the number
1089 of lines, make sure we actually cause the new line to wrap
1090 around on auto-wrapping terminals. */
1091- if (_rl_terminal_can_insert && ((2 * col_temp) >= col_lendiff || _rl_term_IC) && (!_rl_term_autowrap || !gl))
1092+ else if (_rl_terminal_can_insert && ((2 * col_temp) >= col_lendiff || _rl_term_IC) && (!_rl_term_autowrap || !gl))
1093 {
1094 /* If lendiff > prompt_visible_length and _rl_last_c_pos == 0 and
1095 _rl_horizontal_scroll_mode == 1, inserting the characters with
1096@@ -1533,11 +1579,16 @@
1097 }
1098 else
1099 {
1100- /* We have horizontal scrolling and we are not inserting at
1101- the end. We have invisible characters in this line. This
1102- is a dumb update. */
1103 _rl_output_some_chars (nfd, temp);
1104 _rl_last_c_pos += col_temp;
1105+ /* If nfd begins before any invisible characters in the prompt,
1106+ adjust _rl_last_c_pos to account for wrap_offset and set
1107+ cpos_adjusted to let the caller know. */
1108+ if (current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible))
1109+ {
1110+ _rl_last_c_pos -= wrap_offset;
1111+ cpos_adjusted = 1;
1112+ }
1113 return;
1114 }
1115 /* Copy (new) chars to screen from first diff to last match. */
1116@@ -1545,15 +1596,15 @@
1117 if ((temp - lendiff) > 0)
1118 {
1119 _rl_output_some_chars (nfd + lendiff, temp - lendiff);
1120-#if 1
1121 /* XXX -- this bears closer inspection. Fixes a redisplay bug
1122 reported against bash-3.0-alpha by Andreas Schwab involving
1123 multibyte characters and prompt strings with invisible
1124 characters, but was previously disabled. */
1125- _rl_last_c_pos += _rl_col_width (nfd+lendiff, 0, temp-col_lendiff);
1126-#else
1127- _rl_last_c_pos += _rl_col_width (nfd+lendiff, 0, temp-lendiff);
1128-#endif
1129+ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
1130+ twidth = _rl_col_width (nfd+lendiff, 0, temp-col_lendiff);
1131+ else
1132+ twidth = temp - lendiff;
1133+ _rl_last_c_pos += twidth;
1134 }
1135 }
1136 else
1137@@ -1586,8 +1637,22 @@
1138 temp = nls - nfd;
1139 if (temp > 0)
1140 {
1141+ /* If nfd begins at the prompt, or before the invisible
1142+ characters in the prompt, we need to adjust _rl_last_c_pos
1143+ in a multibyte locale to account for the wrap offset and
1144+ set cpos_adjusted accordingly. */
1145 _rl_output_some_chars (nfd, temp);
1146- _rl_last_c_pos += _rl_col_width (nfd, 0, temp);;
1147+ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
1148+ {
1149+ _rl_last_c_pos += _rl_col_width (nfd, 0, temp);
1150+ if (current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible))
1151+ {
1152+ _rl_last_c_pos -= wrap_offset;
1153+ cpos_adjusted = 1;
1154+ }
1155+ }
1156+ else
1157+ _rl_last_c_pos += temp;
1158 }
1159 }
1160 /* Otherwise, print over the existing material. */
1161@@ -1595,8 +1660,20 @@
1162 {
1163 if (temp > 0)
1164 {
1165+ /* If nfd begins at the prompt, or before the invisible
1166+ characters in the prompt, we need to adjust _rl_last_c_pos
1167+ in a multibyte locale to account for the wrap offset and
1168+ set cpos_adjusted accordingly. */
1169 _rl_output_some_chars (nfd, temp);
1170 _rl_last_c_pos += col_temp; /* XXX */
1171+ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
1172+ {
1173+ if (current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible))
1174+ {
1175+ _rl_last_c_pos -= wrap_offset;
1176+ cpos_adjusted = 1;
1177+ }
1178+ }
1179 }
1180 lendiff = (oe - old) - (ne - new);
1181 if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
1182@@ -1721,7 +1798,7 @@
1183 int woff; /* number of invisible chars on current line */
1184 int cpos, dpos; /* current and desired cursor positions */
1185
1186- woff = W_OFFSET (_rl_last_v_pos, wrap_offset);
1187+ woff = WRAP_OFFSET (_rl_last_v_pos, wrap_offset);
1188 cpos = _rl_last_c_pos;
1189 #if defined (HANDLE_MULTIBYTE)
1190 /* If we have multibyte characters, NEW is indexed by the buffer point in
1191@@ -1732,7 +1809,14 @@
1192 if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
1193 {
1194 dpos = _rl_col_width (data, 0, new);
1195- if (dpos > prompt_last_invisible) /* XXX - don't use woff here */
1196+ /* Use NEW when comparing against the last invisible character in the
1197+ prompt string, since they're both buffer indices and DPOS is a
1198+ desired display position. */
1199+ if ((new > prompt_last_invisible) || /* XXX - don't use woff here */
1200+ (prompt_physical_chars > _rl_screenwidth &&
1201+ _rl_last_v_pos == prompt_last_screen_line &&
1202+ wrap_offset != woff &&
1203+ new > (prompt_last_invisible-_rl_screenwidth-wrap_offset)))
1204 {
1205 dpos -= woff;
1206 /* Since this will be assigned to _rl_last_c_pos at the end (more
1207@@ -2380,6 +2464,8 @@
1208
1209 if (end <= start)
1210 return 0;
1211+ if (MB_CUR_MAX == 1 || rl_byte_oriented)
1212+ return (end - start);
1213
1214 memset (&ps, 0, sizeof (mbstate_t));
1215
1216diff -Naur bash-3.2.orig/lib/readline/input.c bash-3.2/lib/readline/input.c
1217--- bash-3.2.orig/lib/readline/input.c 2006-08-16 12:15:16.000000000 -0700
1218+++ bash-3.2/lib/readline/input.c 2009-01-08 16:15:50.000000000 -0800
1219@@ -133,8 +133,11 @@
1220 return (0);
1221
1222 *key = ibuffer[pop_index++];
1223-
1224+#if 0
1225 if (pop_index >= ibuffer_len)
1226+#else
1227+ if (pop_index > ibuffer_len)
1228+#endif
1229 pop_index = 0;
1230
1231 return (1);
1232@@ -151,7 +154,7 @@
1233 {
1234 pop_index--;
1235 if (pop_index < 0)
1236- pop_index = ibuffer_len - 1;
1237+ pop_index = ibuffer_len;
1238 ibuffer[pop_index] = key;
1239 return (1);
1240 }
1241@@ -250,7 +253,8 @@
1242 while (chars_avail--)
1243 {
1244 k = (*rl_getc_function) (rl_instream);
1245- rl_stuff_char (k);
1246+ if (rl_stuff_char (k) == 0)
1247+ break; /* some problem; no more room */
1248 if (k == NEWLINE || k == RETURN)
1249 break;
1250 }
1251@@ -373,7 +377,11 @@
1252 RL_SETSTATE (RL_STATE_INPUTPENDING);
1253 }
1254 ibuffer[push_index++] = key;
1255+#if 0
1256 if (push_index >= ibuffer_len)
1257+#else
1258+ if (push_index > ibuffer_len)
1259+#endif
1260 push_index = 0;
1261
1262 return 1;
1263@@ -513,20 +521,26 @@
1264 char *mbchar;
1265 int size;
1266 {
1267- int mb_len = 0;
1268+ int mb_len, c;
1269 size_t mbchar_bytes_length;
1270 wchar_t wc;
1271 mbstate_t ps, ps_back;
1272
1273 memset(&ps, 0, sizeof (mbstate_t));
1274 memset(&ps_back, 0, sizeof (mbstate_t));
1275-
1276+
1277+ mb_len = 0;
1278 while (mb_len < size)
1279 {
1280 RL_SETSTATE(RL_STATE_MOREINPUT);
1281- mbchar[mb_len++] = rl_read_key ();
1282+ c = rl_read_key ();
1283 RL_UNSETSTATE(RL_STATE_MOREINPUT);
1284
1285+ if (c < 0)
1286+ break;
1287+
1288+ mbchar[mb_len++] = c;
1289+
1290 mbchar_bytes_length = mbrtowc (&wc, mbchar, mb_len, &ps);
1291 if (mbchar_bytes_length == (size_t)(-1))
1292 break; /* invalid byte sequence for the current locale */
1293@@ -564,7 +578,7 @@
1294
1295 c = first;
1296 memset (mb, 0, mlen);
1297- for (i = 0; i < mlen; i++)
1298+ for (i = 0; c >= 0 && i < mlen; i++)
1299 {
1300 mb[i] = (char)c;
1301 memset (&ps, 0, sizeof (mbstate_t));
1302diff -Naur bash-3.2.orig/lib/readline/isearch.c bash-3.2/lib/readline/isearch.c
1303--- bash-3.2.orig/lib/readline/isearch.c 2005-12-26 14:18:53.000000000 -0800
1304+++ bash-3.2/lib/readline/isearch.c 2009-01-08 16:15:29.000000000 -0800
1305@@ -327,8 +327,15 @@
1306 rl_command_func_t *f;
1307
1308 f = (rl_command_func_t *)NULL;
1309-
1310- /* Translate the keys we do something with to opcodes. */
1311+
1312+ if (c < 0)
1313+ {
1314+ cxt->sflags |= SF_FAILED;
1315+ cxt->history_pos = cxt->last_found_line;
1316+ return -1;
1317+ }
1318+
1319+ /* Translate the keys we do something with to opcodes. */
1320 if (c >= 0 && _rl_keymap[c].type == ISFUNC)
1321 {
1322 f = _rl_keymap[c].function;
1323diff -Naur bash-3.2.orig/lib/readline/misc.c bash-3.2/lib/readline/misc.c
1324--- bash-3.2.orig/lib/readline/misc.c 2005-12-26 14:20:46.000000000 -0800
1325+++ bash-3.2/lib/readline/misc.c 2009-01-08 16:15:29.000000000 -0800
1326@@ -146,6 +146,8 @@
1327 rl_restore_prompt ();
1328 rl_clear_message ();
1329 RL_UNSETSTATE(RL_STATE_NUMERICARG);
1330+ if (key < 0)
1331+ return -1;
1332 return (_rl_dispatch (key, _rl_keymap));
1333 }
1334 }
1335diff -Naur bash-3.2.orig/lib/readline/readline.c bash-3.2/lib/readline/readline.c
1336--- bash-3.2.orig/lib/readline/readline.c 2006-08-16 12:00:36.000000000 -0700
1337+++ bash-3.2/lib/readline/readline.c 2009-01-08 16:15:29.000000000 -0800
1338@@ -645,6 +645,11 @@
1339 if ((cxt->flags & KSEQ_DISPATCHED) == 0)
1340 {
1341 nkey = _rl_subseq_getchar (cxt->okey);
1342+ if (nkey < 0)
1343+ {
1344+ _rl_abort_internal ();
1345+ return -1;
1346+ }
1347 r = _rl_dispatch_subseq (nkey, cxt->dmap, cxt->subseq_arg);
1348 cxt->flags |= KSEQ_DISPATCHED;
1349 }
1350diff -Naur bash-3.2.orig/lib/readline/text.c bash-3.2/lib/readline/text.c
1351--- bash-3.2.orig/lib/readline/text.c 2006-07-28 08:55:27.000000000 -0700
1352+++ bash-3.2/lib/readline/text.c 2009-01-08 16:15:29.000000000 -0800
1353@@ -857,6 +857,9 @@
1354 c = rl_read_key ();
1355 RL_UNSETSTATE(RL_STATE_MOREINPUT);
1356
1357+ if (c < 0)
1358+ return -1;
1359+
1360 #if defined (HANDLE_SIGNALS)
1361 if (RL_ISSTATE (RL_STATE_CALLBACK) == 0)
1362 _rl_restore_tty_signals ();
1363@@ -1520,6 +1523,9 @@
1364
1365 mb_len = _rl_read_mbchar (mbchar, MB_LEN_MAX);
1366
1367+ if (mb_len <= 0)
1368+ return -1;
1369+
1370 if (count < 0)
1371 return (_rl_char_search_internal (-count, bdir, mbchar, mb_len));
1372 else
1373@@ -1536,6 +1542,9 @@
1374 c = rl_read_key ();
1375 RL_UNSETSTATE(RL_STATE_MOREINPUT);
1376
1377+ if (c < 0)
1378+ return -1;
1379+
1380 if (count < 0)
1381 return (_rl_char_search_internal (-count, bdir, c));
1382 else
1383diff -Naur bash-3.2.orig/lib/readline/vi_mode.c bash-3.2/lib/readline/vi_mode.c
1384--- bash-3.2.orig/lib/readline/vi_mode.c 2006-07-29 13:42:28.000000000 -0700
1385+++ bash-3.2/lib/readline/vi_mode.c 2009-01-08 16:15:29.000000000 -0800
1386@@ -886,6 +886,13 @@
1387 RL_SETSTATE(RL_STATE_MOREINPUT);
1388 c = rl_read_key ();
1389 RL_UNSETSTATE(RL_STATE_MOREINPUT);
1390+
1391+ if (c < 0)
1392+ {
1393+ *nextkey = 0;
1394+ return -1;
1395+ }
1396+
1397 *nextkey = c;
1398
1399 if (!member (c, vi_motion))
1400@@ -902,6 +909,11 @@
1401 RL_SETSTATE(RL_STATE_MOREINPUT);
1402 c = rl_read_key (); /* real command */
1403 RL_UNSETSTATE(RL_STATE_MOREINPUT);
1404+ if (c < 0)
1405+ {
1406+ *nextkey = 0;
1407+ return -1;
1408+ }
1409 *nextkey = c;
1410 }
1411 else if (key == c && (key == 'd' || key == 'y' || key == 'c'))
1412@@ -1224,14 +1236,22 @@
1413 _rl_vi_callback_char_search (data)
1414 _rl_callback_generic_arg *data;
1415 {
1416+ int c;
1417 #if defined (HANDLE_MULTIBYTE)
1418- _rl_vi_last_search_mblen = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
1419+ c = _rl_vi_last_search_mblen = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
1420 #else
1421 RL_SETSTATE(RL_STATE_MOREINPUT);
1422- _rl_vi_last_search_char = rl_read_key ();
1423+ c = rl_read_key ();
1424 RL_UNSETSTATE(RL_STATE_MOREINPUT);
1425 #endif
1426
1427+ if (c <= 0)
1428+ return -1;
1429+
1430+#if !defined (HANDLE_MULTIBYTE)
1431+ _rl_vi_last_search_char = c;
1432+#endif
1433+
1434 _rl_callback_func = 0;
1435 _rl_want_redisplay = 1;
1436
1437@@ -1247,6 +1267,7 @@
1438 rl_vi_char_search (count, key)
1439 int count, key;
1440 {
1441+ int c;
1442 #if defined (HANDLE_MULTIBYTE)
1443 static char *target;
1444 static int tlen;
1445@@ -1293,11 +1314,17 @@
1446 else
1447 {
1448 #if defined (HANDLE_MULTIBYTE)
1449- _rl_vi_last_search_mblen = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
1450+ c = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
1451+ if (c <= 0)
1452+ return -1;
1453+ _rl_vi_last_search_mblen = c;
1454 #else
1455 RL_SETSTATE(RL_STATE_MOREINPUT);
1456- _rl_vi_last_search_char = rl_read_key ();
1457+ c = rl_read_key ();
1458 RL_UNSETSTATE(RL_STATE_MOREINPUT);
1459+ if (c < 0)
1460+ return -1;
1461+ _rl_vi_last_search_char = c;
1462 #endif
1463 }
1464 }
1465@@ -1467,6 +1494,9 @@
1466 c = rl_read_key ();
1467 RL_UNSETSTATE(RL_STATE_MOREINPUT);
1468
1469+ if (c < 0)
1470+ return -1;
1471+
1472 #if defined (HANDLE_MULTIBYTE)
1473 if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
1474 c = _rl_read_mbstring (c, mb, mlen);
1475@@ -1485,6 +1515,9 @@
1476
1477 _rl_vi_last_replacement = c = _rl_vi_callback_getchar (mb, MB_LEN_MAX);
1478
1479+ if (c < 0)
1480+ return -1;
1481+
1482 _rl_callback_func = 0;
1483 _rl_want_redisplay = 1;
1484
1485@@ -1516,6 +1549,9 @@
1486 else
1487 _rl_vi_last_replacement = c = _rl_vi_callback_getchar (mb, MB_LEN_MAX);
1488
1489+ if (c < 0)
1490+ return -1;
1491+
1492 return (_rl_vi_change_char (count, c, mb));
1493 }
1494
1495@@ -1650,7 +1686,7 @@
1496 ch = rl_read_key ();
1497 RL_UNSETSTATE(RL_STATE_MOREINPUT);
1498
1499- if (ch < 'a' || ch > 'z')
1500+ if (ch < 0 || ch < 'a' || ch > 'z') /* make test against 0 explicit */
1501 {
1502 rl_ding ();
1503 return -1;
1504@@ -1702,7 +1738,7 @@
1505 rl_point = rl_mark;
1506 return 0;
1507 }
1508- else if (ch < 'a' || ch > 'z')
1509+ else if (ch < 0 || ch < 'a' || ch > 'z') /* make test against 0 explicit */
1510 {
1511 rl_ding ();
1512 return -1;
1513diff -Naur bash-3.2.orig/lib/sh/getcwd.c bash-3.2/lib/sh/getcwd.c
1514--- bash-3.2.orig/lib/sh/getcwd.c 2004-07-21 14:15:19.000000000 -0700
1515+++ bash-3.2/lib/sh/getcwd.c 2009-01-08 16:15:58.000000000 -0800
1516@@ -251,19 +251,21 @@
1517
1518 {
1519 size_t len = pathbuf + pathsize - pathp;
1520+ if (buf == NULL && size <= 0)
1521+ size = len;
1522+
1523+ if ((size_t) size < len)
1524+ {
1525+ errno = ERANGE;
1526+ goto lose2;
1527+ }
1528 if (buf == NULL)
1529 {
1530- if (len < (size_t) size)
1531- len = size;
1532- buf = (char *) malloc (len);
1533+ buf = (char *) malloc (size);
1534 if (buf == NULL)
1535 goto lose2;
1536 }
1537- else if ((size_t) size < len)
1538- {
1539- errno = ERANGE;
1540- goto lose2;
1541- }
1542+
1543 (void) memcpy((PTR_T) buf, (PTR_T) pathp, len);
1544 }
1545
1546diff -Naur bash-3.2.orig/lib/sh/snprintf.c bash-3.2/lib/sh/snprintf.c
1547--- bash-3.2.orig/lib/sh/snprintf.c 2006-04-06 06:48:40.000000000 -0700
1548+++ bash-3.2/lib/sh/snprintf.c 2009-01-08 16:15:13.000000000 -0800
1549@@ -471,6 +471,8 @@
1550 10^x ~= r
1551 * log_10(200) = 2;
1552 * log_10(250) = 2;
1553+ *
1554+ * NOTE: do not call this with r == 0 -- an infinite loop results.
1555 */
1556 static int
1557 log_10(r)
1558@@ -576,8 +578,11 @@
1559 {
1560 integral_part[0] = '0';
1561 integral_part[1] = '\0';
1562- fraction_part[0] = '0';
1563- fraction_part[1] = '\0';
1564+ /* The fractional part has to take the precision into account */
1565+ for (ch = 0; ch < precision-1; ch++)
1566+ fraction_part[ch] = '0';
1567+ fraction_part[ch] = '0';
1568+ fraction_part[ch+1] = '\0';
1569 if (fract)
1570 *fract = fraction_part;
1571 return integral_part;
1572@@ -663,7 +668,8 @@
1573 p->flags &= ~PF_ZEROPAD;
1574
1575 sd = d; /* signed for ' ' padding in base 10 */
1576- flags = (*p->pf == 'u' || *p->pf == 'U') ? FL_UNSIGNED : 0;
1577+ flags = 0;
1578+ flags = (*p->pf == 'x' || *p->pf == 'X' || *p->pf == 'o' || *p->pf == 'u' || *p->pf == 'U') ? FL_UNSIGNED : 0;
1579 if (*p->pf == 'X')
1580 flags |= FL_HEXUPPER;
1581
1582@@ -733,7 +739,7 @@
1583 p->flags &= ~PF_ZEROPAD;
1584
1585 sd = d; /* signed for ' ' padding in base 10 */
1586- flags = (*p->pf == 'u' || *p->pf == 'U') ? FL_UNSIGNED : 0;
1587+ flags = (*p->pf == 'x' || *p->pf == 'X' || *p->pf == 'o' || *p->pf == 'u' || *p->pf == 'U') ? FL_UNSIGNED : 0;
1588 if (*p->pf == 'X')
1589 flags |= FL_HEXUPPER;
1590
1591@@ -805,6 +811,7 @@
1592 PUT_CHAR(*tmp, p);
1593 tmp++;
1594 }
1595+
1596 PAD_LEFT(p);
1597 }
1598
1599@@ -972,11 +979,21 @@
1600 if ((p->flags & PF_THOUSANDS) && grouping && (t = groupnum (tmp)))
1601 tmp = t;
1602
1603+ if ((*p->pf == 'g' || *p->pf == 'G') && (p->flags & PF_ALTFORM) == 0)
1604+ {
1605+ /* smash the trailing zeros unless altform */
1606+ for (i = strlen(tmp2) - 1; i >= 0 && tmp2[i] == '0'; i--)
1607+ tmp2[i] = '\0';
1608+ if (tmp2[0] == '\0')
1609+ p->precision = 0;
1610+ }
1611+
1612 /* calculate the padding. 1 for the dot */
1613 p->width = p->width -
1614 ((d > 0. && p->justify == RIGHT) ? 1:0) -
1615 ((p->flags & PF_SPACE) ? 1:0) -
1616- strlen(tmp) - p->precision - 1;
1617+ strlen(tmp) - p->precision -
1618+ ((p->precision != 0 || (p->flags & PF_ALTFORM)) ? 1 : 0); /* radix char */
1619 PAD_RIGHT(p);
1620 PUT_PLUS(d, p, 0.);
1621 PUT_SPACE(d, p, 0.);
1622@@ -991,11 +1008,6 @@
1623 if (p->precision != 0 || (p->flags & PF_ALTFORM))
1624 PUT_CHAR(decpoint, p); /* put the '.' */
1625
1626- if ((*p->pf == 'g' || *p->pf == 'G') && (p->flags & PF_ALTFORM) == 0)
1627- /* smash the trailing zeros unless altform */
1628- for (i = strlen(tmp2) - 1; i >= 0 && tmp2[i] == '0'; i--)
1629- tmp2[i] = '\0';
1630-
1631 for (; *tmp2; tmp2++)
1632 PUT_CHAR(*tmp2, p); /* the fraction */
1633
1634@@ -1011,14 +1023,19 @@
1635 char *tmp, *tmp2;
1636 int j, i;
1637
1638- if (chkinfnan(p, d, 1) || chkinfnan(p, d, 2))
1639+ if (d != 0 && (chkinfnan(p, d, 1) || chkinfnan(p, d, 2)))
1640 return; /* already printed nan or inf */
1641
1642 GETLOCALEDATA(decpoint, thoussep, grouping);
1643 DEF_PREC(p);
1644- j = log_10(d);
1645- d = d / pow_10(j); /* get the Mantissa */
1646- d = ROUND(d, p);
1647+ if (d == 0.)
1648+ j = 0;
1649+ else
1650+ {
1651+ j = log_10(d);
1652+ d = d / pow_10(j); /* get the Mantissa */
1653+ d = ROUND(d, p);
1654+ }
1655 tmp = dtoa(d, p->precision, &tmp2);
1656
1657 /* 1 for unit, 1 for the '.', 1 for 'e|E',
1658@@ -1076,6 +1093,7 @@
1659 PUT_CHAR(*tmp, p);
1660 tmp++;
1661 }
1662+
1663 PAD_LEFT(p);
1664 }
1665 #endif
1666@@ -1358,7 +1376,7 @@
1667 STAR_ARGS(data);
1668 DEF_PREC(data);
1669 d = GETDOUBLE(data);
1670- i = log_10(d);
1671+ i = (d != 0.) ? log_10(d) : -1;
1672 /*
1673 * for '%g|%G' ANSI: use f if exponent
1674 * is in the range or [-4,p] exclusively
1675diff -Naur bash-3.2.orig/parse.y bash-3.2/parse.y
1676--- bash-3.2.orig/parse.y 2006-09-19 13:37:21.000000000 -0700
1677+++ bash-3.2/parse.y 2009-01-08 16:16:03.000000000 -0800
1678@@ -1029,6 +1029,7 @@
1679 #define PST_CMDTOKEN 0x1000 /* command token OK - unused */
1680 #define PST_COMPASSIGN 0x2000 /* parsing x=(...) compound assignment */
1681 #define PST_ASSIGNOK 0x4000 /* assignment statement ok in this context */
1682+#define PST_REGEXP 0x8000 /* parsing an ERE/BRE as a single word */
1683
1684 /* Initial size to allocate for tokens, and the
1685 amount to grow them by. */
1686@@ -2591,6 +2592,9 @@
1687 return (character);
1688 }
1689
1690+ if (parser_state & PST_REGEXP)
1691+ goto tokword;
1692+
1693 /* Shell meta-characters. */
1694 if MBTEST(shellmeta (character) && ((parser_state & PST_DBLPAREN) == 0))
1695 {
1696@@ -2698,6 +2702,7 @@
1697 if MBTEST(character == '-' && (last_read_token == LESS_AND || last_read_token == GREATER_AND))
1698 return (character);
1699
1700+tokword:
1701 /* Okay, if we got this far, we have to read a word. Read one,
1702 and then check it against the known ones. */
1703 result = read_token_word (character);
1704@@ -2735,7 +2740,7 @@
1705 /* itrace("parse_matched_pair: open = %c close = %c", open, close); */
1706 count = 1;
1707 pass_next_character = backq_backslash = was_dollar = in_comment = 0;
1708- check_comment = (flags & P_COMMAND) && qc != '\'' && qc != '"' && (flags & P_DQUOTE) == 0;
1709+ check_comment = (flags & P_COMMAND) && qc != '`' && qc != '\'' && qc != '"' && (flags & P_DQUOTE) == 0;
1710
1711 /* RFLAGS is the set of flags we want to pass to recursive calls. */
1712 rflags = (qc == '"') ? P_DQUOTE : (flags & P_DQUOTE);
1713@@ -3202,8 +3207,11 @@
1714 if (tok == WORD && test_binop (yylval.word->word))
1715 op = yylval.word;
1716 #if defined (COND_REGEXP)
1717- else if (tok == WORD && STREQ (yylval.word->word,"=~"))
1718- op = yylval.word;
1719+ else if (tok == WORD && STREQ (yylval.word->word, "=~"))
1720+ {
1721+ op = yylval.word;
1722+ parser_state |= PST_REGEXP;
1723+ }
1724 #endif
1725 else if (tok == '<' || tok == '>')
1726 op = make_word_from_token (tok); /* ( */
1727@@ -3234,6 +3242,7 @@
1728
1729 /* rhs */
1730 tok = read_token (READ);
1731+ parser_state &= ~PST_REGEXP;
1732 if (tok == WORD)
1733 {
1734 tright = make_cond_node (COND_TERM, yylval.word, (COND_COM *)NULL, (COND_COM *)NULL);
1735@@ -3367,7 +3376,7 @@
1736 if (pass_next_character)
1737 {
1738 pass_next_character = 0;
1739- goto got_character;
1740+ goto got_escaped_character;
1741 }
1742
1743 cd = current_delimiter (dstack);
1744@@ -3419,9 +3428,34 @@
1745 goto next_character;
1746 }
1747
1748+#ifdef COND_REGEXP
1749+ /* When parsing a regexp as a single word inside a conditional command,
1750+ we need to special-case characters special to both the shell and
1751+ regular expressions. Right now, that is only '(' and '|'. */ /*)*/
1752+ if MBTEST((parser_state & PST_REGEXP) && (character == '(' || character == '|')) /*)*/
1753+ {
1754+ if (character == '|')
1755+ goto got_character;
1756+
1757+ push_delimiter (dstack, character);
1758+ ttok = parse_matched_pair (cd, '(', ')', &ttoklen, 0);
1759+ pop_delimiter (dstack);
1760+ if (ttok == &matched_pair_error)
1761+ return -1; /* Bail immediately. */
1762+ RESIZE_MALLOCED_BUFFER (token, token_index, ttoklen + 2,
1763+ token_buffer_size, TOKEN_DEFAULT_GROW_SIZE);
1764+ token[token_index++] = character;
1765+ strcpy (token + token_index, ttok);
1766+ token_index += ttoklen;
1767+ FREE (ttok);
1768+ dollar_present = all_digit_token = 0;
1769+ goto next_character;
1770+ }
1771+#endif /* COND_REGEXP */
1772+
1773 #ifdef EXTENDED_GLOB
1774 /* Parse a ksh-style extended pattern matching specification. */
1775- if (extended_glob && PATTERN_CHAR (character))
1776+ if MBTEST(extended_glob && PATTERN_CHAR (character))
1777 {
1778 peek_char = shell_getc (1);
1779 if MBTEST(peek_char == '(') /* ) */
1780@@ -3616,12 +3650,14 @@
1781
1782 got_character:
1783
1784- all_digit_token &= DIGIT (character);
1785- dollar_present |= character == '$';
1786-
1787 if (character == CTLESC || character == CTLNUL)
1788 token[token_index++] = CTLESC;
1789
1790+ got_escaped_character:
1791+
1792+ all_digit_token &= DIGIT (character);
1793+ dollar_present |= character == '$';
1794+
1795 token[token_index++] = character;
1796
1797 RESIZE_MALLOCED_BUFFER (token, token_index, 1, token_buffer_size,
1798@@ -4330,7 +4366,7 @@
1799 if (promptvars || posixly_correct)
1800 {
1801 last_exit_value = last_command_exit_value;
1802- list = expand_prompt_string (result, Q_DOUBLE_QUOTES);
1803+ list = expand_prompt_string (result, Q_DOUBLE_QUOTES, 0);
1804 free (result);
1805 result = string_list (list);
1806 dispose_words (list);
1807diff -Naur bash-3.2.orig/patchlevel.h bash-3.2/patchlevel.h
1808--- bash-3.2.orig/patchlevel.h 2006-04-13 05:31:04.000000000 -0700
1809+++ bash-3.2/patchlevel.h 2009-01-08 16:16:26.000000000 -0800
1810@@ -25,6 +25,6 @@
1811 regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
1812 looks for to find the patch level (for the sccs version string). */
1813
1814-#define PATCHLEVEL 0
1815+#define PATCHLEVEL 48
1816
1817 #endif /* _PATCHLEVEL_H_ */
1818diff -Naur bash-3.2.orig/pathexp.c bash-3.2/pathexp.c
1819--- bash-3.2.orig/pathexp.c 2002-05-06 10:43:05.000000000 -0700
1820+++ bash-3.2/pathexp.c 2009-01-08 16:15:15.000000000 -0800
1821@@ -1,6 +1,6 @@
1822 /* pathexp.c -- The shell interface to the globbing library. */
1823
1824-/* Copyright (C) 1995-2002 Free Software Foundation, Inc.
1825+/* Copyright (C) 1995-2007 Free Software Foundation, Inc.
1826
1827 This file is part of GNU Bash, the Bourne Again SHell.
1828
1829@@ -110,6 +110,33 @@
1830 return (0);
1831 }
1832
1833+/* Return 1 if C is a character that is `special' in a POSIX ERE and needs to
1834+ be quoted to match itself. */
1835+static inline int
1836+ere_char (c)
1837+ int c;
1838+{
1839+ switch (c)
1840+ {
1841+ case '.':
1842+ case '[':
1843+ case '\\':
1844+ case '(':
1845+ case ')':
1846+ case '*':
1847+ case '+':
1848+ case '?':
1849+ case '{':
1850+ case '|':
1851+ case '^':
1852+ case '$':
1853+ return 1;
1854+ default:
1855+ return 0;
1856+ }
1857+ return (0);
1858+}
1859+
1860 /* PATHNAME can contain characters prefixed by CTLESC; this indicates
1861 that the character is to be quoted. We quote it here in the style
1862 that the glob library recognizes. If flags includes QGLOB_CVTNULL,
1863@@ -142,6 +169,8 @@
1864 {
1865 if ((qflags & QGLOB_FILENAME) && pathname[i+1] == '/')
1866 continue;
1867+ if ((qflags & QGLOB_REGEXP) && ere_char (pathname[i+1]) == 0)
1868+ continue;
1869 temp[j++] = '\\';
1870 i++;
1871 if (pathname[i] == '\0')
1872diff -Naur bash-3.2.orig/pathexp.h bash-3.2/pathexp.h
1873--- bash-3.2.orig/pathexp.h 2005-02-19 14:23:18.000000000 -0800
1874+++ bash-3.2/pathexp.h 2009-01-08 16:15:15.000000000 -0800
1875@@ -1,6 +1,6 @@
1876 /* pathexp.h -- The shell interface to the globbing library. */
1877
1878-/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
1879+/* Copyright (C) 1987-2007 Free Software Foundation, Inc.
1880
1881 This file is part of GNU Bash, the Bourne Again SHell.
1882
1883@@ -32,6 +32,7 @@
1884 /* Flag values for quote_string_for_globbing */
1885 #define QGLOB_CVTNULL 0x01 /* convert QUOTED_NULL strings to '\0' */
1886 #define QGLOB_FILENAME 0x02 /* do correct quoting for matching filenames */
1887+#define QGLOB_REGEXP 0x04 /* quote an ERE for regcomp/regexec */
1888
1889 #if defined (EXTENDED_GLOB)
1890 /* Flags to OR with other flag args to strmatch() to enabled the extended
1891diff -Naur bash-3.2.orig/po/ru.po bash-3.2/po/ru.po
1892--- bash-3.2.orig/po/ru.po 2006-01-10 14:51:03.000000000 -0800
1893+++ bash-3.2/po/ru.po 2009-01-08 16:15:00.000000000 -0800
1894@@ -12,7 +12,7 @@
1895 "Last-Translator: Evgeniy Dushistov <dushistov@mail.ru>\n"
1896 "Language-Team: Russian <ru@li.org>\n"
1897 "MIME-Version: 1.0\n"
1898-"Content-Type: text/plain; charset=UTF-8\n"
1899+"Content-Type: text/plain; charset=KOI8-R\n"
1900 "Content-Transfer-Encoding: 8bit\n"
1901 "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
1902
1903diff -Naur bash-3.2.orig/shell.h bash-3.2/shell.h
1904--- bash-3.2.orig/shell.h 2003-06-01 12:04:36.000000000 -0700
1905+++ bash-3.2/shell.h 2009-01-08 16:16:06.000000000 -0800
1906@@ -89,6 +89,7 @@
1907 extern int executing, login_shell;
1908 extern int interactive, interactive_shell;
1909 extern int startup_state;
1910+extern int shell_compatibility_level;
1911
1912 /* Structure to pass around that holds a bitmap of file descriptors
1913 to close, and the size of that structure. Used in execute_cmd.c. */
1914diff -Naur bash-3.2.orig/sig.c bash-3.2/sig.c
1915--- bash-3.2.orig/sig.c 2006-01-25 11:57:59.000000000 -0800
1916+++ bash-3.2/sig.c 2009-01-08 16:15:30.000000000 -0800
1917@@ -350,6 +350,25 @@
1918 #undef XSIG
1919 #undef XHANDLER
1920
1921+/* Run some of the cleanups that should be performed when we run
1922+ jump_to_top_level from a builtin command context. XXX - might want to
1923+ also call reset_parser here. */
1924+void
1925+top_level_cleanup ()
1926+{
1927+ /* Clean up string parser environment. */
1928+ while (parse_and_execute_level)
1929+ parse_and_execute_cleanup ();
1930+
1931+#if defined (PROCESS_SUBSTITUTION)
1932+ unlink_fifo_list ();
1933+#endif /* PROCESS_SUBSTITUTION */
1934+
1935+ run_unwind_protects ();
1936+ loop_level = continuing = breaking = 0;
1937+ return_catch_flag = 0;
1938+}
1939+
1940 /* What to do when we've been interrupted, and it is safe to handle it. */
1941 void
1942 throw_to_top_level ()
1943diff -Naur bash-3.2.orig/sig.h bash-3.2/sig.h
1944--- bash-3.2.orig/sig.h 2006-01-25 11:50:27.000000000 -0800
1945+++ bash-3.2/sig.h 2009-01-08 16:15:30.000000000 -0800
1946@@ -121,6 +121,7 @@
1947 extern void initialize_signals __P((int));
1948 extern void initialize_terminating_signals __P((void));
1949 extern void reset_terminating_signals __P((void));
1950+extern void top_level_cleanup __P((void));
1951 extern void throw_to_top_level __P((void));
1952 extern void jump_to_top_level __P((int)) __attribute__((__noreturn__));
1953
1954diff -Naur bash-3.2.orig/subst.c bash-3.2/subst.c
1955--- bash-3.2.orig/subst.c 2006-09-19 05:35:09.000000000 -0700
1956+++ bash-3.2/subst.c 2009-01-08 16:16:19.000000000 -0800
1957@@ -4,7 +4,7 @@
1958 /* ``Have a little faith, there's magic in the night. You ain't a
1959 beauty, but, hey, you're alright.'' */
1960
1961-/* Copyright (C) 1987-2006 Free Software Foundation, Inc.
1962+/* Copyright (C) 1987-2007 Free Software Foundation, Inc.
1963
1964 This file is part of GNU Bash, the Bourne Again SHell.
1965
1966@@ -137,7 +137,7 @@
1967 /* Extern functions and variables from different files. */
1968 extern int last_command_exit_value, last_command_exit_signal;
1969 extern int subshell_environment;
1970-extern int subshell_level;
1971+extern int subshell_level, parse_and_execute_level;
1972 extern int eof_encountered;
1973 extern int return_catch_flag, return_catch_value;
1974 extern pid_t dollar_dollar_pid;
1975@@ -1278,7 +1278,7 @@
1976 {
1977 if (no_longjmp_on_fatal_error == 0)
1978 { /* { */
1979- report_error ("bad substitution: no closing `%s' in %s", "}", string);
1980+ report_error (_("bad substitution: no closing `%s' in %s"), "}", string);
1981 last_command_exit_value = EXECUTION_FAILURE;
1982 exp_jump_to_top_level (DISCARD);
1983 }
1984@@ -1887,7 +1887,13 @@
1985 sep[1] = '\0';
1986 #endif
1987
1988+ /* XXX -- why call quote_list if ifs == 0? we can get away without doing
1989+ it now that quote_escapes quotes spaces */
1990+#if 0
1991 tlist = ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) || (ifs && *ifs == 0))
1992+#else
1993+ tlist = (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))
1994+#endif
1995 ? quote_list (list)
1996 : list_quote_escapes (list);
1997
1998@@ -2646,11 +2652,12 @@
1999
2000 /* This needs better error handling. */
2001 /* Expand W for use as an argument to a unary or binary operator in a
2002- [[...]] expression. If SPECIAL is nonzero, this is the rhs argument
2003+ [[...]] expression. If SPECIAL is 1, this is the rhs argument
2004 to the != or == operator, and should be treated as a pattern. In
2005- this case, we quote the string specially for the globbing code. The
2006- caller is responsible for removing the backslashes if the unquoted
2007- words is needed later. */
2008+ this case, we quote the string specially for the globbing code. If
2009+ SPECIAL is 2, this is an rhs argument for the =~ operator, and should
2010+ be quoted appropriately for regcomp/regexec. The caller is responsible
2011+ for removing the backslashes if the unquoted word is needed later. */
2012 char *
2013 cond_expand_word (w, special)
2014 WORD_DESC *w;
2015@@ -2658,6 +2665,7 @@
2016 {
2017 char *r, *p;
2018 WORD_LIST *l;
2019+ int qflags;
2020
2021 if (w->word == 0 || w->word[0] == '\0')
2022 return ((char *)NULL);
2023@@ -2672,8 +2680,11 @@
2024 }
2025 else
2026 {
2027+ qflags = QGLOB_CVTNULL;
2028+ if (special == 2)
2029+ qflags |= QGLOB_REGEXP;
2030 p = string_list (l);
2031- r = quote_string_for_globbing (p, QGLOB_CVTNULL);
2032+ r = quote_string_for_globbing (p, qflags);
2033 free (p);
2034 }
2035 dispose_words (l);
2036@@ -2803,9 +2814,10 @@
2037 passed string when an error occurs. Might want to trap other calls
2038 to jump_to_top_level here so we don't endlessly loop. */
2039 WORD_LIST *
2040-expand_prompt_string (string, quoted)
2041+expand_prompt_string (string, quoted, wflags)
2042 char *string;
2043 int quoted;
2044+ int wflags;
2045 {
2046 WORD_LIST *value;
2047 WORD_DESC td;
2048@@ -2813,7 +2825,7 @@
2049 if (string == 0 || *string == 0)
2050 return ((WORD_LIST *)NULL);
2051
2052- td.flags = 0;
2053+ td.flags = wflags;
2054 td.word = savestring (string);
2055
2056 no_longjmp_on_fatal_error = 1;
2057@@ -2916,7 +2928,12 @@
2058
2059 /* Quote escape characters in string s, but no other characters. This is
2060 used to protect CTLESC and CTLNUL in variable values from the rest of
2061- the word expansion process after the variable is expanded. */
2062+ the word expansion process after the variable is expanded. If IFS is
2063+ null, we quote spaces as well, just in case we split on spaces later
2064+ (in the case of unquoted $@, we will eventually attempt to split the
2065+ entire word on spaces). Corresponding code exists in dequote_escapes.
2066+ Even if we don't end up splitting on spaces, quoting spaces is not a
2067+ problem. */
2068 char *
2069 quote_escapes (string)
2070 char *string;
2071@@ -2924,17 +2941,19 @@
2072 register char *s, *t;
2073 size_t slen;
2074 char *result, *send;
2075+ int quote_spaces;
2076 DECLARE_MBSTATE;
2077
2078 slen = strlen (string);
2079 send = string + slen;
2080
2081+ quote_spaces = (ifs_value && *ifs_value == 0);
2082 t = result = (char *)xmalloc ((slen * 2) + 1);
2083 s = string;
2084
2085 while (*s)
2086 {
2087- if (*s == CTLESC || *s == CTLNUL)
2088+ if (*s == CTLESC || *s == CTLNUL || (quote_spaces && *s == ' '))
2089 *t++ = CTLESC;
2090 COPY_CHAR_P (t, s, send);
2091 }
2092@@ -2976,6 +2995,7 @@
2093 register char *s, *t;
2094 size_t slen;
2095 char *result, *send;
2096+ int quote_spaces;
2097 DECLARE_MBSTATE;
2098
2099 if (string == 0)
2100@@ -2990,9 +3010,10 @@
2101 if (strchr (string, CTLESC) == 0)
2102 return (strcpy (result, s));
2103
2104+ quote_spaces = (ifs_value && *ifs_value == 0);
2105 while (*s)
2106 {
2107- if (*s == CTLESC && (s[1] == CTLESC || s[1] == CTLNUL))
2108+ if (*s == CTLESC && (s[1] == CTLESC || s[1] == CTLNUL || (quote_spaces && s[1] == ' ')))
2109 {
2110 s++;
2111 if (*s == '\0')
2112@@ -3954,7 +3975,11 @@
2113 if (patspec == RP_LONG_LEFT || patspec == RP_LONG_RIGHT)
2114 patstr++;
2115
2116- pattern = getpattern (patstr, quoted, 1);
2117+ /* Need to pass getpattern newly-allocated memory in case of expansion --
2118+ the expansion code will free the passed string on an error. */
2119+ temp1 = savestring (patstr);
2120+ pattern = getpattern (temp1, quoted, 1);
2121+ free (temp1);
2122
2123 temp1 = (char *)NULL; /* shut up gcc */
2124 switch (vtype)
2125@@ -4123,6 +4148,12 @@
2126 nfifo = 0;
2127 }
2128
2129+int
2130+fifos_pending ()
2131+{
2132+ return nfifo;
2133+}
2134+
2135 static char *
2136 make_named_pipe ()
2137 {
2138@@ -4172,6 +4203,12 @@
2139 nfds++;
2140 }
2141
2142+int
2143+fifos_pending ()
2144+{
2145+ return 0; /* used for cleanup; not needed with /dev/fd */
2146+}
2147+
2148 void
2149 unlink_fifo_list ()
2150 {
2151@@ -4456,7 +4493,15 @@
2152 /* Add the character to ISTRING, possibly after resizing it. */
2153 RESIZE_MALLOCED_BUFFER (istring, istring_index, 2, istring_size, DEFAULT_ARRAY_SIZE);
2154
2155- if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) || c == CTLESC || c == CTLNUL)
2156+ /* This is essentially quote_string inline */
2157+ if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) /* || c == CTLESC || c == CTLNUL */)
2158+ istring[istring_index++] = CTLESC;
2159+ /* Escape CTLESC and CTLNUL in the output to protect those characters
2160+ from the rest of the word expansions (word splitting and globbing.)
2161+ This is essentially quote_escapes inline. */
2162+ else if (c == CTLESC)
2163+ istring[istring_index++] = CTLESC;
2164+ else if (c == CTLNUL || (c == ' ' && (ifs_value && *ifs_value == 0)))
2165 istring[istring_index++] = CTLESC;
2166
2167 istring[istring_index++] = c;
2168@@ -4578,7 +4623,8 @@
2169 #if defined (JOB_CONTROL)
2170 set_sigchld_handler ();
2171 stop_making_children ();
2172- pipeline_pgrp = old_pipeline_pgrp;
2173+ if (pid != 0)
2174+ pipeline_pgrp = old_pipeline_pgrp;
2175 #else
2176 stop_making_children ();
2177 #endif /* JOB_CONTROL */
2178@@ -4665,6 +4711,9 @@
2179
2180 last_command_exit_value = rc;
2181 rc = run_exit_trap ();
2182+#if defined (PROCESS_SUBSTITUTION)
2183+ unlink_fifo_list ();
2184+#endif
2185 exit (rc);
2186 }
2187 else
2188@@ -4763,7 +4812,7 @@
2189 else
2190 t = (ind == 0) ? value_cell (var) : (char *)NULL;
2191
2192- len = STRLEN (t);
2193+ len = MB_STRLEN (t);
2194 return (len);
2195 }
2196 #endif /* ARRAY_VARS */
2197@@ -4860,10 +4909,11 @@
2198 char *temp, *tt;
2199 intmax_t arg_index;
2200 SHELL_VAR *var;
2201- int atype;
2202+ int atype, rflags;
2203
2204 ret = 0;
2205 temp = 0;
2206+ rflags = 0;
2207
2208 /* Handle multiple digit arguments, as in ${11}. */
2209 if (legal_number (name, &arg_index))
2210@@ -4896,6 +4946,8 @@
2211 temp = (*temp && (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)))
2212 ? quote_string (temp)
2213 : quote_escapes (temp);
2214+ else if (atype == 1 && temp && QUOTED_NULL (temp) && (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)))
2215+ rflags |= W_HASQUOTEDNULL;
2216 }
2217 #endif
2218 else if (var = find_variable (name))
2219@@ -4923,6 +4975,7 @@
2220 {
2221 ret = alloc_word_desc ();
2222 ret->word = temp;
2223+ ret->flags |= rflags;
2224 }
2225 return ret;
2226 }
2227@@ -5546,12 +5599,16 @@
2228 so verify_substring_values just returns the numbers specified and we
2229 rely on array_subrange to understand how to deal with them). */
2230 tt = array_subrange (array_cell (v), e1, e2, starsub, quoted);
2231+#if 0
2232+ /* array_subrange now calls array_quote_escapes as appropriate, so the
2233+ caller no longer needs to. */
2234 if ((quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) == 0)
2235 {
2236 temp = tt ? quote_escapes (tt) : (char *)NULL;
2237 FREE (tt);
2238 }
2239 else
2240+#endif
2241 temp = tt;
2242 break;
2243 #endif
2244@@ -5707,6 +5764,11 @@
2245 vtype &= ~VT_STARSUB;
2246
2247 mflags = 0;
2248+ if (patsub && *patsub == '/')
2249+ {
2250+ mflags |= MATCH_GLOBREP;
2251+ patsub++;
2252+ }
2253
2254 /* Malloc this because expand_string_if_necessary or one of the expansion
2255 functions in its call chain may free it on a substitution error. */
2256@@ -5741,13 +5803,12 @@
2257 }
2258
2259 /* ksh93 doesn't allow the match specifier to be a part of the expanded
2260- pattern. This is an extension. */
2261+ pattern. This is an extension. Make sure we don't anchor the pattern
2262+ at the beginning or end of the string if we're doing global replacement,
2263+ though. */
2264 p = pat;
2265- if (pat && pat[0] == '/')
2266- {
2267- mflags |= MATCH_GLOBREP|MATCH_ANY;
2268- p++;
2269- }
2270+ if (mflags & MATCH_GLOBREP)
2271+ mflags |= MATCH_ANY;
2272 else if (pat && pat[0] == '#')
2273 {
2274 mflags |= MATCH_BEG;
2275@@ -5798,12 +5859,16 @@
2276 #if defined (ARRAY_VARS)
2277 case VT_ARRAYVAR:
2278 temp = array_patsub (array_cell (v), p, rep, mflags);
2279+#if 0
2280+ /* Don't need to do this anymore; array_patsub calls array_quote_escapes
2281+ as appropriate before adding the space separators. */
2282 if (temp && (mflags & MATCH_QUOTED) == 0)
2283 {
2284 tt = quote_escapes (temp);
2285 free (temp);
2286 temp = tt;
2287 }
2288+#endif
2289 break;
2290 #endif
2291 }
2292@@ -7607,6 +7672,10 @@
2293 expand_no_split_dollar_star = 0; /* XXX */
2294 expanding_redir = 0;
2295
2296+ if (parse_and_execute_level == 0)
2297+ top_level_cleanup (); /* from sig.c */
2298+
2299+
2300 jump_to_top_level (v);
2301 }
2302
2303@@ -7824,7 +7893,7 @@
2304 else if (fail_glob_expansion != 0)
2305 {
2306 report_error (_("no match: %s"), tlist->word->word);
2307- jump_to_top_level (DISCARD);
2308+ exp_jump_to_top_level (DISCARD);
2309 }
2310 else if (allow_null_glob_expansion == 0)
2311 {
2312diff -Naur bash-3.2.orig/subst.h bash-3.2/subst.h
2313--- bash-3.2.orig/subst.h 2006-09-19 05:34:41.000000000 -0700
2314+++ bash-3.2/subst.h 2009-01-08 16:16:03.000000000 -0800
2315@@ -135,7 +135,7 @@
2316 extern WORD_LIST *expand_string_assignment __P((char *, int));
2317
2318 /* Expand a prompt string. */
2319-extern WORD_LIST *expand_prompt_string __P((char *, int));
2320+extern WORD_LIST *expand_prompt_string __P((char *, int, int));
2321
2322 /* Expand STRING just as if you were expanding a word. This also returns
2323 a list of words. Note that filename globbing is *NOT* done for word
2324@@ -222,6 +222,7 @@
2325 extern char *command_substitute __P((char *, int));
2326 extern char *pat_subst __P((char *, char *, char *, int));
2327
2328+extern int fifos_pending __P((void));
2329 extern void unlink_fifo_list __P((void));
2330
2331 extern WORD_LIST *list_string_with_quotes __P((char *));
2332diff -Naur bash-3.2.orig/tests/new-exp.right bash-3.2/tests/new-exp.right
2333--- bash-3.2.orig/tests/new-exp.right 2006-08-10 09:00:00.000000000 -0700
2334+++ bash-3.2/tests/new-exp.right 2009-01-08 16:15:05.000000000 -0800
2335@@ -430,7 +430,7 @@
2336 Case06---1---A B C::---
2337 Case07---3---A:B:C---
2338 Case08---3---A:B:C---
2339-./new-exp.tests: line 506: /${$(($#-1))}: bad substitution
2340+./new-exp.tests: line 506: ${$(($#-1))}: bad substitution
2341 argv[1] = <a>
2342 argv[2] = <b>
2343 argv[3] = <c>
2344diff -Naur bash-3.2.orig/tests/shopt.right bash-3.2/tests/shopt.right
2345--- bash-3.2.orig/tests/shopt.right 2005-02-19 14:46:09.000000000 -0800
2346+++ bash-3.2/tests/shopt.right 2009-01-08 16:16:06.000000000 -0800
2347@@ -6,6 +6,7 @@
2348 shopt -u checkhash
2349 shopt -u checkwinsize
2350 shopt -s cmdhist
2351+shopt -u compat31
2352 shopt -u dotglob
2353 shopt -u execfail
2354 shopt -s expand_aliases
2355@@ -53,6 +54,7 @@
2356 shopt -u cdable_vars
2357 shopt -u checkhash
2358 shopt -u checkwinsize
2359+shopt -u compat31
2360 shopt -u dotglob
2361 shopt -u execfail
2362 shopt -u extdebug
2363@@ -77,6 +79,7 @@
2364 cdable_vars off
2365 checkhash off
2366 checkwinsize off
2367+compat31 off
2368 dotglob off
2369 execfail off
2370 extdebug off
2371diff -Naur bash-3.2.orig/variables.c bash-3.2/variables.c
2372--- bash-3.2.orig/variables.c 2006-09-08 10:33:32.000000000 -0700
2373+++ bash-3.2/variables.c 2009-01-08 16:16:13.000000000 -0800
2374@@ -1821,11 +1821,17 @@
2375 oval = value_cell (var);
2376 lval = evalexp (oval, &expok); /* ksh93 seems to do this */
2377 if (expok == 0)
2378- jump_to_top_level (DISCARD);
2379+ {
2380+ top_level_cleanup ();
2381+ jump_to_top_level (DISCARD);
2382+ }
2383 }
2384 rval = evalexp (value, &expok);
2385 if (expok == 0)
2386- jump_to_top_level (DISCARD);
2387+ {
2388+ top_level_cleanup ();
2389+ jump_to_top_level (DISCARD);
2390+ }
2391 if (flags & ASS_APPEND)
2392 rval += lval;
2393 retval = itos (rval);
2394@@ -3452,9 +3458,11 @@
2395 if (shell_variables == global_variables)
2396 var->attributes &= ~(att_tempvar|att_propagate);
2397 else
2398- shell_variables->flags |= VC_HASTMPVAR;
2399+ shell_variables->flags |= VC_HASTMPVAR;
2400 v->attributes |= var->attributes;
2401 }
2402+ else
2403+ stupidly_hack_special_variables (var->name); /* XXX */
2404
2405 dispose_variable (var);
2406 }
2407@@ -3541,6 +3549,8 @@
2408 var->attributes &= ~att_propagate;
2409 v->attributes |= var->attributes;
2410 }
2411+ else
2412+ stupidly_hack_special_variables (var->name); /* XXX */
2413
2414 dispose_variable (var);
2415 }
2416diff -Naur bash-3.2.orig/version.c bash-3.2/version.c
2417--- bash-3.2.orig/version.c 2005-05-16 08:58:34.000000000 -0700
2418+++ bash-3.2/version.c 2009-01-08 16:16:06.000000000 -0800
2419@@ -43,6 +43,9 @@
2420 #endif
2421 const char *sccs_version = SCCSVERSION;
2422
2423+/* If == 31, shell compatible with bash-3.1, == 32 with bash-3.2, and so on */
2424+int shell_compatibility_level = 32;
2425+
2426 /* Functions for getting, setting, and displaying the shell version. */
2427
2428 /* Forward declarations so we don't have to include externs.h */
2429@@ -79,5 +82,5 @@
2430 {
2431 printf ("GNU bash, version %s (%s)\n", shell_version_string (), MACHTYPE);
2432 if (extended)
2433- printf (_("Copyright (C) 2005 Free Software Foundation, Inc.\n"));
2434+ printf (_("Copyright (C) 2007 Free Software Foundation, Inc.\n"));
2435 }
Note: See TracBrowser for help on using the repository browser.