1 # These should all be safe
7 # these tests should all generate errors
9 # make sure we don't exit prematurely
13 # the iteration variable must be a valid identifier
14 for 1 in a b c; do echo $1; done
16 # try to rebind a read-only function
22 # make sure `readonly' and `declare' play well together
29 # cannot unset readonly functions or variables
31 # or make them not readonly
39 # cannot unset invalid identifiers
44 # cannot declare invalid identifiers
48 # this is the syntax used to export functions in the environment, but
49 # it cannot be used with `declare'
50 declare -f func='() { echo "this is func"; }'
52 # try to export -f something that is not a function -- this should be
53 # an error, not create an `invisible function'
56 # this depends on the setting of BREAK_COMPLAINS in config.h.in
60 # this should not exit the shell; it did in versions before 2.01
63 # other shells do not complain about the extra arguments; maybe someday
67 # and get rid of the positional parameters
70 # let without an expression is an error, though maybe it should just return
74 # local outside a function is an error
77 # try to hash a non-existant command
80 # turn off hashing, then try to hash something
82 hash -p ${THIS_SH} ${THIS_SH##*/}
84 # bad identifiers to declare/readonly/export
91 # try to assign to a readonly array
95 # bad counts to `shift'
96 shopt -s shift_verbose
101 shopt -s no_such_option
104 # non-octal digits for umask and other errors
106 umask -S u=rwx:g=rwx:o=rx >/dev/null # 002
107 umask -S u:rwx,g:rwx,o:rx >/dev/null # 002
108 # this may behave identically to umask without arguments in the future,
109 # but for now it is an error
112 # assignment to a readonly variable in environment
117 # more readonly variable tests
123 # iteration variable in a for statement being readonly
124 for VAR in 1 2 3 ; do echo $VAR; done
127 : $( for z in 1 2 3; do )
128 : $( for z in 1 2 3; done )
130 # various `cd' errors
132 ( unset OLDPWD ; cd - )
134 # various `source/.' errors
138 # maybe someday this will work like in rc
141 # make sure that this gives an error rather than setting $1
144 # enable non-builtins
147 # try to set and unset shell options simultaneously
148 shopt -s -u checkhash
150 # try to read into an invalid identifier
151 read /bin/sh < /dev/null
153 # try to read into a readonly variable
156 # someday these may mean something, but for now they're errors
160 # error to list trap for an unknown signal
163 # maybe someday trap will take a -s argument like kill, but not now
166 # maybe someday we will have a ksh-like ERR trap, but not yet
167 trap 'echo [$LINENO] -- error' ERR
169 # can only return from a function or sourced script
172 # break and continue with arguments <= 0
182 # builtin with non-builtin
185 # maybe someday you will be able to use fg/bg when job control is not really
186 # active, but for now they are errors
196 # in posix mode, a function name must be a valid identifier
197 # this can't go in posix2.tests, since it causes the shell to exit
200 function !! () { fc -s "$@" ; }