| 1 | # These should all be safe
|
|---|
| 2 | LC_ALL=C
|
|---|
| 3 | LC_CTYPE=C
|
|---|
| 4 | LC_COLLATE=C
|
|---|
| 5 | LC_MESSAGES=C
|
|---|
| 6 |
|
|---|
| 7 | # these tests should all generate errors
|
|---|
| 8 |
|
|---|
| 9 | # make sure we don't exit prematurely
|
|---|
| 10 | set +e
|
|---|
| 11 | set +o posix
|
|---|
| 12 |
|
|---|
| 13 | # various alias/unalias errors
|
|---|
| 14 |
|
|---|
| 15 | # at some point, this may mean to `export' an alias, like ksh, but
|
|---|
| 16 | # for now it is an error
|
|---|
| 17 | alias -x foo=barz
|
|---|
| 18 | unalias -x fooaha
|
|---|
| 19 | alias hoowah
|
|---|
| 20 | unalias hoowah
|
|---|
| 21 |
|
|---|
| 22 | # the iteration variable must be a valid identifier
|
|---|
| 23 | for 1 in a b c; do echo $1; done
|
|---|
| 24 |
|
|---|
| 25 | # try to rebind a read-only function
|
|---|
| 26 | func()
|
|---|
| 27 | {
|
|---|
| 28 | echo func
|
|---|
| 29 | }
|
|---|
| 30 | readonly -f func
|
|---|
| 31 | # make sure `readonly' and `declare' play well together
|
|---|
| 32 | declare -Fr
|
|---|
| 33 | func()
|
|---|
| 34 | {
|
|---|
| 35 | echo bar
|
|---|
| 36 | }
|
|---|
| 37 |
|
|---|
| 38 | # bad option
|
|---|
| 39 | unset -x func
|
|---|
| 40 |
|
|---|
| 41 | # cannot unset readonly functions or variables
|
|---|
| 42 | unset -f func
|
|---|
| 43 | # or make them not readonly
|
|---|
| 44 | declare -fr func
|
|---|
| 45 | declare -f +r func
|
|---|
| 46 |
|
|---|
| 47 | XPATH=$PATH
|
|---|
| 48 | declare -r XPATH
|
|---|
| 49 | unset -v XPATH
|
|---|
| 50 |
|
|---|
| 51 | # cannot unset invalid identifiers
|
|---|
| 52 | unset /bin/sh
|
|---|
| 53 |
|
|---|
| 54 | # cannot unset function and variable at the same time
|
|---|
| 55 | unset -f -v SHELL
|
|---|
| 56 |
|
|---|
| 57 | # bad option
|
|---|
| 58 | declare -z
|
|---|
| 59 | # cannot declare invalid identifiers
|
|---|
| 60 | declare -- -z
|
|---|
| 61 | declare /bin/sh
|
|---|
| 62 |
|
|---|
| 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"; }'
|
|---|
| 66 |
|
|---|
| 67 | # bad option to exec -- this should not exit the script
|
|---|
| 68 | exec -i /bin/sh
|
|---|
| 69 |
|
|---|
| 70 | # try to export -f something that is not a function -- this should be
|
|---|
| 71 | # an error, not create an `invisible function'
|
|---|
| 72 | export -f XPATH
|
|---|
| 73 |
|
|---|
| 74 | # this depends on the setting of BREAK_COMPLAINS in config.h.in
|
|---|
| 75 | break
|
|---|
| 76 | continue
|
|---|
| 77 |
|
|---|
| 78 | # this should not exit the shell; it did in versions before 2.01
|
|---|
| 79 | shift label
|
|---|
|
|---|