📄 execscript
字号:
export LC_ALL=Cexport LANG=Cif [ $UID -eq 0 ]; then echo "execscript: the test suite should not be run as root" >&2fiset -- one two threeecho before exec1.sub: "$@"echo calling exec1.sub./exec1.sub aa bb cc dd eeecho after exec1.sub with args: $?./exec1.subecho after exec1.sub without args: $?# set up a fixed path so we know notthere will not be foundPATH=/usr/bin:/bin:/usr/local/bin:export PATHnotthereecho $?# this is iffy, since the error messages may vary from system to system# and /tmp might not existln -s ${THIS_SH} /tmp/bash 2>/dev/nullif [ -f /tmp/bash ]; then /tmp/bash notthereelse ${THIS_SH} nottherefiecho $?rm -f /tmp/bash# /bin/sh should be there on all systems${THIS_SH} /bin/shecho $?# try executing a directory/echo $?${THIS_SH} /echo $?# try sourcing a directory. /echo $?# try sourcing a binary file -- post-2.04 versions don't do the binary file# check, and will probably fail with `command not found', or status 127# bash-4.1 and later check for 256 NUL characters and fail as binary files# if there are more than that, it's probably binary. ${THIS_SH} 2>/dev/nullecho $?# post-bash-2.05 versions allow sourcing non-regular files. /dev/nullecho $?# kill two birds with one test -- test out the BASH_ENV codeecho echo this is bashenv > /tmp/bashenvexport BASH_ENV=/tmp/bashenv${THIS_SH} ./exec3.subrm -f /tmp/bashenvunset BASH_ENV# we're resetting the $PATH to empty, so this should be lastPATH=notthereecho $?command notthereecho $?command -p notthereecho $?# but -p should guarantee that we find all the standard utilities, even# with an empty or unset $PATHcommand -p sh -c 'echo this is $0'unset PATHcommand -p sh -c 'echo this is $0'# a bug in bash before bash-2.01 caused PATH to be set to the empty string# when command -p was run with PATH unsetecho ${PATH-unset}echo "echo ok" | ${THIS_SH} -t${THIS_SH} ./exec2.subecho $?${THIS_SH} ./exec4.sub# try exec'ing a command that cannot be found in $PATH${THIS_SH} ./exec5.sub# this was a bug in bash versions before bash-2.04${THIS_SH} -c 'cat </dev/null | cat >/dev/null' >&-# checks for proper return values in subshell commands with inverted return# values${THIS_SH} ./exec6.sub# checks for properly deciding what constitutes an executable file${THIS_SH} ./exec7.sub${THIS_SH} -i ./exec8.sub${THIS_SH} ./exec9.subtrue | `echo true` &echo after# Problem with bash at least back to version 3.0${THIS_SH} -c 'VAR=0; VAR=1 command exec; exit ${VAR}'# problem with bash through bash-4.1( exec /var/empty/nosuch echo bad) 2>/dev/null[ $? = 127 ] || echo FAIL: bad exit status $? at $LINENO
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -