On 4/28/06, Martin McCormick <[EMAIL PROTECTED]> wrote:

        I read about the noexecute flag or -n flag which is supposed
to check the syntax of a Bourn Shell script to see what it would do if
run, but not actually do anything.  This sounds like a wonderful
thing, especially when one is going to run a dangerous script and you
only get one chance to get it right.

        I tried sh -n scriptname and it always silently succeeds even
if I type sh -x -n somescript.  I even deliberately created a script
with a syntax error in it and tried sh -x -n again.  It still did
nothing but exit.  Does this just not work or am I misunderstanding
the purpose of the flag?

        Thanks for your help.

N. Ersen SISECI wrote:
> Hello,
> Bourne shell is bash. So you should try
> bash -n scriptname

Um, "Bourne shell" is /bin/sh. "Bourne Again SHell" is bash, which is not installed in FreeBSD by default.

As for "sh -n", consider:

[343] Fri 28.Apr.2006 19:35:03
[EMAIL PROTECTED]/scripts]# cat foobaz



[344] Fri 28.Apr.2006 19:35:20
[EMAIL PROTECTED]/scripts]# sh -n foobaz
foobaz: 3: Syntax error: Unterminated quoted string

So, it would appear that "-n" is merely a "lint" type option or "syntax checker". Whether or not it's smart enough to catch your error I can't tell; it caught mine with and without "-x" ....


Kevin Kinsey

The giraffe you thought you offended last week is willing to be nuzzled
freebsd-questions@freebsd.org mailing list
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to