How to "test" shell script without running it?

I seem to remember with the korn shell a switch that would syntactically
evaluate the script reporting any errors but NOT run the script.

Is something like this available with bash?

If so, please advise? I've looked through the bash docs and man pages but
cannot seem to find anything.

TIA

Re: How to "test" shell script without running it?

Use the -n option:

bash -n script

In vim I have a ksh script called compile tied to F4.
It determines the type of script and calls the appropriate
routine (ksh -n for ksh, perl -c for perl).

It has saved me endless agony over the years.

Dan Mercer

"bobmct" wrote in message news:4Lduh.1$ji5.4167@news.ntplx.net...
: I seem to remember with the korn shell a switch that would syntactically
: evaluate the script reporting any errors but NOT run the script.
:
: Is something like this available with bash?
:
: If so, please advise? I've looked through the bash docs and man pages but
: cannot seem to find anything.
:
: TIA

Re: How to "test" shell script without running it?

Dan Mercer wrote:
> Use the -n option:
>
> bash -n script
>
> In vim I have a ksh script called compile tied to F4.
> It determines the type of script and calls the appropriate
> routine (ksh -n for ksh, perl -c for perl).
>
> It has saved me endless agony over the years.
>
> Dan Mercer
>

Thanks, Dan;

That's what I was looking for! Funny, thought, I still don't see reference
to it int he bash docs...

But, it does what I was looking for.

Thanks again.

bobmct

Re: How to "test" shell script without running it?

Hi bob,

For the K shell what is option we need to choice just for the systax
checking , is ksh -n script ???,is this way u r testing ....