Operating System - HP-UX
1827995 Members
2780 Online
109973 Solutions
New Discussion

Re: script syntax checking

 
SOLVED
Go to solution
marc seguin
Regular Advisor

script syntax checking

When using "-n" option with sh in order to check the syntax of my script,

# cat script
typeset idx=0
HP_DSK[$idx]="hello"
TOTO=${HP_DSK[$idx]}

it returns nothing (meaning it's OK) under HP-UX 10.20.
But under HP-UX 11.X, I get the following error message :

script[3]: HP_DSK: The specified subscript cannot be greater than 1024

Is this a regression (a bug) ? or does it perform a more complete check (and so, where is my error) ?
4 REPLIES 4
A. Clay Stephenson
Acclaimed Contributor

Re: script syntax checking

Hi Marc:

That is simply a warning that any array index cannot exceed 1023. The -n does not actually evaluate the expression $idx; it's just telling you that you may have problems.

Set the value idx to 1024 and actually execute
you script. You will then get a real 'honest-to-God' run-rime index error.

It appears that the warnings are simply a little better in 11x. Both OS versions will actually fail at run-time.

Regards, Clay
If it ain't broke, I can fix that.
marc seguin
Regular Advisor

Re: script syntax checking

Perhaps it's a warning, but it is handled as an error.
Return code is 1 and not 0.
And, most important, it stops further checking.

I intentionally added an error on a 4th line.
Under 10.20, I get an error on line 4.
Under 11.X, It still stops with the same message about line 3 !
James R. Ferguson
Acclaimed Contributor
Solution

Re: script syntax checking

Hi Marc:

A couple of comments. First the "normal" behavior of using '-n' is to stop on the first error. Therefore, in your 10.20 vs. 11.0 case you are *still* seeing the 11.0 behavior of the subscript limit checking.

Most importantly, though, it looks to me too like this is a *bug*, since cases like your snippet of shell could not be debugged with the -n' option.

I don't find this problem on 11.0 with the Korn (ksh) shell, only the Posix one.

Also, to get real picky, the error message is poorly written -- subscripts range from 0-1023 which is 1024 elements, but... ;-)

Regards!

...JRF...
Roger Baptiste
Honored Contributor

Re: script syntax checking

Marc,

Seems to be a bug.
ksh does not give the problem
even in 11.00 .

-R
Take it easy.