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

This commit is contained in:
Jari Aalto 2005-12-07 14:08:12 +00:00
commit 95732b497d
267 changed files with 24541 additions and 18843 deletions

18
tests/appendop.right Normal file
View file

@ -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

83
tests/appendop.tests Normal file
View file

@ -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

View file

@ -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;

View file

@ -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

View file

@ -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}

1
tests/array1.sub Normal file
View file

@ -0,0 +1 @@
printf "%s\n" -a a=(a 'b c')

1
tests/array2.sub Normal file
View file

@ -0,0 +1 @@
declare -a ''=(a 'b c')

9
tests/array3.sub Normal file
View file

@ -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}

View file

@ -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}

View file

@ -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}

View file

@ -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

View file

@ -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.

View file

@ -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

26
tests/dollar-star2.sub Normal file
View file

@ -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 "$*"

View file

@ -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>

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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//\?/ }

View file

@ -143,3 +143,5 @@ argv[2] = <b>
argv[3] = <c>
argv[4] = <d>
argv[5] = <e>
a?b?c
a b c

View file

@ -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>

View file

@ -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

27
tests/extglob3.right Normal file
View file

@ -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

56
tests/extglob3.tests Normal file
View file

@ -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

View file

@ -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

View file

@ -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
")'

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

1
tests/ifs-posix.right Normal file
View file

@ -0,0 +1 @@
# tests 6856 passed 6856 failed 0

257
tests/ifs-posix.tests Normal file
View file

@ -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"

10
tests/intl.right Normal file
View file

@ -0,0 +1,10 @@
é
1
AéB
B
B
ok 1
ok 2
aéb
0000000 141 303 251 142
0000004

38
tests/intl.tests Normal file
View file

@ -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

61
tests/iquote.right Normal file
View file

@ -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>

143
tests/iquote.tests Normal file
View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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] = <+>

View file

@ -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:-"~"}"

View file

@ -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

View file

@ -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"}

30
tests/new-exp5.sub Normal file
View file

@ -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}

View file

@ -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>

View file

@ -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""

Binary file not shown.

View file

@ -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

View file

@ -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>

View file

@ -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

View file

@ -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

69
tests/redir7.sub Normal file
View file

@ -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

View file

@ -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

View file

@ -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//\//}"

2
tests/run-appendop Normal file
View file

@ -0,0 +1,2 @@
${THIS_SH} ./appendop.tests > /tmp/xx 2>&1
diff /tmp/xx appendop.right && rm -f /tmp/xx

4
tests/run-extglob3 Normal file
View file

@ -0,0 +1,4 @@
PATH=$PATH:`pwd`
export PATH
${THIS_SH} ./extglob3.tests > /tmp/xx
diff /tmp/xx extglob3.right && rm -f /tmp/xx

2
tests/run-ifs-posix Normal file
View file

@ -0,0 +1,2 @@
${THIS_SH} ./ifs-posix.tests > /tmp/xx 2>&1
diff /tmp/xx ifs-posix.right && rm -f /tmp/xx

8
tests/run-intl Normal file
View file

@ -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

2
tests/run-iquote Normal file
View file

@ -0,0 +1,2 @@
${THIS_SH} ./iquote.tests >/tmp/xx 2>&1
diff /tmp/xx iquote.right && rm -f /tmp/xx

View file

@ -27,7 +27,7 @@ do
*.orig|*~) ;;
run-dollars|run-execscript|run-func|run-getopts|run-heredoc) echo $x ; sh $x ;;
run-ifs-tests|run-input-test|run-invert|run-more-exp|run-nquote) echo $x ; sh $x ;;
run-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

View file

@ -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

View file

@ -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

View file

@ -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

2
tests/run-tilde2 Normal file
View file

@ -0,0 +1,2 @@
${THIS_SH} ./tilde2.tests > /tmp/xx
diff /tmp/xx tilde2.right && rm -f /tmp/xx

View file

@ -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

24
tests/tilde2.right Normal file
View file

@ -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

70
tests/tilde2.tests Normal file
View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -51,3 +51,6 @@ after fff3: x=4
|0|12|
|y|
|y|
a=z
a=b
a=z

View file

@ -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