Imported from ../bash-3.2.tar.gz.

This commit is contained in:
Jari Aalto 2006-10-10 14:15:34 +00:00
commit 0628567a28
182 changed files with 17647 additions and 9477 deletions

5
tests/COPYRIGHT Normal file
View file

@ -0,0 +1,5 @@
Unless otherwise stated, all files in this directory are Copyright (C)
1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006
Free Software Foundation, Inc.
The file ifs-posix.tests is Copyright (C) 2005 Glen Fowler.

View file

@ -1 +1,3 @@
Type `sh run-all'.
Read COPYRIGHT for copyright information.

View file

@ -137,6 +137,14 @@ value = new1 new2 new3
7 8 9
8 11
8 11
6
6
nordholz
8
8
8
a b c d e f g
for case if then else
@ -144,10 +152,10 @@ for case if then else
12 14 16 18 20
4414758999202
aaa bbb
./array.tests: line 282: syntax error near unexpected token `<>'
./array.tests: line 282: `metas=( <> < > ! )'
./array.tests: line 283: syntax error near unexpected token `<>'
./array.tests: line 283: `metas=( [1]=<> [2]=< [3]=> [4]=! )'
./array.tests: line 285: syntax error near unexpected token `<>'
./array.tests: line 285: `metas=( <> < > ! )'
./array.tests: line 286: syntax error near unexpected token `<>'
./array.tests: line 286: `metas=( [1]=<> [2]=< [3]=> [4]=! )'
abc 3
case 4
abc case if then else 5
@ -197,3 +205,4 @@ t
[3]=abcde r s t u v
e
9
2

View file

@ -242,6 +242,9 @@ ${THIS_SH} ./array2.sub
# some old bugs and ksh93 compatibility tests
${THIS_SH} ./array3.sub
# some compound assingment parsing problems that showed up in bash-3.1-release
${THIS_SH} ./array4.sub
set +u
cd /tmp
@ -396,3 +399,7 @@ unset x[2]
x[9]='9'
echo ${x[*]: -1}
TOOLKIT=(1 2 3 4 5 6 7 8 9 10)
ARRAY="1"
echo ${TOOLKIT["$ARRAY"]}

32
tests/array4.sub Normal file
View file

@ -0,0 +1,32 @@
# compound assignment parsing problems in bash-3.1-release
func()
{
local -a x=() y=()
}
a=() b=()
eval foo=()
eval foo=() bar=() qux=( "bash" )
foo=( "bash" )
eval foo=( "bash" )
eval bar=( "bash" ) bax=( "bash" )
let a=(5 + 3) b=(4 + 7)
echo $a $b
typeset -i a b
a=(5+3) b=(4+7)
echo $a $b
let a=(4*3)/2
echo $a
a=(4*3)/2
echo $a
LNAME=nordholz
echo ${LNAME}
echo ${#LNAME}
echo ${#LNAME[$(( 0 ))]}
echo ${#LNAME[$(( 0+0 ))]}

View file

@ -41,3 +41,5 @@ f
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20
-1 -2 -3 -4 -5 -6 -7 -8 -9 -10
-20 -19 -18 -17 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0
a-{bd}-c a-{be}-c
a-{bdef-g-c a-{bdef-i-c

View file

@ -68,3 +68,8 @@ echo 0{1..9} {10..20}
# do negative numbers work?
echo {-1..-10}
echo {-20..0}
# weirdly-formed brace expansions -- fixed in post-bash-3.1
echo a-{b{d,e}}-c
echo a-{bdef-{g,i}-c

View file

@ -1,14 +1,14 @@
tf is a function
tf ()
{
echo this is ${0##*/} >/dev/null;
echo a | cat - >/dev/null;
echo this is ${0##*/} > /dev/null;
echo a | cat - > /dev/null;
test -f ${0##*/} && echo ${0##*/} is a regular file;
test -d ${0##*/} || echo ${0##*/} is not a directory;
echo a;
echo b;
echo c;
echo background >/dev/null & ( exit 1 );
echo background > /dev/null & ( exit 1 );
echo $?;
{
echo a
@ -18,20 +18,20 @@ tf ()
test -r /dev/fd/$i;
i=$(( i + 1 ));
done;
[[ -r /dev/fd/0 && -w /dev/fd/1 ]] || echo oops >/dev/null;
[[ -r /dev/fd/0 && -w /dev/fd/1 ]] || echo oops > /dev/null;
for name in $( echo 1 2 3 );
do
test -r /dev/fd/$name;
done;
if [[ -r /dev/fd/0 && -w /dev/fd/1 ]]; then
echo ok >/dev/null;
echo ok > /dev/null;
else
if (( 7 > 40 )); then
echo oops;
else
echo done;
fi;
fi >/dev/null;
fi > /dev/null;
case $PATH in
*$PWD*)
echo \$PWD in \$PATH
@ -39,13 +39,13 @@ tf ()
*)
echo \$PWD not in \$PATH
;;
esac >/dev/null;
esac > /dev/null;
while false; do
echo z;
done >/dev/null;
done > /dev/null;
until true; do
echo z;
done >/dev/null;
done > /dev/null;
echo \&\|'()' \{ echo abcde \; \};
eval fu\%nc'()' \{ echo abcde \; \};
type fu\%nc
@ -54,7 +54,7 @@ tf2 is a function
tf2 ()
{
( {
time -p echo a | cat - >/dev/null
time -p echo a | cat - > /dev/null
} ) 2>&1
}
cprint.tests is a regular file

View file

@ -78,3 +78,12 @@ a b a,b a-b a.b a:b a;b a_b
a b a,b a-b a.b a:b a;b a_b
a b a,b a-b a.b a:b a;b a_b
argv[1] = <ef>
a.c
a.c
a.c
a.c
a.c
a.c
ok 1
ok 2
ok 3

View file

@ -193,7 +193,7 @@ esac
MYDIR=$PWD # save where we are
TESTDIR=/tmp/eglob-test
TESTDIR=/tmp/eglob-test-$$
mkdir $TESTDIR
builtin cd $TESTDIR || { echo $0: cannot cd to $TESTDIR >&2 ; exit 1; }
rm -rf *
@ -360,4 +360,6 @@ recho "${x#*(a|b)cd}"
# in the right place
builtin cd $MYDIR
${THIS_SH} ./extglob1.sub
exit 0

37
tests/extglob1.sub Normal file
View file

@ -0,0 +1,37 @@
MYDIR=$PWD
: ${TMPDIR:=/tmp}
GDIR=$TMPDIR/gtest-$$
shopt -s extglob
mkdir $GDIR || exit 1
cd $GDIR || exit 1
touch a.c
echo +([[:alpha:].])
echo +([[:alpha:].])+([[:alpha:].])
echo *([[:alpha:].])
echo *([[:alpha:].])*([[:alpha:].])
echo ?([[:alpha:].])?([[:alpha:].])?([[:alpha:].])
echo @([[:alpha:].])@([[:alpha:].])@([[:alpha:].])
case . in
!([[:alpha:].]) ) echo bad 1;;
*) echo ok 1;;
esac
case . in
?([[:alpha:].]) ) echo ok 2;;
*) echo bad 2;;
esac
case . in
@([[:alpha:].]) ) echo ok 3;;
*) echo bad 3;;
esac
cd $MYDIR
rm -rf $GDIR

View file

@ -27,7 +27,7 @@ f1 ()
return $status
}
before: try to assign to FUNCNAME
outside: FUNCNAME =
outside: FUNCNAME = main
before: FUNCNAME = func
FUNCNAME = func2
after: FUNCNAME = func
@ -148,3 +148,4 @@ expect 2 40
2 40
expect 5 20
5 20
5

View file

@ -132,7 +132,7 @@ func()
}
echo before: try to assign to FUNCNAME
FUCNAME=7
FUNCNAME=7
echo outside: FUNCNAME = $FUNCNAME
func
@ -165,4 +165,12 @@ myfunction() {
myfunction
myfunction | cat
segv()
{
echo foo | return 5
}
segv
echo $?
exit 0

View file

@ -20,7 +20,7 @@ jkl mno
fff is a function
fff ()
{
ed /tmp/foo >/dev/null <<ENDOFINPUT
ed /tmp/foo > /dev/null <<ENDOFINPUT
/^name/d
w
q
@ -31,7 +31,7 @@ ENDOFINPUT
fff is a function
fff ()
{
ed /tmp/foo >/dev/null <<ENDOFINPUT
ed /tmp/foo > /dev/null <<ENDOFINPUT
/^name/d
w
q

View file

@ -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 506: /${$(($#-1))}: bad substitution
argv[1] = <a>
argv[2] = <b>
argv[3] = <c>
@ -502,4 +502,17 @@ h
--blah
lah
lah
./new-exp.tests: line 558: ABXD: parameter unset
argv[1] = <>
argv[1] = <+>
argv[1] = <+^?>
argv[1] = <+>
argv[1] = <^?2>
argv[1] = <^?2>
argv[1] = <^?>
argv[1] = <^?>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <12>
./new-exp.tests: line 560: ABXD: parameter unset

View file

@ -212,9 +212,9 @@ recho ${av[1]/??/za}
expect '<zaza>'
recho ${av[1]//??/za}
expect '<zagh>'
recho ${av[1]//#??/za}
recho ${av[1]/#??/za}
expect '<efza>'
recho ${av[1]//%??/za}
recho ${av[1]/%??/za}
expect '<yyy> <yyy> <yyy> <yyy> <yyy> <yyy>'
recho ${av[@]/*/yyy}
@ -238,17 +238,17 @@ recho ${@/%??/xx}
expect '<zaza>'
recho ${3//??/za}
expect '<efza>'
recho ${3//%??/za}
recho ${3/%??/za}
expect '<zaza> <zaza> <zaza> <zaza> <zaza> <zaza>'
recho ${@//??/za}
expect '<zacd> <zagh> <zakl> <zaop> <zast> <zawx>'
recho ${@//#??/za}
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}
recho ${@/%x*/yyy}
expect a newline
echo $abmcde
@ -548,11 +548,13 @@ var=blah
# these had better agree
echo ${var[@]:3}
echo ${var:3}
echo ${var[@]//#/--}
echo ${var//#/--}
echo ${var[@]/#/--}
echo ${var/#/--}
echo ${var[@]##?}
echo ${var##?}
${THIS_SH} ./new-exp6.sub
# this must be last!
expect $0: 'ABXD: parameter unset'
recho ${ABXD:?"parameter unset"}

22
tests/new-exp6.sub Normal file
View file

@ -0,0 +1,22 @@
# quoted null problems in versions of bash prior to 3.2
str='12'
snul=$'\177'
recho "${str:2}"
recho "+${str:2}"
recho "+${snul:0:1}"
recho "+""${str:2}"
recho "${str/?/$snul}"
recho ${str/?/$snul}
recho "${snul/x/y}"
recho ${snul/x/y}
recho "${snul/$snul/}"
recho "${str/$str/}"
recho "${snul##$snul}"
recho "${str##$str}"
recho "${str##$nul}"

View file

@ -30,3 +30,8 @@ argv[1] = <hello, $"world">
argv[1] = <hello, \$"world">
argv[1] = <hello, $"world">
argv[1] = <hello, $world>
1
1
;foo
argv[1] = <^I>
argv[1] = <'A^IB'>

View file

@ -100,3 +100,17 @@ recho $'hello, \$"world"'
recho $'hello, $\"world"'
recho "hello, $"world""
# ansi quoting inside double-quoted command subst - bash-3.1 bug
echo $(set -- $'a b'; echo $#)
echo "$(set -- $'a b'; echo $#)"
echo "$(echo $';foo')"
args ()
{
for a in "$@";do echo "'$a'";done
}
unset mytab
recho "${mytab:-$'\t'}"
recho "$( args $'A\tB' )"

Binary file not shown.

View file

@ -67,7 +67,7 @@ printf -- "--%b--\n" '\t\0101'
printf -- "--%b--\n" '\t\101'
# these should all display `A7'
echo -e "\1017"
echo -e "\01017"
echo -e "\x417"
printf "%b\n" '\01017'
@ -246,3 +246,10 @@ printf '\x07e\n'
# additional backslash escapes
printf '\"\?\n'
# failures with decimal precisions until after bash-3.1
printf '%0.5d\n' 1
printf '%05d\n' 1
printf '%5d\n' 1
printf '%0d\n' 1

