Unix Shell - syntax checker?

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > January 2006 > syntax checker?





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 syntax checker?
luxor1275bc@yahoo.com

2006-01-31, 8:00 am

I have a 199-line Bourne shell script that gives the error:

syntax error at line 200: `end of file' unexpected

and I know that this is either a missing quote or a quote
where there shouldn't be one. Has anyone ever written a
syntax checker (for Bourne-style scripts) to find an
offending item such as this? If so and you're willing
to share it, I'd much appreciate it. Thanks for any help.
Thomas Maier-Komor

2006-01-31, 8:00 am

luxor1275bc@yahoo.com wrote:
> I have a 199-line Bourne shell script that gives the error:
>
> syntax error at line 200: `end of file' unexpected
>
> and I know that this is either a missing quote or a quote
> where there shouldn't be one. Has anyone ever written a
> syntax checker (for Bourne-style scripts) to find an
> offending item such as this? If so and you're willing
> to share it, I'd much appreciate it. Thanks for any help.


I don't know any checker, but would be interested in one, too.
But you might want to try the -x option of /bin/sh, if you haven't done
so already...

BTW: http://code.dogmap.org/lintsh might be worth a look, too.

Tom
Sashi

2006-01-31, 7:20 pm


Thomas Maier-Komor wrote:
> luxor1275bc@yahoo.com wrote:
>
> I don't know any checker, but would be interested in one, too.
> But you might want to try the -x option of /bin/sh, if you haven't done
> so already...
>
> BTW: http://code.dogmap.org/lintsh might be worth a look, too.
>
> Tom


Also I would suggest using the set -v and set -n options as well. These
are useful for shell script debugging in general.
Sashi

James

2006-01-31, 8:49 pm


luxor1275bc@yahoo.com wrote:
> I have a 199-line Bourne shell script that gives the error:
>
> syntax error at line 200: `end of file' unexpected
>
> and I know that this is either a missing quote or a quote
> where there shouldn't be one. Has anyone ever written a
> syntax checker (for Bourne-style scripts) to find an
> offending item such as this? If so and you're willing
> to share it, I'd much appreciate it. Thanks for any help.


sh -n script
bash -n script
etc.

James

bsh

2006-01-31, 8:49 pm

luxor1275bc@yahoo.com wrote:
> I have a 199-line Bourne shell script that gives the error:
> syntax error at line 200: `end of file' unexpected


This is almost always an occurence of a missing quote; a
missing keyword would have given the message, say,
"done expected".

> Has anyone ever written a syntax checker (for Bourne-
> style scripts) to find an offending item such as this?.


I have, but inasmuch as it's beta-quality software (and
for other reasons) it's not going to help you... I
recommend the previous advice, especially that
of using "set -nv".

In general, ksh93(1) has a "set -n" option that's greatly
enhanced to function as a static lint(1). ksh(1) is freely
downloadable and available precompiled for many
platforms at kornshell.com .

The following are quite good whitepapers on debugging and
troubleshooting techniques as applied to shell scripting.

D,"Debugging",,http://www.injunea.demon.co.uk/pages/page213.htm,$0,"webpage","R.H.
Reepe" <rhreepe@injunea.demon.co.uk>
D,"Software Carpentry:
Debugging",535,http://www.third-bit.com/swc/www/debugging.html,$0,"webpage","Python
Software Foundation"
D,"Notes on the Bourne (sh) and Korn (ksh) shells: Debugging
hints",,http://www.cs.uleth.ca/~holzmann/C/shells/debug_hints,$0,"webpage","Wolfgang
(Wolf' H. Holzmann" <holzmann@uleth.ca>
D,"Shell Mistakes",,http://www.greenend.org.uk/rjk/2001/04/shell.html

=Brian

Bill Seivert

2006-01-31, 8:49 pm



luxor1275bc@yahoo.com wrote:
> I have a 199-line Bourne shell script that gives the error:
>
> syntax error at line 200: `end of file' unexpected
>
> and I know that this is either a missing quote or a quote
> where there shouldn't be one. Has anyone ever written a
> syntax checker (for Bourne-style scripts) to find an
> offending item such as this? If so and you're willing
> to share it, I'd much appreciate it. Thanks for any help.


Check for other missing delimiters too, e.g., ), }, done, fi.

Bill Seivert

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com