source: patches/bash-4.2-branch_update-7.patch@ ac02164

clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since ac02164 was e307159, checked in by William Harrington <kb0iic@…>, 11 years ago

Update Bash to patch level 045.

  • Property mode set to 100644
File size: 56.2 KB
RevLine 
[31f34c6]1Submitted By: William Harrington (kb0iic at gmail dot com)
[e307159]2Date: 05-08-2013
[31f34c6]3Initial Package Version: 4.2
4Origin: Upstream
5Upstream Status: Applied
[e307159]6Description: Contains all upstream patches up to 4.2-045
[31f34c6]7
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
[e307159]10+++ bash-4.2/assoc.c 2013-03-12 21:55:21.530771482 +0000
[31f34c6]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/bashline.c bash-4.2/bashline.c
24--- bash-4.2.orig/bashline.c 2011-01-16 20:32:47.000000000 +0000
[e307159]25+++ bash-4.2/bashline.c 2013-03-12 21:55:21.646771944 +0000
[31f34c6]26@@ -121,6 +121,9 @@
27 static int filename_completion_ignore __P((char **));
28 static int bash_push_line __P((void));
29
30+static rl_icppfunc_t *save_directory_hook __P((void));
31+static void reset_directory_hook __P((rl_icppfunc_t *));
32+
33 static void cleanup_expansion_error __P((void));
34 static void maybe_make_readline_line __P((char *));
35 static void set_up_new_line __P((char *));
36@@ -243,10 +246,17 @@
37 /* Perform spelling correction on directory names during word completion */
38 int dircomplete_spelling = 0;
39
40+/* Expand directory names during word/filename completion. */
41+int dircomplete_expand = 0;
42+int dircomplete_expand_relpath = 0;
43+
44 static char *bash_completer_word_break_characters = " \t\n\"'@><=;|&(:";
45 static char *bash_nohostname_word_break_characters = " \t\n\"'><=;|&(:";
46 /* )) */
47
48+static const char *default_filename_quote_characters = " \t\n\\\"'@<>=;|&()#$`?*[!:{~"; /*}*/
49+static char *custom_filename_quote_characters = 0;
50+
51 static rl_hook_func_t *old_rl_startup_hook = (rl_hook_func_t *)NULL;
52
53 static int dot_in_path = 0;
54@@ -501,7 +511,7 @@
55
56 /* Tell the completer that we might want to follow symbolic links or
57 do other expansion on directory names. */
58- rl_directory_rewrite_hook = bash_directory_completion_hook;
59+ set_directory_hook ();
60
61 rl_filename_rewrite_hook = bash_filename_rewrite_hook;
62
63@@ -529,7 +539,7 @@
64 enable_hostname_completion (perform_hostname_completion);
65
66 /* characters that need to be quoted when appearing in filenames. */
67- rl_filename_quote_characters = " \t\n\\\"'@<>=;|&()#$`?*[!:{~"; /*}*/
68+ rl_filename_quote_characters = default_filename_quote_characters;
69
70 rl_filename_quoting_function = bash_quote_filename;
71 rl_filename_dequoting_function = bash_dequote_filename;
72@@ -564,8 +574,10 @@
73 tilde_initialize ();
74 rl_attempted_completion_function = attempt_shell_completion;
75 rl_completion_entry_function = NULL;
76- rl_directory_rewrite_hook = bash_directory_completion_hook;
77 rl_ignore_some_completions_function = filename_completion_ignore;
78+ rl_filename_quote_characters = default_filename_quote_characters;
79+
80+ set_directory_hook ();
81 }
82
83 /* Contains the line to push into readline. */
84@@ -1279,6 +1291,9 @@
85 matches = (char **)NULL;
86 rl_ignore_some_completions_function = filename_completion_ignore;
87
88+ rl_filename_quote_characters = default_filename_quote_characters;
89+ set_directory_hook ();
90+
91 /* Determine if this could be a command word. It is if it appears at
92 the start of the line (ignoring preceding whitespace), or if it
93 appears after a character that separates commands. It cannot be a
94@@ -1591,6 +1606,12 @@
95 }
96 else
97 {
98+ if (dircomplete_expand && dot_or_dotdot (filename_hint))
99+ {
100+ dircomplete_expand = 0;
101+ set_directory_hook ();
102+ dircomplete_expand = 1;
103+ }
104 mapping_over = 4;
105 goto inner;
106 }
107@@ -1791,6 +1812,9 @@
108
109 inner:
110 val = rl_filename_completion_function (filename_hint, istate);
111+ if (mapping_over == 4 && dircomplete_expand)
112+ set_directory_hook ();
113+
114 istate = 1;
115
116 if (val == 0)
117@@ -2693,6 +2717,52 @@
118 return conv;
119 }
120
121+/* Functions to save and restore the appropriate directory hook */
122+/* This is not static so the shopt code can call it */
123+void
124+set_directory_hook ()
125+{
126+ if (dircomplete_expand)
127+ {
128+ rl_directory_completion_hook = bash_directory_completion_hook;
129+ rl_directory_rewrite_hook = (rl_icppfunc_t *)0;
130+ }
131+ else
132+ {
133+ rl_directory_rewrite_hook = bash_directory_completion_hook;
134+ rl_directory_completion_hook = (rl_icppfunc_t *)0;
135+ }
136+}
137+
138+static rl_icppfunc_t *
139+save_directory_hook ()
140+{
141+ rl_icppfunc_t *ret;
142+
143+ if (dircomplete_expand)
144+ {
145+ ret = rl_directory_completion_hook;
146+ rl_directory_completion_hook = (rl_icppfunc_t *)NULL;
147+ }
148+ else
149+ {
150+ ret = rl_directory_rewrite_hook;
151+ rl_directory_rewrite_hook = (rl_icppfunc_t *)NULL;
152+ }
153+
154+ return ret;
155+}
156+
157+static void
158+restore_directory_hook (hookf)
159+ rl_icppfunc_t *hookf;
160+{
161+ if (dircomplete_expand)
162+ rl_directory_completion_hook = hookf;
163+ else
164+ rl_directory_rewrite_hook = hookf;
165+}
166+
167 /* Handle symbolic link references and other directory name
168 expansions while hacking completion. This should return 1 if it modifies
169 the DIRNAME argument, 0 otherwise. It should make sure not to modify
170@@ -2702,20 +2772,31 @@
171 char **dirname;
172 {
173 char *local_dirname, *new_dirname, *t;
174- int return_value, should_expand_dirname;
175+ int return_value, should_expand_dirname, nextch, closer;
176 WORD_LIST *wl;
177 struct stat sb;
178
179- return_value = should_expand_dirname = 0;
180+ return_value = should_expand_dirname = nextch = closer = 0;
181 local_dirname = *dirname;
182
183- if (mbschr (local_dirname, '$'))
184- should_expand_dirname = 1;
185+ if (t = mbschr (local_dirname, '$'))
186+ {
187+ should_expand_dirname = '$';
188+ nextch = t[1];
189+ /* Deliberately does not handle the deprecated $[...] arithmetic
190+ expansion syntax */
191+ if (nextch == '(')
192+ closer = ')';
193+ else if (nextch == '{')
194+ closer = '}';
195+ else
196+ nextch = 0;
197+ }
198 else
199 {
200 t = mbschr (local_dirname, '`');
201 if (t && unclosed_pair (local_dirname, strlen (local_dirname), "`") == 0)
202- should_expand_dirname = 1;
203+ should_expand_dirname = '`';
204 }
205
206 #if defined (HAVE_LSTAT)
207@@ -2739,6 +2820,23 @@
208 free (new_dirname);
209 dispose_words (wl);
210 local_dirname = *dirname;
211+ /* XXX - change rl_filename_quote_characters here based on
212+ should_expand_dirname/nextch/closer. This is the only place
213+ custom_filename_quote_characters is modified. */
214+ if (rl_filename_quote_characters && *rl_filename_quote_characters)
215+ {
216+ int i, j, c;
217+ i = strlen (default_filename_quote_characters);
218+ custom_filename_quote_characters = xrealloc (custom_filename_quote_characters, i+1);
219+ for (i = j = 0; c = default_filename_quote_characters[i]; i++)
220+ {
221+ if (c == should_expand_dirname || c == nextch || c == closer)
222+ continue;
223+ custom_filename_quote_characters[j++] = c;
224+ }
225+ custom_filename_quote_characters[j] = '\0';
226+ rl_filename_quote_characters = custom_filename_quote_characters;
227+ }
228 }
229 else
230 {
231@@ -2758,11 +2856,31 @@
232 local_dirname = *dirname = new_dirname;
233 }
234
235+ /* no_symbolic_links == 0 -> use (default) logical view of the file system.
236+ local_dirname[0] == '.' && local_dirname[1] == '/' means files in the
237+ current directory (./).
238+ local_dirname[0] == '.' && local_dirname[1] == 0 means relative pathnames
239+ in the current directory (e.g., lib/sh).
240+ XXX - should we do spelling correction on these? */
241+
242+ /* This is test as it was in bash-4.2: skip relative pathnames in current
243+ directory. Change test to
244+ (local_dirname[0] != '.' || (local_dirname[1] && local_dirname[1] != '/'))
245+ if we want to skip paths beginning with ./ also. */
246 if (no_symbolic_links == 0 && (local_dirname[0] != '.' || local_dirname[1]))
247 {
248 char *temp1, *temp2;
249 int len1, len2;
250
251+ /* If we have a relative path
252+ (local_dirname[0] != '/' && local_dirname[0] != '.')
253+ that is canonical after appending it to the current directory, then
254+ temp1 = temp2+'/'
255+ That is,
256+ strcmp (temp1, temp2) == 0
257+ after adding a slash to temp2 below. It should be safe to not
258+ change those.
259+ */
260 t = get_working_directory ("symlink-hook");
261 temp1 = make_absolute (local_dirname, t);
262 free (t);
263@@ -2797,7 +2915,15 @@
264 temp2[len2 + 1] = '\0';
265 }
266 }
267- return_value |= STREQ (local_dirname, temp2) == 0;
268+
269+ /* dircomplete_expand_relpath == 0 means we want to leave relative
270+ pathnames that are unchanged by canonicalization alone.
271+ *local_dirname != '/' && *local_dirname != '.' == relative pathname
272+ (consistent with general.c:absolute_pathname())
273+ temp1 == temp2 (after appending a slash to temp2) means the pathname
274+ is not changed by canonicalization as described above. */
275+ if (dircomplete_expand_relpath || ((local_dirname[0] != '/' && local_dirname[0] != '.') && STREQ (temp1, temp2) == 0))
276+ return_value |= STREQ (local_dirname, temp2) == 0;
277 free (local_dirname);
278 *dirname = temp2;
279 free (temp1);
280@@ -3002,12 +3128,13 @@
281
282 orig_func = rl_completion_entry_function;
283 orig_attempt_func = rl_attempted_completion_function;
284- orig_dir_func = rl_directory_rewrite_hook;
285 orig_ignore_func = rl_ignore_some_completions_function;
286 orig_rl_completer_word_break_characters = rl_completer_word_break_characters;
287+
288+ orig_dir_func = save_directory_hook ();
289+
290 rl_completion_entry_function = rl_filename_completion_function;
291 rl_attempted_completion_function = (rl_completion_func_t *)NULL;
292- rl_directory_rewrite_hook = (rl_icppfunc_t *)NULL;
293 rl_ignore_some_completions_function = filename_completion_ignore;
294 rl_completer_word_break_characters = " \t\n\"\'";
295
296@@ -3015,10 +3142,11 @@
297
298 rl_completion_entry_function = orig_func;
299 rl_attempted_completion_function = orig_attempt_func;
300- rl_directory_rewrite_hook = orig_dir_func;
301 rl_ignore_some_completions_function = orig_ignore_func;
302 rl_completer_word_break_characters = orig_rl_completer_word_break_characters;
303
304+ restore_directory_hook (orig_dir_func);
305+
306 return r;
307 }
308
309diff -Naur bash-4.2.orig/bashline.h bash-4.2/bashline.h
310--- bash-4.2.orig/bashline.h 2009-01-04 19:32:22.000000000 +0000
[e307159]311+++ bash-4.2/bashline.h 2013-03-12 21:55:21.646771944 +0000
[31f34c6]312@@ -33,10 +33,15 @@
313 extern void bashline_reinitialize __P((void));
314 extern int bash_re_edit __P((char *));
315
316+extern void bashline_set_event_hook __P((void));
317+extern void bashline_reset_event_hook __P((void));
318+
319 extern int bind_keyseq_to_unix_command __P((char *));
320
321 extern char **bash_default_completion __P((const char *, int, int, int, int));
322
323+void set_directory_hook __P((void));
324+
325 /* Used by programmable completion code. */
326 extern char *command_word_completion_function __P((const char *, int));
327 extern char *bash_groupname_completion_function __P((const char *, int));
328diff -Naur bash-4.2.orig/builtins/declare.def bash-4.2/builtins/declare.def
329--- bash-4.2.orig/builtins/declare.def 2010-05-30 22:25:21.000000000 +0000
[e307159]330+++ bash-4.2/builtins/declare.def 2013-03-12 21:55:21.587771709 +0000
[31f34c6]331@@ -513,6 +513,11 @@
332 *subscript_start = '['; /* ] */
333 var = assign_array_element (name, value, 0); /* XXX - not aflags */
334 *subscript_start = '\0';
335+ if (var == 0) /* some kind of assignment error */
336+ {
337+ assign_error++;
338+ NEXT_VARIABLE ();
339+ }
340 }
341 else if (simple_array_assign)
342 {
343diff -Naur bash-4.2.orig/builtins/fc.def bash-4.2/builtins/fc.def
344--- bash-4.2.orig/builtins/fc.def 2010-05-30 22:25:38.000000000 +0000
[e307159]345+++ bash-4.2/builtins/fc.def 2013-03-12 21:55:21.521771446 +0000
[31f34c6]346@@ -304,7 +304,7 @@
347 last_hist = i - rh - hist_last_line_added;
348
349 /* XXX */
350- if (saved_command_line_count > 0 && i == last_hist && hlist[last_hist] == 0)
351+ if (i == last_hist && hlist[last_hist] == 0)
352 while (last_hist >= 0 && hlist[last_hist] == 0)
353 last_hist--;
354 if (last_hist < 0)
355@@ -475,7 +475,7 @@
356 HIST_ENTRY **hlist;
357 {
358 int sign, n, clen, rh;
359- register int i, j;
360+ register int i, j, last_hist;
361 register char *s;
362
363 sign = 1;
364@@ -495,7 +495,15 @@
365 has been enabled (interactive or not) should use it in the last_hist
366 calculation as if it were on. */
367 rh = remember_on_history || ((subshell_environment & SUBSHELL_COMSUB) && enable_history_list);
368- i -= rh + hist_last_line_added;
369+ last_hist = i - rh - hist_last_line_added;
370+
371+ if (i == last_hist && hlist[last_hist] == 0)
372+ while (last_hist >= 0 && hlist[last_hist] == 0)
373+ last_hist--;
374+ if (last_hist < 0)
375+ return (-1);
376+
377+ i = last_hist;
378
379 /* No specification defaults to most recent command. */
380 if (command == NULL)
381diff -Naur bash-4.2.orig/builtins/mapfile.def bash-4.2/builtins/mapfile.def
382--- bash-4.2.orig/builtins/mapfile.def 2010-05-30 02:09:47.000000000 +0000
[e307159]383+++ bash-4.2/builtins/mapfile.def 2013-03-12 21:55:21.675772060 +0000
[31f34c6]384@@ -195,13 +195,9 @@
385 /* Reset the buffer for bash own stream */
386 interrupt_immediately++;
387 for (array_index = origin, line_count = 1;
388- zgetline (fd, &line, &line_length, unbuffered_read) != -1;
389- array_index++, line_count++)
390+ zgetline (fd, &line, &line_length, unbuffered_read) != -1;
391+ array_index++)
392 {
393- /* Have we exceeded # of lines to store? */
394- if (line_count_goal != 0 && line_count > line_count_goal)
395- break;
396-
397 /* Remove trailing newlines? */
398 if (flags & MAPF_CHOP)
399 do_chop (line);
400@@ -217,6 +213,11 @@
401 }
402
403 bind_array_element (entry, array_index, line, 0);
404+
405+ /* Have we exceeded # of lines to store? */
406+ line_count++;
407+ if (line_count_goal != 0 && line_count > line_count_goal)
408+ break;
409 }
410
411 xfree (line);
412diff -Naur bash-4.2.orig/builtins/printf.def bash-4.2/builtins/printf.def
413--- bash-4.2.orig/builtins/printf.def 2010-11-23 15:02:55.000000000 +0000
[e307159]414+++ bash-4.2/builtins/printf.def 2013-03-12 21:55:21.615771821 +0000
[31f34c6]415@@ -255,6 +255,8 @@
416 #endif
417 {
418 vflag = 1;
419+ if (vbsize == 0)
420+ vbuf = xmalloc (vbsize = 16);
421 vblen = 0;
422 if (vbuf)
423 vbuf[0] = 0;
424@@ -465,6 +467,9 @@
425 secs = shell_start_time; /* roughly $SECONDS */
426 else
427 secs = arg;
428+#if defined (HAVE_TZSET)
429+ sv_tz ("TZ"); /* XXX -- just make sure */
430+#endif
431 tm = localtime (&secs);
432 n = strftime (timebuf, sizeof (timebuf), timefmt, tm);
433 free (timefmt);
434diff -Naur bash-4.2.orig/builtins/read.def bash-4.2/builtins/read.def
435--- bash-4.2.orig/builtins/read.def 2011-01-04 16:43:36.000000000 +0000
[e307159]436+++ bash-4.2/builtins/read.def 2013-03-12 21:55:21.734772295 +0000
437@@ -385,10 +385,20 @@
438 {
439 /* Tricky. The top of the unwind-protect stack is the free of
440 input_string. We want to run all the rest and use input_string,
441- so we have to remove it from the stack. */
442- remove_unwind_protect ();
443- run_unwind_frame ("read_builtin");
444+ so we have to save input_string temporarily, run the unwind-
445+ protects, then restore input_string so we can use it later. */
446+
447 input_string[i] = '\0'; /* make sure it's terminated */
448+ if (i == 0)
449+ {
450+ t = (char *)xmalloc (1);
451+ t[0] = 0;
452+ }
453+ else
454+ t = savestring (input_string);
455+
456+ run_unwind_frame ("read_builtin");
457+ input_string = t;
458 retval = 128+SIGALRM;
459 goto assign_vars;
460 }
461@@ -642,6 +652,12 @@
[31f34c6]462 xfree (input_string);
463 return EXECUTION_FAILURE; /* readonly or noassign */
464 }
465+ if (assoc_p (var))
466+ {
467+ builtin_error (_("%s: cannot convert associative to indexed array"), arrayname);
468+ xfree (input_string);
469+ return EXECUTION_FAILURE; /* existing associative array */
470+ }
471 array_flush (array_cell (var));
472
473 alist = list_string (input_string, ifs_chars, 0);
[e307159]474@@ -731,7 +747,7 @@
[31f34c6]475 xfree (t1);
476 }
477 else
478- var = bind_read_variable (varname, t);
479+ var = bind_read_variable (varname, t ? t : "");
480 }
481 else
482 {
[e307159]483@@ -785,14 +801,14 @@
[31f34c6]484 }
485 #endif
486
487- if (saw_escape)
488+ if (saw_escape && input_string && *input_string)
489 {
490 t = dequote_string (input_string);
491 var = bind_read_variable (list->word->word, t);
492 xfree (t);
493 }
494 else
495- var = bind_read_variable (list->word->word, input_string);
496+ var = bind_read_variable (list->word->word, input_string ? input_string : "");
497
498 if (var)
499 {
500diff -Naur bash-4.2.orig/builtins/shopt.def bash-4.2/builtins/shopt.def
501--- bash-4.2.orig/builtins/shopt.def 2010-07-03 02:42:44.000000000 +0000
[e307159]502+++ bash-4.2/builtins/shopt.def 2013-03-12 21:55:21.647771948 +0000
[31f34c6]503@@ -61,6 +61,10 @@
504 #include "common.h"
505 #include "bashgetopt.h"
506
507+#if defined (READLINE)
508+# include "../bashline.h"
509+#endif
510+
511 #if defined (HISTORY)
512 # include "../bashhist.h"
513 #endif
514@@ -94,7 +98,7 @@
515 extern int hist_verify, history_reediting, perform_hostname_completion;
516 extern int no_empty_command_completion;
517 extern int force_fignore;
518-extern int dircomplete_spelling;
519+extern int dircomplete_spelling, dircomplete_expand;
520
521 extern int enable_hostname_completion __P((int));
522 #endif
523@@ -121,6 +125,10 @@
524 static int set_restricted_shell __P((char *, int));
525 #endif
526
527+#if defined (READLINE)
528+static int shopt_set_complete_direxpand __P((char *, int));
529+#endif
530+
531 static int shopt_login_shell;
532 static int shopt_compat31;
533 static int shopt_compat32;
534@@ -150,6 +158,7 @@
535 { "compat40", &shopt_compat40, set_compatibility_level },
536 { "compat41", &shopt_compat41, set_compatibility_level },
537 #if defined (READLINE)
538+ { "direxpand", &dircomplete_expand, shopt_set_complete_direxpand },
539 { "dirspell", &dircomplete_spelling, (shopt_set_func_t *)NULL },
540 #endif
541 { "dotglob", &glob_dot_filenames, (shopt_set_func_t *)NULL },
542@@ -535,6 +544,17 @@
543 return 0;
544 }
545
546+#if defined (READLINE)
547+static int
548+shopt_set_complete_direxpand (option_name, mode)
549+ char *option_name;
550+ int mode;
551+{
552+ set_directory_hook ();
553+ return 0;
554+}
555+#endif
556+
557 #if defined (RESTRICTED_SHELL)
558 /* Don't allow the value of restricted_shell to be modified. */
559
560diff -Naur bash-4.2.orig/command.h bash-4.2/command.h
561--- bash-4.2.orig/command.h 2010-08-02 23:36:51.000000000 +0000
[e307159]562+++ bash-4.2/command.h 2013-03-12 21:55:21.619771836 +0000
[31f34c6]563@@ -97,6 +97,7 @@
564 #define W_HASCTLESC 0x200000 /* word contains literal CTLESC characters */
565 #define W_ASSIGNASSOC 0x400000 /* word looks like associative array assignment */
566 #define W_ARRAYIND 0x800000 /* word is an array index being expanded */
567+#define W_ASSNGLOBAL 0x1000000 /* word is a global assignment to declare (declare/typeset -g) */
568
569 /* Possible values for subshell_environment */
570 #define SUBSHELL_ASYNC 0x01 /* subshell caused by `command &' */
571diff -Naur bash-4.2.orig/doc/bash.1 bash-4.2/doc/bash.1
572--- bash-4.2.orig/doc/bash.1 2011-01-16 20:31:39.000000000 +0000
[e307159]573+++ bash-4.2/doc/bash.1 2013-03-12 21:55:21.650771960 +0000
[31f34c6]574@@ -8948,6 +8948,16 @@
575 quoted. This is the behavior of posix mode through version 4.1.
576 The default bash behavior remains as in previous versions.
577 .TP 8
578+.B direxpand
579+If set,
580+.B bash
581+replaces directory names with the results of word expansion when performing
582+filename completion. This changes the contents of the readline editing
583+buffer.
584+If not set,
585+.B bash
586+attempts to preserve what the user typed.
587+.TP 8
588 .B dirspell
589 If set,
590 .B bash
591diff -Naur bash-4.2.orig/doc/bashref.texi bash-4.2/doc/bashref.texi
592--- bash-4.2.orig/doc/bashref.texi 2011-01-16 20:31:57.000000000 +0000
[e307159]593+++ bash-4.2/doc/bashref.texi 2013-03-12 21:55:21.653771972 +0000
[31f34c6]594@@ -4535,6 +4535,13 @@
595 quoted. This is the behavior of @sc{posix} mode through version 4.1.
596 The default Bash behavior remains as in previous versions.
597
598+@item direxpand
599+If set, Bash
600+replaces directory names with the results of word expansion when performing
601+filename completion. This changes the contents of the readline editing
602+buffer.
603+If not set, Bash attempts to preserve what the user typed.
604+
605 @item dirspell
606 If set, Bash
607 attempts spelling correction on directory names during word completion
608diff -Naur bash-4.2.orig/error.c bash-4.2/error.c
609--- bash-4.2.orig/error.c 2009-08-22 02:31:31.000000000 +0000
[e307159]610+++ bash-4.2/error.c 2013-03-12 21:55:21.610771801 +0000
[31f34c6]611@@ -200,7 +200,11 @@
612
613 va_end (args);
614 if (exit_immediately_on_error)
615- exit_shell (1);
616+ {
617+ if (last_command_exit_value == 0)
618+ last_command_exit_value = 1;
619+ exit_shell (last_command_exit_value);
620+ }
621 }
622
623 void
624diff -Naur bash-4.2.orig/execute_cmd.c bash-4.2/execute_cmd.c
625--- bash-4.2.orig/execute_cmd.c 2011-02-09 22:32:25.000000000 +0000
[e307159]626+++ bash-4.2/execute_cmd.c 2013-03-12 21:55:21.627771868 +0000
[31f34c6]627@@ -2196,6 +2196,7 @@
628 if (ignore_return && cmd)
629 cmd->flags |= CMD_IGNORE_RETURN;
630
631+#if defined (JOB_CONTROL)
632 lastpipe_flag = 0;
633 begin_unwind_frame ("lastpipe-exec");
634 lstdin = -1;
635@@ -2204,7 +2205,7 @@
636 current shell environment. */
637 if (lastpipe_opt && job_control == 0 && asynchronous == 0 && pipe_out == NO_PIPE && prev > 0)
638 {
639- lstdin = move_to_high_fd (0, 0, 255);
640+ lstdin = move_to_high_fd (0, 1, -1);
641 if (lstdin > 0)
642 {
643 do_piping (prev, pipe_out);
644@@ -2215,15 +2216,19 @@
645 lastpipe_jid = stop_pipeline (0, (COMMAND *)NULL); /* XXX */
646 add_unwind_protect (lastpipe_cleanup, lastpipe_jid);
647 }
648- cmd->flags |= CMD_LASTPIPE;
649+ if (cmd)
650+ cmd->flags |= CMD_LASTPIPE;
651 }
652 if (prev >= 0)
653 add_unwind_protect (close, prev);
654+#endif
655
656 exec_result = execute_command_internal (cmd, asynchronous, prev, pipe_out, fds_to_close);
657
658+#if defined (JOB_CONTROL)
659 if (lstdin > 0)
660 restore_stdin (lstdin);
661+#endif
662
663 if (prev >= 0)
664 close (prev);
665@@ -2246,7 +2251,9 @@
666 unfreeze_jobs_list ();
667 }
668
669+#if defined (JOB_CONTROL)
670 discard_unwind_frame ("lastpipe-exec");
671+#endif
672
673 return (exec_result);
674 }
675@@ -3575,13 +3582,13 @@
676 {
677 WORD_LIST *w;
678 struct builtin *b;
679- int assoc;
680+ int assoc, global;
681
682 if (words == 0)
683 return;
684
685 b = 0;
686- assoc = 0;
687+ assoc = global = 0;
688
689 for (w = words; w; w = w->next)
690 if (w->word->flags & W_ASSIGNMENT)
691@@ -3598,12 +3605,17 @@
692 #if defined (ARRAY_VARS)
693 if (assoc)
694 w->word->flags |= W_ASSIGNASSOC;
695+ if (global)
696+ w->word->flags |= W_ASSNGLOBAL;
697 #endif
698 }
699 #if defined (ARRAY_VARS)
700 /* Note that we saw an associative array option to a builtin that takes
701 assignment statements. This is a bit of a kludge. */
702- else if (w->word->word[0] == '-' && strchr (w->word->word, 'A'))
703+ else if (w->word->word[0] == '-' && (strchr (w->word->word+1, 'A') || strchr (w->word->word+1, 'g')))
704+#else
705+ else if (w->word->word[0] == '-' && strchr (w->word->word+1, 'g'))
706+#endif
707 {
708 if (b == 0)
709 {
710@@ -3613,10 +3625,11 @@
711 else if (b && (b->flags & ASSIGNMENT_BUILTIN))
712 words->word->flags |= W_ASSNBLTIN;
713 }
714- if (words->word->flags & W_ASSNBLTIN)
715+ if ((words->word->flags & W_ASSNBLTIN) && strchr (w->word->word+1, 'A'))
716 assoc = 1;
717+ if ((words->word->flags & W_ASSNBLTIN) && strchr (w->word->word+1, 'g'))
718+ global = 1;
719 }
720-#endif
721 }
722
723 /* Return 1 if the file found by searching $PATH for PATHNAME, defaulting
724diff -Naur bash-4.2.orig/expr.c bash-4.2/expr.c
725--- bash-4.2.orig/expr.c 2010-12-21 16:12:13.000000000 +0000
[e307159]726+++ bash-4.2/expr.c 2013-03-12 21:55:21.706772183 +0000
[31f34c6]727@@ -476,19 +476,23 @@
728
729 if (special)
730 {
731+ if ((op == DIV || op == MOD) && value == 0)
732+ {
733+ if (noeval == 0)
734+ evalerror (_("division by 0"));
735+ else
736+ value = 1;
737+ }
738+
739 switch (op)
740 {
741 case MUL:
742 lvalue *= value;
743 break;
744 case DIV:
745- if (value == 0)
746- evalerror (_("division by 0"));
747 lvalue /= value;
748 break;
749 case MOD:
750- if (value == 0)
751- evalerror (_("division by 0"));
752 lvalue %= value;
753 break;
754 case PLUS:
755@@ -804,7 +808,12 @@
756 val2 = exppower ();
757
758 if (((op == DIV) || (op == MOD)) && (val2 == 0))
759- evalerror (_("division by 0"));
760+ {
761+ if (noeval == 0)
762+ evalerror (_("division by 0"));
763+ else
764+ val2 = 1;
765+ }
766
767 if (op == MUL)
768 val1 *= val2;
769@@ -1000,6 +1009,12 @@
770 arrayind_t ind;
771 #endif
772
773+/*itrace("expr_streval: %s: noeval = %d", tok, noeval);*/
774+ /* If we are suppressing evaluation, just short-circuit here instead of
775+ going through the rest of the evaluator. */
776+ if (noeval)
777+ return (0);
778+
779 /* [[[[[ */
780 #if defined (ARRAY_VARS)
781 v = (e == ']') ? array_variable_part (tok, (char **)0, (int *)0) : find_variable (tok);
782@@ -1173,6 +1188,10 @@
783 #endif /* ARRAY_VARS */
784
785 *cp = '\0';
786+ /* XXX - watch out for pointer aliasing issues here */
787+ if (curlval.tokstr && curlval.tokstr == tokstr)
788+ init_lvalue (&curlval);
789+
790 FREE (tokstr);
791 tokstr = savestring (tp);
792 *cp = c;
793diff -Naur bash-4.2.orig/lib/glob/glob.c bash-4.2/lib/glob/glob.c
794--- bash-4.2.orig/lib/glob/glob.c 2009-11-14 23:39:30.000000000 +0000
[e307159]795+++ bash-4.2/lib/glob/glob.c 2013-03-12 21:55:21.658771992 +0000
[31f34c6]796@@ -200,8 +200,11 @@
797 wchar_t *pat_wc, *dn_wc;
798 size_t pat_n, dn_n;
799
800+ pat_wc = dn_wc = (wchar_t *)NULL;
801+
802 pat_n = xdupmbstowcs (&pat_wc, NULL, pat);
803- dn_n = xdupmbstowcs (&dn_wc, NULL, dname);
804+ if (pat_n != (size_t)-1)
805+ dn_n = xdupmbstowcs (&dn_wc, NULL, dname);
806
807 ret = 0;
808 if (pat_n != (size_t)-1 && dn_n !=(size_t)-1)
809@@ -221,6 +224,8 @@
810 (pat_wc[0] != L'\\' || pat_wc[1] != L'.'))
811 ret = 1;
812 }
813+ else
814+ ret = skipname (pat, dname, flags);
815
816 FREE (pat_wc);
817 FREE (dn_wc);
818@@ -266,8 +271,11 @@
819 /* Convert the strings into wide characters. */
820 n = xdupmbstowcs (&wpathname, NULL, pathname);
821 if (n == (size_t) -1)
822- /* Something wrong. */
823- return;
824+ {
825+ /* Something wrong. Fall back to single-byte */
826+ udequote_pathname (pathname);
827+ return;
828+ }
829 orig_wpathname = wpathname;
830
831 for (i = j = 0; wpathname && wpathname[i]; )
832diff -Naur bash-4.2.orig/lib/glob/gmisc.c bash-4.2/lib/glob/gmisc.c
833--- bash-4.2.orig/lib/glob/gmisc.c 2011-02-05 21:11:17.000000000 +0000
[e307159]834+++ bash-4.2/lib/glob/gmisc.c 2013-03-12 21:55:21.465771223 +0000
[31f34c6]835@@ -77,8 +77,8 @@
836 wchar_t *wpat;
837 size_t wmax;
838 {
839- wchar_t wc, *wbrack;
840- int matlen, t, in_cclass, in_collsym, in_equiv;
841+ wchar_t wc;
842+ int matlen, bracklen, t, in_cclass, in_collsym, in_equiv;
843
844 if (*wpat == 0)
845 return (0);
846@@ -118,58 +118,80 @@
847 break;
848 case L'[':
849 /* scan for ending `]', skipping over embedded [:...:] */
850- wbrack = wpat;
851+ bracklen = 1;
852 wc = *wpat++;
853 do
854 {
855 if (wc == 0)
856 {
857- matlen += wpat - wbrack - 1; /* incremented below */
858- break;
859+ wpat--; /* back up to NUL */
860+ matlen += bracklen;
861+ goto bad_bracket;
862 }
863 else if (wc == L'\\')
864 {
865- wc = *wpat++;
866- if (*wpat == 0)
867- break;
868+ /* *wpat == backslash-escaped character */
869+ bracklen++;
870+ /* If the backslash or backslash-escape ends the string,
871+ bail. The ++wpat skips over the backslash escape */
872+ if (*wpat == 0 || *++wpat == 0)
873+ {
874+ matlen += bracklen;
875+ goto bad_bracket;
876+ }
877 }
878 else if (wc == L'[' && *wpat == L':') /* character class */
879 {
880 wpat++;
881+ bracklen++;
882 in_cclass = 1;
883 }
884 else if (in_cclass && wc == L':' && *wpat == L']')
885 {
886 wpat++;
887+ bracklen++;
888 in_cclass = 0;
889 }
890 else if (wc == L'[' && *wpat == L'.') /* collating symbol */
891 {
892 wpat++;
893+ bracklen++;
894 if (*wpat == L']') /* right bracket can appear as collating symbol */
895- wpat++;
896+ {
897+ wpat++;
898+ bracklen++;
899+ }
900 in_collsym = 1;
901 }
902 else if (in_collsym && wc == L'.' && *wpat == L']')
903 {
904 wpat++;
905+ bracklen++;
906 in_collsym = 0;
907 }
908 else if (wc == L'[' && *wpat == L'=') /* equivalence class */
909 {
910 wpat++;
911+ bracklen++;
912 if (*wpat == L']') /* right bracket can appear as equivalence class */
913- wpat++;
914+ {
915+ wpat++;
916+ bracklen++;
917+ }
918 in_equiv = 1;
919 }
920 else if (in_equiv && wc == L'=' && *wpat == L']')
921 {
922 wpat++;
923+ bracklen++;
924 in_equiv = 0;
925 }
926+ else
927+ bracklen++;
928 }
929 while ((wc = *wpat++) != L']');
930 matlen++; /* bracket expression can only match one char */
931+bad_bracket:
932 break;
933 }
934 }
935@@ -213,8 +235,8 @@
936 char *pat;
937 size_t max;
938 {
939- char c, *brack;
940- int matlen, t, in_cclass, in_collsym, in_equiv;
941+ char c;
942+ int matlen, bracklen, t, in_cclass, in_collsym, in_equiv;
943
944 if (*pat == 0)
945 return (0);
946@@ -254,58 +276,80 @@
947 break;
948 case '[':
949 /* scan for ending `]', skipping over embedded [:...:] */
950- brack = pat;
951+ bracklen = 1;
952 c = *pat++;
953 do
954 {
955 if (c == 0)
956 {
957- matlen += pat - brack - 1; /* incremented below */
958- break;
959+ pat--; /* back up to NUL */
960+ matlen += bracklen;
961+ goto bad_bracket;
962 }
963 else if (c == '\\')
964 {
965- c = *pat++;
966- if (*pat == 0)
967- break;
968+ /* *pat == backslash-escaped character */
969+ bracklen++;
970+ /* If the backslash or backslash-escape ends the string,
971+ bail. The ++pat skips over the backslash escape */
972+ if (*pat == 0 || *++pat == 0)
973+ {
974+ matlen += bracklen;
975+ goto bad_bracket;
976+ }
977 }
978 else if (c == '[' && *pat == ':') /* character class */
979 {
980 pat++;
981+ bracklen++;
982 in_cclass = 1;
983 }
984 else if (in_cclass && c == ':' && *pat == ']')
985 {
986 pat++;
987+ bracklen++;
988 in_cclass = 0;
989 }
990 else if (c == '[' && *pat == '.') /* collating symbol */
991 {
992 pat++;
993+ bracklen++;
994 if (*pat == ']') /* right bracket can appear as collating symbol */
995- pat++;
996+ {
997+ pat++;
998+ bracklen++;
999+ }
1000 in_collsym = 1;
1001 }
1002 else if (in_collsym && c == '.' && *pat == ']')
1003 {
1004 pat++;
1005+ bracklen++;
1006 in_collsym = 0;
1007 }
1008 else if (c == '[' && *pat == '=') /* equivalence class */
1009 {
1010 pat++;
1011+ bracklen++;
1012 if (*pat == ']') /* right bracket can appear as equivalence class */
1013- pat++;
1014+ {
1015+ pat++;
1016+ bracklen++;
1017+ }
1018 in_equiv = 1;
1019 }
1020 else if (in_equiv && c == '=' && *pat == ']')
1021 {
1022 pat++;
1023+ bracklen++;
1024 in_equiv = 0;
1025 }
1026+ else
1027+ bracklen++;
1028 }
1029 while ((c = *pat++) != ']');
1030 matlen++; /* bracket expression can only match one char */
1031+bad_bracket:
1032 break;
1033 }
1034 }
1035diff -Naur bash-4.2.orig/lib/glob/xmbsrtowcs.c bash-4.2/lib/glob/xmbsrtowcs.c
1036--- bash-4.2.orig/lib/glob/xmbsrtowcs.c 2010-05-30 22:36:27.000000000 +0000
[e307159]1037+++ bash-4.2/lib/glob/xmbsrtowcs.c 2013-03-12 21:55:21.736772303 +0000
[31f34c6]1038@@ -35,6 +35,8 @@
1039
1040 #if HANDLE_MULTIBYTE
1041
1042+#define WSBUF_INC 32
1043+
1044 #ifndef FREE
1045 # define FREE(x) do { if (x) free (x); } while (0)
1046 #endif
1047@@ -148,7 +150,7 @@
1048 size_t wsbuf_size; /* Size of WSBUF */
1049 size_t wcnum; /* Number of wide characters in WSBUF */
1050 mbstate_t state; /* Conversion State */
1051- size_t wcslength; /* Number of wide characters produced by the conversion. */
1052+ size_t n, wcslength; /* Number of wide characters produced by the conversion. */
1053 const char *end_or_backslash;
1054 size_t nms; /* Number of multibyte characters to convert at one time. */
1055 mbstate_t tmp_state;
1056@@ -171,7 +173,18 @@
1057 /* Compute the number of produced wide-characters. */
1058 tmp_p = p;
1059 tmp_state = state;
1060- wcslength = mbsnrtowcs(NULL, &tmp_p, nms, 0, &tmp_state);
1061+
1062+ if (nms == 0 && *p == '\\') /* special initial case */
1063+ nms = wcslength = 1;
1064+ else
1065+ wcslength = mbsnrtowcs (NULL, &tmp_p, nms, 0, &tmp_state);
1066+
1067+ if (wcslength == 0)
1068+ {
1069+ tmp_p = p; /* will need below */
1070+ tmp_state = state;
1071+ wcslength = 1; /* take a single byte */
1072+ }
1073
1074 /* Conversion failed. */
1075 if (wcslength == (size_t)-1)
1076@@ -186,7 +199,8 @@
1077 {
1078 wchar_t *wstmp;
1079
1080- wsbuf_size = wcnum+wcslength+1; /* 1 for the L'\0' or the potential L'\\' */
1081+ while (wsbuf_size < wcnum+wcslength+1) /* 1 for the L'\0' or the potential L'\\' */
1082+ wsbuf_size += WSBUF_INC;
1083
1084 wstmp = (wchar_t *) realloc (wsbuf, wsbuf_size * sizeof (wchar_t));
1085 if (wstmp == NULL)
[e307159]1086@@ -199,10 +213,30 @@
[31f34c6]1087 }
1088
1089 /* Perform the conversion. This is assumed to return 'wcslength'.
1090- * It may set 'p' to NULL. */
1091- mbsnrtowcs(wsbuf+wcnum, &p, nms, wsbuf_size-wcnum, &state);
1092+ It may set 'p' to NULL. */
1093+ n = mbsnrtowcs(wsbuf+wcnum, &p, nms, wsbuf_size-wcnum, &state);
1094
1095- wcnum += wcslength;
[e307159]1096+ if (n == 0 && p == 0)
1097+ {
1098+ wsbuf[wcnum] = L'\0';
1099+ break;
1100+ }
1101+
[31f34c6]1102+ /* Compensate for taking single byte on wcs conversion failure above. */
1103+ if (wcslength == 1 && (n == 0 || n == (size_t)-1))
1104+ {
1105+ state = tmp_state;
1106+ p = tmp_p;
[e307159]1107+ wsbuf[wcnum] = *p;
1108+ if (*p == 0)
1109+ break;
1110+ else
1111+ {
1112+ wcnum++; p++;
1113+ }
[31f34c6]1114+ }
1115+ else
1116+ wcnum += wcslength;
1117
1118 if (mbsinit (&state) && (p != NULL) && (*p == '\\'))
1119 {
[e307159]1120@@ -230,8 +264,6 @@
[31f34c6]1121 If conversion is failed, the return value is (size_t)-1 and the values
1122 of DESTP and INDICESP are NULL. */
1123
1124-#define WSBUF_INC 32
1125-
1126 size_t
1127 xdupmbstowcs (destp, indicesp, src)
1128 wchar_t **destp; /* Store the pointer to the wide character string */
1129diff -Naur bash-4.2.orig/lib/readline/callback.c bash-4.2/lib/readline/callback.c
1130--- bash-4.2.orig/lib/readline/callback.c 2010-06-06 16:18:58.000000000 +0000
[e307159]1131+++ bash-4.2/lib/readline/callback.c 2013-03-12 21:55:21.461771207 +0000
[31f34c6]1132@@ -148,6 +148,9 @@
1133 eof = _rl_vi_domove_callback (_rl_vimvcxt);
1134 /* Should handle everything, including cleanup, numeric arguments,
1135 and turning off RL_STATE_VIMOTION */
1136+ if (RL_ISSTATE (RL_STATE_NUMERICARG) == 0)
1137+ _rl_internal_char_cleanup ();
1138+
1139 return;
1140 }
1141 #endif
1142diff -Naur bash-4.2.orig/lib/readline/input.c bash-4.2/lib/readline/input.c
1143--- bash-4.2.orig/lib/readline/input.c 2010-05-30 22:33:01.000000000 +0000
[e307159]1144+++ bash-4.2/lib/readline/input.c 2013-03-12 21:55:21.661772004 +0000
[31f34c6]1145@@ -409,7 +409,7 @@
1146 int
1147 rl_read_key ()
1148 {
1149- int c;
1150+ int c, r;
1151
1152 rl_key_sequence_length++;
1153
1154@@ -429,14 +429,18 @@
1155 {
1156 while (rl_event_hook)
1157 {
1158- if (rl_gather_tyi () < 0) /* XXX - EIO */
1159+ if (rl_get_char (&c) != 0)
1160+ break;
1161+
1162+ if ((r = rl_gather_tyi ()) < 0) /* XXX - EIO */
1163 {
1164 rl_done = 1;
1165 return ('\n');
1166 }
1167+ else if (r == 1) /* read something */
1168+ continue;
1169+
1170 RL_CHECK_SIGNALS ();
1171- if (rl_get_char (&c) != 0)
1172- break;
1173 if (rl_done) /* XXX - experimental */
1174 return ('\n');
1175 (*rl_event_hook) ();
1176diff -Naur bash-4.2.orig/lib/readline/vi_mode.c bash-4.2/lib/readline/vi_mode.c
1177--- bash-4.2.orig/lib/readline/vi_mode.c 2010-11-21 00:51:39.000000000 +0000
[e307159]1178+++ bash-4.2/lib/readline/vi_mode.c 2013-03-12 21:55:21.698772151 +0000
[31f34c6]1179@@ -1114,7 +1114,7 @@
1180 rl_beg_of_line (1, c);
1181 _rl_vi_last_motion = c;
1182 RL_UNSETSTATE (RL_STATE_VIMOTION);
1183- return (0);
1184+ return (vidomove_dispatch (m));
1185 }
1186 #if defined (READLINE_CALLBACKS)
1187 /* XXX - these need to handle rl_universal_argument bindings */
1188@@ -1234,11 +1234,19 @@
1189 _rl_vimvcxt->motion = '$';
1190 r = rl_domove_motion_callback (_rl_vimvcxt);
1191 }
1192- else if (vi_redoing)
1193+ else if (vi_redoing && _rl_vi_last_motion != 'd') /* `dd' is special */
1194 {
1195 _rl_vimvcxt->motion = _rl_vi_last_motion;
1196 r = rl_domove_motion_callback (_rl_vimvcxt);
1197 }
1198+ else if (vi_redoing) /* handle redoing `dd' here */
1199+ {
1200+ _rl_vimvcxt->motion = _rl_vi_last_motion;
1201+ rl_mark = rl_end;
1202+ rl_beg_of_line (1, key);
1203+ RL_UNSETSTATE (RL_STATE_VIMOTION);
1204+ r = vidomove_dispatch (_rl_vimvcxt);
1205+ }
1206 #if defined (READLINE_CALLBACKS)
1207 else if (RL_ISSTATE (RL_STATE_CALLBACK))
1208 {
1209@@ -1316,11 +1324,19 @@
1210 _rl_vimvcxt->motion = '$';
1211 r = rl_domove_motion_callback (_rl_vimvcxt);
1212 }
1213- else if (vi_redoing)
1214+ else if (vi_redoing && _rl_vi_last_motion != 'c') /* `cc' is special */
1215 {
1216 _rl_vimvcxt->motion = _rl_vi_last_motion;
1217 r = rl_domove_motion_callback (_rl_vimvcxt);
1218 }
1219+ else if (vi_redoing) /* handle redoing `cc' here */
1220+ {
1221+ _rl_vimvcxt->motion = _rl_vi_last_motion;
1222+ rl_mark = rl_end;
1223+ rl_beg_of_line (1, key);
1224+ RL_UNSETSTATE (RL_STATE_VIMOTION);
1225+ r = vidomove_dispatch (_rl_vimvcxt);
1226+ }
1227 #if defined (READLINE_CALLBACKS)
1228 else if (RL_ISSTATE (RL_STATE_CALLBACK))
1229 {
1230@@ -1377,6 +1393,19 @@
1231 _rl_vimvcxt->motion = '$';
1232 r = rl_domove_motion_callback (_rl_vimvcxt);
1233 }
1234+ else if (vi_redoing && _rl_vi_last_motion != 'y') /* `yy' is special */
1235+ {
1236+ _rl_vimvcxt->motion = _rl_vi_last_motion;
1237+ r = rl_domove_motion_callback (_rl_vimvcxt);
1238+ }
1239+ else if (vi_redoing) /* handle redoing `yy' here */
1240+ {
1241+ _rl_vimvcxt->motion = _rl_vi_last_motion;
1242+ rl_mark = rl_end;
1243+ rl_beg_of_line (1, key);
1244+ RL_UNSETSTATE (RL_STATE_VIMOTION);
1245+ r = vidomove_dispatch (_rl_vimvcxt);
1246+ }
1247 #if defined (READLINE_CALLBACKS)
1248 else if (RL_ISSTATE (RL_STATE_CALLBACK))
1249 {
1250diff -Naur bash-4.2.orig/lib/sh/eaccess.c bash-4.2/lib/sh/eaccess.c
1251--- bash-4.2.orig/lib/sh/eaccess.c 2011-01-09 01:50:10.000000000 +0000
[e307159]1252+++ bash-4.2/lib/sh/eaccess.c 2013-03-12 21:55:21.668772032 +0000
[31f34c6]1253@@ -82,6 +82,8 @@
1254 const char *path;
1255 struct stat *finfo;
1256 {
1257+ static char *pbuf = 0;
1258+
1259 if (*path == '\0')
1260 {
1261 errno = ENOENT;
1262@@ -106,7 +108,7 @@
1263 trailing slash. Make sure /dev/fd/xx really uses DEV_FD_PREFIX/xx.
1264 On most systems, with the notable exception of linux, this is
1265 effectively a no-op. */
1266- char pbuf[32];
1267+ pbuf = xrealloc (pbuf, sizeof (DEV_FD_PREFIX) + strlen (path + 8));
1268 strcpy (pbuf, DEV_FD_PREFIX);
1269 strcat (pbuf, path + 8);
1270 return (stat (pbuf, finfo));
1271diff -Naur bash-4.2.orig/lib/sh/zread.c bash-4.2/lib/sh/zread.c
1272--- bash-4.2.orig/lib/sh/zread.c 2009-03-02 13:54:45.000000000 +0000
[e307159]1273+++ bash-4.2/lib/sh/zread.c 2013-03-12 21:55:21.601771765 +0000
[31f34c6]1274@@ -160,14 +160,13 @@
1275 zsyncfd (fd)
1276 int fd;
1277 {
1278- off_t off;
1279- int r;
1280+ off_t off, r;
1281
1282 off = lused - lind;
1283 r = 0;
1284 if (off > 0)
1285 r = lseek (fd, -off, SEEK_CUR);
1286
1287- if (r >= 0)
1288+ if (r != -1)
1289 lused = lind = 0;
1290 }
1291diff -Naur bash-4.2.orig/parse.y bash-4.2/parse.y
1292--- bash-4.2.orig/parse.y 2011-01-02 20:48:11.000000000 +0000
[e307159]1293+++ bash-4.2/parse.y 2013-03-12 21:55:21.731772283 +0000
1294@@ -2393,6 +2393,7 @@
1295 is the last character). If it's not the last character, we need
1296 to consume the quoted newline and move to the next character in
1297 the expansion. */
1298+#if defined (ALIAS)
1299 if (expanding_alias () && shell_input_line[shell_input_line_index+1] == '\0')
1300 {
1301 uc = 0;
1302@@ -2403,7 +2404,8 @@
1303 shell_input_line_index++; /* skip newline */
1304 goto next_alias_char; /* and get next character */
1305 }
1306- else
1307+ else
1308+#endif
1309 goto restart_read;
1310 }
1311
1312@@ -2499,7 +2501,7 @@
[31f34c6]1313 We do this only if it is time to do so. Notice that only here
1314 is the mail alarm reset; nothing takes place in check_mail ()
1315 except the checking of mail. Please don't change this. */
1316- if (prompt_is_ps1 && time_to_check_mail ())
1317+ if (prompt_is_ps1 && parse_and_execute_level == 0 && time_to_check_mail ())
1318 {
1319 check_mail ();
1320 reset_mail_timer ();
[e307159]1321@@ -3842,6 +3844,7 @@
[31f34c6]1322 int flags;
1323 {
1324 sh_parser_state_t ps;
1325+ sh_input_line_state_t ls;
1326 int orig_ind, nc, sflags;
1327 char *ret, *s, *ep, *ostring;
1328
[e307159]1329@@ -3849,10 +3852,12 @@
[31f34c6]1330 orig_ind = *indp;
1331 ostring = string;
1332
1333+/*itrace("xparse_dolparen: size = %d shell_input_line = `%s'", shell_input_line_size, shell_input_line);*/
1334 sflags = SEVAL_NONINT|SEVAL_NOHIST|SEVAL_NOFREE;
1335 if (flags & SX_NOLONGJMP)
1336 sflags |= SEVAL_NOLONGJMP;
1337 save_parser_state (&ps);
1338+ save_input_line_state (&ls);
1339
1340 /*(*/
1341 parser_state |= PST_CMDSUBST|PST_EOFTOKEN; /* allow instant ')' */ /*(*/
[e307159]1342@@ -3861,6 +3866,8 @@
[31f34c6]1343
1344 restore_parser_state (&ps);
1345 reset_parser ();
1346+ /* reset_parser clears shell_input_line and associated variables */
1347+ restore_input_line_state (&ls);
1348 if (interactive)
1349 token_to_read = 0;
1350
[e307159]1351@@ -4895,6 +4902,9 @@
[31f34c6]1352 return (current_command_line_count == 2 ? "\n" : "");
1353 }
1354
1355+ if (parser_state & PST_COMPASSIGN)
1356+ return (" ");
1357+
1358 /* First, handle some special cases. */
1359 /*(*/
1360 /* If we just read `()', assume it's a function definition, and don't
[e307159]1361@@ -5135,6 +5145,9 @@
[31f34c6]1362 case 'A':
1363 /* Make the current time/date into a string. */
1364 (void) time (&the_time);
1365+#if defined (HAVE_TZSET)
1366+ sv_tz ("TZ"); /* XXX -- just make sure */
1367+#endif
1368 tm = localtime (&the_time);
1369
1370 if (c == 'd')
[e307159]1371@@ -5905,6 +5918,12 @@
[31f34c6]1372 ps->expand_aliases = expand_aliases;
1373 ps->echo_input_at_read = echo_input_at_read;
1374
1375+ ps->token = token;
1376+ ps->token_buffer_size = token_buffer_size;
1377+ /* Force reallocation on next call to read_token_word */
1378+ token = 0;
1379+ token_buffer_size = 0;
1380+
1381 return (ps);
1382 }
1383
[e307159]1384@@ -5946,6 +5965,42 @@
[31f34c6]1385
1386 expand_aliases = ps->expand_aliases;
1387 echo_input_at_read = ps->echo_input_at_read;
1388+
1389+ FREE (token);
1390+ token = ps->token;
1391+ token_buffer_size = ps->token_buffer_size;
1392+}
1393+
1394+sh_input_line_state_t *
1395+save_input_line_state (ls)
1396+ sh_input_line_state_t *ls;
1397+{
1398+ if (ls == 0)
1399+ ls = (sh_input_line_state_t *)xmalloc (sizeof (sh_input_line_state_t));
1400+ if (ls == 0)
1401+ return ((sh_input_line_state_t *)NULL);
1402+
1403+ ls->input_line = shell_input_line;
1404+ ls->input_line_size = shell_input_line_size;
1405+ ls->input_line_len = shell_input_line_len;
1406+ ls->input_line_index = shell_input_line_index;
1407+
1408+ /* force reallocation */
1409+ shell_input_line = 0;
1410+ shell_input_line_size = shell_input_line_len = shell_input_line_index = 0;
1411+}
1412+
1413+void
1414+restore_input_line_state (ls)
1415+ sh_input_line_state_t *ls;
1416+{
1417+ FREE (shell_input_line);
1418+ shell_input_line = ls->input_line;
1419+ shell_input_line_size = ls->input_line_size;
1420+ shell_input_line_len = ls->input_line_len;
1421+ shell_input_line_index = ls->input_line_index;
1422+
1423+ set_line_mbstate ();
1424 }
1425
1426 /************************************************
1427diff -Naur bash-4.2.orig/patchlevel.h bash-4.2/patchlevel.h
1428--- bash-4.2.orig/patchlevel.h 2010-06-13 00:14:48.000000000 +0000
[e307159]1429+++ bash-4.2/patchlevel.h 2013-03-12 21:55:21.740772319 +0000
[31f34c6]1430@@ -25,6 +25,6 @@
1431 regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
1432 looks for to find the patch level (for the sccs version string). */
1433
1434-#define PATCHLEVEL 0
[e307159]1435+#define PATCHLEVEL 45
[31f34c6]1436
1437 #endif /* _PATCHLEVEL_H_ */
1438diff -Naur bash-4.2.orig/pathexp.c bash-4.2/pathexp.c
1439--- bash-4.2.orig/pathexp.c 2010-08-14 03:21:57.000000000 +0000
[e307159]1440+++ bash-4.2/pathexp.c 2013-03-12 21:55:21.550771561 +0000
[31f34c6]1441@@ -196,7 +196,7 @@
1442 {
1443 if ((qflags & QGLOB_FILENAME) && pathname[i+1] == '/')
1444 continue;
1445- if ((qflags & QGLOB_REGEXP) && ere_char (pathname[i+1]) == 0)
1446+ if (pathname[i+1] != CTLESC && (qflags & QGLOB_REGEXP) && ere_char (pathname[i+1]) == 0)
1447 continue;
1448 temp[j++] = '\\';
1449 i++;
1450diff -Naur bash-4.2.orig/print_cmd.c bash-4.2/print_cmd.c
1451--- bash-4.2.orig/print_cmd.c 2010-05-30 22:34:08.000000000 +0000
[e307159]1452+++ bash-4.2/print_cmd.c 2013-03-12 21:55:21.526771466 +0000
[31f34c6]1453@@ -315,6 +315,7 @@
1454 cprintf ("( ");
1455 skip_this_indent++;
1456 make_command_string_internal (command->value.Subshell->command);
1457+ PRINT_DEFERRED_HEREDOCS ("");
1458 cprintf (" )");
1459 break;
1460
1461@@ -592,6 +593,7 @@
1462 newline ("do\n");
1463 indentation += indentation_amount;
1464 make_command_string_internal (arith_for_command->action);
1465+ PRINT_DEFERRED_HEREDOCS ("");
1466 semicolon ();
1467 indentation -= indentation_amount;
1468 newline ("done");
1469@@ -653,6 +655,7 @@
1470 }
1471
1472 make_command_string_internal (group_command->command);
1473+ PRINT_DEFERRED_HEREDOCS ("");
1474
1475 if (inside_function_def)
1476 {
[e307159]1477diff -Naur bash-4.2.orig/redir.c bash-4.2/redir.c
1478--- bash-4.2.orig/redir.c 2011-01-02 21:00:31.000000000 +0000
1479+++ bash-4.2/redir.c 2013-03-12 21:55:21.740772319 +0000
1480@@ -1007,6 +1007,16 @@
1481 close (redirector);
1482 REDIRECTION_ERROR (r, errno, -1);
1483 }
1484+ if ((flags & RX_UNDOABLE) && (ri == r_move_input || ri == r_move_output))
1485+ {
1486+ /* r_move_input and r_move_output add an additional close()
1487+ that needs to be undone */
1488+ if (fcntl (redirector, F_GETFD, 0) != -1)
1489+ {
1490+ r = add_undo_redirect (redir_fd, r_close_this, -1);
1491+ REDIRECTION_ERROR (r, errno, -1);
1492+ }
1493+ }
1494 #if defined (BUFFERED_INPUT)
1495 check_bash_input (redirector);
1496 #endif
1497@@ -1091,10 +1101,12 @@
1498
1499 #if defined (BUFFERED_INPUT)
1500 check_bash_input (redirector);
1501- close_buffered_fd (redirector);
1502+ r = close_buffered_fd (redirector);
1503 #else /* !BUFFERED_INPUT */
1504- close (redirector);
1505+ r = close (redirector);
1506 #endif /* !BUFFERED_INPUT */
1507+ if (r < 0 && (flags & RX_INTERNAL) && (errno == EIO || errno == ENOSPC))
1508+ REDIRECTION_ERROR (r, errno, -1);
1509 }
1510 break;
1511
[31f34c6]1512diff -Naur bash-4.2.orig/shell.h bash-4.2/shell.h
1513--- bash-4.2.orig/shell.h 2011-01-07 03:16:55.000000000 +0000
[e307159]1514+++ bash-4.2/shell.h 2013-03-12 21:55:21.537771510 +0000
[31f34c6]1515@@ -136,6 +136,9 @@
1516 int parser_state;
1517 int *token_state;
1518
1519+ char *token;
1520+ int token_buffer_size;
1521+
1522 /* input line state -- line number saved elsewhere */
1523 int input_line_terminator;
1524 int eof_encountered;
1525@@ -166,6 +169,16 @@
1526
1527 } sh_parser_state_t;
1528
1529+typedef struct _sh_input_line_state_t {
1530+ char *input_line;
1531+ int input_line_index;
1532+ int input_line_size;
1533+ int input_line_len;
1534+} sh_input_line_state_t;
1535+
1536 /* Let's try declaring these here. */
1537 extern sh_parser_state_t *save_parser_state __P((sh_parser_state_t *));
1538 extern void restore_parser_state __P((sh_parser_state_t *));
1539+
1540+extern sh_input_line_state_t *save_input_line_state __P((sh_input_line_state_t *));
1541+extern void restore_input_line_state __P((sh_input_line_state_t *));
1542diff -Naur bash-4.2.orig/sig.c bash-4.2/sig.c
1543--- bash-4.2.orig/sig.c 2010-11-23 13:21:22.000000000 +0000
[e307159]1544+++ bash-4.2/sig.c 2013-03-12 21:55:21.516771426 +0000
[31f34c6]1545@@ -46,6 +46,7 @@
1546
1547 #if defined (READLINE)
1548 # include "bashline.h"
1549+# include <readline/readline.h>
1550 #endif
1551
1552 #if defined (HISTORY)
1553@@ -62,6 +63,7 @@
1554 #if defined (HISTORY)
1555 extern int history_lines_this_session;
1556 #endif
1557+extern int no_line_editing;
1558
1559 extern void initialize_siglist ();
1560
1561@@ -505,7 +507,10 @@
1562 {
1563 #if defined (HISTORY)
1564 /* XXX - will inhibit history file being written */
1565- history_lines_this_session = 0;
1566+# if defined (READLINE)
1567+ if (interactive_shell == 0 || interactive == 0 || (sig != SIGHUP && sig != SIGTERM) || no_line_editing || (RL_ISSTATE (RL_STATE_READCMD) == 0))
1568+# endif
1569+ history_lines_this_session = 0;
1570 #endif
1571 terminate_immediately = 0;
1572 termsig_handler (sig);
1573diff -Naur bash-4.2.orig/subst.c bash-4.2/subst.c
1574--- bash-4.2.orig/subst.c 2011-01-02 21:12:51.000000000 +0000
[e307159]1575+++ bash-4.2/subst.c 2013-03-12 21:55:21.726772263 +0000
[31f34c6]1576@@ -366,6 +366,11 @@
1577 f &= ~W_ASSNBLTIN;
1578 fprintf (stderr, "W_ASSNBLTIN%s", f ? "|" : "");
1579 }
1580+ if (f & W_ASSNGLOBAL)
1581+ {
1582+ f &= ~W_ASSNGLOBAL;
1583+ fprintf (stderr, "W_ASSNGLOBAL%s", f ? "|" : "");
1584+ }
1585 if (f & W_COMPASSIGN)
1586 {
1587 f &= ~W_COMPASSIGN;
1588@@ -1379,10 +1384,12 @@
1589 slen = strlen (string + *sindex) + *sindex;
1590
1591 /* The handling of dolbrace_state needs to agree with the code in parse.y:
1592- parse_matched_pair() */
1593- dolbrace_state = 0;
1594- if (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))
1595- dolbrace_state = (flags & SX_POSIXEXP) ? DOLBRACE_QUOTE : DOLBRACE_PARAM;
1596+ parse_matched_pair(). The different initial value is to handle the
1597+ case where this function is called to parse the word in
1598+ ${param op word} (SX_WORD). */
1599+ dolbrace_state = (flags & SX_WORD) ? DOLBRACE_WORD : DOLBRACE_PARAM;
1600+ if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && (flags & SX_POSIXEXP))
1601+ dolbrace_state = DOLBRACE_QUOTE;
1602
1603 i = *sindex;
1604 while (c = string[i])
1605@@ -2801,7 +2808,7 @@
1606 }
1607 else if (assign_list)
1608 {
1609- if (word->flags & W_ASSIGNARG)
1610+ if ((word->flags & W_ASSIGNARG) && (word->flags & W_ASSNGLOBAL) == 0)
1611 aflags |= ASS_MKLOCAL;
1612 if (word->flags & W_ASSIGNASSOC)
1613 aflags |= ASS_MKASSOC;
1614@@ -3371,7 +3378,7 @@
1615 if (string == 0 || *string == '\0')
1616 return (WORD_LIST *)NULL;
1617
1618- td.flags = 0;
1619+ td.flags = W_NOSPLIT2; /* no splitting, remove "" and '' */
1620 td.word = string;
1621 tresult = call_expand_word_internal (&td, quoted, 1, dollar_at_p, has_dollar_at);
1622 return (tresult);
1623@@ -3704,7 +3711,10 @@
1624 break;
1625 }
1626 else if (string[i] == CTLNUL)
1627- i++;
1628+ {
1629+ i++;
1630+ continue;
1631+ }
1632
1633 prev_i = i;
1634 ADVANCE_CHAR (string, slen, i);
1635@@ -4156,7 +4166,7 @@
1636 simple = (wpat[0] != L'\\' && wpat[0] != L'*' && wpat[0] != L'?' && wpat[0] != L'[');
1637 #if defined (EXTENDED_GLOB)
1638 if (extended_glob)
1639- simple |= (wpat[1] != L'(' || (wpat[0] != L'*' && wpat[0] != L'?' && wpat[0] != L'+' && wpat[0] != L'!' && wpat[0] != L'@')); /*)*/
1640+ simple &= (wpat[1] != L'(' || (wpat[0] != L'*' && wpat[0] != L'?' && wpat[0] != L'+' && wpat[0] != L'!' && wpat[0] != L'@')); /*)*/
1641 #endif
1642
1643 /* If the pattern doesn't match anywhere in the string, go ahead and
1644@@ -4607,6 +4617,7 @@
1645 if (ifs_firstc == 0)
1646 #endif
1647 word->flags |= W_NOSPLIT;
1648+ word->flags |= W_NOSPLIT2;
1649 result = call_expand_word_internal (word, quoted, 0, (int *)NULL, (int *)NULL);
1650 expand_no_split_dollar_star = 0;
1651
[e307159]1652@@ -5113,6 +5124,10 @@
1653 dev_fd_list[parent_pipe_fd] = 0;
1654 #endif /* HAVE_DEV_FD */
1655
1656+ /* subshells shouldn't have this flag, which controls using the temporary
1657+ environment for variable lookups. */
1658+ expanding_redir = 0;
1659+
1660 result = parse_and_execute (string, "process substitution", (SEVAL_NONINT|SEVAL_NOHIST));
1661
1662 #if !defined (HAVE_DEV_FD)
1663@@ -5798,6 +5813,16 @@
[31f34c6]1664 is the only expansion that creates more than one word. */
1665 if (qdollaratp && ((hasdol && quoted) || l->next))
1666 *qdollaratp = 1;
1667+ /* If we have a quoted null result (QUOTED_NULL(temp)) and the word is
1668+ a quoted null (l->next == 0 && QUOTED_NULL(l->word->word)), the
1669+ flags indicate it (l->word->flags & W_HASQUOTEDNULL), and the
1670+ expansion is quoted (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))
1671+ (which is more paranoia than anything else), we need to return the
1672+ quoted null string and set the flags to indicate it. */
1673+ if (l->next == 0 && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && QUOTED_NULL(temp) && QUOTED_NULL(l->word->word) && (l->word->flags & W_HASQUOTEDNULL))
1674+ {
1675+ w->flags |= W_HASQUOTEDNULL;
1676+ }
1677 dispose_words (l);
1678 }
1679 else if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && hasdol)
[e307159]1680@@ -7176,7 +7201,7 @@
[31f34c6]1681 {
1682 /* Extract the contents of the ${ ... } expansion
1683 according to the Posix.2 rules. */
1684- value = extract_dollar_brace_string (string, &sindex, quoted, (c == '%' || c == '#') ? SX_POSIXEXP : 0);
1685+ value = extract_dollar_brace_string (string, &sindex, quoted, (c == '%' || c == '#' || c =='/' || c == '^' || c == ',' || c ==':') ? SX_POSIXEXP|SX_WORD : SX_WORD);
1686 if (string[sindex] == RBRACE)
1687 sindex++;
1688 else
[e307159]1689@@ -7268,6 +7293,7 @@
[31f34c6]1690 default:
1691 case '\0':
1692 bad_substitution:
1693+ last_command_exit_value = EXECUTION_FAILURE;
1694 report_error (_("%s: bad substitution"), string ? string : "??");
1695 FREE (value);
1696 FREE (temp);
[e307159]1697@@ -7900,7 +7926,7 @@
[31f34c6]1698
1699 /* State flags */
1700 int had_quoted_null;
1701- int has_dollar_at;
1702+ int has_dollar_at, temp_has_dollar_at;
1703 int tflag;
1704 int pflags; /* flags passed to param_expand */
1705
[e307159]1706@@ -8105,13 +8131,14 @@
[31f34c6]1707 if (expanded_something)
1708 *expanded_something = 1;
1709
1710- has_dollar_at = 0;
1711+ temp_has_dollar_at = 0;
1712 pflags = (word->flags & W_NOCOMSUB) ? PF_NOCOMSUB : 0;
1713 if (word->flags & W_NOSPLIT2)
1714 pflags |= PF_NOSPLIT2;
1715 tword = param_expand (string, &sindex, quoted, expanded_something,
1716- &has_dollar_at, &quoted_dollar_at,
1717+ &temp_has_dollar_at, &quoted_dollar_at,
1718 &had_quoted_null, pflags);
1719+ has_dollar_at += temp_has_dollar_at;
1720
1721 if (tword == &expand_wdesc_error || tword == &expand_wdesc_fatal)
1722 {
[e307159]1723@@ -8129,6 +8156,14 @@
[31f34c6]1724 temp = tword->word;
1725 dispose_word_desc (tword);
1726
1727+ /* Kill quoted nulls; we will add them back at the end of
1728+ expand_word_internal if nothing else in the string */
1729+ if (had_quoted_null && temp && QUOTED_NULL (temp))
1730+ {
1731+ FREE (temp);
1732+ temp = (char *)NULL;
1733+ }
1734+
1735 goto add_string;
1736 break;
1737
[e307159]1738@@ -8244,9 +8279,10 @@
[31f34c6]1739
1740 temp = (char *)NULL;
1741
1742- has_dollar_at = 0;
1743+ temp_has_dollar_at = 0; /* XXX */
1744 /* Need to get W_HASQUOTEDNULL flag through this function. */
1745- list = expand_word_internal (tword, Q_DOUBLE_QUOTES, 0, &has_dollar_at, (int *)NULL);
1746+ list = expand_word_internal (tword, Q_DOUBLE_QUOTES, 0, &temp_has_dollar_at, (int *)NULL);
1747+ has_dollar_at += temp_has_dollar_at;
1748
1749 if (list == &expand_word_error || list == &expand_word_fatal)
1750 {
[e307159]1751@@ -8533,7 +8569,7 @@
[31f34c6]1752 tword->flags |= W_NOEXPAND; /* XXX */
1753 if (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))
1754 tword->flags |= W_QUOTED;
1755- if (had_quoted_null)
1756+ if (had_quoted_null && QUOTED_NULL (istring))
1757 tword->flags |= W_HASQUOTEDNULL;
1758 list = make_word_list (tword, (WORD_LIST *)NULL);
1759 }
[e307159]1760@@ -8564,7 +8600,7 @@
[31f34c6]1761 tword->flags |= W_NOGLOB;
1762 if (word->flags & W_NOEXPAND)
1763 tword->flags |= W_NOEXPAND;
1764- if (had_quoted_null)
1765+ if (had_quoted_null && QUOTED_NULL (istring))
1766 tword->flags |= W_HASQUOTEDNULL; /* XXX */
1767 list = make_word_list (tword, (WORD_LIST *)NULL);
1768 }
1769diff -Naur bash-4.2.orig/subst.h bash-4.2/subst.h
1770--- bash-4.2.orig/subst.h 2010-12-03 01:21:29.000000000 +0000
[e307159]1771+++ bash-4.2/subst.h 2013-03-12 21:55:21.450771163 +0000
[31f34c6]1772@@ -56,6 +56,7 @@
1773 #define SX_NOLONGJMP 0x0040 /* don't longjmp on fatal error */
1774 #define SX_ARITHSUB 0x0080 /* extracting $(( ... )) (currently unused) */
1775 #define SX_POSIXEXP 0x0100 /* extracting new Posix pattern removal expansions in extract_dollar_brace_string */
1776+#define SX_WORD 0x0200 /* extracting word in ${param op word} */
1777
1778 /* Remove backslashes which are quoting backquotes from STRING. Modifies
1779 STRING, and returns a pointer to it. */
1780diff -Naur bash-4.2.orig/support/shobj-conf bash-4.2/support/shobj-conf
1781--- bash-4.2.orig/support/shobj-conf 2009-10-28 13:20:21.000000000 +0000
[e307159]1782+++ bash-4.2/support/shobj-conf 2013-03-12 21:55:21.592771729 +0000
[31f34c6]1783@@ -157,7 +157,7 @@
1784 ;;
1785
1786 # Darwin/MacOS X
1787-darwin[89]*|darwin10*)
1788+darwin[89]*|darwin1[012]*)
1789 SHOBJ_STATUS=supported
1790 SHLIB_STATUS=supported
1791
1792@@ -186,7 +186,7 @@
1793 SHLIB_LIBSUFF='dylib'
1794
1795 case "${host_os}" in
1796- darwin[789]*|darwin10*) SHOBJ_LDFLAGS=''
1797+ darwin[789]*|darwin1[012]*) SHOBJ_LDFLAGS=''
1798 SHLIB_XLDFLAGS='-dynamiclib -arch_only `/usr/bin/arch` -install_name $(libdir)/$@ -current_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -compatibility_version $(SHLIB_MAJOR) -v'
1799 ;;
1800 *) SHOBJ_LDFLAGS='-dynamic'
1801diff -Naur bash-4.2.orig/tests/shopt.right bash-4.2/tests/shopt.right
1802--- bash-4.2.orig/tests/shopt.right 2010-07-03 03:36:30.000000000 +0000
[e307159]1803+++ bash-4.2/tests/shopt.right 2013-03-12 21:55:21.653771972 +0000
[31f34c6]1804@@ -12,6 +12,7 @@
1805 shopt -u compat32
1806 shopt -u compat40
1807 shopt -u compat41
1808+shopt -u direxpand
1809 shopt -u dirspell
1810 shopt -u dotglob
1811 shopt -u execfail
1812@@ -68,6 +69,7 @@
1813 shopt -u compat32
1814 shopt -u compat40
1815 shopt -u compat41
1816+shopt -u direxpand
1817 shopt -u dirspell
1818 shopt -u dotglob
1819 shopt -u execfail
1820@@ -101,6 +103,7 @@
1821 compat32 off
1822 compat40 off
1823 compat41 off
1824+direxpand off
1825 dirspell off
1826 dotglob off
1827 execfail off
1828diff -Naur bash-4.2.orig/variables.c bash-4.2/variables.c
1829--- bash-4.2.orig/variables.c 2011-01-25 01:07:48.000000000 +0000
[e307159]1830+++ bash-4.2/variables.c 2013-03-12 21:55:21.499771358 +0000
[31f34c6]1831@@ -3653,6 +3653,22 @@
1832 return n;
1833 }
1834
1835+int
1836+chkexport (name)
1837+ char *name;
1838+{
1839+ SHELL_VAR *v;
1840+
1841+ v = find_variable (name);
1842+ if (v && exported_p (v))
1843+ {
1844+ array_needs_making = 1;
1845+ maybe_make_export_env ();
1846+ return 1;
1847+ }
1848+ return 0;
1849+}
1850+
1851 void
1852 maybe_make_export_env ()
1853 {
1854@@ -4214,7 +4230,7 @@
1855 { "TEXTDOMAIN", sv_locale },
1856 { "TEXTDOMAINDIR", sv_locale },
1857
1858-#if defined (HAVE_TZSET) && defined (PROMPT_STRING_DECODE)
1859+#if defined (HAVE_TZSET)
1860 { "TZ", sv_tz },
1861 #endif
1862
1863@@ -4558,12 +4574,13 @@
1864 }
1865 #endif /* HISTORY */
1866
1867-#if defined (HAVE_TZSET) && defined (PROMPT_STRING_DECODE)
1868+#if defined (HAVE_TZSET)
1869 void
1870 sv_tz (name)
1871 char *name;
1872 {
1873- tzset ();
1874+ if (chkexport (name))
1875+ tzset ();
1876 }
1877 #endif
1878
1879diff -Naur bash-4.2.orig/variables.h bash-4.2/variables.h
1880--- bash-4.2.orig/variables.h 2010-12-03 01:22:01.000000000 +0000
[e307159]1881+++ bash-4.2/variables.h 2013-03-12 21:55:21.486771306 +0000
[31f34c6]1882@@ -313,6 +313,7 @@
1883
1884 extern void sort_variables __P((SHELL_VAR **));
1885
1886+extern int chkexport __P((char *));
1887 extern void maybe_make_export_env __P((void));
1888 extern void update_export_env_inplace __P((char *, int, char *));
1889 extern void put_command_name_into_env __P((char *));
Note: See TracBrowser for help on using the repository browser.