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 # assignment to a readonly variable in environment
148 # more readonly variable tests
154 # iteration variable in a for statement being readonly
155 for VAR in 1 2 3 ; do echo $VAR; done
158 : $( for z in 1 2 3; do )
159 : $( for z in 1 2 3; done )
161 # various `cd' errors
163 ( HOME=/tmp/xyz.bash ; cd )
166 cd /bin/sh # error - not a directory
167 OLDPWD=/tmp/cd-notthere
170 # various `source/.' errors
174 # maybe someday this will work like in rc
177 # make sure that this gives an error rather than setting $1
180 # enable non-builtins
183 # try to set and unset shell options simultaneously
184 shopt -s -u checkhash
186 # someday, this may give `read' a timeout, but for now it is an error
187 read -t var < /dev/null
189 # try to read into an invalid identifier
190 read /bin/sh < /dev/null
192 # try to read into a readonly variable
195 # bad option to readonly/export
198 # someday these may mean something, but for now they're errors
202 # this caused a core dump in bash-2.01 (fixed in bash-2.01.1)
203 eval echo \$[/bin/sh + 0]
204 eval echo '$((/bin/sh + 0))'
206 # error to list trap for an unknown signal
209 # maybe someday trap will take a -s argument like kill, but not now
212 # maybe someday we will have a ksh-like ERR trap, but not yet
213 trap 'echo [$LINENO] -- error' ERR
215 # can only return from a function or sourced script
218 # break and continue with arguments <= 0
228 # builtin with non-builtin
231 # maybe someday you will be able to use fg/bg when job control is not really
232 # active, but for now they are errors
245 # bad shell option names
246 set -o trackall # bash is not ksh
249 # in posix mode, a function name must be a valid identifier
250 # this can't go in posix2.tests, since it causes the shell to exit
253 function !! () { fc -s "$@" ; }