1 # tests for miscellaneous builtins not tested elsewhere
5 ulimit -c 0 2>/dev/null
7 # check that break breaks loops
8 for i in a b c; do echo $i; break; echo bad-$i; done
10 for i in a b c; do echo $i; break 1; echo bad-$i; done
22 # check that break breaks nested loops
33 # check that continue continues loops
34 for i in a b c; do echo $i; continue; echo bad-$i ; done
36 for i in a b c; do echo $i; continue 1; echo bad-$i; done
48 # check that continue breaks out of nested loops
59 # check that `eval' re-evaluates arguments, but `builtin' and `command' do not
69 # test out eval with a temp environment
70 AVAR=bar eval echo \$AVAR
71 BVAR=xxx eval echo $AVAR
80 umask -S u=rwx,g=rwx,o=rx >/dev/null # 002
85 umask ${mask} # restore original mask
87 # builtin/command without arguments should do nothing. maybe someday they will
94 enable -aps ; enable -nps
97 case "$(type -t test)" in
98 builtin) echo oops -- enable -n test failed ;;
99 *) echo enable -n test worked ;;
103 case "$(type -t test)" in
104 builtin) echo enable test worked ;;
105 *) echo oops -- enable test failed ;;
108 # test options to exec
109 (exec -a specialname ${THIS_SH} -c 'echo $0' )
110 # test `clean' environment. if /bin/sh is bash, and the script version of
111 # printenv is run, there will be variables in the environment that bash
113 (export FOO=BAR ; exec -c printenv ) | grep FOO
114 (FOO=BAR exec -c printenv ) | grep FOO
116 (export FOO=BAR ; exec printenv ) | grep FOO
117 (FOO=BAR exec printenv ) | grep FOO
119 # ok, forget everything about hashed commands
128 AVAR=foo . ./source.sub1
136 # make sure source with arguments does not change the shell's positional
137 # parameters, but that the sourced file sees the arguments as its
138 # positional parameters
140 . ./source.sub3 x y z
143 # but if the sourced script sets the positional parameters explicitly, they
144 # should be reflected in the calling shell's positional parameters. this
145 # also tests one of the shopt options that controls source using $PATH to
152 # this is complicated when the sourced scripts gets its own positional
153 # parameters from arguments to `.'
159 # test out cd and $CDPATH
160 ${THIS_SH} ./builtins.sub1
162 # in posix mode, assignment statements preceding special builtins are
163 # reflected in the shell environment. `.' and `eval' need special-case
167 AVAR=foo . ./source.sub1
172 AVAR=foo eval echo \$AVAR
180 # test out kill -l. bash versions prior to 2.01 did `kill -l num' wrong
182 sigone=$(kill -l | sed -n 's:^ 1) *\([^ ]*\)[ ].*$:\1:p')
184 case "$(kill -l 1)" in
185 ${sigone/SIG/}) echo ok;;
186 *) echo oops -- kill -l failure;;
189 # POSIX.2 says that exit statuses > 128 are mapped to signal names by
190 # subtracting 128 so you can find out what signal killed a process
191 case "$(kill -l $(( 128 + 1)) )" in
192 ${sigone/SIG/}) echo ok;;
193 *) echo oops -- kill -l 129 failure;;
196 # out-of-range signal numbers should report the argument in the error
197 # message, not 128 less than the argument
200 # kill -l NAME should return the signal number
201 kill -l ${sigone/SIG/}