views:

4418

answers:

2

Is it possible to check a bash script syntax without executing it?

Using Perl, I can run perl -c 'script name', is there any equivalent command for bash scripts?

Thanks.

+33  A: 
andy
Thanks for the tip, I will definitly use this one.Strangely, this option isn't listed in bash's man page :S...
skinp
In bash's manpage, under "SHELL BUILTIN COMMANDS / set", -n is documented, and as the beginning of the manpage states, bash interprets all single-character options that `set` does.
ephemient
A: 

No.

bash -n script-name

Is not returning any error although one of the command in the script is wrong.