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

This commit is contained in:
Jari Aalto
2009-09-12 16:46:49 +00:00
parent 726f63884d
commit ccc6cda312
502 changed files with 91975 additions and 69110 deletions
+91
View File
@@ -0,0 +1,91 @@
163
166
4
16
8
2
4
2
2
1
0
0
0
1
1
2
-3
-2
1
0
2
131072
29
33
49
1
1
0
0
1
1
1
2
3
1
58
2
60
1
256
16
62
4
29
5
-4
4
1
32
32
1
1
32
20
1,i+=2
30
1,j+=2
20
1,i+=2
30
1,j+=2
./arith.tests: 1 ? 20 : x+=2: attempted assignment to non-variable (error token is "+=2")
20
6
6,5,3
263
255
255
127
36
40
10
10
10
10
10
10
36
36
62
63
./arith.tests: 3425#56: illegal arithmetic base (error token is "3425#56")
0
./arith.tests: 7 = 43 : attempted assignment to non-variable (error token is "= 43 ")
./arith.tests: 2#44: value too great for base (error token is "2#44")
./arith.tests: 44 / 0 : division by 0 (error token is " ")
./arith.tests: let: jv += $iv: syntax error: operand expected (error token is "$iv")
./arith.tests: jv += $iv : syntax error: operand expected (error token is "$iv ")
./arith.tests: let: rv = 7 + (43 * 6: missing `)' (error token is "6")
./arith.tests: 0#4: bad number (error token is "0#4")
./arith.tests: 2#110#11: bad number (error token is "2#110#11")
+158
View File
@@ -0,0 +1,158 @@
declare -i iv jv
iv=$(( 3 + 5 * 32 ))
echo $iv
iv=iv+3
echo $iv
iv=2
jv=iv
let "jv *= 2"
echo $jv
jv=$(( $jv << 2 ))
echo $jv
let jv="$jv / 2"
echo $jv
jv="jv >> 2"
echo $jv
iv=$((iv+ $jv))
echo $iv
echo $((iv -= jv))
echo $iv
echo $(( iv == jv ))
echo $(( iv != $jv ))
echo $(( iv < jv ))
echo $(( $iv > $jv ))
echo $(( iv <= $jv ))
echo $(( $iv >= jv ))
echo $jv
echo $(( ~$jv ))
echo $(( ~1 ))
echo $(( ! 0 ))
echo $(( jv % 2 ))
echo $(( $iv % 4 ))
echo $(( iv <<= 16 ))
echo $(( iv %= 33 ))
echo $(( 33 & 55 ))
echo $(( 33 | 17 ))
echo $(( iv && $jv ))
echo $(( $iv || jv ))
echo $(( iv && 0 ))
echo $(( iv & 0 ))
echo $(( iv && 1 ))
echo $(( iv & 1 ))
echo $(( $jv || 0 ))
echo $(( jv | 0 ))
echo $(( jv | 1 ))
echo $(( $jv || 1 ))
let 'iv *= jv'
echo $iv
echo $jv
let "jv += $iv"
echo $jv
echo $(( jv /= iv ))
echo $(( jv <<= 8 ))
echo $(( jv >>= 4 ))
echo $(( iv |= 4 ))
echo $(( iv &= 4 ))
echo $(( iv += (jv + 9)))
echo $(( (iv + 4) % 7 ))
# unary plus, minus
echo $(( +4 - 8 ))
echo $(( -4 + 8 ))
# conditional expressions
echo $(( 4<5 ? 1 : 32))
echo $(( 4>5 ? 1 : 32))
echo $(( 4>(2+3) ? 1 : 32))
echo $(( 4<(2+3) ? 1 : 32))
echo $(( (2+2)<(2+3) ? 1 : 32))
echo $(( (2+2)>(2+3) ? 1 : 32))
# check that the unevaluated part of the ternary operator does not do
# evaluation or assignment
x=i+=2
y=j+=2
declare -i i=1 j=1
echo $((1 ? 20 : (x+=2)))
echo $i,$x
echo $((0 ? (y+=2) : 30))
echo $j,$y
x=i+=2
y=j+=2
declare -i i=1 j=1
echo $((1 ? 20 : (x+=2)))
echo $i,$x
echo $((0 ? (y+=2) : 30))
echo $i,$y
# check precedence of assignment vs. conditional operator
# should be an error
declare -i x=2
y=$((1 ? 20 : x+=2))
# check precedence of assignment vs. conditional operator
declare -i x=2
echo $((0 ? x+=2 : 20))
# associativity of assignment-operator operator
declare -i i=1 j=2 k=3
echo $((i += j += k))
echo $i,$j,$k
# octal, hex
echo $(( 0x100 | 007 ))
echo $(( 0xff ))
echo $(( 16#ff ))
echo $(( 16#FF/2 ))
echo $(( 8#44 ))
echo $(( 8 ^ 32 ))
# other bases
echo $(( 16#a ))
echo $(( 32#a ))
echo $(( 56#a ))
echo $(( 64#a ))
echo $(( 16#A ))
echo $(( 32#A ))
echo $(( 56#A ))
echo $(( 64#A ))
echo $(( 64#_ ))
echo $(( 64#@ ))
# weird bases
echo $(( 3425#56 ))
# missing number after base
echo $(( 2# ))
# these should generate errors
echo $(( 7 = 43 ))
echo $(( 2#44 ))
echo $(( 44 / 0 ))
let 'jv += $iv'
echo $(( jv += \$iv ))
let 'rv = 7 + (43 * 6'
# more errors
declare -i i
i=0#4
i=2#110#11
+78
View File
@@ -0,0 +1,78 @@
abcde
abcde bdef
abcde bdef
declare -a DIRSTACK='()'
declare -a a='([0]="abcde" [1]="" [2]="bdef")'
declare -a b='()'
declare -ar c='()'
abcde bdef
abcde bdef
abcde
abcde
abcde
bdef
hello world
11
3
bdef hello world test expression
./array.tests: readonly: `a[5]': not a valid identifier
declare -ar a='([1]="" [2]="bdef" [5]="hello world" [6]="test expression")'
declare -ar c='()'
declare -ar a='([1]="" [2]="bdef" [5]="hello world" [6]="test expression")'
declare -ar c='()'
./array.tests: declare: e: cannot assign to array variables in this way
a test
declare -a DIRSTACK='()'
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='()'
declare -a d='([1]="" [2]="bdef" [5]="hello world" [6]="test" [9]="ninth element")'
declare -a e='([0]="test")'
declare -a f='([0]="" [1]="bdef" [2]="hello world" [3]="test" [4]="ninth element")'
./array.tests: a: readonly variable
./array.tests: b[]: bad array subscript
./array.tests: b[*]: bad array subscript
./array.tests: ${b[ ]}: bad substitution
./array.tests: c[-2]: bad array subscript
./array.tests: c: bad array subscript
./array.tests: d[7]: cannot assign list to array member
./array.tests: []=abcde: bad array subscript
./array.tests: [*]=last: cannot assign to non-numeric index
./array.tests: [-65]=negative: bad array subscript
declare -a DIRSTACK='()'
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='()'
declare -a d='([1]="test test" [2]="bdef" [5]="hello world" [6]="test" [9]="ninth element")'
declare -a f='([0]="" [1]="bdef" [2]="hello world" [3]="test" [4]="ninth element")'
./array.tests: unset: ps1: not an array variable
./array.tests: declare: c: cannot destroy array variables in this way
this of
this is a test of read using arrays
declare -a DIRSTACK='()'
declare -a rv='([0]="this" [1]="is" [2]="a" [3]="test" [4]="of" [5]="read" [6]="using" [7]="arrays")'
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='()'
declare -a d='([1]="test test" [2]="bdef" [5]="hello world" [6]="test" [9]="ninth element")'
declare -a f='([0]="" [1]="bdef" [2]="hello world" [3]="test" [4]="ninth element")'
abde
abde
bbb
efgh
wxyz
wxyz
./array.tests
a
b c
d
e f g
h
./array.tests
a
b c
d
e f g
h
+131
View File
@@ -0,0 +1,131 @@
set +a
# The calls to egrep -v are to filter out builtin array variables that are
# automatically set and possibly contain values that vary.
unset a
a=abcde
a[2]=bdef
declare -a b[256]
unset c[2]
unset c[*]
a[1]=
_ENV=/bin/true
x=${_ENV[(_$-=0)+(_=1)-_${-%%*i*}]}
declare -r c[100]
echo ${a[0]} ${a[4]}
echo ${a[@]}
echo ${a[*]}
# this should print out values, too
declare -a | egrep -v '(BASH_VERSINFO|PIPESTATUS)'
unset a[7]
echo ${a[*]}
unset a[4]
echo ${a[*]}
echo ${a}
echo "${a}"
echo $a
unset a[0]
echo ${a}
echo ${a[@]}
a[5]="hello world"
echo ${a[5]}
echo ${#a[5]}
echo ${#a[@]}
a[4+5/2]="test expression"
echo ${a[@]}
readonly a[5]
readonly a
readonly -a | egrep -v '(BASH_VERSINFO|PIPESTATUS)'
declare -ar | egrep -v '(BASH_VERSINFO|PIPESTATUS)'
declare -a d='([1]="" [2]="bdef" [5]="hello world" "test")'
d[9]="ninth element"
declare -a e[10]=test
declare -a e[10]='(test)'
pass=/etc/passwd
declare -a f='("${d[@]}")'
b=([0]=this [1]=is [2]=a [3]=test [4]="$PS1" [5]=$pass)
echo ${b[@]:2:3}
declare -a | egrep -v '(BASH_VERSINFO|PIPESTATUS)'
a[3]="this is a test"
b[]=bcde
b[*]=aaa
echo ${b[ ]}
c[-2]=4
echo ${c[-4]}
d[7]=(abdedfegeee)
d=([]=abcde [1]="test test" [*]=last [-65]=negative )
unset d[12]
unset e[*]
declare -a | egrep -v '(BASH_VERSINFO|PIPESTATUS)'
ps1='hello'
unset ps1[2]
unset ${ps1[2]}
declare +a ps1
declare +a c
# the prompt should not print when using a here doc
read -p "array test: " -a rv <<!
this is a test of read using arrays
!
echo ${rv[0]} ${rv[4]}
echo ${rv[@]}
declare -a | egrep -v '(BASH_VERSINFO|PIPESTATUS)'
export rv
#set
x[4]=bbb
x=abde
echo $x
echo ${x[0]}
echo ${x[4]}
echo efgh | ( read x[1] ; echo ${x[1]} )
echo wxyz | ( declare -a x ; read x ; echo $x ; echo ${x[0]} )
# Make sure that arrays can be used to save the positional paramters verbatim
set -- a 'b c' d 'e f g' h
ARGV=( [0]=$0 "$@" )
for z in "${ARGV[@]}"
do
echo "$z"
done
echo "$0"
for z in "$@"
do
echo "$z"
done
+20
View File
@@ -0,0 +1,20 @@
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
+16
View File
@@ -0,0 +1,16 @@
ffc ffb ffa
fdg feg ffg
lxyz nxyz mxyz
{abc,def}
{abc}
{a,b,c,d,e}
x} y} {a} b} c}
x,y {abc} trie
/usr/ucb/ex /usr/ucb/edit /usr/lib/ex /usr/lib/how_ex
XXXX{a,b,c}
XXXXa XXXXb XXXXc
{}
{ }
}
{
abcd{efgh
+18 -2
View File
@@ -163,14 +163,24 @@ expect '<^A^A^B>'
recho ''
# More tests of "$@"
set abc def ghi jkl
expect '< abc> <def> <ghi> <jkl >'
set abc def ghi jkl
recho " $@ "
expect '< abc> <def> <ghi> <jkl >'
recho "${1+ $@ }"
expect '<--abc> <def> <ghi> <jkl-->'
set abc def ghi jkl
expect '<--abc> <def> <ghi> <jkl-->'
recho "--$@--"
set "a b" cd ef gh
expect '<a b> <cd> <ef> <gh>'
recho ${1+"$@"}
expect '<a b> <cd> <ef> <gh>'
recho ${foo:-"$@"}
expect '<a b> <cd> <ef> <gh>'
recho "${@}"
expect '< >'
recho " "
expect '< - >'
@@ -324,3 +334,9 @@ recho '~'
expect nothing
recho $!
# test word splitting of assignment statements not preceding a command
a="a b c d e"
declare b=$a
expect '<a> <b> <c> <d> <e>'
recho $b
+21
View File
@@ -53,10 +53,26 @@ argv[1] = < abc>
argv[2] = <def>
argv[3] = <ghi>
argv[4] = <jkl >
argv[1] = < abc>
argv[2] = <def>
argv[3] = <ghi>
argv[4] = <jkl >
argv[1] = <--abc>
argv[2] = <def>
argv[3] = <ghi>
argv[4] = <jkl-->
argv[1] = <a b>
argv[2] = <cd>
argv[3] = <ef>
argv[4] = <gh>
argv[1] = <a b>
argv[2] = <cd>
argv[3] = <ef>
argv[4] = <gh>
argv[1] = <a b>
argv[2] = <cd>
argv[3] = <ef>
argv[4] = <gh>
argv[1] = < >
argv[1] = < - >
argv[1] = </^root:/{s/^[^:]*:[^:]*:\([^:]*\).*$/\1/>
@@ -111,3 +127,8 @@ argv[1] = <42>
argv[1] = <26>
argv[1] = <\>
argv[1] = <~>
argv[1] = <a>
argv[2] = <b>
argv[3] = <c>
argv[4] = <d>
argv[5] = <e>
+109 -4
View File
@@ -7,9 +7,9 @@ expect()
}
TESTDIR=/tmp/glob-test
rm -rf $TESTDIR
mkdir $TESTDIR
builtin cd $TESTDIR
builtin cd $TESTDIR || { echo $0: cannot cd to $TESTDIR >&2 ; exit 1; }
rm -rf *
touch a b c d abc abd abe bb bcd ca cb dd de
mkdir bdir
@@ -22,12 +22,12 @@ expect '<a> <abc> <abd> <abe>'
recho \a*
# see if null glob expansion works
allow_null_glob_expansion=
shopt -s nullglob
expect '<a> <abc> <abd> <abe>'
recho a* X*
unset allow_null_glob_expansion
shopt -u nullglob
# see if the code that expands directories only works
expect '<bdir/>'
@@ -174,6 +174,111 @@ a["\b"]c) echo ok
;;
esac
mkdir man
mkdir man/man1
touch man/man1/bash.1
expect '<man/man1/bash.1>'
recho */man*/bash.*
expect '<man/man1/bash.1>'
recho $(echo */man*/bash.*)
expect '<man/man1/bash.1>'
recho "$(echo */man*/bash.*)"
# tests with multiple `*'s
case abc in
a***c) echo ok 1;;
esac
case abc in
a*****?c) echo ok 2;;
esac
case abc in
?*****??) echo ok 3;;
esac
case abc in
*****??) echo ok 4;;
esac
case abc in
*****??c) echo ok 5;;
esac
case abc in
?*****?c) echo ok 6;;
esac
case abc in
?***?****c) echo ok 7;;
esac
case abc in
?***?****?) echo ok 8;;
esac
case abc in
?***?****) echo ok 9;;
esac
case abc in
*******c) echo ok 10;;
esac
case abc in
*******?) echo ok 11;;
esac
case abcdecdhjk in
a*cd**?**??k) echo ok 20;;
esac
case abcdecdhjk in
a**?**cd**?**??k) echo ok 21;;
esac
case abcdecdhjk in
a**?**cd**?**??k***) echo ok 22;;
esac
case abcdecdhjk in
a**?**cd**?**??***k) echo ok 23;;
esac
case abcdecdhjk in
a**?**cd**?**??***k**) echo ok 24;;
esac
case abcdecdhjk in
a****c**?**??*****) echo ok 25;;
esac
# none of these should output anything
case abc in
??**********?****?) echo bad ;;
esac
case abc in
??**********?****c) echo bad ;;
esac
case abc in
?************c****?****) echo bad;;
esac
case abc in
*c*?**) echo bad;;
esac
case abc in
a*****c*?**) echo bad;;
esac
case abc in
a********???*******) echo bad;;
esac
builtin cd /
rm -rf $TESTDIR
exit 0
+20
View File
@@ -61,3 +61,23 @@ ok
ok
ok
ok
argv[1] = <man/man1/bash.1>
argv[1] = <man/man1/bash.1>
argv[1] = <man/man1/bash.1>
ok 1
ok 2
ok 3
ok 4
ok 5
ok 6
ok 7
ok 8
ok 9
ok 10
ok 11
ok 20
ok 21
ok 22
ok 23
ok 24
ok 25
+12
View File
@@ -0,0 +1,12 @@
there
hi\
there$a
stuff
hi\
there
EO\
F
hi
hi
hi
there
+45
View File
@@ -0,0 +1,45 @@
# check order and content of multiple here docs
cat << EOF1 << EOF2
hi
EOF1
there
EOF2
# check quoted here-doc is protected
a=foo
cat << 'EOF'
hi\
there$a
stuff
EOF
# check that quoted here-documents don't have \newline processing done
cat << 'EOF'
hi\
there
EO\
F
EOF
true
# check that \newline is removed at start of here-doc
cat << EO\
F
hi
EOF
# check that \newline removal works for here-doc delimiter
cat << EOF
hi
EO\
F
# check that end of file delimits a here-document
# THIS MUST BE LAST!
cat << EOF
hi
there
+1 -1
View File
@@ -1,4 +1,4 @@
echo before calling input-line.sub
../bash ./input-line.sub
${THIS_SH} ./input-line.sub
this line for input-line.sub
echo finished with input-line.sub
+2 -2
View File
@@ -1,7 +1,7 @@
echo "Point 1"
exec 3</etc/passwd
exec 4>a
exec 5>b
exec 4>/tmp/a
exec 5>/tmp/b
echo "Point 2"
echo to a 1>&4
echo to b 1>&5
+146
View File
@@ -0,0 +1,146 @@
argv[1] = <aaa bbb ccc>
argv[1] = <aaa bbb ccc>
argv[1] = <baz:bar>
argv[1] = <baz:bar>
argv[1] = <aaa bbb ccc>
argv[1] = <bar>
argv[1] = <bar>
argv[1] = <bar>
argv[1] = <abcde>
argv[1] = <abcde>
argv[1] = <xyz>
argv[1] = <a b>
argv[2] = <c>
argv[3] = <d>
argv[4] = <e>
argv[5] = <f>
argv[1] = <a b>
argv[1] = <a>
argv[2] = <b>
argv[1] = <a b>
argv[2] = <c>
argv[3] = <d>
argv[4] = <e>
argv[5] = <f>
argv[1] = <a b>
argv[2] = <c>
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] = <\ \ \~>
argv[1] = </usr/homes/chet>
argv[1] = </usr/homes/chet>
argv[1] = </usr/homes/chet>
argv[1] = <$HOME>
argv[1] = <\ $HOME>
argv[1] = <\ \ $HOME>
argv[1] = <'bar'>
argv[1] = <'bar'>
argv[1] = <*@*>
argv[1] = <*@*>
argv[1] = <*@>
argv[1] = <*@>
argv[1] = <*@*>
argv[1] = <*@*>
argv[1] = <*@*>
argv[1] = <*@*>
argv[1] = <abcd>
argv[1] = <efghijkl>
argv[1] = <4>
argv[2] = <2>
argv[1] = <1>
argv[1] = <bar>
argv[1] = <2>
argv[1] = <bar>
argv[1] = <2>
argv[1] = <4>
argv[1] = <--\>
argv[2] = <-->
argv[1] = <--\^J-->
argv[1] = <--+\>
argv[2] = <+-->
argv[1] = <--+\^J+-->
argv[1] = <-+\>
argv[2] = <+-\>
argv[3] = <->
argv[1] = <xy>
argv[1] = <xy>
argv[1] = <xy>
argv[1] = <>
argv[1] = <>
argv[1] = <x>
argv[1] = <x>
argv[1] = <>
argv[1] = <x>
argv[1] = <x>
argv[1] = <x>
argv[1] = <x>
argv[1] = <^?>
argv[1] = <^?>
argv[1] = <x>
argv[1] = <x>
argv[1] = <>
argv[2] = <abd>
argv[3] = <x>
argv[1] = <>
argv[2] = <abd>
argv[3] = <>
argv[1] = <a,b,c,d,e,f>
argv[1] = <a>
argv[2] = <b>
argv[3] = <c>
argv[4] = <d>
argv[5] = <e>
argv[6] = <f>
./more-exp.tests: abc=def: command not found
argv[1] = <a b c d e>
argv[1] = <a>
argv[2] = <b>
argv[3] = <c>
argv[4] = <d>
argv[5] = <e>
argv[1] = <foo)>
argv[1] = <a>
argv[1] = <\a>
argv[1] = <\a>
argv[1] = <\a>
argv[1] = <\a>
argv[1] = <\\a>
argv[1] = <a>
argv[1] = <\a>
argv[1] = <\a>
argv[1] = <\a>
argv[1] = <\a>
argv[1] = <\\a>
argv[1] = <a>
argv[1] = <a>
argv[1] = <\a>
argv[1] = <\a>
argv[1] = <\a>
argv[1] = <\a>
argv[1] = <$a>
argv[1] = <\foo>
argv[1] = <$a>
argv[1] = <\foo>
argv[1] = <\$a>
argv[1] = <\\$a>
argv[1] = <a>
argv[1] = <a>
argv[1] = <\a>
argv[1] = <\a>
argv[1] = <\a>
argv[1] = <\a>
argv[1] = <G>
argv[2] = <{>
argv[3] = <I>
argv[4] = <K>
argv[5] = <}>
argv[1] = <hi>
argv[2] = <K>
argv[3] = <}>
argv[1] = <a*>
+303
View File
@@ -0,0 +1,303 @@
expect()
{
echo expect "$@"
}
tool_var() {
eval $1=\"\${$1:-$2}\"
export $1
}
A="aaa bbb ccc"
unset B
tool_var B ${B:-"$A"}
expect '<aaa bbb ccc>'
recho "$A"
expect '<aaa bbb ccc>'
recho "$B"
eto_prepend() {
eval $1=\'$2\''${'$1':+":"${'$1'}}'; export $1
}
foo=bar; export foo
eto_prepend foo baz
expect '<baz:bar>'
recho $foo
expect '<baz:bar>'
recho ${foo-"bar"}
aa='aaa bbb ccc'
expect '<aaa bbb ccc>'
recho ${zzz-"$aa"}
expect '<bar>'
recho ${zzz:-"bar"}
expect '<bar>'
recho "${zzz:-bar}"
expect '<bar>'
recho "${zzz:-"bar"}"
var=abcde
expect '<abcde>'
recho "${var:-xyz}"
expect '<abcde>'
recho "${var:=xyz}"
expect '<xyz>'
recho "${var:+xyz}"
set 'a b' c d e f
expect '<a b> <c> <d> <e> <f>'
recho ${1+"$@"}
expect '<a b>'
recho "${1-"$@"}"
expect '<a> <b>'
recho ${1-"$@"}
expect '<a b> <c> <d> <e> <f>'
recho "${1+$@}"
expect '<a b> <c> <d> <e> <f>'
recho "${1+"$@"}"
HOME=/usr/homes/chet
somevar=
expect "<$HOME>"
recho ${somevar:-~}
expect "<$HOME>"
recho "${somevar:-~}"
expect '<~>'
recho "${somevar:-"~"}"
expect '<\~>'
recho "${somevar:-\~}"
expect '<\ \~>'
recho "${somevar:-\ \~}"
expect '<\ \ \~>'
recho "${somevar:-\ \ \~}"
expect "<$HOME>"
recho ${somevar:-$HOME}
expect "<$HOME>"
recho "${somevar:-$HOME}"
expect "<$HOME>"
recho "${somevar:-"$HOME"}"
expect '<$HOME>'
recho "${somevar:-\$HOME}"
expect '<\ $HOME>'
recho "${somevar:-\ \$HOME}"
expect '<\ \ $HOME>'
recho "${somevar:-\ \ \$HOME}"
foo=bar
expect "<'bar'>"
recho "${foo+'$foo'}"
expect "<'bar'>"
recho "${fox='$foo'}"
P='*@*'
expect '<*@*>'
recho "${P%"*"}"
expect '<*@*>'
recho "${P%'*'}"
expect '<*@>'
recho ${P%"*"}
expect '<*@>'
recho ${P%'*'}
expect '<*@*>'
recho ${P%""}
expect '<*@*>'
recho ${P#""}
expect '<*@*>'
recho ${P#"$foobar"}
expect '<*@*>'
recho ${P%"$foobar"}
s1=abcdefghijkl
s2=efgh
first=${s1/$s2*/}
expect '<abcd>'
recho $first
last=${s1##$first}
expect '<efghijkl>'
recho $last
shift $#
UNAME_RELEASE=${1:-4.2MP}
RELEASE=`expr "$UNAME_RELEASE" : '[^0-9]*\([0-9]*\)'` # 4
case "$RELEASE" in
"") RELEASE=0 ;;
*) RELEASE=`expr "$RELEASE" + 0` ;;
esac
REL_LEVEL=`expr "$UNAME_RELEASE" : '[^0-9]*[0-9]*.\([0-9]*\)'` # 1
REL_SUBLEVEL=`expr "$UNAME_RELEASE" : '[^0-9]*[0-9]*.[0-9]*.\([0-9]*\)'` # 2
expect '<4> <2>'
recho $RELEASE $REL_LEVEL $REL_SUBLEVEL
b1()
{
b2 ${1+"$@"}
}
b2()
{
recho $*
recho $#
}
expect '<1>'
b1 ''
expect '<bar> <2>'
b1 bar ''
expect '<bar> <2>'
b1 '' bar
expect '<4>'
b1 '' '' '' ''
NL="\\
"
NNL="+$NL+"
expect '<--\> <-->'
recho --$NL--
expect '<--\^J-->'
recho "--$NL--"
expect '<--+\> <+-->'
recho --$NNL--
expect '<--+\^J+-->'
recho "--$NNL--"
expect '<-+\> <+-\> <->'
recho -$NNL-$NL-
set ''
expect '<xy>'
recho "$*xy"
expect '<xy>'
recho "x$*y"
expect '<xy>'
recho "xy$*"
expect '<>'
recho "$*"
expect nothing
recho $*
unset undef ; set ""
recho ${undef-"$zzz"}
recho x${undef-"$zzz"}
recho x${undef-"$@"}
recho ${undef-"$@"}
recho ${undef-"$zzz"}x
recho ${undef-"$@"}x
recho "$@"x
recho "$zzz"x
recho ${undef-}
recho ${undef-""}
yyy=""
recho "$xxx"x
recho "$yyy"x
set "" "abd" ""
recho "$@"x
recho "$@"$xxx
OIFS="$IFS"
arg=a,b,c,d,e,f
IFS=,
export z=$arg
eval z1=\"$arg\"
IFS="$OIFS"
recho $z
recho $z1
# should give an error
abc\=def
zz="a b c d e"
declare a=$zz
recho "$a"
recho $a
recho $(echo "foo$(echo ")")")
# test backslash escapes
recho \a
recho \\a
recho "\a"
recho "\\a"
recho '\a'
recho '\\a'
recho $(zecho \a)
recho $(zecho \\a)
recho $(zecho "\a")
recho $(zecho "\\a")
recho $(zecho '\a')
recho $(zecho '\\a')
recho `zecho \a`
recho `zecho \\a`
recho `zecho "\a"`
recho `zecho "\\a"`
recho `zecho '\a'`
recho `zecho '\\a'`
a=foo
recho \$a
recho \\$a
recho "\$a"
recho "\\$a"
recho '\$a'
recho '\\$a'
recho $(zecho `zecho \a`)
recho $(zecho `zecho \\a`)
recho $(zecho `zecho "\a"`)
recho $(zecho `zecho "\\a"`)
recho $(zecho `zecho '\a'`)
recho $(zecho `zecho '\\a'`)
# should echo G { I K }
recho ${abc:-G { I } K }
abc=hi
# should echo hi K }
recho ${abc:-G { I } K }
# should echo a*
unset foo
recho "${foo:-"a"}*"
+191 -5
View File
@@ -3,8 +3,8 @@ argv[1] = <foo>
argv[1] = </usr/homes/chet>
argv[1] = </usr/homes/chet>
argv[1] = </usr/homes/chet>
./new-exp.tests: ${HOME:`echo }`}: bad substitution
./new-exp.tests: ${_ENV[(_$-=0)+(_=1)-_${-%%*i*}]}: bad substitution
./new-exp.tests: HOME: }: syntax error: operand expected (error token is "}")
unset
argv[1] = </usr/homes/chet>
argv[1] = </usr/homes/chet>
argv[1] = </usr/homes/chet>
@@ -12,7 +12,8 @@ argv[1] = </usr/homes/chet>
argv[1] = </usr/homes/chet>
argv[1] = </usr/homes/chet>
argv[1] = </usr/homes/chet>
argv[1] = <*@>
argv[1] = <*@*>
argv[1] = <*@*>
argv[1] = <@*>
argv[1] = <)>
argv[1] = <")">
@@ -25,9 +26,194 @@ argv[1] = <a b c d e>
bar foo
bar foo
bar foo
bar foo
bar foo
barfoo
barfoo
argv[1] = <abcd>
argv[1] = <efg>
argv[2] = <nop>
argv[1] = <hijklmnop>
argv[1] = <abcdefghijklmnop>
argv[1] = <abcdefghijklmnop>
argv[1] = <ab cd>
argv[2] = <ef>
argv[1] = <gh ij>
argv[2] = <kl mn>
argv[1] = <gh ij>
argv[2] = <kl mn>
argv[3] = <op>
argv[1] = <ab cd>
argv[2] = <ef>
argv[3] = <gh ij>
argv[4] = <kl mn>
argv[5] = <op>
argv[1] = <abcdefghijklmnop>
argv[1] = <4>
argv[1] = <op>
argv[1] = <abcdefghijklmnop>
argv[1] = <abcdefghijklmnop>
./new-exp.tests: ABX: unbound variable
./new-exp.tests: $6: cannot assign in this way
argv[1] = <xxcde>
argv[1] = <axxde>
argv[1] = <abxyz>
argv[1] = <abbcde>
argv[1] = <abcde>
argv[1] = <abcabe>
argv[1] = <abcdlast>
argv[1] = <abcde>
argv[1] = <xxcd>
argv[1] = <abxx>
argv[1] = <xxgh>
argv[1] = <efgh>
argv[1] = <xxfgh>
argv[1] = <zagh>
argv[1] = <zaza>
argv[1] = <zagh>
argv[1] = <efza>
argv[1] = <yyy>
argv[2] = <yyy>
argv[3] = <yyy>
argv[4] = <yyy>
argv[5] = <yyy>
argv[6] = <yyy>
argv[1] = <yyy>
argv[2] = <yyy>
argv[3] = <yyy>
argv[4] = <yyy>
argv[5] = <yyy>
argv[6] = <yyy>
argv[1] = <yyy>
argv[2] = <yyy>
argv[3] = <yyy>
argv[4] = <yyy>
argv[5] = <yyy>
argv[6] = <yyy>
argv[1] = <yyy>
argv[2] = <efgh>
argv[3] = <ijkl>
argv[4] = <mnop>
argv[5] = <qrst>
argv[6] = <uvwx>
argv[1] = <abxx>
argv[2] = <efxx>
argv[3] = <ijxx>
argv[4] = <mnxx>
argv[5] = <qrxx>
argv[6] = <uvxx>
argv[1] = <xxcd>
argv[1] = <xxcd>
argv[2] = <xxgh>
argv[3] = <xxkl>
argv[4] = <xxop>
argv[5] = <xxst>
argv[6] = <xxwx>
argv[1] = <abxx>
argv[2] = <efxx>
argv[3] = <ijxx>
argv[4] = <mnxx>
argv[5] = <qrxx>
argv[6] = <uvxx>
argv[1] = <zaza>
argv[1] = <ijza>
argv[1] = <zaza>
argv[2] = <zaza>
argv[3] = <zaza>
argv[4] = <zaza>
argv[5] = <zaza>
argv[6] = <zaza>
argv[1] = <zacd>
argv[2] = <zagh>
argv[3] = <zakl>
argv[4] = <zaop>
argv[5] = <zast>
argv[6] = <zawx>
argv[1] = <yyy>
argv[2] = <yyy>
argv[3] = <yyy>
argv[4] = <yyy>
argv[5] = <yyy>
argv[6] = <yyy>
argv[1] = <yyy>
argv[2] = <efgh>
argv[3] = <ijkl>
argv[4] = <mnop>
argv[5] = <qrst>
argv[6] = <uvwx>
argv[1] = <abcd>
argv[2] = <efgh>
argv[3] = <ijkl>
argv[4] = <mnop>
argv[5] = <qrst>
argv[6] = <uvwyyy>
this is a test of proc subst
this is test 2
./new-exp.tests: ${#:-foo}: bad substitution
./new-exp.tests: ${#:}: bad substitution
argv[1] = <'>
argv[1] = <">
argv[1] = <"hello">
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <abcdef>
argv[1] = <abc def>
argv[1] = <abcdef>
argv[1] = <abc>
argv[2] = <def>
argv[1] = <abcdef>
argv[1] = <abc def>
argv[1] = <abcdef>
argv[1] = <abc def>
argv[1] = <ab>
argv[2] = <cd>
argv[3] = <ef>
argv[4] = <gh>
argv[1] = <ab>
argv[2] = <cd>
argv[3] = <ef>
argv[4] = <gh>
argv[1] = <ab>
argv[2] = <cd>
argv[3] = <ef>
argv[4] = <gh>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <hijklmnopqrstuv>
argv[1] = <pqrstuv>
argv[1] = <uvwxyz>
argv[1] = <abcdefghijklmnopqrstuvwxyz>
argv[1] = <abcdefghijklmnopqrst>
argv[1] = <klmnopq>
argv[1] = <klmnopq>
argv[1] = <klmnopq>
argv[1] = <"2 3">
argv[1] = <"2:3">
argv[1] = <"34">
argv[1] = <"3456">
argv[1] = <"3456">
argv[1] = <"3456">
argv[1] = <^A>
argv[2] = <^B>
argv[3] = <^?>
argv[1] = <^A>
argv[2] = <^B>
argv[3] = <^?>
argv[1] = <^A>
argv[2] = <^B>
argv[3] = <^?>
argv[1] = <^A>
argv[2] = <^B>
argv[3] = <^?>
argv[1] = <one/two>
argv[1] = <one/two>
argv[1] = <two>
argv[1] = <oneonetwo>
argv[1] = <onetwo>
argv[1] = <two>
argv[1] = <oneonetwo>
./new-exp.tests: ABXD: parameter unset
+284 -7
View File
@@ -16,11 +16,13 @@ recho "${HOME-'}'}"
expect "<$HOME>"
recho "${HOME-"}"}"
expect $0: '${HOME:`echo }`}: bad substitution'
recho "${HOME:`echo }`}" # should be an error -- bad substitution
expect $0: 'HOME: }: syntax error: operand expected (error token is "}")'
recho "${HOME:`echo }`}" # should be a math error -- bad substring substitution
expect $0: '${_ENV[(_$-=0)+(_=1)-_${-%%*i*}]}: bad substitution'
expect unset
_ENV=oops
x=${_ENV[(_$-=0)+(_=1)-_${-%%*i*}]} # memory leak
echo ${x:-unset}
expect "<$HOME>"
recho ${HOME}
@@ -38,8 +40,10 @@ expect "<$HOME>"
recho "$(echo "$(echo "${HOME}")")"
P=*@*
expect '<*@>'
recho "${P%"*"}" # should be *@
expect '<*@*>'
recho "${P%"*"}" #
expect '<*@*>'
recho "${P%'*'}" #
expect '<@*>'
recho "${P#\*}" # should be @*
@@ -73,12 +77,65 @@ echo -n $foo" " ; echo foo
expect '<bar foo>'
echo -n "$foo " ; echo foo
expect '<bar foo>'
expect '<barfoo>'
echo -e "$foo\c " ; echo foo
expect '<bar foo>'
expect '<barfoo>'
echo -e $foo"\c " ; echo foo
# substring tests
z=abcdefghijklmnop
expect '<abcd>'
recho ${z:0:4}
expect '<efg> <nop>'
recho ${z:4:3} ${z:${#z}-3:3}
expect '<hijklmnop>'
recho ${z:7:30}
expect '<abcdefghijklmnop>'
recho ${z:0:100}
expect '<abcdefghijklmnop>'
recho ${z:0:${#z}}
set 'ab cd' 'ef' 'gh ij' 'kl mn' 'op'
expect '<ab cd> <ef>'
recho "${@:1:2}"
expect '<gh ij> <kl mn>'
recho "${@:3:2}"
expect '<gh ij> <kl mn> <op>'
recho "${@:3:4}"
expect '<ab cd> <ef> <gh ij> <kl mn> <op>'
recho "${@:1:$#}"
# indirect variable references
expect '<abcdefghijklmnop>'
recho ${!9:-$z}
ef=4
expect '<4>'
recho ${!2}
expect '<op>'
recho ${!#}
set a b c d e
a=
expect '<abcdefghijklmnop>'
recho ${a:-$z}
expect '<abcdefghijklmnop>'
recho ${!1:-$z}
expect nothing
recho ${a-$z}
expect nothing
recho ${!1-$z}
set -u
expect $0: ABX: unbound variable
recho ${ABX}
@@ -87,9 +144,229 @@ set +u
expect $0: '$6: cannot assign in this way'
recho ${6="arg6"}
v=abcde
# sed-like variable substitution
expect '<xxcde>'
recho ${v/a[a-z]/xx}
expect '<axxde>'
recho ${v/a??/axx}
expect '<abxyz>'
recho ${v/c??/xyz}
expect '<abbcde>'
recho ${v/#a/ab}
expect '<abcde>'
recho ${v/#d/ab}
expect '<abcabe>'
recho ${v/d/ab}
expect '<abcdlast>'
recho ${v/%?/last}
expect '<abcde>'
recho ${v/%x/last}
av=(abcd efgh ijkl mnop qrst uvwx)
expect '<xxcd>'
recho ${av/??/xx}
expect '<abxx>'
recho ${av/%??/xx}
expect '<xxgh>'
recho ${av[1]/??/xx}
expect '<efgh>'
recho ${av[1]/%ab/xx}
expect '<xxfgh>'
recho ${av[1]/#?/xx}
expect '<zagh>'
recho ${av[1]/??/za}
expect '<zaza>'
recho ${av[1]//??/za}
expect '<zagh>'
recho ${av[1]//#??/za}
expect '<efza>'
recho ${av[1]//%??/za}
expect '<yyy> <yyy> <yyy> <yyy> <yyy> <yyy>'
recho ${av[@]/*/yyy}
expect '<yyy> <yyy> <yyy> <yyy> <yyy> <yyy>'
recho ${av[@]/#*/yyy}
expect '<yyy> <yyy> <yyy> <yyy> <yyy> <yyy>'
recho ${av[@]/%*/yyy}
expect '<yyy> <efgh> <ijkl> <mnop> <qrst> <uvwx>'
recho ${av[@]/a*/yyy}
expect '<abxx> <efxx> <ijxx> <mnxx> <qrxx> <uvxx>'
recho ${av[@]/%??/xx}
set abcd efgh ijkl mnop qrst uvwx
expect '<xxcd>'
recho ${1/??/xx}
expect '<xxcd> <xxgh> <xxkl> <xxop> <xxst> <xxwx>'
recho ${@/??/xx}
expect '<xxcd> <xxgh> <xxkl> <xxop> <xxst> <xxwx>'
recho ${@/%??/xx}
expect '<zaza>'
recho ${3//??/za}
expect '<efza>'
recho ${3//%??/za}
expect '<zaza> <zaza> <zaza> <zaza> <zaza> <zaza>'
recho ${@//??/za}
expect '<zacd> <zagh> <zakl> <zaop> <zast> <zawx>'
recho ${@//#??/za}
expect '<yyy> <yyy> <yyy> <yyy> <yyy> <yyy>'
recho ${@//*/yyy}
expect '<yyy> <efgh> <ijkl> <mnop> <qrst> <uvwx>'
recho ${@//a*/yyy}
expect '<abcd> <efgh> <ijkl> <mnop> <qrst> <uvwyyy>'
recho ${@//%x*/yyy}
expect a newline
echo $abmcde
expect this is a test of proc subst
cat <(echo this is a test of proc subst)
echo this is test 2 > /tmp/x
expect this is test 2
cat <(cat /tmp/x)
rm -f /tmp/x
expect $0: '${#:-foo}: bad substitution'
echo ${#:-foo}
expect $0: '${#:}: bad substitution'
echo ${#:}
expect "<'>"
recho "'"
expect '<">'
recho '"'
expect '<"hello">'
recho "\"hello\""
shift $#
unset foo
z=abcdef
z1='abc def'
expect '<>'
recho ${foo:-""}
expect nothing
recho ${foo:-"$@"}
expect '<>'
recho "${foo:-$@}"
# unset var
expect '<>'
recho ${foo:-"$zbcd"}
expect nothing
recho ${foo:-$zbcd}
# set var
expect '<abcdef>'
recho ${foo:-"$z"}
expect '<abc def>'
recho ${foo:-"$z1"}
expect '<abcdef>'
recho ${foo:-$z}
expect '<abc> <def>'
recho ${foo:-$z1}
expect '<abcdef>'
recho "${foo:-$z}"
expect '<abc def>'
recho "${foo:-$z1}"
expect '<abcdef>'
recho "${foo:-"$z"}"
# this disagrees with sh and ksh, but I think it is right according
# to posix.2.
expect '<abc def>'
recho "${foo:-"$z1"}"
set ab cd ef gh
expect '<ab> <cd> <ef> <gh>'
recho ${foo:-"$@"}
expect '<ab> <cd> <ef> <gh>'
recho "${foo:-$@}"
expect '<ab> <cd> <ef> <gh>'
recho "${foo:-"$@"}"
shift $#
expect nothing
recho $xxx"$@"
expect nothing
recho ${foo:-$xxx"$@"}
expect '<>'
recho "${foo:-$xxx$@}"
expect '<>'
recho "${foo:-$xxx"$@"}"
expect nothing
recho $xxx"$@"
expect nothing
recho "$xxx$@"
expect nothing
recho "$@"$xxx
expect '<>'
recho $xxx""
expect '<>'
recho $xxx''
expect '<>'
recho ''$xxx
expect '<>'
recho ""$xxx
AB='abcdefghijklmnopqrstuvwxyz'
recho ${AB:7:15}
recho ${AB:15:7}
recho ${AB:20}
recho ${AB:0}
recho ${AB:0:20}
recho ${AB:10:7}
recho ${AB:10:3+4}
recho ${AB:20/2:3+4}
set 1 2 3 4 5 6
recho \""${*:2:2}"\"
IFS=:
recho \""${*:2:2}"\"
IFS=$' \t\n'
z=123456
recho \""${z:2:2}"\"
recho \""${z:2}"\"
recho \""${z:2:4}"\"
recho \""${z:2:6}"\"
set $'\1' $'\2' $'\177'
recho $*
recho $@
recho ${*}
recho ${@}
xx=one/two/two
recho ${xx%/*}
recho ${xx/\/two}
yy=oneonetwo
recho ${yy//one}
recho ${yy/\/one}
xx=oneonetwo
recho ${xx/one}
recho ${xx//one}
recho ${xx/\/one}
# this must be last!
expect $0: 'ABXD: parameter unset'
recho ${ABXD:?"parameter unset"}
+16
View File
@@ -0,0 +1,16 @@
argv[1] = <^J^J^J>
argv[1] = <>
argv[1] = <^J^I >
argv[1] = <abc>
argv[1] = <^M^[^Gabc>
argv[1] = <hello,>
argv[2] = <world>
argv[1] = <hello, world>
argv[1] = <>
argv[1] = <$hello, world>
argv[1] = <hello, $world>
argv[1] = <hello, "world">
argv[1] = <hello, $"world">
argv[1] = <hello, $"world">
argv[1] = <$hello, chet>
argv[1] = <hello, chet>
+57
View File
@@ -0,0 +1,57 @@
expect()
{
echo expect "$@"
}
expect '<^J^J^J>'
recho $'\n\n\n'
z1=$''
expect '<>'
recho "$z1"
ZIFS=$'\n'$'\t'$' '
expect '<^J^I >'
recho "$ZIFS"
expect '<abc>'
recho $'abc'
expect '<^M^[^Gabc>'
recho $'\r\e\aabc'
D=$"hello"," "$"world"
expect '<hello,> <world>'
recho $D
expect '<hello, world>'
recho "$D"
D=$""
expect '<>'
recho "$D"
world=chet
expect '<$hello, world>'
recho \$"hello, world"
expect '<hello, $world>'
recho $"hello, \$world"
expect '<hello, "world">'
recho $"hello, \"world\""
expect '<hello, $"world">'
recho $"hello"', $"world"'
expect '<hello, $"world">'
recho $'hello, $"world"'
expect '<$hello, chet>'
recho \$"hello, $world"
expect '<hello, chet>'
recho $"hello, $world"
+2
View File
@@ -0,0 +1,2 @@
Testing for POSIX.2 conformance
All tests passed
+148
View File
@@ -0,0 +1,148 @@
#! /bin/sh
# posix-2.sh - Simple identification tests for POSIX.2 features
# commonly missing or incorrectly implemented.
# Time-stamp: <96/04/10 16:43:48 gildea>
# By Stephen Gildea <gildea@x.org> March 1995
#
# Copyright (c) 1995 Stephen Gildea
# Permission is hereby granted to deal in this Software without restriction.
# THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.
#
# MODIFIED BY chet@po.cwru.edu to make part of the bash test suite.
# last change: Wed Jun 19 12:24:24 EDT 1996
#
# some of the tests:
#
# shell functions (do we care?)
# var=${var:-val}
# unset
# set --
# IFS parsing
## not exiting with -e and failed "if", the way Ultrix does (Ultrix 4.2?)
# "$@" expands to zero arguments if passed zero arguments
# $SHELL -c 'echo $1' bad good
# test -x
# positional parameters greater than 9
# arithmetic expansion $(( ... ))
# getopts
# For some tests we must run a sub-shell; $TESTSHELL says what to use.
# If set, TESTSHELL must be an absolute pathname.
# For example, on HP-UX 9, /bin/posix/sh is the supposedly-compliant shell.
TESTSHELL=${THIS_SH:-$PWD/../bash}
# these tests create temp files with names $TMPDIR/conf*
: ${TMPDIR:=/tmp}
exitval=0
numtests=0
echo "Testing for POSIX.2 conformance"
newtest()
{
numtests=$(($numtests + 1))
}
testfail()
{
echo "$1 test failed"
exitval=$(($exitval + 1))
}
newtest
empty=""
test "${empty:-ok}" = ok || testfail "empty var colon"
newtest
test "${empty-bad}" = "" || testfail "got \"${empty-bad}\": empty var nocolon"
newtest
test "${unsetvar-ok}" = ok || testfail "unset var"
newtest
unset empty
test "${empty-ok}" = ok || testfail "unset"
newtest
set -- -Z
test "x$1" = x-Z || testfail '\"set -- arg\"'
# this should empty the argument list
newtest
set --
test $# = 0 || testfail "still $# args: \"set --\""
# IFS parsing:
newtest
names=one/good/three
saved_ifs="$IFS"
IFS=/
set $names lose
test "$2" = good || testfail "got \"$2\": IFS parsing"
IFS="$saved_ifs"
# "$@" with 0 arguments should expand to 0 arguments
newtest
cat > $TMPDIR/conftest1 << EOF
$TMPDIR/conftest2 "\$@"
EOF
cat > $TMPDIR/conftest2 << "EOF"
#! /bin/sh
echo $#
EOF
chmod +x $TMPDIR/conftest1 $TMPDIR/conftest2
numargs=$($TESTSHELL $TMPDIR/conftest1)
if [ "$?" != 0 ]; then
testfail 'running $@'
else
test "$numargs" = 0 || testfail '"$@" got '"$numargs args: expansion w 0 args"
fi
rm -f $TMPDIR/conftest1 $TMPDIR/conftest2
newtest
val=$("$TESTSHELL" -c 'echo $1' csh good)
test "$val" = good || testfail "got \"$val\": sh -c"
newtest
# do these tests in a sub-shell because failure will exit
val=$("$TESTSHELL" -c 'echo ${10}' 0 1 2 3 4 5 6 7 8 9 ten 11 2> /dev/null)
test "$val" = ten || testfail "accessing more than 9 positional params"
a=abc_def_ghi
export a
newtest; val=`"$TESTSHELL" -c 'echo "${a%_*}"' 2> /dev/null`
test "$val" = abc_def || testfail "parameter % op"
newtest; val=`"$TESTSHELL" -c 'echo "${a%%_*}"' 2> /dev/null`
test "$val" = abc || testfail "parameter %% op"
newtest; val=`"$TESTSHELL" -c 'echo "${a#*_}"' 2> /dev/null`
test "$val" = def_ghi || testfail "parameter # op"
newtest; val=`"$TESTSHELL" -c 'echo "${a##*_}"' 2> /dev/null`
test "$val" = ghi || testfail "parameter ## op"
newtest
"$TESTSHELL" -c 'export a=value' 2> /dev/null || testfail "export with value"
newtest
a=5; test "$(( ($a+1)/2 ))" = 3 || testfail "arithmetic expansion"
# does "test" support the -x switch?
newtest
touch $TMPDIR/conftest
chmod -x $TMPDIR/conftest
test -x $TMPDIR/conftest && testfail "negative test -x"
chmod +x $TMPDIR/conftest
test -x $TMPDIR/conftest || testfail "positive test -x"
rm -f $TMPDIR/conftest
newtest
test "$OPTIND" = 1 || testfail "OPTIND initial value"
newtest
getopts a: store -a aoptval
if [ "$OPTIND" != 3 ] || [ "$store" != a ] || [ "$OPTARG" != aoptval ]; then
testfail "getopts"
fi
if [ $exitval = 0 ]; then
echo "All tests passed"
else
echo "$exitval of $numtests tests failed"
fi
exit $exitval
+42
View File
@@ -0,0 +1,42 @@
Single Quote
foo
bar
foo
bar
foo\
bar
Double Quote
foo
bar
foo
bar
foobar
Backslash Single Quote
foo bar
foo bar
foobar
Backslash Double Quote
foo bar
foo bar
foobar
Double Quote Backslash Single Quote
foo
bar
foo
bar
foobar
Dollar Paren Single Quote
foo bar
foo bar
foo\ bar
Dollar Paren Double Quote
foo bar
foo bar
foobar
Double Quote Dollar Paren Single Quote
foo
bar
foo
bar
foo\
bar
+63
View File
@@ -0,0 +1,63 @@
echo "Single Quote"
echo 'foo
bar'
echo 'foo
bar'
echo 'foo\
bar'
echo "Double Quote"
echo "foo
bar"
echo "foo
bar"
echo "foo\
bar"
echo "Backslash Single Quote"
echo `echo 'foo
bar'`
echo `echo 'foo
bar'`
echo `echo 'foo\
bar'`
echo "Backslash Double Quote"
echo `echo "foo
bar"`
echo `echo "foo
bar"`
echo `echo "foo\
bar"`
echo "Double Quote Backslash Single Quote"
echo "`echo 'foo
bar'`"
echo "`echo 'foo
bar'`"
echo "`echo 'foo\
bar'`"
echo "Dollar Paren Single Quote"
echo $(echo 'foo
bar')
echo $(echo 'foo
bar')
echo $(echo 'foo\
bar')
echo "Dollar Paren Double Quote"
echo $(echo "foo
bar")
echo $(echo "foo
bar")
echo $(echo "foo\
bar")
echo "Double Quote Dollar Paren Single Quote"
echo "$(echo 'foo
bar')"
echo "$(echo 'foo
bar')"
echo "$(echo 'foo\
bar')"
+14
View File
@@ -0,0 +1,14 @@
a.
-a-b-
-a-b-
-a b-
-a b-
-a-b\-
-a b\-
-\-a b\-
-\ a b\-
-\-a b\-
-\ a b\-
1: x[A] y[B] z[]
1a:
2: x[A B]
+24
View File
@@ -0,0 +1,24 @@
echo " a " | (read x; echo "$x.")
echo " a b " | ( read x y ; echo -"$x"-"$y"- )
echo " a b\ " | ( read x y ; echo -"$x"-"$y"- )
echo " a b " | ( read x ; echo -"$x"- )
echo " a b\ " | ( read x ; echo -"$x"- )
echo " a b\ " | ( read -r x y ; echo -"$x"-"$y"- )
echo " a b\ " | ( read -r x ; echo -"$x"- )
echo "\ a b\ " | ( read -r x y ; echo -"$x"-"$y"- )
echo "\ a b\ " | ( read -r x ; echo -"$x"- )
echo " \ a b\ " | ( read -r x y ; echo -"$x"-"$y"- )
echo " \ a b\ " | ( read -r x ; echo -"$x"- )
echo "A B " > /tmp/IN
unset x y z
read x y z < /tmp/IN
echo 1: "x[$x] y[$y] z[$z]"
echo 1a: ${z-z not set}
read x < /tmp/IN
echo 2: "x[$x]"
rm /tmp/IN
+68
View File
@@ -0,0 +1,68 @@
argv[1] = <TDEFAULTS = -DSELECT_VECS='&m68kcoff_vec'>
argv[1] = <TDEFAULTS = -DSELECT_VECS=\'&m68kcoff_vec\'>
argv[1] = <TDEFAULTS = -DSELECT_VECS=&m68kcoff_vec>
argv[1] = <TDEFAULTS = -DSELECT_VECS="&m68kcoff_vec">
argv[1] = <TDEFAULTS = -DSELECT_VECS=\&m68kcoff_vec\>
argv[1] = <TDEFAULTS = -DSELECT_VECS=&m68kcoff_vec>
argv[1] = <TDEFAULTS = -DSELECT_VECS=$selvecs>
argv[1] = <TDEFAULTS = -DSELECT_VECS=$selvecs>
argv[1] = <TDEFAULTS = -DSELECT_VECS='&m68kcoff_vec'>
argv[1] = <TDEFAULTS = -DSELECT_VECS=\&m68kcoff_vec>
argv[1] = <TDEFAULTS = -DSELECT_VECS='&m68kcoff_vec'>
argv[1] = <TDEFAULTS>
argv[2] = <=>
argv[3] = <-DSELECT_VECS=$selvecs>
argv[1] = <TDEFAULTS>
argv[2] = <=>
argv[3] = <-DSELECT_VECS='&m68kcoff_vec'>
argv[1] = <TDEFAULTS>
argv[2] = <=>
argv[3] = <-DSELECT_VECS=&m68kcoff_vec>
argv[1] = <TDEFAULTS>
argv[2] = <=>
argv[3] = <-DSELECT_VECS="&m68kcoff_vec">
argv[1] = <TDEFAULTS>
argv[2] = <=>
argv[3] = <-DSELECT_VECS=\&m68kcoff_vec\>
argv[1] = <TDEFAULTS>
argv[2] = <=>
argv[3] = <-DSELECT_VECS=&m68kcoff_vec>
argv[1] = <TDEFAULTS>
argv[2] = <=>
argv[3] = <-DSELECT_VECS=$selvecs>
argv[1] = <TDEFAULTS>
argv[2] = <=>
argv[3] = <-DSELECT_VECS=$selvecs>
argv[1] = <TDEFAULTS>
argv[2] = <=>
argv[3] = <-DSELECT_VECS=$selvecs>
argv[1] = <TDEFAULTS>
argv[2] = <=>
argv[3] = <-DSELECT_VECS=\&m68kcoff_vec>
argv[1] = <TDEFAULTS>
argv[2] = <=>
argv[3] = <-DSELECT_VECS=\'&m68kcoff_vec\'>
argv[1] = <TDEFAULTS = -DSELECT_VECS=p>
argv[1] = <TDEFAULTS = -DSELECT_VECS=\p>
argv[1] = <TDEFAULTS = -DSELECT_VECS=\>
argv[1] = <TDEFAULTS = -DSELECT_VECS=\>
argv[1] = <TDEFAULTS = -DSELECT_VECS=\'>
argv[1] = <TDEFAULTS = -DSELECT_VECS='>
argv[1] = <TDEFAULTS>
argv[2] = <=>
argv[3] = <-DSELECT_VECS=\p>
argv[1] = <TDEFAULTS>
argv[2] = <=>
argv[3] = <-DSELECT_VECS=p>
argv[1] = <TDEFAULTS>
argv[2] = <=>
argv[3] = <-DSELECT_VECS=\>
argv[1] = <TDEFAULTS>
argv[2] = <=>
argv[3] = <-DSELECT_VECS=\>
argv[1] = <TDEFAULTS>
argv[2] = <=>
argv[3] = <-DSELECT_VECS='>
argv[1] = <TDEFAULTS>
argv[2] = <=>
argv[3] = <-DSELECT_VECS=\'>
+38
View File
@@ -0,0 +1,38 @@
selvecs='&m68kcoff_vec'
recho "TDEFAULTS = ${selvecs:+-DSELECT_VECS='$selvecs'}"
recho "TDEFAULTS = ${selvecs:+-DSELECT_VECS=\'$selvecs\'}"
recho "TDEFAULTS = ${selvecs:+-DSELECT_VECS="$selvecs"}"
recho "TDEFAULTS = ${selvecs:+-DSELECT_VECS=\"$selvecs\"}"
recho "TDEFAULTS = ${selvecs:+-DSELECT_VECS=\\$selvecs\\}"
recho "TDEFAULTS = ${selvecs:+-DSELECT_VECS=$selvecs}"
recho "TDEFAULTS = ${selvecs:+-DSELECT_VECS=\$selvecs}"
recho "TDEFAULTS = ${selvecs:+-DSELECT_VECS="\$selvecs"}"
recho "TDEFAULTS = ${selvecs:+-DSELECT_VECS='$selvecs'"$null"}"
recho "TDEFAULTS = ${selvecs:+-DSELECT_VECS="\\$selvecs"}"
recho "TDEFAULTS = ${selvecs:+-DSELECT_VECS="\'$selvecs\'"}"
recho TDEFAULTS = ${selvecs:+-DSELECT_VECS='$selvecs'}
recho TDEFAULTS = ${selvecs:+-DSELECT_VECS=\'$selvecs\'}
recho TDEFAULTS = ${selvecs:+-DSELECT_VECS="$selvecs"}
recho TDEFAULTS = ${selvecs:+-DSELECT_VECS=\"$selvecs\"}
recho TDEFAULTS = ${selvecs:+-DSELECT_VECS=\\$selvecs\\}
recho TDEFAULTS = ${selvecs:+-DSELECT_VECS=$selvecs}
recho TDEFAULTS = ${selvecs:+-DSELECT_VECS=\$selvecs}
recho TDEFAULTS = ${selvecs:+-DSELECT_VECS="\$selvecs"}
recho TDEFAULTS = ${selvecs:+-DSELECT_VECS='$selvecs'"$null"}
recho TDEFAULTS = ${selvecs:+-DSELECT_VECS="\\$selvecs"}
recho TDEFAULTS = ${selvecs:+-DSELECT_VECS="\'$selvecs\'"}
recho "TDEFAULTS = ${selvecs:+-DSELECT_VECS="\p"}"
recho "TDEFAULTS = ${selvecs:+-DSELECT_VECS=\p}"
recho "TDEFAULTS = ${selvecs:+-DSELECT_VECS="\\"}"
recho "TDEFAULTS = ${selvecs:+-DSELECT_VECS=\\}"
recho "TDEFAULTS = ${selvecs:+-DSELECT_VECS=\'}"
recho "TDEFAULTS = ${selvecs:+-DSELECT_VECS="\'"}"
recho TDEFAULTS = ${selvecs:+-DSELECT_VECS="\p"}
recho TDEFAULTS = ${selvecs:+-DSELECT_VECS=\p}
recho TDEFAULTS = ${selvecs:+-DSELECT_VECS="\\"}
recho TDEFAULTS = ${selvecs:+-DSELECT_VECS=\\}
recho TDEFAULTS = ${selvecs:+-DSELECT_VECS=\'}
recho TDEFAULTS = ${selvecs:+-DSELECT_VECS="\'"}
Executable → Regular
+9 -3
View File
@@ -1,14 +1,20 @@
#! /bin/sh
PATH=.:$PATH # just to get the right version of printenv
PATH=.:$PATH # just to get the right version of printenv
export PATH
unset ENV
# unset ENV only if it is set
[ "${ENV+set}" = "set" ] && unset ENV
: ${THIS_SH:=../bash}
export THIS_SH
echo Testing ${THIS_SH}
echo Any output from any test indicates an anomaly worth investigating
for x in run-*
do
case $x in
$0) ;;
$0|run-minimal) ;;
*.orig|*~) ;;
*) echo $x ; sh $x ;;
esac
+2
View File
@@ -0,0 +1,2 @@
${THIS_SH} ./arith.tests > /tmp/xx 2>&1
diff /tmp/xx arith.right && rm -f /tmp/xx
+2
View File
@@ -0,0 +1,2 @@
${THIS_SH} ./array.tests > /tmp/xx 2>&1
diff /tmp/xx array.right && rm -f /tmp/xx
+2
View File
@@ -0,0 +1,2 @@
${THIS_SH} ./braces-tests > /tmp/xx
diff /tmp/xx braces.right && rm -f /tmp/xx
Executable → Regular
+3 -3
View File
@@ -1,3 +1,3 @@
../bash ./dollar-star.sh a b > x 2>&1
../bash ./dollar-at.sh a b >>x 2>&1
diff x dollar.right && rm -f x
${THIS_SH} ./dollar-star.sh a b > /tmp/xx 2>&1
${THIS_SH} ./dollar-at.sh a b >>/tmp/xx 2>&1
diff /tmp/xx dollar.right && rm -f /tmp/xx
Executable → Regular
+2 -2
View File
@@ -1,2 +1,2 @@
../bash ./exp-tests | grep -v '^expect' > xx
diff xx exp.right && rm -f xx
${THIS_SH} ./exp-tests | grep -v '^expect' > /tmp/xx
diff /tmp/xx exp.right && rm -f /tmp/xx
Executable → Regular
+2 -2
View File
@@ -1,4 +1,4 @@
PATH=$PATH:`pwd`
export PATH
../bash ./glob-test | grep -v '^expect' > xx
diff xx glob.right && rm -f xx
${THIS_SH} ./glob-test | grep -v '^expect' > /tmp/xx
diff /tmp/xx glob.right && rm -f /tmp/xx
+2
View File
@@ -0,0 +1,2 @@
${THIS_SH} ./heredoc.tests > /tmp/xx 2>&1
diff /tmp/xx heredoc.right && rm -f /tmp/xx
Executable → Regular
+7 -7
View File
@@ -1,13 +1,13 @@
#
# show that IFS is only applied to the result of expansions
#
../bash ifs-test-1.sh > xx
diff xx ./ifs.1.right
${THIS_SH} ifs-test-1.sh > /tmp/xx
diff /tmp/xx ./ifs.1.right
../bash ifs-test-2.sh > xx
diff xx ./ifs.2.right
${THIS_SH} ifs-test-2.sh > /tmp/xx
diff /tmp/xx ./ifs.2.right
../bash ifs-test-3.sh > xx
diff xx ./ifs.3.right
${THIS_SH} ifs-test-3.sh > /tmp/xx
diff /tmp/xx ./ifs.3.right
rm -f xx
rm -f /tmp/xx
Executable → Regular
+2 -2
View File
@@ -1,2 +1,2 @@
../bash < ./input-line.sh > xx
diff xx input.right && rm -f xx
${THIS_SH} < ./input-line.sh > /tmp/xx
diff /tmp/xx input.right && rm -f /tmp/xx
Executable → Regular
+2 -2
View File
@@ -1,2 +1,2 @@
../bash ./minus-e > xx
diff xx minus-e.right && rm -f xx
${THIS_SH} ./minus-e > /tmp/xx
diff /tmp/xx minus-e.right && rm -f /tmp/xx
+2
View File
@@ -0,0 +1,2 @@
${THIS_SH} ./more-exp.tests 2>&1 | grep -v '^expect' > /tmp/xx
diff /tmp/xx more-exp.right && rm -f /tmp/xx
Executable → Regular
+2 -2
View File
@@ -1,2 +1,2 @@
../bash ./new-exp.tests 2>&1 | grep -v '^expect' > xx
diff xx new-exp.right && rm -f xx
${THIS_SH} ./new-exp.tests 2>&1 | grep -v '^expect' > /tmp/xx
diff /tmp/xx new-exp.right && rm -f /tmp/xx
+2
View File
@@ -0,0 +1,2 @@
${THIS_SH} ./nquote.tests 2>&1 | grep -v '^expect' > /tmp/xx
diff /tmp/xx nquote.right && rm -f /tmp/xx
+2
View File
@@ -0,0 +1,2 @@
${THIS_SH} ./posix2.tests 2>&1 | grep -v '^expect' > /tmp/xx
diff /tmp/xx posix2.right && rm -f /tmp/xx
Executable → Regular
+2 -2
View File
@@ -1,2 +1,2 @@
../bash ./precedence > xx
diff xx prec.right && rm -f xx
${THIS_SH} ./precedence > /tmp/xx
diff /tmp/xx prec.right && rm -f /tmp/xx
+2
View File
@@ -0,0 +1,2 @@
${THIS_SH} ./quote.tests >/tmp/xx 2>&1
diff /tmp/xx quote.right && rm -f /tmp/xx
+2
View File
@@ -0,0 +1,2 @@
${THIS_SH} ./read.tests > /tmp/xx
diff /tmp/xx read.right && rm -f /tmp/xx
+2
View File
@@ -0,0 +1,2 @@
${THIS_SH} ./rhs-exp.tests 2>&1 > /tmp/xx
diff /tmp/xx rhs-exp.right && rm -f /tmp/xx
Executable → Regular
+2 -2
View File
@@ -1,2 +1,2 @@
../bash ./set-e-test > xx
diff xx set-e.right && rm -f xx
${THIS_SH} ./set-e-test > /tmp/xx
diff /tmp/xx set-e.right && rm -f /tmp/xx
Executable → Regular
+2 -2
View File
@@ -1,2 +1,2 @@
../bash ./strip.tests > xx
diff xx strip.right && rm -f xx
${THIS_SH} ./strip.tests > /tmp/xx
diff /tmp/xx strip.right && rm -f /tmp/xx
+2
View File
@@ -0,0 +1,2 @@
${THIS_SH} ./test-tests 2>&1 > /tmp/xx
diff /tmp/xx test.right && rm -f /tmp/xx
+2
View File
@@ -0,0 +1,2 @@
${THIS_SH} ./tilde-tests > /tmp/xx
diff /tmp/xx tilde.right && rm -f /tmp/xx
Executable → Regular
+2 -2
View File
@@ -1,2 +1,2 @@
../bash ./varenv.sh | grep -v '^expect' > xx
diff xx varenv.right && rm -f xx
${THIS_SH} ./varenv.sh | grep -v '^expect' > /tmp/xx
diff /tmp/xx varenv.right && rm -f /tmp/xx
+3
View File
@@ -14,3 +14,6 @@ if : ; then
done
set +e
fi
# command subst should not inherit -e
set -e
echo $(false; echo ok)
+1
View File
@@ -13,3 +13,4 @@
7
8
9
ok
+279
View File
@@ -0,0 +1,279 @@
t()
{
test "$@"
echo $?
}
echo 't -a noexist'
t -a noexist
echo 't -a run-all'
t -a run-all
echo 't -b run-all'
t -b run-all
echo 't -b /dev/jb1a'
t -b /dev/jb1a
echo 't -c run-all'
t -c run-all
echo 't -c /dev/tty'
t -c /dev/tty
echo 't -d run-all'
t -d run-all
echo 't -d /etc'
t -d /etc
echo 't -e noexist'
t -e noexist
echo 't -e run-all'
t -e run-all
echo 't -f noexist'
t -f noexist
echo 't -f /dev/tty'
t -f /dev/tty
echo 't -f run-all'
t -f run-all
echo 't -g run-all'
t -g run-all
touch /tmp/test.setgid
chmod ug+x /tmp/test.setgid
chmod g+s /tmp/test.setgid
echo 't -g /tmp/test.setgid'
t -g /tmp/test.setgid
rm -f /tmp/test.setgid
echo 't -k run-all'
t -k run-all
echo 't -n ""'
t -n ""
echo 't -n "hello"'
t -n "hello"
echo 't -p run-all'
t -p run-all
echo 't -r noexist'
t -r noexist
touch /tmp/test.noread
chmod a-r /tmp/test.noread
echo 't -r /tmp/test.noread'
t -r /tmp/test.noread
rm -f /tmp/test.noread
echo 't -r run-all'
t -r run-all
echo 't -s noexist'
t -s noexist
echo 't -s /dev/null'
t -s /dev/null
echo 't -s run-all'
t -s run-all
echo 't -t 20'
t -t 20
echo 't -t 0'
t -t 0
echo 't -u noexist'
t -u noexist
echo 't -u run-all'
t -u run-all
touch /tmp/test.setuid
chmod u+x /tmp/test.setuid # some systems require this to turn on setuid bit
chmod u+s /tmp/test.setuid
echo 't -u /tmp/test.setuid'
t -u /tmp/test.setuid
rm -f /tmp/test.setuid
echo 't -w noexist'
t -w noexist
touch /tmp/test.nowrite
chmod a-w /tmp/test.nowrite
echo 't -w /tmp/test.nowrite'
t -w /tmp/test.nowrite
rm -f /tmp/test.nowrite
echo 't -w /dev/null'
t -w /dev/null
echo 't -x noexist'
t -x noexist
touch /tmp/test.exec
chmod u+x /tmp/test.exec
echo 't -x /tmp/test.exec'
t -x /tmp/test.exec
rm -f /tmp/test.exec
touch /tmp/test.noexec
chmod u-x /tmp/test.noexec
echo 't -x /tmp/test.noexec'
t -x /tmp/test.noexec
rm -f /tmp/test.noexec
echo 't -z ""'
t -z ""
echo 't -z "foo"'
t -z "foo"
echo 't "foo"'
t "foo"
echo 't ""'
t ""
touch /tmp/test.owner
echo 't -O /tmp/test.owner'
t -O /tmp/test.owner
rm -f /tmp/test.owner
echo 't "hello" = "hello"'
t "hello" = "hello"
echo 't "hello" = "goodbye"'
t "hello" = "goodbye"
echo 't "hello" == "hello"'
t "hello" == "hello"
echo 't "hello" == "goodbye"'
t "hello" == "goodbye"
echo 't "hello" != "hello"'
t "hello" != "hello"
echo 't "hello" != "goodbye"'
t "hello" != "goodbye"
echo 't "hello" < "goodbye"'
t "hello" \< "goodbye"
echo 't "hello" > "goodbye"'
t "hello" \> "goodbye"
echo 't ! "hello" > "goodbye"'
t "! hello" \> "goodbye"
echo 't 200 -eq 200'
t 200 -eq 200
echo 't 34 -eq 222'
t 34 -eq 222
echo 't 200 -ne 200'
t 200 -ne 200
echo 't 34 -ne 222'
t 34 -ne 222
echo 't 200 -gt 200'
t 200 -gt 200
echo 't 340 -gt 222'
t 340 -gt 222
echo 't 200 -ge 200'
t 200 -ge 200
echo 't 34 -ge 222'
t 34 -ge 222
echo 't 200 -lt 200'
t 200 -lt 200
echo 't 34 -lt 222'
t 34 -lt 222
echo 't 200 -le 200'
t 200 -le 200
echo 't 340 -le 222'
t 340 -le 222
echo 't 700 -le 1000 -a -n "1" -a "20" = "20"'
t 700 -le 1000 -a -n "1" -a "20" = "20"
echo 't ! \( 700 -le 1000 -a -n "1" -a "20" = "20" \)'
t ! \( 700 -le 1000 -a -n "1" -a "20" = "20" \)
touch /tmp/abc
sleep 2
touch /tmp/def
echo 't /tmp/abc -nt /tmp/def'
t /tmp/abc -nt /tmp/def
echo 't /tmp/abc -ot /tmp/def'
t /tmp/abc -ot /tmp/def
echo 't /tmp/def -nt /tmp/abc'
t /tmp/def -nt /tmp/abc
echo 't /tmp/def -ot /tmp/abc'
t /tmp/def -ot /tmp/abc
echo 't /tmp/abc -ef /tmp/def'
t /tmp/abc -ef /tmp/def
ln /tmp/abc /tmp/ghi
echo 't /tmp/abc -ef /tmp/ghi'
t /tmp/abc -ef /tmp/ghi
rm /tmp/abc /tmp/def /tmp/ghi
echo 't -r /dev/fd/0'
t -r /dev/fd/0
echo 't -w /dev/fd/1'
t -w /dev/fd/1
echo 't -w /dev/fd/2'
t -w /dev/fd/2
echo 't'
t
echo 't 12 -eq 34'
t 12 -eq 34
echo 't ! 12 -eq 34'
t ! 12 -eq 34
echo 't -n abcd -o aaa'
t -n abcd -o aaa
echo 't -n abcd -o -z aaa'
t -n abcd -o -z aaa
echo 't -n abcd -a aaa'
t -n abcd -a aaa
echo 't -n abcd -a -z aaa'
t -n abcd -a -z aaa
set +o allexport
echo 't -o allexport'
t -o allexport
echo 't ! -o allexport'
t ! -o allexport
echo 't xx -a yy'
t xx -a yy
echo 't xx -o ""'
t xx -o ""
echo 't xx -a ""'
t xx -a ""
echo 't -X -a -X'
t -X -a -X
echo 't -X -o -X'
t -X -o -X
echo 't -X -o ""'
t -X -o ""
echo 't -X -a ""'
t -X -a ""
echo 't "" -a -X'
t "" -a -X
echo 't "" -o -X'
t "" -o -X
echo 't "" -a ""'
t "" -a ""
echo 't "" -o ""'
t "" -o ""
echo 't true -o -X'
t true -o -X
echo 't true -a -X'
t true -a -X
echo 't ( -E )'
t \( -E \)
echo 't ( "" )'
t \( "" \)
+194
View File
@@ -0,0 +1,194 @@
t -a noexist
1
t -a run-all
0
t -b run-all
1
t -b /dev/jb1a
1
t -c run-all
1
t -c /dev/tty
0
t -d run-all
1
t -d /etc
0
t -e noexist
1
t -e run-all
0
t -f noexist
1
t -f /dev/tty
1
t -f run-all
0
t -g run-all
1
t -g /tmp/test.setgid
0
t -k run-all
1
t -n ""
1
t -n "hello"
0
t -p run-all
1
t -r noexist
1
t -r /tmp/test.noread
1
t -r run-all
0
t -s noexist
1
t -s /dev/null
1
t -s run-all
0
t -t 20
1
t -t 0
0
t -u noexist
1
t -u run-all
1
t -u /tmp/test.setuid
0
t -w noexist
1
t -w /tmp/test.nowrite
1
t -w /dev/null
0
t -x noexist
1
t -x /tmp/test.exec
0
t -x /tmp/test.noexec
1
t -z ""
0
t -z "foo"
1
t "foo"
0
t ""
1
t -O /tmp/test.owner
0
t "hello" = "hello"
0
t "hello" = "goodbye"
1
t "hello" == "hello"
0
t "hello" == "goodbye"
1
t "hello" != "hello"
1
t "hello" != "goodbye"
0
t "hello" < "goodbye"
1
t "hello" > "goodbye"
0
t ! "hello" > "goodbye"
1
t 200 -eq 200
0
t 34 -eq 222
1
t 200 -ne 200
1
t 34 -ne 222
0
t 200 -gt 200
1
t 340 -gt 222
0
t 200 -ge 200
0
t 34 -ge 222
1
t 200 -lt 200
1
t 34 -lt 222
0
t 200 -le 200
0
t 340 -le 222
1
t 700 -le 1000 -a -n "1" -a "20" = "20"
0
t ! \( 700 -le 1000 -a -n "1" -a "20" = "20" \)
1
t /tmp/abc -nt /tmp/def
1
t /tmp/abc -ot /tmp/def
0
t /tmp/def -nt /tmp/abc
0
t /tmp/def -ot /tmp/abc
1
t /tmp/abc -ef /tmp/def
1
t /tmp/abc -ef /tmp/ghi
0
t -r /dev/fd/0
0
t -w /dev/fd/1
0
t -w /dev/fd/2
0
t
1
t 12 -eq 34
1
t ! 12 -eq 34
0
t -n abcd -o aaa
0
t -n abcd -o -z aaa
0
t -n abcd -a aaa
0
t -n abcd -a -z aaa
1
t -o allexport
1
t ! -o allexport
0
t xx -a yy
0
t xx -o ""
0
t xx -a ""
1
t -X -a -X
0
t -X -o -X
0
t -X -o ""
0
t -X -a ""
1
t "" -a -X
1
t "" -o -X
0
t "" -a ""
1
t "" -o ""
1
t true -o -X
0
t true -a -X
0
t ( -E )
0
t ( "" )
1
+28 -5
View File
@@ -1,8 +1,7 @@
HOME=/usr/xyz
set -v
echo ~chet
SHELL=~/bash
echo ~ch\et
echo ~chet/"foo"
echo ~/"foo"
echo "~chet"/"foo"
echo \~chet/"foo"
echo \~chet/bar
@@ -11,6 +10,30 @@ echo ~chet""/bar
echo ":~chet/"
echo abcd~chet
echo "SHELL=~/bash"
echo SHELL=~/bash
echo $SHELL
echo abcd:~chet
echo PATH=/usr/ucb:/bin:~/bin:~/tmp/bin:/usr/bin
path=/usr/ucb:/bin:~/bin:~/tmp/bin:/usr/bin
echo $path
cd /usr
cd /tmp
echo ~-
echo ~+
XPATH=/bin:/usr/bin:.
# yes tilde expansion
PPATH=$XPATH:~/bin
echo "$PPATH"
# no tilde expansion
PPATH="$XPATH:~/bin"
echo "$PPATH"
# yes tilde expansion
export PPATH=$XPATH:~/bin
echo "$PPATH"
# no tilde expansion
export PPATH="$XPATH:~/bin"
echo "$PPATH"
+9 -4
View File
@@ -1,6 +1,5 @@
/usr/homes/chet
~chet
/usr/homes/chet/foo
/usr/xyz/foo
~chet/foo
~chet/foo
~chet/bar
@@ -9,6 +8,12 @@
:~chet/
abcd~chet
SHELL=~/bash
SHELL=/usr/xyz/bash
/usr/xyz/bash
abcd:~chet
PATH=/usr/ucb:/bin:~/bin:~/tmp/bin:/usr/bin
/usr/ucb:/bin:/usr/xyz/bin:/usr/xyz/tmp/bin:/usr/bin
/usr
/tmp
/bin:/usr/bin:.:/usr/xyz/bin
/bin:/usr/bin:.:~/bin
/bin:/usr/bin:.:/usr/xyz/bin
/bin:/usr/bin:.:~/bin
+1
View File
@@ -12,3 +12,4 @@
/a/b/c /a/b/c
1 2
1 1
unset
+11
View File
@@ -92,3 +92,14 @@ echo $c $d
d=$c c=$d
expect "1 1"
echo $c $d
# just for completeness
unset d c
expect unset
echo ${d-unset}
# no output
export a
a=bcde
export a
/bin/true 2>/dev/null