]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
commit bash-20060202 snapshot
authorChet Ramey <chet.ramey@case.edu>
Sun, 4 Dec 2011 03:44:49 +0000 (22:44 -0500)
committerChet Ramey <chet.ramey@case.edu>
Sun, 4 Dec 2011 03:44:49 +0000 (22:44 -0500)
12 files changed:
CWRU/CWRU.chlog
CWRU/CWRU.chlog~
autom4te.cache/requests
bashline.c
jobs.c
jobs.c.diff [new file with mode: 0644]
lib/readline/display.c
lib/readline/display.c~
lib/readline/terminal.c
parse.y.diff [new file with mode: 0644]
terminal.c.diff [new file with mode: 0644]
tests/RUN-ONE-TEST

index d18cd1774faf2dbb6134adec4ed08fdaec6d17f9..f3fcc0f8a050a99f9330004f06be9f1ece4eda3d 100644 (file)
@@ -13015,3 +13015,34 @@ braces.c
        - make change from 1/28 dependant on CSH_BRACE_COMPAT not being
          defined (since old bash behavior is what csh does, defining
          CSH_BRACE_COMPAT will produce old bash behavior)
+
+                                  1/30
+                                  ----
+bashline.c
+       - last argument of bash_default_completion is now a flags word:
+         DEFCOMP_CMDPOS (in command position) is only current value
+       - attempt_shell_completion now computes flags before calling
+         bash_default_completion
+       - if no_empty_command_completion is set, bash does not attempt command
+         word completion even if not at the beginning of the line, as long
+         as the word to be completed is empty and start == end (catches
+         beginning of line and all whitespace preceding point)
+
+                                   2/4
+                                   ---
+lib/readline/display.c
+       - change _rl_make_prompt_for_search to use rl_prompt and append the
+         search character to it, so the call to expand_prompt in rl_message
+         will process the non-printing characters correctly.  Bug reported
+         by Mike Stroyan <mike.stroyan@hp.com>
+
+                                   2/5
+                                   ---
+lib/readline/display.c
+       - fix off-by-one error when comparing against PROMPT_ENDING_INDEX,
+         which caused a prompt with invisible characters to be redrawn one
+         extra time in a multibyte locale.  Change from <= to < fixes
+         multibyte locale, but I added 1 to single-byte definition of
+         PROMPT_ENDING_INDEX (worth checking) to compensate.  Bug reported
+         by Egmont Koblinger <egmont@uhulinux.hu>
+
index db0f9b03c849ede9aeb20547fb93ec82902c8e68..6c73f3ddebb44a5c5cbdea153358a902fa52f590 100644 (file)
@@ -13014,4 +13014,33 @@ test.[ch]
 braces.c
        - make change from 1/28 dependant on CSH_BRACE_COMPAT not being
          defined (since old bash behavior is what csh does, defining
-         CSH_BRACE_COMPAT produces old bash behavior)
+         CSH_BRACE_COMPAT will produce old bash behavior)
+
+                                  1/30
+                                  ----
+bashline.c
+       - last argument of bash_default_completion is now a flags word:
+         DEFCOMP_CMDPOS (in command position) is only current value
+       - attempt_shell_completion now computes flags before calling
+         bash_default_completion
+       - if no_empty_command_completion is set, bash does not attempt command
+         word completion even if not at the beginning of the line, as long
+         as the word to be completed is empty and start == end (catches
+         beginning of line and all whitespace preceding point)
+
+                                   2/4
+                                   ---
+lib/readline/display.c
+       - change _rl_make_prompt_for_search to use rl_prompt and append the
+         search character to it, so the call to expand_prompt in rl_message
+         will process the non-printing characters correctly.  Bug reported
+         by Mike Stroyan <mike.stroyan@hp.com>
+
+                                   2/5
+                                   ---
+lib/readline/display.c
+       - fix off-by-one error when comparing against PROMPT_ENDING_INDEX,
+         which caused a prompt with invisible characters to be redrawn one
+         extra time in a multibyte locale.  Change from <= to < fixes
+         multibyte locale, but I added 1 to single-byte definition of
+         PROMPT_ENDING_INDEX (worth checking) to compensate
index baa7f90df4a5f72ac75d0295aabb043a16b88b7a..84e4075e3c65875aa1f7dcc2ad2003258d75c6bc 100644 (file)
                       {
                         'm4_pattern_forbid' => 1,
                         'AC_CONFIG_LIBOBJ_DIR' => 1,
-                        'AC_TYPE_OFF_T' => 1,
                         'AC_C_VOLATILE' => 1,
+                        'AC_TYPE_OFF_T' => 1,
                         'AC_FUNC_CLOSEDIR_VOID' => 1,
                         'AC_REPLACE_FNMATCH' => 1,
                         'AC_PROG_LIBTOOL' => 1,
                         'AC_FUNC_STAT' => 1,
-                        'AC_FUNC_WAIT3' => 1,
                         'AC_HEADER_TIME' => 1,
-                        'AM_AUTOMAKE_VERSION' => 1,
-                        'AC_STRUCT_TM' => 1,
+                        'AC_FUNC_WAIT3' => 1,
                         'AC_FUNC_LSTAT' => 1,
-                        'AC_FUNC_GETMNTENT' => 1,
+                        'AC_STRUCT_TM' => 1,
+                        'AM_AUTOMAKE_VERSION' => 1,
                         'AC_TYPE_MODE_T' => 1,
+                        'AC_FUNC_GETMNTENT' => 1,
                         'AC_FUNC_STRTOD' => 1,
                         'AC_CHECK_HEADERS' => 1,
                         'AC_FUNC_STRNLEN' => 1,
                         'AC_STRUCT_ST_BLOCKS' => 1,
                         'AC_TYPE_SIGNAL' => 1,
                         'AC_TYPE_UID_T' => 1,
-                        'AC_PROG_MAKE_SET' => 1,
                         'AC_CONFIG_AUX_DIR' => 1,
-                        'm4_pattern_allow' => 1,
+                        'AC_PROG_MAKE_SET' => 1,
                         'sinclude' => 1,
+                        'm4_pattern_allow' => 1,
                         'AC_DEFINE_TRACE_LITERAL' => 1,
                         'AC_FUNC_STRERROR_R' => 1,
                         'AC_PROG_CC' => 1,
-                        'AC_DECL_SYS_SIGLIST' => 1,
                         'AC_FUNC_FORK' => 1,
-                        'AC_FUNC_STRCOLL' => 1,
+                        'AC_DECL_SYS_SIGLIST' => 1,
                         'AC_FUNC_VPRINTF' => 1,
+                        'AC_FUNC_STRCOLL' => 1,
                         'AC_PROG_YACC' => 1,
                         'AC_INIT' => 1,
                         'AC_STRUCT_TIMEZONE' => 1,
                         'AM_MAINTAINER_MODE' => 1,
                         'AC_FUNC_UTIME_NULL' => 1,
                         'AC_FUNC_SELECT_ARGTYPES' => 1,
-                        'AC_HEADER_STAT' => 1,
                         'AC_FUNC_STRFTIME' => 1,
-                        'AC_C_INLINE' => 1,
+                        'AC_HEADER_STAT' => 1,
                         'AC_PROG_CPP' => 1,
-                        'AC_C_CONST' => 1,
-                        'AC_PROG_LEX' => 1,
+                        'AC_C_INLINE' => 1,
                         'AC_TYPE_PID_T' => 1,
+                        'AC_PROG_LEX' => 1,
+                        'AC_C_CONST' => 1,
                         'AC_CONFIG_FILES' => 1,
                         'include' => 1,
                         'AC_FUNC_SETVBUF_REVERSED' => 1,
                         'AC_PROG_INSTALL' => 1,
                         'AM_GNU_GETTEXT' => 1,
-                        'AC_FUNC_OBSTACK' => 1,
                         'AC_CHECK_LIB' => 1,
+                        'AC_FUNC_OBSTACK' => 1,
                         'AC_FUNC_MALLOC' => 1,
                         'AC_FUNC_GETGROUPS' => 1,
                         'AC_FUNC_GETLOADAVG' => 1,
                         'AH_OUTPUT' => 1,
                         'AC_FUNC_FSEEKO' => 1,
                         'AM_PROG_CC_C_O' => 1,
-                        'AM_CONDITIONAL' => 1,
-                        'AC_CANONICAL_SYSTEM' => 1,
                         'AC_FUNC_MKTIME' => 1,
+                        'AC_CANONICAL_SYSTEM' => 1,
+                        'AM_CONDITIONAL' => 1,
                         'AC_CONFIG_HEADERS' => 1,
                         'AC_HEADER_SYS_WAIT' => 1,
-                        'AC_PROG_LN_S' => 1,
                         'AC_FUNC_MEMCMP' => 1,
+                        'AC_PROG_LN_S' => 1,
                         'm4_include' => 1,
                         'AC_HEADER_DIRENT' => 1,
                         'AC_CHECK_FUNCS' => 1
index 19f2c694fdbf56e299d630107a25d54488c58471..cc330d084192bd66dbaf4a265e8748de27691efb 100644 (file)
@@ -238,6 +238,9 @@ static int dot_in_path = 0;
 #define COMPLETE_BSQUOTE 3
 static int completion_quoting_style = COMPLETE_BSQUOTE;
 
+/* Flag values for the final argument to bash_default_completion */
+#define DEFCOMP_CMDPOS         1
+
 /* Change the readline VI-mode keymaps into or out of Posix.2 compliance.
    Called when the shell is put into or out of `posix' mode. */
 void
@@ -999,7 +1002,7 @@ attempt_shell_completion (text, start, end)
      const char *text;
      int start, end;
 {
-  int in_command_position, ti, saveti, qc;
+  int in_command_position, ti, saveti, qc, dflags;
   char **matches, *command_separator_chars;
 
   command_separator_chars = COMMAND_SEPARATORS;
@@ -1112,15 +1115,20 @@ attempt_shell_completion (text, start, end)
 #endif
 
   if (matches == 0)
-    matches = bash_default_completion (text, start, end, qc, in_command_position);
+    {
+      dflags = 0;
+      if (in_command_position)
+       dflags |= DEFCOMP_CMDPOS;
+      matches = bash_default_completion (text, start, end, qc, dflags);
+    }
 
   return matches;
 }
 
 char **
-bash_default_completion (text, start, end, qc, in_command_position)
+bash_default_completion (text, start, end, qc, compflags)
      const char *text;
-     int start, end, qc, in_command_position;
+     int start, end, qc, compflags;
 {
   char **matches;
 
@@ -1148,9 +1156,11 @@ bash_default_completion (text, start, end, qc, in_command_position)
   /* And last, (but not least) if this word is in a command position, then
      complete over possible command names, including aliases, functions,
      and command names. */
-  if (!matches && in_command_position)
+  if (matches == 0 && (compflags & DEFCOMP_CMDPOS))
     {
-      if (start == 0 && end == 0 && text[0] == '\0' && no_empty_command_completion)
+      /* If END == START and text[0] == 0, we are trying to complete an empty
+        command word. */
+      if (no_empty_command_completion && end == start && text[0] == '\0')
        {
          matches = (char **)NULL;
          rl_ignore_some_completions_function = bash_ignore_everything;
diff --git a/jobs.c b/jobs.c
index cde791e3dbe8108054c13da081a934ce11b5594a..0e43e9746e9ce7e87dadc8b83fedce9dd0eb76bc 100644 (file)
--- a/jobs.c
+++ b/jobs.c
@@ -77,8 +77,8 @@ extern int errno;
 #endif /* !errno */
 
 #define DEFAULT_CHILD_MAX 32
-#if 1
-#define MAX_JOBS_IN_ARRAY 4096         /* production*/
+#if !defined (DEBUG)
+#define MAX_JOBS_IN_ARRAY 4096         /* production */
 #else
 #define MAX_JOBS_IN_ARRAY 128          /* testing */
 #endif
@@ -962,7 +962,7 @@ compact_jobs_list (flags)
 
   reap_dead_jobs ();
   realloc_jobs_list ();
-  
+
   return (js.j_lastj);
 }
 
diff --git a/jobs.c.diff b/jobs.c.diff
new file mode 100644 (file)
index 0000000..f1ea4e0
--- /dev/null
@@ -0,0 +1,521 @@
+*** ../bash-3.1/jobs.c Fri Nov 11 23:13:27 2005
+--- jobs.c     Wed Feb  1 13:55:38 2006
+***************
+*** 4,8 ****
+     control. */
+  
+! /* Copyright (C) 1989-2005 Free Software Foundation, Inc.
+  
+     This file is part of GNU Bash, the Bourne Again SHell.
+--- 4,8 ----
+     control. */
+  
+! /* Copyright (C) 1989-2006 Free Software Foundation, Inc.
+  
+     This file is part of GNU Bash, the Bourne Again SHell.
+***************
+*** 78,82 ****
+  
+  #define DEFAULT_CHILD_MAX 32
+! #define MAX_JOBS_IN_ARRAY 4096               /* testing */
+  
+  /* Take care of system dependencies that must be handled when waiting for
+--- 78,90 ----
+  
+  #define DEFAULT_CHILD_MAX 32
+! #if !defined (DEBUG)
+! #define MAX_JOBS_IN_ARRAY 4096               /* production */
+! #else
+! #define MAX_JOBS_IN_ARRAY 128                /* testing */
+! #endif
+! 
+! /* Flag values for second argument to delete_job */
+! #define DEL_WARNSTOPPED              1       /* warn about deleting stopped jobs */
+! #define DEL_NOBGPID          2       /* don't add pgrp leader to bgpids */
+  
+  /* Take care of system dependencies that must be handled when waiting for
+***************
+*** 308,311 ****
+--- 316,323 ----
+  static char retcode_name_buffer[64];
+  
++ /* flags to detect pid wraparound */
++ static pid_t first_pid = NO_PID;
++ static int pid_wrap = -1;
++ 
+  #if !defined (_POSIX_VERSION)
+  
+***************
+*** 329,337 ****
+  #endif /* !_POSIX_VERSION */
+  
+! /* Initialize the global job stats structure. */
+  void
+  init_job_stats ()
+  {
+    js = zerojs;
+  }
+  
+--- 341,351 ----
+  #endif /* !_POSIX_VERSION */
+  
+! /* Initialize the global job stats structure and other bookkeeping variables */
+  void
+  init_job_stats ()
+  {
+    js = zerojs;
++   first_pid = NO_PID;
++   pid_wrap = -1;
+  }
+  
+***************
+*** 620,625 ****
+          * the parent gives it away.
+          *
+          */
+!        if (job_control && newjob->pgrp)
+           give_terminal_to (newjob->pgrp, 0);
+       }
+--- 634,642 ----
+          * the parent gives it away.
+          *
++         * Don't give the terminal away if this shell is an asynchronous
++         * subshell.
++         *
+          */
+!        if (job_control && newjob->pgrp && (subshell_environment&SUBSHELL_ASYNC) == 0)
+           give_terminal_to (newjob->pgrp, 0);
+       }
+***************
+*** 806,810 ****
+    QUEUE_SIGCHLD(os);
+  
+!   /* XXX could use js.j_firstj here */
+    for (i = 0; i < js.j_jobslots; i++)
+      {
+--- 823,827 ----
+    QUEUE_SIGCHLD(os);
+  
+!   /* XXX could use js.j_firstj and js.j_lastj here */
+    for (i = 0; i < js.j_jobslots; i++)
+      {
+***************
+*** 812,815 ****
+--- 829,834 ----
+        if (i < js.j_firstj && jobs[i])
+       itrace("cleanup_dead_jobs: job %d non-null before js.j_firstj (%d)", i, js.j_firstj);
++       if (i > js.j_lastj && jobs[i])
++      itrace("cleanup_dead_jobs: job %d non-null after js.j_lastj (%d)", i, js.j_lastj);
+  #endif
+  
+***************
+*** 838,841 ****
+--- 857,884 ----
+  }
+  
++ static void
++ delete_old_job (pid)
++      pid_t pid;
++ {
++   PROCESS *p;
++   int job;
++ 
++   job = find_job (pid, 0, &p);
++   if (job != NO_JOB)
++     {
++ #ifdef DEBUG
++       itrace ("delete_old_job: found pid %d in job %d with state %d", pid, job, jobs[job]->state);
++ #endif
++       if (JOBSTATE (job) == JDEAD)
++      delete_job (job, DEL_NOBGPID);
++       else
++      {
++        internal_warning (_("forked pid %d appears in running job %d"), pid, job);
++        if (p)
++          p->pid = 0;
++      }
++     }
++ }
++ 
+  /* Reallocate and compress the jobs list.  This returns with a jobs array
+     whose size is a multiple of JOB_SLOTS and can hold the current number of
+***************
+*** 845,851 ****
+  {
+    sigset_t set, oset;
+!   int nsize, i, j;
+    JOB **nlist;
+  
+    nsize = ((js.j_njobs + JOB_SLOTS - 1) / JOB_SLOTS);
+    nsize *= JOB_SLOTS;
+--- 888,895 ----
+  {
+    sigset_t set, oset;
+!   int nsize, i, j, ncur, nprev;
+    JOB **nlist;
+  
++   ncur = nprev = NO_JOB;
+    nsize = ((js.j_njobs + JOB_SLOTS - 1) / JOB_SLOTS);
+    nsize *= JOB_SLOTS;
+***************
+*** 855,869 ****
+  
+    BLOCK_CHILD (set, oset);
+!   nlist = (JOB **) xmalloc (nsize * sizeof (JOB *));
+    for (i = j = 0; i < js.j_jobslots; i++)
+      if (jobs[i])
+!       nlist[j++] = jobs[i];
+  
+    js.j_firstj = 0;
+!   js.j_lastj = (j > 0) ? j - 1: 0;
+    js.j_jobslots = nsize;
+  
+!   free (jobs);
+!   jobs = nlist;
+  
+    UNBLOCK_CHILD (oset);
+--- 899,947 ----
+  
+    BLOCK_CHILD (set, oset);
+!   nlist = (js.j_jobslots == nsize) ? jobs : (JOB **) xmalloc (nsize * sizeof (JOB *));
+! 
+    for (i = j = 0; i < js.j_jobslots; i++)
+      if (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_njobs = j;
+    js.j_jobslots = nsize;
+  
+!   /* 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);
+***************
+*** 874,878 ****
+     the foreground process (subshell_environment != 0).  Returns the first
+     available slot in the compacted list.  If that value is js.j_jobslots, then
+!    the list needs to be reallocated.  The jobs array is in new memory if
+     this returns > 0 and < js.j_jobslots.  FLAGS is reserved for future use. */
+  static int
+--- 952,956 ----
+     the foreground process (subshell_environment != 0).  Returns the first
+     available slot in the compacted list.  If that value is js.j_jobslots, then
+!    the list needs to be reallocated.  The jobs array may be in new memory if
+     this returns > 0 and < js.j_jobslots.  FLAGS is reserved for future use. */
+  static int
+***************
+*** 892,897 ****
+     with SIGCHLD blocked. */
+  void
+! delete_job (job_index, warn_stopped)
+!      int job_index, warn_stopped;
+  {
+    register JOB *temp;
+--- 970,975 ----
+     with SIGCHLD blocked. */
+  void
+! delete_job (job_index, dflags)
+!      int job_index, dflags;
+  {
+    register JOB *temp;
+***************
+*** 903,918 ****
+      return;
+  
+!   if (warn_stopped && subshell_environment == 0 && STOPPED (job_index))
+      internal_warning (_("deleting stopped job %d with process group %ld"), job_index+1, (long)jobs[job_index]->pgrp);
+    temp = jobs[job_index];
+    if (job_index == js.j_current || job_index == js.j_previous)
+      reset_current ();
+  
+!   proc = find_last_proc (job_index, 0);
+!   /* Could do this just for J_ASYNC jobs, but we save all. */
+!   bgp_add (proc->pid, process_exit_status (proc->status));
+  
+    jobs[job_index] = (JOB *)NULL;
+- 
+    if (temp == js.j_lastmade)
+      js.j_lastmade = 0;
+--- 981,1001 ----
+      return;
+  
+!   if ((dflags & DEL_WARNSTOPPED) && subshell_environment == 0 && STOPPED (job_index))
+      internal_warning (_("deleting stopped job %d with process group %ld"), job_index+1, (long)jobs[job_index]->pgrp);
+    temp = jobs[job_index];
++   if (temp == 0)
++     return;
+    if (job_index == js.j_current || job_index == js.j_previous)
+      reset_current ();
+  
+!   if ((dflags & DEL_NOBGPID) == 0)
+!     {
+!       proc = find_last_proc (job_index, 0);
+!       /* Could do this just for J_ASYNC jobs, but we save all. */
+!       if (proc)
+!      bgp_add (proc->pid, process_exit_status (proc->status));
+!     }
+  
+    jobs[job_index] = (JOB *)NULL;
+    if (temp == js.j_lastmade)
+      js.j_lastmade = 0;
+***************
+*** 1092,1095 ****
+--- 1175,1180 ----
+        if (i < js.j_firstj && jobs[i])
+       itrace("map_over_jobs: job %d non-null before js.j_firstj (%d)", i, js.j_firstj);
++       if (i > js.j_lastj && jobs[i])
++      itrace("map_over_jobs: job %d non-null after js.j_lastj (%d)", i, js.j_lastj);
+  #endif
+        if (jobs[i])
+***************
+*** 1224,1228 ****
+    PROCESS *p;
+  
+!   /* XXX could use js.j_firstj here */
+    for (i = 0; i < js.j_jobslots; i++)
+      {
+--- 1309,1313 ----
+    PROCESS *p;
+  
+!   /* XXX could use js.j_firstj here, and should check js.j_lastj */
+    for (i = 0; i < js.j_jobslots; i++)
+      {
+***************
+*** 1230,1233 ****
+--- 1315,1320 ----
+        if (i < js.j_firstj && jobs[i])
+       itrace("find_job: job %d non-null before js.j_firstj (%d)", i, js.j_firstj);
++       if (i > js.j_lastj && jobs[i])
++      itrace("find_job: job %d non-null after js.j_lastj (%d)", i, js.j_lastj);
+  #endif
+        if (jobs[i])
+***************
+*** 1656,1660 ****
+            shell's process group (we could be in the middle of a
+            pipeline, for example). */
+!        if (async_p == 0 && pipeline_pgrp != shell_pgrp)
+           give_terminal_to (pipeline_pgrp, 0);
+  
+--- 1743,1747 ----
+            shell's process group (we could be in the middle of a
+            pipeline, for example). */
+!        if (async_p == 0 && pipeline_pgrp != shell_pgrp && ((subshell_environment&SUBSHELL_ASYNC) == 0))
+           give_terminal_to (pipeline_pgrp, 0);
+  
+***************
+*** 1698,1701 ****
+--- 1785,1795 ----
+        as the proper pgrp if this is the first child. */
+  
++       if (first_pid == NO_PID)
++      first_pid = pid;
++       else if (pid_wrap == -1 && pid < first_pid)
++      pid_wrap = 0;
++       else if (pid_wrap == 0 && pid >= first_pid)
++      pid_wrap = 1;
++ 
+        if (job_control)
+       {
+***************
+*** 1731,1734 ****
+--- 1825,1831 ----
+  #endif
+  
++       if (pid_wrap > 0)
++      delete_old_job (pid);
++ 
+  #if !defined (RECYCLES_PIDS)
+        /* Only check for saved status if we've saved more than CHILD_MAX
+***************
+*** 1915,1919 ****
+  
+    p = jobs[job]->pipe;
+!   while (p->next != jobs[job]->pipe)
+      p = p->next;
+  
+--- 2012,2016 ----
+  
+    p = jobs[job]->pipe;
+!   while (p && p->next != jobs[job]->pipe)
+      p = p->next;
+  
+***************
+*** 1999,2003 ****
+  
+        /* find first running job; if none running in foreground, break */
+!       /* XXX could use js.j_firstj here */
+        for (i = 0; i < js.j_jobslots; i++)
+       {
+--- 2096,2100 ----
+  
+        /* find first running job; if none running in foreground, break */
+!       /* XXX could use js.j_firstj and js.j_lastj here */
+        for (i = 0; i < js.j_jobslots; i++)
+       {
+***************
+*** 2005,2008 ****
+--- 2102,2107 ----
+         if (i < js.j_firstj && jobs[i])
+           itrace("wait_for_background_pids: job %d non-null before js.j_firstj (%d)", i, js.j_firstj);
++        if (i > js.j_lastj && jobs[i])
++          itrace("wait_for_background_pids: job %d non-null after js.j_lastj (%d)", i, js.j_lastj);
+  #endif
+         if (jobs[i] && RUNNING (i) && IS_FOREGROUND (i) == 0)
+***************
+*** 2199,2203 ****
+    wait_sigint_received = 0;
+    if (job_control == 0)
+!     old_sigint_handler = set_signal_handler (SIGINT, wait_sigint_handler);
+  
+    termination_state = last_command_exit_value;
+--- 2298,2306 ----
+    wait_sigint_received = 0;
+    if (job_control == 0)
+!     {
+!       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;
+***************
+*** 2266,2269 ****
+--- 2369,2373 ----
+             child->running = PS_DONE;
+             child->status = 0;        /* XXX -- can't find true status */
++            js.c_living = 0;          /* no living child processes */
+             if (job != NO_JOB)
+               {
+***************
+*** 2317,2321 ****
+    itrace("wait_for: job == NO_JOB, giving the terminal to shell_pgrp (%ld)", (long)shell_pgrp);
+  #endif
+- 
+        give_terminal_to (shell_pgrp, 0);
+      }
+--- 2421,2424 ----
+***************
+*** 2866,2869 ****
+--- 2969,2973 ----
+        if (sigchld || block == 0)
+       waitpid_flags |= WNOHANG;
++       CHECK_TERMSIG;
+        pid = WAITPID (-1, &status, waitpid_flags);
+  
+***************
+*** 2892,2895 ****
+--- 2996,3000 ----
+        /* If waitpid returns 0, there are running children.  If it returns -1,
+        the only other error POSIX says it can return is EINTR. */
++       CHECK_TERMSIG;
+        if (pid <= 0)
+       continue;       /* jumps right to the test */
+***************
+*** 2898,2902 ****
+           run the trap if a process is just being continued. */
+        if (WIFCONTINUED(status) == 0)
+!      children_exited++;
+  
+        /* Locate our PROCESS for this pid. */
+--- 3003,3010 ----
+           run the trap if a process is just being continued. */
+        if (WIFCONTINUED(status) == 0)
+!      {
+!        children_exited++;
+!        js.c_living--;
+!      }
+  
+        /* Locate our PROCESS for this pid. */
+***************
+*** 3123,3127 ****
+               restore_sigint_handler ();
+             if (temp_handler == SIG_DFL)
+!              termination_unwind_protect (SIGINT);
+             else if (temp_handler != SIG_IGN)
+               (*temp_handler) (SIGINT);
+--- 3231,3235 ----
+               restore_sigint_handler ();
+             if (temp_handler == SIG_DFL)
+!              termsig_handler (SIGINT);
+             else if (temp_handler != SIG_IGN)
+               (*temp_handler) (SIGINT);
+***************
+*** 3638,3644 ****
+         if (i < js.j_firstj && jobs[i])
+           itrace("delete_all_jobs: job %d non-null before js.j_firstj (%d)", i, js.j_firstj);
+  #endif
+         if (jobs[i] && (running_only == 0 || (running_only && RUNNING(i))))
+!          delete_job (i, 1);
+       }
+        if (running_only == 0)
+--- 3746,3754 ----
+         if (i < js.j_firstj && jobs[i])
+           itrace("delete_all_jobs: job %d non-null before js.j_firstj (%d)", i, js.j_firstj);
++        if (i > js.j_lastj && jobs[i])
++          itrace("delete_all_jobs: job %d non-null after js.j_lastj (%d)", i, js.j_lastj);
+  #endif
+         if (jobs[i] && (running_only == 0 || (running_only && RUNNING(i))))
+!          delete_job (i, DEL_WARNSTOPPED);
+       }
+        if (running_only == 0)
+***************
+*** 3692,3695 ****
+--- 3802,3807 ----
+        if (i < js.j_firstj && jobs[i])
+       itrace("count_all_jobs: job %d non-null before js.j_firstj (%d)", i, js.j_firstj);
++       if (i > js.j_lastj && jobs[i])
++      itrace("count_all_jobs: job %d non-null after js.j_lastj (%d)", i, js.j_lastj);
+  #endif
+        if (jobs[i] && DEADJOB(i) == 0)
+***************
+*** 3765,3768 ****
+--- 3877,3882 ----
+        if (i < js.j_firstj && jobs[i])
+       itrace("mark_dead_jobs_as_notified: job %d non-null before js.j_firstj (%d)", i, js.j_firstj);
++       if (i > js.j_lastj && jobs[i])
++      itrace("mark_dead_jobs_as_notified: job %d non-null after js.j_lastj (%d)", i, js.j_lastj);
+  #endif
+        if (jobs[i] && DEADJOB (i))
+***************
+*** 3816,3819 ****
+--- 3930,3935 ----
+         if (i < js.j_firstj && jobs[i])
+           itrace("mark_dead_jobs_as_notified: job %d non-null before js.j_firstj (%d)", i, js.j_firstj);
++        if (i > js.j_lastj && jobs[i])
++          itrace("mark_dead_jobs_as_notified: job %d non-null after js.j_lastj (%d)", i, js.j_lastj);
+  #endif
+         /* If marking this job as notified would drop us down below
index be72f8f4f49aa53e7a2750de67fc5735ceebefda..28abadeb7973690d01bc1b09d2b4ea52a4717d3d 100644 (file)
@@ -88,7 +88,7 @@ static int inv_lbsize, vis_lbsize;
    current cursor position is in the middle of a prompt string containing
    invisible characters. */
 #define PROMPT_ENDING_INDEX \
-  ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) ? prompt_physical_chars : prompt_last_invisible)
+  ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) ? prompt_physical_chars : prompt_last_invisible+1)
   
 
 /* **************************************************************** */
@@ -977,7 +977,11 @@ rl_redisplay ()
             invisible character in the prompt string. */
          nleft = prompt_visible_length + wrap_offset;
          if (cursor_linenum == 0 && wrap_offset > 0 && _rl_last_c_pos > 0 &&
+#if 0
              _rl_last_c_pos <= PROMPT_ENDING_INDEX && local_prompt)
+#else
+             _rl_last_c_pos < PROMPT_ENDING_INDEX && local_prompt)
+#endif
            {
 #if defined (__MSDOS__)
              putc ('\r', rl_outstream);
@@ -1997,28 +2001,14 @@ _rl_make_prompt_for_search (pchar)
 
   rl_save_prompt ();
 
-  if (saved_local_prompt == 0)
-    {
-      len = (rl_prompt && *rl_prompt) ? strlen (rl_prompt) : 0;
-      pmt = (char *)xmalloc (len + 2);
-      if (len)
-       strcpy (pmt, rl_prompt);
-      pmt[len] = pchar;
-      pmt[len+1] = '\0';
-    }
-  else
-    {
-      len = *saved_local_prompt ? strlen (saved_local_prompt) : 0;
-      pmt = (char *)xmalloc (len + 2);
-      if (len)
-       strcpy (pmt, saved_local_prompt);
-      pmt[len] = pchar;
-      pmt[len+1] = '\0';
-      local_prompt = savestring (pmt);
-      prompt_last_invisible = saved_last_invisible;
-      prompt_visible_length = saved_visible_length + 1;
-    }
+  len = (rl_prompt && *rl_prompt) ? strlen (rl_prompt) : 0;
+  pmt = (char *)xmalloc (len + 2);
+  if (len)
+    strcpy (pmt, rl_prompt);
+  pmt[len] = pchar;
+  pmt[len+1] = '\0';
 
+  /* will be overwritten by expand_prompt, called from rl_message */
   prompt_physical_chars = saved_physical_chars + 1;
 
   return pmt;
index e0a4bcf4151924b6846a249de42463a60b17eacf..3f902db67ed9ebf384d7647ecc5c43539e420322 100644 (file)
@@ -83,6 +83,14 @@ static int inv_lbsize, vis_lbsize;
    by backing up or outputting a carriage return and moving forward. */
 #define CR_FASTER(new, cur) (((new) + 1) < ((cur) - (new)))
 
+/* _rl_last_c_pos is an absolute cursor position in multibyte locales and a
+   buffer index in others.  This macro is used when deciding whether the
+   current cursor position is in the middle of a prompt string containing
+   invisible characters. */
+#define PROMPT_ENDING_INDEX \
+  ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) ? prompt_physical_chars : prompt_last_invisible)
+  
+
 /* **************************************************************** */
 /*                                                                 */
 /*                     Display stuff                               */
