Submitted By: Jeremy Huntwork (jhuntwork at linuxfromscratch dot org) Date: 2006-04-11 Initial Package Version: 3.1 Origin: http://ftp.gnu.org/gnu/bash/bash-3.1-patches/ Upstream Status: From Upstream Description: Contains patches 001-016 from upstream diff -Naur bash-3.1.orig/doc/bash.1 bash-3.1/doc/bash.1 --- bash-3.1.orig/doc/bash.1 2005-10-12 11:40:52.000000000 -0400 +++ bash-3.1/doc/bash.1 2006-04-11 11:36:54.702393214 -0400 @@ -6,12 +6,12 @@ .\" Case Western Reserve University .\" chet@po.cwru.edu .\" -.\" Last Change: Sat Aug 27 13:28:44 EDT 2005 +.\" Last Change: Wed Dec 28 19:58:45 EST 2005 .\" .\" bash_builtins, strip all but Built-Ins section .if \n(zZ=1 .ig zZ .if \n(zY=1 .ig zY -.TH BASH 1 "2005 Aug 27" "GNU Bash-3.1-beta1" +.TH BASH 1 "2005 Dec 28" "GNU Bash-3.1" .\" .\" There's some problem with having a `@' .\" in a tagged paragraph with the BSD man macros. @@ -677,8 +677,8 @@ .B nocasematch is enabled, the match is performed without regard to the case of alphabetic characters. -The return value is 0 if the string matches or does not match -the pattern, respectively, and 1 otherwise. +The return value is 0 if the string matches (\fB==\fP) or does not match +(\fB!=\fP) the pattern, and 1 otherwise. Any part of the pattern may be quoted to force it to be matched as a string. .if t .sp 0.5 @@ -807,6 +807,12 @@ as for pathname expansion (see .B Pathname Expansion below). +The \fIword\fP is expanded using tilde +expansion, parameter and variable expansion, arithmetic substituion, +command substitution, process substitution and quote removal. +Each \fIpattern\fP examined is expanded using tilde +expansion, parameter and variable expansion, arithmetic substituion, +command substitution, and process substitution. If the shell option .B nocasematch is enabled, the match is performed without regard to the case @@ -8484,7 +8490,7 @@ returns true if any of the arguments are found, false if none are found. .TP -\fBulimit\fP [\fB\-SHacdflmnpstuv\fP [\fIlimit\fP]] +\fBulimit\fP [\fB\-SHacdfilmnpqstuvx\fP [\fIlimit\fP]] Provides control over the resources available to the shell and to processes started by it, on systems that allow such control. The \fB\-H\fP and \fB\-S\fP options specify that the hard or soft limit is @@ -8523,6 +8529,9 @@ .B \-f The maximum size of files created by the shell .TP +.B \-i +The maximum number of pending signals +.TP .B \-l The maximum size that may be locked into memory .TP @@ -8536,6 +8545,9 @@ .B \-p The pipe size in 512-byte blocks (this may not be set) .TP +.B \-q +The maximum number of bytes in POSIX message queues +.TP .B \-s The maximum stack size .TP @@ -8547,6 +8559,9 @@ .TP .B \-v The maximum amount of virtual memory available to the shell +.TP +.B \-x +The maximum number of file locks .PD .PP If diff -Naur bash-3.1.orig/doc/bashref.texi bash-3.1/doc/bashref.texi --- bash-3.1.orig/doc/bashref.texi 2005-10-03 15:07:21.000000000 -0400 +++ bash-3.1/doc/bashref.texi 2006-04-11 11:36:54.709392515 -0400 @@ -961,8 +961,8 @@ (see the description of @code{shopt} in @ref{Bash Builtins}) is enabled, the match is performed without regard to the case of alphabetic characters. -The return value is 0 if the string matches or does not match -the pattern, respectively, and 1 otherwise. +The return value is 0 if the string matches (@samp{==}) or does not +match (@samp{!=})the pattern, and 1 otherwise. Any part of the pattern may be quoted to force it to be matched as a string. @@ -2598,7 +2598,7 @@ Builtin commands are necessary to implement functionality impossible or inconvenient to obtain with separate utilities. -This section briefly the builtins which Bash inherits from +This section briefly describes the builtins which Bash inherits from the Bourne Shell, as well as the builtin commands which are unique to or have been extended in Bash. @@ -3833,7 +3833,7 @@ @item ulimit @btindex ulimit @example -ulimit [-acdflmnpstuvSH] [@var{limit}] +ulimit [-acdfilmnpqstuvxSH] [@var{limit}] @end example @code{ulimit} provides control over the resources available to processes started by the shell, on systems that allow such control. If an @@ -3857,6 +3857,9 @@ @item -f The maximum size of files created by the shell. +@item -i +The maximum number of pending signals. + @item -l The maximum size that may be locked into memory. @@ -3869,6 +3872,9 @@ @item -p The pipe buffer size. +@item -q +The maximum number of bytes in POSIX message queues. + @item -s The maximum stack size. @@ -3881,6 +3887,9 @@ @item -v The maximum amount of virtual memory available to the process. +@item -x +The maximum number of file locks. + @end table If @var{limit} is given, it is the new value of the specified resource; @@ -4089,8 +4098,8 @@ Print shell input lines as they are read. @item -x -Print a trace of simple commands, \fBfor\fP commands, \fBcase\fP -commands, \fBselect\fP commands, and arithmetic \fBfor\fP commands +Print a trace of simple commands, @code{for} commands, @code{case} +commands, @code{select} commands, and arithmetic @code{for} commands and their arguments or associated word lists after they are expanded and before they are executed. The value of the @env{PS4} variable is expanded and the resultant value is printed before diff -Naur bash-3.1.orig/doc/version.texi bash-3.1/doc/version.texi --- bash-3.1.orig/doc/version.texi 2005-09-20 14:52:56.000000000 -0400 +++ bash-3.1/doc/version.texi 2006-04-11 11:36:54.710392415 -0400 @@ -2,9 +2,9 @@ Copyright (C) 1988-2005 Free Software Foundation, Inc. @end ignore -@set LASTCHANGE Mon Sep 5 11:47:04 EDT 2005 +@set LASTCHANGE Fri Dec 30 10:50:51 EST 2005 -@set EDITION 3.1-beta1 -@set VERSION 3.1-beta1 -@set UPDATED 5 September 2005 -@set UPDATED-MONTH September 2005 +@set EDITION 3.1 +@set VERSION 3.1 +@set UPDATED 30 December 2005 +@set UPDATED-MONTH December 2005 diff -Naur bash-3.1.orig/jobs.c bash-3.1/jobs.c --- bash-3.1.orig/jobs.c 2005-11-11 23:13:27.000000000 -0500 +++ bash-3.1/jobs.c 2006-04-11 11:36:54.713392115 -0400 @@ -619,8 +619,11 @@ * once in the parent and once in each child. This is where * the parent gives it away. * + * Don't give the terminal away if this shell is an asynchronous + * subshell. + * */ - if (job_control && newjob->pgrp) + if (job_control && newjob->pgrp && (subshell_environment&SUBSHELL_ASYNC) == 0) give_terminal_to (newjob->pgrp, 0); } } @@ -844,9 +847,10 @@ realloc_jobs_list () { sigset_t set, oset; - int nsize, i, j; + int nsize, i, j, ncur, nprev; JOB **nlist; + ncur = nprev = NO_JOB; nsize = ((js.j_njobs + JOB_SLOTS - 1) / JOB_SLOTS); nsize *= JOB_SLOTS; i = js.j_njobs % JOB_SLOTS; @@ -854,17 +858,51 @@ nsize += JOB_SLOTS; BLOCK_CHILD (set, oset); - nlist = (JOB **) xmalloc (nsize * sizeof (JOB *)); + nlist = (js.j_jobslots == nsize) ? jobs : (JOB **) xmalloc (nsize * sizeof (JOB *)); + for (i = j = 0; i < js.j_jobslots; i++) if (jobs[i]) - nlist[j++] = jobs[i]; + { + if (i == js.j_current) + ncur = j; + if (i == js.j_previous) + nprev = j; + nlist[j++] = jobs[i]; + } + +#if defined (DEBUG) + itrace ("realloc_jobs_list: resize jobs list from %d to %d", js.j_jobslots, nsize); + itrace ("realloc_jobs_list: j_lastj changed from %d to %d", js.j_lastj, (j > 0) ? j - 1 : 0); + itrace ("realloc_jobs_list: j_njobs changed from %d to %d", js.j_njobs, (j > 0) ? j - 1 : 0); +#endif js.j_firstj = 0; - js.j_lastj = (j > 0) ? j - 1: 0; + js.j_lastj = (j > 0) ? j - 1 : 0; + js.j_njobs = j; js.j_jobslots = nsize; - free (jobs); - jobs = nlist; + /* Zero out remaining slots in new jobs list */ + for ( ; j < nsize; j++) + nlist[j] = (JOB *)NULL; + + if (jobs != nlist) + { + free (jobs); + jobs = nlist; + } + + if (ncur != NO_JOB) + js.j_current = ncur; + if (nprev != NO_JOB) + js.j_previous = nprev; + + /* Need to reset these */ + if (js.j_current == NO_JOB || js.j_previous == NO_JOB || js.j_current > js.j_lastj || js.j_previous > js.j_lastj) + reset_current (); + +#ifdef DEBUG + itrace ("realloc_jobs_list: reset js.j_current (%d) and js.j_previous (%d)", js.j_current, js.j_previous); +#endif UNBLOCK_CHILD (oset); } @@ -1655,7 +1693,7 @@ In this case, we don't want to give the terminal to the shell's process group (we could be in the middle of a pipeline, for example). */ - if (async_p == 0 && pipeline_pgrp != shell_pgrp) + if (async_p == 0 && pipeline_pgrp != shell_pgrp && ((subshell_environment&SUBSHELL_ASYNC) == 0)) give_terminal_to (pipeline_pgrp, 0); #if defined (PGRP_PIPE) @@ -2198,7 +2236,11 @@ /* This is possibly a race condition -- should it go in stop_pipeline? */ wait_sigint_received = 0; if (job_control == 0) - old_sigint_handler = set_signal_handler (SIGINT, wait_sigint_handler); + { + old_sigint_handler = set_signal_handler (SIGINT, wait_sigint_handler); + if (old_sigint_handler == SIG_IGN) + set_signal_handler (SIGINT, old_sigint_handler); + } termination_state = last_command_exit_value; diff -Naur bash-3.1.orig/lib/glob/glob.c bash-3.1/lib/glob/glob.c --- bash-3.1.orig/lib/glob/glob.c 2005-03-24 12:42:27.000000000 -0500 +++ bash-3.1/lib/glob/glob.c 2006-04-11 11:37:12.868577740 -0400 @@ -360,6 +360,7 @@ count = lose = skip = 0; firstmalloc = 0; + nalloca = 0; /* If PAT is empty, skip the loop, but return one (empty) filename. */ if (pat == 0 || *pat == '\0') @@ -546,6 +547,8 @@ firstmalloc = 0; tmplink = lastlink; } + else + tmplink = 0; free (lastlink->name); lastlink = lastlink->next; FREE (tmplink); diff -Naur bash-3.1.orig/lib/glob/sm_loop.c bash-3.1/lib/glob/sm_loop.c --- bash-3.1.orig/lib/glob/sm_loop.c 2005-10-16 21:21:04.000000000 -0400 +++ bash-3.1/lib/glob/sm_loop.c 2006-04-11 11:37:09.500914295 -0400 @@ -638,12 +638,13 @@ CHAR *psub; /* pointer to sub-pattern */ CHAR *pnext; /* pointer to next sub-pattern */ CHAR *srest; /* pointer to rest of string */ - int m1, m2; + int m1, m2, xflags; /* xflags = flags passed to recursive matches */ #if DEBUG_MATCHING fprintf(stderr, "extmatch: xc = %c\n", xc); fprintf(stderr, "extmatch: s = %s; se = %s\n", s, se); fprintf(stderr, "extmatch: p = %s; pe = %s\n", p, pe); +fprintf(stderr, "extmatch: flags = %d\n", flags); #endif prest = PATSCAN (p + (*p == L('(')), pe, 0); /* ) */ @@ -677,8 +678,12 @@ string matches the rest of the pattern. Also handle multiple matches of the pattern. */ if (m1) - m2 = (GMATCH (srest, se, prest, pe, flags) == 0) || - (s != srest && GMATCH (srest, se, p - 1, pe, flags) == 0); + { + /* if srest > s, we are not at start of string */ + xflags = (srest > s) ? (flags & ~FNM_PERIOD) : flags; + m2 = (GMATCH (srest, se, prest, pe, xflags) == 0) || + (s != srest && GMATCH (srest, se, p - 1, pe, xflags) == 0); + } if (m1 && m2) return (0); } @@ -704,8 +709,10 @@ srest = (prest == pe) ? se : s; for ( ; srest <= se; srest++) { + /* if srest > s, we are not at start of string */ + xflags = (srest > s) ? (flags & ~FNM_PERIOD) : flags; if (GMATCH (s, srest, psub, pnext - 1, flags) == 0 && - GMATCH (srest, se, prest, pe, flags) == 0) + GMATCH (srest, se, prest, pe, xflags) == 0) return (0); } if (pnext == prest) @@ -726,7 +733,9 @@ if (pnext == prest) break; } - if (m1 == 0 && GMATCH (srest, se, prest, pe, flags) == 0) + /* if srest > s, we are not at start of string */ + xflags = (srest > s) ? (flags & ~FNM_PERIOD) : flags; + if (m1 == 0 && GMATCH (srest, se, prest, pe, xflags) == 0) return (0); } return (FNM_NOMATCH); diff -Naur bash-3.1.orig/lib/readline/display.c bash-3.1/lib/readline/display.c --- bash-3.1.orig/lib/readline/display.c 2005-11-30 14:05:02.000000000 -0500 +++ bash-3.1/lib/readline/display.c 2006-04-11 11:36:54.716391815 -0400 @@ -1983,11 +1983,15 @@ int pchar; { int len; - char *pmt; + char *pmt, *p; rl_save_prompt (); - if (saved_local_prompt == 0) + /* We've saved the prompt, and can do anything with the various prompt + strings we need before they're restored. We want the unexpanded + portion of the prompt string after any final newline. */ + p = rl_prompt ? strrchr (rl_prompt, '\n') : 0; + if (p == 0) { len = (rl_prompt && *rl_prompt) ? strlen (rl_prompt) : 0; pmt = (char *)xmalloc (len + 2); @@ -1998,19 +2002,17 @@ } else { - len = *saved_local_prompt ? strlen (saved_local_prompt) : 0; + p++; + len = strlen (p); pmt = (char *)xmalloc (len + 2); if (len) - strcpy (pmt, saved_local_prompt); + strcpy (pmt, p); pmt[len] = pchar; pmt[len+1] = '\0'; - local_prompt = savestring (pmt); - prompt_last_invisible = saved_last_invisible; - prompt_visible_length = saved_visible_length + 1; - } + } + /* will be overwritten by expand_prompt, called from rl_message */ prompt_physical_chars = saved_physical_chars + 1; - return pmt; } diff -Naur bash-3.1.orig/lib/readline/readline.c bash-3.1/lib/readline/readline.c --- bash-3.1.orig/lib/readline/readline.c 2005-07-04 22:29:35.000000000 -0400 +++ bash-3.1/lib/readline/readline.c 2006-04-11 11:36:54.717391715 -0400 @@ -282,6 +282,7 @@ { FREE (rl_prompt); rl_prompt = prompt ? savestring (prompt) : (char *)NULL; + rl_display_prompt = rl_prompt ? rl_prompt : ""; rl_visible_prompt_length = rl_expand_prompt (rl_prompt); return 0; diff -Naur bash-3.1.orig/lib/readline/terminal.c bash-3.1/lib/readline/terminal.c --- bash-3.1.orig/lib/readline/terminal.c 2005-11-12 20:46:54.000000000 -0500 +++ bash-3.1/lib/readline/terminal.c 2006-04-11 11:36:54.718391615 -0400 @@ -122,7 +122,7 @@ static char *_rl_visible_bell; /* Non-zero means the terminal can auto-wrap lines. */ -int _rl_term_autowrap; +int _rl_term_autowrap = -1; /* Non-zero means that this terminal has a meta key. */ static int term_has_meta; @@ -274,6 +274,9 @@ _rl_set_screen_size (rows, cols) int rows, cols; { + if (_rl_term_autowrap == -1) + _rl_init_terminal_io (rl_terminal_name); + if (rows > 0) _rl_screenheight = rows; if (cols > 0) diff -Naur bash-3.1.orig/parse.y bash-3.1/parse.y --- bash-3.1.orig/parse.y 2005-11-11 23:14:18.000000000 -0500 +++ bash-3.1/parse.y 2006-04-11 11:36:54.722391216 -0400 @@ -2716,6 +2716,7 @@ #define P_ALLOWESC 0x02 #define P_DQUOTE 0x04 #define P_COMMAND 0x08 /* parsing a command, so look for comments */ +#define P_BACKQUOTE 0x10 /* parsing a backquoted command substitution */ static char matched_pair_error; static char * @@ -2725,12 +2726,12 @@ int *lenp, flags; { int count, ch, was_dollar, in_comment, check_comment; - int pass_next_character, nestlen, ttranslen, start_lineno; + int pass_next_character, backq_backslash, nestlen, ttranslen, start_lineno; char *ret, *nestret, *ttrans; int retind, retsize, rflags; count = 1; - pass_next_character = was_dollar = in_comment = 0; + pass_next_character = backq_backslash = was_dollar = in_comment = 0; check_comment = (flags & P_COMMAND) && qc != '\'' && qc != '"' && (flags & P_DQUOTE) == 0; /* RFLAGS is the set of flags we want to pass to recursive calls. */ @@ -2742,11 +2743,8 @@ start_lineno = line_number; while (count) { -#if 0 - ch = shell_getc ((qc != '\'' || (flags & P_ALLOWESC)) && pass_next_character == 0); -#else - ch = shell_getc (qc != '\'' && pass_next_character == 0); -#endif + ch = shell_getc (qc != '\'' && pass_next_character == 0 && backq_backslash == 0); + if (ch == EOF) { free (ret); @@ -2771,9 +2769,16 @@ continue; } /* Not exactly right yet */ - else if (check_comment && in_comment == 0 && ch == '#' && (retind == 0 || ret[retind-1] == '\n' || whitespace (ret[retind -1]))) + else if MBTEST(check_comment && in_comment == 0 && ch == '#' && (retind == 0 || ret[retind-1] == '\n' || whitespace (ret[retind - 1]))) in_comment = 1; + /* last char was backslash inside backquoted command substitution */ + if (backq_backslash) + { + backq_backslash = 0; + /* Placeholder for adding special characters */ + } + if (pass_next_character) /* last char was backslash */ { pass_next_character = 0; @@ -2814,6 +2819,8 @@ { if MBTEST((flags & P_ALLOWESC) && ch == '\\') pass_next_character++; + else if MBTEST((flags & P_BACKQUOTE) && ch == '\\') + backq_backslash++; continue; } @@ -2898,7 +2905,11 @@ } else if MBTEST(qc == '`' && (ch == '"' || ch == '\'') && in_comment == 0) { - nestret = parse_matched_pair (0, ch, ch, &nestlen, rflags); + /* Add P_BACKQUOTE so backslash quotes the next character and + shell_getc does the right thing with \. We do this for + a measure of backwards compatibility -- it's not strictly the + right POSIX thing. */ + nestret = parse_matched_pair (0, ch, ch, &nestlen, rflags|P_BACKQUOTE); goto add_nestret; } else if MBTEST(was_dollar && (ch == '(' || ch == '{' || ch == '[')) /* ) } ] */ @@ -2907,7 +2918,7 @@ if (open == ch) /* undo previous increment */ count--; if (ch == '(') /* ) */ - nestret = parse_matched_pair (0, '(', ')', &nestlen, rflags); + nestret = parse_matched_pair (0, '(', ')', &nestlen, rflags & ~P_DQUOTE); else if (ch == '{') /* } */ nestret = parse_matched_pair (0, '{', '}', &nestlen, P_FIRSTCLOSE|rflags); else if (ch == '[') /* ] */ @@ -3578,7 +3589,7 @@ FREE (ttok); all_digit_token = 0; compound_assignment = 1; -#if 0 +#if 1 goto next_character; #else goto got_token; /* ksh93 seems to do this */ @@ -3695,7 +3706,9 @@ struct builtin *b; b = builtin_address_internal (token, 0); if (b && (b->flags & ASSIGNMENT_BUILTIN)) - parser_state |= PST_ASSIGNOK; + parser_state |= PST_ASSIGNOK; + else if (STREQ (token, "eval") || STREQ (token, "let")) + parser_state |= PST_ASSIGNOK; } yylval.word = the_word; @@ -4686,18 +4699,21 @@ int *retlenp; { WORD_LIST *wl, *rl; - int tok, orig_line_number, orig_token_size; + int tok, orig_line_number, orig_token_size, orig_last_token, assignok; char *saved_token, *ret; saved_token = token; orig_token_size = token_buffer_size; orig_line_number = line_number; + orig_last_token = last_read_token; last_read_token = WORD; /* WORD to allow reserved words here */ token = (char *)NULL; token_buffer_size = 0; + assignok = parser_state&PST_ASSIGNOK; /* XXX */ + wl = (WORD_LIST *)NULL; /* ( */ parser_state |= PST_COMPASSIGN; @@ -4740,7 +4756,7 @@ jump_to_top_level (DISCARD); } - last_read_token = WORD; + last_read_token = orig_last_token; /* XXX - was WORD? */ if (wl) { rl = REVERSE_LIST (wl, WORD_LIST *); @@ -4752,6 +4768,10 @@ if (retlenp) *retlenp = (ret && *ret) ? strlen (ret) : 0; + + if (assignok) + parser_state |= PST_ASSIGNOK; + return ret; } diff -Naur bash-3.1.orig/patchlevel.h bash-3.1/patchlevel.h --- bash-3.1.orig/patchlevel.h 2005-07-20 13:58:20.000000000 -0400 +++ bash-3.1/patchlevel.h 2006-04-11 11:37:12.869577641 -0400 @@ -25,6 +25,6 @@ regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh looks for to find the patch level (for the sccs version string). */ -#define PATCHLEVEL 0 +#define PATCHLEVEL 16 #endif /* _PATCHLEVEL_H_ */ diff -Naur bash-3.1.orig/subst.c bash-3.1/subst.c --- bash-3.1.orig/subst.c 2005-10-24 09:51:13.000000000 -0400 +++ bash-3.1/subst.c 2006-04-11 11:36:54.727390716 -0400 @@ -2187,7 +2187,7 @@ if (mklocal && variable_context) { v = find_variable (name); - if (v == 0 || array_p (v) == 0) + if (v == 0 || array_p (v) == 0 || v->context != variable_context) v = make_local_array_variable (name); v = assign_array_var_from_string (v, value, flags); } @@ -6795,6 +6795,12 @@ if (temp && *temp && t_index > 0) { temp1 = bash_tilde_expand (temp, tflag); + if (temp1 && *temp1 == '~' && STREQ (temp, temp1)) + { + FREE (temp); + FREE (temp1); + goto add_character; /* tilde expansion failed */ + } free (temp); temp = temp1; sindex += t_index; diff -Naur bash-3.1.orig/variables.c bash-3.1/variables.c --- bash-3.1.orig/variables.c 2005-11-12 21:22:37.000000000 -0500 +++ bash-3.1/variables.c 2006-04-11 11:36:54.731390316 -0400 @@ -860,9 +860,11 @@ { char val[INT_STRLEN_BOUND(int) + 1], *v; +#if defined (READLINE) /* If we are currently assigning to LINES or COLUMNS, don't do anything. */ if (winsize_assignment) return; +#endif v = inttostr (lines, val, sizeof (val)); bind_variable ("LINES", v, 0);