mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-08-11 04:30:44 +02:00
more changes to avoid expanding associative array subscripts twice; internal debugging changes
This commit is contained in:
+1
-1
@@ -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
|
||||
|
||||
|
||||
@@ -352,3 +352,34 @@ declare -A var=([two]=$'ab\001cd' [one]=$'\001\001\001\001' )
|
||||
declare -A foo=([two]=$'ab\001cd' [one]=$'\001\001\001\001' )
|
||||
declare -A foo=([$'\001']=$'ab\001cd' )
|
||||
declare -A foo=([$'\001']=$'\001\001\001\001' )
|
||||
declare -A A=(["\$(echo Darwin ; echo stderr>&2)"]="darjeeling" [Darwin]="darjeeling" )
|
||||
stderr
|
||||
darjsharking
|
||||
darjsharking
|
||||
stderr
|
||||
darj
|
||||
darj
|
||||
stderr
|
||||
DARJEELING
|
||||
DARJEELING
|
||||
stderr
|
||||
'darjeeling'
|
||||
'darjeeling'
|
||||
stderr
|
||||
darjeel
|
||||
darjeel
|
||||
stderr
|
||||
10
|
||||
10
|
||||
stderr
|
||||
darjeeling
|
||||
darjeeling
|
||||
stderr
|
||||
set
|
||||
set
|
||||
stderr
|
||||
set
|
||||
set
|
||||
stderr
|
||||
42
|
||||
42
|
||||
|
||||
@@ -256,3 +256,6 @@ ${THIS_SH} ./assoc14.sub
|
||||
|
||||
# tests with subscripts and values containing 0x01 (some indexed array tests too)
|
||||
${THIS_SH} ./assoc15.sub
|
||||
|
||||
# tests with subscripts being expanded more than one in ${xxx} word expansions
|
||||
${THIS_SH} ./assoc16.sub
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
# bash versions up to and including bash-5.1 expanded these subscripts more
|
||||
# than once
|
||||
|
||||
declare -A A
|
||||
|
||||
A["Darwin"]=darjeeling
|
||||
A['$(echo Darwin ; echo stderr>&2)']=darjeeling
|
||||
|
||||
declare -p A
|
||||
|
||||
echo ${A[$(echo Darwin ; echo stderr>&2)]//eel/shark}
|
||||
echo ${A['$(echo Darwin ; echo stderr>&2)']//eel/shark}
|
||||
|
||||
echo ${A[$(echo Darwin ; echo stderr>&2)]:0:4}
|
||||
echo ${A['$(echo Darwin ; echo stderr>&2)']:0:4}
|
||||
|
||||
echo ${A[$(echo Darwin ; echo stderr>&2)]^^}
|
||||
echo ${A['$(echo Darwin ; echo stderr>&2)']^^}
|
||||
|
||||
echo ${A[$(echo Darwin ; echo stderr>&2)]@Q}
|
||||
echo ${A['$(echo Darwin ; echo stderr>&2)']@Q}
|
||||
|
||||
echo ${A[$(echo Darwin ; echo stderr>&2)]%ing}
|
||||
echo ${A['$(echo Darwin ; echo stderr>&2)']%ing}
|
||||
|
||||
echo ${#A[$(echo Darwin ; echo stderr>&2)]}
|
||||
echo ${#A['$(echo Darwin ; echo stderr>&2)']}
|
||||
|
||||
echo ${A[$(echo Darwin ; echo stderr>&2)]:-value}
|
||||
echo ${A['$(echo Darwin ; echo stderr>&2)']:-value}
|
||||
|
||||
echo ${A[$(echo Darwin ; echo stderr>&2)]:+set}
|
||||
echo ${A['$(echo Darwin ; echo stderr>&2)']:+set}
|
||||
|
||||
echo ${A[$(echo Darwin ; echo stderr>&2)]:+set}
|
||||
echo ${A['$(echo Darwin ; echo stderr>&2)']:+set}
|
||||
|
||||
darjeeling=7*6
|
||||
Darwin=7*4
|
||||
|
||||
echo $(( ${A[$(echo Darwin ; echo stderr>&2)]} ))
|
||||
echo $(( ${A['$(echo Darwin ; echo stderr>&2)']} ))
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
#
|
||||
|
||||
# this is a new feature: expanding aliases when initially parsing command
|
||||
# substiitutions
|
||||
# substitutions
|
||||
|
||||
shopt -s expand_aliases
|
||||
|
||||
|
||||
+7
-1
@@ -120,7 +120,13 @@ argv[3] = <ve>
|
||||
5: ${x#$pat}
|
||||
6: ${y#$'not'}
|
||||
7: ${y#'not'}
|
||||
foo bar
|
||||
./heredoc7.sub: line 21: after: command not found
|
||||
./heredoc7.sub: line 29: warning: here-document at line 29 delimited by end-of-file (wanted `EOF')
|
||||
./heredoc7.sub: line 29: foobar: command not found
|
||||
./heredoc7.sub: line 29: EOF: command not found
|
||||
grep: *.c: No such file or directory
|
||||
comsub here-string
|
||||
./heredoc.tests: line 152: warning: here-document at line 150 delimited by end-of-file (wanted `EOF')
|
||||
./heredoc.tests: line 156: warning: here-document at line 154 delimited by end-of-file (wanted `EOF')
|
||||
hi
|
||||
there
|
||||
|
||||
@@ -140,6 +140,10 @@ ${THIS_SH} ./heredoc5.sub
|
||||
# test $'...' and $"..." quoted strings in here-documents
|
||||
${THIS_SH} ./heredoc6.sub
|
||||
|
||||
# interaction between here-documents and command substitutions
|
||||
${THIS_SH} ./heredoc7.sub
|
||||
|
||||
|
||||
echo $(
|
||||
cat <<< "comsub here-string"
|
||||
)
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
# should characters outside a command substitution be interpreted as a delimiter
|
||||
# for a here-document started inside it?
|
||||
echo $(cat << EOF)
|
||||
foo
|
||||
bar
|
||||
EOF
|
||||
after
|
||||
|
||||
# should characters inside a command substitution be interpreted as a delimiter
|
||||
# for a here-document started outside of it?
|
||||
|
||||
cat <<EOF && grep $(
|
||||
foobar
|
||||
EOF
|
||||
echo notthereanywhere) *.c
|
||||
Reference in New Issue
Block a user