summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChet Ramey <chet.ramey@case.edu>2011-11-28 14:41:26 -0500
committerChet Ramey <chet.ramey@case.edu>2011-11-28 14:41:26 -0500
commitd3a24ed242e91e6afb53b2cbf38b89667637168d (patch)
treeb67e38d2eca8abd31da74e1dcbe69dd1bfa679a3 /tests
parent7117c2d221b2aed4ede8600f6a36b7c1454b4f55 (diff)
downloadbash-d3a24ed242e91e6afb53b2cbf38b89667637168d.tar.gz
Initial devel branch import from bash-3.0-alpha
Diffstat (limited to 'tests')
-rw-r--r--tests/alias.right4
-rw-r--r--tests/alias.tests37
-rw-r--r--tests/arith-for.right22
-rw-r--r--tests/arith.right1
-rw-r--r--tests/arith.tests3
-rw-r--r--tests/array.right33
-rw-r--r--tests/array.tests11
-rw-r--r--tests/braces.right19
-rw-r--r--tests/braces.tests57
-rw-r--r--tests/builtins.right8
-rw-r--r--tests/builtins.tests12
-rw-r--r--tests/cond.right2
-rwxr-xr-xtests/cond.tests4
-rw-r--r--tests/cprint.right4
-rw-r--r--tests/dbg-support.right353
-rw-r--r--tests/dbg-support.sub26
-rwxr-xr-xtests/dbg-support.tests139
-rw-r--r--tests/dbg-support2.right7
-rwxr-xr-xtests/dbg-support2.tests26
-rwxr-xr-xtests/dollar-at-star4
-rw-r--r--tests/dollar-star1.sub31
-rw-r--r--tests/dollar.right16
-rw-r--r--tests/errors.right20
-rw-r--r--tests/exec.right1
-rw-r--r--tests/exec7.sub20
-rw-r--r--tests/execscript5
-rw-r--r--tests/extglob.right1
-rw-r--r--tests/extglob.tests6
-rw-r--r--tests/glob-test10
-rw-r--r--tests/glob.right2
-rw-r--r--tests/herestr.right2
-rw-r--r--tests/herestr.tests3
-rw-r--r--tests/jobs.right2
-rw-r--r--tests/new-exp.right14
-rw-r--r--tests/new-exp.tests3
-rw-r--r--tests/new-exp4.sub31
-rw-r--r--tests/nquote4.right18
-rw-r--r--tests/nquote4.tests24
-rw-r--r--tests/read2.sub4
-rw-r--r--tests/redir.right6
-rw-r--r--tests/redir.tests3
-rw-r--r--tests/redir6.sub8
-rw-r--r--tests/run-alias2
-rw-r--r--tests/run-braces2
-rwxr-xr-xtests/run-dbg-support11
-rwxr-xr-xtests/run-dbg-support216
-rw-r--r--tests/run-glob-test2
-rw-r--r--tests/run-nquote42
-rwxr-xr-xtests/run-set-x11
-rw-r--r--tests/run-test2
-rw-r--r--tests/set-x.right28
-rwxr-xr-xtests/set-x.tests21
-rw-r--r--tests/shopt.right28
-rw-r--r--tests/test.tests2
-rw-r--r--tests/trap.right1
-rw-r--r--tests/type.right12
-rw-r--r--tests/type.tests17
-rw-r--r--tests/varenv.right2
58 files changed, 1104 insertions, 57 deletions
diff --git a/tests/alias.right b/tests/alias.right
new file mode 100644
index 00000000..53111beb
--- /dev/null
+++ b/tests/alias.right
@@ -0,0 +1,4 @@
+alias: 0
+alias: 0
+./alias.tests: line 25: qfoo: command not found
+quux
diff --git a/tests/alias.tests b/tests/alias.tests
new file mode 100644
index 00000000..9cfec16b
--- /dev/null
+++ b/tests/alias.tests
@@ -0,0 +1,37 @@
+# place holder for future alias testing
+shopt -s expand_aliases
+
+# alias/unalias tests originally in builtins.tests
+
+unalias -a
+# this should return success, according to POSIX.2
+alias
+echo alias: $?
+alias foo=bar
+unalias foo
+# this had better return success, according to POSIX.2
+alias
+echo alias: $?
+
+# bug in all versions through bash-2.05b
+
+unalias qfoo qbar qbaz quux 2>/dev/null
+
+alias qfoo=qbar
+alias qbar=qbaz
+alias qbaz=quux
+alias quux=qfoo
+
+qfoo
+
+unalias qfoo qbar qbaz quux
+
+unalias -a
+
+alias foo='echo '
+alias bar=baz
+alias baz=quux
+
+foo bar
+
+unalias foo bar baz
diff --git a/tests/arith-for.right b/tests/arith-for.right
index 0c05d981..c74baa48 100644
--- a/tests/arith-for.right
+++ b/tests/arith-for.right
@@ -14,39 +14,39 @@ fx is a function
fx ()
{
i=0;
- for (( 1 ; i < 3 ; i++ ))
+ for ((1 ; i < 3 ; i++ ))
do
echo $i;
done;
- for (( i=0 ; 1 ; i++ ))
+ for ((i=0 ; 1 ; i++ ))
do
- if (( " i >= 3 " )); then
+ if (( i >= 3 )); then
break;
fi;
echo $i;
done;
- for (( i=0 ; i<3 ; 1 ))
+ for ((i=0 ; i<3 ; 1))
do
echo $i;
- (( " i++ " ));
+ (( i++ ));
done;
i=0;
- for (( 1 ; 1 ; 1 ))
+ for ((1 ; 1 ; 1))
do
- if (( " i > 2 " )); then
+ if (( i > 2 )); then
break;
fi;
echo $i;
- (( " i++ " ));
+ (( i++ ));
done;
i=0;
- for (( 1 ; 1 ; 1 ))
+ for ((1 ; 1 ; 1))
do
- if (( " i > 2 " )); then
+ if (( i > 2 )); then
break;
fi;
echo $i;
- (( " i++ " ));
+ (( i++ ));
done
}
0
diff --git a/tests/arith.right b/tests/arith.right
index 6d82f1ac..f1f854b3 100644
--- a/tests/arith.right
+++ b/tests/arith.right
@@ -150,3 +150,4 @@ ok
42
42
42
+./arith.tests: line 281: b[c]d: syntax error in expression (error token is "d")
diff --git a/tests/arith.tests b/tests/arith.tests
index ccc6e5d8..ce6a372a 100644
--- a/tests/arith.tests
+++ b/tests/arith.tests
@@ -276,3 +276,6 @@ echo $(( 8#$(printf "%o\n" $n) ))
printf "%u\n" $n
echo $(( 16#$(printf "%x\n" $n) ))
echo $(( 16#$(printf "%X\n" $n) ))
+
+# causes longjmp botches through bash-2.05b
+a[b[c]d]=e
diff --git a/tests/array.right b/tests/array.right
index bda49d86..084c242f 100644
--- a/tests/array.right
+++ b/tests/array.right
@@ -6,7 +6,12 @@ abcde
abcde
abcde bdef
abcde bdef
+declare -a BASH_ARGC='()'
+declare -a BASH_ARGV='()'
+declare -a BASH_LINENO='([0]="0")'
+declare -a BASH_SOURCE='([0]="./array.tests")'
declare -a DIRSTACK='()'
+declare -a FUNCNAME='([0]="main")'
declare -a a='([0]="abcde" [1]="" [2]="bdef")'
declare -a b='()'
declare -ar c='()'
@@ -29,7 +34,12 @@ declare -ar c='()'
readonly -a a='([1]="" [2]="bdef" [5]="hello world" [6]="test expression")'
readonly -a c='()'
a test
+declare -a BASH_ARGC='()'
+declare -a BASH_ARGV='()'
+declare -a BASH_LINENO='([0]="0")'
+declare -a BASH_SOURCE='([0]="./array.tests")'
declare -a DIRSTACK='()'
+declare -a FUNCNAME='([0]="main")'
declare -ar a='([1]="" [2]="bdef" [5]="hello world" [6]="test expression")'
declare -a b='([0]="this" [1]="is" [2]="a" [3]="test" [4]="" [5]="/etc/passwd")'
declare -ar c='()'
@@ -47,7 +57,12 @@ declare -a f='([0]="" [1]="bdef" [2]="hello world" [3]="test" [4]="ninth element
./array.tests: line 109: []=abcde: bad array subscript
./array.tests: line 109: [*]=last: cannot assign to non-numeric index
./array.tests: line 109: [-65]=negative: bad array subscript
+declare -a BASH_ARGC='()'
+declare -a BASH_ARGV='()'
+declare -a BASH_LINENO='([0]="0")'
+declare -a BASH_SOURCE='([0]="./array.tests")'
declare -a DIRSTACK='()'
+declare -a FUNCNAME='([0]="main")'
declare -ar a='([1]="" [2]="bdef" [5]="hello world" [6]="test expression")'
declare -a b='([0]="this" [1]="is" [2]="a" [3]="test" [4]="" [5]="/etc/passwd")'
declare -ar c='()'
@@ -59,7 +74,12 @@ this of
this is a test of read using arrays
this test
this is a test of arrays
+declare -a BASH_ARGC='()'
+declare -a BASH_ARGV='()'
+declare -a BASH_LINENO='([0]="0")'
+declare -a BASH_SOURCE='([0]="./array.tests")'
declare -a DIRSTACK='()'
+declare -a FUNCNAME='([0]="main")'
declare -ar a='([1]="" [2]="bdef" [5]="hello world" [6]="test expression")'
declare -a b='([0]="this" [1]="is" [2]="a" [3]="test" [4]="" [5]="/etc/passwd")'
declare -ar c='()'
@@ -127,3 +147,16 @@ abc case if then else 5
case 4
case if then else 5
case if then else 5
+argv[1] = <0>
+argv[2] = <1>
+argv[3] = <4>
+argv[4] = <10>
+argv[1] = <0>
+argv[2] = <1>
+argv[3] = <4>
+argv[4] = <10>
+argv[1] = <0>
+argv[2] = <1>
+argv[3] = <4>
+argv[4] = <10>
+argv[1] = <0 1 4 10>
diff --git a/tests/array.tests b/tests/array.tests
index afa7556a..b38b91cf 100644
--- a/tests/array.tests
+++ b/tests/array.tests
@@ -289,3 +289,14 @@ echo ${foo[0]} ${#foo[0]}
echo ${foo[1]} ${#foo[1]}
echo ${foo[@]} ${#foo[@]}
echo ${foo[*]} ${#foo[*]}
+
+# new expansions added after bash-2.05b
+x[0]=zero
+x[1]=one
+x[4]=four
+x[10]=ten
+
+recho ${!x[@]}
+recho "${!x[@]}"
+recho ${!x[*]}
+recho "${!x[*]}"
diff --git a/tests/braces.right b/tests/braces.right
index d35e08d0..006f2c2d 100644
--- a/tests/braces.right
+++ b/tests/braces.right
@@ -17,3 +17,22 @@ abcd{efgh
foo 1 2 bar
foo 1 2 bar
foo 1 2 bar
+1 2 3 4 5 6 7 8 9 10
+0..10 braces
+0 1 2 3 4 5 6 7 8 9 10 braces
+x0y x1y x2y x3y x4y x5y x6y x7y x8y x9y x10y xbracesy
+3
+x3y
+10 9 8 7 6 5 4 3 2 1
+10y 9y 8y 7y 6y 5y 4y 3y 2y 1y
+x10y x9y x8y x7y x6y x5y x4y x3y x2y x1y
+a b c d e f
+f e d c b a
+a _ ^ ] [ Z Y X W V U T S R Q P O N M L K J I H G F E D C B A
+A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ ] ^ _ a
+f
+{1..f}
+{f..1}
+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
diff --git a/tests/braces.tests b/tests/braces.tests
new file mode 100644
index 00000000..b9ae1806
--- /dev/null
+++ b/tests/braces.tests
@@ -0,0 +1,57 @@
+echo ff{c,b,a}
+echo f{d,e,f}g
+echo {l,n,m}xyz
+echo {abc\,def}
+echo {abc}
+
+echo \{a,b,c,d,e}
+echo {x,y,\{a,b,c}}
+echo {x\,y,\{abc\},trie}
+
+echo /usr/{ucb/{ex,edit},lib/{ex,how_ex}}
+
+echo XXXX\{`echo a b c | tr ' ' ','`\}
+eval echo XXXX\{`echo a b c | tr ' ' ','`\}
+
+echo {}
+echo { }
+echo }
+echo {
+echo abcd{efgh
+
+echo foo {1,2} bar
+echo `zecho foo {1,2} bar`
+echo $(zecho foo {1,2} bar)
+
+# new sequence brace operators
+echo {1..10}
+
+# this doesn't work yet
+echo {0..10,braces}
+# but this does
+echo {{0..10},braces}
+echo x{{0..10},braces}y
+
+echo {3..3}
+echo x{3..3}y
+echo {10..1}
+echo {10..1}y
+echo x{10..1}y
+
+echo {a..f}
+echo {f..a}
+
+echo {a..A}
+echo {A..a}
+
+echo {f..f}
+
+# mixes are incorrectly-formed brace expansions
+echo {1..f}
+echo {f..1}
+
+echo 0{1..9} {10..20}
+
+# do negative numbers work?
+echo {-1..-10}
+echo {-20..0}
diff --git a/tests/builtins.right b/tests/builtins.right
index 9d7bb0ee..f686606b 100644
--- a/tests/builtins.right
+++ b/tests/builtins.right
@@ -1,5 +1,3 @@
-alias: 0
-alias: 0
a
end-1
a
@@ -118,15 +116,15 @@ AVAR
foo
declare -x foo=""
declare -x FOO="\$\$"
-./builtins.tests: line 219: declare: FOO: not found
+./builtins.tests: line 207: declare: FOO: not found
declare -x FOO="\$\$"
ok
ok
-./builtins.tests: line 251: kill: 4096: invalid signal specification
+./builtins.tests: line 239: kill: 4096: invalid signal specification
1
a\n\n\nb
a
b
-./builtins.tests: line 260: exit: status: numeric argument required
+./builtins.tests: line 248: exit: status: numeric argument required
diff --git a/tests/builtins.tests b/tests/builtins.tests
index 979a4de0..3c286338 100644
--- a/tests/builtins.tests
+++ b/tests/builtins.tests
@@ -4,18 +4,6 @@ set +o posix
ulimit -c 0 2>/dev/null
-# alias/unalias tests
-
-unalias -a
-# this should return success, according to POSIX.2
-alias
-echo alias: $?
-alias foo=bar
-unalias foo
-# this had better return success, according to POSIX.2
-alias
-echo alias: $?
-
# check that break breaks loops
for i in a b c; do echo $i; break; echo bad-$i; done
echo end-1
diff --git a/tests/cond.right b/tests/cond.right
index 58972ff1..06f36a9a 100644
--- a/tests/cond.right
+++ b/tests/cond.right
@@ -33,3 +33,5 @@ returns: 0
returns: 1
returns: 0
ok
+ok 42
+ok 43
diff --git a/tests/cond.tests b/tests/cond.tests
index acaa5272..3abfa9d7 100755
--- a/tests/cond.tests
+++ b/tests/cond.tests
@@ -153,3 +153,7 @@ PAT=
if [[ $STR = $PAT ]]; then
echo ok
fi
+
+# bug in all versions up to and including bash-2.05b
+if [[ "123abc" == *?(a)bc ]]; then echo ok 42; else echo bad 42; fi
+if [[ "123abc" == *?(a)bc ]]; then echo ok 43; else echo bad 43; fi
diff --git a/tests/cprint.right b/tests/cprint.right
index 6b711b8c..5dd629d1 100644
--- a/tests/cprint.right
+++ b/tests/cprint.right
@@ -14,7 +14,7 @@ tf ()
echo a
};
i=0;
- while (( " i < 3 " )); do
+ while (( i < 3 )); do
test -r /dev/fd/$i;
i=$(( i + 1 ));
done;
@@ -26,7 +26,7 @@ tf ()
if [[ -r /dev/fd/0 && -w /dev/fd/1 ]]; then
echo ok >/dev/null;
else
- if (( " 7 > 40 " )); then
+ if (( 7 > 40 )); then
echo oops;
else
echo done;
diff --git a/tests/dbg-support.right b/tests/dbg-support.right
new file mode 100644
index 00000000..eb7d3c3a
--- /dev/null
+++ b/tests/dbg-support.right
@@ -0,0 +1,353 @@
+debug lineno: 63 main
+debug lineno: 66 main
+FUNCNAME main
+debug lineno: 70 main
+debug lineno: 17 fn1
+debug lineno: 18 fn1
+LINENO 18
+debug lineno: 19 fn1
+LINENO 19
+debug lineno: 20 fn1
+BASH_SOURCE[0] ./dbg-support.tests
+debug lineno: 21 fn1
+FUNCNAME[0] fn1
+debug lineno: 22 fn1
+debug lineno: 22 fn1 70 ./dbg-support.tests
+debug lineno: 23 fn1
+debug lineno: 23 fn1 70 main ./dbg-support.tests
+debug lineno: 24 fn1
+debug lineno: 24 fn1
+debug lineno: 25 fn1
+./dbg-support.tests: line 25: caller: foo: invalid number
+caller: usage: caller [EXPR]
+debug lineno: 25 fn1
+debug lineno: 17 fn1
+debug lineno: 12 print_return_trap
+debug lineno: 13 print_return_trap
+return lineno: 17 fn1
+debug lineno: 14 print_return_trap
+debug lineno: 71 main
+debug lineno: 28 fn2
+debug lineno: 29 fn2
+fn2 here. Calling fn1...
+debug lineno: 30 fn2
+debug lineno: 17 fn1
+debug lineno: 18 fn1
+LINENO 18
+debug lineno: 19 fn1
+LINENO 19
+debug lineno: 20 fn1
+BASH_SOURCE[0] ./dbg-support.tests
+debug lineno: 21 fn1
+FUNCNAME[0] fn1
+debug lineno: 22 fn1
+debug lineno: 22 fn1 30 ./dbg-support.tests
+debug lineno: 23 fn1
+debug lineno: 23 fn1 30 fn2 ./dbg-support.tests
+debug lineno: 24 fn1
+debug lineno: 24 fn1 71 main ./dbg-support.tests
+debug lineno: 25 fn1
+./dbg-support.tests: line 25: caller: foo: invalid number
+caller: usage: caller [EXPR]
+debug lineno: 25 fn1
+debug lineno: 17 fn1
+debug lineno: 12 print_return_trap
+debug lineno: 13 print_return_trap
+return lineno: 17 fn1
+debug lineno: 14 print_return_trap
+debug lineno: 28 fn2
+debug lineno: 12 print_return_trap
+debug lineno: 13 print_return_trap
+return lineno: 28 fn2
+debug lineno: 14 print_return_trap
+debug lineno: 72 main
+debug lineno: 33 fn3
+debug lineno: 34 fn3
+LINENO 34
+debug lineno: 35 fn3
+BASH_SOURCE[0] ./dbg-support.tests
+debug lineno: 38 fn3
+debug lineno: 39 fn3
+debug lineno: 40 fn3
+debug lineno: 40 fn3
+debug lineno: 41 fn3
+debug lineno: 42 fn3
+debug lineno: 43 fn3
+fn3 called from file `./dbg-support.tests' at line 0
+debug lineno: 40 fn3
+debug lineno: 40 fn3
+debug lineno: 41 fn3
+debug lineno: 42 fn3
+debug lineno: 42 fn3
+debug lineno: 43 fn3
+main called from file `./dbg-support.tests' at line 0
+debug lineno: 40 fn3
+debug lineno: 40 fn3
+debug lineno: 46 fn3
+debug lineno: 18 source
+SOURCED LINENO 18
+debug lineno: 19 source
+SOURCED BASH_SOURCE[0] ./dbg-support.sub
+debug lineno: 20 source
+debug lineno: 3 sourced_fn
+debug lineno: 4 sourced_fn
+debug lineno: 5 sourced_fn
+SOURCED FN LINENO 5
+debug lineno: 8 sourced_fn
+debug lineno: 9 sourced_fn
+debug lineno: 10 sourced_fn
+debug lineno: 10 sourced_fn
+debug lineno: 11 sourced_fn
+debug lineno: 12 sourced_fn
+debug lineno: 13 sourced_fn
+FUNCNAME[0]: sourced_fn called from ./dbg-support.sub at line 20
+debug lineno: 10 sourced_fn
+debug lineno: 10 sourced_fn
+debug lineno: 11 sourced_fn
+debug lineno: 12 sourced_fn
+debug lineno: 13 sourced_fn
+FUNCNAME[1]: source called from ./dbg-support.tests at line 46
+debug lineno: 10 sourced_fn
+debug lineno: 10 sourced_fn
+debug lineno: 11 sourced_fn
+debug lineno: 12 sourced_fn
+debug lineno: 13 sourced_fn
+FUNCNAME[2]: fn3 called from ./dbg-support.tests at line 72
+debug lineno: 10 sourced_fn
+debug lineno: 10 sourced_fn
+debug lineno: 11 sourced_fn
+debug lineno: 12 sourced_fn
+debug lineno: 12 sourced_fn
+debug lineno: 13 sourced_fn
+FUNCNAME[3]: main called from ./dbg-support.tests at line 0
+debug lineno: 10 sourced_fn
+debug lineno: 10 sourced_fn
+debug lineno: 3 sourced_fn
+debug lineno: 12 print_return_trap
+debug lineno: 13 print_return_trap
+return lineno: 3 sourced_fn
+debug lineno: 14 print_return_trap
+debug lineno: 46 fn3
+debug lineno: 12 print_return_trap
+debug lineno: 13 print_return_trap
+return lineno: 46 fn3
+debug lineno: 14 print_return_trap
+debug lineno: 33 fn3
+debug lineno: 12 print_return_trap
+debug lineno: 13 print_return_trap
+return lineno: 33 fn3
+debug lineno: 14 print_return_trap
+debug lineno: 73 main
+debug lineno: 18 source
+SOURCED LINENO 18
+debug lineno: 19 source
+SOURCED BASH_SOURCE[0] ./dbg-support.sub
+debug lineno: 20 source
+debug lineno: 3 sourced_fn
+debug lineno: 4 sourced_fn
+debug lineno: 5 sourced_fn
+SOURCED FN LINENO 5
+debug lineno: 8 sourced_fn
+debug lineno: 9 sourced_fn
+debug lineno: 10 sourced_fn
+debug lineno: 10 sourced_fn
+debug lineno: 11 sourced_fn
+debug lineno: 12 sourced_fn
+debug lineno: 13 sourced_fn
+FUNCNAME[0]: sourced_fn called from ./dbg-support.sub at line 20
+debug lineno: 10 sourced_fn
+debug lineno: 10 sourced_fn
+debug lineno: 11 sourced_fn
+debug lineno: 12 sourced_fn
+debug lineno: 13 sourced_fn
+FUNCNAME[1]: source called from ./dbg-support.tests at line 73
+debug lineno: 10 sourced_fn
+debug lineno: 10 sourced_fn
+debug lineno: 11 sourced_fn
+debug lineno: 12 sourced_fn
+debug lineno: 12 sourced_fn
+debug lineno: 13 sourced_fn
+FUNCNAME[2]: main called from ./dbg-support.tests at line 0
+debug lineno: 10 sourced_fn
+debug lineno: 10 sourced_fn
+debug lineno: 3 sourced_fn
+debug lineno: 12 print_return_trap
+debug lineno: 13 print_return_trap
+return lineno: 3 sourced_fn
+debug lineno: 14 print_return_trap
+debug lineno: 73 main
+debug lineno: 12 print_return_trap
+debug lineno: 13 print_return_trap
+return lineno: 73 main
+debug lineno: 14 print_return_trap
+debug lineno: 76 main
+debug lineno: 79 main
+LINENO 18
+LINENO 19
+BASH_SOURCE[0] ./dbg-support.tests
+FUNCNAME[0] fn1
+79 ./dbg-support.tests
+79 main ./dbg-support.tests
+
+./dbg-support.tests: line 25: caller: foo: invalid number
+caller: usage: caller [EXPR]
+
+debug lineno: 80 main
+fn2 here. Calling fn1...
+LINENO 18
+LINENO 19
+BASH_SOURCE[0] ./dbg-support.tests
+FUNCNAME[0] fn1
+30 ./dbg-support.tests
+30 fn2 ./dbg-support.tests
+80 main ./dbg-support.tests
+./dbg-support.tests: line 25: caller: foo: invalid number
+caller: usage: caller [EXPR]
+
+debug lineno: 81 main
+LINENO 34
+BASH_SOURCE[0] ./dbg-support.tests
+fn3 called from file `./dbg-support.tests' at line 0
+main called from file `./dbg-support.tests' at line 0
+SOURCED LINENO 18
+SOURCED BASH_SOURCE[0] ./dbg-support.sub
+SOURCED FN LINENO 5
+FUNCNAME[0]: sourced_fn called from ./dbg-support.sub at line 20
+FUNCNAME[1]: source called from ./dbg-support.tests at line 46
+FUNCNAME[2]: fn3 called from ./dbg-support.tests at line 81
+FUNCNAME[3]: main called from ./dbg-support.tests at line 0
+debug lineno: 82 main
+fn4 here. Calling fn3...
+LINENO 34
+BASH_SOURCE[0] ./dbg-support.tests
+fn3 called from file `./dbg-support.tests' at line 82
+fn4 called from file `./dbg-support.tests' at line 0
+main called from file `./dbg-support.tests' at line 0
+SOURCED LINENO 18
+SOURCED BASH_SOURCE[0] ./dbg-support.sub
+SOURCED FN LINENO 5
+FUNCNAME[0]: sourced_fn called from ./dbg-support.sub at line 20
+FUNCNAME[1]: source called from ./dbg-support.tests at line 46
+FUNCNAME[2]: fn3 called from ./dbg-support.tests at line 51
+FUNCNAME[3]: fn4 called from ./dbg-support.tests at line 82
+FUNCNAME[4]: main called from ./dbg-support.tests at line 0
+debug lineno: 83 main
+SOURCED LINENO 18
+SOURCED BASH_SOURCE[0] ./dbg-support.sub
+SOURCED FN LINENO 5
+FUNCNAME[0]: sourced_fn called from ./dbg-support.sub at line 20
+FUNCNAME[1]: source called from ./dbg-support.tests at line 83
+FUNCNAME[2]: main called from ./dbg-support.tests at line 0
+return lineno: 83 main
+debug lineno: 86 main
+debug lineno: 89 main
+debug lineno: 18 source
+SOURCED LINENO 18
+debug lineno: 19 source
+SOURCED BASH_SOURCE[0] ./dbg-support.sub
+debug lineno: 20 source
+debug lineno: 3 sourced_fn
+debug lineno: 4 sourced_fn
+debug lineno: 5 sourced_fn
+SOURCED FN LINENO 5
+debug lineno: 8 sourced_fn
+debug lineno: 9 sourced_fn
+debug lineno: 10 sourced_fn
+debug lineno: 10 sourced_fn
+debug lineno: 11 sourced_fn
+debug lineno: 12 sourced_fn
+debug lineno: 13 sourced_fn
+FUNCNAME[0]: sourced_fn called from ./dbg-support.sub at line 20
+debug lineno: 10 sourced_fn
+debug lineno: 10 sourced_fn
+debug lineno: 11 sourced_fn
+debug lineno: 12 sourced_fn
+debug lineno: 13 sourced_fn
+FUNCNAME[1]: source called from ./dbg-support.tests at line 89
+debug lineno: 10 sourced_fn
+debug lineno: 10 sourced_fn
+debug lineno: 11 sourced_fn
+debug lineno: 12 sourced_fn
+debug lineno: 12 sourced_fn
+debug lineno: 13 sourced_fn
+FUNCNAME[2]: main called from ./dbg-support.tests at line 0
+debug lineno: 10 sourced_fn
+debug lineno: 10 sourced_fn
+debug lineno: 3 sourced_fn
+debug lineno: 12 print_return_trap
+debug lineno: 13 print_return_trap
+return lineno: 3 sourced_fn
+debug lineno: 14 print_return_trap
+debug lineno: 89 main
+debug lineno: 12 print_return_trap
+debug lineno: 13 print_return_trap
+return lineno: 89 main
+debug lineno: 14 print_return_trap
+debug lineno: 90 main
+debug lineno: 93 main
+debug lineno: 93 main
+debug lineno: 94 main
+debug lineno: 97 main
+debug lineno: 93 main
+debug lineno: 93 main
+debug lineno: 94 main
+debug lineno: 97 main
+debug lineno: 93 main
+debug lineno: 93 main
+debug lineno: 94 main
+debug lineno: 95 main
+Hit 2
+debug lineno: 97 main
+debug lineno: 93 main
+debug lineno: 93 main
+debug lineno: 103 main
+SOURCED FN LINENO 5 FUNCNAME[0]: sourced_fn called from ./dbg-support.tests at line 103 FUNCNAME[1]: main called from ./dbg-support.tests at line 0
+debug lineno: 104 main
+SOURCED FN LINENO 5 FUNCNAME[0]: sourced_fn called from ./dbg-support.tests at line 104 FUNCNAME[1]: main called from ./dbg-support.tests at line 0
+debug lineno: 105 main
+debug lineno: 106 main
+SOURCED FN LINENO 5
+FUNCNAME[0]: sourced_fn called from ./dbg-support.tests at line 106
+FUNCNAME[1]: main called from ./dbg-support.tests at line 0
+debug lineno: 110 main
+debug lineno: 111 main
+debug lineno: 3 sourced_fn
+debug lineno: 4 sourced_fn
+debug lineno: 5 sourced_fn
+SOURCED FN LINENO 5
+debug lineno: 8 sourced_fn
+debug lineno: 9 sourced_fn
+debug lineno: 10 sourced_fn
+debug lineno: 10 sourced_fn
+debug lineno: 11 sourced_fn
+debug lineno: 12 sourced_fn
+debug lineno: 13 sourced_fn
+FUNCNAME[0]: sourced_fn called from ./dbg-support.tests at line 111
+debug lineno: 10 sourced_fn
+debug lineno: 10 sourced_fn
+debug lineno: 11 sourced_fn
+debug lineno: 12 sourced_fn
+debug lineno: 12 sourced_fn
+debug lineno: 13 sourced_fn
+FUNCNAME[1]: main called from ./dbg-support.tests at line 0
+debug lineno: 10 sourced_fn
+debug lineno: 10 sourced_fn
+debug lineno: 3 sourced_fn
+debug lineno: 12 print_return_trap
+debug lineno: 13 print_return_trap
+return lineno: 3 sourced_fn
+debug lineno: 14 print_return_trap
+debug lineno: 114 main
+debug lineno: 119 main
+debug lineno: 123 main
+got it
+debug lineno: 131 main
+debug lineno: 132 main
+debug lineno: 133 main
+debug lineno: 132 main
+debug lineno: 133 main
+debug lineno: 131 main
+debug lineno: 132 main
+debug lineno: 133 main
+debug lineno: 132 main
+debug lineno: 133 main
diff --git a/tests/dbg-support.sub b/tests/dbg-support.sub
new file mode 100644
index 00000000..f68f8d9b
--- /dev/null
+++ b/tests/dbg-support.sub
@@ -0,0 +1,26 @@
+# This file is intended to be sourced from one of the bashdb test programs
+
+sourced_fn() {
+ name="fn2"
+ echo "SOURCED FN LINENO $LINENO"
+
+ # Print a stack trace
+ declare -i n
+ n=${#FUNCNAME[@]}
+ for (( i=0 ; (( i < $n )) ; i++ )) ; do
+ local -i j=i+1
+ [ $j -eq $n ] && j=i # main()'s file is the same as the first caller
+ echo "FUNCNAME[$i]: ${FUNCNAME[$i]} called from ${BASH_SOURCE[$j]}" \
+ "at line ${BASH_LINENO[$i]}"
+ done
+}
+
+echo "SOURCED LINENO $LINENO"
+echo "SOURCED BASH_SOURCE[0]" ${BASH_SOURCE[0]}
+sourced_fn
+
+#;;; Local Variables: ***
+#;;; mode:shell-script ***
+#;;; eval: (sh-set-shell "bash") ***
+#;;; End: ***
+
diff --git a/tests/dbg-support.tests b/tests/dbg-support.tests
new file mode 100755
index 00000000..27825d6a
--- /dev/null
+++ b/tests/dbg-support.tests
@@ -0,0 +1,139 @@
+#!../bash
+#
+# Test correct functioning bash debug support not via the bashdb
+# debugger but merely by printing via print_trap()
+# $Id: dbg-support.tests,v 1.13 2003/02/17 22:02:25 rockyb Exp $
+shopt -s extdebug
+print_debug_trap() {
+ echo "debug lineno: $1 ${FUNCNAME[1]}"
+ return
+}
+
+print_return_trap() {
+ echo "return lineno: $1 ${FUNCNAME[1]}"
+ return
+}
+
+fn1() {
+ echo "LINENO $LINENO"
+ echo "LINENO $LINENO"
+ echo "BASH_SOURCE[0]" ${BASH_SOURCE[0]}
+ echo "FUNCNAME[0]" ${FUNCNAME[0]}
+ echo `caller`
+ echo `caller 0`
+ echo `caller 1`
+ echo `caller foo`
+}
+
+fn2() {
+ echo "fn2 here. Calling fn1..."
+ fn1
+}
+
+fn3() {
+ echo "LINENO $LINENO"
+ echo "BASH_SOURCE[0]" ${BASH_SOURCE[0]}
+
+ # Print a stack trace
+ declare -i n
+ n=${#FUNCNAME[@]}
+ for (( i=0 ; (( i < $n )) ; i++ )) ; do
+ local -i j=i+1
+ [ $j -eq $n ] && j=i # main()'s file is the same as the first caller
+ echo "${FUNCNAME[$i]} called from file " \
+ "\`${BASH_SOURCE[$j]}' at line ${BASH_LINENO[$j]}"
+ done
+ source ./dbg-support.sub
+}
+
+fn4() {
+ echo "fn4 here. Calling fn3..."
+ fn3
+}
+
+
+#!../bash
+#
+# Test of support for debugging facilities in bash
+#
+# Test debugger set option fntrace - set on. Not in vanilla Bash 2.05
+#
+set -o functrace
+trap 'print_debug_trap $LINENO' DEBUG
+trap 'print_return_trap $LINENO' RETURN
+
+# Funcname is now an array. Vanilla Bash 2.05 doesn't have FUNCNAME array.
+echo "FUNCNAME" ${FUNCNAME[0]}
+
+# We should trace into the below.
+# Start easy with a simple function.
+fn1
+fn2
+fn3
+source ./dbg-support.sub
+
+# Test debugger set option fntrace - set off
+set +T
+
+# We should not trace into this.
+fn1
+fn2
+fn3
+fn4
+source ./dbg-support.sub
+
+# Another way to say: set -o fntrace
+set -T
+
+# We should trace into this.
+source ./dbg-support.sub
+set +T
+
+# Test that the line numbers in the presence of conditionals are correct.
+for (( i=0 ; (( i <= 2 )) ; i++ )) ; do
+ if [ $i -eq 2 ] ; then
+ echo "Hit 2"
+ fi
+ j=4
+done
+
+#
+# Check line numbers in command substitution
+#
+echo $(sourced_fn)
+echo `sourced_fn`
+x=$((sourced_fn))
+x={ sourced_fn }
+
+# Make sure we step into sourced_fn as a comand when we request to do so.
+# Vanilla bash 2.0 doesn't do.
+set -o functrace
+x={ sourced_fn }
+
+# Should see line number of xyzzy below. Vanilla bash 2.05b doesn't do
+case xyzzy in
+ a )
+ x=5
+ ;;
+ xyzz? )
+ case 3 in
+ 2 )
+ x=6 ;;
+ 3 )
+ echo "got it" ;;
+ * ) echo "no good" ;;
+ esac
+ ;;
+ * )
+esac
+
+# Should see line numbers for initial for lines.
+for i in 0 1 ; do
+ for j in 3 4 ; do
+ ((x=i+j))
+ done
+done
+#;;; Local Variables: ***
+#;;; mode:shell-script ***
+#;;; eval: (sh-set-shell "bash") ***
+#;;; End: ***
diff --git a/tests/dbg-support2.right b/tests/dbg-support2.right
new file mode 100644
index 00000000..c9d884e6
--- /dev/null
+++ b/tests/dbg-support2.right
@@ -0,0 +1,7 @@
+lineno: 17 (6) main
+lineno: 18 (6) main
+x is 1
+lineno: 19 (6) main
+lineno: 20 (6) main
+lineno: 21 (6) main
+x is 1
diff --git a/tests/dbg-support2.tests b/tests/dbg-support2.tests
new file mode 100755
index 00000000..fdc0f31e
--- /dev/null
+++ b/tests/dbg-support2.tests
@@ -0,0 +1,26 @@
+#!../bash
+#
+# Test correct trap return codes = 2 means skip execution.
+shopt -s extdebug
+print_trap() {
+ echo "lineno: $1 ($LINENO) ${FUNCNAME[1]}"
+ if [[ $debug_exit == 2 ]] ; then
+ debug_exit=0
+ return 2
+ fi
+ return 0
+}
+
+debug_exit=0
+trap 'print_trap $LINENO' DEBUG
+
+x=1
+echo "x is $x"
+debug_exit=2
+x=2
+echo "x is $x"
+
+#;;; Local Variables: ***
+#;;; mode:shell-script ***
+#;;; eval: (sh-set-shell "bash") ***
+#;;; End: ***
diff --git a/tests/dollar-at-star b/tests/dollar-at-star
index 1a754d8c..ade9c1f9 100755
--- a/tests/dollar-at-star
+++ b/tests/dollar-at-star
@@ -207,4 +207,8 @@ case "$@" in
*) echo bad 4;;
esac
+# tests for special expansion of "$*" and "${array[*]}" when used with other
+# expansions -- bugs through bash-2.05b
+${THIS_SH} ./dollar-star1.sub
+
exit 0
diff --git a/tests/dollar-star1.sub b/tests/dollar-star1.sub
new file mode 100644
index 00000000..63a9ef86
--- /dev/null
+++ b/tests/dollar-star1.sub
@@ -0,0 +1,31 @@
+set -- a b c
+x=(a b c); IFS='|'
+
+echo "${*/#/x}"
+echo "${x[*]/#/x}"
+
+echo "$*"
+echo "${x[*]}"
+
+echo "$@"
+echo "${x[@]}"
+
+echo "${@/#/x}"
+echo "${x[@]/#/x}"
+
+echo "${*:1:2}"
+echo "${x[*]:1:2}"
+
+echo "${@:1:2}"
+echo "${x[@]:1:2}"
+
+IFS=$' \t\n'
+set -- xa xb xc
+x=(xa xb xc)
+IFS='|'
+
+echo "${*#x}"
+echo "${x[*]#x}"
+
+echo "$*"
+echo "${x[*]}"
diff --git a/tests/dollar.right b/tests/dollar.right
index 345775be..42bb65e7 100644
--- a/tests/dollar.right
+++ b/tests/dollar.right
@@ -95,3 +95,19 @@ ok 1
ok 2
ok 3
ok 4
+xa|xb|xc
+xa|xb|xc
+a|b|c
+a|b|c
+a b c
+a b c
+xa xb xc
+xa xb xc
+a|b
+b|c
+a b
+b c
+a|b|c
+a|b|c
+xa|xb|xc
+xa|xb|xc
diff --git a/tests/errors.right b/tests/errors.right
index e2e8ad04..b00101cb 100644
--- a/tests/errors.right
+++ b/tests/errors.right
@@ -15,7 +15,7 @@ unset: usage: unset [-f] [-v] [name ...]
./errors.tests: line 52: unset: `/bin/sh': not a valid identifier
./errors.tests: line 55: unset: cannot simultaneously unset a function and a variable
./errors.tests: line 58: declare: -z: invalid option
-declare: usage: declare [-afFirtx] [-p] name[=value] ...
+declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
./errors.tests: line 60: declare: `-z': not a valid identifier
./errors.tests: line 61: declare: `/bin/sh': not a valid identifier
./errors.tests: line 65: declare: cannot use `-f' to make functions
@@ -53,20 +53,20 @@ umask: usage: umask [-p] [-S] [mode]
./errors.tests: line 159: declare: VAR: readonly variable
./errors.tests: line 161: declare: unset: not found
./errors.tests: line 164: VAR: readonly variable
-./errors.tests: command substitution: line 2: syntax error: unexpected end of file
-./errors.tests: command substitution: line 1: syntax error near unexpected token `done'
-./errors.tests: command substitution: line 1: ` for z in 1 2 3; done '
+./errors.tests: command substitution: line 168: syntax error: unexpected end of file
+./errors.tests: command substitution: line 168: syntax error near unexpected token `done'
+./errors.tests: command substitution: line 168: ` for z in 1 2 3; done '
./errors.tests: line 171: cd: HOME not set
./errors.tests: line 172: cd: /tmp/xyz.bash: No such file or directory
./errors.tests: line 174: cd: OLDPWD not set
./errors.tests: line 175: cd: /bin/sh: Not a directory
./errors.tests: line 177: cd: /tmp/cd-notthere: No such file or directory
./errors.tests: line 180: .: filename argument required
-.: usage: . filename
+.: usage: . filename [arguments]
./errors.tests: line 181: source: filename argument required
-source: usage: source filename
+source: usage: source filename [arguments]
./errors.tests: line 184: .: -i: invalid option
-.: usage: . filename
+.: usage: . filename [arguments]
./errors.tests: line 187: set: -q: invalid option
set: usage: set [--abefhkmnptuvxBCHP] [-o option] [arg ...]
./errors.tests: line 190: enable: sh: not a shell builtin
@@ -76,13 +76,13 @@ set: usage: set [--abefhkmnptuvxBCHP] [-o option] [arg ...]
./errors.tests: line 199: read: `/bin/sh': not a valid identifier
./errors.tests: line 202: VAR: readonly variable
./errors.tests: line 205: readonly: -x: invalid option
-readonly: usage: readonly [-anf] [name[=value] ...] or readonly -p
+readonly: usage: readonly [-af] [name[=value] ...] or readonly -p
./errors.tests: line 208: eval: -i: invalid option
eval: usage: eval [arg ...]
./errors.tests: line 209: command: -i: invalid option
command: usage: command [-pVv] command [arg ...]
-./errors.tests: line 1: /bin/sh + 0: syntax error: operand expected (error token is "/bin/sh + 0")
-./errors.tests: line 1: /bin/sh + 0: syntax error: operand expected (error token is "/bin/sh + 0")
+./errors.tests: line 212: /bin/sh + 0: syntax error: operand expected (error token is "/bin/sh + 0")
+./errors.tests: line 213: /bin/sh + 0: syntax error: operand expected (error token is "/bin/sh + 0")
./errors.tests: line 216: trap: NOSIG: invalid signal specification
./errors.tests: line 219: trap: -s: invalid option
trap: usage: trap [arg] [signal_spec ...] or trap -l
diff --git a/tests/exec.right b/tests/exec.right
index 0121ed4b..070ea58e 100644
--- a/tests/exec.right
+++ b/tests/exec.right
@@ -50,3 +50,4 @@ this is ohio-state
1
0
1
+testb
diff --git a/tests/exec7.sub b/tests/exec7.sub
new file mode 100644
index 00000000..ea2fd066
--- /dev/null
+++ b/tests/exec7.sub
@@ -0,0 +1,20 @@
+# make sure that bash really checks the right things when deciding what
+# constitutes an executable file
+
+[ $UID -eq 0 ] && { echo "exec7.sub: the test suite should not be run as root" >&2 ; }
+
+: ${TMPDIR:=/tmp}
+
+cd $TMPDIR || { echo "cannot cd to $TMPDIR" >&2 ; exit 2; }
+
+mkdir testa testb
+
+echo 'echo "testa"' > testa/foo
+echo 'echo "testb"' > testb/foo
+
+chmod 655 testa/foo
+chmod 755 testb/foo
+
+PATH=$TMPDIR/testa:$TMPDIR/testb $THIS_SH -c foo
+
+rm -rf testa testb
diff --git a/tests/execscript b/tests/execscript
index 7eab4af0..03208c9e 100644
--- a/tests/execscript
+++ b/tests/execscript
@@ -1,7 +1,7 @@
export LC_ALL=C
export LANG=C
-if (( $UID == 0 )); then
+if [ $UID -eq 0 ]; then
echo "execscript: the test suite should not be run as root" >&2
fi
@@ -94,3 +94,6 @@ ${THIS_SH} -c 'cat </dev/null | cat >/dev/null' >&-
# values
${THIS_SH} ./exec6.sub
+
+# checks for properly deciding what constitutes an executable file
+${THIS_SH} ./exec7.sub
diff --git a/tests/extglob.right b/tests/extglob.right
index c205a4f1..154a969a 100644
--- a/tests/extglob.right
+++ b/tests/extglob.right
@@ -67,6 +67,7 @@ ok 38
ok 39
ok 40
ok 41
+ok 42
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
diff --git a/tests/extglob.tests b/tests/extglob.tests
index b1295c07..1a123d8b 100644
--- a/tests/extglob.tests
+++ b/tests/extglob.tests
@@ -321,6 +321,12 @@ ab**) echo ok 41;;
*) echo bad 41;;
esac
+# bug in all versions up to and including bash-2.05b
+case "123abc" in
+*?(a)bc) echo ok 42;;
+*) echo bad 42;;
+esac
+
# clean up and do the next one
builtin cd /
diff --git a/tests/glob-test b/tests/glob-test
index dfb987ec..d4357083 100644
--- a/tests/glob-test
+++ b/tests/glob-test
@@ -35,6 +35,16 @@ recho a* X*
shopt -u nullglob
+# see if the failglob option works
+
+mkdir tmp
+touch tmp/l1 tmp/l2 tmp/l3
+builtin echo tmp/l[12] tmp/*4 tmp/*3
+shopt -s failglob
+builtin echo tmp/l[12] tmp/*4 tmp/*3
+rm -r tmp
+shopt -u failglob
+
# see if the code that expands directories only works
expect '<bdir/>'
recho b*/
diff --git a/tests/glob.right b/tests/glob.right
index 08f1778c..46ac4d3d 100644
--- a/tests/glob.right
+++ b/tests/glob.right
@@ -12,6 +12,8 @@ argv[1] = <a>
argv[2] = <abc>
argv[3] = <abd>
argv[4] = <abe>
+tmp/l1 tmp/l2 tmp/*4 tmp/l3
+./glob-test: line 44: no match: tmp/*4
argv[1] = <bdir/>
argv[1] = <*>
argv[1] = <a*>
diff --git a/tests/herestr.right b/tests/herestr.right
index c20c0a56..2659aace 100644
--- a/tests/herestr.right
+++ b/tests/herestr.right
@@ -24,3 +24,5 @@ f3 ()
echo $(echo hi)
echo ho
echo off to work we go
+declare -a uu='([0]="" [1]="kghfjk" [2]="jkfzuk" [3]="i\
+")'
diff --git a/tests/herestr.tests b/tests/herestr.tests
index 4f3ac682..f77b229f 100644
--- a/tests/herestr.tests
+++ b/tests/herestr.tests
@@ -34,3 +34,6 @@ cat <<< 'echo $(echo hi)'
cat <<< "echo ho"
cat <<< "echo $(echo off to work we go)"
+
+IFS="/" read -r -d $'\000' -a uu <<< /kghfjk/jkfzuk/i
+declare -p uu
diff --git a/tests/jobs.right b/tests/jobs.right
index 12bf8a34..1117f5e2 100644
--- a/tests/jobs.right
+++ b/tests/jobs.right
@@ -43,7 +43,7 @@ fg-bg 4
sleep 5
fg-bg 5
./jobs.tests: line 83: fg: %2: no such job
-./jobs.tests: line 84: bg: bg background job?
+./jobs.tests: line 84: bg: job %1 already in background
fg-bg 6
./jobs.tests: line 91: fg: -s: invalid option
fg: usage: fg [job_spec]
diff --git a/tests/new-exp.right b/tests/new-exp.right
index 95f16d99..a2ad16f1 100644
--- a/tests/new-exp.right
+++ b/tests/new-exp.right
@@ -422,7 +422,15 @@ argv[1] = <_QUANTITY-_QUART-_QUEST-_QUILL-_QUOTA-_QUOTE>
./new-exp3.sub: line 19: ${!_Q* }: bad substitution
./new-exp3.sub: line 24: ${!1*}: bad substitution
./new-exp3.sub: line 26: ${!@*}: bad substitution
-./new-exp.tests: line 503: ${$(($#-1))}: bad substitution
+Case01---3---A:B:C---
+Case02---1---A B C::---
+Case03---3---A:B:C---
+Case04---3---A:B:C---
+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
argv[1] = <a>
argv[2] = <b>
argv[3] = <c>
@@ -439,7 +447,7 @@ argv[1] = <a>
argv[1] = <a>
argv[2] = <b>
argv[1] = <>
-./new-exp.tests: line 522: $(($# - 2)): substring expression < 0
+./new-exp.tests: line 525: $(($# - 2)): substring expression < 0
argv[1] = <bin>
argv[2] = <bin>
argv[3] = <ucb>
@@ -471,4 +479,4 @@ argv[1] = </full/path/to>
argv[1] = </>
argv[1] = <full/path/to/x16>
argv[1] = <x16>
-./new-exp.tests: line 542: ABXD: parameter unset
+./new-exp.tests: line 545: ABXD: parameter unset
diff --git a/tests/new-exp.tests b/tests/new-exp.tests
index 89b92136..5d806d6c 100644
--- a/tests/new-exp.tests
+++ b/tests/new-exp.tests
@@ -498,6 +498,9 @@ 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/}
diff --git a/tests/new-exp4.sub b/tests/new-exp4.sub
new file mode 100644
index 00000000..45439a06
--- /dev/null
+++ b/tests/new-exp4.sub
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+arrayA=("A" "B" "C")
+
+arrayB=( ${arrayA[*]} )
+echo "Case01---${#arrayB[*]}---${arrayB[0]}:${arrayB[1]}:${arrayB[2]}---"
+
+arrayB=( "${arrayA[*]}" )
+echo "Case02---${#arrayB[*]}---${arrayB[0]}:${arrayB[1]}:${arrayB[2]}---"
+
+arrayB=( ${arrayA[@]} )
+echo "Case03---${#arrayB[@]}---${arrayB[0]}:${arrayB[1]}:${arrayB[2]}---"
+
+arrayB=( "${arrayA[@]}" )
+echo "Case04---${#arrayB[@]}---${arrayB[0]}:${arrayB[1]}:${arrayB[2]}---"
+
+xx="arrayA[*]"
+
+arrayB=( ${!xx} )
+echo "Case05---${#arrayB[*]}---${arrayB[0]}:${arrayB[1]}:${arrayB[2]}---"
+
+arrayB=( "${!xx}" )
+echo "Case06---${#arrayB[*]}---${arrayB[0]}:${arrayB[1]}:${arrayB[2]}---"
+
+xx="arrayA[@]"
+
+arrayB=( ${!xx} )
+echo "Case07---${#arrayB[@]}---${arrayB[0]}:${arrayB[1]}:${arrayB[2]}---"
+
+arrayB=( "${!xx}" )
+echo "Case08---${#arrayB[@]}---${arrayB[0]}:${arrayB[1]}:${arrayB[2]}---"
diff --git a/tests/nquote4.right b/tests/nquote4.right
new file mode 100644
index 00000000..1f7ae170
--- /dev/null
+++ b/tests/nquote4.right
@@ -0,0 +1,18 @@
+argv[1] = <ab>
+argv[1] = <abAcd>
+argv[1] = <abAcd>
+argv[1] = <ab^Dcd>
+argv[1] = <abLd>
+argv[1] = <abÞ>
+argv[1] = <abÞ>
+argv[1] = <abÍe>
+argv[1] = <ab^Lde>
+argv[1] = <¼X>
+argv[1] = <«cX>
+argv[1] = <>
+argv[1] = <>
+argv[1] = <gX>
+argv[1] = <Ab>
+argv[1] = <>
+argv[1] = <^Abcd>
+argv[1] = <Þ>
diff --git a/tests/nquote4.tests b/tests/nquote4.tests
new file mode 100644
index 00000000..ed734677
--- /dev/null
+++ b/tests/nquote4.tests
@@ -0,0 +1,24 @@
+recho $'ab\x{}cd'
+recho $'ab\x{41}cd'
+recho $'ab\x41cd'
+
+recho $'ab\x{4}cd'
+recho $'ab\x4cd'
+
+recho $'ab\x{cde'
+
+recho $'ab\x{cde'
+recho $'ab\x{cd}e'
+recho $'ab\x{c}de'
+
+recho $'\x{abcX'
+recho $'\x{ab}cX'
+recho $'\x{}X'
+recho $'\x{X'
+recho $'\x{01234567X'
+
+recho $'\x{41}b'
+recho $'\x{}bc'
+recho $'\x{1}bcd'
+
+recho $'\x{bde'
diff --git a/tests/read2.sub b/tests/read2.sub
index 1e632c35..176cf863 100644
--- a/tests/read2.sub
+++ b/tests/read2.sub
@@ -1,6 +1,6 @@
a=4
-read -t 2 a
+read -t 2 a < /dev/tty
echo $?
echo $a
@@ -10,7 +10,7 @@ echo $?
echo $a
-read -t -3 a
+read -t -3 a < /dev/tty
echo $?
echo $a
diff --git a/tests/redir.right b/tests/redir.right
index 283bdcdb..54b05f8d 100644
--- a/tests/redir.right
+++ b/tests/redir.right
@@ -88,3 +88,9 @@ f ()
after read
./redir5.sub: line 27: read: read error: 0: Bad file descriptor
# tests of ksh93-like dup-and-close redirection operators
+/
+/
+/
+0
+0
+0
diff --git a/tests/redir.tests b/tests/redir.tests
index e80b7309..19cf9a1e 100644
--- a/tests/redir.tests
+++ b/tests/redir.tests
@@ -153,3 +153,6 @@ cat < redir1.*
# test ksh93 dup-and-close (move fd) redirections
${THIS_SH} ./redir5.sub
+
+# test behavior after a write error with a builtin command
+${THIS_SH} ./redir6.sub
diff --git a/tests/redir6.sub b/tests/redir6.sub
new file mode 100644
index 00000000..60cc68b0
--- /dev/null
+++ b/tests/redir6.sub
@@ -0,0 +1,8 @@
+cd /
+pwd
+help >&-
+pwd
+pwd
+echo $?
+echo $?
+echo $?
diff --git a/tests/run-alias b/tests/run-alias
new file mode 100644
index 00000000..6a20b06e
--- /dev/null
+++ b/tests/run-alias
@@ -0,0 +1,2 @@
+${THIS_SH} ./alias.tests > /tmp/xx 2>&1
+diff /tmp/xx alias.right && rm -f /tmp/xx
diff --git a/tests/run-braces b/tests/run-braces
index 564a96f3..53d4f1b7 100644
--- a/tests/run-braces
+++ b/tests/run-braces
@@ -1,2 +1,2 @@
-${THIS_SH} ./braces-tests > /tmp/xx
+${THIS_SH} ./braces.tests > /tmp/xx
diff /tmp/xx braces.right && rm -f /tmp/xx
diff --git a/tests/run-dbg-support b/tests/run-dbg-support
new file mode 100755
index 00000000..9e9c649c
--- /dev/null
+++ b/tests/run-dbg-support
@@ -0,0 +1,11 @@
+#!../bash
+#$Id: run-dbg-support,v 1.5 2002/11/14 06:08:16 rockyb Exp $
+
+TEST_NAME='dbg-support'
+TEST_FILE="/tmp/${TEST_NAME}.check"
+${THIS_SH} ./${TEST_NAME}.tests > $TEST_FILE 2>&1 < /dev/null
+set -f
+diff $TEST_FILE ${TEST_NAME}.right && rm -f $TEST_FILE
+
+# Return code tells testing mechanism whether passed or not.
+exit $?
diff --git a/tests/run-dbg-support2 b/tests/run-dbg-support2
new file mode 100755
index 00000000..f62583f8
--- /dev/null
+++ b/tests/run-dbg-support2
@@ -0,0 +1,16 @@
+#!../bash
+#$Id: run-dbg-support2,v 1.3 2002/11/14 06:08:16 rockyb Exp $
+
+TEST_NAME='dbg-support2'
+TEST_FILE="/tmp/${TEST_NAME}.check"
+${THIS_SH} ./${TEST_NAME}.tests > $TEST_FILE 2>&1 < /dev/null
+set -f
+diff $TEST_FILE ${TEST_NAME}.right && rm -f $TEST_FILE
+
+# Return code tells testing mechanism whether passed or not.
+exit $?
+
+#;;; Local Variables: ***
+#;;; mode:shell-script ***
+#;;; eval: (sh-set-shell "bash") ***
+#;;; End: ***
diff --git a/tests/run-glob-test b/tests/run-glob-test
index a01047ff..659112a3 100644
--- a/tests/run-glob-test
+++ b/tests/run-glob-test
@@ -1,4 +1,4 @@
PATH=$PATH:`pwd`
export PATH
-${THIS_SH} ./glob-test | grep -v '^expect' > /tmp/xx
+${THIS_SH} ./glob-test 2>&1 | grep -v '^expect' > /tmp/xx
diff /tmp/xx glob.right && rm -f /tmp/xx
diff --git a/tests/run-nquote4 b/tests/run-nquote4
new file mode 100644
index 00000000..006872c8
--- /dev/null
+++ b/tests/run-nquote4
@@ -0,0 +1,2 @@
+${THIS_SH} ./nquote.tests 2>&1 | grep -v '^expect' > /tmp/xx
+diff /tmp/xx nquote.right && rm -f /tmp/xx
diff --git a/tests/run-set-x b/tests/run-set-x
new file mode 100755
index 00000000..b999e698
--- /dev/null
+++ b/tests/run-set-x
@@ -0,0 +1,11 @@
+#!../bash
+#$Id: run-set-x,v 1.1 2002/12/09 13:12:37 rockyb Exp $
+
+TEST_NAME='set-x'
+TEST_FILE="/tmp/${TEST_NAME}.check"
+${THIS_SH} ./${TEST_NAME}.tests > $TEST_FILE 2>&1 < /dev/null
+set -f
+diff $TEST_FILE ${TEST_NAME}.right && rm -f $TEST_FILE
+
+# Return code tells testing mechanism whether passed or not.
+exit $?
diff --git a/tests/run-test b/tests/run-test
index 32fbde7a..b2482c3f 100644
--- a/tests/run-test
+++ b/tests/run-test
@@ -1,2 +1,4 @@
+unset GROUPS UID 2>/dev/null
+
${THIS_SH} ./test.tests >/tmp/xx 2>&1
diff /tmp/xx test.right && rm -f /tmp/xx
diff --git a/tests/set-x.right b/tests/set-x.right
new file mode 100644
index 00000000..fc55bd88
--- /dev/null
+++ b/tests/set-x.right
@@ -0,0 +1,28 @@
++ (( i=0 ))
++ (( i<=5 ))
++ x=0
++ (( i++ ))
++ (( i<=5 ))
++ x=0
++ (( i++ ))
++ (( i<=5 ))
++ x=0
++ (( i++ ))
++ (( i<=5 ))
++ x=0
++ (( i++ ))
++ (( i<=5 ))
++ x=0
++ (( i++ ))
++ (( i<=5 ))
++ x=0
++ (( i++ ))
++ (( i<=5 ))
++ for i in 0 1 2
++ x=i
++ for i in 0 1 2
++ x=i
++ for i in 0 1 2
++ x=i
++ case x in
++ x=i
diff --git a/tests/set-x.tests b/tests/set-x.tests
new file mode 100755
index 00000000..323b772d
--- /dev/null
+++ b/tests/set-x.tests
@@ -0,0 +1,21 @@
+#!../bash
+# $Id: set-x.tests,v 1.1 2002/12/09 13:12:37 rockyb Exp $
+#
+# Test that "set -x" shows what we think it should.
+#
+set -x
+for ((i=0; i<=5; i++ )) ; do
+ x=0
+done
+for i in 0 1 2 ; do
+ x=i
+done
+case x in
+ 0) x=i ;;
+ *) x=i ;;
+esac
+
+#;;; Local Variables: ***
+#;;; mode:shell-script ***
+#;;; eval: (sh-set-shell "bash") ***
+#;;; End: ***
diff --git a/tests/shopt.right b/tests/shopt.right
index 51218f65..605a8f01 100644
--- a/tests/shopt.right
+++ b/tests/shopt.right
@@ -9,7 +9,12 @@ shopt -s cmdhist
shopt -u dotglob
shopt -u execfail
shopt -s expand_aliases
+shopt -u extdebug
shopt -u extglob
+shopt -s extquote
+shopt -u failglob
+shopt -s force_fignore
+shopt -u gnu_errfmt
shopt -u histreedit
shopt -u histappend
shopt -u histverify
@@ -36,6 +41,8 @@ shopt -s sourcepath
shopt -s cdspell
shopt -s cmdhist
shopt -s expand_aliases
+shopt -s extquote
+shopt -s force_fignore
shopt -s hostcomplete
shopt -s interactive_comments
shopt -s progcomp
@@ -47,7 +54,10 @@ shopt -u checkhash
shopt -u checkwinsize
shopt -u dotglob
shopt -u execfail
+shopt -u extdebug
shopt -u extglob
+shopt -u failglob
+shopt -u gnu_errfmt
shopt -u histreedit
shopt -u histappend
shopt -u histverify
@@ -67,7 +77,10 @@ checkhash off
checkwinsize off
dotglob off
execfail off
+extdebug off
extglob off
+failglob off
+gnu_errfmt off
histreedit off
histappend off
histverify off
@@ -86,6 +99,8 @@ set +o allexport
set -o braceexpand
set -o emacs
set +o errexit
+set +o errtrace
+set +o functrace
set -o hashall
set -o histexpand
set -o history
@@ -101,6 +116,7 @@ set +o notify
set +o nounset
set +o onecmd
set +o physical
+set +o pipefail
set +o posix
set -o privileged
set +o verbose
@@ -111,6 +127,8 @@ allexport off
braceexpand on
emacs on
errexit off
+errtrace off
+functrace off
hashall on
histexpand on
history on
@@ -126,6 +144,7 @@ notify off
nounset off
onecmd off
physical off
+pipefail off
posix off
privileged on
verbose off
@@ -136,6 +155,8 @@ set +o allexport
set -o braceexpand
set -o emacs
set +o errexit
+set +o errtrace
+set +o functrace
set -o hashall
set -o histexpand
set -o history
@@ -151,6 +172,7 @@ set +o notify
set +o nounset
set +o onecmd
set +o physical
+set +o pipefail
set +o posix
set -o privileged
set +o verbose
@@ -171,6 +193,8 @@ set -o privileged
--
set +o allexport
set +o errexit
+set +o errtrace
+set +o functrace
set +o ignoreeof
set +o keyword
set +o noclobber
@@ -181,6 +205,7 @@ set +o notify
set +o nounset
set +o onecmd
set +o physical
+set +o pipefail
set +o posix
set +o verbose
set +o vi
@@ -188,6 +213,8 @@ set +o xtrace
--
allexport off
errexit off
+errtrace off
+functrace off
ignoreeof off
keyword off
noclobber off
@@ -198,6 +225,7 @@ notify off
nounset off
onecmd off
physical off
+pipefail off
posix off
verbose off
vi off
diff --git a/tests/test.tests b/tests/test.tests
index d84af1bd..e378cf2b 100644
--- a/tests/test.tests
+++ b/tests/test.tests
@@ -99,7 +99,7 @@ t -s run-all
echo 't -t 20'
t -t 20
echo 't -t 0'
-t -t 0
+t -t 0 < /dev/tty
echo 't -u noexist'
t -u noexist
diff --git a/tests/trap.right b/tests/trap.right
index 6c179d0a..72f3b6d2 100644
--- a/tests/trap.right
+++ b/tests/trap.right
@@ -29,6 +29,7 @@ trap -- 'echo [$LINENO] debug' DEBUG
[28] debug
./trap.tests[33] debug
./trap.tests[34] debug
+func2[30] debug
func2[31] debug
func2debug line
./trap.tests[36] debug
diff --git a/tests/type.right b/tests/type.right
index 30f433ab..853c33bb 100644
--- a/tests/type.right
+++ b/tests/type.right
@@ -4,7 +4,6 @@ type: usage: type [-afptP] name [name ...]
./type.tests: line 13: command: notthere: not found
function
keyword
-alias
builtin
file
file
@@ -16,7 +15,6 @@ func ()
}
while is a shell keyword
while is a shell keyword
-m is aliased to `more'
builtin is a shell builtin
/bin/sh is /bin/sh
func
@@ -27,6 +25,12 @@ func ()
}
while
while is a shell keyword
+./type.tests: line 42: type: m: not found
+./type.tests: line 43: command: m: not found
+alias m='more'
+alias m='more'
+m is aliased to `more'
+alias
alias m='more'
alias m='more'
alias m='more'
@@ -35,8 +39,8 @@ builtin
builtin is a shell builtin
/bin/sh
/bin/sh is /bin/sh
-./type.tests: line 51: type: func: not found
-./type.tests: line 53: type: m: not found
+./type.tests: line 64: type: func: not found
+./type.tests: line 66: type: m: not found
/bin/sh
/tmp/bash
bash is hashed (/tmp/bash)
diff --git a/tests/type.tests b/tests/type.tests
index 706e3be3..7307c869 100644
--- a/tests/type.tests
+++ b/tests/type.tests
@@ -19,7 +19,6 @@ func() { echo this is func; }
type -t func
type -t while
-type -t m
type -t builtin
type -t /bin/sh
type -t ${THIS_SH}
@@ -29,7 +28,6 @@ type func
# the following two should produce identical output
type while
type -a while
-type m
type builtin
type /bin/sh
@@ -37,11 +35,26 @@ command -v func
command -V func
command -v while
command -V while
+
# the following three lines should produce the same output
+# first test with alias expansion off (should all fail or produce no output)
+type -t m
+type m
command -v m
alias -p
alias m
+
+# then test with alias expansion on
+shopt -s expand_aliases
+type m
+type -t m
+command -v m
+alias -p
+alias m
+
command -V m
+shopt -u expand_aliases
+
command -v builtin
command -V builtin
command -v /bin/sh
diff --git a/tests/varenv.right b/tests/varenv.right
index 563411d3..c458b184 100644
--- a/tests/varenv.right
+++ b/tests/varenv.right
@@ -30,7 +30,7 @@ unset
declare -x ivar="42"
hB
braceexpand:hashall:interactive-comments
-hPB
+hBP
braceexpand:hashall:interactive-comments:physical
declare -r SHELLOPTS="braceexpand:hashall:interactive-comments:physical"
abcde