1 # These should all be safe
7 # these tests should all generate errors
9 # make sure we don't exit prematurely
13 # various alias/unalias errors
15 # at some point, this may mean to `export' an alias, like ksh, but
16 # for now it is an error
22 # the iteration variable must be a valid identifier
23 for 1 in a b c; do echo $1; done
25 # try to rebind a read-only function
31 # make sure `readonly' and `declare' play well together
41 # cannot unset readonly functions or variables
43 # or make them not readonly
51 # cannot unset invalid identifiers
54 # cannot unset function and variable at the same time
59 # cannot declare invalid identifiers
63 # this is the syntax used to export functions in the environment, but
64 # it cannot be used with `declare'
65 declare -f func='() { echo "this is func"; }'
67 # bad option to exec -- this should not exit the script
70 # try to export -f something that is not a function -- this should be
71 # an error, not create an `invisible function'
74 # this depends on the setting of BREAK_COMPLAINS in config.h.in
78 # this should not exit the shell; it did in versions before 2.01
81 # other shells do not complain about the extra arguments; maybe someday
85 # and get rid of the positional parameters
88 # let without an expression is an error, though maybe it should just return
92 # local outside a function is an error
95 # logout of a non-login shell is an error
98 # try to hash a non-existant command
101 # bad option to hash, although it may mean `verbose' at some future point
104 # turn off hashing, then try to hash something
106 hash -p ${THIS_SH} ${THIS_SH##*/}
108 # bad identifiers to declare/readonly/export
115 # try to assign to a readonly array
119 # make sure `readonly -n' doesn't turn off readonly status
123 # try to assign a readonly array with bad assignment syntax
126 # bad counts to `shift'
127 shopt -s shift_verbose
132 shopt -s no_such_option
135 # non-octal digits for umask and other errors
137 umask -S u=rwx:g=rwx:o=rx >/dev/null # 002
138 umask -S u:rwx,g:rwx,o:rx >/dev/null # 002
140 # at some point, this may mean `invert', but for now it is an error
143 # bad assignments shouldn't change the umask
147 if [ "$mask" != "$mask2" ]; then
148 echo "umask errors change process umask"
151 # assignment to a readonly variable in environment
156 # more readonly variable tests
162 # iteration variable in a for statement being readonly
163 for VAR in 1 2 3 ; do echo $VAR; done
166 : $( for z in 1 2 3; do )
167 : $( for z in 1 2 3; done )
169 # various `cd' errors
171 ( HOME=/tmp/xyz.bash ; cd )
174 cd /bin/sh # error - not a directory
175 OLDPWD=/tmp/cd-notthere
178 # various `source/.' errors
182 # maybe someday this will work like in rc
185 # make sure that this gives an error rather than setting $1
188 # enable non-builtins
191 # try to set and unset shell options simultaneously
192 shopt -s -u checkhash
194 # this is an error -- bad timeout spec
195 read -t var < /dev/null
197 # try to read into an invalid identifier
198 read /bin/sh < /dev/null
200 # try to read into a readonly variable
203 # bad option to readonly/export
206 # someday these may mean something, but for now they're errors
210 # this caused a core dump in bash-2.01 (fixed in bash-2.01.1)
211 eval echo \$[/bin/sh + 0]
212 eval echo '$((/bin/sh + 0))'
214 # error to list trap for an unknown signal
217 # maybe someday trap will take a -s argument like kill, but not now
220 # maybe someday we will have a ksh-like ERR trap, but not yet
221 trap 'echo [$LINENO] -- error' ERR
223 # can only return from a function or sourced script
226 # break and continue with arguments <= 0
236 # builtin with non-builtin
239 # maybe someday you will be able to use fg/bg when job control is not really
240 # active, but for now they are errors
253 # bad shell option names
254 set -o trackall # bash is not ksh
257 # in posix mode, a function name must be a valid identifier
258 # this can't go in posix2.tests, since it causes the shell to exit
261 function !! () { fc -s "$@" ; }