mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-15 16:10:50 +02:00
commit bash-20200323 snapshot
This commit is contained in:
+5
-13
@@ -442,17 +442,13 @@ declare -a foo=([0]="[0]=bar")
|
||||
declare -a foo=([0]="[0]=bar")
|
||||
declare -- a="(1 2 3)"
|
||||
declare -a a=([0]="1" [1]="2" [2]="3")
|
||||
./array19.sub: line 59: a: 1: must use subscript when assigning associative array
|
||||
./array19.sub: line 59: a: 2: must use subscript when assigning associative array
|
||||
./array19.sub: line 59: a: 3: must use subscript when assigning associative array
|
||||
declare -A a=()
|
||||
declare -- a="([0]=a [1]=b)"
|
||||
declare -a a=([0]="a" [1]="b")
|
||||
declare -A a=([1]="b" [0]="a" )
|
||||
declare -a var=([0]="[\$(echo" [1]="total" [2]="0)]=1" [3]="[2]=2]")
|
||||
declare -a var=([0]="[\$(echo total 0)]=1 [2]=2]")
|
||||
declare -a var=([0]="[\$(echo" [1]="total" [2]="0)]=1" [3]="[2]=2]")
|
||||
./array19.sub: line 94: total 0: syntax error in expression (error token is "0")
|
||||
./array19.sub: line 89: total 0: syntax error in expression (error token is "0")
|
||||
declare -a var=()
|
||||
declare -al foo=([0]="abcde" [1]="two" [2]="three")
|
||||
declare -al foo=([0]="abcde")
|
||||
@@ -460,7 +456,7 @@ declare -al ar=([0]="one" [1]="two" [2]="three")
|
||||
declare -a a=([2]="foo")
|
||||
declare -a a=([2]="foo")
|
||||
declare -a a=([1]="(var)" [2]="foo")
|
||||
./array19.sub: line 133: warning: a[1]=(var): quoted compound array assignment deprecated
|
||||
./array19.sub: line 128: warning: a[1]=(var): quoted compound array assignment deprecated
|
||||
declare -a a=([1]="(var)")
|
||||
declare -a a=([0]="1" [1]="2" [2]="(1 2 3)")
|
||||
declare -a a=([0]="1" [1]="2" [2]="(1 2 3)")
|
||||
@@ -477,15 +473,11 @@ declare -a b=([0]="/scratch/bash")
|
||||
declare -a c=([0]="1" [1]="2")
|
||||
declare -a d=([0]="a" [1]="b")
|
||||
declare -a e=([0]="Darwin")
|
||||
./array19.sub: line 179: c: 1: must use subscript when assigning associative array
|
||||
./array19.sub: line 179: c: 2: must use subscript when assigning associative array
|
||||
./array19.sub: line 179: d: $a: must use subscript when assigning associative array
|
||||
./array19.sub: line 179: e: $(echo Darwin): must use subscript when assigning associative array
|
||||
declare -A a=([0]="a b" )
|
||||
declare -A b=([0]="/scratch/bash" )
|
||||
declare -A c=()
|
||||
declare -A d=()
|
||||
declare -A e=()
|
||||
declare -A c=([1]="2" )
|
||||
declare -A d=(["a b"]="" )
|
||||
declare -A e=([Darwin]="" )
|
||||
a+b+c
|
||||
x+b+c
|
||||
a+b+c
|
||||
|
||||
@@ -55,11 +55,6 @@ declare a='(1 2 3)'
|
||||
declare -p a
|
||||
unset a
|
||||
|
||||
declare -A a
|
||||
declare a='(1 2 3)'
|
||||
declare -p a
|
||||
unset a
|
||||
|
||||
declare a='([0]=a [1]=b)'
|
||||
declare -p a
|
||||
unset a
|
||||
|
||||
@@ -231,3 +231,21 @@ f: declare -a a
|
||||
main: declare -- a="7"
|
||||
f: declare -A a
|
||||
main: declare -- a="42"
|
||||
declare -A a=([3]="" [1]="2" )
|
||||
declare -A foo=([d]="4" [c]="3" [b]="2" [a]="1" )
|
||||
foo=( d "4" c "3" b "2" a "1" )
|
||||
declare -A foo=(["spa ces"]="2" ["\\"]="5" ["@"]="3" ["holy hell this works"]="4" ["a b"]="1" )
|
||||
foo=( echo "spa ces" "2" "\\" "5" "@" "3" "holy hell this works" "4" "a b" "1" )
|
||||
./assoc11.sub: line 34: "": bad array subscript
|
||||
declare -A foo=(["foo[bar"]="bleh" [";"]="semicolon" ["]"]="def" [a=b]="assignment" ["a]a"]="abc" )
|
||||
foo=( "foo[bar" "bleh" ";" "semicolon" "]" "def" a=b "assignment" "a]a" "abc" )
|
||||
declare -A foo=(["'"]="squote" ["\""]="dquote" ["\\"]="bslash" ["\`"]="backquote" )
|
||||
foo=( "'" "squote" "\"" "dquote" "\\" "bslash" "\`" "backquote" )
|
||||
declare -A foo=(["bar]bie"]="doll" ["a]=test1;#a"]="123" ["bar\"bie"]="doll" )
|
||||
foo=( "bar]bie" "doll" "a]=test1;#a" "123" "bar\"bie" "doll" )
|
||||
declare -A inside=([c]="3" [b]="2" [a]="1" )
|
||||
inside=( c "3" b "2" a "1" )
|
||||
declare -A dict=(["?"]="quest" ["*"]="star" ["'"]="squote" ["\$"]="dol" ["\""]="dquote" ["\\"]="bslash" ["@"]="at" ["}"]="rbrace" ["{"]="lbrace" ["\`"]="bquote" )
|
||||
dict=( "?" "quest" "*" "star" "'" "squote" "\$" "dol" "\"" "dquote" "\\" "bslash" "@" "at" "}" "rbrace" "{" "lbrace" "\`" "bquote" )
|
||||
declare -A foo=([two]="" [one]="1" )
|
||||
foo=( two "" one "1" )
|
||||
|
||||
@@ -241,3 +241,6 @@ ${THIS_SH} ./assoc8.sub
|
||||
${THIS_SH} ./assoc9.sub
|
||||
|
||||
${THIS_SH} ./assoc10.sub
|
||||
|
||||
# test assigning associative arrays using compound key/value pair assignments
|
||||
${THIS_SH} ./assoc11.sub
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
# 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/>.
|
||||
#
|
||||
# these tests were previously in array19.sub, but they are acceptable syntax now
|
||||
|
||||
declare -A a
|
||||
declare a='(1 2 3)'
|
||||
declare -p a
|
||||
unset a
|
||||
|
||||
declare -A foo
|
||||
|
||||
v1='spa ces'
|
||||
v2=@
|
||||
|
||||
foo=(a 1 b 2 c 3 d 4 )
|
||||
declare -p foo
|
||||
echo foo=\( ${foo[@]@K} \)
|
||||
|
||||
foo=('a b' 1 "$v1" 2 "$v2" 3 'holy hell this works' 4 \\ 5)
|
||||
declare -p foo
|
||||
echo foo=\( echo ${foo[@]@K} \)
|
||||
|
||||
foo=( "" null )
|
||||
|
||||
foo=('a]a' abc ']' def $(echo 'foo[bar') bleh \; semicolon a=b assignment)
|
||||
declare -p foo
|
||||
echo foo=\( ${foo[@]@K} \)
|
||||
|
||||
foo=('`' backquote '"' dquote "'" squote \\ bslash)
|
||||
declare -p foo
|
||||
echo foo=\( ${foo[@]@K} \)
|
||||
|
||||
bar='a]=test1;#a'
|
||||
foo=( $bar 123 bar\"bie doll bar]bie doll )
|
||||
declare -p foo
|
||||
echo foo=\( ${foo[@]@K} \)
|
||||
|
||||
func()
|
||||
{
|
||||
declare -A inside=(a 1 b 2 c 3)
|
||||
declare -p inside
|
||||
echo inside=\( ${inside[@]@K} \)
|
||||
}
|
||||
func
|
||||
|
||||
loaddict()
|
||||
{
|
||||
dict=( '"' dquote '`' bquote "'" squote '\' bslash)
|
||||
dict+=( '$' dol @ at * star \{ lbrace \} rbrace ? quest)
|
||||
|
||||
declare -p dict
|
||||
echo dict=\( ${dict[@]@K} \)
|
||||
}
|
||||
declare -A dict
|
||||
loaddict
|
||||
|
||||
foo=(one 1 two)
|
||||
declare -p foo
|
||||
echo foo=\( ${foo[@]@K} \)
|
||||
+7
-1
@@ -701,7 +701,13 @@ aaa bbb
|
||||
'aaa' 'bbb'
|
||||
a bbb
|
||||
aaa bb
|
||||
'string'
|
||||
'value with spaces'
|
||||
'a b' 'c d' 'e f'
|
||||
'a b' 'c d' 'e f'
|
||||
0 "zero" 1 "one" 2 "two" 3 "three"
|
||||
0 "zero z" 1 "one o" 2 "two t" 3 "three t"
|
||||
argv[1] = </>
|
||||
argv[1] = </>
|
||||
|
||||
./new-exp.tests: line 643: ABXD: parameter unset
|
||||
./new-exp.tests: ABXD: parameter unset
|
||||
|
||||
+4
-2
@@ -623,6 +623,9 @@ ${THIS_SH} ./new-exp12.sub
|
||||
# more indirect expansion and parameter transformation issues
|
||||
${THIS_SH} ./new-exp13.sub
|
||||
|
||||
# new K parameter transformation operator
|
||||
${THIS_SH} ./new-exp14.sub
|
||||
|
||||
# problems with stray CTLNUL in bash-4.0-alpha
|
||||
unset a
|
||||
a=/a
|
||||
@@ -638,6 +641,5 @@ patfunc foo
|
||||
# caused core dumps because of bad bracket expression parsing in bash-5.0
|
||||
eval : $'${x/#[0\xef\xbf\xbd\\Z[:]]}'
|
||||
|
||||
# this must be last!
|
||||
expect $0: 'ABXD: parameter unset'
|
||||
recho ${ABXD:?"parameter unset"}
|
||||
${THIS_SH} -c 'recho ${ABXD:?"parameter unset"}' $0
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
# test the other uses of the 'K' tranform operator
|
||||
# the associative array tests are performed separately, since that was the
|
||||
# original motivation for this feature
|
||||
foo=string
|
||||
bar='value with spaces'
|
||||
|
||||
set -- 'a b' 'c d' 'e f'
|
||||
|
||||
echo ${foo@K}
|
||||
echo ${bar@K}
|
||||
|
||||
echo ${@@K}
|
||||
echo "${@@K}"
|
||||
|
||||
foo=( zero one two three )
|
||||
echo ${foo[@]@K}
|
||||
|
||||
foo=( 'zero z' 'one o' 'two t' 'three t' )
|
||||
echo ${foo[@]@K}
|
||||
@@ -26,3 +26,8 @@ extern
|
||||
0
|
||||
0
|
||||
123
|
||||
bar1
|
||||
ouch
|
||||
bar2
|
||||
foo
|
||||
subshell
|
||||
|
||||
@@ -102,6 +102,7 @@ echo extern
|
||||
FN=$TMPDIR/bashtest-$$
|
||||
cat >$FN << \EOF
|
||||
wc -l < $1
|
||||
case $1 in *sh-np*) [ -e $1 ] || { echo 0; echo 0; echo 0; echo 0; return; } ;; esac
|
||||
wc -l < $1
|
||||
wc -l < $1
|
||||
true | wc -l < $1
|
||||
@@ -117,3 +118,4 @@ moo() { ls -al "$1" >/dev/null; (true); ls -al "$1" >/dev/null; }; moo >(true)
|
||||
unset -f moo
|
||||
|
||||
${THIS_SH} ./procsub1.sub
|
||||
${THIS_SH} ./procsub2.sub
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
# 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/>.
|
||||
#
|
||||
|
||||
# test whether or not we remove FIFOs and close pipe file descriptors too
|
||||
# aggressively
|
||||
|
||||
ouch()
|
||||
{
|
||||
while read foo; do echo "$foo"; done < <(echo bar1)
|
||||
cat "$1"
|
||||
}
|
||||
|
||||
ouch <(echo ouch )
|
||||
|
||||
ouch2()
|
||||
{
|
||||
{ cat; } < <(echo bar2)
|
||||
cat "$1"
|
||||
}
|
||||
|
||||
exec 4< <(echo subshell)
|
||||
ouch2 <(echo foo )
|
||||
|
||||
read var <&4
|
||||
echo $var
|
||||
Reference in New Issue
Block a user