2012年6月26日星期二

Setting option flags -n -v -x

sh -n scriptname checks for syntax errors without actually running the script. This is the equivalent of inserting set -n or set -o noexec into the script. Note that certain types of syntax errors can slip past this check.

sh -v scriptname echoes each command before executing it. This is the equivalent of inserting set -v or set -o verbose in the script.

The -n and -v flags work well together. sh -nv scriptname gives a verbose syntax check.

sh -x scriptname echoes the result each command, but in an abbreviated manner. This is the equivalent of inserting set -x or set -o xtrace in the script.

Inserting set -u or set -o nounset in the script runs it, but gives an unbound variable error
message and aborts the script.

没有评论:

发表评论