Imported from ../bash-2.02.tar.gz.
This commit is contained in:
parent
e8ce775db8
commit
cce855bc5b
323 changed files with 33916 additions and 12321 deletions
|
|
@ -115,3 +115,8 @@ ok
|
|||
7
|
||||
7
|
||||
4
|
||||
32767
|
||||
32768
|
||||
131072
|
||||
2147483647
|
||||
1
|
||||
|
|
|
|||
|
|
@ -213,3 +213,10 @@ do
|
|||
done
|
||||
|
||||
echo $x
|
||||
|
||||
# exponentiation
|
||||
echo $(( 2**15 - 1))
|
||||
echo $(( 2**(16-1)))
|
||||
echo $(( 2**16*2 ))
|
||||
echo $(( 2**31-1))
|
||||
echo $(( 2**0 ))
|
||||
|
|
|
|||
120
tests/array-at-star
Executable file
120
tests/array-at-star
Executable file
|
|
@ -0,0 +1,120 @@
|
|||
# test the expansion of ${array[@]} and ${array[*]}, both quoted and
|
||||
# unquoted. the expansions should be exactly analogous to the
|
||||
# expansions of $@ and $* quoted and unquoted
|
||||
A=(a b)
|
||||
|
||||
recho "${A[*]}"
|
||||
|
||||
# If IFS is null, the parameters are joined without separators
|
||||
IFS=''
|
||||
recho "${A[*]}"
|
||||
|
||||
# If IFS is unset, the parameters are separated by spaces
|
||||
unset IFS
|
||||
recho "${A[*]}"
|
||||
|
||||
recho "${A[@]}"
|
||||
recho ${A[@]}
|
||||
|
||||
IFS='/'
|
||||
A=(bob 'tom dick harry' joe)
|
||||
set ${A[*]}
|
||||
recho $#
|
||||
recho $1
|
||||
recho $2
|
||||
recho $3
|
||||
|
||||
A=(bob 'tom dick harry' joe)
|
||||
set ${A[*]}
|
||||
recho $#
|
||||
recho $1
|
||||
recho $2
|
||||
recho $3
|
||||
|
||||
A=(bob 'tom dick harry' joe)
|
||||
set ${A[@]}
|
||||
recho $#
|
||||
recho $1
|
||||
recho $2
|
||||
recho $3
|
||||
|
||||
A=(bob 'tom dick harry' joe)
|
||||
set ${A[@]}
|
||||
recho $#
|
||||
recho $1
|
||||
recho $2
|
||||
recho $3
|
||||
|
||||
# according to POSIX.2, unquoted $* should expand to multiple words if
|
||||
# $IFS is null, just like unquoted $@
|
||||
IFS=''
|
||||
A=(bob 'tom dick harry' joe)
|
||||
set "${A[*]}"
|
||||
recho $#
|
||||
recho $1
|
||||
recho $2
|
||||
recho $3
|
||||
|
||||
A=(bob 'tom dick harry' joe)
|
||||
set ${A[*]}
|
||||
recho $#
|
||||
recho $1
|
||||
recho $2
|
||||
recho $3
|
||||
|
||||
A=(bob 'tom dick harry' joe)
|
||||
set ${A[@]}
|
||||
recho $#
|
||||
recho $1
|
||||
recho $2
|
||||
recho $3
|
||||
|
||||
# if IFS is unset, the individual positional parameters are split on
|
||||
# " \t\n" if $* or $@ are unquoted
|
||||
unset IFS
|
||||
A=(bob 'tom dick harry' joe)
|
||||
set ${A[*]}
|
||||
recho $#
|
||||
recho $1
|
||||
recho $2
|
||||
recho $3
|
||||
|
||||
A=(bob 'tom dick harry' joe)
|
||||
set ${A[@]}
|
||||
recho $#
|
||||
recho $1
|
||||
recho $2
|
||||
recho $3
|
||||
|
||||
# but not for "$@" or "$*"
|
||||
A=(bob 'tom dick harry' joe)
|
||||
set "${A[*]}"
|
||||
recho $#
|
||||
recho $1
|
||||
recho $2
|
||||
recho $3
|
||||
|
||||
A=(bob 'tom dick harry' joe)
|
||||
set "${A[@]}"
|
||||
recho $#
|
||||
recho $1
|
||||
recho $2
|
||||
recho $3
|
||||
|
||||
# these should both expand the value of A to multiple words
|
||||
A=(a b c d e)
|
||||
IFS=""
|
||||
recho ${A[@]}
|
||||
recho "${A[@]}"
|
||||
|
||||
# this example is straight from the POSIX.2 rationale and adapted to arrays
|
||||
A=(foo bar bam)
|
||||
|
||||
recho "${A[@]}"
|
||||
recho "${A[*]}"
|
||||
|
||||
unset IFS
|
||||
|
||||
recho "${A[@]}"
|
||||
recho ${A[@]}
|
||||
recho "${A[*]}"
|
||||
|
|
@ -22,6 +22,8 @@ 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='()'
|
||||
readonly -a a='([1]="" [2]="bdef" [5]="hello world" [6]="test expression")'
|
||||
readonly -a c='()'
|
||||
./array.tests: declare: e: cannot assign to array variables in this way
|
||||
a test
|
||||
declare -a DIRSTACK='()'
|
||||
|
|
@ -52,6 +54,8 @@ declare -a f='([0]="" [1]="bdef" [2]="hello world" [3]="test" [4]="ninth element
|
|||
./array.tests: declare: c: cannot destroy array variables in this way
|
||||
this of
|
||||
this is a test of read using arrays
|
||||
this test
|
||||
this is a test of arrays
|
||||
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")'
|
||||
|
|
@ -94,4 +98,6 @@ bin
|
|||
grep [ 123 ] *
|
||||
6 7 9
|
||||
6 7 9 5
|
||||
length = 3
|
||||
value = new1 new2 new3
|
||||
./array.tests: narray: unbound variable
|
||||
|
|
|
|||
|
|
@ -62,8 +62,13 @@ echo ${a[@]}
|
|||
|
||||
readonly a[5]
|
||||
readonly a
|
||||
# these two lines should output `declare' commands
|
||||
readonly -a | egrep -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)'
|
||||
declare -ar | egrep -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)'
|
||||
# this line should output `readonly' commands, even for arrays
|
||||
set -o posix
|
||||
readonly -a | egrep -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)'
|
||||
set +o posix
|
||||
|
||||
declare -a d='([1]="" [2]="bdef" [5]="hello world" "test")'
|
||||
d[9]="ninth element"
|
||||
|
|
@ -112,6 +117,15 @@ this is a test of read using arrays
|
|||
echo ${rv[0]} ${rv[4]}
|
||||
echo ${rv[@]}
|
||||
|
||||
# the variable should be converted to an array when `read -a' is done
|
||||
vv=1
|
||||
read -a vv <<!
|
||||
this is a test of arrays
|
||||
!
|
||||
echo ${vv[0]} ${vv[3]}
|
||||
echo ${vv[@]}
|
||||
unset vv
|
||||
|
||||
declare -a | egrep -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)'
|
||||
|
||||
export rv
|
||||
|
|
@ -196,6 +210,13 @@ echo ${iarray[@]}
|
|||
iarray[4]=4+1
|
||||
echo ${iarray[@]}
|
||||
|
||||
# make sure assignment using the compound assignment syntax removes all
|
||||
# of the old elements from the array value
|
||||
barray=(old1 old2 old3 old4 old5)
|
||||
barray=(new1 new2 new3)
|
||||
echo "length = ${#barray[@]}"
|
||||
echo "value = ${barray[*]}"
|
||||
|
||||
# make sure the array code behaves correctly with respect to unset variables
|
||||
set -u
|
||||
( echo ${#narray[4]} )
|
||||
|
|
|
|||
74
tests/array2.right
Normal file
74
tests/array2.right
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
argv[1] = <a b>
|
||||
argv[1] = <ab>
|
||||
argv[1] = <a b>
|
||||
argv[1] = <a>
|
||||
argv[2] = <b>
|
||||
argv[1] = <a>
|
||||
argv[2] = <b>
|
||||
argv[1] = <3>
|
||||
argv[1] = <bob>
|
||||
argv[1] = <tom dick harry>
|
||||
argv[1] = <joe>
|
||||
argv[1] = <3>
|
||||
argv[1] = <bob>
|
||||
argv[1] = <tom dick harry>
|
||||
argv[1] = <joe>
|
||||
argv[1] = <3>
|
||||
argv[1] = <bob>
|
||||
argv[1] = <tom dick harry>
|
||||
argv[1] = <joe>
|
||||
argv[1] = <3>
|
||||
argv[1] = <bob>
|
||||
argv[1] = <tom dick harry>
|
||||
argv[1] = <joe>
|
||||
argv[1] = <1>
|
||||
argv[1] = <bobtom dick harryjoe>
|
||||
argv[1] = <3>
|
||||
argv[1] = <bob>
|
||||
argv[1] = <tom dick harry>
|
||||
argv[1] = <joe>
|
||||
argv[1] = <3>
|
||||
argv[1] = <bob>
|
||||
argv[1] = <tom dick harry>
|
||||
argv[1] = <joe>
|
||||
argv[1] = <5>
|
||||
argv[1] = <bob>
|
||||
argv[1] = <tom>
|
||||
argv[1] = <dick>
|
||||
argv[1] = <5>
|
||||
argv[1] = <bob>
|
||||
argv[1] = <tom>
|
||||
argv[1] = <dick>
|
||||
argv[1] = <1>
|
||||
argv[1] = <bob>
|
||||
argv[2] = <tom>
|
||||
argv[3] = <dick>
|
||||
argv[4] = <harry>
|
||||
argv[5] = <joe>
|
||||
argv[1] = <3>
|
||||
argv[1] = <bob>
|
||||
argv[1] = <tom>
|
||||
argv[2] = <dick>
|
||||
argv[3] = <harry>
|
||||
argv[1] = <joe>
|
||||
argv[1] = <a>
|
||||
argv[2] = <b>
|
||||
argv[3] = <c>
|
||||
argv[4] = <d>
|
||||
argv[5] = <e>
|
||||
argv[1] = <a>
|
||||
argv[2] = <b>
|
||||
argv[3] = <c>
|
||||
argv[4] = <d>
|
||||
argv[5] = <e>
|
||||
argv[1] = <foo>
|
||||
argv[2] = <bar>
|
||||
argv[3] = <bam>
|
||||
argv[1] = <foobarbam>
|
||||
argv[1] = <foo>
|
||||
argv[2] = <bar>
|
||||
argv[3] = <bam>
|
||||
argv[1] = <foo>
|
||||
argv[2] = <bar>
|
||||
argv[3] = <bam>
|
||||
argv[1] = <foo bar bam>
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
alias: 0
|
||||
alias: 0
|
||||
a
|
||||
end-1
|
||||
a
|
||||
|
|
@ -47,6 +49,8 @@ xxx
|
|||
u=rwx,g=rx,o=rx
|
||||
002
|
||||
u=rwx,g=rwx,o=rx
|
||||
umask 002
|
||||
umask -S u=rwx,g=rwx,o=rx
|
||||
u=rwx,g=rwx,o=rwx
|
||||
enable .
|
||||
enable :
|
||||
|
|
@ -81,9 +85,11 @@ enable unset
|
|||
enable -n test worked
|
||||
enable test worked
|
||||
specialname
|
||||
-specialname
|
||||
FOO=BAR
|
||||
FOO=BAR
|
||||
hash: hash table empty
|
||||
0
|
||||
AVAR
|
||||
foo
|
||||
in source.sub2, calling return
|
||||
|
|
@ -99,6 +105,9 @@ m n o p
|
|||
/tmp/bash-dir-a
|
||||
/tmp/bash-dir-a
|
||||
/tmp/bash-dir-a
|
||||
./source5.sub: /tmp/source-notthere: No such file or directory
|
||||
after bad source 1
|
||||
./source5.sub: /tmp/source-notthere: No such file or directory
|
||||
AVAR
|
||||
foo
|
||||
foo
|
||||
|
|
@ -107,7 +116,12 @@ foo
|
|||
foo
|
||||
AVAR
|
||||
foo
|
||||
declare -x foo=""
|
||||
declare -x FOO="\$\$"
|
||||
./builtins.tests: declare: FOO: not found
|
||||
declare -x FOO="\$\$"
|
||||
ok
|
||||
ok
|
||||
./builtins.tests: kill: bad signal number: 4096
|
||||
1
|
||||
./builtins.tests: exit: bad non-numeric arg `status'
|
||||
|
|
|
|||
|
|
@ -4,6 +4,18 @@ set +o posix
|
|||
|
||||
ulimit -c 0 2>/dev/null
|
||||
|
||||
# alias/unalias tests
|
||||
|
||||
unalias -a
|
||||
# this should return success, according to POSIX.2
|
||||
alias
|
||||
echo alias: $?
|
||||
alias foo=bar
|
||||
unalias foo
|
||||
# this had better return success, according to POSIX.2
|
||||
alias
|
||||
echo alias: $?
|
||||
|
||||
# check that break breaks loops
|
||||
for i in a b c; do echo $i; break; echo bad-$i; done
|
||||
echo end-1
|
||||
|
|
@ -80,6 +92,8 @@ umask -S
|
|||
umask -S u=rwx,g=rwx,o=rx >/dev/null # 002
|
||||
umask
|
||||
umask -S
|
||||
umask -p
|
||||
umask -p -S
|
||||
umask 0
|
||||
umask -S
|
||||
umask ${mask} # restore original mask
|
||||
|
|
@ -107,10 +121,11 @@ esac
|
|||
|
||||
# test options to exec
|
||||
(exec -a specialname ${THIS_SH} -c 'echo $0' )
|
||||
(exec -l -a specialname ${THIS_SH} -c 'echo $0' )
|
||||
# test `clean' environment. if /bin/sh is bash, and the script version of
|
||||
# printenv is run, there will be variables in the environment that bash
|
||||
# sets on startup.
|
||||
(export FOO=BAR ; exec -c printenv ) | grep FOO
|
||||
# sets on startup. Also test code that prefixes argv[0] with a dash.
|
||||
(export FOO=BAR ; exec -c -l printenv ) | grep FOO
|
||||
(FOO=BAR exec -c printenv ) | grep FOO
|
||||
|
||||
(export FOO=BAR ; exec printenv ) | grep FOO
|
||||
|
|
@ -120,24 +135,35 @@ esac
|
|||
hash -r
|
||||
hash
|
||||
|
||||
# this had better succeed, since command -p guarantees we will find the
|
||||
# standard utilties
|
||||
command -p hash rm
|
||||
|
||||
# check out source/.
|
||||
|
||||
# sourcing a zero-length-file had better not be an error
|
||||
rm -f /tmp/zero-length-file
|
||||
cp /dev/null /tmp/zero-length-file
|
||||
. /tmp/zero-length-file
|
||||
echo $?
|
||||
rm /tmp/zero-length-file
|
||||
|
||||
AVAR=AVAR
|
||||
|
||||
. ./source.sub1
|
||||
AVAR=foo . ./source.sub1
|
||||
. ./source1.sub
|
||||
AVAR=foo . ./source1.sub
|
||||
|
||||
. ./source.sub2
|
||||
. ./source2.sub
|
||||
echo $?
|
||||
|
||||
set -- a b c
|
||||
. ./source.sub3
|
||||
. ./source3.sub
|
||||
|
||||
# make sure source with arguments does not change the shell's positional
|
||||
# parameters, but that the sourced file sees the arguments as its
|
||||
# positional parameters
|
||||
echo "$@"
|
||||
. ./source.sub3 x y z
|
||||
. ./source3.sub x y z
|
||||
echo "$@"
|
||||
|
||||
# but if the sourced script sets the positional parameters explicitly, they
|
||||
|
|
@ -146,25 +172,28 @@ echo "$@"
|
|||
# find the script
|
||||
echo "$@"
|
||||
shopt -u sourcepath
|
||||
. source.sub4
|
||||
. source4.sub
|
||||
echo "$@"
|
||||
|
||||
# this is complicated when the sourced scripts gets its own positional
|
||||
# parameters from arguments to `.'
|
||||
set -- a b c
|
||||
echo "$@"
|
||||
. source.sub4 x y z
|
||||
. source4.sub x y z
|
||||
echo "$@"
|
||||
|
||||
# test out cd and $CDPATH
|
||||
${THIS_SH} ./builtins.sub1
|
||||
|
||||
# test behavior of `.' when given a non-existant file argument
|
||||
${THIS_SH} ./source5.sub
|
||||
|
||||
# in posix mode, assignment statements preceding special builtins are
|
||||
# reflected in the shell environment. `.' and `eval' need special-case
|
||||
# code.
|
||||
set -o posix
|
||||
echo $AVAR
|
||||
AVAR=foo . ./source.sub1
|
||||
AVAR=foo . ./source1.sub
|
||||
echo $AVAR
|
||||
|
||||
AVAR=AVAR
|
||||
|
|
@ -176,9 +205,26 @@ AVAR=AVAR
|
|||
echo $AVAR
|
||||
AVAR=foo :
|
||||
echo $AVAR
|
||||
set +o posix
|
||||
|
||||
# but assignment statements preceding `export' are always reflected in
|
||||
# the environment
|
||||
foo="" export foo
|
||||
declare -p foo
|
||||
unset foo
|
||||
|
||||
# assignment statements preceding `declare' should be displayed correctly,
|
||||
# but not persist after the command
|
||||
FOO='$$' declare -p FOO
|
||||
declare -p FOO
|
||||
unset FOO
|
||||
|
||||
# except for `declare -x', which should be equivalent to `export'
|
||||
FOO='$$' declare -x FOO
|
||||
declare -p FOO
|
||||
unset FOO
|
||||
|
||||
# test out kill -l. bash versions prior to 2.01 did `kill -l num' wrong
|
||||
set +o posix
|
||||
sigone=$(kill -l | sed -n 's:^ 1) *\([^ ]*\)[ ].*$:\1:p')
|
||||
|
||||
case "$(kill -l 1)" in
|
||||
|
|
@ -186,6 +232,13 @@ ${sigone/SIG/}) echo ok;;
|
|||
*) echo oops -- kill -l failure;;
|
||||
esac
|
||||
|
||||
# kill -l and trap -l should display exactly the same output
|
||||
sigonea=$(trap -l | sed -n 's:^ 1) *\([^ ]*\)[ ].*$:\1:p')
|
||||
|
||||
if [ "$sigone" != "$sigonea" ]; then
|
||||
echo oops -- kill -l and trap -l differ
|
||||
fi
|
||||
|
||||
# POSIX.2 says that exit statuses > 128 are mapped to signal names by
|
||||
# subtracting 128 so you can find out what signal killed a process
|
||||
case "$(kill -l $(( 128 + 1)) )" in
|
||||
|
|
@ -199,3 +252,8 @@ kill -l 4096
|
|||
|
||||
# kill -l NAME should return the signal number
|
||||
kill -l ${sigone/SIG/}
|
||||
|
||||
# this must be last -- it is a fatal error
|
||||
exit status
|
||||
|
||||
echo after bad exit
|
||||
|
|
|
|||
31
tests/cond.right
Normal file
31
tests/cond.right
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
returns: 0
|
||||
returns: 0
|
||||
returns: 1
|
||||
returns: 0
|
||||
returns: 1
|
||||
returns: 0
|
||||
returns: 0
|
||||
returns: 1
|
||||
returns: 1
|
||||
returns: 1
|
||||
returns: 1
|
||||
returns: 0
|
||||
returns: 0
|
||||
returns: 0
|
||||
returns: 1
|
||||
returns: 0
|
||||
returns: 1
|
||||
returns: 0
|
||||
returns: 1
|
||||
returns: 1
|
||||
returns: 0
|
||||
./cond.tests: [[: 4+: syntax error: operand expected (error token is "+")
|
||||
returns: 1
|
||||
returns: 0
|
||||
returns: 0
|
||||
returns: 1
|
||||
returns: 0
|
||||
returns: 0
|
||||
returns: 1
|
||||
returns: 0
|
||||
ok
|
||||
142
tests/cond.tests
Executable file
142
tests/cond.tests
Executable file
|
|
@ -0,0 +1,142 @@
|
|||
#
|
||||
# the test/[ code is tested elsewhere, and the [[...]] just uses the same
|
||||
# code. this tests the special features of [[...]]
|
||||
#
|
||||
TDIR=/usr/homes/chet
|
||||
|
||||
# this one is straight out of the ksh88 book
|
||||
[[ foo > bar && $PWD -ef . ]]
|
||||
echo returns: $?
|
||||
|
||||
# [[ x ]] is equivalent to [[ -n x ]]
|
||||
[[ x ]]
|
||||
echo returns: $?
|
||||
|
||||
# [[ ! x ]] is equivalent to [[ ! -n x ]]
|
||||
[[ ! x ]]
|
||||
echo returns: $?
|
||||
|
||||
# ! binds tighter than test/[ -- it binds to a term, not an expression
|
||||
[[ ! x || x ]]
|
||||
echo returns: $?
|
||||
|
||||
# unset variables don't need to be quoted
|
||||
[[ -n $UNSET ]]
|
||||
echo returns: $?
|
||||
|
||||
[[ -z $UNSET ]]
|
||||
echo returns: $?
|
||||
|
||||
# the ==/= and != operators do pattern matching
|
||||
[[ $TDIR == /usr/homes/* ]]
|
||||
echo returns: $?
|
||||
|
||||
# ...but you can quote any part of the pattern to have it matched as a string
|
||||
[[ $TDIR == /usr/homes/\* ]]
|
||||
echo returns: $?
|
||||
|
||||
[[ $TDIR == '/usr/homes/*' ]]
|
||||
echo returns: $?
|
||||
|
||||
# if the first part of && fails, the second is not executed
|
||||
[[ -n $UNSET && $UNSET == foo ]]
|
||||
echo returns: $?
|
||||
|
||||
[[ -z $UNSET && $UNSET == foo ]]
|
||||
echo returns: $?
|
||||
|
||||
# if the first part of || succeeds, the second is not executed
|
||||
[[ -z $UNSET || -d $PWD ]]
|
||||
echo returns: $?
|
||||
|
||||
# if the rhs were executed, it would be an error
|
||||
[[ -n $TDIR || $HOME -ef ${H*} ]]
|
||||
echo returns: $?
|
||||
|
||||
[[ -n $TDIR && -z $UNSET || $HOME -ef ${H*} ]]
|
||||
echo returns: $?
|
||||
|
||||
# && has a higher parsing precedence than ||
|
||||
[[ -n $TDIR && -n $UNSET || $TDIR -ef . ]]
|
||||
echo returns: $?
|
||||
|
||||
# ...but expressions in parentheses may be used to override precedence rules
|
||||
[[ -n $TDIR || -n $UNSET && $PWD -ef xyz ]]
|
||||
echo returns: $?
|
||||
|
||||
[[ ( -n $TDIR || -n $UNSET ) && $PWD -ef xyz ]]
|
||||
echo returns: $?
|
||||
|
||||
# some arithmetic tests for completeness -- see what happens with missing
|
||||
# operands, bad expressions, makes sure arguments are evaluated as
|
||||
# arithmetic expressions, etc.
|
||||
|
||||
unset IVAR A
|
||||
[[ 7 -gt $IVAR ]]
|
||||
echo returns: $?
|
||||
|
||||
[[ $IVAR -gt 7 ]]
|
||||
echo returns: $?
|
||||
|
||||
IVAR=4
|
||||
[[ $IVAR -gt 7 ]]
|
||||
echo returns: $?
|
||||
|
||||
[[ 7 -eq 4+3 ]]
|
||||
echo returns: $?
|
||||
|
||||
[[ 7 -eq 4+ ]]
|
||||
echo returns: $?
|
||||
|
||||
IVAR=4+3
|
||||
[[ $IVAR -eq 7 ]]
|
||||
echo returns: $?
|
||||
|
||||
A=7
|
||||
[[ $IVAR -eq A ]]
|
||||
echo returns: $?
|
||||
|
||||
unset IVAR A
|
||||
|
||||
# more pattern matching tests
|
||||
|
||||
[[ $filename == *.c ]]
|
||||
echo returns: $?
|
||||
|
||||
filename=patmatch.c
|
||||
|
||||
[[ $filename == *.c ]]
|
||||
echo returns: $?
|
||||
|
||||
# the extended globbing features may be used when matching patterns
|
||||
shopt -s extglob
|
||||
|
||||
arg=-7
|
||||
|
||||
[[ $arg == -+([0-9]) ]]
|
||||
echo returns: $?
|
||||
|
||||
arg=-H
|
||||
|
||||
[[ $arg == -+([0-9]) ]]
|
||||
echo returns: $?
|
||||
|
||||
arg=+4
|
||||
[[ $arg == ++([0-9]) ]]
|
||||
echo returns: $?
|
||||
|
||||
# make sure the null string is never matched if the string is not null
|
||||
STR=file.c
|
||||
PAT=
|
||||
|
||||
if [[ $STR = $PAT ]]; then
|
||||
echo oops
|
||||
fi
|
||||
|
||||
# but that if the string is null, a null pattern is matched correctly
|
||||
STR=
|
||||
PAT=
|
||||
|
||||
if [[ $STR = $PAT ]]; then
|
||||
echo ok
|
||||
fi
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
./dirstack.tests: pushd: no other directory
|
||||
./dirstack.tests: popd: directory stack empty
|
||||
./dirstack.tests: pushd: -m: bad argument
|
||||
pushd: usage: pushd [dir | +N | -N] [-n]
|
||||
./dirstack.tests: popd: -m: bad argument
|
||||
popd: usage: popd [+N | -N] [-n]
|
||||
./dirstack.tests: dirs: -m: bad argument
|
||||
dirs: usage: dirs [-clpv] [+N] [-N]
|
||||
ok
|
||||
/usr /
|
||||
/usr /
|
||||
/usr /
|
||||
/usr /
|
||||
/usr /
|
||||
/
|
||||
/usr /
|
||||
/etc /usr /
|
||||
/etc /usr /
|
||||
/etc /usr /
|
||||
0 /etc
|
||||
1 /usr
|
||||
2 /
|
||||
/usr /etc /
|
||||
/etc /usr /
|
||||
/tmp /etc /usr /
|
||||
/tmp
|
||||
/tmp
|
||||
/usr
|
||||
/usr
|
||||
./dirstack.tests: dirs: 9: bad directory stack index
|
||||
./dirstack.tests: dirs: 9: bad directory stack index
|
||||
./dirstack.tests: pushd: +9: bad directory stack index
|
||||
./dirstack.tests: pushd: -9: bad directory stack index
|
||||
./dirstack.tests: popd: +9: bad directory stack index
|
||||
./dirstack.tests: popd: -9: bad directory stack index
|
||||
/tmp /etc /
|
||||
/tmp /etc /
|
||||
/tmp /etc /
|
||||
/tmp /usr /etc /
|
||||
/tmp
|
||||
/tmp /usr /etc /
|
||||
/tmp /usr /etc /
|
||||
/tmp
|
||||
/tmp /bin /etc /
|
||||
/tmp
|
||||
/tmp /bin /
|
||||
/tmp
|
||||
/bin / /tmp
|
||||
/bin / /tmp
|
||||
/bin
|
||||
/bin
|
||||
119
tests/dollar-at-star
Executable file
119
tests/dollar-at-star
Executable file
|
|
@ -0,0 +1,119 @@
|
|||
# first, let's start with the basics
|
||||
|
||||
recho "$@"
|
||||
recho "$*"
|
||||
|
||||
recho $@
|
||||
recho $*
|
||||
|
||||
set a b
|
||||
|
||||
recho "$*"
|
||||
|
||||
# If IFS is null, the parameters are joined without separators
|
||||
IFS=''
|
||||
recho "$*"
|
||||
|
||||
# If IFS is unset, the parameters are separated by spaces
|
||||
unset IFS
|
||||
recho "${*}"
|
||||
|
||||
recho "$@"
|
||||
recho $@
|
||||
|
||||
IFS='/'
|
||||
set bob 'tom dick harry' joe
|
||||
set $*
|
||||
recho $#
|
||||
recho $1
|
||||
recho $2
|
||||
recho $3
|
||||
|
||||
set bob 'tom dick harry' joe
|
||||
set ${*}
|
||||
recho $#
|
||||
recho $1
|
||||
recho $2
|
||||
recho $3
|
||||
|
||||
set bob 'tom dick harry' joe
|
||||
set $@
|
||||
recho $#
|
||||
recho $1
|
||||
recho $2
|
||||
recho $3
|
||||
|
||||
set bob 'tom dick harry' joe
|
||||
set ${@}
|
||||
recho $#
|
||||
recho $1
|
||||
recho $2
|
||||
recho $3
|
||||
|
||||
# according to POSIX.2, unquoted $* should expand to multiple words if
|
||||
# $IFS is null, just like unquoted $@
|
||||
IFS=''
|
||||
set bob 'tom dick harry' joe
|
||||
set $*
|
||||
recho $#
|
||||
recho $1
|
||||
recho $2
|
||||
recho $3
|
||||
|
||||
set bob 'tom dick harry' joe
|
||||
set $@
|
||||
recho $#
|
||||
recho $1
|
||||
recho $2
|
||||
recho $3
|
||||
|
||||
# if IFS is unset, the individual positional parameters are split on
|
||||
# " \t\n" if $* or $@ are unquoted
|
||||
unset IFS
|
||||
set bob 'tom dick harry' joe
|
||||
set $*
|
||||
recho $#
|
||||
recho $1
|
||||
recho $2
|
||||
recho $3
|
||||
|
||||
set bob 'tom dick harry' joe
|
||||
set $@
|
||||
recho $#
|
||||
recho $1
|
||||
recho $2
|
||||
recho $3
|
||||
|
||||
# but not for "$@" or "$*"
|
||||
set bob 'tom dick harry' joe
|
||||
set "$*"
|
||||
recho $#
|
||||
recho $1
|
||||
recho $2
|
||||
recho $3
|
||||
|
||||
set bob 'tom dick harry' joe
|
||||
set "$@"
|
||||
recho $#
|
||||
recho $1
|
||||
recho $2
|
||||
recho $3
|
||||
|
||||
# POSIX.2 says these should both expand the positional parameters
|
||||
# to multiple words
|
||||
set a b c d e
|
||||
IFS=""
|
||||
recho $@
|
||||
recho "$@"
|
||||
|
||||
# this example is straight from the POSIX.2 rationale
|
||||
set foo bar bam
|
||||
|
||||
recho "$@"
|
||||
recho "$*"
|
||||
|
||||
unset IFS
|
||||
|
||||
recho "$@"
|
||||
recho $@
|
||||
recho "$*"
|
||||
|
|
@ -1 +0,0 @@
|
|||
recho "$@"
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
recho "$*"
|
||||
|
||||
# If IFS is null, the parameters are joined without separators
|
||||
IFS=''
|
||||
recho "$*"
|
||||
|
||||
# If IFS is unset, the parameters are separated by spaces
|
||||
unset IFS
|
||||
recho "${*}"
|
||||
|
|
@ -1,5 +1,73 @@
|
|||
argv[1] = <>
|
||||
argv[1] = <a b>
|
||||
argv[1] = <ab>
|
||||
argv[1] = <a b>
|
||||
argv[1] = <a>
|
||||
argv[2] = <b>
|
||||
argv[1] = <a>
|
||||
argv[2] = <b>
|
||||
argv[1] = <3>
|
||||
argv[1] = <bob>
|
||||
argv[1] = <tom dick harry>
|
||||
argv[1] = <joe>
|
||||
argv[1] = <3>
|
||||
argv[1] = <bob>
|
||||
argv[1] = <tom dick harry>
|
||||
argv[1] = <joe>
|
||||
argv[1] = <3>
|
||||
argv[1] = <bob>
|
||||
argv[1] = <tom dick harry>
|
||||
argv[1] = <joe>
|
||||
argv[1] = <3>
|
||||
argv[1] = <bob>
|
||||
argv[1] = <tom dick harry>
|
||||
argv[1] = <joe>
|
||||
argv[1] = <3>
|
||||
argv[1] = <bob>
|
||||
argv[1] = <tom dick harry>
|
||||
argv[1] = <joe>
|
||||
argv[1] = <3>
|
||||
argv[1] = <bob>
|
||||
argv[1] = <tom dick harry>
|
||||
argv[1] = <joe>
|
||||
argv[1] = <5>
|
||||
argv[1] = <bob>
|
||||
argv[1] = <tom>
|
||||
argv[1] = <dick>
|
||||
argv[1] = <5>
|
||||
argv[1] = <bob>
|
||||
argv[1] = <tom>
|
||||
argv[1] = <dick>
|
||||
argv[1] = <1>
|
||||
argv[1] = <bob>
|
||||
argv[2] = <tom>
|
||||
argv[3] = <dick>
|
||||
argv[4] = <harry>
|
||||
argv[5] = <joe>
|
||||
argv[1] = <3>
|
||||
argv[1] = <bob>
|
||||
argv[1] = <tom>
|
||||
argv[2] = <dick>
|
||||
argv[3] = <harry>
|
||||
argv[1] = <joe>
|
||||
argv[1] = <a>
|
||||
argv[2] = <b>
|
||||
argv[3] = <c>
|
||||
argv[4] = <d>
|
||||
argv[5] = <e>
|
||||
argv[1] = <a>
|
||||
argv[2] = <b>
|
||||
argv[3] = <c>
|
||||
argv[4] = <d>
|
||||
argv[5] = <e>
|
||||
argv[1] = <foo>
|
||||
argv[2] = <bar>
|
||||
argv[3] = <bam>
|
||||
argv[1] = <foobarbam>
|
||||
argv[1] = <foo>
|
||||
argv[2] = <bar>
|
||||
argv[3] = <bam>
|
||||
argv[1] = <foo>
|
||||
argv[2] = <bar>
|
||||
argv[3] = <bam>
|
||||
argv[1] = <foo bar bam>
|
||||
|
|
|
|||
55
tests/dstack.right
Normal file
55
tests/dstack.right
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
./dstack.tests: pushd: /tmp/xxx-notthere: No such file or directory
|
||||
./dstack.tests: pushd: no other directory
|
||||
./dstack.tests: popd: directory stack empty
|
||||
./dstack.tests: pushd: -m: bad argument
|
||||
pushd: usage: pushd [dir | +N | -N] [-n]
|
||||
./dstack.tests: popd: -m: bad argument
|
||||
popd: usage: popd [+N | -N] [-n]
|
||||
./dstack.tests: dirs: -m: bad argument
|
||||
dirs: usage: dirs [-clpv] [+N] [-N]
|
||||
./dstack.tests: dirs: unknown option: 7
|
||||
dirs: usage: dirs [-clpv] [+N] [-N]
|
||||
/
|
||||
ok
|
||||
/usr /
|
||||
/usr /
|
||||
/usr /
|
||||
/usr /
|
||||
/usr /
|
||||
/
|
||||
/usr /
|
||||
/etc /usr /
|
||||
/etc /usr /
|
||||
/etc /usr /
|
||||
0 /etc
|
||||
1 /usr
|
||||
2 /
|
||||
/usr /etc /
|
||||
/etc /usr /
|
||||
/tmp /etc /usr /
|
||||
/tmp
|
||||
/tmp
|
||||
/usr
|
||||
/usr
|
||||
./dstack.tests: dirs: 9: bad directory stack index
|
||||
./dstack.tests: dirs: 9: bad directory stack index
|
||||
./dstack.tests: pushd: +9: bad directory stack index
|
||||
./dstack.tests: pushd: -9: bad directory stack index
|
||||
./dstack.tests: popd: +9: bad directory stack index
|
||||
./dstack.tests: popd: -9: bad directory stack index
|
||||
/tmp /etc /
|
||||
/tmp /etc /
|
||||
/tmp /etc /
|
||||
/tmp /usr /etc /
|
||||
/tmp
|
||||
/tmp /usr /etc /
|
||||
/tmp /usr /etc /
|
||||
/tmp
|
||||
/tmp /bin /etc /
|
||||
/tmp
|
||||
/tmp /bin /
|
||||
/tmp
|
||||
/bin / /tmp
|
||||
/bin / /tmp
|
||||
/bin
|
||||
/bin
|
||||
|
|
@ -1,4 +1,10 @@
|
|||
export LC_ALL=C
|
||||
export LANG=C
|
||||
|
||||
dirs -c
|
||||
# error -- nonexistant directory
|
||||
pushd /tmp/xxx-notthere
|
||||
|
||||
# errors -- empty stack
|
||||
pushd
|
||||
popd
|
||||
|
|
@ -7,6 +13,7 @@ popd
|
|||
pushd -m
|
||||
popd -m
|
||||
dirs -m
|
||||
dirs 7
|
||||
|
||||
MYDIR=$PWD
|
||||
unalias cd 2>/dev/null
|
||||
|
|
@ -14,6 +21,7 @@ unalias cd 2>/dev/null
|
|||
unalias -a
|
||||
|
||||
command cd -P /
|
||||
command pwd -P # better be `/'
|
||||
|
||||
case "$OLDPWD" in
|
||||
$MYDIR) echo ok ;;
|
||||
24
tests/dstack2.right
Normal file
24
tests/dstack2.right
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
expect ~1
|
||||
~1
|
||||
/usr /
|
||||
/tmp /usr /
|
||||
/tmp /usr /
|
||||
these lines should be the same
|
||||
/tmp
|
||||
/tmp /tmp
|
||||
these lines should be the same
|
||||
/usr
|
||||
/usr /usr
|
||||
these lines should be the same
|
||||
/
|
||||
/ /
|
||||
these lines should be the same
|
||||
/tmp
|
||||
/tmp /tmp
|
||||
these lines should be the same
|
||||
/usr
|
||||
/usr /usr
|
||||
1 /usr
|
||||
these lines should be the same
|
||||
/
|
||||
/ /
|
||||
33
tests/dstack2.tests
Normal file
33
tests/dstack2.tests
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
cd /
|
||||
|
||||
echo expect '~1'
|
||||
echo ~1
|
||||
|
||||
pushd /usr
|
||||
pushd /tmp
|
||||
dirs
|
||||
|
||||
echo these lines should be the same
|
||||
dirs +0
|
||||
echo ~0 ${DIRSTACK[0]}
|
||||
echo these lines should be the same
|
||||
dirs +1
|
||||
echo ~1 ${DIRSTACK[1]}
|
||||
echo these lines should be the same
|
||||
dirs +2
|
||||
echo ~2 ${DIRSTACK[2]}
|
||||
|
||||
NDIRS=$(( ${#DIRSTACK[@]} - 1 ))
|
||||
|
||||
echo these lines should be the same
|
||||
dirs -2
|
||||
echo ~-2 ${DIRSTACK[NDIRS-2]}
|
||||
|
||||
echo these lines should be the same
|
||||
dirs -1
|
||||
echo ~-1 ${DIRSTACK[NDIRS-1]}
|
||||
dirs -v -1
|
||||
|
||||
echo these lines should be the same
|
||||
dirs -0
|
||||
echo ~-0 ${DIRSTACK[NDIRS]}
|
||||
|
|
@ -1,15 +1,26 @@
|
|||
./errors.tests: alias: illegal option: -x
|
||||
alias: usage: alias [-p] [name[=value] ... ]
|
||||
./errors.tests: unalias: illegal option: -x
|
||||
unalias: usage: unalias [-a] [name ...]
|
||||
./errors.tests: alias: `hoowah' not found
|
||||
./errors.tests: unalias: `hoowah': not an alias
|
||||
./errors.tests: `1': not a valid identifier
|
||||
declare -fr func
|
||||
./errors.tests: func: readonly function
|
||||
./errors.tests: unset: illegal option: -x
|
||||
unset: usage: unset [-f] [-v] [name ...]
|
||||
./errors.tests: unset: func: cannot unset: readonly function
|
||||
./errors.tests: declare: func: readonly function
|
||||
./errors.tests: unset: XPATH: cannot unset: readonly variable
|
||||
./errors.tests: unset: `/bin/sh': not a valid identifier
|
||||
./errors.tests: unset: cannot simultaneously unset a function and a variable
|
||||
./errors.tests: declare: unknown option: `-z'
|
||||
declare: usage: declare [-afFrxi] [-p] name[=value] ...
|
||||
./errors.tests: declare: `-z': not a valid identifier
|
||||
./errors.tests: declare: `/bin/sh': not a valid identifier
|
||||
./errors.tests: declare: cannot use `-f' to make functions
|
||||
./errors.tests: exec: illegal option: -i
|
||||
exec: usage: exec [-cl] [-a name] file [redirection ...]
|
||||
./errors.tests: export: XPATH: not a function
|
||||
./errors.tests: break: only meaningful in a `for', `while', or `until' loop
|
||||
./errors.tests: continue: only meaningful in a `for', `while', or `until' loop
|
||||
|
|
@ -17,12 +28,17 @@ declare: usage: declare [-afFrxi] [-p] name[=value] ...
|
|||
./errors.tests: shift: too many arguments
|
||||
./errors.tests: let: expression expected
|
||||
./errors.tests: local: can only be used in a function
|
||||
./errors.tests: logout: not login shell: use `exit'
|
||||
./errors.tests: hash: notthere: not found
|
||||
./errors.tests: hash: illegal option: -v
|
||||
hash: usage: hash [-r] [-p pathname] [name ...]
|
||||
./errors.tests: hash: hashing disabled
|
||||
./errors.tests: export: `AA[4]': not a valid identifier
|
||||
./errors.tests: readonly: `AA[4]': not a valid identifier
|
||||
./errors.tests: [-2]: bad array subscript
|
||||
./errors.tests: AA: readonly variable
|
||||
./errors.tests: AA: readonly variable
|
||||
./errors.tests: readonly: ZZZ: cannot assign to array variables in this way
|
||||
./errors.tests: shift: shift count must be <= $#
|
||||
./errors.tests: shift: shift count must be >= 0
|
||||
./errors.tests: shopt: no_such_option: unknown shell option name
|
||||
|
|
@ -30,8 +46,8 @@ declare: usage: declare [-afFrxi] [-p] name[=value] ...
|
|||
./errors.tests: umask: `09' is not an octal number from 000 to 777
|
||||
./errors.tests: umask: bad character in symbolic mode: :
|
||||
./errors.tests: umask: bad symbolic mode operator: :
|
||||
./errors.tests: umask: illegal option: -p
|
||||
umask: usage: umask [-S] [mode]
|
||||
./errors.tests: umask: illegal option: -i
|
||||
umask: usage: umask [-p] [-S] [mode]
|
||||
./errors.tests: VAR: readonly variable
|
||||
./errors.tests: declare: VAR: readonly variable
|
||||
./errors.tests: declare: VAR: readonly variable
|
||||
|
|
@ -41,7 +57,10 @@ umask: usage: umask [-S] [mode]
|
|||
./errors.tests: command substitution: line 1: syntax error near unexpected token `done'
|
||||
./errors.tests: command substitution: line 1: ` for z in 1 2 3; done '
|
||||
./errors.tests: cd: HOME not set
|
||||
./errors.tests: cd: /tmp/xyz.bash: No such file or directory
|
||||
./errors.tests: cd: OLDPWD not set
|
||||
./errors.tests: cd: /bin/sh: Not a directory
|
||||
./errors.tests: cd: /tmp/cd-notthere: No such file or directory
|
||||
./errors.tests: .: filename argument required
|
||||
.: usage: . filename
|
||||
./errors.tests: source: filename argument required
|
||||
|
|
@ -52,12 +71,18 @@ source: usage: source filename
|
|||
./errors.tests: enable: sh: not a shell builtin
|
||||
./errors.tests: enable: bash: not a shell builtin
|
||||
./errors.tests: shopt: cannot set and unset shell options simultaneously
|
||||
./errors.tests: read: illegal option: -t
|
||||
read: usage: read [-r] [-p prompt] [-a array] [-e] [name ...]
|
||||
./errors.tests: read: `/bin/sh': not a valid identifier
|
||||
./errors.tests: VAR: readonly variable
|
||||
./errors.tests: readonly: illegal option: -x
|
||||
readonly: usage: readonly [-anf] [name ...] or readonly -p
|
||||
./errors.tests: eval: illegal option: -i
|
||||
eval: usage: eval [arg ...]
|
||||
./errors.tests: command: illegal option: -i
|
||||
command: usage: command [-pVv] command [arg ...]
|
||||
./errors.tests: /bin/sh + 0: syntax error: operand expected (error token is "/bin/sh + 0")
|
||||
./errors.tests: /bin/sh + 0: syntax error: operand expected (error token is "/bin/sh + 0")
|
||||
./errors.tests: trap: NOSIG: not a signal specification
|
||||
./errors.tests: trap: illegal option: -s
|
||||
trap: usage: trap [arg] [signal_spec ...] or trap -l
|
||||
|
|
@ -70,4 +95,7 @@ trap: usage: trap [arg] [signal_spec ...] or trap -l
|
|||
./errors.tests: fg: no job control
|
||||
./errors.tests: kill: -s requires an argument
|
||||
./errors.tests: kill: bad signal spec `S'
|
||||
./errors.tests: kill: `': not a pid or valid job spec
|
||||
kill: usage: kill [-s sigspec | -n signum | -sigspec] [pid | job]... or kill -l [sigspec]
|
||||
./errors.tests: set: trackall: unknown option name
|
||||
./errors.tests: `!!': not a valid identifier
|
||||
|
|
|
|||
|
|
@ -10,6 +10,15 @@ LC_MESSAGES=C
|
|||
set +e
|
||||
set +o posix
|
||||
|
||||
# various alias/unalias errors
|
||||
|
||||
# at some point, this may mean to `export' an alias, like ksh, but
|
||||
# for now it is an error
|
||||
alias -x foo=barz
|
||||
unalias -x fooaha
|
||||
alias hoowah
|
||||
unalias hoowah
|
||||
|
||||
# the iteration variable must be a valid identifier
|
||||
for 1 in a b c; do echo $1; done
|
||||
|
||||
|
|
@ -26,6 +35,9 @@ func()
|
|||
echo bar
|
||||
}
|
||||
|
||||
# bad option
|
||||
unset -x func
|
||||
|
||||
# cannot unset readonly functions or variables
|
||||
unset -f func
|
||||
# or make them not readonly
|
||||
|
|
@ -39,6 +51,9 @@ unset -v XPATH
|
|||
# cannot unset invalid identifiers
|
||||
unset /bin/sh
|
||||
|
||||
# cannot unset function and variable at the same time
|
||||
unset -f -v SHELL
|
||||
|
||||
# bad option
|
||||
declare -z
|
||||
# cannot declare invalid identifiers
|
||||
|
|
@ -49,6 +64,9 @@ declare /bin/sh
|
|||
# it cannot be used with `declare'
|
||||
declare -f func='() { echo "this is func"; }'
|
||||
|
||||
# bad option to exec -- this should not exit the script
|
||||
exec -i /bin/sh
|
||||
|
||||
# try to export -f something that is not a function -- this should be
|
||||
# an error, not create an `invisible function'
|
||||
export -f XPATH
|
||||
|
|
@ -74,9 +92,15 @@ let
|
|||
# local outside a function is an error
|
||||
local
|
||||
|
||||
# logout of a non-login shell is an error
|
||||
logout
|
||||
|
||||
# try to hash a non-existant command
|
||||
hash notthere
|
||||
|
||||
# bad option to hash, although it may mean `verbose' at some future point
|
||||
hash -v
|
||||
|
||||
# turn off hashing, then try to hash something
|
||||
set +o hashall
|
||||
hash -p ${THIS_SH} ${THIS_SH##*/}
|
||||
|
|
@ -92,6 +116,13 @@ unset AA[-2]
|
|||
declare -r AA
|
||||
AA=( one two three )
|
||||
|
||||
# make sure `readonly -n' doesn't turn off readonly status
|
||||
readonly -n AA
|
||||
AA=(one two three)
|
||||
|
||||
# try to assign a readonly array with bad assignment syntax
|
||||
readonly -a ZZZ=bbb
|
||||
|
||||
# bad counts to `shift'
|
||||
shopt -s shift_verbose
|
||||
shift $(( $# + 5 ))
|
||||
|
|
@ -105,9 +136,9 @@ shopt no_such_option
|
|||
umask 09
|
||||
umask -S u=rwx:g=rwx:o=rx >/dev/null # 002
|
||||
umask -S u:rwx,g:rwx,o:rx >/dev/null # 002
|
||||
# this may behave identically to umask without arguments in the future,
|
||||
# but for now it is an error
|
||||
umask -p
|
||||
|
||||
# at some point, this may mean `invert', but for now it is an error
|
||||
umask -i
|
||||
|
||||
# assignment to a readonly variable in environment
|
||||
VAR=4
|
||||
|
|
@ -129,7 +160,12 @@ for VAR in 1 2 3 ; do echo $VAR; done
|
|||
|
||||
# various `cd' errors
|
||||
( unset HOME ; cd )
|
||||
( unset OLDPWD ; cd - )
|
||||
( HOME=/tmp/xyz.bash ; cd )
|
||||
# errors from cd
|
||||
cd -
|
||||
cd /bin/sh # error - not a directory
|
||||
OLDPWD=/tmp/cd-notthere
|
||||
cd -
|
||||
|
||||
# various `source/.' errors
|
||||
.
|
||||
|
|
@ -147,16 +183,26 @@ enable sh bash
|
|||
# try to set and unset shell options simultaneously
|
||||
shopt -s -u checkhash
|
||||
|
||||
# someday, this may give `read' a timeout, but for now it is an error
|
||||
read -t var < /dev/null
|
||||
|
||||
# try to read into an invalid identifier
|
||||
read /bin/sh < /dev/null
|
||||
|
||||
# try to read into a readonly variable
|
||||
read VAR < /dev/null
|
||||
|
||||
# bad option to readonly/export
|
||||
readonly -x foo
|
||||
|
||||
# someday these may mean something, but for now they're errors
|
||||
eval -i "echo $-"
|
||||
command -i "echo $-"
|
||||
|
||||
# this caused a core dump in bash-2.01 (fixed in bash-2.01.1)
|
||||
eval echo \$[/bin/sh + 0]
|
||||
eval echo '$((/bin/sh + 0))'
|
||||
|
||||
# error to list trap for an unknown signal
|
||||
trap -p NOSIG
|
||||
|
||||
|
|
@ -191,6 +237,13 @@ fg
|
|||
kill -s
|
||||
# bad argument
|
||||
kill -S
|
||||
# null argument
|
||||
kill -INT ''
|
||||
# argument required
|
||||
kill -INT
|
||||
|
||||
# bad shell option names
|
||||
set -o trackall # bash is not ksh
|
||||
|
||||
# this must be last!
|
||||
# in posix mode, a function name must be a valid identifier
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
before execscript.sub: one two three
|
||||
calling execscript.sub
|
||||
before exec1.sub: one two three
|
||||
calling exec1.sub
|
||||
aa bb cc dd ee
|
||||
after execscript.sub with args: 0
|
||||
after exec1.sub with args: 0
|
||||
|
||||
after execscript.sub without args: 0
|
||||
after exec1.sub without args: 0
|
||||
./execscript: notthere: command not found
|
||||
127
|
||||
notthere: notthere: No such file or directory
|
||||
|
|
@ -20,8 +20,8 @@ notthere: notthere: No such file or directory
|
|||
./execscript: .: /dev/null: not a regular file
|
||||
1
|
||||
this is bashenv
|
||||
./execscript.sub3: /tmp/bash-notthere: No such file or directory
|
||||
./execscript.sub3: exec: /tmp/bash-notthere: cannot execute: No such file or directory
|
||||
./exec3.sub: /tmp/bash-notthere: No such file or directory
|
||||
./exec3.sub: exec: /tmp/bash-notthere: cannot execute: No such file or directory
|
||||
126
|
||||
./execscript: notthere: No such file or directory
|
||||
127
|
||||
|
|
@ -34,3 +34,6 @@ this is sh
|
|||
unset
|
||||
ok
|
||||
5
|
||||
./exec5.sub: exec: bash-notthere: not found
|
||||
127
|
||||
this is ohio-state
|
||||
9
tests/exec5.sub
Normal file
9
tests/exec5.sub
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# try exec'ing a command that cannot be found in $PATH
|
||||
shopt -s execfail
|
||||
|
||||
exec bash-notthere
|
||||
# make sure we're still around
|
||||
echo $?
|
||||
|
||||
# now we need to go away, but this should echo 'this is ohio-state'
|
||||
exec -a ohio-state ${THIS_SH} -c 'echo this is $0'
|
||||
|
|
@ -2,12 +2,12 @@ export LC_ALL=C
|
|||
export LANG=C
|
||||
|
||||
set -- one two three
|
||||
echo before execscript.sub: "$@"
|
||||
echo calling execscript.sub
|
||||
./execscript.sub aa bb cc dd ee
|
||||
echo after execscript.sub with args: $?
|
||||
./execscript.sub
|
||||
echo after execscript.sub without args: $?
|
||||
echo before exec1.sub: "$@"
|
||||
echo calling exec1.sub
|
||||
./exec1.sub aa bb cc dd ee
|
||||
echo after exec1.sub with args: $?
|
||||
./exec1.sub
|
||||
echo after exec1.sub without args: $?
|
||||
|
||||
# set up a fixed path so we know notthere will not be found
|
||||
PATH=/usr/bin:/bin:/usr/local/bin:
|
||||
|
|
@ -44,7 +44,7 @@ echo $?
|
|||
# kill two birds with one test -- test out the BASH_ENV code
|
||||
echo echo this is bashenv > /tmp/bashenv
|
||||
export BASH_ENV=/tmp/bashenv
|
||||
${THIS_SH} ./execscript.sub3
|
||||
${THIS_SH} ./exec3.sub
|
||||
rm -f /tmp/bashenv
|
||||
unset BASH_ENV
|
||||
|
||||
|
|
@ -72,7 +72,10 @@ echo ${PATH-unset}
|
|||
|
||||
echo "echo ok" | ${THIS_SH} -t
|
||||
|
||||
${THIS_SH} ./execscript.sub2
|
||||
${THIS_SH} ./exec2.sub
|
||||
echo $?
|
||||
|
||||
${THIS_SH} ./execscript.sub4
|
||||
${THIS_SH} ./exec4.sub
|
||||
|
||||
# try exec'ing a command that cannot be found in $PATH
|
||||
${THIS_SH} ./exec5.sub
|
||||
|
|
|
|||
59
tests/extglob.right
Normal file
59
tests/extglob.right
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
ok 1
|
||||
ok 2
|
||||
ok 3
|
||||
ok 4
|
||||
ok 5
|
||||
ok 6
|
||||
ok 7
|
||||
ok 8
|
||||
ok 9
|
||||
ok 10
|
||||
ok 11
|
||||
ok 12
|
||||
ok 13
|
||||
ok 14
|
||||
ok 15
|
||||
ok 16
|
||||
ok 17
|
||||
ok 18
|
||||
ok 19
|
||||
ok 20
|
||||
ok 21
|
||||
ok 22
|
||||
ok 23
|
||||
ok 24
|
||||
ok 25
|
||||
ok 26
|
||||
ok 27
|
||||
ok 28
|
||||
ok 29
|
||||
ok 30
|
||||
ok 31
|
||||
ok 32
|
||||
ok 33
|
||||
ok 34
|
||||
ok 35
|
||||
ok 36
|
||||
!([*)*
|
||||
+(a|b[)*
|
||||
[a*(]*)z
|
||||
+()c
|
||||
+()x
|
||||
abc
|
||||
+(*)x
|
||||
abc
|
||||
no-file+(a|b)stuff
|
||||
no-file+(a*(c)|b)stuff
|
||||
abd acd
|
||||
acd
|
||||
abd
|
||||
no
|
||||
yes
|
||||
yes
|
||||
1: bcdef
|
||||
2: def
|
||||
3: abcde
|
||||
4: abc
|
||||
5: ef
|
||||
6: ef
|
||||
7: abcdef
|
||||
286
tests/extglob.tests
Normal file
286
tests/extglob.tests
Normal file
|
|
@ -0,0 +1,286 @@
|
|||
# test the ksh-like extended globbing features: [!@*?+](patlist)
|
||||
|
||||
shopt -s extglob
|
||||
|
||||
expect()
|
||||
{
|
||||
echo expect "$@"
|
||||
}
|
||||
|
||||
case "/dev/udp/129.22.8.102/45" in
|
||||
/dev/@(tcp|udp)/*/*) echo ok 1;;
|
||||
*) echo bad 1;;
|
||||
esac
|
||||
|
||||
# valid numbers
|
||||
case 12 in
|
||||
0|[1-9]*([0-9])) echo ok 2;;
|
||||
*) echo bad 2;;
|
||||
esac
|
||||
|
||||
case 12abc in
|
||||
0|[1-9]*([0-9])) echo bad 3;;
|
||||
*) echo ok 3;;
|
||||
esac
|
||||
|
||||
case 1 in
|
||||
0|[1-9]*([0-9])) echo ok 4;;
|
||||
*) echo bad 4;;
|
||||
esac
|
||||
|
||||
# octal numbers
|
||||
case 07 in
|
||||
+([0-7])) echo ok 5;;
|
||||
*) echo bad 5;;
|
||||
esac
|
||||
|
||||
case 0377 in
|
||||
+([0-7])) echo ok 6;;
|
||||
*) echo bad 6;;
|
||||
esac
|
||||
|
||||
case 09 in
|
||||
+([0-7])) echo bad 7;;
|
||||
*) echo ok 7;;
|
||||
esac
|
||||
|
||||
# stuff from korn's book
|
||||
case paragraph in
|
||||
para@(chute|graph)) echo ok 8;;
|
||||
*) echo bad 8;;
|
||||
esac
|
||||
|
||||
case paramour in
|
||||
para@(chute|graph)) echo bad 9;;
|
||||
*) echo ok 9;;
|
||||
esac
|
||||
|
||||
case para991 in
|
||||
para?([345]|99)1) echo ok 10;;
|
||||
*) echo bad 10;;
|
||||
esac
|
||||
|
||||
case para381 in
|
||||
para?([345]|99)1) echo bad 11;;
|
||||
*) echo ok 11;;
|
||||
esac
|
||||
|
||||
case paragraph in
|
||||
para*([0-9])) echo bad 12;;
|
||||
*) echo ok 12;;
|
||||
esac
|
||||
|
||||
case para in
|
||||
para*([0-9])) echo ok 13;;
|
||||
*) echo bad 13;;
|
||||
esac
|
||||
|
||||
case para13829383746592 in
|
||||
para*([0-9])) echo ok 14;;
|
||||
*) echo bad 14;;
|
||||
esac
|
||||
|
||||
case paragraph in
|
||||
para*([0-9])) echo bad 15;;
|
||||
*) echo ok 15;;
|
||||
esac
|
||||
|
||||
case para in
|
||||
para+([0-9])) echo bad 16;;
|
||||
*) echo ok 16;;
|
||||
esac
|
||||
|
||||
case para987346523 in
|
||||
para+([0-9])) echo ok 17;;
|
||||
*) echo bad 17;;
|
||||
esac
|
||||
|
||||
case paragraph in
|
||||
para!(*.[0-9])) echo ok 18;;
|
||||
*) echo bad 18;;
|
||||
esac
|
||||
|
||||
case para.38 in
|
||||
para!(*.[0-9])) echo ok 19;;
|
||||
*) echo bad 19;;
|
||||
esac
|
||||
|
||||
case para.graph in
|
||||
para!(*.[0-9])) echo ok 20;;
|
||||
*) echo bad 20;;
|
||||
esac
|
||||
|
||||
case para39 in
|
||||
para!(*.[0-9])) echo ok 21;;
|
||||
*) echo bad 21;;
|
||||
esac
|
||||
|
||||
# tests derived from those in rosenblatt's korn shell book
|
||||
|
||||
case "" in
|
||||
*(0|1|3|5|7|9)) echo ok 22;;
|
||||
*) echo bad 22;
|
||||
esac
|
||||
|
||||
case 137577991 in
|
||||
*(0|1|3|5|7|9)) echo ok 23;;
|
||||
*) echo bad 23;
|
||||
esac
|
||||
|
||||
case 2468 in
|
||||
*(0|1|3|5|7|9)) echo bad 24;;
|
||||
*) echo ok 24;
|
||||
esac
|
||||
|
||||
case file.c in
|
||||
*.c?(c)) echo ok 25;;
|
||||
*) echo bad 25;;
|
||||
esac
|
||||
|
||||
case file.C in
|
||||
*.c?(c)) echo bad 26;;
|
||||
*) echo ok 26;;
|
||||
esac
|
||||
|
||||
case file.cc in
|
||||
*.c?(c)) echo ok 27;;
|
||||
*) echo bad 27;;
|
||||
esac
|
||||
|
||||
case file.ccc in
|
||||
*.c?(c)) echo bad 28;;
|
||||
*) echo ok 28;;
|
||||
esac
|
||||
|
||||
case parse.y in
|
||||
!(*.c|*.h|Makefile.in|config*|README)) echo ok 29;;
|
||||
*) echo bad 29;;
|
||||
esac
|
||||
|
||||
case shell.c in
|
||||
!(*.c|*.h|Makefile.in|config*|README)) echo bad 30;;
|
||||
*) echo ok 30;;
|
||||
esac
|
||||
|
||||
case Makefile in
|
||||
!(*.c|*.h|Makefile.in|config*|README)) echo ok 31;;
|
||||
*) echo bad 31;;
|
||||
esac
|
||||
|
||||
case "VMS.FILE;1" in
|
||||
*\;[1-9]*([0-9])) echo ok 32;;
|
||||
*) echo bad 32;;
|
||||
esac
|
||||
|
||||
case "VMS.FILE;0" in
|
||||
*\;[1-9]*([0-9])) echo bad 33;;
|
||||
*) echo ok 33;;
|
||||
esac
|
||||
case "VMS.FILE;" in
|
||||
*\;[1-9]*([0-9])) echo bad 34;;
|
||||
*) echo ok 34;;
|
||||
esac
|
||||
case "VMS.FILE;139" in
|
||||
*\;[1-9]*([0-9])) echo ok 35;;
|
||||
*) echo bad 35;;
|
||||
esac
|
||||
case "VMS.FILE;1N" in
|
||||
*\;[1-9]*([0-9])) echo bad 36;;
|
||||
*) echo ok 36;;
|
||||
esac
|
||||
|
||||
# tests derived from the pd-ksh test suite
|
||||
|
||||
MYDIR=$PWD # save where we are
|
||||
|
||||
TESTDIR=/tmp/eglob-test
|
||||
mkdir $TESTDIR
|
||||
builtin cd $TESTDIR || { echo $0: cannot cd to $TESTDIR >&2 ; exit 1; }
|
||||
rm -rf *
|
||||
|
||||
touch abcx abcz bbc
|
||||
expect '!([*)*'
|
||||
echo !([*)*
|
||||
|
||||
expect '+(a|b[)*'
|
||||
echo +(a|b[)*
|
||||
|
||||
expect '[a*(]*z'
|
||||
echo [a*(]*)z
|
||||
|
||||
rm -f abcx abcz bbc
|
||||
|
||||
touch abc
|
||||
|
||||
expect '+()c'
|
||||
echo +()c
|
||||
expect '+()x'
|
||||
echo +()x
|
||||
expect abc
|
||||
echo +(*)c
|
||||
expect '+(*)x'
|
||||
echo +(*)x
|
||||
|
||||
# extended globbing should not be performed on the output of substitutions
|
||||
x='@(*)'
|
||||
expect '@(*)'
|
||||
echo $x
|
||||
|
||||
expect 'no-file+(a|b)stuff'
|
||||
echo no-file+(a|b)stuff
|
||||
expect 'no-file+(a*(c)|b)stuff'
|
||||
echo no-file+(a*(c)|b)stuff
|
||||
|
||||
touch abd acd
|
||||
|
||||
expect 'abd acd'
|
||||
echo a+(b|c)d
|
||||
|
||||
expect 'acd'
|
||||
echo a!(@(b|B))d
|
||||
|
||||
expect 'abd'
|
||||
echo a[b*(foo|bar)]d
|
||||
|
||||
# simple kleene star tests
|
||||
expect no
|
||||
case foo in *(a|b[)) echo yes;; *) echo no;; esac
|
||||
|
||||
expect yes
|
||||
case foo in *(a|b[)|f*) echo yes;; *) echo no;; esac
|
||||
|
||||
# this doesn't work right yet; it is an incorrectly formed pattern
|
||||
expect yes
|
||||
case '*(a|b[)' in *(a|b[)) echo yes;; *) echo no;; esac
|
||||
|
||||
# check extended globbing in pattern removal -- these don't work right yet
|
||||
x=abcdef
|
||||
|
||||
expect '1: bcdef'
|
||||
echo 1: ${x#+(a|abc)}
|
||||
expect '2: def'
|
||||
echo 2: ${x##+(a|abc)}
|
||||
expect '3: abcde'
|
||||
echo 3: ${x%+(def|f)}
|
||||
expect '4: abc'
|
||||
echo 4: ${x%%+(f|def)}
|
||||
|
||||
# these work ok
|
||||
|
||||
expect '5: ef'
|
||||
echo 5: ${x#*(a|b)cd}
|
||||
expect '6: ef'
|
||||
echo 6: "${x#*(a|b)cd}"
|
||||
expect '7: abcdef'
|
||||
echo 7: ${x#"*(a|b)cd"}
|
||||
|
||||
# clean up and exit
|
||||
|
||||
builtin cd /
|
||||
rm -rf $TESTDIR
|
||||
|
||||
# this is for the benefit of pure coverage, so it writes the pcv file
|
||||
# in the right place
|
||||
builtin cd $MYDIR
|
||||
|
||||
exit 0
|
||||
|
|
@ -10,8 +10,8 @@ remaining args: one two three
|
|||
-a specified
|
||||
-b bval specified
|
||||
remaining args: one two three four five six seven eight nine ten eleven twelve
|
||||
./getopts.sub1: option requires an argument -- b
|
||||
Usage: ./getopts.sub1 [-a] [-b value] args
|
||||
./getopts1.sub: option requires an argument -- b
|
||||
Usage: ./getopts1.sub [-a] [-b value] args
|
||||
-a specified
|
||||
-c cval specified
|
||||
-d specified
|
||||
|
|
@ -24,10 +24,10 @@ remaining args: one two three
|
|||
-a specified
|
||||
-b bval specified
|
||||
remaining args: one two three
|
||||
./getopts.sub4: error: option `b' requires an argument
|
||||
Usage: ./getopts.sub4 [-a] [-b value] args
|
||||
./getopts.sub4: error: illegal option character `c'
|
||||
Usage: ./getopts.sub4 [-a] [-b value] args
|
||||
./getopts4.sub: error: option `b' requires an argument
|
||||
Usage: ./getopts4.sub [-a] [-b value] args
|
||||
./getopts4.sub: error: illegal option character `c'
|
||||
Usage: ./getopts4.sub [-a] [-b value] args
|
||||
-a specified
|
||||
remaining args: -b bval one two three
|
||||
OPTERR=0
|
||||
|
|
@ -36,11 +36,11 @@ something else here
|
|||
OPTIND=3
|
||||
getop: OPTERR=1
|
||||
a here
|
||||
./getopts.sub5: illegal option -- c
|
||||
./getopts5.sub: illegal option -- c
|
||||
something else here
|
||||
./getopts.sub5: illegal option -- d
|
||||
./getopts5.sub: illegal option -- d
|
||||
something else here
|
||||
./getopts.sub5: illegal option -- e
|
||||
./getopts5.sub: illegal option -- e
|
||||
something else here
|
||||
getop: OPTIND=5
|
||||
OPTIND=3
|
||||
|
|
@ -52,5 +52,5 @@ remaining args:
|
|||
-a specified
|
||||
remaining args:
|
||||
0
|
||||
./getopts.sub7: getopts: `opt-var': not a valid identifier
|
||||
./getopts7.sub: getopts: `opt-var': not a valid identifier
|
||||
remaining args:
|
||||
|
|
|
|||
|
|
@ -9,30 +9,30 @@ echo $?
|
|||
# used in error messages, but not yet
|
||||
getopts -a opts name
|
||||
|
||||
${THIS_SH} ./getopts.sub1 -a -b bval one two three
|
||||
${THIS_SH} ./getopts1.sub -a -b bval one two three
|
||||
# make sure getopts works when there are more than 9 positional parameters
|
||||
${THIS_SH} ./getopts.sub1 -a -b bval one two three four five six seven eight nine ten eleven twelve
|
||||
${THIS_SH} ./getopts.sub1 -a -b
|
||||
${THIS_SH} ./getopts1.sub -a -b bval one two three four five six seven eight nine ten eleven twelve
|
||||
${THIS_SH} ./getopts1.sub -a -b
|
||||
|
||||
${THIS_SH} ./getopts.sub2 -ad -c cval three four five
|
||||
${THIS_SH} ./getopts2.sub -ad -c cval three four five
|
||||
|
||||
${THIS_SH} ./getopts.sub3
|
||||
${THIS_SH} ./getopts3.sub
|
||||
|
||||
# make sure that `-b bval' and `-bbval' are equivalent
|
||||
${THIS_SH} ./getopts.sub4 -a -b bval one two three
|
||||
${THIS_SH} ./getopts.sub4 -a -bbval one two three
|
||||
${THIS_SH} ./getopts4.sub -a -b bval one two three
|
||||
${THIS_SH} ./getopts4.sub -a -bbval one two three
|
||||
# this tests `silent' error reporting
|
||||
${THIS_SH} ./getopts.sub4 -a -b
|
||||
${THIS_SH} ./getopts.sub4 -a -c
|
||||
${THIS_SH} ./getopts4.sub -a -b
|
||||
${THIS_SH} ./getopts4.sub -a -c
|
||||
|
||||
# make sure that `--' can be used to end the list of options
|
||||
${THIS_SH} ./getopts.sub4 -a -- -b bval one two three
|
||||
${THIS_SH} ./getopts4.sub -a -- -b bval one two three
|
||||
|
||||
${THIS_SH} ./getopts.sub5 -a -c
|
||||
${THIS_SH} ./getopts5.sub -a -c
|
||||
|
||||
${THIS_SH} ./getopts.sub6 -a
|
||||
${THIS_SH} ./getopts.sub6 -a -c
|
||||
${THIS_SH} ./getopts.sub6 -ac
|
||||
${THIS_SH} ./getopts6.sub -a
|
||||
${THIS_SH} ./getopts6.sub -a -c
|
||||
${THIS_SH} ./getopts6.sub -ac
|
||||
echo $? # this should be 2
|
||||
|
||||
${THIS_SH} ./getopts.sub7 -a
|
||||
${THIS_SH} ./getopts7.sub -a
|
||||
|
|
|
|||
|
|
@ -7,6 +7,9 @@ expect()
|
|||
echo expect "$@"
|
||||
}
|
||||
|
||||
# First, a test that bash-2.01.1 fails
|
||||
${THIS_SH} ./glob1.sub
|
||||
|
||||
MYDIR=$PWD # save where we are
|
||||
|
||||
TESTDIR=/tmp/glob-test
|
||||
|
|
@ -14,7 +17,7 @@ mkdir $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
|
||||
touch a b c d abc abd abe bb bcd ca cb dd de Beware
|
||||
mkdir bdir
|
||||
|
||||
# see if `regular' globbing works right
|
||||
|
|
@ -81,7 +84,7 @@ expect '<a-b> <aXb>'
|
|||
recho a[X-]b
|
||||
|
||||
touch .x .y
|
||||
expect '<d> <dd> <de>'
|
||||
expect '<Beware> <d> <dd> <de>'
|
||||
recho [^a-c]*
|
||||
|
||||
# Make sure that filenames with embedded globbing characters are handled
|
||||
|
|
@ -288,6 +291,11 @@ case '-' in
|
|||
[]-]) echo ok 35 ;;
|
||||
esac
|
||||
|
||||
# a backslash should just escape the next character in this context
|
||||
case p in
|
||||
[a-\z]) echo ok 36 ;;
|
||||
esac
|
||||
|
||||
# none of these should output anything
|
||||
|
||||
case abc in
|
||||
|
|
@ -322,6 +330,14 @@ case '[' in
|
|||
[abc) echo bad 8;;
|
||||
esac
|
||||
|
||||
# let's start testing the case-insensitive globbing code
|
||||
recho b*
|
||||
|
||||
shopt -s nocaseglob
|
||||
recho b*
|
||||
|
||||
recho [b]*
|
||||
shopt -u nocaseglob
|
||||
|
||||
# make sure set -f works right
|
||||
set -f
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
foo/bar foobar/bar
|
||||
argv[1] = <a>
|
||||
argv[2] = <abc>
|
||||
argv[3] = <abd>
|
||||
|
|
@ -43,9 +44,10 @@ argv[1] = <abd>
|
|||
argv[2] = <abe>
|
||||
argv[1] = <a-b>
|
||||
argv[2] = <aXb>
|
||||
argv[1] = <d>
|
||||
argv[2] = <dd>
|
||||
argv[3] = <de>
|
||||
argv[1] = <Beware>
|
||||
argv[2] = <d>
|
||||
argv[3] = <dd>
|
||||
argv[4] = <de>
|
||||
argv[1] = <a*b/ooo>
|
||||
argv[1] = <a*b/ooo>
|
||||
no match
|
||||
|
|
@ -91,6 +93,21 @@ ok 32
|
|||
ok 33
|
||||
ok 34
|
||||
ok 35
|
||||
ok 36
|
||||
argv[1] = <b>
|
||||
argv[2] = <bb>
|
||||
argv[3] = <bcd>
|
||||
argv[4] = <bdir>
|
||||
argv[1] = <Beware>
|
||||
argv[2] = <b>
|
||||
argv[3] = <bb>
|
||||
argv[4] = <bcd>
|
||||
argv[5] = <bdir>
|
||||
argv[1] = <Beware>
|
||||
argv[2] = <b>
|
||||
argv[3] = <bb>
|
||||
argv[4] = <bcd>
|
||||
argv[5] = <bdir>
|
||||
argv[1] = <*>
|
||||
argv[1] = <a*b>
|
||||
argv[2] = <a-b>
|
||||
|
|
@ -103,12 +120,13 @@ argv[8] = <ca>
|
|||
argv[9] = <cb>
|
||||
argv[10] = <dd>
|
||||
argv[11] = <man>
|
||||
argv[1] = <abc>
|
||||
argv[2] = <abe>
|
||||
argv[3] = <bdir>
|
||||
argv[4] = <ca>
|
||||
argv[5] = <de>
|
||||
argv[6] = <man>
|
||||
argv[1] = <Beware>
|
||||
argv[2] = <abc>
|
||||
argv[3] = <abe>
|
||||
argv[4] = <bdir>
|
||||
argv[5] = <ca>
|
||||
argv[6] = <de>
|
||||
argv[7] = <man>
|
||||
argv[1] = <*>
|
||||
argv[1] = <man/man1/bash.1>
|
||||
argv[1] = <man/man1/bash.1>
|
||||
|
|
|
|||
14
tests/glob1.sub
Normal file
14
tests/glob1.sub
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# bash-2.01.1 failed this test
|
||||
FN=/tmp/bash-glob.$$
|
||||
mkdir $FN
|
||||
cd $FN
|
||||
mkdir foo
|
||||
mkdir foobar
|
||||
touch foo/bar
|
||||
touch foobar/bar
|
||||
chmod 311 foo foobar
|
||||
echo f*/bar
|
||||
|
||||
chmod 777 foo foobar
|
||||
cd /
|
||||
rm -rf $FN
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
echo $BASH_VERSION
|
||||
./histexp.tests: 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
|
||||
|
|
@ -125,3 +126,4 @@ echo '!!' \!\!
|
|||
!! !!
|
||||
ok 1
|
||||
ok 2
|
||||
ok 3
|
||||
|
|
@ -1,6 +1,9 @@
|
|||
LC_ALL=C
|
||||
LANG=C
|
||||
trap 'rm /tmp/newhistory' 0
|
||||
|
||||
file=bax
|
||||
histchars='!^#' # make sure history comment char is set correctly
|
||||
|
||||
history -c
|
||||
|
||||
|
|
@ -15,6 +18,9 @@ set -o history
|
|||
|
||||
history -p '!!'
|
||||
|
||||
# this should result in a failed history expansion error
|
||||
history -p '!!:z'
|
||||
|
||||
history
|
||||
|
||||
HISTFILE=/tmp/newhistory
|
||||
|
|
@ -110,3 +116,7 @@ var1='ok 2'
|
|||
var2=var1
|
||||
|
||||
echo ${!var2}
|
||||
|
||||
# Bash-2.01[.1] fails this test -- it attempts history expansion after the
|
||||
# history_expansion_char
|
||||
echo ok 3 # !1200
|
||||
|
|
@ -1,3 +1,8 @@
|
|||
./history.tests: history: illegal option: -x
|
||||
history: usage: history [-c] [n] or history -awrn [filename] or history -ps arg [arg...]
|
||||
./history.tests: history: cannot use more than one of -anrw
|
||||
./history.tests: fc: illegal option: -v
|
||||
fc: usage: fc [-e ename] [-nlr] [first] [last] or fc -s [pat=rep] [cmd]
|
||||
1 for i in one two three; do echo $i; done
|
||||
2 /bin/sh -c 'echo this is $0'
|
||||
3 ls
|
||||
|
|
@ -92,6 +97,7 @@ line 2 for history
|
|||
6 HISTFILE=/tmp/newhistory
|
||||
7 echo displaying \$HISTFILE after history -a
|
||||
8 cat $HISTFILE
|
||||
./history.tests: fc: history specification out of range
|
||||
./history.tests: fc: history specification out of range
|
||||
14 set -H
|
||||
15 echo line 2 for history
|
||||
|
|
@ -100,5 +106,7 @@ line 2 for history
|
|||
aa ab ac
|
||||
echo xx xb xc
|
||||
xx xb xc
|
||||
echo 44 48 4c
|
||||
44 48 4c
|
||||
./history.tests: fc: no command found
|
||||
1
|
||||
|
|
|
|||
|
|
@ -1,5 +1,17 @@
|
|||
trap 'rm /tmp/newhistory' 0
|
||||
|
||||
# bad options
|
||||
history -x
|
||||
# cannot use -r and -w at the same time
|
||||
history -r -w /dev/null
|
||||
|
||||
# bad option
|
||||
fc -v
|
||||
|
||||
# all of these should result in an empty history list
|
||||
history -c
|
||||
history -r /dev/null
|
||||
history -n /dev/null
|
||||
history -c
|
||||
|
||||
HISTFILE=history.list
|
||||
|
|
@ -59,6 +71,7 @@ fc -l 4
|
|||
fc -l 4 8
|
||||
|
||||
fc -l 502
|
||||
fc -l one=two three=four 502
|
||||
|
||||
history 4
|
||||
|
||||
|
|
@ -70,6 +83,7 @@ alias r="fc -s"
|
|||
echo aa ab ac
|
||||
|
||||
r a=x
|
||||
r x=4 b=8
|
||||
|
||||
# this had better fail with `no command found'
|
||||
r cc
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
./jobs2.sub: fg: job %1 started without job control
|
||||
fg: 1
|
||||
0
|
||||
./jobs.tests: wait: job control not enabled
|
||||
./jobs.tests: fg: no job control
|
||||
wait-for-pid
|
||||
wait-errors
|
||||
./jobs.tests: wait: `1-1' is not a pid or valid job spec
|
||||
|
|
@ -29,38 +33,44 @@ fg-bg 6
|
|||
fg: usage: fg [job_spec]
|
||||
./jobs.tests: bg: illegal option: -s
|
||||
bg: usage: bg [job_spec]
|
||||
./jobs.tests: disown: illegal option: -r
|
||||
disown: usage: disown [-h] [jobspec ...]
|
||||
./jobs.tests: disown: illegal option: -s
|
||||
disown: usage: disown [-h] [-ar] [jobspec ...]
|
||||
./jobs.tests: disown: %1: no such job
|
||||
./jobs.tests: disown: %2: no such job
|
||||
wait-for-non-child
|
||||
./jobs.tests: wait: pid 1 is not a child of this shell
|
||||
127
|
||||
3 -- 1 2 3 -- 1 - 2 - 3
|
||||
[1] Running sleep 300 &
|
||||
[2]- Running sleep 350 &
|
||||
[3]+ Running sleep 400 &
|
||||
[1] Running sleep 300 &
|
||||
[2]- Running sleep 350 &
|
||||
[3]+ Running sleep 400 &
|
||||
running jobs:
|
||||
[1] Running sleep 300 &
|
||||
[2]- Running sleep 350 &
|
||||
[3]+ Running sleep 400 &
|
||||
[1] Running sleep 300 &
|
||||
[2]- Running sleep 350 &
|
||||
[3]+ Running sleep 400 &
|
||||
./jobs.tests: kill: %4: no such job
|
||||
./jobs.tests: jobs: no such job %4
|
||||
current job:
|
||||
[3]+ Running sleep 400 &
|
||||
previous job:
|
||||
[2]- Running sleep 350 &
|
||||
after kill -STOP
|
||||
running jobs:
|
||||
[1] Running sleep 300 &
|
||||
[3]- Running sleep 400 &
|
||||
[1] Running sleep 300 &
|
||||
[3]- Running sleep 400 &
|
||||
stopped jobs:
|
||||
[2]+ Stopped sleep 350
|
||||
[2]+ Stopped sleep 350
|
||||
after disown
|
||||
[2]+ Stopped sleep 350
|
||||
[3]- Running sleep 400 &
|
||||
[2]+ Stopped sleep 350
|
||||
[3]- Running sleep 400 &
|
||||
running jobs:
|
||||
[3]- Running sleep 400 &
|
||||
[3]- Running sleep 400 &
|
||||
stopped jobs:
|
||||
[2]+ Stopped sleep 350
|
||||
[2]+ Stopped sleep 350
|
||||
after kill -s CONT
|
||||
running jobs:
|
||||
[2]+ Running sleep 350 &
|
||||
[3]- Running sleep 400 &
|
||||
[2]+ Running sleep 350 &
|
||||
[3]- Running sleep 400 &
|
||||
stopped jobs:
|
||||
after kill -STOP, backgrounding %3:
|
||||
[3]+ sleep 400 &
|
||||
|
|
|
|||
|
|
@ -1,6 +1,26 @@
|
|||
# test out %+, jobs -p, and $! agreement in a subshell first
|
||||
${THIS_SH} ./jobs1.sub
|
||||
|
||||
# test out fg/bg failure in a subshell
|
||||
${THIS_SH} ./jobs2.sub
|
||||
|
||||
jobs
|
||||
echo $?
|
||||
|
||||
# should be a job-control-not-enabled error
|
||||
wait %1
|
||||
|
||||
# make sure we can't fg a job started when job control was not active
|
||||
sleep 30 &
|
||||
pid=$!
|
||||
fg %1
|
||||
# make sure the killed processes don't cause a message
|
||||
exec 5>&2
|
||||
exec 2>/dev/null
|
||||
kill -n 9 $pid
|
||||
wait # make sure we reap the processes while stderr is still redirected
|
||||
exec 2>&5
|
||||
|
||||
echo wait-for-pid
|
||||
sleep 10 &
|
||||
wait $!
|
||||
|
|
@ -68,13 +88,17 @@ fg -s %1
|
|||
bg -s %1
|
||||
wait
|
||||
|
||||
# someday this may mean to disown all running jobs, but for now it is
|
||||
# someday this may mean to disown all stopped jobs, but for now it is
|
||||
# an error
|
||||
disown -r
|
||||
disown -s
|
||||
|
||||
# this is an error
|
||||
# this is an error -- the job with the pid that is the value of $! is
|
||||
# retained only until a `wait' is performed
|
||||
disown %1
|
||||
|
||||
# this, however, is an error
|
||||
disown %2
|
||||
|
||||
echo wait-for-non-child
|
||||
wait 1
|
||||
echo $?
|
||||
|
|
@ -93,6 +117,12 @@ jobs -r
|
|||
|
||||
# should be an error
|
||||
kill -n 1 %4
|
||||
# should be an error
|
||||
jobs %4
|
||||
echo current job:
|
||||
jobs %+
|
||||
echo previous job:
|
||||
jobs %-
|
||||
|
||||
kill -STOP %2
|
||||
sleep 5 # give time for the shell to get the stop notification
|
||||
|
|
|
|||
17
tests/jobs1.sub
Normal file
17
tests/jobs1.sub
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# make sure that jobs -p, %+, and $! all agree
|
||||
set -m
|
||||
sleep 60 &
|
||||
|
||||
FN=/tmp/jobs-pid.$$
|
||||
|
||||
pid1=$!
|
||||
jobs -p %+ > $FN
|
||||
pid2=$(< $FN)
|
||||
rm $FN
|
||||
|
||||
if [ $pid1 -ne $pid2 ]; then
|
||||
echo 'oops - $! and jobs -p %+ disagree!'
|
||||
fi
|
||||
|
||||
exec 2>/dev/null
|
||||
kill -9 $pid1
|
||||
13
tests/jobs2.sub
Normal file
13
tests/jobs2.sub
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# make sure fg and bg don't work on jobs started without job control,
|
||||
# even if they are executed when job control is active
|
||||
set +o monitor
|
||||
|
||||
sleep 30 &
|
||||
pid=$!
|
||||
|
||||
set -m
|
||||
fg %1
|
||||
echo fg: $?
|
||||
|
||||
exec 2>/dev/null
|
||||
kill -9 $pid
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
# originally from Mike Haertel
|
||||
foo() { case $1 in a*) ;; *) ;; esac ;}
|
||||
bar() { case $1 in [abc]*) ;; *);; esac ;}
|
||||
baz() { case $1 in xyzzy) ;; *) ;; esac ;}
|
||||
1
tests/misc/run-r2.sh
Executable file
1
tests/misc/run-r2.sh
Executable file
|
|
@ -0,0 +1 @@
|
|||
../../bash ./redir-t2.sh < /etc/passwd
|
||||
|
|
@ -1 +0,0 @@
|
|||
../../bash ./redir.t2.sh < /etc/passwd
|
||||
|
|
@ -71,6 +71,17 @@ argv[3] = <->
|
|||
argv[1] = <xy>
|
||||
argv[1] = <xy>
|
||||
argv[1] = <xy>
|
||||
argv[1] = <xy>
|
||||
argv[1] = <xy>
|
||||
argv[1] = <xy>
|
||||
argv[1] = <>
|
||||
argv[1] = <>
|
||||
argv[1] = <xy>
|
||||
argv[1] = <xy>
|
||||
argv[1] = <xy>
|
||||
argv[1] = <xy>
|
||||
argv[1] = <xy>
|
||||
argv[1] = <xy>
|
||||
argv[1] = <>
|
||||
argv[1] = <>
|
||||
argv[1] = <x>
|
||||
|
|
@ -144,3 +155,40 @@ argv[1] = <hi>
|
|||
argv[2] = <K>
|
||||
argv[3] = <}>
|
||||
argv[1] = <a*>
|
||||
Number of args: 0
|
||||
<${*-x}>: <x>
|
||||
<${@-x}>: <x>
|
||||
Number of args: 1
|
||||
<${*-x}>: <>
|
||||
<${@-x}>: <>
|
||||
Number of args: 2
|
||||
<${*-x}>: < >
|
||||
<${@-x}>: < >
|
||||
argv[1] = <5>
|
||||
argv[1] = <5>
|
||||
argv[1] = <5>
|
||||
argv[1] = <5>
|
||||
argv[1] = <5>
|
||||
argv[1] = <0>
|
||||
argv[1] = <0>
|
||||
argv[1] = <0>
|
||||
argv[1] = <0>
|
||||
argv[1] = <0>
|
||||
argv[1] = <0>
|
||||
argv[1] = <posparams>
|
||||
argv[1] = <posparams>
|
||||
argv[1] = <2>
|
||||
argv[1] = <0>
|
||||
argv[1] = <0>
|
||||
argv[1] = <1>
|
||||
argv[1] = <5>
|
||||
argv[1] = <5>
|
||||
argv[1] = <0>
|
||||
./more-exp.tests: ${#:}: bad substitution
|
||||
./more-exp.tests: ${#/}: bad substitution
|
||||
./more-exp.tests: ${#%}: bad substitution
|
||||
./more-exp.tests: ${#=}: bad substitution
|
||||
./more-exp.tests: ${#+}: bad substitution
|
||||
./more-exp.tests: ${#1xyz}: bad substitution
|
||||
./more-exp.tests: #: %: syntax error: operand expected (error token is "%")
|
||||
argv[1] = <0>
|
||||
|
|
|
|||
|
|
@ -189,6 +189,12 @@ expect '<xy>'
|
|||
recho "x$*y"
|
||||
expect '<xy>'
|
||||
recho "xy$*"
|
||||
expect '<xy>'
|
||||
recho x"$*"y
|
||||
expect '<xy>'
|
||||
recho xy"$*"
|
||||
expect '<xy>'
|
||||
recho "$*"xy
|
||||
expect '<>'
|
||||
recho "$*"
|
||||
expect nothing
|
||||
|
|
@ -196,15 +202,44 @@ recho $*
|
|||
|
||||
unset undef ; set ""
|
||||
|
||||
expect '<>'
|
||||
recho ${undef-"$*"}
|
||||
expect '<xy>'
|
||||
recho ${undef-"x$*y"}
|
||||
expect '<xy>'
|
||||
recho ${undef-"$*xy"}
|
||||
expect '<xy>'
|
||||
recho ${undef-"xy$*"}
|
||||
expect '<xy>'
|
||||
recho ${undef-x"$*"y}
|
||||
expect '<xy>'
|
||||
recho ${undef-xy"$*"}
|
||||
expect '<xy>'
|
||||
recho ${undef-"$*"xy}
|
||||
expect '<>'
|
||||
recho "${undef-$*}"
|
||||
expect nothing
|
||||
recho ${undef-$*}
|
||||
|
||||
expect '<>'
|
||||
recho ${undef-"$zzz"}
|
||||
expect '<x>'
|
||||
recho x${undef-"$zzz"}
|
||||
expect '<x>'
|
||||
recho x${undef-"$@"}
|
||||
expect nothing
|
||||
recho ${undef-"$@"}
|
||||
expect '<x>'
|
||||
recho ${undef-"$zzz"}x
|
||||
expect '<x>'
|
||||
recho ${undef-"$@"}x
|
||||
expect '<x>'
|
||||
recho "$@"x
|
||||
expect '<x>'
|
||||
recho "$zzz"x
|
||||
expect '<^?>'
|
||||
recho ${undef-}
|
||||
expect '<^?>'
|
||||
recho ${undef-""}
|
||||
|
||||
yyy=""
|
||||
|
|
@ -301,3 +336,101 @@ recho ${abc:-G { I } K }
|
|||
# should echo a*
|
||||
unset foo
|
||||
recho "${foo:-"a"}*"
|
||||
|
||||
f ()
|
||||
{
|
||||
echo "Number of args: $#"
|
||||
echo "<\${*-x}>: <${*-x}>"
|
||||
echo "<\${@-x}>: <${@-x}>"
|
||||
}
|
||||
|
||||
f
|
||||
f ''
|
||||
f '' ''
|
||||
|
||||
set 1 2 3 4 5
|
||||
|
||||
expect '<5>'
|
||||
recho ${#}
|
||||
expect '<5>'
|
||||
recho ${#:foo}
|
||||
expect '<5>'
|
||||
recho ${#:-foo}
|
||||
expect '<5>'
|
||||
recho ${#-posparams}
|
||||
expect '<5>'
|
||||
recho ${#:-posparams}
|
||||
|
||||
expect '<0>'
|
||||
recho ${#!}
|
||||
|
||||
expect nothing
|
||||
recho $!
|
||||
expect nothing
|
||||
recho ${!}
|
||||
|
||||
expect nothing
|
||||
recho $8
|
||||
expect nothing
|
||||
recho ${8}
|
||||
|
||||
shift $#
|
||||
|
||||
expect '<0>'
|
||||
recho ${#}
|
||||
expect '<0>'
|
||||
recho ${#:foo}
|
||||
expect '<0>'
|
||||
recho ${#:-foo}
|
||||
expect '<0>'
|
||||
recho ${#-posparams}
|
||||
expect '<0>'
|
||||
recho ${#:-posparams}
|
||||
|
||||
expect '<posparams>'
|
||||
recho ${!-posparams}
|
||||
expect '<posparams>'
|
||||
recho ${!:-posparams}
|
||||
|
||||
expect '<2>'
|
||||
recho ${#-}
|
||||
|
||||
expect '<0>'
|
||||
recho ${#-posparams}
|
||||
|
||||
expect '<0>'
|
||||
recho ${#?:-xyz}
|
||||
|
||||
expect '<1>'
|
||||
recho ${#?}
|
||||
|
||||
set a b c d e
|
||||
|
||||
expect '<5>'
|
||||
recho ${#}
|
||||
expect '<5>'
|
||||
recho ${#?:-xyz}
|
||||
|
||||
shift $#
|
||||
|
||||
expect '<0>'
|
||||
recho ${#:-foo}
|
||||
|
||||
expect a bad substitution error
|
||||
recho ${#:}
|
||||
expect a bad substitution error
|
||||
recho ${#/}
|
||||
expect a bad substitution error
|
||||
recho ${#%}
|
||||
expect a bad substitution error
|
||||
recho ${#=}
|
||||
expect a bad substitution error
|
||||
recho ${#+}
|
||||
expect a bad substitution error
|
||||
recho ${#1xyz}
|
||||
|
||||
expect a math syntax error
|
||||
recho ${#:%}
|
||||
|
||||
expect '<0>'
|
||||
recho ${#:-}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ argv[2] = <->
|
|||
argv[1] = <-abcd>
|
||||
argv[2] = <->
|
||||
argv[1] = <-abcd->
|
||||
argv[1] = <a b c d e>
|
||||
bar foo
|
||||
bar foo
|
||||
bar foo
|
||||
|
|
@ -151,7 +150,10 @@ argv[6] = <uvwyyy>
|
|||
|
||||
this is a test of proc subst
|
||||
this is test 2
|
||||
./new-exp.tests: ${#:-foo}: bad substitution
|
||||
./new-exp2.sub: /tmp/bashtmp.x*: No such file or directory
|
||||
./new-exp2.sub: /tmp/redir-notthere: No such file or directory
|
||||
1
|
||||
argv[1] = <6>
|
||||
./new-exp.tests: ${#:}: bad substitution
|
||||
argv[1] = <'>
|
||||
argv[1] = <">
|
||||
|
|
@ -384,4 +386,8 @@ argv[9] = <z>
|
|||
./new-exp.tests: UNSET: unbound variable
|
||||
./new-exp.tests: UNSET: unbound variable
|
||||
./new-exp.tests: UNSET: unbound variable
|
||||
argv[1] = <5>
|
||||
argv[1] = <#>
|
||||
argv[1] = <#>
|
||||
argv[1] = <>
|
||||
./new-exp.tests: ABXD: parameter unset
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ recho "${HOME:`echo }`}" # should be a math error -- bad substring substitution
|
|||
|
||||
expect unset
|
||||
_ENV=oops
|
||||
x=${_ENV[(_$-=0)+(_=1)-_${-%%*i*}]} # memory leak
|
||||
x=${_ENV[(_$-=0)+(_=1)-_${-%%*i*}]}
|
||||
echo ${x:-unset}
|
||||
|
||||
expect "<$HOME>"
|
||||
|
|
@ -64,13 +64,6 @@ recho -${foo% *}- # should be -abcd -
|
|||
expect '<-abcd->'
|
||||
recho -${foo%% *}- # should be -abcd-
|
||||
|
||||
set a b c d e
|
||||
expect '<a b c d e>'
|
||||
IFS=""
|
||||
recho "$@"
|
||||
IFS='
|
||||
'
|
||||
|
||||
foo=bar
|
||||
expect '<bar foo>'
|
||||
echo -n $foo' ' ; echo foo
|
||||
|
|
@ -237,10 +230,14 @@ echo $abmcde
|
|||
# run process substitution tests in a subshell so that syntax errors
|
||||
# caused by a shell not implementing process substitution (e.g., one
|
||||
# built on a NeXT) will not cause the whole test to exit prematurely
|
||||
${THIS_SH} ./new-exp.sub1
|
||||
${THIS_SH} ./new-exp1.sub
|
||||
|
||||
expect $0: '${#:-foo}: bad substitution'
|
||||
echo ${#:-foo}
|
||||
# run the tests of $(<filename) in a subshell to avoid cluttering up
|
||||
# this script
|
||||
${THIS_SH} ./new-exp2.sub
|
||||
|
||||
expect '<6>'
|
||||
recho ${#:-foo}
|
||||
expect $0: '${#:}: bad substitution'
|
||||
echo ${#:}
|
||||
|
||||
|
|
@ -449,6 +446,15 @@ set -u
|
|||
( recho "${#UNSET}" ; echo after 7)
|
||||
set +u
|
||||
|
||||
RECEIVED="12345"
|
||||
recho "${RECEIVED:$((${#RECEIVED}-1)):1}"
|
||||
RECEIVED="12345#"
|
||||
recho "${RECEIVED:$((${#RECEIVED}-1)):1}"
|
||||
RECEIVED="#"
|
||||
recho "${RECEIVED:$((${#RECEIVED}-1)):1}"
|
||||
RECEIVED=""
|
||||
recho "${RECEIVED:$((${#RECEIVED}-1)):1}"
|
||||
|
||||
# this must be last!
|
||||
expect $0: 'ABXD: parameter unset'
|
||||
recho ${ABXD:?"parameter unset"}
|
||||
|
|
|
|||
36
tests/new-exp2.sub
Normal file
36
tests/new-exp2.sub
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
export LC_ALL=C
|
||||
export LANG=C
|
||||
|
||||
# test out the new $(< filename) code
|
||||
# it should be exactly equivalent to $(cat filename)
|
||||
|
||||
FILENAME=/tmp/bashtmp.x$$
|
||||
|
||||
trap 'rm -f $FILENAME' 0
|
||||
|
||||
cat >$FILENAME << EOF
|
||||
line 1
|
||||
line 2
|
||||
line 3
|
||||
EOF
|
||||
|
||||
LINES1=$(cat $FILENAME)
|
||||
LINES2=$(< $FILENAME)
|
||||
|
||||
if [[ $LINES1 != $LINES2 ]]; then
|
||||
echo 'whoops: $(< filename) failed'
|
||||
fi
|
||||
|
||||
LINES2=$(< /tmp/bashtmp.x*)
|
||||
if [[ $LINES1 != $LINES2 ]]; then
|
||||
echo 'whoops: $(< filename) with glob expansion failed'
|
||||
fi
|
||||
|
||||
# but the glob expansion in the redirection should fail in posix mode
|
||||
set -o posix
|
||||
LINES2=$(< /tmp/bashtmp.x*)
|
||||
set +o posix
|
||||
|
||||
# now see what happens when we try it with a non-existant file
|
||||
LINES3=$(< /tmp/redir-notthere)
|
||||
echo $?
|
||||
|
|
@ -140,6 +140,35 @@ if [ "$OPTIND" != 3 ] || [ "$store" != a ] || [ "$OPTARG" != aoptval ]; then
|
|||
testfail "getopts"
|
||||
fi
|
||||
|
||||
newtest
|
||||
SQUOTE="'"
|
||||
val1=$(set | sed -n 's:^SQUOTE=::p')
|
||||
# if I change the default quoting style for variable values, this must change
|
||||
if [ "$val1" != "''\'''" ]; then
|
||||
testfail "variable quoting 1"
|
||||
fi
|
||||
|
||||
newtest
|
||||
VTILDE='~'
|
||||
val1=$(set | sed -n 's:^VTILDE=::p')
|
||||
if [ "$val1" != "'~'" ]; then
|
||||
testfail "variable quoting 2"
|
||||
fi
|
||||
|
||||
newtest
|
||||
VHASH=ab#cd
|
||||
val1=$(set | sed -n 's:^VHASH=::p')
|
||||
if [ "$val1" != "ab#cd" ]; then
|
||||
testfail "variable quoting 3"
|
||||
fi
|
||||
|
||||
newtest
|
||||
VHASH2=#abcd
|
||||
val1=$(set | sed -n 's:^VHASH2=::p')
|
||||
if [ "$val1" != "'#abcd'" ]; then
|
||||
testfail "variable quoting 4"
|
||||
fi
|
||||
|
||||
if [ $exitval = 0 ]; then
|
||||
echo "All tests passed"
|
||||
else
|
||||
|
|
|
|||
42
tests/posixpat.right
Normal file
42
tests/posixpat.right
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
ok 1
|
||||
ok 2
|
||||
ok 3
|
||||
ok 4
|
||||
ok 5
|
||||
ok 6
|
||||
ok 7
|
||||
ok 8
|
||||
ok 9
|
||||
ok 10
|
||||
ok 11
|
||||
ok 12
|
||||
ok 13
|
||||
ok 14
|
||||
ok 15
|
||||
ok 16
|
||||
ok 17
|
||||
ok 18
|
||||
ok 19
|
||||
ok 20
|
||||
ok 21
|
||||
ok -- space
|
||||
ok -- blank
|
||||
ok 1
|
||||
ok 2
|
||||
ok 3
|
||||
ok 4
|
||||
ok 5
|
||||
ok 6
|
||||
ok 7
|
||||
ok 8
|
||||
ok 9
|
||||
ok 10
|
||||
ok 11
|
||||
ok 12
|
||||
ok 13
|
||||
ok 14
|
||||
ok 15
|
||||
ok 16
|
||||
ok 1
|
||||
ok 2
|
||||
ok 3
|
||||
233
tests/posixpat.tests
Normal file
233
tests/posixpat.tests
Normal file
|
|
@ -0,0 +1,233 @@
|
|||
# A test suite for the POSIX.2 (BRE) pattern matching code
|
||||
LC_ALL=C
|
||||
LANG=C
|
||||
|
||||
# First, test POSIX.2 character classes
|
||||
|
||||
case e in
|
||||
[[:xdigit:]]) echo ok 1;;
|
||||
esac
|
||||
|
||||
case a in
|
||||
[[:alpha:]123]) echo ok 2;;
|
||||
esac
|
||||
|
||||
case 1 in
|
||||
[[:alpha:]123]) echo ok 3;;
|
||||
esac
|
||||
|
||||
case 9 in
|
||||
[![:alpha:]]) echo ok 4;;
|
||||
esac
|
||||
|
||||
# invalid character class expressions are just characters to be matched
|
||||
case a in
|
||||
[:al:]) echo ok 5;;
|
||||
esac
|
||||
|
||||
case a in
|
||||
[[:al:]) echo ok 6;;
|
||||
esac
|
||||
|
||||
case '!' in
|
||||
[abc[:punct:][0-9]) echo ok 7;;
|
||||
esac
|
||||
|
||||
# let's try to match the start of a valid sh identifier
|
||||
case 'PATH' in
|
||||
[_[:alpha:]]*) echo ok 8;;
|
||||
esac
|
||||
|
||||
# let's try to match the first two characters of a valid sh identifier
|
||||
case PATH in
|
||||
[_[:alpha:]][_[:alnum:]]*) echo ok 9;;
|
||||
esac
|
||||
|
||||
# is ^C a cntrl character?
|
||||
case $'\003' in
|
||||
[[:cntrl:]]) echo ok 10;;
|
||||
esac
|
||||
|
||||
# how about A?
|
||||
case A in
|
||||
[[:cntrl:]]) echo oops -- cntrl ;;
|
||||
*) echo ok 11;;
|
||||
esac
|
||||
|
||||
case 9 in
|
||||
[[:digit:]]) echo ok 12;;
|
||||
esac
|
||||
|
||||
case X in
|
||||
[[:digit:]]) echo oops -- digit;;
|
||||
*) echo ok 13;;
|
||||
esac
|
||||
|
||||
case $'\033' in
|
||||
[[:graph:]]) echo oops -- graph;;
|
||||
*) echo ok 14;;
|
||||
esac
|
||||
|
||||
case $'\040' in
|
||||
[[:graph:]]) echo oops -- graph 2;;
|
||||
*) echo ok 15;;
|
||||
esac
|
||||
|
||||
case ' ' in
|
||||
[[:graph:]]) echo oops -- graph 3;;
|
||||
*) echo ok 16;;
|
||||
esac
|
||||
|
||||
case 'aB' in
|
||||
[[:lower:]][[:upper:]]) echo ok 17;;
|
||||
esac
|
||||
|
||||
case $'\040' in
|
||||
[[:print:]]) echo ok 18;;
|
||||
*) echo oops -- print;;
|
||||
esac
|
||||
|
||||
case PS3 in
|
||||
[_[:alpha:]][_[:alnum:]][_[:alnum:]]*) echo ok 19;;
|
||||
esac
|
||||
|
||||
case a in
|
||||
[[:alpha:][:digit:]]) echo ok 20;;
|
||||
*) echo oops - skip brackpat ;;
|
||||
esac
|
||||
|
||||
case a in
|
||||
[[:alpha:]\]) echo oops -- dangling backslash in brackpat ;;
|
||||
*) echo ok 21 ;;
|
||||
esac
|
||||
|
||||
# what's a newline? is it a blank? a space?
|
||||
case $'\n' in
|
||||
[[:blank:]]) echo ok -- blank ;;
|
||||
[[:space:]]) echo ok -- space ;;
|
||||
*) echo oops newline ;;
|
||||
esac
|
||||
|
||||
# OK, what's a tab? is it a blank? a space?
|
||||
case $'\t' in
|
||||
[[:blank:]]) echo ok -- blank ;;
|
||||
[[:space:]]) echo ok -- space ;;
|
||||
*) echo oops newline ;;
|
||||
esac
|
||||
|
||||
# let's check out characters in the ASCII range
|
||||
case $'\377' in
|
||||
[[:ascii:]]) echo oops -- ascii\?;;
|
||||
esac
|
||||
|
||||
case 9 in
|
||||
[1[:alpha:]123]) echo oops 1;;
|
||||
esac
|
||||
|
||||
# however, an unterminated brace expression containing a valid char class
|
||||
# that matches had better fail
|
||||
case a in
|
||||
[[:alpha:]) echo oops 2;;
|
||||
esac
|
||||
|
||||
case $'\b' in
|
||||
[[:graph:]]) echo oops 3;;
|
||||
esac
|
||||
|
||||
case $'\b' in
|
||||
[[:print:]]) echo oops 4;;
|
||||
esac
|
||||
|
||||
case $' ' in
|
||||
[[:punct:]]) echo oops 5;;
|
||||
esac
|
||||
|
||||
# Next, test POSIX.2 collating symbols
|
||||
|
||||
case 'a' in
|
||||
[[.a.]]) echo ok 1;;
|
||||
esac
|
||||
|
||||
case '-' in
|
||||
[[.hyphen.]-9]) echo ok 2;;
|
||||
esac
|
||||
|
||||
case 'p' in
|
||||
[[.a.]-[.z.]]) echo ok 3;;
|
||||
esac
|
||||
|
||||
case '-' in
|
||||
[[.-.]]) echo ok 4;;
|
||||
esac
|
||||
|
||||
case ' ' in
|
||||
[[.space.]]) echo ok 5;;
|
||||
esac
|
||||
|
||||
case ' ' in
|
||||
[[.grave-accent.]]) echo oops - grave;;
|
||||
*) echo ok 6;;
|
||||
esac
|
||||
|
||||
case '4' in
|
||||
[[.-.]-9]) echo ok 7;;
|
||||
esac
|
||||
|
||||
# an invalid collating symbol cannot be the first part of a range
|
||||
case 'c' in
|
||||
[[.yyz.]-[.z.]]) echo oops - yyz;;
|
||||
*) echo ok 8;;
|
||||
esac
|
||||
|
||||
case 'c' in
|
||||
[[.yyz.][.a.]-z]) echo ok 9;;
|
||||
esac
|
||||
|
||||
# but when not part of a range is not an error
|
||||
case 'c' in
|
||||
[[.yyz.][.a.]-[.z.]]) echo ok 10 ;;
|
||||
esac
|
||||
|
||||
case 'p' in
|
||||
[[.a.]-[.Z.]]) echo oops -- bad range ;;
|
||||
*) echo ok 11;;
|
||||
esac
|
||||
|
||||
case p in
|
||||
[[.a.]-[.zz.]p]) echo ok 12;;
|
||||
*) echo oops -- bad range 2;;
|
||||
esac
|
||||
|
||||
case p in
|
||||
[[.aa.]-[.z.]p]) echo ok 13;;
|
||||
*) echo oops -- bad range 3;;
|
||||
esac
|
||||
|
||||
case c in
|
||||
[[.yyz.]cde]) echo ok 14;;
|
||||
esac
|
||||
|
||||
case abc in
|
||||
[[.cb.]a-Za]*) echo ok 15;;
|
||||
esac
|
||||
|
||||
case $'\t' in
|
||||
[[.space.][.tab.][.newline.]]) echo ok 16;;
|
||||
esac
|
||||
|
||||
# and finally, test POSIX.2 equivalence classes
|
||||
|
||||
case "abc" in
|
||||
[[:alpha:]][[=b=]][[:ascii:]]) echo ok 1;;
|
||||
esac
|
||||
|
||||
case "abc" in
|
||||
[[:alpha:]][[=B=]][[:ascii:]]) echo oops -- =B=;;
|
||||
*) echo ok 2 ;;
|
||||
esac
|
||||
|
||||
case a in
|
||||
[[=b=]) echo oops;; # an incomplete equiv class is just a string
|
||||
*) echo ok 3;;
|
||||
esac
|
||||
|
||||
BIN
tests/printf.right
Normal file
BIN
tests/printf.right
Normal file
Binary file not shown.
176
tests/printf.tests
Normal file
176
tests/printf.tests
Normal file
|
|
@ -0,0 +1,176 @@
|
|||
LC_ALL=C
|
||||
|
||||
# these should output error messages -- the format is required
|
||||
printf
|
||||
printf --
|
||||
|
||||
# these should output nothing
|
||||
printf ""
|
||||
printf -- ""
|
||||
|
||||
# this should expand escape sequences in the format string, nothing else
|
||||
printf "\tone\n"
|
||||
|
||||
# this should not cut off output after the \c
|
||||
printf "one\ctwo\n"
|
||||
|
||||
# and unrecognized backslash escapes should have the backslash preserverd
|
||||
printf "4\.2\n"
|
||||
|
||||
printf "no newline " ; printf "now newline\n"
|
||||
|
||||
# %% -> %
|
||||
printf "%%\n"
|
||||
|
||||
# simple character output
|
||||
printf "%c\n" ABCD
|
||||
|
||||
# test simple string output
|
||||
printf "%s\n" unquoted
|
||||
|
||||
# test quoted string output
|
||||
printf "%s %q\n" unquoted quoted
|
||||
printf "%s%10q\n" unquoted quoted
|
||||
|
||||
printf "%q\n" 'this&that'
|
||||
|
||||
# make sure the format string is reused to use up arguments
|
||||
printf "%d " 1 2 3 4 5; printf "\n"
|
||||
|
||||
# make sure that extra format characters get null arguments
|
||||
printf "%s %d %d %d\n" onestring
|
||||
|
||||
printf "%s %d %u %4.2f\n" onestring
|
||||
|
||||
printf -- "--%s %s--\n" 4.2 ''
|
||||
printf -- "--%s %s--\n" 4.2
|
||||
|
||||
# test %b escapes
|
||||
|
||||
# 8 is a non-octal digit, so the `81' should be output
|
||||
printf -- "--%b--\n" '\n\081'
|
||||
|
||||
printf -- "--%b--\n" '\t\0101'
|
||||
printf -- "--%b--\n" '\t\101'
|
||||
|
||||
# these should all display `A7'
|
||||
echo -e "\1017"
|
||||
echo -e "\x0417"
|
||||
|
||||
printf "%b\n" '\01017'
|
||||
printf "%b\n" '\1017'
|
||||
printf "%b\n" '\x0417'
|
||||
|
||||
printf -- "--%b--\n" '\"abcd\"'
|
||||
printf -- "--%b--\n" "\'abcd\'"
|
||||
|
||||
printf -- "--%b--\n" 'a\\x'
|
||||
|
||||
printf -- "--%b--\n" '\x'
|
||||
|
||||
Z1=$(printf -- "%b\n" '\a\b\e\f\r\v')
|
||||
Z2=$'\a\b\e\f\r\v'
|
||||
|
||||
if [ "$Z1" != "$Z2" ]; then
|
||||
echo "whoops: printf %b and $'' differ" >&2
|
||||
fi
|
||||
unset Z1 Z2
|
||||
|
||||
printf -- "--%b--\n" ''
|
||||
printf -- "--%b--\n"
|
||||
|
||||
# the stuff following the \c should be ignored, as well as the rest
|
||||
# of the format string
|
||||
printf -- "--%b--\n" '4.2\c5.4\n'; printf "\n"
|
||||
|
||||
# make sure that a fieldwidth and precision of `*' are handled right
|
||||
printf "%10.8s\n" 4.4BSD
|
||||
printf "%*.*s\n" 10 8 4.4BSD
|
||||
|
||||
printf "%10.8q\n" 4.4BSD
|
||||
printf "%*.*q\n" 10 8 4.4BSD
|
||||
|
||||
printf "%6b\n" 4.4BSD
|
||||
printf "%*b\n" 6 4.4BSD
|
||||
|
||||
# we handle this crap with homemade code in printf.def
|
||||
printf "%10b\n" 4.4BSD
|
||||
printf -- "--%-10b--\n" 4.4BSD
|
||||
printf "%4.2b\n" 4.4BSD
|
||||
printf "%.3b\n" 4.4BSD
|
||||
printf -- "--%-8b--\n" 4.4BSD
|
||||
|
||||
# test numeric conversions -- these four lines should echo identically
|
||||
printf "%d %u %i 0%o 0x%x 0x%X\n" 255 255 255 255 255 255
|
||||
printf "%d %u %i %#o %#x %#X\n" 255 255 255 255 255 255
|
||||
|
||||
printf "%ld %lu %li 0%o 0x%x 0x%X\n" 255 255 255 255 255 255
|
||||
printf "%ld %lu %li %#o %#x %#X\n" 255 255 255 255 255 255
|
||||
|
||||
printf "%10d\n" 42
|
||||
printf "%10d\n" -42
|
||||
|
||||
printf "%*d\n" 10 42
|
||||
printf "%*d\n" 10 -42
|
||||
|
||||
# test some simple floating point formats
|
||||
printf "%4.2f\n" 4.2
|
||||
printf "%#4.2f\n" 4.2
|
||||
printf "%#4.1f\n" 4.2
|
||||
|
||||
printf "%*.*f\n" 4 2 4.2
|
||||
printf "%#*.*f\n" 4 2 4.2
|
||||
printf "%#*.*f\n" 4 1 4.2
|
||||
|
||||
printf "%E\n" 4.2
|
||||
printf "%e\n" 4.2
|
||||
printf "%6.1E\n" 4.2
|
||||
printf "%6.1e\n" 4.2
|
||||
|
||||
printf "%G\n" 4.2
|
||||
printf "%g\n" 4.2
|
||||
printf "%6.2G\n" 4.2
|
||||
printf "%6.2g\n" 4.2
|
||||
|
||||
# test some of the more esoteric features of POSIX.1 printf
|
||||
printf "%d\n" "'string'"
|
||||
printf "%d\n" '"string"'
|
||||
|
||||
printf "%#o\n" "'string'"
|
||||
printf "%#o\n" '"string"'
|
||||
|
||||
printf "%#x\n" "'string'"
|
||||
printf "%#X\n" '"string"'
|
||||
|
||||
printf "%6.2f\n" "'string'"
|
||||
printf "%6.2f\n" '"string"'
|
||||
|
||||
# output from these two lines had better be the same
|
||||
printf -- "--%6.4s--\n" abcdefghijklmnopqrstuvwxyz
|
||||
printf -- "--%6.4b--\n" abcdefghijklmnopqrstuvwxyz
|
||||
|
||||
# and these two also
|
||||
printf -- "--%12.10s--\n" abcdefghijklmnopqrstuvwxyz
|
||||
printf -- "--%12.10b--\n" abcdefghijklmnopqrstuvwxyz
|
||||
|
||||
# error messages
|
||||
|
||||
# this should be an overflow, but error messages vary between systems
|
||||
# printf "%lu\n" 4294967296
|
||||
|
||||
# ...but we cannot use this because some systems (SunOS4, for example),
|
||||
# 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"
|
||||
|
||||
# this caused an infinite loop in older versions of printf
|
||||
printf "%y" 0
|
||||
|
||||
printf "%d\n" GNU
|
||||
printf "%o\n" GNU
|
||||
|
|
@ -9,6 +9,11 @@ a.
|
|||
-\ a b\-
|
||||
-\-a b\-
|
||||
-\ a b\-
|
||||
argv[1] = <^A>
|
||||
argv[1] = <^A>
|
||||
argv[1] = <^?>
|
||||
argv[1] = <^?>
|
||||
argv[1] = <abcd>
|
||||
1: x[A] y[B] z[]
|
||||
1a:
|
||||
2: x[A B]
|
||||
|
|
|
|||
|
|
@ -13,6 +13,18 @@ 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"- )
|
||||
|
||||
# make sure that CTLESC and CTLNUL are passed through correctly
|
||||
echo $'\001' | ( read var ; recho "$var" )
|
||||
echo $'\001' | ( read ; recho "$REPLY" )
|
||||
|
||||
echo $'\177' | ( read var ; recho "$var" )
|
||||
echo $'\177' | ( read ; recho "$REPLY" )
|
||||
|
||||
# make sure a backslash-quoted \\n still disappears from the input when
|
||||
# we're not reading in `raw' mode, and no stray CTLESC chars are left in
|
||||
# the input stream
|
||||
echo $'ab\\\ncd' | ( read ; recho "$REPLY" )
|
||||
|
||||
echo "A B " > /tmp/IN
|
||||
unset x y z
|
||||
read x y z < /tmp/IN
|
||||
|
|
@ -66,4 +78,3 @@ echo " foo" | { IFS=$' \n' ; read line; recho "$line"; }
|
|||
echo " foo" | { IFS=$' \t\n' ; read line; recho "$line"; }
|
||||
|
||||
echo " foo" | { IFS=$':' ; read line; recho "$line"; }
|
||||
|
||||
|
|
|
|||
|
|
@ -8,5 +8,6 @@
|
|||
./rsh.tests: command: restricted: cannot use -p
|
||||
./rsh.tests: set: unknown option: +r
|
||||
set: usage: set [--abefhkmnptuvxBCHP] [-o option] [arg ...]
|
||||
./rsh.tests: set: restricted: unknown option name
|
||||
./rsh.tests: exec: restricted
|
||||
./rsh.tests: after exec
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ fi
|
|||
command -p date
|
||||
|
||||
set +r
|
||||
set +o restricted
|
||||
|
||||
exec /bin/date
|
||||
|
||||
|
|
|
|||
|
|
@ -1,2 +1,4 @@
|
|||
echo "warning: all of these tests will fail if arrays have not" >&2
|
||||
echo "warning: been compiled into the shell" >&2
|
||||
${THIS_SH} ./array.tests > /tmp/xx 2>&1
|
||||
diff /tmp/xx array.right && rm -f /tmp/xx
|
||||
|
|
|
|||
4
tests/run-array2
Normal file
4
tests/run-array2
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
echo "warning: all of these tests will fail if arrays have not" >&2
|
||||
echo "warning: been compiled into the shell" >&2
|
||||
${THIS_SH} ./array-at-star > /tmp/xx 2>&1
|
||||
diff /tmp/xx array2.right && rm -f /tmp/xx
|
||||
7
tests/run-cond
Normal file
7
tests/run-cond
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
echo "warning: all of these tests will fail if the conditional command has not" >&2
|
||||
echo "warning: been compiled into the shell" >&2
|
||||
echo "warning: some of these tests will fail if extended pattern matching has not" >&2
|
||||
echo "warning: been compiled into the shell" >&2
|
||||
|
||||
${THIS_SH} ./cond.tests > /tmp/xx 2>&1
|
||||
diff /tmp/xx cond.right && rm -f /tmp/xx
|
||||
|
|
@ -1,2 +1,5 @@
|
|||
${THIS_SH} ./dirstack.tests > /tmp/xx 2>&1
|
||||
diff /tmp/xx dirstack.right && rm -f /tmp/xx
|
||||
${THIS_SH} ./dstack.tests > /tmp/xx 2>&1
|
||||
diff /tmp/xx dstack.right && rm -f /tmp/xx
|
||||
|
||||
${THIS_SH} ./dstack2.tests > /tmp/xx 2>&1
|
||||
diff /tmp/xx dstack2.right && rm -f /tmp/xx
|
||||
|
|
|
|||
|
|
@ -1,3 +1,2 @@
|
|||
${THIS_SH} ./dollar-star.sh a b > /tmp/xx 2>&1
|
||||
${THIS_SH} ./dollar-at.sh a b >>/tmp/xx 2>&1
|
||||
${THIS_SH} ./dollar-at-star > /tmp/xx 2>&1
|
||||
diff /tmp/xx dollar.right && rm -f /tmp/xx
|
||||
|
|
|
|||
|
|
@ -4,4 +4,4 @@ echo "warning: if the text of the error messages concerning \`notthere' or" >&2
|
|||
echo "warning: \`/tmp/bash-notthere' not being found or \`/' being a directory" >&2
|
||||
echo "warning: produce diff output, please do not consider this a test failure" >&2
|
||||
${THIS_SH} ./execscript > /tmp/xx 2>&1
|
||||
diff /tmp/xx execscript.right && rm -f /tmp/xx
|
||||
diff /tmp/xx exec.right && rm -f /tmp/xx
|
||||
|
|
|
|||
4
tests/run-extglob
Normal file
4
tests/run-extglob
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
PATH=$PATH:`pwd`
|
||||
export PATH
|
||||
${THIS_SH} ./extglob.tests | grep -v '^expect' > /tmp/xx
|
||||
diff /tmp/xx extglob.right && rm -f /tmp/xx
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
echo "warning: all of these tests will fail if history has not been compiled" >&2
|
||||
echo "warning: into the shell" >&2
|
||||
${THIS_SH} ./histexpand.tests > /tmp/xx 2>&1
|
||||
diff /tmp/xx histexpand.right && rm -f /tmp/xx
|
||||
${THIS_SH} ./histexp.tests > /tmp/xx 2>&1
|
||||
diff /tmp/xx histexp.right && rm -f /tmp/xx
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
#
|
||||
# show that IFS is only applied to the result of expansions
|
||||
#
|
||||
${THIS_SH} ifs-test-1.sh > /tmp/xx
|
||||
diff /tmp/xx ./ifs.1.right
|
||||
${THIS_SH} ifs-1.test > /tmp/xx
|
||||
diff /tmp/xx ./ifs-1.right
|
||||
|
||||
${THIS_SH} ifs-test-2.sh > /tmp/xx
|
||||
diff /tmp/xx ./ifs.2.right
|
||||
${THIS_SH} ifs-2.test > /tmp/xx
|
||||
diff /tmp/xx ./ifs-2.right
|
||||
|
||||
${THIS_SH} ifs-test-3.sh > /tmp/xx
|
||||
diff /tmp/xx ./ifs.3.right
|
||||
${THIS_SH} ifs-3.test > /tmp/xx
|
||||
diff /tmp/xx ./ifs-3.right
|
||||
|
||||
rm -f /tmp/xx
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ do
|
|||
*.orig|*~) ;;
|
||||
run-dollars|run-execscript|run-func|run-getopts|run-heredoc) echo $x ; sh $x ;;
|
||||
run-ifs-tests|run-input-test|run-more-exp|run-nquote|run-posix2) echo $x ; sh $x ;;
|
||||
run-posixpat) echo $x ; sh $x ;;
|
||||
run-precedence|run-quote|run-read|run-rhs-exp|run-strip|run-tilde) echo $x ; sh $x ;;
|
||||
*) ;;
|
||||
esac
|
||||
|
|
|
|||
|
|
@ -1,2 +1,7 @@
|
|||
echo "warning: two of these tests will fail if your OS does not support" >&2
|
||||
echo "warning: named pipes or the /dev/fd filesystem. If the tests of the" >&2
|
||||
echo "warning: process substitution mechanism fail, please do not consider" >&2
|
||||
echo "warning: this a test failure" >&2
|
||||
|
||||
${THIS_SH} ./new-exp.tests 2>&1 | grep -v '^expect' > /tmp/xx
|
||||
diff /tmp/xx new-exp.right && rm -f /tmp/xx
|
||||
|
|
|
|||
2
tests/run-posixpat
Normal file
2
tests/run-posixpat
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
${THIS_SH} ./posixpat.tests > /tmp/xx
|
||||
diff /tmp/xx posixpat.right && rm -f /tmp/xx
|
||||
2
tests/run-printf
Normal file
2
tests/run-printf
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
${THIS_SH} ./printf.tests > /tmp/xx 2>&1
|
||||
diff /tmp/xx printf.right && rm -f /tmp/xx
|
||||
2
tests/run-shopt
Normal file
2
tests/run-shopt
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
${THIS_SH} ./shopt.tests > /tmp/xx 2>&1
|
||||
diff /tmp/xx shopt.right && rm -f /tmp/xx
|
||||
|
|
@ -1,2 +1,6 @@
|
|||
echo "warning: UNIX versions number signals differently. If output differing" >&2
|
||||
echo "warning: only in line numbers is produced, please do not consider this" >&2
|
||||
echo "warning: a test failure." >&2
|
||||
|
||||
${THIS_SH} ./trap.tests > /tmp/xx 2>&1
|
||||
diff /tmp/xx trap.right && rm -f /tmp/xx
|
||||
|
|
|
|||
189
tests/shopt.right
Normal file
189
tests/shopt.right
Normal file
|
|
@ -0,0 +1,189 @@
|
|||
./shopt.tests: shopt: illegal option: -z
|
||||
shopt: usage: shopt [-pqsu] [-o long-option] optname [optname...]
|
||||
--
|
||||
shopt -u cdable_vars
|
||||
shopt -s cdspell
|
||||
shopt -u checkhash
|
||||
shopt -u checkwinsize
|
||||
shopt -s cmdhist
|
||||
shopt -u dotglob
|
||||
shopt -u execfail
|
||||
shopt -s expand_aliases
|
||||
shopt -u extglob
|
||||
shopt -u histreedit
|
||||
shopt -u histappend
|
||||
shopt -u histverify
|
||||
shopt -s hostcomplete
|
||||
shopt -u huponexit
|
||||
shopt -s interactive_comments
|
||||
shopt -u lithist
|
||||
shopt -u mailwarn
|
||||
shopt -u nocaseglob
|
||||
shopt -u nullglob
|
||||
shopt -s promptvars
|
||||
shopt -u shift_verbose
|
||||
shopt -s sourcepath
|
||||
--
|
||||
shopt -u huponexit
|
||||
shopt -u checkwinsize
|
||||
shopt -s sourcepath
|
||||
--
|
||||
shopt -s cdspell
|
||||
shopt -s cmdhist
|
||||
shopt -s expand_aliases
|
||||
shopt -s hostcomplete
|
||||
shopt -s interactive_comments
|
||||
shopt -s promptvars
|
||||
shopt -s sourcepath
|
||||
--
|
||||
shopt -u cdable_vars
|
||||
shopt -u checkhash
|
||||
shopt -u checkwinsize
|
||||
shopt -u dotglob
|
||||
shopt -u execfail
|
||||
shopt -u extglob
|
||||
shopt -u histreedit
|
||||
shopt -u histappend
|
||||
shopt -u histverify
|
||||
shopt -u huponexit
|
||||
shopt -u lithist
|
||||
shopt -u mailwarn
|
||||
shopt -u nocaseglob
|
||||
shopt -u nullglob
|
||||
shopt -u shift_verbose
|
||||
--
|
||||
cdable_vars off
|
||||
checkhash off
|
||||
checkwinsize off
|
||||
dotglob off
|
||||
execfail off
|
||||
extglob off
|
||||
histreedit off
|
||||
histappend off
|
||||
histverify off
|
||||
huponexit off
|
||||
lithist off
|
||||
mailwarn off
|
||||
nocaseglob off
|
||||
nullglob off
|
||||
shift_verbose off
|
||||
--
|
||||
set +o allexport
|
||||
set -o braceexpand
|
||||
set +o errexit
|
||||
set -o hashall
|
||||
set -o histexpand
|
||||
set +o keyword
|
||||
set -o monitor
|
||||
set +o noclobber
|
||||
set +o noexec
|
||||
set +o noglob
|
||||
set +o notify
|
||||
set +o nounset
|
||||
set +o onecmd
|
||||
set +o physical
|
||||
set -o privileged
|
||||
set +o verbose
|
||||
set +o xtrace
|
||||
set -o history
|
||||
set +o ignoreeof
|
||||
set +o interactive-comments
|
||||
set +o posix
|
||||
set -o emacs
|
||||
set +o vi
|
||||
--
|
||||
allexport off
|
||||
braceexpand on
|
||||
errexit off
|
||||
hashall on
|
||||
histexpand on
|
||||
keyword off
|
||||
monitor on
|
||||
noclobber off
|
||||
noexec off
|
||||
noglob off
|
||||
notify off
|
||||
nounset off
|
||||
onecmd off
|
||||
physical off
|
||||
privileged on
|
||||
verbose off
|
||||
xtrace off
|
||||
history on
|
||||
ignoreeof off
|
||||
interactive-comments off
|
||||
posix off
|
||||
emacs on
|
||||
vi off
|
||||
--
|
||||
set +o allexport
|
||||
set -o braceexpand
|
||||
set +o errexit
|
||||
set -o hashall
|
||||
set -o histexpand
|
||||
set +o keyword
|
||||
set -o monitor
|
||||
set +o noclobber
|
||||
set +o noexec
|
||||
set +o noglob
|
||||
set +o notify
|
||||
set +o nounset
|
||||
set +o onecmd
|
||||
set +o physical
|
||||
set -o privileged
|
||||
set +o verbose
|
||||
set +o xtrace
|
||||
set -o history
|
||||
set +o ignoreeof
|
||||
set +o interactive-comments
|
||||
set +o posix
|
||||
set -o emacs
|
||||
set +o vi
|
||||
--
|
||||
set -o history
|
||||
set +o verbose
|
||||
--
|
||||
set -o braceexpand
|
||||
set -o hashall
|
||||
set -o histexpand
|
||||
set -o monitor
|
||||
set -o privileged
|
||||
set -o history
|
||||
set -o emacs
|
||||
--
|
||||
set +o allexport
|
||||
set +o errexit
|
||||
set +o keyword
|
||||
set +o noclobber
|
||||
set +o noexec
|
||||
set +o noglob
|
||||
set +o notify
|
||||
set +o nounset
|
||||
set +o onecmd
|
||||
set +o physical
|
||||
set +o verbose
|
||||
set +o xtrace
|
||||
set +o ignoreeof
|
||||
set +o interactive-comments
|
||||
set +o posix
|
||||
set +o vi
|
||||
--
|
||||
allexport off
|
||||
errexit off
|
||||
keyword off
|
||||
noclobber off
|
||||
noexec off
|
||||
noglob off
|
||||
notify off
|
||||
nounset off
|
||||
onecmd off
|
||||
physical off
|
||||
verbose off
|
||||
xtrace off
|
||||
ignoreeof off
|
||||
interactive-comments off
|
||||
posix off
|
||||
vi off
|
||||
--
|
||||
./shopt.tests: shopt: xyz1: unknown shell option name
|
||||
./shopt.tests: shopt: xyz1: unknown option name
|
||||
93
tests/shopt.tests
Normal file
93
tests/shopt.tests
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
# let's try an error message first
|
||||
shopt -z
|
||||
|
||||
# first, set up a known environment
|
||||
shopt -u cdable_vars
|
||||
shopt -s cdspell
|
||||
shopt -u checkhash
|
||||
shopt -u checkwinsize
|
||||
shopt -s cmdhist
|
||||
shopt -u dotglob
|
||||
shopt -u execfail
|
||||
shopt -s expand_aliases
|
||||
shopt -u extglob
|
||||
shopt -u histreedit
|
||||
shopt -u histappend
|
||||
shopt -u histverify
|
||||
shopt -s hostcomplete
|
||||
shopt -u huponexit
|
||||
shopt -s interactive_comments
|
||||
shopt -u lithist
|
||||
shopt -u mailwarn
|
||||
shopt -u nocaseglob
|
||||
shopt -u nullglob
|
||||
shopt -s promptvars
|
||||
shopt -u shift_verbose
|
||||
shopt -s sourcepath
|
||||
|
||||
# Now, start checking the output
|
||||
builtin printf -- "--\n"
|
||||
shopt -p # list 'em all
|
||||
builtin printf -- "--\n"
|
||||
# test specific variables
|
||||
shopt -p huponexit
|
||||
shopt -p checkwinsize
|
||||
shopt -p sourcepath
|
||||
|
||||
builtin printf -- "--\n"
|
||||
shopt -s -p
|
||||
builtin printf -- "--\n"
|
||||
shopt -u -p
|
||||
builtin printf -- "--\n"
|
||||
shopt -u
|
||||
|
||||
# Now set up another known environment
|
||||
set +o allexport
|
||||
set -o braceexpand
|
||||
set +o errexit
|
||||
set -o hashall
|
||||
set -o histexpand
|
||||
set +o keyword
|
||||
set -o monitor
|
||||
set +o noclobber
|
||||
set +o noexec
|
||||
set +o noglob
|
||||
set +o notify
|
||||
set +o nounset
|
||||
set +o onecmd
|
||||
set +o physical
|
||||
set -o privileged
|
||||
set +o verbose
|
||||
set +o xtrace
|
||||
set -o history
|
||||
set +o ignoreeof
|
||||
set -o interactive-comments
|
||||
set +o posix
|
||||
set -o emacs
|
||||
set +o vi
|
||||
|
||||
# list 'em all
|
||||
builtin printf -- "--\n"
|
||||
shopt -o -p
|
||||
|
||||
builtin printf -- "--\n"
|
||||
set -o
|
||||
builtin printf -- "--\n"
|
||||
set +o
|
||||
|
||||
# test specific variables
|
||||
builtin printf -- "--\n"
|
||||
shopt -p -o history
|
||||
shopt -p -o verbose
|
||||
|
||||
builtin printf -- "--\n"
|
||||
shopt -s -p -o
|
||||
builtin printf -- "--\n"
|
||||
shopt -u -p -o
|
||||
builtin printf -- "--\n"
|
||||
shopt -u -o
|
||||
|
||||
# errors
|
||||
builtin printf -- "--\n"
|
||||
shopt -p xyz1
|
||||
shopt -o -p xyz1
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue