Reputation: 809
I'm looking for a way to validate the syntax of a bash script without executing it.
bash -n
only seems to validate base bash syntax, what I am missing is:
Any ideas on how to achieve that?
I am also missing the validation of the number of parameters a function takes, but that sounds like a very hard thing to do in theory, in bash.
In other words what I'd like to do is pretty much take a bash script and "compile" it like I would compile a c++ program.
Upvotes: 1
Views: 270
Reputation: 3894
bash -n is certainly the fundamental way to do that.
However there is also a site that will do some validation for you: http://www.shellcheck.net/ --And there is a link on the site to the source code if you want to run it locally.
Upvotes: 3