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

This commit is contained in:
Jari Aalto
2009-09-12 16:46:53 +00:00
parent b72432fdcc
commit bb70624e96
387 changed files with 28522 additions and 9334 deletions
+72
View File
@@ -0,0 +1,72 @@
0
1
2
0
1
2
0
1
2
0
2
4
fx is a function
fx ()
{
i=0;
for (( 1 ; i < 3 ; i++ ))
do
echo $i;
done;
for (( i=0 ; 1 ; i++ ))
do
if (( " i >= 3 " )); then
break;
fi;
echo $i;
done;
for (( i=0 ; i<3 ; 1 ))
do
echo $i;
(( " i++ " ));
done;
i=0;
for (( 1 ; 1 ; 1 ))
do
if (( " i > 2 " )); then
break;
fi;
echo $i;
(( " i++ " ));
done;
i=0;
for (( 1 ; 1 ; 1 ))
do
if (( " i > 2 " )); then
break;
fi;
echo $i;
(( " i++ " ));
done
}
0
1
2
0
1
2
0
1
2
0
1
2
0
1
2
./arith-for.tests: line 77: syntax error: arithmetic expression required
./arith-for.tests: line 77: syntax error: `(( i=0; "i < 3" ))'
2
./arith-for.tests: line 83: syntax error: `;' unexpected
./arith-for.tests: line 83: syntax error: `(( i=0; i < 3; i++; 7 ))'
2
+87
View File
@@ -0,0 +1,87 @@
fx()
{
i=0
for (( ; i < 3; i++ ))
do
echo $i
done
for (( i=0; ; i++ ))
do
if (( i >= 3 )); then
break;
fi
echo $i
done
for (( i=0; i<3; ))
do
echo $i
(( i++ ))
done
i=0
for (( ; ; ))
do
if (( i > 2 )); then
break;
fi
echo $i;
(( i++ ))
done
i=0
for ((;;))
do
if (( i > 2 )); then
break;
fi
echo $i;
(( i++ ))
done
}
for (( i=0; "i < 3" ; i++ ))
do
echo $i
done
i=0
for (( ; "i < 3"; i++ ))
do
echo $i
done
for (( i=0; ; i++ ))
do
if (( i >= 3 )); then
break;
fi
echo $i
done
for ((i = 0; ;i++ ))
do
echo $i
if (( i < 3 )); then
(( i++ ))
continue;
fi
break
done
type fx
fx
# errors
for (( i=0; "i < 3" ))
do
echo $i
done
echo $?
for (( i=0; i < 3; i++; 7 ))
do
echo $i
done
echo $?
+24
View File
@@ -120,3 +120,27 @@ ok
131072
2147483647
1
4
4
5
5
4
3
3
4
4
7
./arith.tests: 7-- : syntax error: operand expected (error token is " ")
./arith.tests: --x=7 : attempted assignment to non-variable (error token is "=7 ")
./arith.tests: ++x=7 : attempted assignment to non-variable (error token is "=7 ")
./arith.tests: x++=7 : attempted assignment to non-variable (error token is "=7 ")
./arith.tests: x--=7 : attempted assignment to non-variable (error token is "=7 ")
4
7
-7
7
7
8 12
./arith.tests: ((: x=9 y=41 : syntax error in expression (error token is "y=41 ")
./arith.tests: a b: syntax error in expression (error token is "b")
./arith.tests: ((: a b: syntax error in expression (error token is "b")
+47
View File
@@ -220,3 +220,50 @@ echo $(( 2**(16-1)))
echo $(( 2**16*2 ))
echo $(( 2**31-1))
echo $(( 2**0 ))
# {pre,post}-{inc,dec}rement and associated errors
x=4
echo $x
echo $(( x++ ))
echo $x
echo $(( x-- ))
echo $x
echo $(( --x ))
echo $x
echo $(( ++x ))
echo $x
echo $(( ++7 ))
echo $(( 7-- ))
echo $(( --x=7 ))
echo $(( ++x=7 ))
echo $(( x++=7 ))
echo $(( x--=7 ))
echo $x
echo $(( +7 ))
echo $(( -7 ))
echo $(( ++7 ))
echo $(( --7 ))
x=4
y=7
(( x=8 , y=12 ))
echo $x $y
# should be an error
(( x=9 y=41 ))
# These are errors
echo $((a b))
((a b))
+17
View File
@@ -1,3 +1,6 @@
./array.tests: array assign: line 10: syntax error near unexpected token `&'
./array.tests: array assign: line 10: `first & second'
1
abcde
abcde
abcde bdef
@@ -101,3 +104,17 @@ grep [ 123 ] *
length = 3
value = new1 new2 new3
./array.tests: narray: unbound variable
a b c d e f g
for case if then else
<> < > !
12 14 16 18 20
4414758999202
./array.tests: array assign: line 257: syntax error near unexpected token `for'
./array.tests: array assign: line 257: `a b c for case if then else'
./array.tests: array assign: line 259: syntax error near unexpected token `for'
./array.tests: array assign: line 259: `for case if then else'
./array.tests: array assign: line 261: syntax error near unexpected token `<>'
./array.tests: array assign: line 261: ` <> < > ! '
./array.tests: array assign: line 262: syntax error near unexpected token `[1]=<>'
./array.tests: array assign: line 262: ` [1]=<> [2]=< [3]=> [4]=! '
+40
View File
@@ -6,6 +6,11 @@ set +a
# The calls to egrep -v are to filter out builtin array variables that are
# automatically set and possibly contain values that vary.
# this should be an error
test=(first & second)
echo $?
unset test
# make sure declare -a converts an existing variable to an array
unset a
a=abcde
@@ -220,3 +225,38 @@ echo "value = ${barray[*]}"
# make sure the array code behaves correctly with respect to unset variables
set -u
( echo ${#narray[4]} )
# some old bugs and ksh93 compatibility tests
set +u
cd /tmp
touch 1=bar
foo=([10]="bar")
echo ${foo[0]}
rm 1=bar
foo=(a b c d e f g)
echo ${foo[@]}
# quoted reserved words are ok
foo=(\for \case \if \then \else)
echo ${foo[@]}
# quoted metacharacters are ok
foo=( [1]='<>' [2]='<' [3]='>' [4]='!' )
echo ${foo[@]}
# numbers are just words when not in a redirection context
foo=( 12 14 16 18 20 )
echo ${foo[@]}
foo=( 4414758999202 )
echo ${foo[@]}
# errors
foo=(a b c for case if then else)
foo=(for case if then else)
metas=( <> < > ! )
metas=( [1]=<> [2]=< [3]=> [4]=! )
+5
View File
@@ -124,4 +124,9 @@ ok
ok
./builtins.tests: kill: bad signal number: 4096
1
a\n\n\nb
a
b
./builtins.tests: exit: bad non-numeric arg `status'
+4 -1
View File
@@ -183,7 +183,7 @@ echo "$@"
echo "$@"
# test out cd and $CDPATH
${THIS_SH} ./builtins.sub1
${THIS_SH} ./builtins1.sub
# test behavior of `.' when given a non-existant file argument
${THIS_SH} ./source5.sub
@@ -253,6 +253,9 @@ 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
+10
View File
@@ -0,0 +1,10 @@
# test behavior of shopt xpg_echo
USG_ECHO=off
shopt -q xpg_echo && USG_ECHO=on
shopt -u xpg_echo
echo 'a\n\n\nb'
shopt -s xpg_echo
echo 'a\n\n\nb'
+2 -2
View File
@@ -55,8 +55,8 @@ tf2 ()
{
( {
time -p echo a | cat - >/dev/null
} ) 2>&1
}
} )
} 2>&1
cprint.tests is a regular file
cprint.tests is not a directory
a
+2 -2
View File
@@ -48,6 +48,7 @@ hash: usage: hash [-r] [-p pathname] [name ...]
./errors.tests: umask: bad symbolic mode operator: :
./errors.tests: umask: illegal option: -i
umask: usage: umask [-p] [-S] [mode]
./errors.tests: umask: bad character in symbolic mode: u
./errors.tests: VAR: readonly variable
./errors.tests: declare: VAR: readonly variable
./errors.tests: declare: VAR: readonly variable
@@ -71,8 +72,7 @@ source: usage: source filename
./errors.tests: enable: sh: not a shell builtin
./errors.tests: enable: bash: not a shell builtin
./errors.tests: shopt: cannot set and unset shell options simultaneously
./errors.tests: read: illegal option: -t
read: usage: read [-r] [-p prompt] [-a array] [-e] [name ...]
./errors.tests: read: var: invalid timeout specification
./errors.tests: read: `/bin/sh': not a valid identifier
./errors.tests: VAR: readonly variable
./errors.tests: readonly: illegal option: -x
+9 -1
View File
@@ -140,6 +140,14 @@ umask -S u:rwx,g:rwx,o:rx >/dev/null # 002
# at some point, this may mean `invert', but for now it is an error
umask -i
# bad assignments shouldn't change the umask
mask=$(umask)
umask g=u
mask2=$(umask)
if [ "$mask" != "$mask2" ]; then
echo "umask errors change process umask"
fi
# assignment to a readonly variable in environment
VAR=4
readonly VAR
@@ -183,7 +191,7 @@ enable sh bash
# try to set and unset shell options simultaneously
shopt -s -u checkhash
# someday, this may give `read' a timeout, but for now it is an error
# this is an error -- bad timeout spec
read -t var < /dev/null
# try to read into an invalid identifier
+3
View File
@@ -79,3 +79,6 @@ ${THIS_SH} ./exec4.sub
# try exec'ing a command that cannot be found in $PATH
${THIS_SH} ./exec5.sub
# this was a bug in bash versions before bash-2.04
${THIS_SH} -c 'cat </dev/null | cat >/dev/null' >&-
+1
View File
@@ -329,6 +329,7 @@ rm -rf $TESTDIR
mkdir $TESTDIR
builtin cd $TESTDIR
LC_COLLATE=C # have to set this; it affects the sorting
touch a.b a,b a:b a-b a\;b a\ b a_b
echo a[^[:alnum:]]b
+70
View File
@@ -0,0 +1,70 @@
0: [[ fofo = *(f*(o)) ]]
0: [[ ffo = *(f*(o)) ]]
0: [[ foooofo = *(f*(o)) ]]
0: [[ foooofof = *(f*(o)) ]]
0: [[ fooofoofofooo = *(f*(o)) ]]
1: [[ foooofof = *(f+(o)) ]]
1: [[ xfoooofof = *(f*(o)) ]]
1: [[ foooofofx = *(f*(o)) ]]
0: [[ ofxoofxo = *(*(of*(o)x)o) ]]
1: [[ ofooofoofofooo = *(f*(o)) ]]
0: [[ foooxfooxfoxfooox = *(f*(o)x) ]]
1: [[ foooxfooxofoxfooox = *(f*(o)x) ]]
0: [[ foooxfooxfxfooox = *(f*(o)x) ]]
0: [[ ofxoofxo = *(*(of*(o)x)o) ]]
0: [[ ofoooxoofxo = *(*(of*(o)x)o) ]]
0: [[ ofoooxoofxoofoooxoofxo = *(*(of*(o)x)o) ]]
0: [[ ofoooxoofxoofoooxoofxoo = *(*(of*(o)x)o) ]]
1: [[ ofoooxoofxoofoooxoofxofo = *(*(of*(o)x)o) ]]
0: [[ ofoooxoofxoofoooxoofxooofxofxo = *(*(of*(o)x)o) ]]
0: [[ aac = *(@(a))a@(c) ]]
0: [[ ac = *(@(a))a@(c) ]]
1: [[ c = *(@(a))a@(c) ]]
0: [[ aaac = *(@(a))a@(c) ]]
1: [[ baaac = *(@(a))a@(c) ]]
0: [[ abcd = ?@(a|b)*@(c)d ]]
0: [[ abcd = @(ab|a*@(b))*(c)d ]]
0: [[ acd = @(ab|a*(b))*(c)d ]]
0: [[ abbcd = @(ab|a*(b))*(c)d ]]
0: [[ effgz = @(b+(c)d|e*(f)g?|?(h)i@(j|k)) ]]
0: [[ efgz = @(b+(c)d|e*(f)g?|?(h)i@(j|k)) ]]
0: [[ egz = @(b+(c)d|e*(f)g?|?(h)i@(j|k)) ]]
0: [[ egzefffgzbcdij = *(b+(c)d|e*(f)g?|?(h)i@(j|k)) ]]
1: [[ egz = @(b+(c)d|e+(f)g?|?(h)i@(j|k)) ]]
0: [[ ofoofo = *(of+(o)) ]]
0: [[ oxfoxoxfox = *(oxf+(ox)) ]]
1: [[ oxfoxfox = *(oxf+(ox)) ]]
0: [[ ofoofo = *(of+(o)|f) ]]
0: [[ foofoofo = @(foo|f|fo)*(f|of+(o)) ]]
0: [[ oofooofo = *(of|oof+(o)) ]]
0: [[ fffooofoooooffoofffooofff = *(*(f)*(o)) ]]
0: [[ fofoofoofofoo = *(fo|foo) ]]
0: [[ foo = !(x) ]]
0: [[ foo = !(x)* ]]
1: [[ foo = !(foo) ]]
0: [[ foo = !(foo)* ]]
0: [[ foobar = !(foo) ]]
0: [[ foobar = !(foo)* ]]
0: [[ moo.cow = !(*.*).!(*.*) ]]
1: [[ mad.moo.cow = !(*.*).!(*.*) ]]
1: [[ mucca.pazza = mu!(*(c))?.pa!(*(z))? ]]
0: [[ fff = !(f) ]]
0: [[ fff = *(!(f)) ]]
0: [[ fff = +(!(f)) ]]
0: [[ ooo = !(f) ]]
0: [[ ooo = *(!(f)) ]]
0: [[ ooo = +(!(f)) ]]
0: [[ foo = !(f) ]]
0: [[ foo = *(!(f)) ]]
0: [[ foo = +(!(f)) ]]
1: [[ f = !(f) ]]
1: [[ f = *(!(f)) ]]
1: [[ f = +(!(f)) ]]
0: [[ foot = @(!(z*)|*x) ]]
1: [[ zoot = @(!(z*)|*x) ]]
0: [[ foox = @(!(z*)|*x) ]]
0: [[ zoox = @(!(z*)|*x) ]]
0: [[ foo = *(!(foo)) ]]
1: [[ foob = !(foo)b* ]]
0: [[ foobb = !(foo)b* ]]
0 tests failed.
+90
View File
@@ -0,0 +1,90 @@
#
# More ksh-like extended globbing tests, cribbed from zsh-3.1.5
#
shopt -s extglob
failed=0
while read res str pat; do
[[ $res = '#' ]] && continue
[[ $str = ${pat} ]]
ts=$?
[[ $1 = -q ]] || echo "$ts: [[ $str = $pat ]]"
if [[ ( $ts -gt 0 && $res = t) || ($ts -eq 0 && $res = f) ]]; then
echo "Test failed: [[ $str = $pat ]]"
(( failed += 1 ))
fi
done <<EOT
t fofo *(f*(o))
t ffo *(f*(o))
t foooofo *(f*(o))
t foooofof *(f*(o))
t fooofoofofooo *(f*(o))
f foooofof *(f+(o))
f xfoooofof *(f*(o))
f foooofofx *(f*(o))
t ofxoofxo *(*(of*(o)x)o)
f ofooofoofofooo *(f*(o))
t foooxfooxfoxfooox *(f*(o)x)
f foooxfooxofoxfooox *(f*(o)x)
t foooxfooxfxfooox *(f*(o)x)
t ofxoofxo *(*(of*(o)x)o)
t ofoooxoofxo *(*(of*(o)x)o)
t ofoooxoofxoofoooxoofxo *(*(of*(o)x)o)
t ofoooxoofxoofoooxoofxoo *(*(of*(o)x)o)
f ofoooxoofxoofoooxoofxofo *(*(of*(o)x)o)
t ofoooxoofxoofoooxoofxooofxofxo *(*(of*(o)x)o)
t aac *(@(a))a@(c)
t ac *(@(a))a@(c)
f c *(@(a))a@(c)
t aaac *(@(a))a@(c)
f baaac *(@(a))a@(c)
t abcd ?@(a|b)*@(c)d
t abcd @(ab|a*@(b))*(c)d
t acd @(ab|a*(b))*(c)d
t abbcd @(ab|a*(b))*(c)d
t effgz @(b+(c)d|e*(f)g?|?(h)i@(j|k))
t efgz @(b+(c)d|e*(f)g?|?(h)i@(j|k))
t egz @(b+(c)d|e*(f)g?|?(h)i@(j|k))
t egzefffgzbcdij *(b+(c)d|e*(f)g?|?(h)i@(j|k))
f egz @(b+(c)d|e+(f)g?|?(h)i@(j|k))
t ofoofo *(of+(o))
t oxfoxoxfox *(oxf+(ox))
f oxfoxfox *(oxf+(ox))
t ofoofo *(of+(o)|f)
# The following is supposed to match only as fo+ofo+ofo
t foofoofo @(foo|f|fo)*(f|of+(o))
t oofooofo *(of|oof+(o))
t fffooofoooooffoofffooofff *(*(f)*(o))
# The following tests backtracking in alternation matches
t fofoofoofofoo *(fo|foo)
# Exclusion
t foo !(x)
t foo !(x)*
f foo !(foo)
t foo !(foo)*
t foobar !(foo)
t foobar !(foo)*
t moo.cow !(*.*).!(*.*)
f mad.moo.cow !(*.*).!(*.*)
f mucca.pazza mu!(*(c))?.pa!(*(z))?
t fff !(f)
t fff *(!(f))
t fff +(!(f))
t ooo !(f)
t ooo *(!(f))
t ooo +(!(f))
t foo !(f)
t foo *(!(f))
t foo +(!(f))
f f !(f)
f f *(!(f))
f f +(!(f))
t foot @(!(z*)|*x)
f zoot @(!(z*)|*x)
t foox @(!(z*)|*x)
t zoox @(!(z*)|*x)
t foo *(!(foo))
f foob !(foo)b*
t foobb !(foo)b*
EOT
echo "$failed tests failed."
+92
View File
@@ -26,3 +26,95 @@ f1 ()
echo $status;
return $status
}
before: try to assign to FUNCNAME
outside: FUNCNAME =
before: FUNCNAME = func
FUNCNAME = func2
after: FUNCNAME = func
outside2: FUNCNAME =
function
zf is a function
zf ()
{
echo this is zf
}
f is a function
f ()
{
echo f-x;
echo f-y
} 1>&2
subshell
f is a function
f ()
{
echo f-x;
echo f-y
} 1>&2
f2 is a function
f2 ()
{
echo f2-a;
function f3 ()
{
echo f3-a;
echo f3-b
} 1>&2;
f3
}
subshell
f2 is a function
f2 ()
{
echo f2-a;
function f3 ()
{
echo f3-a;
echo f3-b
} 1>&2;
f3
}
f4 is a function
f4 ()
{
echo f4-a;
function f5 ()
{
echo f5-a;
echo f5-b
} 1>&2;
f5
} 2>&1
subshell
f4 is a function
f4 ()
{
echo f4-a;
function f5 ()
{
echo f5-a;
echo f5-b
} 1>&2;
f5
} 2>&1
testgrp is a function
testgrp ()
{
echo testgrp-a;
{
echo tg-x;
echo tg-y
} 1>&2;
echo testgrp-b
}
subshell
testgrp is a function
testgrp ()
{
echo testgrp-a;
{
echo tg-x;
echo tg-y
} 1>&2;
echo testgrp-b
}
+34
View File
@@ -117,3 +117,37 @@ declare -f f1 # should print the definition, too
# no functions should be exported, right?
declare -xF
declare -xf
# FUNCNAME tests
func2()
{
echo FUNCNAME = $FUNCNAME
}
func()
{
echo before: FUNCNAME = $FUNCNAME
func2
echo after: FUNCNAME = $FUNCNAME
}
echo before: try to assign to FUNCNAME
FUCNAME=7
echo outside: FUNCNAME = $FUNCNAME
func
echo outside2: FUNCNAME = $FUNCNAME
# test exported functions (and cached exportstr)
zf()
{
echo this is zf
}
export -f zf
${THIS_SH} -c 'type -t zf'
${THIS_SH} -c 'type zf'
${THIS_SH} ./func1.sub
exit 0
+55
View File
@@ -0,0 +1,55 @@
#
# Test that redirections attached to shell functions are printed correctly.
# This was a bug in all bash versions before bash-2.04.
#
f()
{
echo f-x
echo f-y
} >&2
type f
export -f f
${THIS_SH} -c 'echo subshell; type f'
f2()
{
echo f2-a
f3()
{
echo f3-a
echo f3-b
} >&2
f3
}
type f2
export -f f2
${THIS_SH} -c 'echo subshell; type f2'
f4()
{
echo f4-a
f5()
{
echo f5-a
echo f5-b
} >&2
f5
} 2>&1
type f4
export -f f4
${THIS_SH} -c 'echo subshell; type f4'
testgrp()
{
echo testgrp-a
{ echo tg-x; echo tg-y; } >&2
echo testgrp-b
}
type testgrp
export -f testgrp
${THIS_SH} -c 'echo subshell; type testgrp'
+1 -1
View File
@@ -1,5 +1,5 @@
./history.tests: history: illegal option: -x
history: usage: history [-c] [n] or history -awrn [filename] or history -ps arg [arg...]
history: usage: history [-c] [-d offset] [n] or history -awrn [filename] or history -ps arg [arg...]
./history.tests: history: cannot use more than one of -anrw
./history.tests: fc: illegal option: -v
fc: usage: fc [-e ename] [-nlr] [first] [last] or fc -s [pat=rep] [cmd]
+10
View File
@@ -0,0 +1,10 @@
1
1
1
0
0
1
0
1
0
1
+19
View File
@@ -0,0 +1,19 @@
# tests of return value inversion
# placeholder for future expansion
# user subshells (...) did this wrong in bash versions before 2.04
! ( echo hello | grep h >/dev/null 2>&1 ); echo $?
! echo hello | grep h >/dev/null 2>&1 ; echo $?
! true ; echo $?
! false; echo $?
! (false) ; echo $?
! (true); echo $?
! true | false ; echo $?
! false | true ; echo $?
! (true | false) ; echo $?
! (false | true) ; echo $?
+16
View File
@@ -1,5 +1,21 @@
./jobs2.sub: fg: job %1 started without job control
fg: 1
Waiting for job 0
job 0 returns 0
Waiting for job 1
job 1 returns 0
Waiting for job 2
job 2 returns 0
Waiting for job 3
job 3 returns 0
Waiting for job 4
job 4 returns 0
Waiting for job 5
job 5 returns 0
Waiting for job 6
job 6 returns 0
Waiting for job 7
job 7 returns 0
0
./jobs.tests: wait: job control not enabled
./jobs.tests: fg: no job control
+4
View File
@@ -4,6 +4,10 @@ ${THIS_SH} ./jobs1.sub
# test out fg/bg failure in a subshell
${THIS_SH} ./jobs2.sub
# test out behavior of waiting for background pids -- bug in versions
# before 2.03
${THIS_SH} ./jobs3.sub
jobs
echo $?
+26
View File
@@ -0,0 +1,26 @@
#! /bin/bash
NJOB=8
i=0
while [ $i -lt $NJOB ]
do
/bin/sh -c "sleep 4; exit 0" &
rv=$?
pid=$!
eval bg_pid_$i=$pid
# echo $$: Job $i: pid is $pid rv=$rv
i=$((i + 1))
done
i=0
while [ $i -lt $NJOB ]
do
eval wpid=\$bg_pid_$i
echo Waiting for job $i #'('pid $wpid')'
wait $wpid
rv=$?
echo job $i returns $rv
i=$((i + 1))
done
+16
View File
@@ -0,0 +1,16 @@
exec 9<>/dev/tcp/129.22.8.162/25
read banner <&9
echo "$banner"
echo quit >&9
read msg <&9
echo "$msg"
exec 9<&-
# nifty date command that queries the date/time server
cat < /dev/tcp/129.22.8.102/13
exit 0
+11
View File
@@ -0,0 +1,11 @@
# interactive
# from tty
read -n 3 -p 'enter three chars: ' xyz
echo
echo $xyz
# using readline
read -p 'enter 3 chars: ' -e -n 3 abc
# readline outputs a newline for us, so we don't need the extra echo
echo $abc
+25
View File
@@ -0,0 +1,25 @@
#! /bin/bash
i=0
while [ $i -lt $1 ]
do
/bin/sh -c "sleep 4; exit 0" &
rv=$?
pid=$!
eval bg_pid_$i=$pid
echo $$: Job $i: pid is $pid rv=$rv
i=$((i + 1))
done
i=0
while [ $i -lt $1 ]
do
eval wpid=\$bg_pid_$i
echo Waiting for job $i '('pid $wpid')'
wait $wpid
rv=$?
echo Return value is $rv
i=$((i + 1))
done
+4
View File
@@ -202,3 +202,7 @@ argv[3] = <}>
argv[1] = <hi>
argv[2] = <K>
argv[3] = <}>
argv[1] = <xxx>
argv[2] = <yyy>
1
argv[1] = <>
+22
View File
@@ -453,6 +453,10 @@ recho + "$@"
expect '<+>'
recho +"$@"
# variants of nested curly braces inside ${...} expressions
# IFS is not the standard one
expect '<G { I>' '<K>' '<}>'
recho ${gik:-G { I } K }
@@ -460,3 +464,21 @@ abc=hi
expect '<hi>' '<K>' '<}>'
recho ${abc:-G { I } K }
# reset IFS to the default
IFS='
'
# nested ${...} inside ${...} are handled specially
unset XXX FOO BAR
expect '<xxx>' '<yyy>'
XXX=xxx
FOO=${BAR:-${XXX} yyy}
recho $FOO
# this was a bug in versions of bash prior to bash-2.04-release
set -- ''
expect 1
echo $#
expect '<>'
recho "${@:-}"
+44
View File
@@ -148,6 +148,12 @@ argv[4] = <mnop>
argv[5] = <qrst>
argv[6] = <uvwyyy>
This
string
has
multiple
lines.
This-string-has-multiple-lines.
this is a test of proc subst
this is test 2
./new-exp2.sub: /tmp/bashtmp.x*: No such file or directory
@@ -228,6 +234,10 @@ argv[1] = <e*docrine>
argv[1] = <e*docri*e>
argv[1] = <endocrine>
argv[1] = <endocrine>
argv[1] = <endocrine>
argv[1] = <endocrine>
argv[1] = <endocrine>
argv[1] = <endocrine>
argv[1] = </usr/bin>
argv[2] = </bin>
argv[3] = </usr/local/bin>
@@ -390,4 +400,38 @@ argv[1] = <5>
argv[1] = <#>
argv[1] = <#>
argv[1] = <>
argv[1] = <_QUANTITY>
argv[2] = <_QUART>
argv[3] = <_QUEST>
argv[4] = <_QUILL>
argv[5] = <_QUOTA>
argv[6] = <_QUOTE>
argv[1] = <_QUANTITY>
argv[2] = <_QUART>
argv[3] = <_QUEST>
argv[4] = <_QUILL>
argv[5] = <_QUOTA>
argv[6] = <_QUOTE>
argv[1] = <_QUANTITY-_QUART-_QUEST-_QUILL-_QUOTA-_QUOTE>
./new-exp3.sub: ${!_Q* }: bad substitution
./new-exp3.sub: ${!1*}: bad substitution
./new-exp3.sub: ${!@*}: bad substitution
./new-exp.tests: ${$(($#-1))}: bad substitution
argv[1] = <a>
argv[2] = <b>
argv[3] = <c>
argv[4] = <d>
argv[5] = <e>
argv[6] = <f>
argv[7] = <g>
argv[1] = <a>
argv[2] = <b>
argv[3] = <c>
argv[4] = <d>
argv[5] = <e>
argv[1] = <a>
argv[1] = <a>
argv[2] = <b>
argv[1] = <>
./new-exp.tests: $(($# - 2)): substring expression < 0
./new-exp.tests: ABXD: parameter unset
+40
View File
@@ -227,6 +227,15 @@ 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
@@ -402,6 +411,11 @@ 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
@@ -455,6 +469,32 @@ recho "${RECEIVED:$((${#RECEIVED}-1)):1}"
RECEIVED=""
recho "${RECEIVED:$((${#RECEIVED}-1)):1}"
# tests of new prefix expansion ${!prefix*}
${THIS_SH} ./new-exp3.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))}
# this must be last!
expect $0: 'ABXD: parameter unset'
recho ${ABXD:?"parameter unset"}
+26
View File
@@ -0,0 +1,26 @@
:
# Set up some dummy variables beginning with _Q
_QUANTITY=
_QUOTA=
_QUOTE=
_QUILL=
_QUEST=
_QUART=
recho ${!_Q*}
IFS="-$IFS"
recho ${!_Q*}
recho "${!_Q*}"
recho ${!_Y*}
recho "${!_Q* }"
IFS=$' \t\n'
set a b c d e f g h i j k l m n o p
recho ${!1*}
recho ${!@*}
+5
View File
@@ -1,4 +1,5 @@
argv[1] = <^J^J^J>
argv[1] = <++^J++>
argv[1] = <>
argv[1] = <^J^I >
argv[1] = <abc>
@@ -15,3 +16,7 @@ argv[1] = <hello, $"world">
argv[1] = <$hello, chet>
argv[1] = <hello, chet>
ok
'abcd'
'abcd'
\'abcd\'
\'abcd\'
+17
View File
@@ -6,6 +6,11 @@ expect()
expect '<^J^J^J>'
recho $'\n\n\n'
expect '<++^J++>'
f=$'\n'
recho "++$f++"
unset f
z1=$''
expect '<>'
recho "$z1"
@@ -61,3 +66,15 @@ case "$z" in
$'\v\f\a\b') echo ok;;
*) echo bad;;
esac
# Dave Korn says this should be allowed and echo 'abcd'
echo $'\'abcd\''
# printf translates \' to ' ...
printf "\'abcd\'\n"
# but echo -e doesn't
echo -e "\'abcd\'"
echo -e "\\'abcd\\'"
Binary file not shown.
+29
View File
@@ -1,4 +1,5 @@
LC_ALL=C
LC_NUMERIC=C
# these should output error messages -- the format is required
printf
@@ -22,6 +23,11 @@ printf "no newline " ; printf "now newline\n"
# %% -> %
printf "%%\n"
# this was a bug caused by pre-processing the string for backslash escapes
# before doing the `%' format processing -- all versions before bash-2.04
printf "\045" ; echo
printf "\045d\n"
# simple character output
printf "%c\n" ABCD
@@ -83,6 +89,12 @@ printf -- "--%b--\n"
# of the format string
printf -- "--%b--\n" '4.2\c5.4\n'; printf "\n"
# unrecognized escape sequences should by displayed unchanged
printf -- "--%b--\n" '4\.2'
# a bare \ should not be processed as an escape sequence
printf -- "--%b--\n" '\'
# make sure extra arguments are ignored if the format string doesn't
# actually use them
printf "\n" 4.4 BSD
@@ -158,6 +170,23 @@ printf -- "--%6.4b--\n" abcdefghijklmnopqrstuvwxyz
printf -- "--%12.10s--\n" abcdefghijklmnopqrstuvwxyz
printf -- "--%12.10b--\n" abcdefghijklmnopqrstuvwxyz
# tests for translating \' to ' and \\ to \
# printf translates \' to ' in the format string...
printf "\'abcd\'\n"
# but not when the %b format specification is used
printf "%b\n" \\\'abcd\\\'
# but both translate \\ to \
printf '\\abcd\\\n'
printf "%b\n" '\\abcd\\'
# this was reported as a bug in bash-2.03
# these three lines should all echo `26'
printf "%d\n" 0x1a
printf "%d\n" 032
printf "%d\n" 26
# error messages
# this should be an overflow, but error messages vary between systems
+16
View File
@@ -29,3 +29,19 @@ argv[1] = < foo>
argv[1] = <foo>
argv[1] = <foo>
argv[1] = < foo>
a = abcdefg
a = xyz
a = -xyz 123-
a = abc
1
4
1
4
./read2.sub: read: -3: invalid timeout specification
1
4
abcde
./read3.sub: read: -1: invalid number specification
abc
ab
#
+9
View File
@@ -78,3 +78,12 @@ echo " foo" | { IFS=$' \n' ; read line; recho "$line"; }
echo " foo" | { IFS=$' \t\n' ; read line; recho "$line"; }
echo " foo" | { IFS=$':' ; read line; recho "$line"; }
# test read -d delim behavior
${THIS_SH} ./read1.sub
# test read -t timeout behavior
${THIS_SH} ./read2.sub
# test read -n nchars behavior
${THIS_SH} ./read3.sub
+23
View File
@@ -0,0 +1,23 @@
a=7
echo 'abcdefg|xyz' | {
read -d '|' a
echo a = "${a-unset}"
}
echo xyz 123 | {
read -d ' ' a
echo a = "${a-unset}"
}
echo xyz 123 | {
read -d $'\n' a
echo a = -"${a-unset}"-
}
a=44
echo abcd | {
read -d d a
echo a = $a
}
exit 0
+22
View File
@@ -0,0 +1,22 @@
a=4
read -t 2 a
echo $?
echo $a
sleep 5 | read -t 1 a
echo $?
echo $a
read -t -3 a
echo $?
echo $a
# the above should all time out
echo abcde | {
read -t 2 a
echo $a
}
+19
View File
@@ -0,0 +1,19 @@
# non-interactive
# error
read -n -1
# from pipe -- should work, but doesn't change tty attributes
echo abcdefg | {
read -n 3 xyz
echo $xyz
}
# fewer chars than specified
echo ab | {
read -n 3 xyz
echo $xyz
}
read -n 1 < $0
echo "$REPLY"
+5
View File
@@ -140,6 +140,11 @@ cd
EOF
echo $l2
# These should not echo anything -- bug in versions before 2.04
( ( echo hello 1>&3 ) 3>&1 ) >/dev/null 2>&1
( ( echo hello 1>&3 ) 3>&1 ) >/dev/null 2>&1 | cat
# in posix mode, non-interactive shells are not allowed to perform
# filename expansion on input redirections, even if they expand to
# a single filename
+3 -1
View File
@@ -13,12 +13,14 @@ export THIS_SH
${THIS_SH} ./version
rm -f /tmp/xx
echo Any output from any test, unless otherwise noted, indicates a possible anomaly
for x in run-*
do
case $x in
$0|run-minimal) ;;
$0|run-minimal|run-gprof) ;;
*.orig|*~) ;;
*) echo $x ; sh $x ;;
esac
+2
View File
@@ -0,0 +1,2 @@
${THIS_SH} ./arith-for.tests > /tmp/xx 2>&1
diff /tmp/xx arith-for.right && rm -f /tmp/xx
+4
View File
@@ -0,0 +1,4 @@
PATH=$PATH:`pwd`
export PATH
${THIS_SH} ./extglob2.tests | grep -v '^expect' > /tmp/xx
diff /tmp/xx extglob2.right && rm -f /tmp/xx
+2
View File
@@ -0,0 +1,2 @@
${THIS_SH} ./invert.tests | grep -v '^expect' > /tmp/xx
diff /tmp/xx invert.right && rm -f /tmp/xx
+4 -2
View File
@@ -16,6 +16,8 @@ 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-*
@@ -24,8 +26,8 @@ do
$0) ;;
*.orig|*~) ;;
run-dollars|run-execscript|run-func|run-getopts|run-heredoc) echo $x ; sh $x ;;
run-ifs-tests|run-input-test|run-more-exp|run-nquote|run-posix2) echo $x ; sh $x ;;
run-posixpat) echo $x ; sh $x ;;
run-ifs-tests|run-input-test|run-invert|run-more-exp|run-nquote) echo $x ; sh $x ;;
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
+3
View File
@@ -2,6 +2,9 @@ echo "warning: two of these tests will fail if your OS does not support" >&2
echo "warning: named pipes or the /dev/fd filesystem. If the tests of the" >&2
echo "warning: process substitution mechanism fail, please do not consider" >&2
echo "warning: this a test failure" >&2
echo "warning: if you have exported variables beginning with the string _Q," >&2
echo "warning: diff output may be generated. If so, please do not consider" >&2
echo "warning: this a test failure" >&2
${THIS_SH} ./new-exp.tests 2>&1 | grep -v '^expect' > /tmp/xx
diff /tmp/xx new-exp.right && rm -f /tmp/xx
+1 -1
View File
@@ -1,2 +1,2 @@
${THIS_SH} ./read.tests > /tmp/xx
${THIS_SH} ./read.tests > /tmp/xx 2>&1
diff /tmp/xx read.right && rm -f /tmp/xx
+1 -1
View File
@@ -1,2 +1,2 @@
${THIS_SH} ./test-tests >/tmp/xx 2>&1
${THIS_SH} ./test.tests >/tmp/xx 2>&1
diff /tmp/xx test.right && rm -f /tmp/xx
+8
View File
@@ -18,12 +18,15 @@ shopt -u huponexit
shopt -s interactive_comments
shopt -u lithist
shopt -u mailwarn
shopt -u no_empty_cmd_completion
shopt -u nocaseglob
shopt -u nullglob
shopt -s progcomp
shopt -s promptvars
shopt -u restricted_shell
shopt -u shift_verbose
shopt -s sourcepath
shopt -u xpg_echo
--
shopt -u huponexit
shopt -u checkwinsize
@@ -34,6 +37,7 @@ shopt -s cmdhist
shopt -s expand_aliases
shopt -s hostcomplete
shopt -s interactive_comments
shopt -s progcomp
shopt -s promptvars
shopt -s sourcepath
--
@@ -49,10 +53,12 @@ shopt -u histverify
shopt -u huponexit
shopt -u lithist
shopt -u mailwarn
shopt -u no_empty_cmd_completion
shopt -u nocaseglob
shopt -u nullglob
shopt -u restricted_shell
shopt -u shift_verbose
shopt -u xpg_echo
--
cdable_vars off
checkhash off
@@ -66,10 +72,12 @@ histverify off
huponexit off
lithist off
mailwarn off
no_empty_cmd_completion off
nocaseglob off
nullglob off
restricted_shell off
shift_verbose off
xpg_echo off
--
set +o allexport
set -o braceexpand
+1
View File
@@ -24,6 +24,7 @@ shopt -u nullglob
shopt -s promptvars
shopt -u shift_verbose
shopt -s sourcepath
shopt -u xpg_echo
# Now, start checking the output
builtin printf -- "--\n"
+23 -17
View File
@@ -154,6 +154,12 @@ t -w /dev/fd/1
0
t -w /dev/fd/2
0
t -r /dev/stdin
0
t -w /dev/stdout
0
t -w /dev/stderr
0
t
1
b
@@ -221,46 +227,46 @@ t -G /tmp/test.group
t -h /tmp/test.symlink
0
t 4+3 -eq 7
./test-tests: test: 4+3: integer expression expected
./test.tests: test: 4+3: integer expression expected
2
b 4-5 -eq 7
./test-tests: [: 4+3: integer expression expected
./test.tests: [: 4+3: integer expression expected
2
t 9 -eq 4+5
./test-tests: test: 4+5: integer expression expected
./test.tests: test: 4+5: integer expression expected
2
b 9 -eq 4+5
./test-tests: [: 4+5: integer expression expected
./test.tests: [: 4+5: integer expression expected
2
t A -eq 7
./test-tests: test: A: integer expression expected
./test.tests: test: A: integer expression expected
2
b A -eq 7
./test-tests: [: A: integer expression expected
./test.tests: [: A: integer expression expected
2
t 9 -eq B
./test-tests: test: B: integer expression expected
./test.tests: test: B: integer expression expected
2
b 9 -eq B
./test-tests: [: B: integer expression expected
./test.tests: [: B: integer expression expected
2
t ( 1 = 2
./test-tests: test: `)' expected
./test.tests: test: `)' expected
2
b ( 1 = 2
./test-tests: [: `)' expected, found ]
./test.tests: [: `)' expected, found ]
2
./test-tests: test: a: unary operator expected
./test.tests: test: a: unary operator expected
2
./test-tests: test: b: binary operator expected
./test.tests: test: b: binary operator expected
2
./test-tests: test: -A: unary operator expected
./test.tests: test: -A: unary operator expected
2
./test-tests: test: too many arguments
./test.tests: test: too many arguments
2
./test-tests: test: too many arguments
./test.tests: test: too many arguments
2
./test-tests: [: missing `]'
./test.tests: [: missing `]'
2
./test-tests: test: (: unary operator expected
./test.tests: test: (: unary operator expected
2
+7
View File
@@ -259,6 +259,13 @@ t -w /dev/fd/1
echo 't -w /dev/fd/2'
t -w /dev/fd/2
echo 't -r /dev/stdin'
t -r /dev/stdin
echo 't -w /dev/stdout'
t -w /dev/stdout
echo 't -w /dev/stderr'
t -w /dev/stderr
echo 't'
t
echo 'b'
+1
View File
@@ -33,3 +33,4 @@ braceexpand:hashall
hPB
braceexpand:hashall:physical
declare -r SHELLOPTS="braceexpand:hashall:physical"
abcde
+12 -2
View File
@@ -125,11 +125,11 @@ export A
# Make sure expansion doesn't use assignment statements preceding a builtin
A=ZVAR echo $A
PATH=/bin:/usr/bin:/usr/local/bin:.
XPATH=/bin:/usr/bin:/usr/local/bin:.
func2()
{
local z=yy
local -a avar=( ${PATH//: } )
local -a avar=( ${XPATH//: } )
echo ${avar[@]}
local
}
@@ -184,3 +184,13 @@ echo ${SHELLOPTS}
# and make sure it is readonly
readonly -p | grep SHELLOPTS
# This was an error in bash versions prior to bash-2.04. The `set -a'
# should cause the assignment statement that's an argument to typeset
# to create an exported variable
unset FOOFOO
FOOFOO=bar
set -a
typeset FOOFOO=abcde
printenv FOOFOO