On 03/19/2012 08:54 PM, Lane Schwartz wrote:
> Hi,
> 
> If I have a file that contains a bash script, is there any
> straightforward way of determining whether that script can be parsed
> successfully as a Bash script, without actually running the file?
>
Yes: the "-n" option.  Simple examples:

  $ echo 'if :; then echo not seen; fi' | bash -n; echo status: $?
  status: 0
  $ echo 'if :; then echo not seen' | bash -n; echo status: $?
  bash: line 2: syntax error: unexpected end of file
  status: 2

The bash manual should provide more details.

HTH,
  Stefano

Reply via email to