source: patches/bash-4.2-branch_update-1.patch@ f8e1743

Last change on this file since f8e1743 was b36b9f9, checked in by Joe Ciccone <jciccone@…>, 14 years ago

Updated Bash to 4.2.

  • Property mode set to 100644
File size: 11.8 KB
RevLine 
[b36b9f9]1Submitted By: Joe Ciccone <jciccone@gmail.com>
2Date: 04-16-2011
3Initial Package Version: 4.2
4Origin: Upstream
5Upstream Status: From Upstream
6Description: Contains all upstream patches up to 4.2-008
7
8diff -Naur bash-4.2.orig/builtins/printf.def bash-4.2/builtins/printf.def
9--- bash-4.2.orig/builtins/printf.def 2010-11-23 10:02:55.000000000 -0500
10+++ bash-4.2/builtins/printf.def 2011-04-16 16:50:36.379215007 -0400
11@@ -465,6 +465,9 @@
12 secs = shell_start_time; /* roughly $SECONDS */
13 else
14 secs = arg;
15+#if defined (HAVE_TZSET)
16+ sv_tz ("TZ"); /* XXX -- just make sure */
17+#endif
18 tm = localtime (&secs);
19 n = strftime (timebuf, sizeof (timebuf), timefmt, tm);
20 free (timefmt);
21diff -Naur bash-4.2.orig/lib/glob/gmisc.c bash-4.2/lib/glob/gmisc.c
22--- bash-4.2.orig/lib/glob/gmisc.c 2011-02-05 16:11:17.000000000 -0500
23+++ bash-4.2/lib/glob/gmisc.c 2011-04-16 16:50:36.371215007 -0400
24@@ -77,8 +77,8 @@
25 wchar_t *wpat;
26 size_t wmax;
27 {
28- wchar_t wc, *wbrack;
29- int matlen, t, in_cclass, in_collsym, in_equiv;
30+ wchar_t wc;
31+ int matlen, bracklen, t, in_cclass, in_collsym, in_equiv;
32
33 if (*wpat == 0)
34 return (0);
35@@ -118,58 +118,80 @@
36 break;
37 case L'[':
38 /* scan for ending `]', skipping over embedded [:...:] */
39- wbrack = wpat;
40+ bracklen = 1;
41 wc = *wpat++;
42 do
43 {
44 if (wc == 0)
45 {
46- matlen += wpat - wbrack - 1; /* incremented below */
47- break;
48+ wpat--; /* back up to NUL */
49+ matlen += bracklen;
50+ goto bad_bracket;
51 }
52 else if (wc == L'\\')
53 {
54- wc = *wpat++;
55- if (*wpat == 0)
56- break;
57+ /* *wpat == backslash-escaped character */
58+ bracklen++;
59+ /* If the backslash or backslash-escape ends the string,
60+ bail. The ++wpat skips over the backslash escape */
61+ if (*wpat == 0 || *++wpat == 0)
62+ {
63+ matlen += bracklen;
64+ goto bad_bracket;
65+ }
66 }
67 else if (wc == L'[' && *wpat == L':') /* character class */
68 {
69 wpat++;
70+ bracklen++;
71 in_cclass = 1;
72 }
73 else if (in_cclass && wc == L':' && *wpat == L']')
74 {
75 wpat++;
76+ bracklen++;
77 in_cclass = 0;
78 }
79 else if (wc == L'[' && *wpat == L'.') /* collating symbol */
80 {
81 wpat++;
82+ bracklen++;
83 if (*wpat == L']') /* right bracket can appear as collating symbol */
84- wpat++;
85+ {
86+ wpat++;
87+ bracklen++;
88+ }
89 in_collsym = 1;
90 }
91 else if (in_collsym && wc == L'.' && *wpat == L']')
92 {
93 wpat++;
94+ bracklen++;
95 in_collsym = 0;
96 }
97 else if (wc == L'[' && *wpat == L'=') /* equivalence class */
98 {
99 wpat++;
100+ bracklen++;
101 if (*wpat == L']') /* right bracket can appear as equivalence class */
102- wpat++;
103+ {
104+ wpat++;
105+ bracklen++;
106+ }
107 in_equiv = 1;
108 }
109 else if (in_equiv && wc == L'=' && *wpat == L']')
110 {
111 wpat++;
112+ bracklen++;
113 in_equiv = 0;
114 }
115+ else
116+ bracklen++;
117 }
118 while ((wc = *wpat++) != L']');
119 matlen++; /* bracket expression can only match one char */
120+bad_bracket:
121 break;
122 }
123 }
124@@ -213,8 +235,8 @@
125 char *pat;
126 size_t max;
127 {
128- char c, *brack;
129- int matlen, t, in_cclass, in_collsym, in_equiv;
130+ char c;
131+ int matlen, bracklen, t, in_cclass, in_collsym, in_equiv;
132
133 if (*pat == 0)
134 return (0);
135@@ -254,58 +276,80 @@
136 break;
137 case '[':
138 /* scan for ending `]', skipping over embedded [:...:] */
139- brack = pat;
140+ bracklen = 1;
141 c = *pat++;
142 do
143 {
144 if (c == 0)
145 {
146- matlen += pat - brack - 1; /* incremented below */
147- break;
148+ pat--; /* back up to NUL */
149+ matlen += bracklen;
150+ goto bad_bracket;
151 }
152 else if (c == '\\')
153 {
154- c = *pat++;
155- if (*pat == 0)
156- break;
157+ /* *pat == backslash-escaped character */
158+ bracklen++;
159+ /* If the backslash or backslash-escape ends the string,
160+ bail. The ++pat skips over the backslash escape */
161+ if (*pat == 0 || *++pat == 0)
162+ {
163+ matlen += bracklen;
164+ goto bad_bracket;
165+ }
166 }
167 else if (c == '[' && *pat == ':') /* character class */
168 {
169 pat++;
170+ bracklen++;
171 in_cclass = 1;
172 }
173 else if (in_cclass && c == ':' && *pat == ']')
174 {
175 pat++;
176+ bracklen++;
177 in_cclass = 0;
178 }
179 else if (c == '[' && *pat == '.') /* collating symbol */
180 {
181 pat++;
182+ bracklen++;
183 if (*pat == ']') /* right bracket can appear as collating symbol */
184- pat++;
185+ {
186+ pat++;
187+ bracklen++;
188+ }
189 in_collsym = 1;
190 }
191 else if (in_collsym && c == '.' && *pat == ']')
192 {
193 pat++;
194+ bracklen++;
195 in_collsym = 0;
196 }
197 else if (c == '[' && *pat == '=') /* equivalence class */
198 {
199 pat++;
200+ bracklen++;
201 if (*pat == ']') /* right bracket can appear as equivalence class */
202- pat++;
203+ {
204+ pat++;
205+ bracklen++;
206+ }
207 in_equiv = 1;
208 }
209 else if (in_equiv && c == '=' && *pat == ']')
210 {
211 pat++;
212+ bracklen++;
213 in_equiv = 0;
214 }
215+ else
216+ bracklen++;
217 }
218 while ((c = *pat++) != ']');
219 matlen++; /* bracket expression can only match one char */
220+bad_bracket:
221 break;
222 }
223 }
224diff -Naur bash-4.2.orig/lib/readline/callback.c bash-4.2/lib/readline/callback.c
225--- bash-4.2.orig/lib/readline/callback.c 2010-06-06 12:18:58.000000000 -0400
226+++ bash-4.2/lib/readline/callback.c 2011-04-16 16:50:36.359215007 -0400
227@@ -148,6 +148,9 @@
228 eof = _rl_vi_domove_callback (_rl_vimvcxt);
229 /* Should handle everything, including cleanup, numeric arguments,
230 and turning off RL_STATE_VIMOTION */
231+ if (RL_ISSTATE (RL_STATE_NUMERICARG) == 0)
232+ _rl_internal_char_cleanup ();
233+
234 return;
235 }
236 #endif
237diff -Naur bash-4.2.orig/lib/readline/vi_mode.c bash-4.2/lib/readline/vi_mode.c
238--- bash-4.2.orig/lib/readline/vi_mode.c 2010-11-20 19:51:39.000000000 -0500
239+++ bash-4.2/lib/readline/vi_mode.c 2011-04-16 16:50:36.359215007 -0400
240@@ -1114,7 +1114,7 @@
241 rl_beg_of_line (1, c);
242 _rl_vi_last_motion = c;
243 RL_UNSETSTATE (RL_STATE_VIMOTION);
244- return (0);
245+ return (vidomove_dispatch (m));
246 }
247 #if defined (READLINE_CALLBACKS)
248 /* XXX - these need to handle rl_universal_argument bindings */
249diff -Naur bash-4.2.orig/parse.y bash-4.2/parse.y
250--- bash-4.2.orig/parse.y 2011-01-02 15:48:11.000000000 -0500
251+++ bash-4.2/parse.y 2011-04-16 16:50:36.379215007 -0400
252@@ -5135,6 +5135,9 @@
253 case 'A':
254 /* Make the current time/date into a string. */
255 (void) time (&the_time);
256+#if defined (HAVE_TZSET)
257+ sv_tz ("TZ"); /* XXX -- just make sure */
258+#endif
259 tm = localtime (&the_time);
260
261 if (c == 'd')
262diff -Naur bash-4.2.orig/patchlevel.h bash-4.2/patchlevel.h
263--- bash-4.2.orig/patchlevel.h 2010-06-12 20:14:48.000000000 -0400
264+++ bash-4.2/patchlevel.h 2011-04-16 16:50:36.387215007 -0400
265@@ -25,6 +25,6 @@
266 regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
267 looks for to find the patch level (for the sccs version string). */
268
269-#define PATCHLEVEL 0
270+#define PATCHLEVEL 8
271
272 #endif /* _PATCHLEVEL_H_ */
273diff -Naur bash-4.2.orig/sig.c bash-4.2/sig.c
274--- bash-4.2.orig/sig.c 2010-11-23 08:21:22.000000000 -0500
275+++ bash-4.2/sig.c 2011-04-16 16:50:36.387215007 -0400
276@@ -46,6 +46,7 @@
277
278 #if defined (READLINE)
279 # include "bashline.h"
280+# include <readline/readline.h>
281 #endif
282
283 #if defined (HISTORY)
284@@ -62,6 +63,7 @@
285 #if defined (HISTORY)
286 extern int history_lines_this_session;
287 #endif
288+extern int no_line_editing;
289
290 extern void initialize_siglist ();
291
292@@ -505,7 +507,10 @@
293 {
294 #if defined (HISTORY)
295 /* XXX - will inhibit history file being written */
296- history_lines_this_session = 0;
297+# if defined (READLINE)
298+ if (interactive_shell == 0 || interactive == 0 || (sig != SIGHUP && sig != SIGTERM) || no_line_editing || (RL_ISSTATE (RL_STATE_READCMD) == 0))
299+# endif
300+ history_lines_this_session = 0;
301 #endif
302 terminate_immediately = 0;
303 termsig_handler (sig);
304diff -Naur bash-4.2.orig/subst.c bash-4.2/subst.c
305--- bash-4.2.orig/subst.c 2011-01-02 16:12:51.000000000 -0500
306+++ bash-4.2/subst.c 2011-04-16 16:50:36.383215007 -0400
307@@ -1379,10 +1379,12 @@
308 slen = strlen (string + *sindex) + *sindex;
309
310 /* The handling of dolbrace_state needs to agree with the code in parse.y:
311- parse_matched_pair() */
312- dolbrace_state = 0;
313- if (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))
314- dolbrace_state = (flags & SX_POSIXEXP) ? DOLBRACE_QUOTE : DOLBRACE_PARAM;
315+ parse_matched_pair(). The different initial value is to handle the
316+ case where this function is called to parse the word in
317+ ${param op word} (SX_WORD). */
318+ dolbrace_state = (flags & SX_WORD) ? DOLBRACE_WORD : DOLBRACE_PARAM;
319+ if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && (flags & SX_POSIXEXP))
320+ dolbrace_state = DOLBRACE_QUOTE;
321
322 i = *sindex;
323 while (c = string[i])
324@@ -3371,7 +3373,7 @@
325 if (string == 0 || *string == '\0')
326 return (WORD_LIST *)NULL;
327
328- td.flags = 0;
329+ td.flags = W_NOSPLIT2; /* no splitting, remove "" and '' */
330 td.word = string;
331 tresult = call_expand_word_internal (&td, quoted, 1, dollar_at_p, has_dollar_at);
332 return (tresult);
333@@ -4607,6 +4609,7 @@
334 if (ifs_firstc == 0)
335 #endif
336 word->flags |= W_NOSPLIT;
337+ word->flags |= W_NOSPLIT2;
338 result = call_expand_word_internal (word, quoted, 0, (int *)NULL, (int *)NULL);
339 expand_no_split_dollar_star = 0;
340
341@@ -7176,7 +7179,7 @@
342 {
343 /* Extract the contents of the ${ ... } expansion
344 according to the Posix.2 rules. */
345- value = extract_dollar_brace_string (string, &sindex, quoted, (c == '%' || c == '#') ? SX_POSIXEXP : 0);
346+ value = extract_dollar_brace_string (string, &sindex, quoted, (c == '%' || c == '#' || c =='/' || c == '^' || c == ',' || c ==':') ? SX_POSIXEXP|SX_WORD : SX_WORD);
347 if (string[sindex] == RBRACE)
348 sindex++;
349 else
350diff -Naur bash-4.2.orig/subst.h bash-4.2/subst.h
351--- bash-4.2.orig/subst.h 2010-12-02 20:21:29.000000000 -0500
352+++ bash-4.2/subst.h 2011-04-16 16:50:36.359215007 -0400
353@@ -56,6 +56,7 @@
354 #define SX_NOLONGJMP 0x0040 /* don't longjmp on fatal error */
355 #define SX_ARITHSUB 0x0080 /* extracting $(( ... )) (currently unused) */
356 #define SX_POSIXEXP 0x0100 /* extracting new Posix pattern removal expansions in extract_dollar_brace_string */
357+#define SX_WORD 0x0200 /* extracting word in ${param op word} */
358
359 /* Remove backslashes which are quoting backquotes from STRING. Modifies
360 STRING, and returns a pointer to it. */
361diff -Naur bash-4.2.orig/variables.c bash-4.2/variables.c
362--- bash-4.2.orig/variables.c 2011-01-24 20:07:48.000000000 -0500
363+++ bash-4.2/variables.c 2011-04-16 16:50:36.379215007 -0400
364@@ -3653,6 +3653,22 @@
365 return n;
366 }
367
368+int
369+chkexport (name)
370+ char *name;
371+{
372+ SHELL_VAR *v;
373+
374+ v = find_variable (name);
375+ if (v && exported_p (v))
376+ {
377+ array_needs_making = 1;
378+ maybe_make_export_env ();
379+ return 1;
380+ }
381+ return 0;
382+}
383+
384 void
385 maybe_make_export_env ()
386 {
387@@ -4214,7 +4230,7 @@
388 { "TEXTDOMAIN", sv_locale },
389 { "TEXTDOMAINDIR", sv_locale },
390
391-#if defined (HAVE_TZSET) && defined (PROMPT_STRING_DECODE)
392+#if defined (HAVE_TZSET)
393 { "TZ", sv_tz },
394 #endif
395
396@@ -4558,12 +4574,13 @@
397 }
398 #endif /* HISTORY */
399
400-#if defined (HAVE_TZSET) && defined (PROMPT_STRING_DECODE)
401+#if defined (HAVE_TZSET)
402 void
403 sv_tz (name)
404 char *name;
405 {
406- tzset ();
407+ if (chkexport (name))
408+ tzset ();
409 }
410 #endif
411
412diff -Naur bash-4.2.orig/variables.h bash-4.2/variables.h
413--- bash-4.2.orig/variables.h 2010-12-02 20:22:01.000000000 -0500
414+++ bash-4.2/variables.h 2011-04-16 16:50:36.375215007 -0400
415@@ -313,6 +313,7 @@
416
417 extern void sort_variables __P((SHELL_VAR **));
418
419+extern int chkexport __P((char *));
420 extern void maybe_make_export_env __P((void));
421 extern void update_export_env_inplace __P((char *, int, char *));
422 extern void put_command_name_into_env __P((char *));
Note: See TracBrowser for help on using the repository browser.