]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
commit bash-20150515 snapshot
authorChet Ramey <chet.ramey@case.edu>
Fri, 5 Jun 2015 15:48:51 +0000 (11:48 -0400)
committerChet Ramey <chet.ramey@case.edu>
Fri, 5 Jun 2015 15:48:51 +0000 (11:48 -0400)
15 files changed:
CWRU/CWRU.chlog
aclocal.m4
bashline.c
builtins/cd.def
configure
lib/readline/bind.c
lib/sh/shquote.c
lib/sh/strtrans.c
tests/RUN-ONE-TEST
tests/case.right
tests/case.tests
tests/intl.right
tests/new-exp.right
tests/new-exp.tests
tests/unicode3.sub

index 1edc56040fcc3cb3da411635cb150f1185b94248..5f52542640361795200f198b04a95a48fecd0a32 100644 (file)
@@ -8518,3 +8518,43 @@ subst.c
        - pat_subst: change to allow empty strings to be replaced as long as
          pattern matches empty string.  Report and fix from isabella parakiss
          <izaberina@gmail.com>
+
+                                  5/12
+                                  ----
+lib/sh/strtrans.c
+       - ansic_wshouldquote: make behavior consistent in the event of an
+         invalid multibyte sequence: return 1 to the caller so the string
+         will be $'...' quoted
+
+builtins/cd.def
+       - cd_builtin: print the right error message even if printable_filename
+         changes errno (e.g., EILSEQ)
+
+lib/sh/shquote.c
+       - sh_backslash_quote: in multibyte locales, even if is_basic does not
+         return true, backslash-quote an ASCII character that backslash_table
+         says should be quoted.  Part of fix for bug reported by Igor
+         Bogomazov <ygrex@ygrex.ru>
+
+bashline.c
+       - directory_exists: new function, dequotes the string argument, removes
+         any trailing slash, and returns true if the result is a valid
+         existing filename
+       - bash_filename_stat_hook,bash_directory_completion_hook: use
+         directory_exists instead of calling lstat/stat on the quoted
+         directory name.  Rest of fix for bug reported by Igor Bogomazov
+         <ygrex@ygrex.ru>
+
+                                  5/15
+                                  ----
+aclocal.m4
+       - BASH_CHECK_MULTIBYTE: when checking for locale_charset, add $LIBINTL to
+         $LIBS.  If we're using the included lib/intl/libintl.a, it will include
+         a version of locale_charset
+
+                                  5/17
+                                  ----
+lib/readline/bind.c
+       - sv_isrchterm: make sure we check for v[end] == 0 while in the loop
+         looking for whitespace.  Bug report and fix from Sergio Durigan
+         Junior <sergiodj@sergiodj.net>
index 105b886e3bd1b36bd5c87c46d9143da054c8e099..7730d2d9c11da72ec9a65796267a56d4dfe321ac 100644 (file)
@@ -1793,7 +1793,7 @@ fi
 
 if test "$am_cv_func_iconv" = yes; then
        OLDLIBS="$LIBS"
-       LIBS="$LIBS $LIBICONV"
+       LIBS="$LIBS $LIBINTL $LIBICONV"
        AC_CHECK_FUNCS(locale_charset)
        LIBS="$OLDLIBS"
 fi
index f81103aff6cab6d14a599e57f20a71285923c75b..1cef29efad1cf2207fca5635041f4c5d0570e037 100644 (file)
@@ -141,6 +141,8 @@ static int executable_completion __P((const char *, int));
 static rl_icppfunc_t *save_directory_hook __P((void));
 static void restore_directory_hook __P((rl_icppfunc_t));
 
+static int directory_exists __P((const char *));
+
 static void cleanup_expansion_error __P((void));
 static void maybe_make_readline_line __P((char *));
 static void set_up_new_line __P((char *));
@@ -3077,6 +3079,30 @@ restore_directory_hook (hookf)
     rl_directory_rewrite_hook = hookf;
 }
 
