1 --- bash-3.1.orig/arrayfunc.c 2005-07-04 17:25:58.000000000 -0700
2 +++ bash-3.1/arrayfunc.c 2006-04-19 15:59:29.000000000 -0700
4 exp = (char *)xmalloc (len);
5 strncpy (exp, s, len - 1);
8 - t = expand_string_to_string (exp, 0);
10 - t = expand_string_to_string (exp, Q_DOUBLE_QUOTES);
12 + t = expand_arith_string (exp, 0);
13 this_command_name = (char *)NULL;
14 val = evalexp (t, &expok);
16 --- bash-3.1.orig/doc/bash.1 2005-10-12 08:40:52.000000000 -0700
17 +++ bash-3.1/doc/bash.1 2006-04-19 15:58:34.000000000 -0700
19 .\" Case Western Reserve University
22 -.\" Last Change: Sat Aug 27 13:28:44 EDT 2005
23 +.\" Last Change: Wed Dec 28 19:58:45 EST 2005
25 .\" bash_builtins, strip all but Built-Ins section
28 -.TH BASH 1 "2005 Aug 27" "GNU Bash-3.1-beta1"
29 +.TH BASH 1 "2005 Dec 28" "GNU Bash-3.1"
31 .\" There's some problem with having a `@'
32 .\" in a tagged paragraph with the BSD man macros.
35 is enabled, the match is performed without regard to the case
36 of alphabetic characters.
37 -The return value is 0 if the string matches or does not match
38 -the pattern, respectively, and 1 otherwise.
39 +The return value is 0 if the string matches (\fB==\fP) or does not match
40 +(\fB!=\fP) the pattern, and 1 otherwise.
41 Any part of the pattern may be quoted to force it to be matched as a
45 as for pathname expansion (see
48 +The \fIword\fP is expanded using tilde
49 +expansion, parameter and variable expansion, arithmetic substituion,
50 +command substitution, process substitution and quote removal.
51 +Each \fIpattern\fP examined is expanded using tilde
52 +expansion, parameter and variable expansion, arithmetic substituion,
53 +command substitution, and process substitution.
56 is enabled, the match is performed without regard to the case
58 returns true if any of the arguments are found, false if
61 -\fBulimit\fP [\fB\-SHacdflmnpstuv\fP [\fIlimit\fP]]
62 +\fBulimit\fP [\fB\-SHacdfilmnpqstuvx\fP [\fIlimit\fP]]
63 Provides control over the resources available to the shell and to
64 processes started by it, on systems that allow such control.
65 The \fB\-H\fP and \fB\-S\fP options specify that the hard or soft limit is
68 The maximum size of files created by the shell
71 +The maximum number of pending signals
74 The maximum size that may be locked into memory
78 The pipe size in 512-byte blocks (this may not be set)
81 +The maximum number of bytes in POSIX message queues
84 The maximum stack size
89 The maximum amount of virtual memory available to the shell
92 +The maximum number of file locks
96 --- bash-3.1.orig/doc/bashref.texi 2005-10-03 12:07:21.000000000 -0700
97 +++ bash-3.1/doc/bashref.texi 2006-04-19 15:58:34.000000000 -0700
99 (see the description of @code{shopt} in @ref{Bash Builtins})
100 is enabled, the match is performed without regard to the case
101 of alphabetic characters.
102 -The return value is 0 if the string matches or does not match
103 -the pattern, respectively, and 1 otherwise.
104 +The return value is 0 if the string matches (@samp{==}) or does not
105 +match (@samp{!=})the pattern, and 1 otherwise.
106 Any part of the pattern may be quoted to force it to be matched as a
109 @@ -2598,7 +2598,7 @@
110 Builtin commands are necessary to implement functionality impossible
111 or inconvenient to obtain with separate utilities.
113 -This section briefly the builtins which Bash inherits from
114 +This section briefly describes the builtins which Bash inherits from
115 the Bourne Shell, as well as the builtin commands which are unique
116 to or have been extended in Bash.
118 @@ -3833,7 +3833,7 @@
122 -ulimit [-acdflmnpstuvSH] [@var{limit}]
123 +ulimit [-acdfilmnpqstuvxSH] [@var{limit}]
125 @code{ulimit} provides control over the resources available to processes
126 started by the shell, on systems that allow such control. If an
127 @@ -3857,6 +3857,9 @@
129 The maximum size of files created by the shell.
132 +The maximum number of pending signals.
135 The maximum size that may be locked into memory.
137 @@ -3869,6 +3872,9 @@
139 The pipe buffer size.
142 +The maximum number of bytes in POSIX message queues.
145 The maximum stack size.
147 @@ -3881,6 +3887,9 @@
149 The maximum amount of virtual memory available to the process.
152 +The maximum number of file locks.
156 If @var{limit} is given, it is the new value of the specified resource;
157 @@ -4089,8 +4098,8 @@
158 Print shell input lines as they are read.
161 -Print a trace of simple commands, \fBfor\fP commands, \fBcase\fP
162 -commands, \fBselect\fP commands, and arithmetic \fBfor\fP commands
163 +Print a trace of simple commands, @code{for} commands, @code{case}
164 +commands, @code{select} commands, and arithmetic @code{for} commands
165 and their arguments or associated word lists after they are
166 expanded and before they are executed. The value of the @env{PS4}
167 variable is expanded and the resultant value is printed before
168 --- bash-3.1.orig/doc/version.texi 2005-09-20 11:52:56.000000000 -0700
169 +++ bash-3.1/doc/version.texi 2006-04-19 15:58:34.000000000 -0700
171 Copyright (C) 1988-2005 Free Software Foundation, Inc.
174 -@set LASTCHANGE Mon Sep 5 11:47:04 EDT 2005
175 +@set LASTCHANGE Fri Dec 30 10:50:51 EST 2005
177 -@set EDITION 3.1-beta1
178 -@set VERSION 3.1-beta1
179 -@set UPDATED 5 September 2005
180 -@set UPDATED-MONTH September 2005
183 +@set UPDATED 30 December 2005
184 +@set UPDATED-MONTH December 2005
185 --- bash-3.1.orig/jobs.c 2005-11-11 20:13:27.000000000 -0800
186 +++ bash-3.1/jobs.c 2006-04-19 15:58:34.000000000 -0700
188 * once in the parent and once in each child. This is where
189 * the parent gives it away.
191 + * Don't give the terminal away if this shell is an asynchronous
195 - if (job_control && newjob->pgrp)
196 + if (job_control && newjob->pgrp && (subshell_environment&SUBSHELL_ASYNC) == 0)
197 give_terminal_to (newjob->pgrp, 0);
205 + int nsize, i, j, ncur, nprev;
208 + ncur = nprev = NO_JOB;
209 nsize = ((js.j_njobs + JOB_SLOTS - 1) / JOB_SLOTS);
211 i = js.j_njobs % JOB_SLOTS;
212 @@ -854,17 +858,51 @@
215 BLOCK_CHILD (set, oset);
216 - nlist = (JOB **) xmalloc (nsize * sizeof (JOB *));
217 + nlist = (js.j_jobslots == nsize) ? jobs : (JOB **) xmalloc (nsize * sizeof (JOB *));
219 for (i = j = 0; i < js.j_jobslots; i++)
221 - nlist[j++] = jobs[i];
223 + if (i == js.j_current)
225 + if (i == js.j_previous)
227 + nlist[j++] = jobs[i];
231 + itrace ("realloc_jobs_list: resize jobs list from %d to %d", js.j_jobslots, nsize);
232 + itrace ("realloc_jobs_list: j_lastj changed from %d to %d", js.j_lastj, (j > 0) ? j - 1 : 0);
233 + itrace ("realloc_jobs_list: j_njobs changed from %d to %d", js.j_njobs, (j > 0) ? j - 1 : 0);
237 - js.j_lastj = (j > 0) ? j - 1: 0;
238 + js.j_lastj = (j > 0) ? j - 1 : 0;
240 js.j_jobslots = nsize;
244 + /* Zero out remaining slots in new jobs list */
245 + for ( ; j < nsize; j++)
246 + nlist[j] = (JOB *)NULL;
254 + if (ncur != NO_JOB)
255 + js.j_current = ncur;
256 + if (nprev != NO_JOB)
257 + js.j_previous = nprev;
259 + /* Need to reset these */
260 + if (js.j_current == NO_JOB || js.j_previous == NO_JOB || js.j_current > js.j_lastj || js.j_previous > js.j_lastj)
264 + itrace ("realloc_jobs_list: reset js.j_current (%d) and js.j_previous (%d)", js.j_current, js.j_previous);
267 UNBLOCK_CHILD (oset);
269 @@ -1655,7 +1693,7 @@
270 In this case, we don't want to give the terminal to the
271 shell's process group (we could be in the middle of a
272 pipeline, for example). */
273 - if (async_p == 0 && pipeline_pgrp != shell_pgrp)
274 + if (async_p == 0 && pipeline_pgrp != shell_pgrp && ((subshell_environment&SUBSHELL_ASYNC) == 0))
275 give_terminal_to (pipeline_pgrp, 0);
277 #if defined (PGRP_PIPE)
278 @@ -2198,7 +2236,11 @@
279 /* This is possibly a race condition -- should it go in stop_pipeline? */
280 wait_sigint_received = 0;
281 if (job_control == 0)
282 - old_sigint_handler = set_signal_handler (SIGINT, wait_sigint_handler);
284 + old_sigint_handler = set_signal_handler (SIGINT, wait_sigint_handler);
285 + if (old_sigint_handler == SIG_IGN)
286 + set_signal_handler (SIGINT, old_sigint_handler);
289 termination_state = last_command_exit_value;
291 --- bash-3.1.orig/lib/glob/glob.c 2005-03-24 09:42:27.000000000 -0800
292 +++ bash-3.1/lib/glob/glob.c 2006-04-19 15:58:34.000000000 -0700
294 count = lose = skip = 0;
299 /* If PAT is empty, skip the loop, but return one (empty) filename. */
300 if (pat == 0 || *pat == '\0')
307 free (lastlink->name);
308 lastlink = lastlink->next;
310 --- bash-3.1.orig/lib/glob/sm_loop.c 2005-10-16 18:21:04.000000000 -0700
311 +++ bash-3.1/lib/glob/sm_loop.c 2006-04-19 15:58:34.000000000 -0700
312 @@ -638,12 +638,13 @@
313 CHAR *psub; /* pointer to sub-pattern */
314 CHAR *pnext; /* pointer to next sub-pattern */
315 CHAR *srest; /* pointer to rest of string */
317 + int m1, m2, xflags; /* xflags = flags passed to recursive matches */
320 fprintf(stderr, "extmatch: xc = %c\n", xc);
321 fprintf(stderr, "extmatch: s = %s; se = %s\n", s, se);
322 fprintf(stderr, "extmatch: p = %s; pe = %s\n", p, pe);
323 +fprintf(stderr, "extmatch: flags = %d\n", flags);
326 prest = PATSCAN (p + (*p == L('(')), pe, 0); /* ) */
328 string matches the rest of the pattern. Also handle
329 multiple matches of the pattern. */
331 - m2 = (GMATCH (srest, se, prest, pe, flags) == 0) ||
332 - (s != srest && GMATCH (srest, se, p - 1, pe, flags) == 0);
334 + /* if srest > s, we are not at start of string */
335 + xflags = (srest > s) ? (flags & ~FNM_PERIOD) : flags;
336 + m2 = (GMATCH (srest, se, prest, pe, xflags) == 0) ||
337 + (s != srest && GMATCH (srest, se, p - 1, pe, xflags) == 0);
343 srest = (prest == pe) ? se : s;
344 for ( ; srest <= se; srest++)
346 + /* if srest > s, we are not at start of string */
347 + xflags = (srest > s) ? (flags & ~FNM_PERIOD) : flags;
348 if (GMATCH (s, srest, psub, pnext - 1, flags) == 0 &&
349 - GMATCH (srest, se, prest, pe, flags) == 0)
350 + GMATCH (srest, se, prest, pe, xflags) == 0)
358 - if (m1 == 0 && GMATCH (srest, se, prest, pe, flags) == 0)
359 + /* if srest > s, we are not at start of string */
360 + xflags = (srest > s) ? (flags & ~FNM_PERIOD) : flags;
361 + if (m1 == 0 && GMATCH (srest, se, prest, pe, xflags) == 0)
364 return (FNM_NOMATCH);
365 --- bash-3.1.orig/lib/readline/display.c 2005-11-30 11:05:02.000000000 -0800
366 +++ bash-3.1/lib/readline/display.c 2006-04-19 15:58:34.000000000 -0700
367 @@ -1983,11 +1983,15 @@
376 - if (saved_local_prompt == 0)
377 + /* We've saved the prompt, and can do anything with the various prompt
378 + strings we need before they're restored. We want the unexpanded
379 + portion of the prompt string after any final newline. */
380 + p = rl_prompt ? strrchr (rl_prompt, '\n') : 0;
383 len = (rl_prompt && *rl_prompt) ? strlen (rl_prompt) : 0;
384 pmt = (char *)xmalloc (len + 2);
385 @@ -1998,19 +2002,17 @@
389 - len = *saved_local_prompt ? strlen (saved_local_prompt) : 0;
392 pmt = (char *)xmalloc (len + 2);
394 - strcpy (pmt, saved_local_prompt);
398 - local_prompt = savestring (pmt);
399 - prompt_last_invisible = saved_last_invisible;
400 - prompt_visible_length = saved_visible_length + 1;
404 + /* will be overwritten by expand_prompt, called from rl_message */
405 prompt_physical_chars = saved_physical_chars + 1;
410 --- bash-3.1.orig/lib/readline/readline.c 2005-07-04 19:29:35.000000000 -0700
411 +++ bash-3.1/lib/readline/readline.c 2006-04-19 15:58:34.000000000 -0700
415 rl_prompt = prompt ? savestring (prompt) : (char *)NULL;
416 + rl_display_prompt = rl_prompt ? rl_prompt : "";
418 rl_visible_prompt_length = rl_expand_prompt (rl_prompt);
420 --- bash-3.1.orig/lib/readline/terminal.c 2005-11-12 17:46:54.000000000 -0800
421 +++ bash-3.1/lib/readline/terminal.c 2006-04-19 15:58:34.000000000 -0700
423 static char *_rl_visible_bell;
425 /* Non-zero means the terminal can auto-wrap lines. */
426 -int _rl_term_autowrap;
427 +int _rl_term_autowrap = -1;
429 /* Non-zero means that this terminal has a meta key. */
430 static int term_has_meta;
432 _rl_set_screen_size (rows, cols)
435 + if (_rl_term_autowrap == -1)
436 + _rl_init_terminal_io (rl_terminal_name);
439 _rl_screenheight = rows;
441 --- bash-3.1.orig/parse.y 2005-11-11 20:14:18.000000000 -0800
442 +++ bash-3.1/parse.y 2006-04-19 15:58:34.000000000 -0700
443 @@ -2716,6 +2716,7 @@
444 #define P_ALLOWESC 0x02
445 #define P_DQUOTE 0x04
446 #define P_COMMAND 0x08 /* parsing a command, so look for comments */
447 +#define P_BACKQUOTE 0x10 /* parsing a backquoted command substitution */
449 static char matched_pair_error;
451 @@ -2725,12 +2726,12 @@
454 int count, ch, was_dollar, in_comment, check_comment;
455 - int pass_next_character, nestlen, ttranslen, start_lineno;
456 + int pass_next_character, backq_backslash, nestlen, ttranslen, start_lineno;
457 char *ret, *nestret, *ttrans;
458 int retind, retsize, rflags;
461 - pass_next_character = was_dollar = in_comment = 0;
462 + pass_next_character = backq_backslash = was_dollar = in_comment = 0;
463 check_comment = (flags & P_COMMAND) && qc != '\'' && qc != '"' && (flags & P_DQUOTE) == 0;
465 /* RFLAGS is the set of flags we want to pass to recursive calls. */
466 @@ -2742,11 +2743,8 @@
467 start_lineno = line_number;
471 - ch = shell_getc ((qc != '\'' || (flags & P_ALLOWESC)) && pass_next_character == 0);
473 - ch = shell_getc (qc != '\'' && pass_next_character == 0);
475 + ch = shell_getc (qc != '\'' && pass_next_character == 0 && backq_backslash == 0);
480 @@ -2771,9 +2769,16 @@
483 /* Not exactly right yet */
484 - else if (check_comment && in_comment == 0 && ch == '#' && (retind == 0 || ret[retind-1] == '\n' || whitespace (ret[retind -1])))
485 + else if MBTEST(check_comment && in_comment == 0 && ch == '#' && (retind == 0 || ret[retind-1] == '\n' || whitespace (ret[retind - 1])))
488 + /* last char was backslash inside backquoted command substitution */
489 + if (backq_backslash)
491 + backq_backslash = 0;
492 + /* Placeholder for adding special characters */
495 if (pass_next_character) /* last char was backslash */
497 pass_next_character = 0;
498 @@ -2814,6 +2819,8 @@
500 if MBTEST((flags & P_ALLOWESC) && ch == '\\')
501 pass_next_character++;
502 + else if MBTEST((flags & P_BACKQUOTE) && ch == '\\')
507 @@ -2898,7 +2905,11 @@
509 else if MBTEST(qc == '`' && (ch == '"' || ch == '\'') && in_comment == 0)
511 - nestret = parse_matched_pair (0, ch, ch, &nestlen, rflags);
512 + /* Add P_BACKQUOTE so backslash quotes the next character and
513 + shell_getc does the right thing with \<newline>. We do this for
514 + a measure of backwards compatibility -- it's not strictly the
515 + right POSIX thing. */
516 + nestret = parse_matched_pair (0, ch, ch, &nestlen, rflags|P_BACKQUOTE);
519 else if MBTEST(was_dollar && (ch == '(' || ch == '{' || ch == '[')) /* ) } ] */
520 @@ -2907,7 +2918,7 @@
521 if (open == ch) /* undo previous increment */
523 if (ch == '(') /* ) */
524 - nestret = parse_matched_pair (0, '(', ')', &nestlen, rflags);
525 + nestret = parse_matched_pair (0, '(', ')', &nestlen, rflags & ~P_DQUOTE);
526 else if (ch == '{') /* } */
527 nestret = parse_matched_pair (0, '{', '}', &nestlen, P_FIRSTCLOSE|rflags);
528 else if (ch == '[') /* ] */
529 @@ -3578,7 +3589,7 @@
532 compound_assignment = 1;
537 goto got_token; /* ksh93 seems to do this */
538 @@ -3695,7 +3706,9 @@
540 b = builtin_address_internal (token, 0);
541 if (b && (b->flags & ASSIGNMENT_BUILTIN))
542 - parser_state |= PST_ASSIGNOK;
543 + parser_state |= PST_ASSIGNOK;
544 + else if (STREQ (token, "eval") || STREQ (token, "let"))
545 + parser_state |= PST_ASSIGNOK;
548 yylval.word = the_word;
549 @@ -4686,18 +4699,21 @@
553 - int tok, orig_line_number, orig_token_size;
554 + int tok, orig_line_number, orig_token_size, orig_last_token, assignok;
555 char *saved_token, *ret;
558 orig_token_size = token_buffer_size;
559 orig_line_number = line_number;
560 + orig_last_token = last_read_token;
562 last_read_token = WORD; /* WORD to allow reserved words here */
564 token = (char *)NULL;
565 token_buffer_size = 0;
567 + assignok = parser_state&PST_ASSIGNOK; /* XXX */
569 wl = (WORD_LIST *)NULL; /* ( */
570 parser_state |= PST_COMPASSIGN;
572 @@ -4740,7 +4756,7 @@
573 jump_to_top_level (DISCARD);
576 - last_read_token = WORD;
577 + last_read_token = orig_last_token; /* XXX - was WORD? */
580 rl = REVERSE_LIST (wl, WORD_LIST *);
581 @@ -4752,6 +4768,10 @@
584 *retlenp = (ret && *ret) ? strlen (ret) : 0;
587 + parser_state |= PST_ASSIGNOK;
592 --- bash-3.1.orig/patchlevel.h 2005-07-20 10:58:20.000000000 -0700
593 +++ bash-3.1/patchlevel.h 2006-04-19 15:59:29.000000000 -0700
595 regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
596 looks for to find the patch level (for the sccs version string). */
598 -#define PATCHLEVEL 0
599 +#define PATCHLEVEL 17
601 #endif /* _PATCHLEVEL_H_ */
602 --- bash-3.1.orig/subst.c 2005-10-24 06:51:13.000000000 -0700
603 +++ bash-3.1/subst.c 2006-04-19 15:59:29.000000000 -0700
604 @@ -2187,7 +2187,7 @@
605 if (mklocal && variable_context)
607 v = find_variable (name);
608 - if (v == 0 || array_p (v) == 0)
609 + if (v == 0 || array_p (v) == 0 || v->context != variable_context)
610 v = make_local_array_variable (name);
611 v = assign_array_var_from_string (v, value, flags);
613 @@ -2575,6 +2575,13 @@
614 return (expand_string_to_string_internal (string, quoted, expand_string_assignment));
618 +expand_arith_string (string, quoted)
621 + return (expand_string_if_necessary (string, quoted, expand_string));
624 #if defined (COND_COMMAND)
625 /* Just remove backslashes in STRING. Returns a new string. */
627 @@ -5248,7 +5255,7 @@
631 - temp1 = expand_string_if_necessary (substr, Q_DOUBLE_QUOTES, expand_string);
632 + temp1 = expand_arith_string (substr, Q_DOUBLE_QUOTES);
633 *e1p = evalexp (temp1, &expok);
636 @@ -5293,7 +5300,7 @@
639 temp2 = savestring (t);
640 - temp1 = expand_string_if_necessary (temp2, Q_DOUBLE_QUOTES, expand_string);
641 + temp1 = expand_arith_string (temp2, Q_DOUBLE_QUOTES);
644 *e2p = evalexp (temp1, &expok);
645 @@ -6435,7 +6442,7 @@
646 temp2[t_index] = '\0';
648 /* Expand variables found inside the expression. */
649 - temp1 = expand_string_if_necessary (temp2, Q_DOUBLE_QUOTES, expand_string);
650 + temp1 = expand_arith_string (temp2, Q_DOUBLE_QUOTES);
654 @@ -6477,7 +6484,7 @@
657 /* Do initial variable expansion. */
658 - temp1 = expand_string_if_necessary (temp, Q_DOUBLE_QUOTES, expand_string);
659 + temp1 = expand_arith_string (temp, Q_DOUBLE_QUOTES);
663 @@ -6795,6 +6802,12 @@
664 if (temp && *temp && t_index > 0)
666 temp1 = bash_tilde_expand (temp, tflag);
667 + if (temp1 && *temp1 == '~' && STREQ (temp, temp1))
671 + goto add_character; /* tilde expansion failed */
676 --- bash-3.1.orig/subst.h 2004-11-07 12:12:28.000000000 -0800
677 +++ bash-3.1/subst.h 2006-04-19 15:59:29.000000000 -0700
679 extern char *expand_string_unsplit_to_string __P((char *, int));
680 extern char *expand_assignment_string_to_string __P((char *, int));
682 +/* Expand an arithmetic expression string */
683 +extern char *expand_arith_string __P((char *, int));
685 /* De-quoted quoted characters in STRING. */
686 extern char *dequote_string __P((char *));
688 --- bash-3.1.orig/variables.c 2005-11-12 18:22:37.000000000 -0800
689 +++ bash-3.1/variables.c 2006-04-19 15:58:34.000000000 -0700
692 char val[INT_STRLEN_BOUND(int) + 1], *v;
694 +#if defined (READLINE)
695 /* If we are currently assigning to LINES or COLUMNS, don't do anything. */
696 if (winsize_assignment)
700 v = inttostr (lines, val, sizeof (val));
701 bind_variable ("LINES", v, 0);