commit bash-20100615 snapshot

This commit is contained in:
Chet Ramey
2011-12-12 22:01:09 -05:00
parent 67362c6091
commit 3d35553ad4
33 changed files with 8573 additions and 74 deletions
+4 -1
View File
@@ -138,4 +138,7 @@ a
b
./builtins.tests: line 251: exit: status: numeric argument required
before: f = 4
inside
after: f = 8 bar = 4
./builtins.tests: line 254: exit: status: numeric argument required
+3
View File
@@ -247,6 +247,9 @@ kill -l ${sigone/SIG/}
# test behavior of shopt xpg_echo
${THIS_SH} ./builtins2.sub
# test behavior of declare -g
${THIS_SH} ./builtins3.sub
# this must be last -- it is a fatal error
exit status
+253
View File
@@ -0,0 +1,253 @@
# tests for miscellaneous builtins not tested elsewhere
set +p
set +o posix
ulimit -c 0 2>/dev/null
# check that break breaks loops
for i in a b c; do echo $i; break; echo bad-$i; done
echo end-1
for i in a b c; do echo $i; break 1; echo bad-$i; done
echo end-2
for i in a b c; do
for j in x y z; do
echo $i:$j
break
echo bad-$i
done
echo end-$i
done
echo end-3
# check that break breaks nested loops
for i in a b c; do
for j in x y z; do
echo $i:$j
break 2
echo bad-$i
done
echo end-$i
done
echo end
# check that continue continues loops
for i in a b c; do echo $i; continue; echo bad-$i ; done
echo end-1
for i in a b c; do echo $i; continue 1; echo bad-$i; done
echo end-2
for i in a b c; do
for j in x y z; do
echo $i:$j
continue
echo bad-$i-$j
done
echo end-$i
done
echo end-3
# check that continue breaks out of nested loops
for i in a b c; do
for j in x y z; do
echo $i:$j
continue 2
echo bad-$i-$j
done
echo end-$i
done
echo end
# check that `eval' re-evaluates arguments, but `builtin' and `command' do not
AVAR='$BVAR'
BVAR=foo
echo $AVAR
builtin echo $AVAR
command echo $AVAR
eval echo \$AVAR
eval echo $AVAR
# test out eval with a temp environment
AVAR=bar eval echo \$AVAR
BVAR=xxx eval echo $AVAR
unset -v AVAR BVAR
# test umask
mask=$(umask)
umask 022
umask
umask -S
umask -S u=rwx,g=rwx,o=rx >/dev/null # 002
umask
umask -S
umask -p
umask -p -S
umask 0
umask -S
umask ${mask} # restore original mask
# builtin/command without arguments should do nothing. maybe someday they will
builtin
command
# test enable
enable -ps
enable -aps ; enable -nps
enable -n test
case "$(type -t test)" in
builtin) echo oops -- enable -n test failed ;;
*) echo enable -n test worked ;;
esac
enable test
case "$(type -t test)" in
builtin) echo enable test worked ;;
*) echo oops -- enable test failed ;;
esac
# test options to exec
(exec -a specialname ${THIS_SH} -c 'echo $0' )
(exec -l -a specialname ${THIS_SH} -c 'echo $0' )
# test `clean' environment. if /bin/sh is bash, and the script version of
# printenv is run, there will be variables in the environment that bash
# sets on startup. Also test code that prefixes argv[0] with a dash.
(export FOO=BAR ; exec -c -l printenv ) | grep FOO
(FOO=BAR exec -c printenv ) | grep FOO
(export FOO=BAR ; exec printenv ) | grep FOO
(FOO=BAR exec printenv ) | grep FOO
# ok, forget everything about hashed commands
hash -r
hash
# this had better succeed, since command -p guarantees we will find the
# standard utilties
command -p hash rm
# check out source/.
# sourcing a zero-length-file had better not be an error
rm -f /tmp/zero-length-file
cp /dev/null /tmp/zero-length-file
. /tmp/zero-length-file
echo $?
rm /tmp/zero-length-file
AVAR=AVAR
. ./source1.sub
AVAR=foo . ./source1.sub
. ./source2.sub
echo $?
set -- a b c
. ./source3.sub
# make sure source with arguments does not change the shell's positional
# parameters, but that the sourced file sees the arguments as its
# positional parameters
echo "$@"
. ./source3.sub x y z
echo "$@"
# but if the sourced script sets the positional parameters explicitly, they
# should be reflected in the calling shell's positional parameters. this
# also tests one of the shopt options that controls source using $PATH to
# find the script
echo "$@"
shopt -u sourcepath
. source4.sub
echo "$@"
# this is complicated when the sourced scripts gets its own positional
# parameters from arguments to `.'
set -- a b c
echo "$@"
. source4.sub x y z
echo "$@"
# test out cd and $CDPATH
${THIS_SH} ./builtins1.sub
# test behavior of `.' when given a non-existant file argument
${THIS_SH} ./source5.sub
# test bugs in sourcing non-regular files, fixed post-bash-3.2
${THIS_SH} ./source6.sub
# in posix mode, assignment statements preceding special builtins are
# reflected in the shell environment. `.' and `eval' need special-case
# code.
set -o posix
echo $AVAR
AVAR=foo . ./source1.sub
echo $AVAR
AVAR=AVAR
echo $AVAR
AVAR=foo eval echo \$AVAR
echo $AVAR
AVAR=AVAR
echo $AVAR
AVAR=foo :
echo $AVAR
set +o posix
# but assignment statements preceding `export' are always reflected in
# the environment
foo="" export foo
declare -p foo
unset foo
# assignment statements preceding `declare' should be displayed correctly,
# but not persist after the command
FOO='$$' declare -p FOO
declare -p FOO
unset FOO
# except for `declare -x', which should be equivalent to `export'
FOO='$$' declare -x FOO
declare -p FOO
unset FOO
# test out kill -l. bash versions prior to 2.01 did `kill -l num' wrong
sigone=$(kill -l | sed -n 's:^ 1) *\([^ ]*\)[ ].*$:\1:p')
case "$(kill -l 1)" in
${sigone/SIG/}) echo ok;;
*) echo oops -- kill -l failure;;
esac
# kill -l and trap -l should display exactly the same output
sigonea=$(trap -l | sed -n 's:^ 1) *\([^ ]*\)[ ].*$:\1:p')
if [ "$sigone" != "$sigonea" ]; then
echo oops -- kill -l and trap -l differ
fi
# POSIX.2 says that exit statuses > 128 are mapped to signal names by
# subtracting 128 so you can find out what signal killed a process
case "$(kill -l $(( 128 + 1)) )" in
${sigone/SIG/}) echo ok;;
*) echo oops -- kill -l 129 failure;;
esac
# out-of-range signal numbers should report the argument in the error
# message, not 128 less than the argument
kill -l 4096
# kill -l NAME should return the signal number
kill -l ${sigone/SIG/}
# test behavior of shopt xpg_echo
${THIS_SH} ./builtins2.sub
# this must be last -- it is a fatal error
exit status
echo after bad exit
+14
View File
@@ -0,0 +1,14 @@
# declare -g added in bash-4.2
f=4
foo()
{
declare -g f=8
declare -g bar=4
echo inside
}
echo before: f = $f
foo
echo after: f = $f bar = $bar
+8 -8
View File
@@ -233,7 +233,7 @@ argv[1] = <oneonetwo>
argv[1] = <onetwo>
argv[1] = <two>
argv[1] = <oneonetwo>
./new-exp.tests: line 421: -2: substring expression < 0
argv[1] = <a>
argv[1] = <defghi>
argv[1] = <efghi>
argv[1] = <e*docrine>
@@ -395,13 +395,13 @@ argv[6] = <w>
argv[7] = <x>
argv[8] = <y>
argv[9] = <z>
./new-exp.tests: line 480: $9: unbound variable
./new-exp.tests: line 481: 9: unbound variable
./new-exp.tests: line 482: UNSET: unbound variable
./new-exp.tests: line 483: UNSET: unbound variable
./new-exp.tests: line 482: $9: unbound variable
./new-exp.tests: line 483: 9: unbound variable
./new-exp.tests: line 484: UNSET: unbound variable
./new-exp.tests: line 485: UNSET: unbound variable
./new-exp.tests: line 486: UNSET: unbound variable
./new-exp.tests: line 487: UNSET: unbound variable
./new-exp.tests: line 488: UNSET: unbound variable
argv[1] = <5>
argv[1] = <#>
argv[1] = <#>
@@ -430,7 +430,7 @@ Case05---3---A:B:C---
Case06---1---A B C::---
Case07---3---A:B:C---
Case08---3---A:B:C---
./new-exp.tests: line 506: ${$(($#-1))}: bad substitution
./new-exp.tests: line 508: ${$(($#-1))}: bad substitution
argv[1] = <a>
argv[2] = <b>
argv[3] = <c>
@@ -447,7 +447,7 @@ argv[1] = <a>
argv[1] = <a>
argv[2] = <b>
argv[1] = <>
./new-exp.tests: line 525: $(($# - 2)): substring expression < 0
./new-exp.tests: line 527: $(($# - 2)): substring expression < 0
argv[1] = <bin>
argv[2] = <bin>
argv[3] = <ucb>
@@ -539,4 +539,4 @@ bar ()
}
argv[1] = </>
argv[1] = </>
./new-exp.tests: line 576: ABXD: parameter unset
./new-exp.tests: line 578: ABXD: parameter unset
+3 -1
View File
@@ -417,8 +417,10 @@ recho $c
c=${var:4}
expect nothing
recho $c
expect '<./new-exp.tests: -2: substring expression < 0>'
# as of bash-4.2, negative LENGTH means offset from the end
c=${var:0:-2}
expect '<a>'
recho $c
var=abcdefghi
c=${var:3:12}
+577
View File
@@ -0,0 +1,577 @@
# must do this because posix mode causes process substitution to be disabled
# and flagged as a syntax error, which causes the shell to exit
set +o posix
expect()
{
echo expect "$@"
}
HOME=/usr/homes/chet # to make the check against new-exp.right work
expect '<foo bar>'
recho "${undef-"foo bar"}" # should be foo bar
expect '<foo>'
recho "${und="foo"}" # should be foo
expect "<$HOME>"
recho ${HOME-"}"}
expect "<$HOME>"
recho "${HOME-'}'}"
expect "<$HOME>"
recho "${HOME-"}"}"
expect $0: 'HOME: }: syntax error: operand expected (error token is "}")'
recho "${HOME:`echo }`}" # should be a math error -- bad substring substitution
expect unset
_ENV=oops
x=${_ENV[(_$-=0)+(_=1)-_${-%%*i*}]}
echo ${x:-unset}
expect "<$HOME>"
recho ${HOME}
expect "<$HOME>"
recho ${HOME:-`echo }`}
expect "<$HOME>"
recho ${HOME:-`echo "}"`}
expect "<$HOME>"
recho "${HOME:-`echo "}"`}"
expect "<$HOME>"
recho "$(echo "${HOME}")"
expect "<$HOME>"
recho "$(echo "$(echo ${HOME})")"
expect "<$HOME>"
recho "$(echo "$(echo "${HOME}")")"
P=*@*
expect '<*@>'
recho "${P%"*"}" #
expect '<*@>'
recho "${P%'*'}" #
expect '<@*>'
recho "${P#\*}" # should be @*
expect '<)>'
recho "$(echo ")")" # should be )
expect '<")">'
recho "$(echo "\")\"")" # should be ")"
foo='abcd '
expect '<-abcd> <->'
recho -${foo}- # should be -abcd -
expect '<-abcd> <->'
recho -${foo% *}- # should be -abcd -
expect '<-abcd->'
recho -${foo%% *}- # should be -abcd-
foo=bar
expect '<bar foo>'
echo -n $foo' ' ; echo foo
expect '<bar foo>'
echo -n $foo" " ; echo foo
expect '<bar foo>'
echo -n "$foo " ; echo foo
expect '<barfoo>'
echo -e "$foo\c " ; echo foo
expect '<barfoo>'
echo -e $foo"\c " ; echo foo
# make sure backslashes are preserved in front of characters that are not
# valid backslash escapes
expect '<\x>'
echo -e '\x'
# substring tests
z=abcdefghijklmnop
expect '<abcd>'
recho ${z:0:4}
expect '<efg> <nop>'
recho ${z:4:3} ${z:${#z}-3:3}
expect '<efg> <nop>'
recho ${z:4:3} ${z: -3:3}
expect '<hijklmnop>'
recho ${z:7:30}
expect '<abcdefghijklmnop>'
recho ${z:0:100}
expect '<abcdefghijklmnop>'
recho ${z:0:${#z}}
set 'ab cd' 'ef' 'gh ij' 'kl mn' 'op'
expect '<ab cd> <ef>'
recho "${@:1:2}"
expect '<gh ij> <kl mn>'
recho "${@:3:2}"
expect '<gh ij> <kl mn> <op>'
recho "${@:3:4}"
expect '<ab cd> <ef> <gh ij> <kl mn> <op>'
recho "${@:1:$#}"
# code to ad-hoc parse arithmetic expressions in substring expansions was
# broken until post-2.04
base=/home/chet/foo//bar
string1=$base/abcabcabc
x=1 j=4
expect '</home/chet/foo//bar/abcabcabc>'
recho ${string1:0}
expect '<home/chet/foo//bar/abcabcabc>'
recho ${string1:1}
expect '<home>'
recho ${string1:(j?1:0):j}
expect '<home>'
recho ${string1:j?1:0:j}
expect '<home>'
recho ${string1:(j?(x?1:0):0):j}
expect '<home>'
recho ${string1:j?(x?1:0):0:j}
unset base string1 x j
# indirect variable references
expect '<abcdefghijklmnop>'
recho ${!9:-$z}
ef=4
expect '<4>'
recho ${!2}
expect '<op>'
recho ${!#}
set a b c d e
a=
expect '<abcdefghijklmnop>'
recho ${a:-$z}
expect '<abcdefghijklmnop>'
recho ${!1:-$z}
expect nothing
recho ${a-$z}
expect nothing
recho ${!1-$z}
set -u
expect $0: ABX: unbound variable
( recho ${ABX} )
set +u
expect $0: '$6: cannot assign in this way'
recho ${6="arg6"}
v=abcde
# sed-like variable substitution
expect '<xxcde>'
recho ${v/a[a-z]/xx}
expect '<axxde>'
recho ${v/a??/axx}
expect '<abxyz>'
recho ${v/c??/xyz}
expect '<abbcde>'
recho ${v/#a/ab}
expect '<abcde>'
recho ${v/#d/ab}
expect '<abcabe>'
recho ${v/d/ab}
expect '<abcdlast>'
recho ${v/%?/last}
expect '<abcde>'
recho ${v/%x/last}
av=(abcd efgh ijkl mnop qrst uvwx)
expect '<xxcd>'
recho ${av/??/xx}
expect '<abxx>'
recho ${av/%??/xx}
expect '<xxgh>'
recho ${av[1]/??/xx}
expect '<efgh>'
recho ${av[1]/%ab/xx}
expect '<xxfgh>'
recho ${av[1]/#?/xx}
expect '<zagh>'
recho ${av[1]/??/za}
expect '<zaza>'
recho ${av[1]//??/za}
expect '<zagh>'
recho ${av[1]/#??/za}
expect '<efza>'
recho ${av[1]/%??/za}
expect '<yyy> <yyy> <yyy> <yyy> <yyy> <yyy>'
recho ${av[@]/*/yyy}
expect '<yyy> <yyy> <yyy> <yyy> <yyy> <yyy>'
recho ${av[@]/#*/yyy}
expect '<yyy> <yyy> <yyy> <yyy> <yyy> <yyy>'
recho ${av[@]/%*/yyy}
expect '<yyy> <efgh> <ijkl> <mnop> <qrst> <uvwx>'
recho ${av[@]/a*/yyy}
expect '<abxx> <efxx> <ijxx> <mnxx> <qrxx> <uvxx>'
recho ${av[@]/%??/xx}
set abcd efgh ijkl mnop qrst uvwx
expect '<xxcd>'
recho ${1/??/xx}
expect '<xxcd> <xxgh> <xxkl> <xxop> <xxst> <xxwx>'
recho ${@/??/xx}
expect '<xxcd> <xxgh> <xxkl> <xxop> <xxst> <xxwx>'
recho ${@/%??/xx}
expect '<zaza>'
recho ${3//??/za}
expect '<efza>'
recho ${3/%??/za}
expect '<zaza> <zaza> <zaza> <zaza> <zaza> <zaza>'
recho ${@//??/za}
expect '<zacd> <zagh> <zakl> <zaop> <zast> <zawx>'
recho ${@/#??/za}
expect '<yyy> <yyy> <yyy> <yyy> <yyy> <yyy>'
recho ${@//*/yyy}
expect '<yyy> <efgh> <ijkl> <mnop> <qrst> <uvwx>'
recho ${@//a*/yyy}
expect '<abcd> <efgh> <ijkl> <mnop> <qrst> <uvwyyy>'
recho ${@/%x*/yyy}
expect a newline
echo $abmcde
# sneaky way to replace a newline in a variable value with something else
AVAR=$'This\nstring\nhas\nmultiple\nlines.'
echo "${AVAR}"
eval BVAR=\"\${AVAR//$'\n'/-}\"
echo "$BVAR"
unset AVAR BVAR
# run process substitution tests in a subshell so that syntax errors
# caused by a shell not implementing process substitution (e.g., one
# built on a NeXT) will not cause the whole test to exit prematurely
${THIS_SH} ./new-exp1.sub
# run the tests of $(<filename) in a subshell to avoid cluttering up
# this script
${THIS_SH} ./new-exp2.sub
expect '<6>'
recho ${#:-foo}
expect $0: '${#:}: bad substitution'
echo ${#:}
expect "<'>"
recho "'"
expect '<">'
recho '"'
expect '<"hello">'
recho "\"hello\""
shift $#
unset foo
z=abcdef
z1='abc def'
expect '<>'
recho ${foo:-""}
expect nothing
recho ${foo:-"$@"}
expect '<>'
recho "${foo:-$@}"
# unset var
expect '<>'
recho ${foo:-"$zbcd"}
expect nothing
recho ${foo:-$zbcd}
# set var
expect '<abcdef>'
recho ${foo:-"$z"}
expect '<abc def>'
recho ${foo:-"$z1"}
expect '<abcdef>'
recho ${foo:-$z}
expect '<abc> <def>'
recho ${foo:-$z1}
expect '<abcdef>'
recho "${foo:-$z}"
expect '<abc def>'
recho "${foo:-$z1}"
expect '<abcdef>'
recho "${foo:-"$z"}"
# this disagrees with sh and ksh, but I think it is right according
# to posix.2.
expect '<abc def>'
recho "${foo:-"$z1"}"
set ab cd ef gh
expect '<ab> <cd> <ef> <gh>'
recho ${foo:-"$@"}
expect '<ab> <cd> <ef> <gh>'
recho "${foo:-$@}"
expect '<ab> <cd> <ef> <gh>'
recho "${foo:-"$@"}"
shift $#
expect nothing
recho $xxx"$@"
expect nothing
recho ${foo:-$xxx"$@"}
expect '<>'
recho "${foo:-$xxx$@}"
expect '<>'
recho "${foo:-$xxx"$@"}"
expect nothing
recho $xxx"$@"
expect nothing
recho "$xxx$@"
expect nothing
recho "$@"$xxx
expect '<>'
recho $xxx""
expect '<>'
recho $xxx''
expect '<>'
recho ''$xxx
expect '<>'
recho ""$xxx
AB='abcdefghijklmnopqrstuvwxyz'
recho ${AB:7:15}
recho ${AB:15:7}
recho ${AB:20}
recho ${AB:0}
recho ${AB:0:20}
recho ${AB:10:7}
recho ${AB:10:3+4}
recho ${AB:20/2:3+4}
set 1 2 3 4 5 6
recho \""${*:2:2}"\"
IFS=:
recho \""${*:2:2}"\"
IFS=$' \t\n'
z=123456
recho \""${z:2:2}"\"
recho \""${z:2}"\"
recho \""${z:2:4}"\"
recho \""${z:2:6}"\"
set $'\1' $'\2' $'\177'
recho $*
recho $@
recho ${*}
recho ${@}
xx=one/two/two
recho ${xx%/*}
recho ${xx/\/two}
yy=oneonetwo
recho ${yy//one}
recho ${yy/\/one}
xx=oneonetwo
recho ${xx/one}
recho ${xx//one}
recho ${xx/\/one}
# out-of-range substrings
var=abc
c=${var:3}
expect nothing
recho $c
c=${var:4}
expect nothing
recho $c
# as of bash-4.2, negative LENGTH means offset from the end
expect '<a>'
c=${var:0:-2}
var=abcdefghi
c=${var:3:12}
recho $c
c=${var:4:20}
recho $c
# make sure null patterns work
xxx=endocrine
yyy=n
unset zzz
recho ${xxx/$yyy/*}
recho ${xxx//$yyy/*}
recho ${xxx/$zzz/*}
recho ${xxx//$zzz/*}
recho ${xxx//%${zzz}/}
recho ${xxx//%${zzz}}
recho ${xxx//#${zzz}/}
recho ${xxx//#${zzz}}
# another case that caused a core dump in bash-2.0
XPATH=/usr/bin:/bin:/usr/local/bin:/usr/gnu/bin::/usr/bin/X11:/sbin:/usr/sbin
recho ${XPATH//:/ }
xx=(ar as at au av aw ax ay az)
recho ${xx[@]/a/}
recho ${xx[@]//a/}
recho ${xx[*]/a/}
recho ${xx[*]//a/}
recho ${xx[@]%?}
recho ${xx[*]%?}
recho ${xx[@]#?}
recho ${xx[*]#?}
set -- ar as at au av aw ax ay az
recho ${@/a/}
recho ${@//a/}
recho ${*/a/}
recho ${*//a/}
recho ${@%?}
recho ${*%?}
recho ${@#?}
recho ${*#?}
shift $#
set -u
( recho $9 ; echo after 1)
( recho ${9} ; echo after 2)
( recho $UNSET ; echo after 3)
( recho ${UNSET} ; echo after 4)
( recho "$UNSET" ; echo after 5)
( recho "${UNSET}" ; echo after 6)
( recho "${#UNSET}" ; echo after 7)
set +u
RECEIVED="12345"
recho "${RECEIVED:$((${#RECEIVED}-1)):1}"
RECEIVED="12345#"
recho "${RECEIVED:$((${#RECEIVED}-1)):1}"
RECEIVED="#"
recho "${RECEIVED:$((${#RECEIVED}-1)):1}"
RECEIVED=""
recho "${RECEIVED:$((${#RECEIVED}-1)):1}"
# tests of new prefix expansion ${!prefix*}
${THIS_SH} ./new-exp3.sub
# bug with indirect expansion through bash-2.05b
${THIS_SH} ./new-exp4.sub
# these caused errors and core dumps in versions before bash-2.04
c=""
echo ${c//${$(($#-1))}/x/}
set a b c d e f g
recho "$@"
set -- ${@:1:$(($# - 2))}
recho "$@"
set a b
recho ${@:1:$(($# - 2))}
recho ${@:1:0}
recho ${@:1:1}
recho ${@:1:2}
recho "${*:1:0}"
# this is an error -- negative expression
set a
recho ${@:1:$(($# - 2))}
XPATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:.:/sbin:/usr/sbin
set $( IFS=: ; echo $XPATH )
recho ${@##*/}
recho ${@%%[!/]*}
recho ${@#/*}
recho ${@%*/}
set /full/path/to/x16 /another/full/path
recho ${1%/*}
recho ${1%%[!/]*}
recho ${1#*/}
recho ${1##*/}
${THIS_SH} ./new-exp5.sub
unset var
var=blah
# these had better agree
echo ${var[@]:3}
echo ${var:3}
echo ${var[@]/#/--}
echo ${var/#/--}
echo ${var[@]##?}
echo ${var##?}
unset var
var=(abcde abcfg abchi)
# problems with anchoring pattern replacements
echo ${var[*]//#abc/foo}
echo ${var[*]/#abc/foo}
unset var
${THIS_SH} ./new-exp6.sub
${THIS_SH} ./new-exp7.sub
# problems with stray CTLNUL in bash-4.0-alpha
unset a
a=/a
recho "/${a%/*}"
recho "/${a///a/}"
# this must be last!
expect $0: 'ABXD: parameter unset'
recho ${ABXD:?"parameter unset"}
+13 -2
View File
@@ -1,3 +1,14 @@
a
b
a b
argv[1] = <a>
argv[2] = <b>
argv[3] = <x>
argv[4] = <a>
argv[5] = <b>
argv[1] = <a\ b>
argv[2] = <x>
argv[3] = <a\ b>
argv[1] = <foo 'bar' baz>
argv[1] = <a b c d>
argv[1] = <a b c d>
@@ -26,5 +37,5 @@ argv[1] = <'bar>
argv[1] = <foo 'bar baz>
argv[1] = <z}>
argv[1] = <''z}>
./posixexp.tests: line 56: unexpected EOF while looking for matching `}'
./posixexp.tests: line 59: syntax error: unexpected end of file
./posixexp.tests: line 68: unexpected EOF while looking for matching `}'
./posixexp.tests: line 69: syntax error: unexpected end of file
+12 -2
View File
@@ -1,3 +1,15 @@
unset a
printf "%s\n" ${a:=a\ b}
echo "$a"
unset v
recho ${v=a\ b} x ${v=c\ d}
unset v
recho "${v=a\ b}" x "${v=c\ d}"
unset a v
recho "foo ${IFS+'bar'} baz"
recho "a ${IFS+b c} d"
@@ -54,5 +66,3 @@ recho "${IFS+'}'z}"
# this will be an error
foo=bar
echo "${foo:-"a}"
+56
View File
@@ -0,0 +1,56 @@
recho "foo ${IFS+'bar'} baz"
recho "a ${IFS+b c} d"
recho "a ${IFS+"b c"} d"
u=x
recho "foo ${IFS+a$u{{{\}b} c ${IFS+d{}} bar" ${IFS-e{}} baz
a=foo
recho "${IFS+'$a'}"
recho "${IFS+"'$a'"}"
recho ${IFS+'$a'}
recho ${IFS+"'$a'"}
unset a u
x='foo*bar'
recho "${x##"}"}"
recho "${x##'}'}"
recho "${x##'}"
recho "${x:-'}'}"
foo="x'a'y"
recho "${foo%*'a'*}"
unset x
unset u
v=w
printf '<%s> ' ${u+x} . ${v+x} . "${u+x}" . "${v+x}" .; echo
printf '<%s> ' ${u-x} . ${v-x} . "${u-x}" . "${v-x}" .; echo
printf '<%s> ' ${u=x} . ${v=x} . "${u=x}" . "${v=x}" .; echo
printf '<%s> ' ${u?x} . ${v?x} . "${u?x}" . "${v?x}" .; echo
printf '<%s> ' ${u#x} . ${v#x} . "${u#x}" . "${v#x}" .; echo
printf '<%s> ' ${u%x} . ${v%x} . "${u%x}" . "${v%x}" .; echo
printf '<%s> ' ${u:+x} . ${v:+x} . "${u:+x}" . "${v:+x}" .; echo
printf '<%s> ' ${u:-x} . ${v:-x} . "${u:-x}" . "${v:-x}" .; echo
printf '<%s> ' ${u:=x} . ${v:=x} . "${u:=x}" . "${v:=x}" .; echo
printf '<%s> ' ${u:?x} . ${v:?x} . "${u:?x}" . "${v:?x}" .; echo
# these are invalid substitution operators
#printf '<%s> ' ${u:#x} . ${v:#x} . "${u:#x}" . "${v:#x}" .; echo
#printf '<%s> ' ${u:%x} . ${v:%x} . "${u:%x}" . "${v:%x}" .; echo
unset foo
set -o posix
recho "${IFS+'bar}"
recho "foo ${IFS+'bar} baz"
recho ${IFS+'}'z}
recho "${IFS+'}'z}"
# this will be an error
foo=bar
echo "${foo:-"a}"
+41
View File
@@ -0,0 +1,41 @@
1
0
a
real 0.00
user 0.00
sys 0.00
1
a
real 0.00
user 0.00
sys 0.00
1
tfunc is a function
tfunc ()
{
time
}
1
0
1
a
real 0.00
user 0.00
sys 0.00
0
a
real 0.00
user 0.00
sys 0.00
0
a
real 0.00
user 0.00
sys 0.00
0
1
0
a
real 0.00
user 0.00
sys 0.00
+43
View File
@@ -0,0 +1,43 @@
# Test timed and negated pipelines in bash-4.2 and later
export TIMEFORMAT=$'real %2R\nuser %2U\nsys %2S'
!
echo $?
! !
echo $?
time ! echo a
echo $?
! time echo a
echo $?
tfunc()
{
time
}
type tfunc
! true
echo $?
! ! true
echo $?
! ! ! true
echo $?
time time echo a
echo $?
time time -p echo a
echo $?
time -p time echo a
echo $?
!
echo $?
! !
echo $?
time -p -- echo a
+41
View File
@@ -0,0 +1,41 @@
# Test timed and negated pipelines in bash-4.2 and later
export TIMEFORMAT=$'real %2R\nuser %2U\nsys %2S'
!
echo $?
! !
echo $?
time ! echo a
echo $?
! time echo a
echo $?
tfunc()
{
time
}
type tfunc
! true
echo $?
! ! true
echo $?
! ! ! true
echo $?
time time echo a
echo $?
time time -p echo a
echo $?
time -p time echo a
echo $?
!
echo $?
! !
echo $?
+1 -1
View File
@@ -27,7 +27,7 @@ do
*.orig|*~) ;;
run-dollars|run-execscript|run-func|run-getopts|run-heredoc) echo $x ; sh $x ;;
run-ifs-tests|run-input-test|run-invert|run-more-exp|run-nquote) echo $x ; sh $x ;;
run-ifs-posix|run-posix2|run-posixpat) echo $x ; sh $x ;;
run-ifs-posix|run-posix2|run-posixpat|run-posixpipe) echo $x ; sh $x ;;
run-precedence|run-quote|run-read|run-rhs-exp|run-strip|run-tilde) echo $x ; sh $x ;;
*) ;;
esac
+36
View File
@@ -0,0 +1,36 @@
#! /bin/sh
#
# run-minimal - a version of run-all for shells configured with
# --enable-minimal-config
#
PATH=.:$PATH # just to get the right version of printenv
export PATH
# unset BASH_ENV only if it is set
[ "${BASH_ENV+set}" = "set" ] && unset BASH_ENV
# ditto for SHELLOPTS
#[ "${SHELLOPTS+set}" = "set" ] && unset SHELLOPTS
: ${THIS_SH:=../bash}
export THIS_SH
${THIS_SH} ./version.mini
rm -f /tmp/xx
echo Testing ${THIS_SH}
echo Any output from any test, unless otherwise noted, indicates a possible anomaly
for x in run-*
do
case $x in
$0) ;;
*.orig|*~) ;;
run-dollars|run-execscript|run-func|run-getopts|run-heredoc) echo $x ; sh $x ;;
run-ifs-tests|run-input-test|run-invert|run-more-exp|run-nquote) echo $x ; sh $x ;;
run-ifs-posix|run-posix2|run-posixpat) echo $x ; sh $x ;;
run-precedence|run-quote|run-read|run-rhs-exp|run-strip|run-tilde) echo $x ; sh $x ;;
*) ;;
esac
done
exit 0
+2
View File
@@ -0,0 +1,2 @@
${THIS_SH} ./posixpipe.tests > /tmp/xx 2>&1
diff /tmp/xx posixpipe.right && rm -f /tmp/xx
+2
View File
@@ -0,0 +1,2 @@
${THIS_SH} ./posixexp.tests > /tmp/xx 2>&1
diff /tmp/xx posixexp.right && rm -f /tmp/xx
+1
View File
@@ -53,6 +53,7 @@ trap -- 'echo aborting' SIGQUIT
trap -- 'echo aborting' SIGABRT
trap -- 'echo aborting' SIGTERM
0
trap -- '' SIGUSR2
ERRTRAP
ERRTRAP
ERRTRAP