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
124 # NOTE: this works in post-bash-2.05 (at least when I write this)
125 # readonly -a ZZZ=bbb
127 # bad counts to `shift'
128 shopt -s shift_verbose
133 shopt -s no_such_option
136 # non-octal digits for umask and other errors
138 umask -S u=rwx:g=rwx:o=rx >/dev/null # 002
139 umask -S u:rwx,g:rwx,o:rx >/dev/null # 002
141 # at some point, this may mean `invert', but for now it is an error
144 # bad assignments shouldn't change the umask
148 if [ "$mask" != "$mask2" ]; then
149 echo "umask errors change process umask"
152 # assignment to a readonly variable in environment
157 # more readonly variable tests
163 # iteration variable in a for statement being readonly
164 for VAR in 1 2 3 ; do echo $VAR; done
167 : $( for z in 1 2 3; do )
168 : $( for z in 1 2 3; done )
170 # various `cd' errors
172 ( HOME=/tmp/xyz.bash ; cd )
175 cd /bin/sh # error - not a directory
176 OLDPWD=/tmp/cd-notthere
179 # various `source/.' errors
183 # maybe someday this will work like in rc
186 # make sure that this gives an error rather than setting $1
189 # enable non-builtins
192 # try to set and unset shell options simultaneously
193 shopt -s -u checkhash
195 # this is an error -- bad timeout spec
196 read -t var < /dev/null
198 # try to read into an invalid identifier
199 read /bin/sh < /dev/null
201 # try to read into a readonly variable
204 # bad option to readonly/export
207 # someday these may mean something, but for now they're errors
211 # this caused a core dump in bash-2.01 (fixed in bash-2.01.1)
212 eval echo \$[/bin/sh + 0]
213 eval echo '$((/bin/sh + 0))'
215 # error to list trap for an unknown signal
218 # maybe someday trap will take a -s argument like kill, but not now
221 # we have a ksh-like ERR trap, post-bash-2.05
222 #trap 'echo [$LINENO] -- error' ERR
224 # can only return from a function or sourced script
227 # break and continue with arguments <= 0
237 # builtin with non-builtin
240 # maybe someday you will be able to use fg/bg when job control is not really
241 # active, but for now they are errors
254 # bad shell option names
255 set -o trackall # bash is not ksh
258 # in posix mode, a function name must be a valid identifier
259 # this can't go in posix2.tests, since it causes the shell to exit
262 function !! () { fc -s "$@" ; }