validation tool for shell scripting
Is there any validation tool for shell scripting on unix platform. like after the completion of 开发者_JAVA百科the script the tool validates it and warns us of eroors?
Lack of such tools is one reason why people should move away from the shell scripting language for more complex things. This article shows a good example of how straightforward it is to write a shell script in Python.
When you use Python to write these scripts, you can use tools like PyLint and PyChecker to validate your scripts.
If you are trying to syntax check your first simple bash (tcsh) script, you can use "bash -n" ("tcsh -n").
Unlucky, if your script is a bit more complex than "echo Hello world", execution debug is the only way to validate it.
LLP, Andrea
The shells offer some options to do that: For example, in bash, you can treat unset variables as an error with set -u
.
Other than that, the only way to validate shell scripts is to run them. Bash will read the script and check many things like matching braces and brackets, missing fi
, esac
and done
, etc.
in bash, you can use set -x in your script for debugging. If you check the man page, there is also a --debugger option which you can turn on. also set -n is supposed to do syntax check.
精彩评论