+/* Check whether not the (dequoted) version of DIRNAME, with any trailing slash
+   removed, exists. */
+static int
+directory_exists (dirname)
+     const char *dirname;
+{
+  char *new_dirname;
+  int dirlen, r;
+  struct stat sb;
+
+  /* First, dequote the directory name */
+  new_dirname = bash_dequote_filename (dirname, rl_completion_quote_character);
+  dirlen = STRLEN (new_dirname);
+  if (new_dirname[dirlen - 1] == '/')
+    new_dirname[dirlen - 1] = '\0';
+#if defined (HAVE_LSTAT)
+  r = lstat (new_dirname, &sb) == 0;
+#else
+  r = stat (new_dirname, &sb) == 0;
+#endif
+  free (new_dirname);
+  return (r);
+}
+  
 /* Expand a filename before the readline completion code passes it to stat(2).
    The filename will already have had tilde expansion performed. */
 static int
@@ -3095,11 +3121,7 @@ bash_filename_stat_hook (dirname)
   else if (t = mbschr (local_dirname, '`'))    /* XXX */
     should_expand_dirname = '`';
 
-#if defined (HAVE_LSTAT)
-  if (should_expand_dirname && lstat (local_dirname, &sb) == 0)
-#else
-  if (should_expand_dirname && stat (local_dirname, &sb) == 0)
-#endif
+  if (should_expand_dirname && directory_exists (local_dirname))
     should_expand_dirname = 0;
   
   if (should_expand_dirname)  
@@ -3163,7 +3185,8 @@ bash_directory_completion_hook (dirname)
      char **dirname;
 {
   char *local_dirname, *new_dirname, *t;
-  int return_value, should_expand_dirname, nextch, closer;
+  int return_value, should_expand_dirname, nextch, closer, changed;
+  size_t local_dirlen;
   WORD_LIST *wl;
   struct stat sb;
 
@@ -3192,11 +3215,7 @@ bash_directory_completion_hook (dirname)
        should_expand_dirname = '`';
     }
 
-#if defined (HAVE_LSTAT)
-  if (should_expand_dirname && lstat (local_dirname, &sb) == 0)
-#else
-  if (should_expand_dirname && stat (local_dirname, &sb) == 0)
-#endif
+  if (should_expand_dirname && directory_exists (local_dirname))
     should_expand_dirname = 0;
 
   if (should_expand_dirname)  
index a2ffd3330acced87b9b3301c7667587146d462da..43a181a8229b46caafb5b0e88b47fd5668734bf6 100644 (file)
@@ -262,7 +262,7 @@ cd_builtin (list)
      WORD_LIST *list;
 {
   char *dirname, *cdpath, *path, *temp;
-  int path_index, no_symlinks, opt, lflag;
+  int path_index, no_symlinks, opt, lflag, e;
 
 #if defined (RESTRICTED_SHELL)
   if (restricted)
@@ -437,8 +437,9 @@ cd_builtin (list)
        FREE (temp);
     }
 
+  e = errno;
   temp = printable_filename (dirname, 0);
-  builtin_error ("%s: %s", temp, strerror (errno));
+  builtin_error ("%s: %s", temp, strerror (e));
   if (temp != dirname)
     free (temp);
   return (EXECUTION_FAILURE);
index cf25ea2db36842a1700d0f11aa885e0a9bd41e1b..f289541b144b83afb71a2d9a862273feae041dd8 100755 (executable)
--- a/configure
+++ b/configure
@@ -11423,7 +11423,7 @@ fi
 
 if test "$am_cv_func_iconv" = yes; then
        OLDLIBS="$LIBS"
-       LIBS="$LIBS $LIBICONV"
+       LIBS="$LIBS $LIBINTL $LIBICONV"
        for ac_func in locale_charset
 do :
   ac_fn_c_check_func "$LINENO" "locale_charset" "ac_cv_func_locale_charset"
