Submitted By: Jim Gifford (patches at jg555 dot com)
Date: 2006-02-06
Initial Package Version: 3.1
Origin: Upstream
Upstream Status: Applied 
Description: Contains Patch 001-007 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 15:40:52.000000000 +0000
+++ bash-3.1/doc/bash.1	2006-02-06 22:17:06.000000000 +0000
@@ -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 19:07:21.000000000 +0000
+++ bash-3.1/doc/bashref.texi	2006-02-06 22:17:06.000000000 +0000
@@ -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 18:52:56.000000000 +0000
+++ bash-3.1/doc/version.texi	2006-02-06 22:17:06.000000000 +0000
@@ -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-12 04:13:27.000000000 +0000
+++ bash-3.1/jobs.c	2006-02-06 22:19:37.000000000 +0000
@@ -844,9 +844,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 +855,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);
 }
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-13 01:46:54.000000000 +0000
+++ bash-3.1/lib/readline/terminal.c	2006-02-06 22:18:58.000000000 +0000
@@ -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-12 04:14:18.000000000 +0000
+++ bash-3.1/parse.y	2006-02-06 22:15:02.000000000 +0000
@@ -3695,7 +3695,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 +4688,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 +4745,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 +4757,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 17:58:20.000000000 +0000
+++ bash-3.1/patchlevel.h	2006-02-06 22:19:37.000000000 +0000
@@ -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 7
 
 #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 13:51:13.000000000 +0000
+++ bash-3.1/subst.c	2006-02-06 22:18:34.000000000 +0000
@@ -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-13 02:22:37.000000000 +0000
+++ bash-3.1/variables.c	2006-02-06 22:17:37.000000000 +0000
@@ -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);
