]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
commit bash-20071025 snapshot
authorChet Ramey <chet.ramey@case.edu>
Wed, 7 Dec 2011 14:14:40 +0000 (09:14 -0500)
committerChet Ramey <chet.ramey@case.edu>
Wed, 7 Dec 2011 14:14:40 +0000 (09:14 -0500)
13 files changed:
CWRU/CWRU.chlog
CWRU/CWRU.chlog~
builtins/printf.def
builtins/printf.def~
builtins/read.def
builtins/read.def~
execute_cmd.c
execute_cmd.c~
lib/readline/display.c
lib/readline/display.c~
tests/RUN-ONE-TEST
variables.c
variables.c~

index b1b40cad82a249e25b5a4fc68ba3c83eff0781e3..e05877370bcba8d3272e8e27cda634429787ded9 100644 (file)
@@ -14978,3 +14978,40 @@ expr.c
        - in readtok(), don't reset lasttp if we've consumed the whitespace
          at the end of the expression string.  Fixes error message problem
          reported by <anmaster@tele2.se>
+
+                                  11/1
+                                  ----
+builtins/printf.def
+       - change asciicode() to return intmax_t; add multibyte character
+         support instead of assuming ASCII (depending on behavior of system
+         multibyte support functions).  Fixes bug reported by Rich
+         Felker <dalias@aerifal.cx>
+
+                                  11/5
+                                  ----
+execute_cmd.c
+       - if redirections attached to a compound command fail, make sure to
+         set last_command_exit_value when returning EXECUTION_FAILURE.
+         Fixes bug reported separately by Andreas Schwab <schwab@suse.de>
+         and Paul Eggert <eggert@cs.ucla.edu>
+
+                                  11/9
+                                  ----
+builtins/read.def
+       - make sure the return value from get_word_from_string is freed if
+         non-null.  Fixes bug reported by Lars Ellenberg
+         <lars.ellenberg@linbit.com>
+
+                                  11/10
+                                  -----
+variables.c
+       - use getpid() as value of seeded_subshell to avoid problems with
+         random number generator not getting re-seeded correctly when
+         subshells are created.  Fix from Tomas Janousek <tjanouse@redhat.com>
+
+lib/readline/display.c
+       - in update_line(), when outputting characters at the end of the line,
+         e.g., when displaying the prompt string, adjust _rl_last_c_pos by
+         wrap_offset if the text we're drawing begins before the last
+         invisible character in the line.  Similar to fix from 5/24.  Fixes
+         bug reported by Miroslav Lichvar <mlichvar@redhat.com>
index de0b506c778a20b2a557625bcb326b3104f75eba..79d2c6da563361d2b98946104a46ed688f2fcaa4 100644 (file)
@@ -14957,3 +14957,53 @@ builtins/type.def
        - change exit status of `type' to not successful if any of the
          requested commands are not found.  Reported by Stephane Chazleas
          <stephane_chazelas@yahoo.fr>
+
+pcomplete.c
+       - change command_line_to_word_list to use rl_completer_word_break_characters
+         instead of the shell metacharacters to split words, so programmable
+         completion does the same thing readline does internally.  Reported
+         by Vasily Tarasov <vtaras@sw.ru>
+
+                                  10/16
+                                  -----
+bashline.c
+       - When completing a command name beginnig with a tilde and containing
+         escaped specical characters, dequote the filename before prefixing
+         it to the matches, so the escapes are not quoted again.  Reported
+         by neil@s-z.org
+
+                                  10/17
+                                  -----
+expr.c
+       - in readtok(), don't reset lasttp if we've consumed the whitespace
+         at the end of the expression string.  Fixes error message problem
+         reported by <anmaster@tele2.se>
+
+                                  11/1
+                                  ----
+builtins/printf.def
+       - change asciicode() to return intmax_t; add multibyte character
+         support instead of assuming ASCII (depending on behavior of system
+         multibyte support functions).  Fixes bug reported by Rich
+         Felker <dalias@aerifal.cx>
+
+                                  11/9
+                                  ----
+builtins/read.def
+       - make sure the return value from get_word_from_string is freed if
+         non-null.  Fixes bug reported by Lars Ellenberg
+         <lars.ellenberg@linbit.com>
+
+                                  11/10
+                                  -----
+variables.c
+       - use getpid() as value of seeded_subshell to avoid problems with
+         random number generator not getting re-seeded correctly when
+         subshells are created.  Fix from Tomas Janousek <tjanouse@redhat.com>
+
+lib/readline/display.c
+       - in update_line(), when outputting characters at the end of the line,
+         e.g., when displaying the prompt string, adjust _rl_last_c_pos by
+         wrap_offset if the text we're drawing begins before the last
+         invisible character in the line.  Similar to fix from 5/24.  Fixes
+         bug reported by Miroslav Lichvar <mlichvar@redhat.com>
index 865b04784026844ca00a8a135b3711141447d88c..0f99ffde5651f98c28d40a7d39097ec89f2c6ee2 100644 (file)
@@ -66,6 +66,7 @@ $END
 #include "../bashintl.h"
 
 #include "../shell.h"
+#include "shmbutil.h"
 #include "stdc.h"
 #include "bashgetopt.h"
 #include "common.h"
@@ -190,7 +191,7 @@ typedef double floatmax_t;
 #endif
 static floatmax_t getfloatmax __P((void));
 
-static int asciicode __P((void));
+static intmax_t asciicode __P((void));
 
 static WORD_LIST *garglist;
 static int retval;
@@ -1018,12 +1019,32 @@ getfloatmax ()
 }
 
 /* NO check is needed for garglist here. */
-static int
+static intmax_t
 asciicode ()
 {
-  register int ch;
+  register intmax_t ch;
+#if defined (HANDLE_MULTIBYTE)
+  wchar_t wc;
+  size_t mblength, slen;
+#endif
+  DECLARE_MBSTATE;
+
+#if defined (HANDLE_MULTIBYTE)
+  slen = strlen (garglist->word->word+1);
+  mblength = mbrlen (garglist->word->word+1, slen, NULL);
+#if 0
+  if (mblength > 1)
+#else
+  if (1)
+#endif
+    {
+      mblength = mbrtowc (&wc, garglist->word->word+1, slen, NULL);
+      ch = wc;         /* XXX */
+    }
+  else
+#endif
+    ch = garglist->word->word[1];
 
-  ch = garglist->word->word[1];
   garglist = garglist->next;
   return (ch);
 }
index 5daface1f1ef1a9660830590edb2ec1874aa065a..18c22beb53986ef1fec260019dbafcd492701b9e 100644 (file)
@@ -66,6 +66,7 @@ $END
 #include "../bashintl.h"
 
 #include "../shell.h"
+#include "shmbutil.h"
 #include "stdc.h"
 #include "bashgetopt.h"
 #include "common.h"
@@ -148,6 +149,8 @@ extern int errno;
          vbsize = 0; \
          vbuf = 0; \
        } \
+      else if (vbuf) \
+       vbuf[0] = 0; \
       fflush (stdout); \
       if (ferror (stdout)) \
        { \
@@ -188,7 +191,7 @@ typedef double floatmax_t;
 #endif
 static floatmax_t getfloatmax __P((void));
 
-static int asciicode __P((void));
+static intmax_t asciicode __P((void));
 
 static WORD_LIST *garglist;
 static int retval;
@@ -1016,12 +1019,31 @@ getfloatmax ()
 }
 
 /* NO check is needed for garglist here. */
-static int
+static intmax_t
 asciicode ()
 {
-  register int ch;
+  register intmax_t ch;
+#if defined (HANDLE_MULTIBYTE)
+  wchar_t wc;
+  size_t mblength, slen;
+#endif
+  DECLARE_MBSTATE;
+
+#if defined (HANDLE_MULTIBYTE)
+  slen = strlen (garglist->word->word+1);
+  mblength = mbrlen (garglist->word->word+1, slen, NULL);
+#if 0
+  if (mblength > 1)
+#else
+  if (1)
+    {
+      mblength = mbrtowc (&wc, garglist->word->word+1, slen, NULL);
+      ch = wc;         /* XXX */
+    }
+  else
+#endif
+    ch = garglist->word->word[1];
 
-  ch = garglist->word->word[1];
   garglist = garglist->next;
   return (ch);
 }
index e5aff643904fce490f398d55d5d1272fbc2c8831..fbf0fb4e4a4923946156b21e22fda47899e2aa66 100644 (file)
@@ -137,7 +137,7 @@ read_builtin (list)
   intmax_t intval;
   char c;
   char *input_string, *orig_input_string, *ifs_chars, *prompt, *arrayname;
-  char *e, *t, *t1, *ps2;
+  char *e, *t, *t1, *ps2, *tofree;
   struct stat tsb;
   SHELL_VAR *var;
 #if defined (ARRAY_VARS)
@@ -692,12 +692,13 @@ add_char:
 #else
   /* Check whether or not the number of fields is exactly the same as the
      number of variables. */
+  tofree = NULL;
   if (*input_string)
     {
       t1 = input_string;
       t = get_word_from_string (&input_string, ifs_chars, &e);
       if (*input_string == 0)
-       input_string = t;
+       tofree = input_string = t;
       else
        input_string = strip_trailing_ifs_whitespace (t1, ifs_chars, saw_escape);
     }
@@ -712,6 +713,8 @@ add_char:
   else
     var = bind_read_variable (list->word->word, input_string);
   stupidly_hack_special_variables (list->word->word);
+  FREE (tofree);
+
   if (var)
     VUNSETATTR (var, att_invisible);
   xfree (orig_input_string);
index 9680c425a8dcea64c2e74688870fd52355d398d3..054af654905544be9f10adbe783f8d8255ffcf73 100644 (file)
@@ -137,7 +137,7 @@ read_builtin (list)
   intmax_t intval;
   char c;
   char *input_string, *orig_input_string, *ifs_chars, *prompt, *arrayname;
-  char *e, *t, *t1, *ps2;
+  char *e, *t, *t1, *ps2, *tofree;
   struct stat tsb;
   SHELL_VAR *var;
 #if defined (ARRAY_VARS)
@@ -492,7 +492,7 @@ add_char:
       input_string[i++] = c;
 
 #if defined (HANDLE_MULTIBYTE)
-      if (MB_CUR_MAX > 1)
+      if (nchars > 0 && MB_CUR_MAX > 1)
        {
          input_string[i] = '\0';       /* for simplicity and debugging */
          i += read_mbchar (fd, input_string, i, c, unbuffered_read);
@@ -695,7 +695,8 @@ add_char:
   if (*input_string)
     {
       t1 = input_string;
-      t = get_word_from_string (&input_string, ifs_chars, &e);
+      tofree = NULL;
+      tofree = t = get_word_from_string (&input_string, ifs_chars, &e);
       if (*input_string == 0)
        input_string = t;
       else
index 560631403747792aa0be38b26eb311b0a8256074..be51a3334225c4c4ced7cf584c2889d74840f41b 100644 (file)
@@ -619,7 +619,7 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
       cleanup_redirects (redirection_undo_list);
       redirection_undo_list = (REDIRECT *)NULL;
       dispose_exec_redirects ();
-      return (EXECUTION_FAILURE);
+      return (last_command_exit_value = EXECUTION_FAILURE);
     }
 
   if (redirection_undo_list)
index 1b70813b45a8efe6c92c8bbe262269276c7f48b6..560631403747792aa0be38b26eb311b0a8256074 100644 (file)
@@ -3309,7 +3309,6 @@ execute_function (var, words, flags, fds_to_close, async, subshell)
   array_push (bash_source_a, sfile);
   t = itos (executing_line_number ());
   array_push (bash_lineno_a, t);
-itrace("execute_function: pushed %s to BASH_LINENO", t);
   free (t);
 #endif
 
index 83e71c38dd8601c2b9c329a958e896a1c87007c1..c0532ca05439f4b44424d2120769472b3d82fac9 100644 (file)
@@ -1618,11 +1618,16 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
            }
          else
            {
-             /* We have horizontal scrolling and we are not inserting at
-                the end.  We have invisible characters in this line.  This
-                is a dumb update. */
              _rl_output_some_chars (nfd, temp);
              _rl_last_c_pos += col_temp;
+             /* If nfd begins before any invisible characters in the prompt,
+                adjust _rl_last_c_pos to account for wrap_offset and set
+                cpos_adjusted to let the caller know. */
+             if (current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible))
+               {
+                 _rl_last_c_pos -= wrap_offset;
+                 cpos_adjusted = 1;
+               }
              return;
            }
          /* Copy (new) chars to screen from first diff to last match. */
index 3b964302bb269432b39da3df65dbeb33f7bcd579..0f74b7897272781b038fde4ec0b997e0ea36121a 100644 (file)
@@ -938,7 +938,7 @@ rl_redisplay ()
             second and subsequent lines start at inv_lbreaks[N], offset by
             OFFSET (which has already been calculated above).  */
 
-#define WRAP_OFFSET<(line, offset)  ((line == 0) \
+#define WRAP_OFFSET(line, offset)  ((line == 0) \
                                        ? (offset ? prompt_invis_chars_first_line : 0) \
                                        : ((line == prompt_last_screen_line) ? wrap_offset-prompt_invis_chars_first_line : 0))
 #define W_OFFSET(line, offset) ((line) == 0 ? offset : 0)
@@ -1102,7 +1102,7 @@ rl_redisplay ()
                tx = _rl_col_width (&visible_line[pos], 0, nleft) - visible_wrap_offset;
              else
                tx = nleft;
-             if (_rl_last_c_pos > tx)
+             if (tx >= 0 && _rl_last_c_pos > tx)
                {
                  _rl_backspace (_rl_last_c_pos - tx);  /* XXX */
                  _rl_last_c_pos = tx;
@@ -1251,7 +1251,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
      int current_line, omax, nmax, inv_botlin;
 {
   register char *ofd, *ols, *oe, *nfd, *nls, *ne;
-  int temp, lendiff, wsatend, od, nd, twidth;
+  int temp, lendiff, wsatend, od, nd, twidth, o_cpos;
   int current_invis_chars;
   int col_lendiff, col_temp;
 #if defined (HANDLE_MULTIBYTE)
@@ -1514,6 +1514,8 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
        _rl_last_c_pos = lendiff + modmark;
     }
 
+  o_cpos = _rl_last_c_pos;
+
   /* When this function returns, _rl_last_c_pos is correct, and an absolute
      cursor postion in multibyte mode, but a buffer index when not in a
      multibyte locale. */
@@ -1523,7 +1525,9 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
   /* We need to indicate that the cursor position is correct in the presence of
      invisible characters in the prompt string.  Let's see if setting this when
      we make sure we're at the end of the drawn prompt string works. */
-  if (current_line == 0 && MB_CUR_MAX > 1 && rl_byte_oriented == 0 && _rl_last_c_pos == prompt_physical_chars)
+  if (current_line == 0 && MB_CUR_MAX > 1 && rl_byte_oriented == 0 &&
+      (_rl_last_c_pos > 0 || o_cpos > 0) &&
+      _rl_last_c_pos == prompt_physical_chars)
     cpos_adjusted = 1;
 #endif
 #endif
@@ -1619,6 +1623,14 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
                 is a dumb update. */
              _rl_output_some_chars (nfd, temp);
              _rl_last_c_pos += col_temp;
+             /* If nfd begins before any invisible characters in the prompt,
+                adjust _rl_last_c_pos to account for wrap_offset and set
+                cpos_adjusted to let the caller know. */
+             if (current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible))
+               {
+                 _rl_last_c_pos -= wrap_offset;
+                 cpos_adjusted = 1;
+               }
              return;
            }
          /* Copy (new) chars to screen from first diff to last match. */
index 3efcf32d68e9722024b6ca9d67f9e81b2aa5ac04..72ec06a2c1fd8dde92acea5e8ac773e35f1d061b 100755 (executable)
@@ -1,4 +1,4 @@
-BUILD_DIR=/usr/local/build/chet/bash/bash-current
+BUILD_DIR=/usr/local/build/bash/bash-current
 THIS_SH=$BUILD_DIR/bash
 PATH=$PATH:$BUILD_DIR
 
index a7c8eb03c24afa861cf6c171b8375620acf3fd9d..7aac2b71c29917ead80eb761b6c751b980630086 100644 (file)
@@ -1186,20 +1186,21 @@ assign_random (self, value, unused)
 {
   sbrand (strtoul (value, (char **)NULL, 10));
   if (subshell_environment)
-    seeded_subshell = 1;
+    seeded_subshell = getpid ();
   return (self);
 }
 
 int
 get_random_number ()
 {
-  int rv;
+  int rv, pid;
 
   /* Reset for command and process substitution. */
-  if (subshell_environment && seeded_subshell == 0)
+  pid = getpid ();
+  if (subshell_environment && seeded_subshell != pid)
     {
-      sbrand (rseed + getpid() + NOW);
-      seeded_subshell = 1;
+      sbrand (rseed + pid + NOW);
+      seeded_subshell = pid;
     }
 
   do
index 3bb0ce796644a70a1c8a6591bf3b755384a3dfe8..a7c8eb03c24afa861cf6c171b8375620acf3fd9d 100644 (file)
 #include "posixstat.h"
 #include "posixtime.h"
 
-#if defined (qnx)
-#  if defined (qnx6)
+#if defined (__QNX__)
+#  if defined (__QNXNTO__)
 #    include <sys/netmgr.h>
 #  else
 #    include <sys/vc.h>
-#  endif /* !qnx6 */
-#endif /* qnx */
+#  endif /* !__QNXNTO__ */
+#endif /* __QNX__ */
 
 #if defined (HAVE_UNISTD_H)
 #  include <unistd.h>
@@ -391,11 +391,11 @@ initialize_shell_variables (env, privmode)
   set_auto_export (temp_var);  /* XXX */
 #endif
 
-#if defined (qnx)
+#if defined (__QNX__)
   /* set node id -- don't import it from the environment */
   {
     char node_name[22];
-#  if defined (qnx6)
+#  if defined (__QNXNTO__)
     netmgr_ndtostr(ND2S_LOCAL_STR, ND_LOCAL_NODE, node_name, sizeof(node_name));
 #  else
     qnx_nidtostr (getnid (), node_name, sizeof (node_name));
@@ -1861,10 +1861,10 @@ make_variable_value (var, value, flags)
        }
       rval = evalexp (value, &expok);
       if (expok == 0)
-        {
-          top_level_cleanup ();
+       {
+         top_level_cleanup ();
          jump_to_top_level (DISCARD);
-        }
+       }
       if (flags & ASS_APPEND)
        rval += lval;
       retval = itos (rval);