Unix Shell - validating shell script...

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > February 2007 > validating shell script...





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author validating shell script...
slawko

2007-02-20, 7:18 am

Hi All,
did you hear about any tool for static analysis (validation) of shell
scripts? I'm looking for something to check the code against bunch of
stupid errors, or some pre-defined coding standard. I googled for some
time but failed to find anything.

Anything usefull out there?

Thanks in advance,
Slawek

Michael Tosch

2007-02-20, 7:18 am

slawko wrote:
> Hi All,
> did you hear about any tool for static analysis (validation) of shell
> scripts? I'm looking for something to check the code against bunch of
> stupid errors, or some pre-defined coding standard. I googled for some
> time but failed to find anything.
>
> Anything usefull out there?
>
> Thanks in advance,
> Slawek
>


sh -nx myscript


--
Michael Tosch @ hp : com
slawko

2007-02-20, 7:18 am


> sh -nx myscript
>


hmm... better than nothing but... are there any chances for anything
"smarter"?
Nobody created such tool?

Thanks,
Slawek

Janis Papanagnou

2007-02-20, 1:17 pm

slawko wrote:
>
> hmm... better than nothing but... are there any chances for anything
> "smarter"?
> Nobody created such tool?


Not that I know of.

I've heared about commercial tools existing for several languages
that you may want to search the web for. I am unsure whether they
support shells, though; you'll have to see.

Janis

>
> Thanks,
> Slawek
>

bsh

2007-02-20, 7:16 pm

On Feb 20, 6:27 am, Janis Papanagnou <Janis_Papanag...@hotmail.com>
wrote:
> slawko wrote:
>
> Not that I know of.
> I've heared about commercial tools existing for several languages
> that you may want to search the web for. I am unsure whether they
> support shells, though; you'll have to see.


I have compiled what is in a practical sense a
comprehensive list of internal and external software
tools for shell programming, and I can say that there
is no overall tool being offered which gives better
parsing consistency checks than the noexec ("-n")
option of the shell interpreter.

Although the undocumented ksh93 "-I <filename>"
command line option exists to produce output in the
database format of the AT&T CAIO software analysis
and reverse engineering software tool, I haven't as yet
experimented with it, but this example serves to show
there are solutions available -- they are just unknown
and/or unused. I surmise that the parsing rules for
bournish scripts are too context-bound for external tools
to reverse engineer.

However, hope! The -n option to the 1993 version of ksh
(available through kornshell.com) is greatly expanded to
serve as a compatibility checker as well as for static syntax
validation. Even if you don't use ksh93 as your scripting
environment, using its noexec (-n) option is quite worthwhile.

Also, if you are talking about "stupid errors," aren't the
preponderance of errors going to be runtime errors, and will
mere "coding standards" really mitigate against them?

Ironically, it is I who has coded a real lexical scanner (in
sed) and content-bound parser (in (old!) awk) for sh and ksh as
a engine for a debugger and prettyprinter -- unfortunately,
all finished but not able to be distributed. But it is high time
for a authoritative pretty-printer for k/sh to be made available.
After all, a good prettyprinter is the best debugger! I'm
sorry I cannot solve your problem as of yet by giving it to
you.

Good luck!

=Brian

bsh

2007-02-20, 7:16 pm

On Feb 20, 6:27 am, Janis Papanagnou <Janis_Papanag...@hotmail.com>
wrote:
> slawko wrote:
>
> Not that I know of.
> I've heared about commercial tools existing for several languages
> that you may want to search the web for. I am unsure whether they
> support shells, though; you'll have to see.


I have compiled what is in a practical sense a
comprehensive list of internal and external software
tools for shell programming, and I can say that there
is no overall tool being offered which gives better
parsing consistency checks than the noexec ("-n")
option of the shell interpreter.

Although the undocumented ksh93 "-I <filename>"
command line option exists to produce output in the
database format of the AT&T CAIO software analysis
and reverse engineering software tool, I haven't as yet
experimented with it, but this example serves to show
there are solutions available -- they are just unknown
and/or unused. I surmise that the parsing rules for
bournish scripts are too context-bound for external tools
to reverse engineer.

However, hope! The -n option to the 1993 version of ksh
(available through kornshell.com) is greatly expanded to
serve as a compatibility checker as well as for static syntax
validation. Even if you don't use ksh93 as your scripting
environment, using its noexec (-n) option is quite worthwhile.

Also, if you are talking about "stupid errors," aren't the
preponderance of errors going to be runtime errors, and will
mere "coding standards" really mitigate against them?

Ironically, it is I who has coded a real lexical scanner (in
sed) and content-bound parser (in (old!) awk) for sh and ksh as
a engine for a debugger and prettyprinter -- unfortunately,
all finished but not able to be distributed. But it is high time
for a authoritative pretty-printer for k/sh to be made available.
After all, a good prettyprinter is the best debugger! I'm
sorry I cannot solve your problem as of yet by giving it to
you.

Good luck!

=Brian

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com