diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index 05b025db..3a6d4832 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -4570,3 +4570,20 @@ trap.c increment/decrement evalnest accordingly, since trap actions are processed as if run by `eval'. Feature suggsted by Mike Gerwitz + + 10/16 + ----- +expr.c + - expr_skipsubscript: new function, calls skipsubscript with flags + similar to arrayfunc.c:valid_array_subscript if assoc_expand_once + is set and it looks like we've already expanded the subscript of + an associative array. Reported back on 8/27 by Grisha Levit + + - readtok: call expr_skipsubscript instead of skipsubscript + +arrayfunc.c + - valid_array_reference: call skipsubscript with a third arg computed + from the VA_NOEXPAND flag only if we're expanding an associative + array subscript -- we already figure out whether or not we are + +[bumped release status to beta2] diff --git a/arrayfunc.c b/arrayfunc.c index c635e74c..71e4acfd 100644 --- a/arrayfunc.c +++ b/arrayfunc.c @@ -779,7 +779,7 @@ unbind_array_element (var, sub, flags) char *akey; ARRAY_ELEMENT *ae; - len = skipsubscript (sub, 0, (flags&1) || (var && assoc_p(var))); + len = skipsubscript (sub, 0, (flags&1) || (var && assoc_p(var))); /* XXX */ if (sub[len] != ']' || len == 0) { builtin_error ("%s[%s: %s", var->name, sub, _(bash_badsub_errmsg)); @@ -915,9 +915,12 @@ valid_array_reference (name, flags) if (isassoc && ((flags & (VA_NOEXPAND|VA_ONEWORD)) == (VA_NOEXPAND|VA_ONEWORD))) len = strlen (t) - 1; + else if (isassoc) + len = skipsubscript (t, 0, flags&VA_NOEXPAND); /* VA_NOEXPAND must be 1 */ else /* Check for a properly-terminated non-null subscript. */ - len = skipsubscript (t, 0, flags&VA_NOEXPAND); /* VA_NOEXPAND must be 1 */ + len = skipsubscript (t, 0, 0); /* arithmetic expression */ + if (t[len] != ']' || len == 1 || t[len+1] != '\0') return 0; diff --git a/configure b/configure index 76326a12..3319525e 100755 --- a/configure +++ b/configure @@ -1,7 +1,7 @@ #! /bin/sh # From configure.ac for Bash 5.0, version 5.003. # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for bash 5.0-beta. +# Generated by GNU Autoconf 2.69 for bash 5.0-beta2. # # Report bugs to . # @@ -581,8 +581,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='bash' PACKAGE_TARNAME='bash' -PACKAGE_VERSION='5.0-beta' -PACKAGE_STRING='bash 5.0-beta' +PACKAGE_VERSION='5.0-beta2' +PACKAGE_STRING='bash 5.0-beta2' PACKAGE_BUGREPORT='bug-bash@gnu.org' PACKAGE_URL='' @@ -1394,7 +1394,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures bash 5.0-beta to adapt to many kinds of systems. +\`configure' configures bash 5.0-beta2 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1459,7 +1459,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of bash 5.0-beta:";; + short | recursive ) echo "Configuration of bash 5.0-beta2:";; esac cat <<\_ACEOF @@ -1655,7 +1655,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -bash configure 5.0-beta +bash configure 5.0-beta2 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2364,7 +2364,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by bash $as_me 5.0-beta, which was +It was created by bash $as_me 5.0-beta2, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2759,7 +2759,7 @@ ac_config_headers="$ac_config_headers config.h" BASHVERS=5.0 -RELSTATUS=beta +RELSTATUS=beta2 case "$RELSTATUS" in alp*|bet*|dev*|rc*|releng*|maint*) DEBUG='-DDEBUG' MALLOC_DEBUG='-DMALLOC_DEBUG' ;; @@ -16821,7 +16821,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by bash $as_me 5.0-beta, which was +This file was extended by bash $as_me 5.0-beta2, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -16887,7 +16887,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -bash config.status 5.0-beta +bash config.status 5.0-beta2 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index e848b7f7..38a06a0c 100644 --- a/configure.ac +++ b/configure.ac @@ -24,7 +24,7 @@ dnl Process this file with autoconf to produce a configure script. AC_REVISION([for Bash 5.0, version 5.003])dnl define(bashvers, 5.0) -define(relstatus, beta) +define(relstatus, beta2) AC_INIT([bash], bashvers-relstatus, [bug-bash@gnu.org]) diff --git a/expr.c b/expr.c index 4a1f6070..3f086b63 100644 --- a/expr.c +++ b/expr.c @@ -340,6 +340,27 @@ expr_bind_variable (lhs, rhs) } #if defined (ARRAY_VARS) +/* This is similar to the logic in arrayfunc.c:valid_array_subscript when + you pass VA_NOEXPAND. */ +static char * +expr_skipsubscript (vp, cp) + char *vp, *cp; +{ + int flags, isassoc; + SHELL_VAR *entry; + + isassoc = 0; + entry = 0; + if (assoc_expand_once & already_expanded) + { + *cp = '\0'; + isassoc = legal_identifier (vp) && (entry = find_variable (vp)) && assoc_p (entry); + *cp = '['; /* ] */ + } + flags = (isassoc && assoc_expand_once && already_expanded) ? VA_NOEXPAND : 0; + return (skipsubscript (cp, 0, flags)); +} + /* Rewrite tok, which is of the form vname[expression], to vname[ind], where IND is the already-calculated value of expression. */ static void @@ -1316,7 +1337,7 @@ readtok () #if defined (ARRAY_VARS) if (c == '[') { - e = skipsubscript (cp, 0, 1); /* XXX - arg 3 was 0 */ + e = expr_skipsubscript (tp, cp); /* XXX - was skipsubscript */ if (cp[e] == ']') { cp += e + 1; diff --git a/tests/array.right b/tests/array.right index b7a244e6..5d3e2995 100644 --- a/tests/array.right +++ b/tests/array.right @@ -530,6 +530,9 @@ foo 6 ./array23.sub: line 21: $( echo >&2 foo ): syntax error: operand expected (error token is "$( echo >&2 foo )") ./array23.sub: line 22: $( echo >&2 foo ): syntax error: operand expected (error token is "$( echo >&2 foo )") +0 +0 +0 IFS=: ${var-$*} abc def ghi diff --git a/tests/array23.sub b/tests/array23.sub index a762aadb..bd64fe1f 100644 --- a/tests/array23.sub +++ b/tests/array23.sub @@ -20,3 +20,9 @@ typeset -a a echo $((1+a[$index])) echo $((1+a[\$index])) echo "1+${a[$index]}" + +# intermediate problems discovered while bash-5.0 was in testing +a=0 +echo $(( a[a[0]] )) +echo ${a[a[a[0]]]} +echo $(( a[a[a[0]]] )) diff --git a/tests/exec.right b/tests/exec.right index 81224fa5..6075cc86 100644 --- a/tests/exec.right +++ b/tests/exec.right @@ -84,9 +84,9 @@ after exit code: 1 exit code: 1 exit code: 1 -exit code: 127 -exit code: 127 -exit code: 127 +exit code: 1 +exit code: 1 +exit code: 1 a b c diff --git a/tests/exec12.sub b/tests/exec12.sub index bc627d2d..79bcfc77 100644 --- a/tests/exec12.sub +++ b/tests/exec12.sub @@ -4,7 +4,8 @@ trap 'rm -f $TMPFILE' 0 rm -f $TMPFILE set -e -exit_handler() { echo "exit code: $?" ; touch $TMPFILE; } +# we normalize the exit code to accommodate false returning 255 on Solaris +exit_handler() { echo "exit code: $(( $? != 0 ))" ; touch $TMPFILE; } false() { ! :; } notfound() { nosuchcommand ; } syntaxerror() { !:; } diff --git a/trap.c b/trap.c index ceb83951..f42e1e8c 100644 --- a/trap.c +++ b/trap.c @@ -315,7 +315,7 @@ run_pending_traps () #endif /* could check for running the trap handler for the same signal here (running_trap == sig+1) */ - if (evalnest_max && evalnest > evalnest_max) + if (evalnest_max > 0 && evalnest > evalnest_max) { internal_error (_("trap handler: maximum trap handler level exceeded (%d)"), evalnest_max); evalnest = 0;