⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 errors.tests

📁 android-w.song.android.widget
💻 TESTS
字号:
# These should all be safeLC_ALL=CLC_CTYPE=CLC_COLLATE=CLC_MESSAGES=C# these tests should all generate errors# make sure we don't exit prematurelyset +eset +o posix# various alias/unalias errors# at some point, this may mean to `export' an alias, like ksh, but# for now it is an erroralias -x foo=barzunalias -x fooahaalias hoowahunalias hoowah# the iteration variable must be a valid identifierfor 1 in a b c; do echo $1; done# try to rebind a read-only functionfunc(){	echo func}readonly -f func# make sure `readonly' and `declare' play well togetherdeclare -Frfunc(){	echo bar}# bad optionunset -x func# cannot unset readonly functions or variablesunset -f func# or make them not readonlydeclare -fr funcdeclare -f +r funcXPATH=$PATHdeclare -r XPATHunset -v XPATH# cannot unset invalid identifiersunset /bin/sh# cannot unset function and variable at the same timeunset -f -v SHELL# bad optiondeclare -z# cannot declare invalid identifiersdeclare -- -z declare /bin/sh# this is the syntax used to export functions in the environment, but# it cannot be used with `declare'declare -f func='() { echo "this is func"; }'# bad option to exec -- this should not exit the scriptexec -i /bin/sh# try to export -f something that is not a function -- this should be# an error, not create an `invisible function'export -f XPATH# this depends on the setting of BREAK_COMPLAINS in config.h.inbreakcontinue# this should not exit the shell; it did in versions before 2.01shift label# other shells do not complain about the extra arguments; maybe someday# we won't eitherset -- a b cshift $# label# and get rid of the positional parametersshift $## let without an expression is an error, though maybe it should just return# successlet# local outside a function is an errorlocal# logout of a non-login shell is an errorlogout# try to hash a non-existant commandhash notthere# bad option to hash, although it may mean `verbose' at some future pointhash -v# turn off hashing, then try to hash somethingset +o hashallhash -p ${THIS_SH} ${THIS_SH##*/}# bad identifiers to declare/readonly/exportexport AA[4]readonly AA[4]declare -a AAunset AA[-2]# try to assign to a readonly arraydeclare -r AAAA=( one two three )# make sure `readonly -n' doesn't turn off readonly statusreadonly -n AAAA=(one two three)# try to assign a readonly array with bad assignment syntax# NOTE: this works in post-bash-2.05 (at least when I write this)# readonly -a ZZZ=bbb# bad counts to `shift'shopt -s shift_verboseshift $(( $# + 5 ))shift -2# bad shell optionsshopt -s no_such_optionshopt no_such_option# non-octal digits for umask and other errorsumask 09umask -S u=rwx:g=rwx:o=rx >/dev/null # 002umask -S u:rwx,g:rwx,o:rx >/dev/null # 002# at some point, this may mean `invert', but for now it is an errorumask -i# bad assignments shouldn't change the umaskmask=$(umask)umask g=umask2=$(umask)if [ "$mask" != "$mask2" ]; then	echo "umask errors change process umask"fi# assignment to a readonly variable in environmentVAR=4readonly VARVAR=7 :# more readonly variable testsdeclare VAR=88declare +r VARdeclare -p unset# iteration variable in a for statement being readonlyfor VAR in 1 2 3 ; do echo $VAR; done# parser errors: $( for z in 1 2 3; do ): $( for z in 1 2 3; done )# various `cd' errors( unset HOME ; cd )( HOME=/tmp/xyz.bash ; cd )# errors from cdcd -cd /bin/sh	# error - not a directoryOLDPWD=/tmp/cd-nottherecd -# various `source/.' errors.source# maybe someday this will work like in rc. -i /dev/tty# make sure that this gives an error rather than setting $1set -q# enable non-builtinsenable sh bash# try to set and unset shell options simultaneouslyshopt -s -u checkhash# this is an error -- bad timeout specread -t var < /dev/null# try to read into an invalid identifierread /bin/sh < /dev/null# try to read into a readonly variableread VAR < /dev/null# bad option to readonly/exportreadonly -x foo# someday these may mean something, but for now they're errorseval -i "echo $-"command -i "echo $-"# this caused a core dump in bash-2.01 (fixed in bash-2.01.1)eval echo \$[/bin/sh + 0]eval echo '$((/bin/sh + 0))'# error to list trap for an unknown signaltrap -p NOSIG# maybe someday trap will take a -s argument like kill, but not nowtrap -p -s NOSIG# we have a ksh-like ERR trap, post-bash-2.05#trap 'echo [$LINENO] -- error' ERR# can only return from a function or sourced scriptreturn 2# break and continue with arguments <= 0for z in 1 2 3; do	break 0	echo $xdonefor z in 1 2 3; do	continue 0	echo $xdone# builtin with non-builtinbuiltin bash# maybe someday you will be able to use fg/bg when job control is not really# active, but for now they are errorsbgfg# argument requiredkill -s# bad argumentkill -S# null argumentkill -INT ''# argument requiredkill -INT# bad shell option namesset -o trackall		# bash is not ksh# this must be last!# in posix mode, a function name must be a valid identifier# this can't go in posix2.tests, since it causes the shell to exit# immediatelyset -o posixfunction !! () { fc -s "$@" ; }set +o posixecho end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -