views:

85

answers:

4

Is there any validation tool for shell scripting on unix platform. like after the completion of the script the tool validates it and warns us of eroors?

A: 

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.

Aaron Digulla
A: 

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.

ghostdog74
+1  A: 

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.

Michael Dillon
Although I use perl as my shell replacement, +1 just for saying "move away from shell".
Tanktalus
A: 

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

andcoz