View file

@ -40,3 +40,29 @@ foo
bar
foo\
bar
argv[1] = <foo \\^Jbar>
argv[1] = <foo \^Jbar>
argv[1] = <sed> argv[2] = <-e> argv[3] = <s/[^I:]/\^J/g>
argv[1] = <sed> argv[2] = <-e> argv[3] = <s/[^I:]//g>
argv[1] = <foo\^Jbar>
argv[1] = <foobar>
argv[1] = <foo\^Jbar>
b
a
b
c
argv[1] = <a\>
argv[2] = <b>
argv[1] = <$>
argv[2] = <bab>
argv[1] = <$foo>
argv[2] = <bab>
argv[1] = <$foo>
argv[2] = <bab>
argv[1] = <`>
argv[2] = <ab>
argv[1] = <\>
argv[2] = <ab>
${
argv[1] = <(")>
argv[1] = <(")>

View file

@ -61,3 +61,51 @@ echo "$(echo 'foo
bar')"
echo "$(echo 'foo\
bar')"
# old-style command substitution parsing compatibility tests -- post bash-3.1
recho 'foo \\
bar'
recho 'foo \
bar'
echo `recho sed -e 's/[ :]/\\
/g'`
echo `recho sed -e 's/[ :]/\
/g'`
echo `recho 'foo\\
bar'`
echo `recho 'foo\
bar'`
echo $(recho 'foo\
bar')
a=`echo 'a b c' | sed 's/ /\\
/g' | grep 'b'`
echo $a
a=`echo 'a b c' | sed 's/ /\\
/g'`
echo "$a"
recho `echo 'a\' b`
recho `echo '\$' bab`
recho `echo '\$foo' bab`
recho `echo '$foo' bab`
recho `echo '\`' ab`
recho `echo '\\' ab`
echo `echo '${'`
recho `echo "(\\")"`
# produces no output
: `: "\\""`
# ultimate workaround
recho `echo "(\")"`

View file

@ -78,7 +78,7 @@ read line
echo $line
f ()
{
exec 5<$0;
exec 5< $0;
exec 0<&5-;
while read line; do
echo "$line";

View file

@ -22,3 +22,4 @@ abcd:~chet
ok 1
ok 2
ok 3
~root

View file

@ -64,3 +64,6 @@ case $unset in
"") echo ok 3 ;;
*) echo bad 3 ;;
esac
USER=root # should exist just about everywhere
echo ~$USER