commit bash-20180316 snapshot

This commit is contained in:
Chet Ramey
2018-03-19 09:46:55 -04:00
parent bf5b8103d4
commit f602026a0c
59 changed files with 6880 additions and 6405 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
BUILD_DIR=/usr/local/build/bash/bash-current
BUILD_DIR=/usr/local/build/chet/bash/bash-current
THIS_SH=$BUILD_DIR/bash
PATH=$PATH:$BUILD_DIR
+2 -1
View File
@@ -259,4 +259,5 @@ efg
42
42
42
./arith.tests: line 313: b[c]d: syntax error in expression (error token is "d")
./arith.tests: line 314: 'foo' : syntax error: operand expected (error token is "'foo' ")
./arith.tests: line 318: b[c]d: syntax error in expression (error token is "d")
+5
View File
@@ -309,5 +309,10 @@ printf "%u\n" $n
echo $(( 16#$(printf "%x\n" $n) ))
echo $(( 16#$(printf "%X\n" $n) ))
# these are errors
foo=1
echo $(( 'foo' ))
# causes longjmp botches through bash-2.05b
a[b[c]d]=e
+18 -18
View File
@@ -26,7 +26,7 @@ hello world
11
3
bdef hello world test expression test 2
./array.tests: line 76: readonly: `a[5]': not a valid identifier
./array.tests: line 79: readonly: `a[5]': not a valid identifier
declare -ar a=([1]="" [2]="bdef" [5]="hello world" [6]="test expression" [15]="test 2")
declare -ar c
declare -ar a=([1]="" [2]="bdef" [5]="hello world" [6]="test expression" [15]="test 2")
@@ -46,17 +46,17 @@ declare -ar c
declare -a d=([1]="" [2]="bdef" [5]="hello world" [6]="test" [9]="ninth element")
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
./array.tests: line 103: b[*]: bad array subscript
./array.tests: line 104: ${b[ ]}: bad substitution
./array.tests: line 106: c[-2]: bad array subscript
./array.tests: line 107: c: bad array subscript
./array.tests: line 103: a: readonly variable
./array.tests: line 105: b[]: bad array subscript
./array.tests: line 106: b[*]: bad array subscript
./array.tests: line 107: ${b[ ]}: bad substitution
./array.tests: line 109: c[-2]: bad array subscript
./array.tests: line 110: c: bad array subscript
./array.tests: line 109: d[7]: cannot assign list to array member
./array.tests: line 111: []=abcde: bad array subscript
./array.tests: line 111: [*]=last: cannot assign to non-numeric index
./array.tests: line 111: [-65]=negative: bad array subscript
./array.tests: line 112: d[7]: cannot assign list to array member
./array.tests: line 114: []=abcde: bad array subscript
./array.tests: line 114: [*]=last: cannot assign to non-numeric index
./array.tests: line 114: [-65]=negative: bad array subscript
declare -a BASH_ARGC=()
declare -a BASH_ARGV=()
declare -a BASH_LINENO=([0]="0")
@@ -68,8 +68,8 @@ declare -a b=([0]="this" [1]="is" [2]="a" [3]="test" [4]="" [5]="/etc/passwd")
declare -ar c
declare -a d=([1]="test test")
declare -a f=([0]="" [1]="bdef" [2]="hello world" [3]="test" [4]="ninth element")
./array.tests: line 119: unset: ps1: not an array variable
./array.tests: line 123: declare: c: cannot destroy array variables in this way
./array.tests: line 122: unset: ps1: not an array variable
./array.tests: line 126: declare: c: cannot destroy array variables in this way
this of
this is a test of read using arrays
this test
@@ -127,7 +127,7 @@ grep [ 123 ] *
6 7 9 5
length = 3
value = new1 new2 new3
./array.tests: line 239: narray: unbound variable
./array.tests: line 242: narray: unbound variable
./array1.sub: line 1: syntax error near unexpected token `('
./array1.sub: line 1: `printf "%s\n" -a a=(a 'b c')'
./array2.sub: line 1: declare: `[]=asdf': not a valid identifier
@@ -154,10 +154,10 @@ for case if then else
12 14 16 18 20
4414758999202
aaa bbb
./array.tests: line 289: syntax error near unexpected token `<>'
./array.tests: line 289: `metas=( <> < > ! )'
./array.tests: line 290: syntax error near unexpected token `<>'
./array.tests: line 290: `metas=( [1]=<> [2]=< [3]=> [4]=! )'
./array.tests: line 292: syntax error near unexpected token `<>'
./array.tests: line 292: `metas=( <> < > ! )'
./array.tests: line 293: syntax error near unexpected token `<>'
./array.tests: line 293: `metas=( [1]=<> [2]=< [3]=> [4]=! )'
abc 3
case 4
abc case if then else 5
+3
View File
@@ -21,6 +21,9 @@ unset a
a=abcde
declare -a a
echo ${a[0]}
if [ "$a" != "${a[0]}" ]; then
echo 'array.tests: $a and $a[0] array mismatch'
fi
unset a
a=abcde
+7
View File
@@ -174,6 +174,13 @@ T='([a]=1)'
echo "${T[@]}"
unset T
# peculiar ksh93 semantics for unsubscripted assoc variable reference
declare -A T
T[0]='zero'
if [ "$T" != "${T[0]}" ]; then
echo 'assoc.tests: $T and ${T[0]} mismatch'
fi
${THIS_SH} ./assoc1.sub
${THIS_SH} ./assoc2.sub
+34 -2
View File
@@ -120,8 +120,9 @@ after readonly assignment
./errors4.sub: line 7: var: readonly variable
./errors5.sub: line 6: array: unbound variable
./errors5.sub: line 7: array: unbound variable
./errors5.sub: line 10: 7: unbound variable
./errors5.sub: line 8: array[7]: unbound variable
./errors5.sub: line 11: 7: unbound variable
./errors5.sub: line 12: 7: unbound variable
after 1: 1
after 2: 1
after 3: 1
@@ -136,6 +137,13 @@ array after 2: 1
./errors6.sub: line 27: -3: invalid variable name
after indir: 1
./errors6.sub: line 30: -3: invalid variable name
unset
./errors6.sub: line 37: var: invalid indirect expansion
./errors6.sub: line 38: var: invalid indirect expansion
./errors6.sub: line 41: invalid-ident: invalid variable name
./errors6.sub: line 42: invalid-ident: invalid variable name
./errors6.sub: line 43: invalid-ident: invalid variable name
./errors6.sub: uvar: parameter not set
./errors6.sub: uvar: parameter null or not set
@@ -145,4 +153,28 @@ after indir: 1
./errors6.sub: line 27: -3: invalid variable name
after indir: 1
./errors6.sub: line 30: -3: invalid variable name
./errors.tests: line 278: `!!': not a valid identifier
unset
./errors6.sub: line 37: var: invalid indirect expansion
./errors6.sub: line 38: var: invalid indirect expansion
./errors6.sub: line 41: invalid-ident: invalid variable name
./errors6.sub: line 42: invalid-ident: invalid variable name
./errors6.sub: line 43: invalid-ident: invalid variable name
./errors7.sub: line 8: x: readonly variable
./errors7.sub: line 8: notthere: command not found
after no such command: 127
./errors7.sub: line 10: x: readonly variable
echo builtin
after non-special builtin: 0
./errors7.sub: line 12: x: readonly variable
after special builtin: 0
./errors7.sub: line 14: x: readonly variable
./errors7.sub: line 8: x: readonly variable
./errors7.sub: line 8: notthere: command not found
after no such command: 127
./errors7.sub: line 10: x: readonly variable
echo builtin
after non-special builtin: 0
./errors7.sub: line 12: x: readonly variable
./errors7.sub: line 14: x: readonly variable
./errors.tests: line 281: `!!': not a valid identifier
+3
View File
@@ -270,6 +270,9 @@ ${THIS_SH} ./errors5.sub
${THIS_SH} ./errors6.sub
THIS_SH="${THIS_SH} -o posix" ${THIS_SH} ./errors6.sub
${THIS_SH} ./errors7.sub
${THIS_SH} -o posix ./errors7.sub
# this must be last!
# in posix mode, a function name must be a valid identifier
# this can't go in posix2.tests, since it causes the shell to exit
+1
View File
@@ -5,6 +5,7 @@ set -u
( echo ${#array} )
( echo ${array} )
( echo ${array[7]} )
set -- 1 2 3
( echo ${#7} )
+12
View File
@@ -29,3 +29,15 @@ echo after indir: $?
function ivar() { echo -n "${!1:-${1}}"; }
ivar -3
foo=bar
echo ${!foo}
echo ${!foo:-unset}
echo ${!var:-unset}
echo ${!var+unset}
foo=invalid-ident
echo ${!foo}
echo ${!foo:-unset}
echo ${!foo+unset}
+15
View File
@@ -0,0 +1,15 @@
: ${THIS_SH:=./bash}
readonly x=4
# in posix mode, these are all variable assignment errors, so strict conformance
# implies that we exit after any of them. ksh93 doesn't do that. we more-or-less
# emulate the ksh93 behavior
x=8 notthere
echo after no such command: $?
x=8 echo echo builtin
echo after non-special builtin: $?
( x=8 : nosuchdir
echo after special builtin: $? )
( x=8 $nocmd
echo after assignment error: $? )
+13
View File
@@ -388,3 +388,16 @@ ok 6
ok 7
ok 8
ok 9
argv[1] = <file.o>
argv[1] = <posix>
argv[1] = </src/cmd>
argv[1] = <three>
argv[1] = </one/two/three>
abcdefg
abcdefg
abcdefg
abcdefg
cdefg
abcdefg
abcde
abcdefg
+1
View File
@@ -407,3 +407,4 @@ ${THIS_SH} ./exp8.sub
${THIS_SH} ./exp9.sub
${THIS_SH} ./exp10.sub
${THIS_SH} ./exp11.sub
${THIS_SH} ./exp12.sub
+38
View File
@@ -0,0 +1,38 @@
# force single-byte versions of these functions
export LANG=C
# remove shortest trailing match
x=file.c
recho ${x%.c}.o
# remove longest trailing match
x=posix/src/std
recho ${x%%/*}
# remove shortest leading pattern
x=$HOME/src/cmd
recho ${x#$HOME}
# remove longest leading pattern
x=/one/two/three
recho ${x##*/}
# and no match thrown in for good measure
recho ${x#nomatch}
foo=abcdefg
# fail
echo ${foo%ab}
echo ${foo%def}
echo ${foo#fg}
echo ${foo#def}
# succeed
echo ${foo#ab}
echo ${foo#def}
echo ${foo%fg}
echo ${foo%def}
+1
View File
@@ -113,3 +113,4 @@ a b c
a b c
.x .y .z a b c
.x .y .z a b c
*
+2
View File
@@ -374,4 +374,6 @@ ${THIS_SH} ./extglob3.sub
${THIS_SH} ./extglob4.sub
${THIS_SH} ./extglob5.sub
exit 0
+17
View File
@@ -0,0 +1,17 @@
# globignore extglob patterns containing colons -- problem until bash-4.2
: ${TMPDIR:=/tmp}
TESTDIR=$TMPDIR/bash-globignore-$$
[ -d "$TESTDIR" ] || mkdir "$TESTDIR"
cd "$TESTDIR" || exit 2
shopt -s extglob
GLOBIGNORE='+([^[:alnum:]]):@([-.,:; _]):[![:alnum:]]'
touch ';' '++'
echo *
rm ';' '++'
cd $OLDPWD
+9
View File
@@ -181,6 +181,15 @@ echo g
g
eval echo "echo g"
echo g
h
echo \!\! `echo echo h`
!! echo h
i
echo echo i `echo echo i`
echo i echo i
j
echo `echo j` echo j
j echo j
a
cat < <(echo echo a)
echo a
+9
View File
@@ -31,5 +31,14 @@ echo "!!"
echo g
eval echo "!!"
echo h
echo \!\! `echo !!`
echo i
echo !! `echo !!`
echo j
echo `echo j` !!
set +o history
rm -f $HISTFILE # just in case
+2 -2
View File
@@ -152,7 +152,7 @@ b1()
b2()
{
recho $*
recho $#
recho ${#}
}
expect '<1>'
@@ -414,7 +414,7 @@ recho ${#}
expect '<5>'
recho ${#?:-xyz}
shift $#
shift ${#}
expect '<0>'
recho ${#:-foo}
+7
View File
@@ -226,6 +226,13 @@ declare -r RO="x"
./nameref11.sub: line 39: declare: RO_PID: not found
./nameref11.sub: line 41: RO2: readonly variable
declare -r RO2="a"
2
./nameref11.sub: line 52: typeset: `2': invalid variable name for name reference
2
./nameref11.sub: line 57: typeset: `2': invalid variable name for name reference
2
./nameref11.sub: line 62: foo[2]: invalid indirect expansion
./nameref11.sub: line 63: bar: invalid indirect expansion
./nameref12.sub: line 6: declare: `/': invalid variable name for name reference
./nameref12.sub: line 9: declare: `%': invalid variable name for name reference
./nameref12.sub: line 13: `^': not a valid identifier
+22
View File
@@ -39,3 +39,25 @@ unset -n ref ; unset ref
declare -r RO RO_PID; coproc RO { :; }; declare -p RO_PID; wait; declare -p RO RO_PID
declare -r RO2=a; declare -n ref_PID=RO2; coproc ref { :; }; wait; declare -p RO2
unset x y
set -- one two three
y=2
typeset -n x=y
echo ${x}
unset -n x
typeset -n y
echo $y
unset -n y
typeset -n y
y=2
echo ${y}
declare -n foo=bar
echo ${!foo[2]}
echo ${!bar}
+22 -1
View File
@@ -169,6 +169,7 @@ lines.
This-string-has-multiple-lines.
this is a test of proc subst
this is test 2
a
./new-exp2.sub: line 42: /tmp/redir-notthere: No such file or directory
1
@@ -642,6 +643,26 @@ ir
a b c d e
5
a5b
abcxxxdef
abcådef
ḅć
Ã¥
prependḅć
Ã¥append
prependå
ḅćappend
Ã¥
ḅć
ḅć
ḅć
Ã¥
Ã¥
Ã¥
ḅć
Ã¥
Ã¥
ḅć
ḅć
argv[1] = </>
argv[1] = </>
./new-exp.tests: line 608: ABXD: parameter unset
./new-exp.tests: line 611: ABXD: parameter unset
+5 -2
View File
@@ -340,7 +340,7 @@ recho "${foo:-$@}"
expect '<ab> <cd> <ef> <gh>'
recho "${foo:-"$@"}"
shift $#
shift ${#}
expect nothing
recho $xxx"$@"
expect nothing
@@ -498,7 +498,7 @@ recho ${*%?}
recho ${@#?}
recho ${*#?}
shift $#
shift ${#}
set -u
( recho $9 ; echo after 1)
( recho ${9} ; echo after 2)
@@ -597,6 +597,9 @@ ${THIS_SH} ./new-exp9.sub
# new parameter transformation `@' expansion operator
${THIS_SH} ./new-exp10.sub
# parameter substring replacement and removal operators with multibyte chars
${THIS_SH} ./new-exp11.sub
# problems with stray CTLNUL in bash-4.0-alpha
unset a
a=/a
+4
View File
@@ -10,3 +10,7 @@ echo this is test 2 > $FN
expect this is test 2
cat <(cat $FN)
rm -f $FN
foo=
expect a
cat ${foo:-<(echo a)}
+46
View File
@@ -0,0 +1,46 @@
# pattern matching and replacement operators with multibyte characters
LANG=en_US.UTF-8
s1='abcådef'
s2='Ã¥'
s3='ḅć'
s23=${s2}${s3}
echo ${s1/$s2/xxx}
echo ${s1/$s3/xxx}
echo ${s23/#$s2/}
echo ${s23/%$s3/}
echo ${s23/#$s2/prepend}
echo ${s23/%$s3/append}
echo ${s2/#/prepend}
echo ${s3/%/append}
echo ${s2/#/}
echo ${s3/%/}
recho ${s2/$s2/}
recho ${s3/$s3/}
# posix pattern replacements
echo ${s23##$s2}
echo ${s23#$s2}
echo ${s23%%$s3}
echo ${s23%$s3}
# fail
echo ${s2/#ab/xx}
echo ${s3/%ab/xx}
echo ${s2#ab}
echo ${s2##ab}
echo ${s3%ab}
echo ${s3%%ab}
+3
View File
@@ -18,4 +18,7 @@ ${THIS_SH} -c 'echo ${1?}' 2>/dev/null && exit 11
${THIS_SH} -c 'echo ${1?}' ${THIS_SH} x >/dev/null || exit 12
${THIS_SH} -c 'echo ${2?}' ${THIS_SH} x 2>/dev/null && exit 13
${THIS_SH} -c 'echo ${2?}' ${THIS_SH} x y >/dev/null || exit 14
${THIS_SH} -c $'echo $(( x+ )) \n exit 0' ${THIS_SH} 2>/dev/null && exit 15
exit 0
+6
View File
@@ -66,6 +66,12 @@ argv[2] = <ab>
${
argv[1] = <(")>
argv[1] = <(")>
string \
string \
string \
string \
string \
string \}
'weferfds'\''dsfsdf'
'weferfdsdsfsdf'
'weferfds'\''dsfsdf'
+11
View File
@@ -109,4 +109,15 @@ recho `echo "(\\")"`
# ultimate workaround
recho `echo "(\")"`
# various strings ending in backslashes
echo 'string \'
echo "string \\"
echo string\ \\
echo ${foo:-'string \'}
echo "${foo:-string \\}"
echo ${foo:-string \\\}}
${THIS_SH} ./quote1.sub
+4
View File
@@ -26,6 +26,10 @@
+ x=i
+ case x in
+ x=i
+ foo=one
+ foo+=two
+ echo onetwo
onetwo
+ set +x
1
2
+5
View File
@@ -14,6 +14,11 @@ case x in
0) x=i ;;
*) x=i ;;
esac
foo=one
foo+=two
echo $foo
set +x
# test BASH_XTRACEFD
+7
View File
@@ -128,6 +128,13 @@ outer: res: X Y
main: after second call: X
func: null or unset
after func: x = outside
./varenv11.sub: line 4: local: qux: readonly variable
./varenv11.sub: line 5: qux: readonly variable
declare -A foo=([one]="one" [zero]="zero" )
declare -a bar=([0]="zero" [1]="one")
declare -A foo=([one]="one" [zero]="zero" )
declare -a bar=([0]="zero" [1]="one")
./varenv11.sub: line 29: a: readonly variable
a=z
a=b
a=z
+3
View File
@@ -228,5 +228,8 @@ ${THIS_SH} ./varenv9.sub
# more tests of unset and local variables with dynamic scoping
${THIS_SH} ./varenv10.sub
# tests of compound assignments in function scope
${THIS_SH} ./varenv11.sub
# make sure variable scoping is done right
tt() { typeset a=b;echo a=$a; };a=z;echo a=$a;tt;echo a=$a
+30
View File
@@ -0,0 +1,30 @@
# couple of errors here
func()
{
local qux=7
local qux=(one two)
local what=(zero one two)
}
readonly qux=42
func
func2()
{
declare -gA foo=([zero]=zero [one]=one)
declare -ga bar=(zero one)
}
foo=help
bar=me
func2
declare -p foo bar
unset foo bar
func2
declare -p foo bar
readonly a=7
a=(1 2 3)