commit bash-20161230 snapshot

This commit is contained in:
Chet Ramey
2017-01-03 14:37:53 -05:00
parent e297b0591d
commit ec157dfefb
88 changed files with 593 additions and 411 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
+10
View File
@@ -520,3 +520,13 @@ argv[1] = <>
argv[2] = <x>
p3
argv[1] = <y>
./array23.sub: line 9: $( echo >&2 foo ) : syntax error: operand expected (error token is "$( echo >&2 foo ) ")
./array23.sub: line 10: $( echo >&2 foo ) : syntax error: operand expected (error token is "$( echo >&2 foo ) ")
foo
0
foo
foo
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 )")
+1
View File
@@ -398,3 +398,4 @@ ${THIS_SH} ./array19.sub
${THIS_SH} ./array20.sub
${THIS_SH} ./array21.sub
${THIS_SH} ./array22.sub
${THIS_SH} ./array23.sub
+22
View File
@@ -0,0 +1,22 @@
# this captures how bash and ksh93 expand indexed array subscripts in
# various contexts. if changes are ever made, or an option added to do
# this differently, the diffs will show up here
typeset -a array
index='$( echo >&2 foo )' # Literal shell code should never be evaluated unless an 'eval' is involved.
echo ${array[ $index ]} # [] expands $index, results in a literal that [] does not re-evaluate.
echo $(( $index )) # (( )) expands $index, results in a literal that (( )) does not re-evaluate.
echo $(( array[ $index ] )) # (( )) expands $index, results in a literal that [] DOES re-evaluate.
(( array[ $index ] ))
typeset -a a
: $(( a[$index]=5 ))
#shopt -s assoc_expand_once
echo $((1+a[$index]))
echo $((1+a[\$index]))
echo "1+${a[$index]}"
+4
View File
@@ -215,3 +215,7 @@ declare -A a=(["80's"]="Depeche Mode" )
./assoc9.sub: line 83: printf: `a[80's]': not a valid identifier
declare -A a
declare -A a=(["80's"]="Depeche Mode" )
6
1
1+5
declare -A a=(["\$(date >&2)"]="5" )
+13
View File
@@ -87,3 +87,16 @@ shopt -s assoc_expand_once
printf -v a[$b] "%s" "Depeche Mode"
typeset -p a
unset a
declare -A a
x='$(date >&2)'
a[$x]=5
shopt -s assoc_expand_once
echo $((1+a[$x]))
echo $((1+a[\$x]))
echo "1+${a[$x]}"
declare -p a
+16 -8
View File
@@ -306,30 +306,38 @@ declare -a b=([0]="0")
./nameref15.sub: line 19: warning: ref: circular name reference
./nameref15.sub: line 20: warning: ref: circular name reference
./nameref15.sub: line 21: warning: ref: circular name reference
inside
inside X
outside X
./nameref15.sub: line 29: typeset: ref: nameref variable self references not allowed
./nameref15.sub: line 31: ref: nameref variable self references not allowed
before: 7
./nameref15.sub: line 32: typeset: warning: xxx: circular name reference
./nameref15.sub: line 32: warning: xxx: circular name reference
./nameref15.sub: line 33: warning: xxx: circular name reference
declare -n xxx="xxx"
./nameref15.sub: line 35: warning: xxx: circular name reference
xxx_func: inside: xxx = foo
after: foo
./nameref15.sub: line 46: typeset: ref: nameref variable self references not allowed
./nameref15.sub: line 48: ref: nameref variable self references not allowed
declare -n ref="re"
declare -n ref="re"
declare -- re="4"
4
declare -n foo="var[@]"
declare -n ref="var[@]"
./nameref15.sub: line 48: var[@]: bad array subscript
./nameref15.sub: line 65: var[@]: bad array subscript
declare -n bar="var[@]"
./nameref15.sub: line 53: var[@]: bad array subscript
./nameref15.sub: line 70: var[@]: bad array subscript
declare -n a="b"
declare -n b="a[1]"
./nameref15.sub: line 61: warning: a: removing nameref attribute
./nameref15.sub: line 78: warning: a: removing nameref attribute
declare -a a=([1]="foo")
declare -n b="a[1]"
./nameref15.sub: line 66: warning: a: removing nameref attribute
./nameref15.sub: line 83: warning: a: removing nameref attribute
declare -a a=([1]="foo")
declare -n b="a[1]"
declare -n n="v"
declare -a v=([1]="1")
./nameref15.sub: line 82: typeset: n: not found
./nameref15.sub: line 99: typeset: n: not found
declare -a v=([0]="0" [1]="1")
declare -n n="v[1]"
declare -a v=([0]="0")
+17 -1
View File
@@ -26,6 +26,23 @@ add_X_echo ref
echo outside "$ref"
unset ref
# same test, but assigning nameref variable circular reference directly
xxx_func()
{
typeset -n xxx=xxx
xxx=foo
declare -p xxx
echo $FUNCNAME: inside: xxx = $xxx
}
xxx=7
echo before: $xxx
xxx_func
echo after: $xxx
unset xxx
unset -f xxx_func
typeset -n ref=ref
typeset -n ref=re ref+=f
@@ -85,4 +102,3 @@ v=(0 1)
declare -n n=v[1]
unset n
declare -p n v