commit bash-20150320 snapshot

This commit is contained in:
Chet Ramey
2015-03-25 10:08:06 -04:00
parent 0568080fce
commit 06c3a57511
35 changed files with 460 additions and 80 deletions
+1 -1
View File
@@ -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
+52 -9
View File
@@ -33,6 +33,9 @@ declare -ar a=([1]="" [2]="bdef" [5]="hello world" [6]="test expression" [15]="t
declare -ar c
readonly -a a=([1]="" [2]="bdef" [5]="hello world" [6]="test expression" [15]="test 2")
readonly -a c
./array.tests: line 86: warning: d=([1]="" [2]="bdef" [5]="hello world" "test"): quoted compound array assignment deprecated
./array.tests: line 90: warning: e[10]=(test): quoted compound array assignment deprecated
./array.tests: line 93: warning: f=("${d[@]}"): quoted compound array assignment deprecated
a test
declare -a BASH_ARGC=()
declare -a BASH_ARGV=()
@@ -44,7 +47,7 @@ declare -ar a=([1]="" [2]="bdef" [5]="hello world" [6]="test expression" [15]="t
declare -a b=([0]="this" [1]="is" [2]="a" [3]="test" [4]="" [5]="/etc/passwd")
declare -ar c
declare -a d=([1]="" [2]="bdef" [5]="hello world" [6]="test" [9]="ninth element")
declare -a e=([10]="(test)")
declare -a e=([0]="test")
declare -a f=([0]="" [1]="bdef" [2]="hello world" [3]="test" [4]="ninth element")
./array.tests: line 100: a: readonly variable
./array.tests: line 102: b[]: bad array subscript
@@ -367,7 +370,7 @@ function function
declare -a x=([0]="0" [1]="1" [2]="2" [3]="3" [4]="4" [5]="5")
declare -a x=([0]="0" [1]="1" [2]="2" [3]="3" [4]="4")
declare -a x=([0]="0" [1]="1" [2]="2" [4]="4")
./array14.sub: line 11: [-10]: bad array subscript
./array14.sub: line 11: unset: [-10]: bad array subscript
declare -a x=([0]="0" [1]="1" [2]="2" [3]="3" [4]="4")
declare -a x=([0]="0" [1]="1" [2]="2" [3]="3" [4]="4" [5]="five")
declare -a x=([0]="0" [1]="1" [2]="2" [3]="3" [4]="4" [5]="5")
@@ -376,8 +379,10 @@ declare -a x=([0]="0" [1]="1" [2]="2" [3]="3" [4]="4" [5]="5")
declare -a x=([0]="0" [1]="1" [2]="2" [3]="3" [4]="4four" [5]="5")
strlen(4four) = 5
1 2 0 3
./array15.sub: line 6: warning: foo=(1 2 xx 3): quoted compound array assignment deprecated
1 2 0 3
1 2 0 3
./array15.sub: line 14: warning: foo=(1 2 xx 3): quoted compound array assignment deprecated
1 2 0 3
1 2 0 3
foo index 1: ok
@@ -433,50 +438,88 @@ argv[1] = <->
argv[2] = <->
argv[1] = < >
declare -a foo=([0]="( zeroind )")
./array19.sub: line 13: warning: foo=( zeroind ): quoted compound array assignment deprecated
declare -a foo=([0]="zeroind")
./array19.sub: line 17: warning: foo=( zeroind ): quoted compound array assignment deprecated
declare -a foo=([0]="zeroind")
declare -a foo=([0]="[0]=bar")
declare -a foo=([0]="[0]=bar")
declare -a foo=([0]="[0]=bar")
declare -- a="(1 2 3)"
declare -a a=([0]="(1 2 3)")
declare -A a=([0]="(1 2 3)" )
./array19.sub: line 41: warning: a=(1 2 3): quoted compound array assignment deprecated
declare -a a=([0]="1" [1]="2" [2]="3")
./array19.sub: line 46: warning: a=(1 2 3): quoted compound array assignment deprecated
./array19.sub: line 46: a: 1: must use subscript when assigning associative array
./array19.sub: line 46: a: 2: must use subscript when assigning associative array
./array19.sub: line 46: a: 3: must use subscript when assigning associative array
declare -A a=()
declare -- a="([0]=a [1]=b)"
declare -a a=([0]="([0]=a [1]=b)")
declare -A a=([0]="([0]=a [1]=b)" )
./array19.sub: line 55: warning: a=([0]=a [1]=b): quoted compound array assignment deprecated
declare -a a=([0]="a" [1]="b")
./array19.sub: line 60: warning: a=([0]=a [1]=b): quoted compound array assignment deprecated
declare -A a=([0]="a" [1]="b" )
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 81: warning: var=([$(echo total 0)]=1 [2]=2]): quoted compound array assignment deprecated
./array19.sub: line 81: 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)" [1]="two" [2]="three")
./array19.sub: line 99: warning: foo=(AbCdE): quoted compound array assignment deprecated
declare -al foo=([0]="abcde")
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 120: warning: a[1]=(var): quoted compound array assignment deprecated
declare -a a=([0]="var")
declare -a a=([0]="1" [1]="2" [2]="(1 2 3)")
declare -a a=([0]="1" [1]="2" [2]="(1 2 3)")
declare -a a=([0]="(1 2 3)" [1]="2" [2]="3")
declare -a a=([0]="(1 2 3)" [1]="2" [2]="3")
./array19.sub: line 137: warning: a=(1 2 3): quoted compound array assignment deprecated
declare -a a=([0]="1" [1]="2" [2]="3")
./array19.sub: line 143: warning: a=(1 2 3): quoted compound array assignment deprecated
declare -a a=([0]="1" [1]="2" [2]="3")
./array19.sub: line 148: warning: a=(1 2 3): quoted compound array assignment deprecated
declare -a a=([0]="1" [1]="2" [2]="3")
declare -- a="a b"
declare -- b="/scratch/bash"
declare -- c="(1 2)"
declare -- d="(\$a)"
declare -- e="(\$(echo Darwin))"
./array19.sub: line 162: warning: c=(1 2): quoted compound array assignment deprecated
./array19.sub: line 162: warning: d=($a): quoted compound array assignment deprecated
./array19.sub: line 162: warning: e=($(echo Darwin)): quoted compound array assignment deprecated
declare -a a=([0]="a b")
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 166: warning: c=(1 2): quoted compound array assignment deprecated
./array19.sub: line 166: c: 1: must use subscript when assigning associative array
./array19.sub: line 166: c: 2: must use subscript when assigning associative array
./array19.sub: line 166: warning: d=($a): quoted compound array assignment deprecated
./array19.sub: line 166: d: $a: must use subscript when assigning associative array
./array19.sub: line 166: warning: e=($(echo Darwin)): quoted compound array assignment deprecated
./array19.sub: line 166: 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=()
a+b+c
x+b+c
a+b+c
x+b+c
argv[1] = <a+b+c+d+e+f>
argv[1] = <x+b+c+d+e+f>
a b c
x b c
a b c
x b c
declare -a a=([1]="2" [2]="3" [3]="4")
abcd
unset
./array21.sub: line 17: typeset: a: not found
./array21.sub: line 20: typeset: A: not found
declare -a a=()
declare -A A=()
+2 -11
View File
@@ -384,25 +384,16 @@ ${THIS_SH} ./array6.sub
${THIS_SH} ./array7.sub
${THIS_SH} ./array8.sub
${THIS_SH} ./array9.sub
${THIS_SH} ./array10.sub
${THIS_SH} ./array11.sub
${THIS_SH} ./array12.sub
${THIS_SH} ./array13.sub
${THIS_SH} ./array14.sub
${THIS_SH} ./array15.sub
${THIS_SH} ./array16.sub
${THIS_SH} ./array17.sub
${THIS_SH} ./array18.sub
${THIS_SH} ./array19.sub
${THIS_SH} ./array20.sub
${THIS_SH} ./array21.sub
+34
View File
@@ -0,0 +1,34 @@
# tests to make sure that $* and ${array[*]} expand consistently in `list'
# and `scalar' contexts
arr=(a b c)
IFS=+
# these two should both expand to `+' separated strings
a=${arr[*]} ; echo "$a"
b=${arr[*]/a/x}; echo "$b"
set -- a b c
# these two should both expand to `+' separated strings
a=${*} ; echo "$a"
b=${*/a/x}; echo "$b"
# these two should both expand to `+' separated strings and it should handle
# characters in IFS as chars in the string
unset a b
set -- 'a+b' 'c+d' 'e+f'
a=${*} ; recho "$a"
b=${*/a/x}; recho "$b"
# now let's make sure that @ always uses space separators even in contexts
# where we don't do word splitting
set -- a b c
a=${@} ; echo "$a"
b=${@/a/x}; echo "$b"
unset a b
a=${arr[@]} ; echo "$a"
b=${arr[@]/a/x}; echo "$b"
+31
View File
@@ -0,0 +1,31 @@
typeset -a a
a=(1 2 3 4)
typeset -A A
A=([one]=1 [two]=2 [three]=3 [four]=4)
unset 'a[0]'
typeset -p a
scalar=abcd
echo ${scalar[0]}
unset 'scalar[0]'
echo ${scalar-unset}
unset 'a[@]'
typeset -p a
unset 'A[@]'
typeset -p A
typeset -a a
a=(1 2 3 4)
typeset -A A
A=([one]=1 [two]=2 [three]=3 [four]=4)
# supported, recommended way to unset all array elements
a=()
typeset -p a
A=()
typeset -p A
+27 -1
View File
@@ -168,4 +168,30 @@ declare -a c=([0]="1" [1]="2" [2]="3")
declare -a c=([0]="1" [1]="2" [2]="3")
unset
unset
./builtins.tests: line 260: exit: status: numeric argument required
assoc 1 unset
array 1 unset
assoc 2 unset
array 2 unset
unset1
unset2
1
1
1
1
assoc A
array a
assoc B unset
array b unset
scalar 1
scalar 2
scalar 3 unset
argv[1] = <one two three>
assoc: 3
array: 3
scalar: 13
scalar: 1
scalar: 0
scalar: 1
scalar: 0
scalar: 0
./builtins.tests: line 263: exit: status: numeric argument required
+3
View File
@@ -256,6 +256,9 @@ ${THIS_SH} ./builtins3.sub
# test behavior of using declare to create variables without assigning values
${THIS_SH} ./builtins4.sub
# test behavior of set and unset array variables
${THIS_SH} ./builtins5.sub
# this must be last -- it is a fatal error
exit status
+61
View File
@@ -0,0 +1,61 @@
# a start at a test suite for what it means for an array to be set or unset and
# how to test that state
typeset -A A
A[a]=1
typeset -a a
a[1]=1
if [ -v A ]; then echo assoc 1; else echo assoc 1 unset; fi
if [ -v a ]; then echo array 1; else echo array 1 unset; fi
if [ -v "${A[@]}" ]; then echo assoc 2; else echo assoc 2 unset; fi
if [ -v "${a[@]}" ]; then echo array 2; else echo array 2 unset; fi
echo ${A-unset1}
echo ${a-unset2}
echo ${A[@]-unset3}
echo ${a[@]-unset4}
echo ${#A[@]}
echo ${#a[@]}
typeset -A B
typeset -a b
scalar1=foo
scalar2=
if [ -v A[@] ]; then echo assoc A; else echo assoc A unset; fi
if [ -v a[@] ]; then echo array a; else echo array a unset; fi
if [ -v B[@] ]; then echo assoc B; else echo assoc B unset; fi
if [ -v b[@] ]; then echo array b; else echo array b unset; fi
if [ -v scalar1[@] ]; then echo scalar 1; else echo scalar 1 unset; fi
if [ -v scalar2[@] ]; then echo scalar 2; else echo scalar 2 unset; fi
if [ -v scalar3[@] ]; then echo scalar 3; else echo scalar 3 unset; fi
unset a A
declare -A assoc=([one]=one [two]=two [three]=three)
declare -a array=(one two three)
scalar="one two three"
scalar2=
recho "${scalar[@]}"
echo assoc: ${#assoc[@]}
echo array: ${#array[@]}
echo scalar: ${#scalar}
echo scalar: ${#scalar[@]}
echo scalar: ${#scalar2}
echo scalar: ${#scalar2[@]}
echo scalar: ${#scalar3}
echo scalar: ${#scalar3[@]}
+1 -1
View File
@@ -35,7 +35,7 @@ hash: usage: hash [-lr] [-p pathname] [-dt] [name ...]
./errors.tests: line 106: hash: hashing disabled
./errors.tests: line 109: export: `AA[4]': not a valid identifier
./errors.tests: line 110: readonly: `AA[4]': not a valid identifier
./errors.tests: line 113: [-2]: bad array subscript
./errors.tests: line 113: unset: [-2]: bad array subscript
./errors.tests: line 117: AA: readonly variable
./errors.tests: line 121: AA: readonly variable
./errors.tests: line 129: shift: 5: shift count out of range
+4
View File
@@ -17,6 +17,10 @@ aéb
1.0000
1.0000
1,0000
1
bytematch
0000000 254 012
0000002
Passed all 1378 Unicode tests
0000000 303 277 012
0000003
+3
View File
@@ -44,6 +44,9 @@ ${THIS_SH} ./intl1.sub
# this tests both international handling in printf and temporary environments
${THIS_SH} ./intl2.sub
# test splitting on characters instead of bytes
${THIS_SH} ./intl3.sub
${THIS_SH} ./unicode1.sub 2>/dev/null
${THIS_SH} ./unicode2.sub
+21
View File
@@ -0,0 +1,21 @@
# more tests to make sure that IFS splits on characters, not bytes
export LANG=en_US.UTF-8
euro=$'\342\202\254'
o342=$'\342'
o202=$'\202'
o254=$'\254'
IFS=$o254
t=+$euro+
set -- $t
echo "$#"
# but matching still occurs on bytes if we don't have a valid multibyte char
case $euro in
*$o202*) echo bytematch ;;
*) echo mbchar match ;;
esac
echo "${euro##*$o202}" | od -b
+1
View File
@@ -157,3 +157,4 @@ a+=3
foo
foo
./redir11.sub: line 53: $(echo $a): Bad file descriptor
123
+1
View File
@@ -191,3 +191,4 @@ ${THIS_SH} ./redir9.sub
${THIS_SH} ./redir10.sub
${THIS_SH} ./redir11.sub
${THIS_SH} ./redir12.sub
+5
View File
@@ -0,0 +1,5 @@
# make sure we can wait for the last process substitution, since it sets $!
echo <(exit 123) >/dev/null
wait "$!"
echo $?
+1 -1
View File
@@ -1,2 +1,2 @@
${THIS_SH} ./varenv.sh | grep -v '^expect' > /tmp/xx
${THIS_SH} ./varenv.sh 2>&1 | grep -v '^expect' > /tmp/xx
diff /tmp/xx varenv.right && rm -f /tmp/xx
+1
View File
@@ -54,6 +54,7 @@ after fff3: x=4
a:b:c:d
a-b-c-d
a:b:c:d
./varenv4.sub: line 13: warning: v=( asdf fdsa ): quoted compound array assignment deprecated
g: ,
f: ,
FIN: asdf fdsa, asdf fdsa