@@ -969,7 +977,7 @@ rl_redisplay ()
             invisible character in the prompt string. */
          nleft = prompt_visible_length + wrap_offset;
          if (cursor_linenum == 0 && wrap_offset > 0 && _rl_last_c_pos > 0 &&
-             _rl_last_c_pos <= prompt_last_invisible && local_prompt)
+             _rl_last_c_pos <= PROMPT_ENDING_INDEX && local_prompt)
            {
 #if defined (__MSDOS__)
              putc ('\r', rl_outstream);
@@ -1166,7 +1174,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
   int col_lendiff, col_temp;
 #if defined (HANDLE_MULTIBYTE)
   mbstate_t ps_new, ps_old;
-  int new_offset, old_offset, tmp;
+  int new_offset, old_offset;
 #endif
 
   /* If we're at the right edge of a terminal that supports xn, we're
@@ -1403,7 +1411,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
   od = ofd - old;      /* index of first difference in visible line */
   if (current_line == 0 && !_rl_horizontal_scroll_mode &&
       _rl_term_cr && lendiff > prompt_visible_length && _rl_last_c_pos > 0 &&
-      od >= lendiff && _rl_last_c_pos <= prompt_last_invisible)
+      od >= lendiff && _rl_last_c_pos <= PROMPT_ENDING_INDEX)
     {
 #if defined (__MSDOS__)
       putc ('\r', rl_outstream);
@@ -1989,28 +1997,14 @@ _rl_make_prompt_for_search (pchar)
 
   rl_save_prompt ();
 
-  if (saved_local_prompt == 0)
-    {
-      len = (rl_prompt && *rl_prompt) ? strlen (rl_prompt) : 0;
-      pmt = (char *)xmalloc (len + 2);
-      if (len)
-       strcpy (pmt, rl_prompt);
-      pmt[len] = pchar;
-      pmt[len+1] = '\0';
-    }
-  else
-    {
-      len = *saved_local_prompt ? strlen (saved_local_prompt) : 0;
-      pmt = (char *)xmalloc (len + 2);
-      if (len)
-       strcpy (pmt, saved_local_prompt);
-      pmt[len] = pchar;
-      pmt[len+1] = '\0';
-      local_prompt = savestring (pmt);
-      prompt_last_invisible = saved_last_invisible;
-      prompt_visible_length = saved_visible_length + 1;
-    }
+  len = (rl_prompt && *rl_prompt) ? strlen (rl_prompt) : 0;
+  pmt = (char *)xmalloc (len + 2);
+  if (len)
+    strcpy (pmt, rl_prompt);
+  pmt[len] = pchar;
+  pmt[len+1] = '\0';
 
+  /* will be overwritten by expand_prompt, called from rl_message */
   prompt_physical_chars = saved_physical_chars + 1;
 
   return pmt;
index eb72c19ca01916f50357c04e35c0df73249dc595..f4cfb939facdaa2b25e17386078d6ef65937cefb 100644 (file)
 #define CUSTOM_REDISPLAY_FUNC() (rl_redisplay_function != rl_redisplay)
 #define CUSTOM_INPUT_FUNC() (rl_getc_function != rl_getc)
 
-int rl_prefer_env_winsize;
+/*  If the calling application sets this to a non-zero value, readline will
+    use the $LINES and $COLUMNS environment variables to set its idea of the
+    window size before interrogating the kernel. */
+int rl_prefer_env_winsize = 0;
 
 /* **************************************************************** */
 /*                                                                 */
diff --git a/parse.y.diff b/parse.y.diff
new file mode 100644 (file)
index 0000000..b675aad
--- /dev/null
@@ -0,0 +1,251 @@
+*** ../bash-3.1/parse.y        Fri Nov 11 23:14:18 2005
+--- parse.y    Wed Jan 25 14:55:18 2006
+***************
+*** 1,5 ****
+  /* Yacc grammar for bash. */
+  
+! /* Copyright (C) 1989-2005 Free Software Foundation, Inc.
+  
+     This file is part of GNU Bash, the Bourne Again SHell.
+--- 1,5 ----
+  /* Yacc grammar for bash. */
+  
+! /* Copyright (C) 1989-2006 Free Software Foundation, Inc.
+  
+     This file is part of GNU Bash, the Bourne Again SHell.
+***************
+*** 119,123 ****
+  extern int posixly_correct;
+  extern int last_command_exit_value;
+- extern int interrupt_immediately;
+  extern char *shell_name, *current_host_name;
+  extern char *dist_version;
+--- 119,122 ----
+***************
+*** 1213,1220 ****
+--- 1212,1221 ----
+         interrupt_immediately++;
+       }
++       terminate_immediately = 1;
+  
+        current_readline_line = readline (current_readline_prompt ?
+                                                 current_readline_prompt : "");
+  
++       terminate_immediately = 0;
+        if (signal_is_ignored (SIGINT) == 0 && old_sigint)
+       {
+***************
+*** 1348,1355 ****
+      {
+        if (interactive)
+!      interrupt_immediately++;
+        result = getc_with_restart (bash_input.location.file);
+        if (interactive)
+!      interrupt_immediately--;
+      }
+    return (result);
+--- 1349,1362 ----
+      {
+        if (interactive)
+!      {
+!        interrupt_immediately++;
+!        terminate_immediately++;
+!      }
+        result = getc_with_restart (bash_input.location.file);
+        if (interactive)
+!      {
+!        interrupt_immediately--;
+!        terminate_immediately--;
+!      }
+      }
+    return (result);
+***************
+*** 2743,2751 ****
+    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
+        if (ch == EOF)
+       {
+--- 2750,2755 ----
+    while (count)
+      {
+        ch = shell_getc (qc != '\'' && pass_next_character == 0);
+! 
+        if (ch == EOF)
+       {
+***************
+*** 2772,2776 ****
+       }
+        /* Not exactly right yet */
+!       else if (check_comment && in_comment == 0 && ch == '#' && (retind == 0 || ret[retind-1] == '\n' || whitespace (ret[retind -1])))
+       in_comment = 1;
+  
+--- 2776,2780 ----
+       }
+        /* Not exactly right yet */
+!       else if MBTEST(check_comment && in_comment == 0 && ch == '#' && (retind == 0 || ret[retind-1] == '\n' || whitespace (ret[retind - 1])))
+       in_comment = 1;
+  
+***************
+*** 2799,2807 ****
+        else if MBTEST(ch == close)            /* ending delimiter */
+       count--;
+- #if 1
+        /* handle nested ${...} specially. */
+        else if MBTEST(open != close && was_dollar && open == '{' && ch == open) /* } */
+       count++;
+- #endif
+        else if MBTEST(((flags & P_FIRSTCLOSE) == 0) && ch == open)    /* nested begin */
+       count++;
+--- 2803,2809 ----
+***************
+*** 2899,2903 ****
+        else if MBTEST(qc == '`' && (ch == '"' || ch == '\'') && in_comment == 0)
+       {
+!        nestret = parse_matched_pair (0, ch, ch, &nestlen, rflags);
+         goto add_nestret;
+       }
+--- 2901,2909 ----
+        else if MBTEST(qc == '`' && (ch == '"' || ch == '\'') && in_comment == 0)
+       {
+!        /* Add P_ALLOWESC so backslash quotes the next character and
+!           shell_getc does the right thing with \<newline>.  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_ALLOWESC);
+         goto add_nestret;
+       }
+***************
+*** 2908,2912 ****
+           count--;
+         if (ch == '(')                /* ) */
+!          nestret = parse_matched_pair (0, '(', ')', &nestlen, rflags);
+         else if (ch == '{')           /* } */
+           nestret = parse_matched_pair (0, '{', '}', &nestlen, P_FIRSTCLOSE|rflags);
+--- 2914,2918 ----
+           count--;
+         if (ch == '(')                /* ) */
+!          nestret = parse_matched_pair (0, '(', ')', &nestlen, rflags & ~P_DQUOTE);
+         else if (ch == '{')           /* } */
+           nestret = parse_matched_pair (0, '{', '}', &nestlen, P_FIRSTCLOSE|rflags);
+***************
+*** 2947,2951 ****
+         wd = alloc_word_desc ();
+         wd->word = wval;
+-        wd = make_word (wval);
+         yylval.word_list = make_word_list (wd, (WORD_LIST *)NULL);
+         return (ARITH_FOR_EXPRS);
+--- 2953,2956 ----
+***************
+*** 3497,3501 ****
+             else
+               {
+!                /* Try to locale)-expand the converted string. */
+                 ttrans = localeexpand (ttok, 0, ttoklen - 1, first_line, &ttranslen);
+                 free (ttok);
+--- 3502,3506 ----
+             else
+               {
+!                /* Try to locale-expand the converted string. */
+                 ttrans = localeexpand (ttok, 0, ttoklen - 1, first_line, &ttranslen);
+                 free (ttok);
+***************
+*** 3579,3583 ****
+             all_digit_token = 0;
+             compound_assignment = 1;
+! #if 0
+             goto next_character;
+  #else
+--- 3584,3588 ----
+             all_digit_token = 0;
+             compound_assignment = 1;
+! #if 1
+             goto next_character;
+  #else
+***************
+*** 3696,3700 ****
+        b = builtin_address_internal (token, 0);
+        if (b && (b->flags & ASSIGNMENT_BUILTIN))
+!         parser_state |= PST_ASSIGNOK;
+      }
+  
+--- 3701,3707 ----
+        b = builtin_address_internal (token, 0);
+        if (b && (b->flags & ASSIGNMENT_BUILTIN))
+!      parser_state |= PST_ASSIGNOK;
+!       else if (STREQ (token, "eval") || STREQ (token, "let"))
+!      parser_state |= PST_ASSIGNOK;
+      }
+  
+***************
+*** 4247,4251 ****
+               }
+             temp = (char *)xmalloc (3);
+!            temp[0] = '\001';
+             temp[1] = (c == '[') ? RL_PROMPT_START_IGNORE : RL_PROMPT_END_IGNORE;
+             temp[2] = '\0';
+--- 4254,4258 ----
+               }
+             temp = (char *)xmalloc (3);
+!            temp[0] = CTLESC;
+             temp[1] = (c == '[') ? RL_PROMPT_START_IGNORE : RL_PROMPT_END_IGNORE;
+             temp[2] = '\0';
+***************
+*** 4687,4691 ****
+  {
+    WORD_LIST *wl, *rl;
+!   int tok, orig_line_number, orig_token_size;
+    char *saved_token, *ret;
+  
+--- 4694,4698 ----
+  {
+    WORD_LIST *wl, *rl;
+!   int tok, orig_line_number, orig_token_size, orig_last_token, assignok;
+    char *saved_token, *ret;
+  
+***************
+*** 4693,4696 ****
+--- 4700,4704 ----
+    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 */
+***************
+*** 4699,4702 ****
+--- 4707,4712 ----
+    token_buffer_size = 0;
+  
++   assignok = parser_state&PST_ASSIGNOK;              /* XXX */
++ 
+    wl = (WORD_LIST *)NULL;    /* ( */
+    parser_state |= PST_COMPASSIGN;
+***************
+*** 4741,4745 ****
+      }
+  
+!   last_read_token = WORD;
+    if (wl)
+      {
+--- 4751,4756 ----
+      }
+  
+!   last_read_token = orig_last_token;         /* XXX - was WORD? */
+! 
+    if (wl)
+      {
+***************
+*** 4753,4756 ****
+--- 4764,4771 ----
+    if (retlenp)
+      *retlenp = (ret && *ret) ? strlen (ret) : 0;
++ 
++   if (assignok)
++     parser_state |= PST_ASSIGNOK;
++ 
+    return ret;
+  }
diff --git a/terminal.c.diff b/terminal.c.diff
new file mode 100644 (file)
index 0000000..e3fa899
--- /dev/null
@@ -0,0 +1,41 @@
+*** ../bash-3.1/lib/readline/terminal.c        Sat Nov 12 20:46:54 2005
+--- lib/readline/terminal.c    Tue Jan 31 10:57:54 2006
+***************
+*** 70,74 ****
+  #define CUSTOM_INPUT_FUNC() (rl_getc_function != rl_getc)
+  
+! int rl_prefer_env_winsize;
+  
+  /* **************************************************************** */
+--- 70,77 ----
+  #define CUSTOM_INPUT_FUNC() (rl_getc_function != rl_getc)
+  
+! /*  If the calling application sets this to a non-zero value, readline will
+!     use the $LINES and $COLUMNS environment variables to set its idea of the
+!     window size before interrogating the kernel. */
+! int rl_prefer_env_winsize = 0;
+  
+  /* **************************************************************** */
+***************
+*** 123,127 ****
+  
+  /* Non-zero means the terminal can auto-wrap lines. */
+! int _rl_term_autowrap;
+  
+  /* Non-zero means that this terminal has a meta key. */
+--- 126,130 ----
+  
+  /* Non-zero means the terminal can auto-wrap lines. */
+! int _rl_term_autowrap = -1;
+  
+  /* Non-zero means that this terminal has a meta key. */
+***************
+*** 275,278 ****
+--- 278,284 ----
+       int rows, cols;
+  {
++   if (_rl_term_autowrap == -1)
++     _rl_init_terminal_io (rl_terminal_name);
++ 
+    if (rows > 0)
+      _rl_screenheight = rows;
index 72ec06a2c1fd8dde92acea5e8ac773e35f1d061b..3efcf32d68e9722024b6ca9d67f9e81b2aa5ac04 100755 (executable)
@@ -1,4 +1,4 @@
-BUILD_DIR=/usr/local/build/bash/bash-current
+BUILD_DIR=/usr/local/build/chet/bash/bash-current
 THIS_SH=$BUILD_DIR/bash
 PATH=$PATH:$BUILD_DIR