index 60af35acb4c1b3bda6a77b87baf47a2deaf885a5..f88e5aad55c10cecceacd94d5b6f5589760bff0a 100644 (file)
@@ -1859,7 +1859,7 @@ sv_isrchterm (value)
     }
   else
     {
-      for (beg = end = 0; whitespace (v[end]) == 0; end++)
+      for (beg = end = 0; v[end] && whitespace (v[end]) == 0; end++)
        ;
     }
 
index e009b37672e6cdfa3bbc50a7758f8d6d9f78fdb0..4f13ab399bd7dd59ee1ced3f6f3de3ae9d7dbe02 100644 (file)
@@ -246,6 +246,13 @@ sh_backslash_quote (string, table, flags)
   for (r = result, s = string; s && (c = *s); s++)
     {
 #if defined (HANDLE_MULTIBYTE)
+      /* XXX - isascii, even if is_basic(c) == 0 - works in most cases. */
+      if (c >= 0 && c <= 127 && backslash_table[(unsigned char)c] == 1)
+       {
+         *r++ = '\\';
+         *r++ = c;
+         continue;
+       }
       if (MB_CUR_MAX > 1 && is_basic (c) == 0)
        {
          COPY_CHAR_P (r, s, send);
index 02f5c89afd42e1c7ff2ddb3c0447d94e41b59296..3bed4a6120571ecd6a335d32645776567f34941a 100644 (file)
@@ -312,8 +312,9 @@ ansic_wshouldquote (string)
 
   slen = mbstowcs (wcstr, string, 0);
 
-  if (slen == -1)
-    slen = 0;
+  if (slen == (size_t)-1)
+    return 1;
+
   wcstr = (wchar_t *)xmalloc (sizeof (wchar_t) * (slen + 1));
   mbstowcs (wcstr, string, slen + 1);
 
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
 
index 58ab2a4faf08271a94d8c2568f7526e767557176..a17234b9f28f08c97eb0ca6c32c3b85313f2ae9d 100644 (file)
@@ -7,6 +7,13 @@ no more clauses
 1.0
 ./case.tests: line 29: xx: readonly variable
 1.1
+matches 1
+no
+no
+no
+no
+no
+ok
 ok 1
 ok 2
 ok 3
index 547e8ccd61d5613e93151d995fd29fa9147d7d8f..7ab316a7e7e010f3d48d7a6501448794b22dd25a 100644 (file)
@@ -29,5 +29,25 @@ readonly xx=1
 case 1 in $((xx++)) ) echo hi1 ;; *) echo hi2; esac
 echo ${xx}.$?
 
+unset var empty
+
+var=
+case ']' in
+[$var]*[$var]) echo matches 1;;
+*)             echo no match 1 ;;
+esac
+
+case abc in ( [] ) echo yes ;; ( * ) echo no ;; esac
+empty=''
+case abc in ( ["$empty"] ) echo yes ;; ( * ) echo no ;; esac
+
+case abc in ( [] | [!a-z]* ) echo yes ;; ( * ) echo no ;; esac
+empty=''
+case abc in ( ["$empty"] | [!a-z]* ) echo yes ;; ( * ) echo no ;; esac
+
+case abc in (["$empty"]|[!a-z]*) echo yes ;; (*) echo no ;; esac
+
+case " " in ( [" "] ) echo ok;; ( * ) echo no;; esac
+
 # tests of quote removal and pattern matching
 ${THIS_SH} ./case1.sub
index df160e1fa6e09d9019ac98b945373d864346d7c6..006318e59e22b9288f2a0059530f62fe63551012 100644 (file)
@@ -50,6 +50,7 @@ Passed all 1378 Unicode tests
 0000003
 0000000 101 040 302 243 040 305 222 012
 0000010
-./unicode3.sub: line 2: 5§@3\99+ÆS8\9f¢ê³: command not found
-5§@3\99+ÆS8\9f¢ê³
+./unicode3.sub: line 3: $'5\247@3\231+\306S8\237\242\352\263': command not found
+./unicode3.sub: line 5: cd: $'5\247@3\231+\306S8\237\242\352\263': No such file or directory
+$'5\247@3\231+\306S8\237\242\352\263'
 + : $'5\247@3\231+\306S8\237\242\352\263'
