- 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>
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
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 *));
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
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)
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;
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)
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)
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);
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"
}
else
{
- for (beg = end = 0; whitespace (v[end]) == 0; end++)
+ for (beg = end = 0; v[end] && whitespace (v[end]) == 0; end++)
;
}
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);
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);
-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
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
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
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'
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>
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] = <#>
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>
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>
a5b
argv[1] = </>
argv[1] = </>
-./new-exp.tests: line 595: ABXD: parameter unset
+./new-exp.tests: line 608: ABXD: parameter unset
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
+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