aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/appendop.right18
-rw-r--r--tests/appendop.tests83
-rw-r--r--tests/arith-for.right10
-rw-r--r--tests/array.right27
-rw-r--r--tests/array.tests64
-rw-r--r--tests/array1.sub1
-rw-r--r--tests/array2.sub1
-rw-r--r--tests/array3.sub9
-rw-r--r--tests/braces.right9
-rw-r--r--tests/braces.tests13
-rw-r--r--tests/builtins.right2
-rwxr-xr-xtests/dbg-support.tests6
-rwxr-xr-xtests/dollar-at-star4
-rw-r--r--tests/dollar-star2.sub26
-rw-r--r--tests/dollar.right9
-rw-r--r--tests/errors.right2
-rw-r--r--tests/exec.right3
-rw-r--r--tests/execscript4
-rw-r--r--tests/exp-tests6
-rw-r--r--tests/exp.right2
-rw-r--r--tests/extglob.right1
-rw-r--r--tests/extglob.tests3
-rw-r--r--tests/extglob3.right27
-rw-r--r--tests/extglob3.tests56
-rw-r--r--tests/func.tests8
-rw-r--r--tests/herestr.right2
-rw-r--r--tests/histexp.right2
-rw-r--r--tests/histexp.tests2
-rw-r--r--tests/history.right4
-rw-r--r--tests/history.tests2
-rw-r--r--tests/ifs-posix.right1
-rw-r--r--tests/ifs-posix.tests257
-rw-r--r--tests/intl.right10
-rw-r--r--tests/intl.tests38
-rw-r--r--tests/iquote.right61
-rw-r--r--tests/iquote.tests143
-rw-r--r--tests/jobs.right2
-rw-r--r--tests/jobs4.sub4
-rw-r--r--tests/more-exp.right18
-rw-r--r--tests/more-exp.tests5
-rw-r--r--tests/new-exp.right25
-rw-r--r--tests/new-exp.tests13
-rw-r--r--tests/new-exp5.sub30
-rw-r--r--tests/nquote.right10
-rw-r--r--tests/nquote.tests22
-rw-r--r--tests/printf.rightbin1344 -> 1287 bytes
-rw-r--r--tests/printf.tests16
-rw-r--r--tests/read.right5
-rw-r--r--tests/redir.right6
-rw-r--r--tests/redir.tests16
-rw-r--r--tests/redir7.sub69
-rw-r--r--tests/rhs-exp.right6
-rw-r--r--tests/rhs-exp.tests11
-rw-r--r--tests/run-appendop2
-rw-r--r--tests/run-extglob34
-rw-r--r--tests/run-ifs-posix2
-rw-r--r--tests/run-intl8
-rw-r--r--tests/run-iquote2
-rw-r--r--tests/run-minimal2
-rw-r--r--tests/run-nquote46
-rw-r--r--tests/run-read4
-rw-r--r--tests/run-tilde2
-rw-r--r--tests/run-tilde22
-rw-r--r--tests/shopt.right9
-rw-r--r--tests/tilde.tests (renamed from tests/tilde-tests)0
-rw-r--r--tests/tilde2.right24
-rw-r--r--tests/tilde2.tests70
-rw-r--r--tests/type.right8
-rw-r--r--tests/type.tests3
-rw-r--r--tests/varenv.right3
-rw-r--r--tests/varenv.sh3
71 files changed, 1273 insertions, 55 deletions
diff --git a/tests/appendop.right b/tests/appendop.right
new file mode 100644
index 0000000..1e24333
--- /dev/null
+++ b/tests/appendop.right
@@ -0,0 +1,18 @@
+14
+1 2 3 4 5 6
+1 2 3 4 51 6
+5
+14
+7
+42
+1 2 3 4 12
+18
+1 2 3 4 18
+1 2 7 4 5
+1 2 7 13 5 9
+14
+9
+4
+9
+16
+./appendop.tests: line 83: x: readonly variable
diff --git a/tests/appendop.tests b/tests/appendop.tests
new file mode 100644
index 0000000..7b61f3f
--- /dev/null
+++ b/tests/appendop.tests
@@ -0,0 +1,83 @@
+# basic cases
+a=1
+a+=4
+echo $a
+
+x=(1 2 3)
+x+=(4 5 6)
+
+echo ${x[@]}
+
+x[4]+=1
+echo ${x[@]}
+
+# trickier cases
+
+a+=5 printenv a
+echo $a
+
+# if the integer flag is set, ksh93 appears to do arithmetic += and evaluate
+# old value as an arithmetic expression
+a=
+typeset -i a
+a+=7
+echo $a
+
+b=4+1
+typeset -i b
+b+=37
+
+echo $b
+
+unset x
+x=(1 2 3 4 5)
+
+typeset -i x
+
+x[4]+=7
+
+echo ${x[@]}
+
+unset x
+typeset -i x
+
+x=([0]=7+11)
+echo ${x[@]}
+
+unset x
+x=(1 2 3 4 5)
+
+typeset -i x
+
+#x[4]=7+11
+
+x=(1 2 3 4 [4]=7+11 )
+echo ${x[@]}
+
+x=( 1 2 [2]+=7 4 5 )
+echo ${x[@]}
+
+x+=( [3]+=9 [5]=9 )
+echo ${x[@]}
+
+unset a
+a=1
+export a+=4
+printenv a
+printenv a+
+
+unset x
+typeset -i x=4+5
+echo $x
+
+unset x
+typeset x+=4
+echo $x
+
+typeset -i x+=5
+echo $x
+
+readonly x+=7
+echo $x
+
+x+=5
diff --git a/tests/arith-for.right b/tests/arith-for.right
index c74baa4..4494110 100644
--- a/tests/arith-for.right
+++ b/tests/arith-for.right
@@ -14,24 +14,24 @@ 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
break;
fi;
echo $i;
done;
- for ((i=0 ; i<3 ; 1))
+ for ((i=0; i<3; 1))
do
echo $i;
(( i++ ));
done;
i=0;
- for ((1 ; 1 ; 1))
+ for ((1; 1; 1))
do
if (( i > 2 )); then
break;
@@ -40,7 +40,7 @@ fx ()
(( i++ ));
done;
i=0;
- for ((1 ; 1 ; 1))
+ for ((1; 1; 1))
do
if (( i > 2 )); then
break;
diff --git a/tests/array.right b/tests/array.right
index fa2ae2a..488b4e4 100644
--- a/tests/array.right
+++ b/tests/array.right
@@ -128,6 +128,15 @@ grep [ 123 ] *
length = 3
value = new1 new2 new3
./array.tests: line 237: narray: unbound variable
+./array1.sub: line 1: syntax error near unexpected token `('
+./array1.sub: line 1: `printf "%s\n" -a a=(a 'b c')'
+./array2.sub: line 1: syntax error near unexpected token `('
+./array2.sub: line 1: `declare -a ''=(a 'b c')'
+9
+9
+
+
+7 8 9
a b c d e f g
for case if then else
@@ -135,10 +144,10 @@ for case if then else
12 14 16 18 20
4414758999202
aaa bbb
-./array.tests: line 277: syntax error near unexpected token `<>'
-./array.tests: line 277: `metas=( <> < > ! )'
-./array.tests: line 278: syntax error near unexpected token `<>'
-./array.tests: line 278: `metas=( [1]=<> [2]=< [3]=> [4]=! )'
+./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]=! )'
abc 3
case 4
abc case if then else 5
@@ -178,3 +187,13 @@ negative offset 2 - expect seven
seven
out-of-range offset
+e
+4
+1 4 7 10
+'b
+b c
+$0
+t
+[3]=abcde r s t u v
+e
+9
diff --git a/tests/array.tests b/tests/array.tests
index 4f5d830..4a735d8 100644
--- a/tests/array.tests
+++ b/tests/array.tests
@@ -236,7 +236,12 @@ echo "value = ${barray[*]}"
set -u
( echo ${#narray[4]} )
+${THIS_SH} ./array1.sub
+${THIS_SH} ./array2.sub
+
# some old bugs and ksh93 compatibility tests
+${THIS_SH} ./array3.sub
+
set +u
cd /tmp
@@ -332,3 +337,62 @@ echo ${av[@]: -1:2}
echo out-of-range offset
echo ${av[@]:12}
+
+# parsing problems and other inconsistencies not fixed until post bash-3.0
+unset x
+declare -a x=(')' $$)
+[ ${x[1]} -eq $$ ] || echo bad
+
+unset x
+declare -a x=(a b c d e)
+echo ${x[4]}
+
+z=([1]=one [4]=four [7]=seven [10]=ten)
+
+echo ${#z[@]}
+
+echo ${!z[@]}
+
+unset x
+declare -a x=(a \'b c\')
+
+echo "${x[1]}"
+
+unset x
+declare -a x=(a 'b c')
+
+echo "${x[1]}"
+
+unset x
+declare -a x=($0)
+[ "${x[@]}" = $0 ] || echo double expansion of \$0
+declare -a x=(\$0)
+echo "${x[@]}"
+
+: ${TMPDIR:=/tmp}
+
+mkdir $TMPDIR/bash-test-$$
+cd $TMPDIR/bash-test-$$
+
+trap "cd / ; rm -rf $TMPDIR/bash-test-$$" 0 1 2 3 6 15
+
+touch '[3]=abcde'
+
+touch r s t u v
+
+declare -a x=(*)
+
+echo ${x[3]}
+echo ${x[@]}
+
+unset x
+x=(a b c d e)
+
+echo ${x[*]: -1}
+
+unset x[4]
+unset x[2]
+
+x[9]='9'
+
+echo ${x[*]: -1}
diff --git a/tests/array1.sub b/tests/array1.sub
new file mode 100644
index 0000000..86e9332
--- /dev/null
+++ b/tests/array1.sub
@@ -0,0 +1 @@
+printf "%s\n" -a a=(a 'b c')
diff --git a/tests/array2.sub b/tests/array2.sub
new file mode 100644
index 0000000..0e6417d
--- /dev/null
+++ b/tests/array2.sub
@@ -0,0 +1 @@
+declare -a ''=(a 'b c')
diff --git a/tests/array3.sub b/tests/array3.sub
new file mode 100644
index 0000000..579b42b
--- /dev/null
+++ b/tests/array3.sub
@@ -0,0 +1,9 @@
+a=(0 1 2 3 4 5 6 7 8 9)
+
+echo ${a[@]: -1}
+
+echo ${a[@]:9}
+echo ${a[@]:10}
+echo ${a[@]:11}
+
+echo ${a[@]:7:3}
diff --git a/tests/braces.right b/tests/braces.right
index 006f2c2..3d7ef8e 100644
--- a/tests/braces.right
+++ b/tests/braces.right
@@ -17,6 +17,11 @@ abcd{efgh
foo 1 2 bar
foo 1 2 bar
foo 1 2 bar
+foobar foobaz.
+foobar foobaz
+bazx bazy
+vx vy
+bazx bazy
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
@@ -28,8 +33,8 @@ x3y
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
+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}
diff --git a/tests/braces.tests b/tests/braces.tests
index b9ae180..3f57829 100644
--- a/tests/braces.tests
+++ b/tests/braces.tests
@@ -23,6 +23,19 @@ echo foo {1,2} bar
echo `zecho foo {1,2} bar`
echo $(zecho foo {1,2} bar)
+var=baz
+varx=vx
+vary=vy
+
+echo foo{bar,${var}.}
+echo foo{bar,${var}}
+
+echo "${var}"{x,y}
+echo $var{x,y}
+echo ${var}{x,y}
+
+unset var varx vary
+
# new sequence brace operators
echo {1..10}
diff --git a/tests/builtins.right b/tests/builtins.right
index f686606..9266b5a 100644
--- a/tests/builtins.right
+++ b/tests/builtins.right
@@ -63,6 +63,7 @@ enable return
enable set
enable shift
enable source
+enable times
enable trap
enable unset
enable .
@@ -78,6 +79,7 @@ enable return
enable set
enable shift
enable source
+enable times
enable trap
enable unset
enable -n test worked
diff --git a/tests/dbg-support.tests b/tests/dbg-support.tests
index 3a5e4ae..517591c 100755
--- a/tests/dbg-support.tests
+++ b/tests/dbg-support.tests
@@ -56,7 +56,7 @@ fn4() {
#
# Test of support for debugging facilities in bash
#
-# Test debugger set option fntrace - set on. Not in vanilla Bash 2.05
+# Test debugger set option functrace - set on. Not in vanilla Bash 2.05
#
set -o functrace
trap 'print_debug_trap $LINENO' DEBUG
@@ -72,7 +72,7 @@ fn2
fn3
source ./dbg-support.sub
-# Test debugger set option fntrace - set off
+# Test debugger set option functrace - set off
set +T
# We should not trace into this.
@@ -82,7 +82,7 @@ fn3
fn4
source ./dbg-support.sub
-# Another way to say: set -o fntrace
+# Another way to say: set -o functrace
set -T
# We should trace into this.
diff --git a/tests/dollar-at-star b/tests/dollar-at-star
index d8329b1..25c2443 100755
--- a/tests/dollar-at-star
+++ b/tests/dollar-at-star
@@ -219,4 +219,8 @@ ${THIS_SH} ./dollar-at1.sub
# $@. Bugs through bash-2.05b
${THIS_SH} ./dollar-at2.sub
+# tests for various expansions of $* in different contexts -- word split,
+# no splitting, etc. when $IFS is NUL
+${THIS_SH} ./dollar-star2.sub
+
exit 0
diff --git a/tests/dollar-star2.sub b/tests/dollar-star2.sub
new file mode 100644
index 0000000..844a297
--- /dev/null
+++ b/tests/dollar-star2.sub
@@ -0,0 +1,26 @@
+set A B
+
+IFS=
+
+x=$*
+y="$*"
+
+recho "$x"
+recho "$y"
+
+IFS=$' \t\n'
+
+set 'A B' 'C D'
+
+IFS=
+
+x=$*
+y="$*"
+
+recho "$x"
+recho "$y"
+
+recho $x
+recho $*
+recho $y
+recho "$*"
diff --git a/tests/dollar.right b/tests/dollar.right
index 7b0f511..ff57f1c 100644
--- a/tests/dollar.right
+++ b/tests/dollar.right
@@ -125,3 +125,12 @@ argv[2] = <2>
argv[1] = <echo 1 ; echo 1>
argv[1] = <echo 1 2 ; echo 1>
argv[2] = <2>
+argv[1] = <AB>
+argv[1] = <AB>
+argv[1] = <A BC D>
+argv[1] = <A BC D>
+argv[1] = <A BC D>
+argv[1] = <A B>
+argv[2] = <C D>
+argv[1] = <A BC D>
+argv[1] = <A BC D>
diff --git a/tests/errors.right b/tests/errors.right
index 9d8e185..ac987fb 100644
--- a/tests/errors.right
+++ b/tests/errors.right
@@ -95,6 +95,6 @@ trap: usage: trap [-lp] [arg signal_spec ...]
./errors.tests: line 246: kill: -s: option requires an argument
./errors.tests: line 248: kill: S: invalid signal specification
./errors.tests: line 250: kill: `': not a pid or valid job spec
-kill: usage: kill [-s sigspec | -n signum | -sigspec] [pid | job]... or kill -l [sigspec]
+kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
./errors.tests: line 255: set: trackall: invalid option name
./errors.tests: line 262: `!!': not a valid identifier
diff --git a/tests/exec.right b/tests/exec.right
index fbd2624..d65b89d 100644
--- a/tests/exec.right
+++ b/tests/exec.right
@@ -12,7 +12,7 @@ after exec1.sub without args: 0
126
./execscript: line 39: /: is a directory
126
-/: /: cannot execute binary file
+/: /: is a directory
126
./execscript: line 46: .: /: is a directory
1
@@ -51,3 +51,4 @@ this is ohio-state
0
1
testb
+after
diff --git a/tests/execscript b/tests/execscript
index 61722f2..09a4ba5 100644
--- a/tests/execscript
+++ b/tests/execscript
@@ -104,3 +104,7 @@ ${THIS_SH} ./exec6.sub
# checks for properly deciding what constitutes an executable file
${THIS_SH} ./exec7.sub
+
+true | `echo true` &
+
+echo after
diff --git a/tests/exp-tests b/tests/exp-tests
index f8512c3..884b5a6 100644
--- a/tests/exp-tests
+++ b/tests/exp-tests
@@ -372,3 +372,9 @@ a="a b c d e"
declare b=$a
expect '<a> <b> <c> <d> <e>'
recho $b
+
+a="a?b?c"
+
+echo ${a//\\?/ }
+
+echo ${a//\?/ }
diff --git a/tests/exp.right b/tests/exp.right
index 747c80e..fdadbd9 100644
--- a/tests/exp.right
+++ b/tests/exp.right
@@ -143,3 +143,5 @@ argv[2] = <b>
argv[3] = <c>
argv[4] = <d>
argv[5] = <e>
+a?b?c
+a b c
diff --git a/tests/extglob.right b/tests/extglob.right
index 154a969..f063b26 100644
--- a/tests/extglob.right
+++ b/tests/extglob.right
@@ -77,3 +77,4 @@ 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 a,b a-b a.b a:b a;b a_b
+argv[1] = <ef>
diff --git a/tests/extglob.tests b/tests/extglob.tests
index 1a123d8..2d93850 100644
--- a/tests/extglob.tests
+++ b/tests/extglob.tests
@@ -353,6 +353,9 @@ echo a@(.|[^[:alnum:]])b
builtin cd /
rm -rf $TESTDIR
+x=abcdef
+recho "${x#*(a|b)cd}"
+
# this is for the benefit of pure coverage, so it writes the pcv file
# in the right place
builtin cd $MYDIR
diff --git a/tests/extglob3.right b/tests/extglob3.right
new file mode 100644
index 0000000..db9447e
--- /dev/null
+++ b/tests/extglob3.right
@@ -0,0 +1,27 @@
+match 1
+match 2
+match 3
+match 4
+match 1a
+match 1b
+match 2a
+match 2b
+match 3a
+match 3b
+match 4a
+match 4b
+match 5
+match 6
+match 7
+match 8
+match 9
+match 10
+match 11
+match 12
+match 13
+match 14
+match 15
+match 16
+match 17
+match 18
+ok 19
diff --git a/tests/extglob3.tests b/tests/extglob3.tests
new file mode 100644
index 0000000..60454a2
--- /dev/null
+++ b/tests/extglob3.tests
@@ -0,0 +1,56 @@
+shopt -s extglob
+
+[[ ab/../ == @(ab|+([^/]))/..?(/) ]] && echo match 1
+
+[[ ab/../ == +([^/])/..?(/) ]] && echo match 2
+
+[[ ab/../ == @(ab|?b)/..?(/) ]] && echo match 3
+
+[[ ab/../ == +([^/])/../ ]] && echo match 4
+
+[[ ab/../ == +([!/])/..?(/) ]] && echo match 1a
+
+[[ ab/../ == @(ab|+([!/]))/..?(/) ]] && echo match 1b
+
+[[ ab/../ == +([!/])/../ ]] && echo match 2a
+
+[[ ab/../ == +([!/])/..?(/) ]] && echo match 2b
+
+[[ ab/../ == +([!/])/..@(/) ]] && echo match 3a
+
+[[ ab/../ == +(ab)/..?(/) ]] && echo match 3b
+
+[[ ab/../ == [!/][!/]/../ ]] && echo match 4a
+
+[[ ab/../ == @(ab|?b)/..?(/) ]] && echo match 4b
+
+[[ ab/../ == [^/][^/]/../ ]] && echo match 5
+
+[[ ab/../ == ?b/..?(/) ]] && echo match 6
+
+[[ ab/../ == +(?b)/..?(/) ]] && echo match 7
+
+[[ ab/../ == +(?b|?b)/..?(/) ]] && echo match 8
+
+[[ ab/../ == @(?b|?b)/..?(/) ]] && echo match 9
+
+[[ ab/../ == @(a?|?b)/..?(/) ]] && echo match 10
+
+[[ ab/../ == ?(ab)/..?(/) ]] && echo match 11
+
+[[ ab/../ == ?(ab|??)/..?(/) ]] && echo match 12
+
+[[ ab/../ == @(??)/..?(/) ]] && echo match 13
+
+[[ ab/../ == @(??|a*)/..?(/) ]] && echo match 14
+
+[[ ab/../ == @(a*)/..?(/) ]] && echo match 15
+
+[[ ab/../ == +(??)/..?(/) ]] && echo match 16
+
+[[ ab/../ == +(??|a*)/..?(/) ]] && echo match 17
+
+[[ ab/../ == +(a*)/..?(/) ]] && echo match 18
+
+#
+j="@(x)" ; [[ x == $j ]] && echo ok 19
diff --git a/tests/func.tests b/tests/func.tests
index 2095f24..063f4e0 100644
--- a/tests/func.tests
+++ b/tests/func.tests
@@ -157,4 +157,12 @@ ${THIS_SH} ./func2.sub
# test for some posix-specific function behavior
${THIS_SH} ./func3.sub
+unset -f myfunction
+myfunction() {
+ echo "bad shell function redirection"
+} >> /dev/null
+
+myfunction
+myfunction | cat
+
exit 0
diff --git a/tests/herestr.right b/tests/herestr.right
index 2659aac..80b01cf 100644
--- a/tests/herestr.right
+++ b/tests/herestr.right
@@ -24,5 +24,5 @@ f3 ()
echo $(echo hi)
echo ho
echo off to work we go
-declare -a uu='([0]="" [1]="kghfjk" [2]="jkfzuk" [3]="i\
+declare -a uu='([0]="" [1]="kghfjk" [2]="jkfzuk" [3]="i
")'
diff --git a/tests/histexp.right b/tests/histexp.right
index 193e9d4..f1c9e9d 100644
--- a/tests/histexp.right
+++ b/tests/histexp.right
@@ -1,5 +1,5 @@
echo $BASH_VERSION
-./histexp.tests: line 22: history: !!:z: history expansion failed
+./histexp.tests: line 24: history: !!:z: history expansion failed
1 for i in one two three; do echo $i; done
2 /bin/sh -c 'echo this is $0'
3 ls
diff --git a/tests/histexp.tests b/tests/histexp.tests
index 11596dd..721208c 100644
--- a/tests/histexp.tests
+++ b/tests/histexp.tests
@@ -5,6 +5,8 @@ trap 'rm /tmp/newhistory' 0
file=bax
histchars='!^#' # make sure history comment char is set correctly
+unset HISTFILESIZE
+
history -c
HISTFILE=history.list
diff --git a/tests/history.right b/tests/history.right
index 619d34c..556a312 100644
--- a/tests/history.right
+++ b/tests/history.right
@@ -97,7 +97,7 @@ line 2 for history
6 HISTFILE=/tmp/newhistory
7 echo displaying \$HISTFILE after history -a
8 cat $HISTFILE
-./history.tests: line 73: fc: history specification out of range
+./history.tests: line 75: fc: history specification out of range
14 set -H
15 echo line 2 for history
16 unset HISTSIZE
@@ -107,5 +107,5 @@ echo xx xb xc
xx xb xc
echo 44 48 4c
44 48 4c
-./history.tests: line 88: fc: no command found
+./history.tests: line 90: fc: no command found
1
diff --git a/tests/history.tests b/tests/history.tests
index 76ea561..833cf3a 100644
--- a/tests/history.tests
+++ b/tests/history.tests
@@ -8,6 +8,8 @@ history -r -w /dev/null
# bad option
fc -v
+unset HISTFILESIZE
+
# all of these should result in an empty history list
history -c
history -r /dev/null
diff --git a/tests/ifs-posix.right b/tests/ifs-posix.right
new file mode 100644
index 0000000..f3bdccc
--- /dev/null
+++ b/tests/ifs-posix.right
@@ -0,0 +1 @@
+# tests 6856 passed 6856 failed 0
diff --git a/tests/ifs-posix.tests b/tests/ifs-posix.tests
new file mode 100644
index 0000000..cf9a898
--- /dev/null
+++ b/tests/ifs-posix.tests
@@ -0,0 +1,257 @@
+# Usage: $SHELL ifs.sh
+#
+# This script generates 6856 tests for the set(1) and read(1)
+# builtins w.r.t. IFS whitespace and non-whitespace characters.
+# Each failed test produces one line on the standard output that
+# contains the test along with the expected and actual results.
+# The last output line contains the test result counts. ordered>0
+# are the number of tests where IFS=": " produced different results
+# than IFS=" :". If a test fails the same way for IFS=": " and
+# IFS=" :" then the second output line is suppressed.
+
+TESTS=6856
+
+ksh_read=0
+echo 1 | read ksh_read
+ksh_arith=0
+eval '((ksh_arith+=1))' 2>/dev/null
+
+failed=0
+ordered=0
+passed=0
+
+split()
+{
+ i=$1 s=$2 r=$3 S='' R=''
+ for ifs in ': ' ' :'
+ do IFS=$ifs
+ set x $i
+ shift
+ IFS=' '
+ g="[$#]"
+ while :
+ do case $# in
+ 0) break ;;
+ esac
+ g="$g($1)"
+ shift
+ done
+ case $g in
+ "$s") case $ksh_arith in
+ 1) ((passed+=1)) ;;
+ *) passed=`expr $passed + 1` ;;
+ esac
+ case $S in
+ '') S=$g
+ ;;
+ "$g") ;;
+ *) case $ksh_arith in
+ 1) ((ordered+=1)) ;;
+ *) ordered=`expr $ordered + 1` ;;
+ esac
+ ;;
+ esac
+ ;;
+ "$S") case $ksh_arith in
+ 1) ((failed+=1)) ;;
+ *) failed=`expr $failed + 1` ;;
+ esac
+ ;;
+ *) case $ksh_arith in
+ 1) ((failed+=1)) ;;
+ *) failed=`expr $failed + 1` ;;
+ esac
+ case $s in
+ "$S") ;;
+ ?0*) echo "IFS=\"$ifs\"; x=\"$i\"; set x \$x; shift; echo \"[\$#]\" # expected \"$s\" got \"$g\"" ;;
+ ?1*) echo "IFS=\"$ifs\"; x=\"$i\"; set x \$x; shift; echo \"[\$#](\$1)\" # expected \"$s\" got \"$g\"" ;;
+ ?2*) echo "IFS=\"$ifs\"; x=\"$i\"; set x \$x; shift; echo \"[\$#](\$1)(\$2)\" # expected \"$s\" got \"$g\"" ;;
+ ?3*) echo "IFS=\"$ifs\"; x=\"$i\"; set x \$x; shift; echo \"[\$#](\$1)(\$2)(\$3)\" # expected \"$s\" got \"$g\"" ;;
+ *) echo TEST ERROR i="'$i'" s="'$s'" ;;
+ esac
+ case $S in
+ '') S=$g
+ ;;
+ "$g") ;;
+ *) case $ksh_arith in
+ 1) ((ordered+=1)) ;;
+ *) ordered=`expr $ordered + 1` ;;
+ esac
+ ;;
+ esac
+ esac
+ case $ksh_read in
+ 1) echo "$i" | IFS=$ifs read x y; g="($x)($y)" ;;
+ *) g=`export ifs; echo "$i" | ( IFS=$ifs; read x y; echo "($x)($y)" )` ;;
+ esac
+ case $g in
+ "$r") case $ksh_arith in
+ 1) ((passed+=1)) ;;
+ *) passed=`expr $passed + 1` ;;
+ esac
+ case $R in
+ '') R=$g
+ ;;
+ "$g") ;;
+ *) case $ksh_arith in
+ 1) ((ordered+=1)) ;;
+ *) ordered=`expr $ordered + 1` ;;
+ esac
+ ;;
+ esac
+ ;;
+ "$R") case $ksh_arith in
+ 1) ((failed+=1)) ;;
+ *) failed=`expr $failed + 1` ;;
+ esac
+ ;;
+ *) case $ksh_arith in
+ 1) ((failed+=1)) ;;
+ *) failed=`expr $failed + 1` ;;
+ esac
+ case $r in
+ "$R") ;;
+ *) echo "echo \"$i\" | ( IFS=\"$ifs\" read x y; echo \"(\$x)(\$y)\" ) # expected \"$r\" got \"$g\"" ;;
+ esac
+ case $R in
+ '') R=$g
+ ;;
+ "$g") ;;
+ *) case $ksh_arith in
+ 1) ((ordered+=1)) ;;
+ *) ordered=`expr $ordered + 1` ;;
+ esac
+ ;;
+ esac
+ ;;
+ esac
+ done
+}
+
+for str in \
+ '-' \
+ 'a' \
+ '- -' \
+ '- a' \
+ 'a -' \
+ 'a b' \
+ '- - -' \
+ '- - a' \
+ '- a -' \
+ '- a b' \
+ 'a - -' \
+ 'a - b' \
+ 'a b -' \
+ 'a b c' \
+
+do
+ IFS=' '
+ set x $str
+
+ shift
+ case $# in
+ 0) continue ;;
+ esac
+
+ f1=$1
+ case $f1 in
+ '-') f1='' ;;
+ esac
+
+ shift
+ case $# in
+ 0) for d0 in '' ' '
+ do
+ for d1 in '' ' ' ':' ' :' ': ' ' : '
+ do
+ case $f1$d1 in
+ '') split "$d0$f1$d1" "[0]" "()()" ;;
+ ' ') ;;
+ *) split "$d0$f1$d1" "[1]($f1)" "($f1)()" ;;
+ esac
+ done
+ done
+ continue
+ ;;
+ esac
+ f2=$1
+ case $f2 in
+ '-') f2='' ;;
+ esac
+
+ shift
+ case $# in
+ 0) for d0 in '' ' '
+ do
+ for d1 in ' ' ':' ' :' ': ' ' : '
+ do
+ case ' ' in
+ $f1$d1|$d1$f2) continue ;;
+ esac
+ for d2 in '' ' ' ':' ' :' ': ' ' : '
+ do
+ case $f2$d2 in
+ '') split "$d0$f1$d1$f2$d2" "[1]($f1)" "($f1)()" ;;
+ ' ') ;;
+ *) split "$d0$f1$d1$f2$d2" "[2]($f1)($f2)" "($f1)($f2)" ;;
+ esac
+ done
+ done
+ done
+ continue
+ ;;
+ esac
+ f3=$1
+ case $f3 in
+ '-') f3='' ;;
+ esac
+
+ shift
+ case $# in
+ 0) for d0 in '' ' '
+ do
+ for d1 in ':' ' :' ': ' ' : '
+ do
+ case ' ' in
+ $f1$d1|$d1$f2) continue ;;
+ esac
+ for d2 in ' ' ':' ' :' ': ' ' : '
+ do
+ case $f2$d2 in
+ ' ') continue ;;
+ esac
+ case ' ' in
+ $f2$d2|$d2$f3) continue ;;
+ esac
+ for d3 in '' ' ' ':' ' :' ': ' ' : '
+ do
+ case $f3$d3 in
+ '') split "$d0$f1$d1$f2$d2$f3$d3" "[2]($f1)($f2)" "($f1)($f2)" ;;
+ ' ') ;;
+ *) x=$f2$d2$f3$d3
+ x=${x#' '}
+ x=${x%' '}
+ split "$d0$f1$d1$f2$d2$f3$d3" "[3]($f1)($f2)($f3)" "($f1)($x)"
+ ;;
+ esac
+ done
+ done
+ done
+ done
+ continue
+ ;;
+ esac
+done
+case $ksh_arith in
+1) ((tests=passed+failed)) ;;
+*) tests=`expr $passed + $failed` ;;
+esac
+case $ordered in
+0) ordered="" ;;
+*) ordered=" ordered $ordered" ;;
+esac
+case $tests in
+$TESTS) fatal="" ;;
+*) fatal=" -- fundamental IFS error -- $TESTS tests expected"
+esac
+echo "# tests $tests passed $passed failed $failed$ordered$fatal"
diff --git a/tests/intl.right b/tests/intl.right
new file mode 100644
index 0000000..21a3b4f
--- /dev/null
+++ b/tests/intl.right
@@ -0,0 +1,10 @@
+1
+AéB
+B
+B
+ok 1
+ok 2
+aéb
+0000000 141 303 251 142
+0000004
diff --git a/tests/intl.tests b/tests/intl.tests
new file mode 100644
index 0000000..0dc33cb
--- /dev/null
+++ b/tests/intl.tests
@@ -0,0 +1,38 @@
+export LANG=en_US.UTF-8
+
+a=$'\303\251'
+
+echo "$a"
+
+echo ${#a}
+
+b=$'A\303\251B'
+
+echo "$b"
+
+echo ${b: -1}
+
+c=AeB
+
+echo ${c: -1}
+
+unset a
+a=$(printf '%b' 'A\303\251B')
+IFS=$(printf '%b' '\303\251')
+
+case "$a" in
+"A${IFS}B") echo ok 1 ;;
+*) echo bad 1 ;;
+esac
+
+set $a
+
+case $1 in
+A) echo ok 2 ;;
+*) echo bad 2 ;;
+esac
+
+set a b
+
+printf '%s\n' "$*"
+printf '%s' "$*" | od -b
diff --git a/tests/iquote.right b/tests/iquote.right
new file mode 100644
index 0000000..d164f10
--- /dev/null
+++ b/tests/iquote.right
@@ -0,0 +1,61 @@
+argv[1] = <xxxyyy>
+argv[1] = <xxx^?yyy>
+argv[1] = <xy>
+argv[1] = <x^?y>
+argv[1] = <-->
+argv[1] = <-^?->
+argv[1] = <>
+argv[1] = <>
+argv[1] = <^?>
+argv[1] = <^?yy>
+0x7f
+0x7f
+0x7f
+argv[1] = <^?>
+argv[1] = <^?@>
+argv[1] = <@^?@>
+argv[1] = <@^?>
+argv[1] = <^?>
+argv[1] = <^?@>
+argv[1] = <@^?@>
+argv[1] = <@^?>
+argv[1] = <1>
+argv[2] = <^?>
+argv[3] = <^?>
+argv[1] = <2>
+argv[2] = <^?a>
+argv[3] = <^?a>
+argv[1] = <2>
+argv[2] = <^?a>
+argv[3] = <^?a>
+argv[1] = <3>
+argv[2] = <^?aa>
+argv[3] = <^?aa>
+argv[1] = <>
+argv[1] = <-->
+argv[1] = <-->
+argv[1] = <^?>
+argv[1] = <-^?->
+argv[1] = <^?>
+argv[1] = <-^?->
+ok
+argv[1] = <aaa^?bbb>
+argv[1] = <ccc^?ddd>
+argv[1] = <eee^?fff>
+argv[1] = <ggg^?hhh>
+argv[1] = <aaabbb>
+argv[1] = <cccddd>
+argv[1] = <eeefff>
+argv[1] = <ggghhh>
+argv[1] = <aaa^?bbb>
+argv[1] = <ccc^?ddd>
+argv[1] = <eee^?fff>
+argv[1] = <ggg^?hhh>
+argv[1] = <aaabbb>
+argv[1] = <cccddd>
+argv[1] = <eeefff>
+argv[1] = <ggghhh>
+argv[1] = <aaa^?bbb>
+argv[1] = <ccc^?ddd>
+argv[1] = <eee^?fff>
+argv[1] = <ggg^?hhh>
diff --git a/tests/iquote.tests b/tests/iquote.tests
new file mode 100644
index 0000000..a2cdf4f
--- /dev/null
+++ b/tests/iquote.tests
@@ -0,0 +1,143 @@
+# bug in bash up to and including bash-3.0 (including patches)
+#
+# problem is conflict between CTLNUL used internally to denote quoted null
+# characters and its value (0x7f) appearing in the expansion of a variable
+#
+unset x
+recho "xxx${x}yyy"
+
+y=$'\177'
+recho "xxx${y}yyy"
+
+unset y
+
+unset undef
+
+set ""
+recho ${undef-"x$*y"}
+
+set $'\177'
+recho ${undef-"x$*y"}
+
+shift $#
+
+f()
+{
+ recho "-${*-x}-"
+}
+
+f ''
+f $'\177'
+
+unset -f f
+
+x=12345
+
+recho "${x:6:1}"
+
+x=
+recho "${x:0:1}"
+
+y=$'\177'
+recho "${y:0:1}"
+
+y=xxx$'\177'yyy
+recho "${y:3:3}"
+
+unset x y
+
+eval tmp=`printf "$'\\\\\x%x'\n" 127`
+printf "%#1x\n" "'$tmp"
+
+x=$'\177'
+printf "%#1x\n" "'$x"
+
+a=127
+eval c=\$\'\\$(printf '%o' $a)\'
+printf "%#1x\n" "'$c"
+
+recho "$c"
+recho "$c"@
+recho @"$c"@
+recho @"$c"
+
+recho "$c"
+recho "$c@"
+recho "@$c@"
+recho "@$c"
+
+unset tmp x a c
+
+qtest()
+{
+ recho ${#q} "${q}" ${q}
+}
+
+q=$'\x7f'
+qtest
+
+q=${q}a
+qtest
+
+q=$'\x7fa'
+qtest
+
+q="${q}a"
+qtest
+
+unset -f qtest
+unset q
+
+set -- ''
+recho "${*:1}"
+recho ${*:1}
+recho -${*:1}-
+recho -"${*:1}"-
+
+set $'\177'
+recho "${*:1}"
+recho "-${*:1}-"
+
+recho ${*:1}
+recho -${*:1}-
+
+shift $#
+
+DEL=`awk 'END{printf("%c", 0+127)}' </dev/null`
+T1=a\ $DEL
+T2="a $DEL"
+set -- x $(echo $T1|wc -c) $(echo $T2|wc -c); shift
+L1=$1; L2=$2
+case "$L1/$L2" in
+4/4) echo ok;;
+*) echo CTLNUL bug: L1=$L1, L2=$L2;;
+esac
+
+x=$'\177'
+recho "aaa${x}bbb"
+recho ccc"${x}"ddd
+recho eee"$x"fff
+recho ggg"$(echo $x)"hhh
+
+x=
+recho "aaa${x}bbb"
+recho ccc"${x}"ddd
+recho eee"$x"fff
+recho ggg"$(echo $x)"hhh
+
+set -- $'\177'
+recho "aaa${1}bbb"
+recho ccc"${1}"ddd
+recho eee"$1"fff
+recho ggg"$(echo $1)"hhh
+
+set -- ""
+recho "aaa${1}bbb"
+recho ccc"${1}"ddd
+recho eee"$1"fff
+recho ggg"$(echo $1)"hhh
+
+recho aaa$'\177'bbb
+recho ccc""ddd
+recho "eeefff"
+recho ggg"$(echo $'\177')"hhh
diff --git a/tests/jobs.right b/tests/jobs.right
index 3ec1bbe..0a6fce9 100644
--- a/tests/jobs.right
+++ b/tests/jobs.right
@@ -56,7 +56,7 @@ fg-bg 6
./jobs.tests: line 95: fg: -s: invalid option
fg: usage: fg [job_spec]
./jobs.tests: line 96: bg: -s: invalid option
-bg: usage: bg [job_spec]
+bg: usage: bg [job_spec ...]
./jobs.tests: line 101: disown: -s: invalid option
disown: usage: disown [-h] [-ar] [jobspec ...]
./jobs.tests: line 105: disown: %1: no such job
diff --git a/tests/jobs4.sub b/tests/jobs4.sub
index 51980d1..2eb4197 100644
--- a/tests/jobs4.sub
+++ b/tests/jobs4.sub
@@ -18,5 +18,7 @@ echo $?
wait
-cat &
+# the sleep is intended to give the kill time to execute before the job
+# exits
+(sleep 1 ; cat ) &
kill -1 %% && echo i killed it || echo could not kill it
diff --git a/tests/more-exp.right b/tests/more-exp.right
index a985856..91a375c 100644
--- a/tests/more-exp.right
+++ b/tests/more-exp.right
@@ -28,7 +28,7 @@ argv[3] = <d>
argv[4] = <e>
argv[5] = <f>
argv[1] = </usr/homes/chet>
-argv[1] = </usr/homes/chet>
+argv[1] = <~>
argv[1] = <~>
argv[1] = <\~>
argv[1] = <\ \~>
@@ -108,7 +108,7 @@ argv[3] = <c>
argv[4] = <d>
argv[5] = <e>
argv[6] = <f>
-./more-exp.tests: line 269: abc=def: command not found
+./more-exp.tests: line 272: abc=def: command not found
argv[1] = <a b c d e>
argv[1] = <a>
argv[2] = <b>
@@ -184,13 +184,13 @@ argv[1] = <1>
argv[1] = <5>
argv[1] = <5>
argv[1] = <0>
-./more-exp.tests: line 420: ${#:}: bad substitution
-./more-exp.tests: line 422: ${#/}: bad substitution
-./more-exp.tests: line 424: ${#%}: bad substitution
-./more-exp.tests: line 426: ${#=}: bad substitution
-./more-exp.tests: line 428: ${#+}: bad substitution
-./more-exp.tests: line 430: ${#1xyz}: bad substitution
-./more-exp.tests: line 433: #: %: syntax error: operand expected (error token is "%")
+./more-exp.tests: line 423: ${#:}: bad substitution
+./more-exp.tests: line 425: ${#/}: bad substitution
+./more-exp.tests: line 427: ${#%}: bad substitution
+./more-exp.tests: line 429: ${#=}: bad substitution
+./more-exp.tests: line 431: ${#+}: bad substitution
+./more-exp.tests: line 433: ${#1xyz}: bad substitution
+./more-exp.tests: line 436: #: %: syntax error: operand expected (error token is "%")
argv[1] = <0>
argv[1] = <a+b>
argv[1] = <+>
diff --git a/tests/more-exp.tests b/tests/more-exp.tests
index 6c821a5..4a3cb7f 100644
--- a/tests/more-exp.tests
+++ b/tests/more-exp.tests
@@ -65,7 +65,10 @@ HOME=/usr/homes/chet
somevar=
expect "<$HOME>"
recho ${somevar:-~}
-expect "<$HOME>"
+# This changed after bash-3.0, when the tilde implementation was redone. It's
+# not backward compatible, but it's very hard to be backward-compatible here,
+# and I think the old behavior was a bug
+expect '<~>'
recho "${somevar:-~}"
expect '<~>'
recho "${somevar:-"~"}"
diff --git a/tests/new-exp.right b/tests/new-exp.right
index a2ad16f..8866835 100644
--- a/tests/new-exp.right
+++ b/tests/new-exp.right
@@ -479,4 +479,27 @@ argv[1] = </full/path/to>
argv[1] = </>
argv[1] = <full/path/to/x16>
argv[1] = <x16>
-./new-exp.tests: line 545: ABXD: parameter unset
+two
+one
+ne
+one
+
+one
+one
+one
+1 2 3 4 5 6 7 8 9
+9
+9
+0
+9
+8 9
+123456789
+9
+9
+h
+h
+--blah
+--blah
+lah
+lah
+./new-exp.tests: line 558: ABXD: parameter unset
diff --git a/tests/new-exp.tests b/tests/new-exp.tests
index 5d806d6..e0c2702 100644
--- a/tests/new-exp.tests
+++ b/tests/new-exp.tests
@@ -540,6 +540,19 @@ 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##?}
+
# this must be last!
expect $0: 'ABXD: parameter unset'
recho ${ABXD:?"parameter unset"}
diff --git a/tests/new-exp5.sub b/tests/new-exp5.sub
new file mode 100644
index 0000000..9b3e1b3
--- /dev/null
+++ b/tests/new-exp5.sub
@@ -0,0 +1,30 @@
+x=(one two)
+echo ${x[@]:1}
+echo ${x[@]:0:1}
+
+x=(one)
+echo ${x[0]:1}
+echo ${x[0]:0}
+echo ${x[@]:1}
+echo ${x[@]:0}
+
+echo ${x[@]: -1}
+echo ${x[@]: ${#x[@]}-1}
+
+x=(0 1 2 3 4 5 6 7 8 9)
+echo ${x[@]:1}
+
+echo ${x[@]: -1}
+echo ${x[@]: ${#x[@]}-1}
+
+set -- ${x[@]}
+
+echo $1
+echo ${@: -1}
+echo ${@: $#-1}
+
+a=0123456789
+
+echo ${a:1}
+echo ${a: -1}
+echo ${a: ${#a}-1}
diff --git a/tests/nquote.right b/tests/nquote.right
index 35bf191..904467b 100644
--- a/tests/nquote.right
+++ b/tests/nquote.right
@@ -20,3 +20,13 @@ ok
'abcd'
\'abcd\'
\'abcd\'
+argv[1] = <A\CB>
+argv[1] = <A\CB>
+argv[1] = <ab$cde>
+A\CB
+A\CB
+A\CB
+argv[1] = <hello, $"world">
+argv[1] = <hello, \$"world">
+argv[1] = <hello, $"world">
+argv[1] = <hello, $world>
diff --git a/tests/nquote.tests b/tests/nquote.tests
index 05709f4..b25fbe3 100644
--- a/tests/nquote.tests
+++ b/tests/nquote.tests
@@ -77,4 +77,26 @@ printf "\'abcd\'\n"
echo -e "\'abcd\'"
echo -e "\\'abcd\\'"
+# and what do we do about unrecognized escape sequences?
+shopt -s xpg_echo
+
+recho $'A\CB'
+
+recho "A\CB"
+
+cde=c
+recho $'ab$cde'
+
+printf "%b\n" 'A\CB'
+printf 'A\CB\n'
+
+echo 'A\CB'
+
+world=chet
+
+recho $'hello, $"world"'
+recho $'hello, \$"world"'
+recho $'hello, $\"world"'
+
+recho "hello, $"world""
diff --git a/tests/printf.right b/tests/printf.right
index 4d1647d..656b198 100644
--- a/tests/printf.right
+++ b/tests/printf.right
Binary files differ
diff --git a/tests/printf.tests b/tests/printf.tests
index d9bc30c..9cd7302 100644
--- a/tests/printf.tests
+++ b/tests/printf.tests
@@ -9,6 +9,13 @@ printf --
printf ""
printf -- ""
+# in the future this may mean to put the output into VAR, but for
+# now it is an error
+# 2005-03-15 no longer an error
+unset var
+printf -v var "%10d" $RANDOM
+echo ${#var}
+
# this should expand escape sequences in the format string, nothing else
printf "\tone\n"
@@ -196,10 +203,6 @@ printf "%d\n" 26
# happily ignore overflow conditions in strtol(3)
#printf "%ld\n" 4294967296
-# in the future this may mean to put the output into VAR, but for
-# now it is an error
-printf -v var "%10d" $RANDOM
-
printf "%10"
printf "ab%Mcd\n"
@@ -220,6 +223,11 @@ printf '(%*b)(%*s)\n' -4 foo -4 bar
format='%'`printf '%0100384d' 0`'d\n'
printf $format 0
+# failures in all bash versions through bash-3.0 - undercounted characters
+unset vv
+printf " %s %s %s \n%n" ab cd ef vv
+echo "$vv"
+
# this doesn't work with printf(3) on all systems
#printf "%'s\n" foo
diff --git a/tests/read.right b/tests/read.right
index c388294..8f0b2bf 100644
--- a/tests/read.right
+++ b/tests/read.right
@@ -1,6 +1,6 @@
a.
-a-b-
--a-b-
+-a-b -
-a b-
-a b-
-a-b\-
@@ -51,8 +51,7 @@ echo "$var"
done 3<$0
argv[1] = <>
argv[1] = <>
-argv[1] = <:>
-argv[1] = <:>
+argv[1] = <>
FOO
argv[1] = <>
argv[1] = <3>
diff --git a/tests/redir.right b/tests/redir.right
index 54b05f8..68bea52 100644
--- a/tests/redir.right
+++ b/tests/redir.right
@@ -94,3 +94,9 @@ after read
0
0
0
+before block
+after block
+c1 is 1
+c2 is 2
+c3 is 3
+c4 is 4
diff --git a/tests/redir.tests b/tests/redir.tests
index 19cf9a1..2669cd4 100644
--- a/tests/redir.tests
+++ b/tests/redir.tests
@@ -156,3 +156,19 @@ ${THIS_SH} ./redir5.sub
# test behavior after a write error with a builtin command
${THIS_SH} ./redir6.sub
+
+# problem with redirections using fds bash uses internally
+: ${TMPDIR:=/tmp}
+
+trap 'rm -f $TMPDIR/bash-redir-$$' 0 1 2 3 6 15
+
+echo before block
+{
+ echo before redir
+ exec 10>&1
+ echo after redir
+} > $TMPDIR/bash-redir-$$
+
+echo after block
+
+${THIS_SH} ./redir7.sub
diff --git a/tests/redir7.sub b/tests/redir7.sub
new file mode 100644
index 0000000..3fd371c
--- /dev/null
+++ b/tests/redir7.sub
@@ -0,0 +1,69 @@
+# weird redirections that caused trouble and were fixed in post-3.0 bash
+stuff()
+{
+ c=1
+ ( sleep 5 < /dev/null >/dev/null 2>&1 & ) &
+}
+
+exec 3>&1
+eval `
+exec 4>&1 >&3 3>&-
+{
+ stuff 4>&-
+ echo "c=$c" >&4
+}`
+echo c1 is $c
+
+unset -f stuff
+
+stuff()
+{
+ c=2
+ ( sleep 5 < /dev/null >/dev/null 2>&1 & )
+}
+
+exec 3>&1
+eval `
+exec 4>&1 >&3 3>&-
+{
+ stuff 4>&-
+ echo "c=$c" >&4
+}`
+echo c2 is $c
+
+unset -f stuff
+
+stuff()
+{
+ c=3
+ { sleep 5 < /dev/null >/dev/null 2>&1 & } &
+}
+
+exec 3>&1
+eval `
+exec 4>&1 >&3 3>&-
+{
+ stuff 4>&-
+ echo "c=$c" >&4
+}`
+echo c3 is $c
+
+unset -f stuff
+
+stuff()
+{
+ c=4
+ { sleep 5 < /dev/null >/dev/null 2>&1 & }
+}
+
+exec 3>&1
+eval `
+exec 4>&1 >&3 3>&-
+{
+ stuff 4>&-
+ echo "c=$c" >&4
+}`
+echo c4 is $c
+
+# fixed in bash-3.1
+echo 'exec <&3' | ${THIS_SH} 3<&0
diff --git a/tests/rhs-exp.right b/tests/rhs-exp.right
index 87b9e43..c5dca42 100644
--- a/tests/rhs-exp.right
+++ b/tests/rhs-exp.right
@@ -66,3 +66,9 @@ argv[3] = <-DSELECT_VECS='>
argv[1] = <TDEFAULTS>
argv[2] = <=>
argv[3] = <-DSELECT_VECS=\'>
+a*b
+ab
+a?b
+ab
+a/b
+ab
diff --git a/tests/rhs-exp.tests b/tests/rhs-exp.tests
index 9aecb82..d457198 100644
--- a/tests/rhs-exp.tests
+++ b/tests/rhs-exp.tests
@@ -36,3 +36,14 @@ recho TDEFAULTS = ${selvecs:+-DSELECT_VECS="\\"}
recho TDEFAULTS = ${selvecs:+-DSELECT_VECS=\\}
recho TDEFAULTS = ${selvecs:+-DSELECT_VECS=\'}
recho TDEFAULTS = ${selvecs:+-DSELECT_VECS="\'"}
+
+# more tests for bash-3.0 behavior
+
+var="a*b" ; echo "${var//\\*/}"
+var="a*b" ; echo "${var//\*/}"
+
+var="a?b" ; echo "${var//\\?/}"
+var="a?b" ; echo "${var//\?/}"
+
+var="a/b" ; echo "${var//\\//}"
+var="a/b" ; echo "${var//\//}"
diff --git a/tests/run-appendop b/tests/run-appendop
new file mode 100644
index 0000000..c5bffbc
--- /dev/null
+++ b/tests/run-appendop
@@ -0,0 +1,2 @@
+${THIS_SH} ./appendop.tests > /tmp/xx 2>&1
+diff /tmp/xx appendop.right && rm -f /tmp/xx
diff --git a/tests/run-extglob3 b/tests/run-extglob3
new file mode 100644
index 0000000..2675196
--- /dev/null
+++ b/tests/run-extglob3
@@ -0,0 +1,4 @@
+PATH=$PATH:`pwd`
+export PATH
+${THIS_SH} ./extglob3.tests > /tmp/xx
+diff /tmp/xx extglob3.right && rm -f /tmp/xx
diff --git a/tests/run-ifs-posix b/tests/run-ifs-posix
new file mode 100644
index 0000000..e578e8d
--- /dev/null
+++ b/tests/run-ifs-posix
@@ -0,0 +1,2 @@
+${THIS_SH} ./ifs-posix.tests > /tmp/xx 2>&1
+diff /tmp/xx ifs-posix.right && rm -f /tmp/xx
diff --git a/tests/run-intl b/tests/run-intl
new file mode 100644
index 0000000..6a9234a
--- /dev/null
+++ b/tests/run-intl
@@ -0,0 +1,8 @@
+# See whether or not we can use `diff -a'
+( diff -a ./intl.right ./intl.right >/dev/null 2>&1 ) && AFLAG=-a
+
+echo "warning: some of these tests will fail if you do not have UTF-8" >&2
+echo "warning: locales installed on your system." >&2
+echo "warning: please ignore any differences consisting only of white space" >&2
+${THIS_SH} ./intl.tests > /tmp/xx
+diff $AFLAG /tmp/xx intl.right && rm -f /tmp/xx
diff --git a/tests/run-iquote b/tests/run-iquote
new file mode 100644
index 0000000..61a8aa7
--- /dev/null
+++ b/tests/run-iquote
@@ -0,0 +1,2 @@
+${THIS_SH} ./iquote.tests >/tmp/xx 2>&1
+diff /tmp/xx iquote.right && rm -f /tmp/xx
diff --git a/tests/run-minimal b/tests/run-minimal
index 3014181..5c5dcc4 100644
--- a/tests/run-minimal
+++ b/tests/run-minimal
@@ -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-posix2|run-posixpat) echo $x ; sh $x ;;
+ run-ifs-0posix|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
diff --git a/tests/run-nquote4 b/tests/run-nquote4
index 006872c..f7d05bb 100644
--- a/tests/run-nquote4
+++ b/tests/run-nquote4
@@ -1,2 +1,4 @@
-${THIS_SH} ./nquote.tests 2>&1 | grep -v '^expect' > /tmp/xx
-diff /tmp/xx nquote.right && rm -f /tmp/xx
+echo warning: some of these tests will fail if you do not have UTF-8 >&2
+echo warning: locales installed on your system
+${THIS_SH} ./nquote4.tests 2>&1 | grep -v '^expect' > /tmp/xx
+diff /tmp/xx nquote4.right && rm -f /tmp/xx
diff --git a/tests/run-read b/tests/run-read
index b7a4268..47e4188 100644
--- a/tests/run-read
+++ b/tests/run-read
@@ -1,4 +1,4 @@
-echo "warning: different versions of wc put differing amounts of whitespace" >&2
-echo "warning: before their output. Please do not consider this an error." >&2
+echo "warning: please do not consider output differing only in the amount of" >&2
+echo "warning: white space to be an error." >&2
${THIS_SH} ./read.tests > /tmp/xx 2>&1
diff /tmp/xx read.right && rm -f /tmp/xx
diff --git a/tests/run-tilde b/tests/run-tilde
index ecb7e9a..b8569c1 100644
--- a/tests/run-tilde
+++ b/tests/run-tilde
@@ -1,2 +1,2 @@
-${THIS_SH} ./tilde-tests > /tmp/xx
+${THIS_SH} ./tilde.tests > /tmp/xx
diff /tmp/xx tilde.right && rm -f /tmp/xx
diff --git a/tests/run-tilde2 b/tests/run-tilde2
new file mode 100644
index 0000000..4446989
--- /dev/null
+++ b/tests/run-tilde2
@@ -0,0 +1,2 @@
+${THIS_SH} ./tilde2.tests > /tmp/xx
+diff /tmp/xx tilde2.right && rm -f /tmp/xx
diff --git a/tests/shopt.right b/tests/shopt.right
index 605a8f0..b2fc219 100644
--- a/tests/shopt.right
+++ b/tests/shopt.right
@@ -15,8 +15,8 @@ shopt -s extquote
shopt -u failglob
shopt -s force_fignore
shopt -u gnu_errfmt
-shopt -u histreedit
shopt -u histappend
+shopt -u histreedit
shopt -u histverify
shopt -s hostcomplete
shopt -u huponexit
@@ -26,6 +26,7 @@ shopt -u login_shell
shopt -u mailwarn
shopt -u no_empty_cmd_completion
shopt -u nocaseglob
+shopt -u nocasematch
shopt -u nullglob
shopt -s progcomp
shopt -s promptvars
@@ -58,8 +59,8 @@ shopt -u extdebug
shopt -u extglob
shopt -u failglob
shopt -u gnu_errfmt
-shopt -u histreedit
shopt -u histappend
+shopt -u histreedit
shopt -u histverify
shopt -u huponexit
shopt -u lithist
@@ -67,6 +68,7 @@ shopt -u login_shell
shopt -u mailwarn
shopt -u no_empty_cmd_completion
shopt -u nocaseglob
+shopt -u nocasematch
shopt -u nullglob
shopt -u restricted_shell
shopt -u shift_verbose
@@ -81,8 +83,8 @@ extdebug off
extglob off
failglob off
gnu_errfmt off
-histreedit off
histappend off
+histreedit off
histverify off
huponexit off
lithist off
@@ -90,6 +92,7 @@ login_shell off
mailwarn off
no_empty_cmd_completion off
nocaseglob off
+nocasematch off
nullglob off
restricted_shell off
shift_verbose off
diff --git a/tests/tilde-tests b/tests/tilde.tests
index f5f5309..f5f5309 100644
--- a/tests/tilde-tests
+++ b/tests/tilde.tests
diff --git a/tests/tilde2.right b/tests/tilde2.right
new file mode 100644
index 0000000..fce0468
--- /dev/null
+++ b/tests/tilde2.right
@@ -0,0 +1,24 @@
+PATH=~/bin:/bin:/usr/bin:.
+/usr/xyz/bin:~/bin2:/bin:/usr/bin:.
+PATH=~/bin:~/bin2:/bin:/usr/bin:.
+~/bin
+~
+/usr/xyz
+~
+~
+~
+argv[1] = <\a>
+argv[1] = <\a>
+/usr/xyz/bash
+ok
+~
+~
+make -k FOO=/usr/xyz/mumble
+/usr/xyz/mumble
+HOME=~
+HOME=~
+/usr/$x/abc
+HOME=~
+/usr/$x/abc
+HOME=/usr/$x/abc
+/usr/$x/abc
diff --git a/tests/tilde2.tests b/tests/tilde2.tests
new file mode 100644
index 0000000..ff6c76f
--- /dev/null
+++ b/tests/tilde2.tests
@@ -0,0 +1,70 @@
+HOME=/usr/xyz
+XPATH=/bin:/usr/bin:.
+
+ADDPATH=PATH=~/bin:$XPATH
+
+echo $ADDPATH
+
+unset ADDPATH
+: ${ADDPATH:=~/bin:~/bin2:$XPATH}
+echo $ADDPATH
+
+unset ADDPATH
+: ${ADDPATH:=PATH=~/bin:~/bin2:$XPATH}
+echo $ADDPATH
+
+cat << !
+~/bin
+!
+
+echo "~"
+
+echo ${TPATH:-~}
+echo "${TPATH:-~}"
+echo "${TPATH:-"~"}"
+
+echo "${XPATH+~}"
+
+recho "\a"
+recho "${TPATH:-\a}"
+
+SHELL=~/bash
+echo $SHELL
+
+case $SHELL in
+~/bash) echo ok;;
+*) echo bad;;
+esac
+
+somevar=
+echo "${somevar:-~}"
+echo "${somevar:-"~"}"
+
+echo make -k FOO=~/mumble
+
+typeset FOO=~/mumble
+echo "$FOO"
+
+h=HOME=~
+echo $h
+
+export h=HOME=~
+echo $h
+
+x=1234
+HOME='/usr/$x/abc'
+
+echo ~
+
+# behavior differs here in posix mode
+set -o posix
+
+eval echo $h
+eval $h
+echo $HOME
+
+set +o posix
+
+eval echo $h
+eval $h
+echo $HOME
diff --git a/tests/type.right b/tests/type.right
index 853c33b..dbd51ca 100644
--- a/tests/type.right
+++ b/tests/type.right
@@ -1,7 +1,6 @@
./type.tests: line 9: type: -r: invalid option
type: usage: type [-afptP] name [name ...]
./type.tests: line 12: type: notthere: not found
-./type.tests: line 13: command: notthere: not found
function
keyword
builtin
@@ -25,8 +24,7 @@ func ()
}
while
while is a shell keyword
-./type.tests: line 42: type: m: not found
-./type.tests: line 43: command: m: not found
+./type.tests: line 43: type: m: not found
alias m='more'
alias m='more'
m is aliased to `more'
@@ -39,8 +37,8 @@ builtin
builtin is a shell builtin
/bin/sh
/bin/sh is /bin/sh
-./type.tests: line 64: type: func: not found
-./type.tests: line 66: type: m: not found
+./type.tests: line 65: type: func: not found
+./type.tests: line 67: type: m: not found
/bin/sh
/tmp/bash
bash is hashed (/tmp/bash)
diff --git a/tests/type.tests b/tests/type.tests
index 7307c86..d47ae64 100644
--- a/tests/type.tests
+++ b/tests/type.tests
@@ -36,7 +36,8 @@ command -V func
command -v while
command -V while
-# the following three lines should produce the same output
+# the following two lines should produce the same output
+# post-3.0 patch makes command -v silent, as posix specifies
# first test with alias expansion off (should all fail or produce no output)
type -t m
type m
diff --git a/tests/varenv.right b/tests/varenv.right
index c458b18..df8086d 100644
--- a/tests/varenv.right
+++ b/tests/varenv.right
@@ -51,3 +51,6 @@ after fff3: x=4
|0|12|
|y|
|y|
+a=z
+a=b
+a=z
diff --git a/tests/varenv.sh b/tests/varenv.sh
index d6d763d..77776f9 100644
--- a/tests/varenv.sh
+++ b/tests/varenv.sh
@@ -201,3 +201,6 @@ $THIS_SH ./varenv1.sub
# more tests; bugs in bash up to version 2.05a
$THIS_SH ./varenv2.sub
+
+# make sure variable scoping is done right
+tt() { typeset a=b;echo a=$a; };a=z;echo a=$a;tt;echo a=$a