index 7366e07aea49e83f21dd6110f609577d9059d8e5..b4e2a8e4e0e3c3ced9831e8b9a26124d74accc6c 100644 (file)
@@ -254,6 +254,12 @@ argv[1] = <endocrine>
 argv[1] = <endocrine>
 argv[1] = <endocrine>
 argv[1] = <endocrine>
+x
+x
+x
+xabc
+x
+x
 argv[1] = </usr/bin>
 argv[2] = </bin>
 argv[3] = </usr/local/bin>
@@ -405,13 +411,13 @@ argv[6] = <w>
 argv[7] = <x>
 argv[8] = <y>
 argv[9] = <z>
-./new-exp.tests: line 490: $9: unbound variable
-./new-exp.tests: line 491: 9: unbound variable
-./new-exp.tests: line 492: UNSET: unbound variable
-./new-exp.tests: line 493: UNSET: unbound variable
-./new-exp.tests: line 494: UNSET: unbound variable
-./new-exp.tests: line 495: UNSET: unbound variable
-./new-exp.tests: line 496: UNSET: unbound variable
+./new-exp.tests: line 503: $9: unbound variable
+./new-exp.tests: line 504: 9: unbound variable
+./new-exp.tests: line 505: UNSET: unbound variable
+./new-exp.tests: line 506: UNSET: unbound variable
+./new-exp.tests: line 507: UNSET: unbound variable
+./new-exp.tests: line 508: UNSET: unbound variable
+./new-exp.tests: line 509: UNSET: unbound variable
 argv[1] = <5>
 argv[1] = <#>
 argv[1] = <#>
@@ -440,7 +446,7 @@ Case05---3---A:B:C---
 Case06---1---A B C::---
 Case07---3---A:B:C---
 Case08---3---A:B:C---
-./new-exp.tests: line 516: ${$(($#-1))}: bad substitution
+./new-exp.tests: line 529: ${$(($#-1))}: bad substitution
 argv[1] = <a>
 argv[2] = <b>
 argv[3] = <c>
@@ -457,7 +463,7 @@ argv[1] = <a>
 argv[1] = <a>
 argv[2] = <b>
 argv[1] = <>
-./new-exp.tests: line 535: $(($# - 2)): substring expression < 0
+./new-exp.tests: line 548: $(($# - 2)): substring expression < 0
 argv[1] = <bin>
 argv[2] = <bin>
 argv[3] = <ucb>
@@ -621,4 +627,4 @@ a b c d e
 a5b
 argv[1] = </>
 argv[1] = </>
-./new-exp.tests: line 595: ABXD: parameter unset
+./new-exp.tests: line 608: ABXD: parameter unset
index 666d8a9d2452ef752bb10bc528c72d223ccd4450..c4aa9d167b5bb5440419af8f96c1c65b0f15fa25 100644 (file)
@@ -452,6 +452,19 @@ recho ${xxx//%${zzz}}
 recho ${xxx//#${zzz}/}
 recho ${xxx//#${zzz}}
 
+# make sure null strings are replaced appropriately
+unset var
+var=
+echo "${var/#/x}"
+echo "${var/*/x}"
+echo "${var//*/x}"
+
+var=abc
+echo "${var/#/x}"
+echo "${var/*/x}"
+echo "${var//*/x}"
+unset var
+
 # another case that caused a core dump in bash-2.0
 XPATH=/usr/bin:/bin:/usr/local/bin:/usr/gnu/bin::/usr/bin/X11:/sbin:/usr/sbin
 
index f79871f613ad562cf3c4e02457893078a9b3c306..b39f1d3ca58c48cffa5c3ef3c97ca5fd58e80ce7 100644 (file)
@@ -1,6 +1,8 @@
+export LANG=en_US.UTF-8        # make sure
 payload=$'\065\247\100\063\231\053\306\123\070\237\242\352\263'
 "$payload"
 
+cd "$payload"
 printf %q "$payload"
 echo