[comp.os.minix] shell bug

paula@bcsaic.UUCP (Paul Allen) (06/27/91)

While working my way through the perl 4.0 Configure script, I
discovered that the Minix shell chokes on a construct like:

	for n do
	  whatever
	done

It complains about a syntax error.  My V7 documentation says
that "for n do" is equivalent to "for n in $@ do".  "$@" expands
to the entire argument list, or "$1 $2 $3 ...".  I changed
the offending section of Configure to something like:

	for n in $@ do
	  whatever
	done

The shell still complained about a syntax error.  But if I wrote:

	for n in $@
	do
	  whatever
	done

or:

	for n in $@ ; do
	  whatever
	done

it worked fine.  This looks like a bug to me.  I didn't spend
any time trying to fix it, 'cause it was so much easier to just
patch Configure.  :-)

Has anybody seen this bug?  If I ever get to the point where I
can post diffs for compiling perl under 386 Minix, it would be
nice not to have to post patches that are just bandaids for
Minix bugs.  :-(

And while I'm here, is anybody working on porting perl to Minix?
I took a stab at it with perl-4.000, but gave it up when I was
unable to chmem either the shell or awk big enough to handle
Configure.  After applying patches 1-10, Configure is working
somewhat better, but I'm having to fix what appear to be glaring
bugs.  Given that this software comes from Larry Wall, I hesitate 
to suggest that it contains bugs.  However, the perl-4.010 
Configure has the same problems on my Sun as it does under 
Minix!  Hmmm...  If there are others working along these same
lines, I wouldn't mind comparing notes with you.

Paul Allen


-- 
------------------------------------------------------------------------
Paul L. Allen                       | pallen@atc.boeing.com
Boeing Advanced Technology Center   | ...!uw-beaver!bcsaic!pallen

ramon@convex.com (Ramon Dominguez) (06/28/91)

In article <50556@bcsaic.UUCP> paula@bcsaic.UUCP (Paul Allen) writes:
=>While working my way through the perl 4.0 Configure script, I
=>discovered that the Minix shell chokes on a construct like:
=>
=>	for n do
=>	  whatever
=>	done
=>
=>It complains about a syntax error.

It _is_ a syntax error.  You need a newline or a semicolon between the last
word of the wordlist and the "do" keyword.  This allows the wordlist to contain
the word "do".

--ramon

v882087@si.hhs.nl (06/28/91)

In article <9106280203.AA09940@mcsun.EU.net> you write:
>
>It complains about a syntax error.  My V7 documentation says
>that "for n do" is equivalent to "for n in $@ do".  "$@" expands
>to the entire argument list, or "$1 $2 $3 ...".  I changed
>
>it worked fine.  This looks like a bug to me.  I didn't spend
>any time trying to fix it, 'cause it was so much easier to just
>patch Configure.  :-)
>

If this is a bug, I can only say it is a bug in your V7 documentation. I
have never ever seen a UNIX(like) shell that accepted the for .. do
construction without a semicolon (";")

 ___
<*,*> . . . < "Good luck 2 U, Uhu" >
[` ']
-"-"-

--
|   |   /   Hans Voss              <v882087@si.hhs.nl>                 |   ___
|___|  /    Parkweg 200          +-------------------------------------+  <*,*>
|   | /     3134 VS  VLAARDINGEN | /// Now, what is this //////////////|  [' `]
|   |/      The Netherlands      |/// supposed to mean? ////////////// |  -"-"-

burgess%creek.decnet@hqhsd.brooks.af.mil (CREEK::BURGESS) (06/28/91)

Quoting: Paul Allen <paula%BCSAIC.UUCP@VM1.NoDak.EDU>
>The shell still complained about a syntax error.  But if I wrote:
>
>	for n in $@
>	do
>	  whatever
>	done
>
>or:
>
>	for n in $@ ; do
>	  whatever
>	done
>
>it worked fine.  This looks like a bug to me.  I didn't spend
>any time trying to fix it, 'cause it was so much easier to just
>patch Configure.  :-)
>
>Has anybody seen this bug?  

Yup, I ran across it last Saturday doing something similar.  I also came up 
with the same two workarounds.  After I get done upgradeing to 1.5 and 
porting PERL (deja vu) for my boss ('by the hour' type work), I am going to 
look into shell and find out if the 'do' operator can be allowed on the 'for' 
line, unless it has been fixed :-)...

TSgt Dave Burgess
Armstrong Lab
Brooks AFB, TX

paula@bcsaic.UUCP (Paul Allen) (06/29/91)

In article <57433@nigel.ee.udel.edu> v882087@si.hhs.nl writes:
>In article <9106280203.AA09940@mcsun.EU.net> I write:
>>
>>[...about a couple suspected bugs in the Minix shell ...]
>
>If this is a bug, I can only say it is a bug in your V7 documentation. I
>have never ever seen a UNIX(like) shell that accepted the for .. do
>construction without a semicolon (";")

Try this under SunOS 4.1.1:

# set a b c
# for n do
> echo $n
> done
a
b
c
# 

Or Ultrix 3.1:

$ set a b c
$ for n do
> echo $n
> done
a
b
c
$

As you would expect, both of those systems complain about things like:

for n in a b c do
echo $n
done

The Seventh Edition Unix Programmer's Manual states that "reserved
words like do and done are only recognized following a newline or
semicolon."  But in the next paragraph, it says:

"Another example of the use of the for loop is the create command whose
text is

	for i do >$i; done

The command

	create alpha beta

ensures that two empty files alpha and beta exist and are empty.  [...]
Notice also that a semicolon (or newline) is required before done."

I'll leave it as an exercise for the reader to determine which shell
has a bug.  I've managed to work around the various problems and have
now made it all the way through the perl Configure script.  The next
step is to run all the *.SH scripts manually.  (The shell ran into
some sort of nesting limit when Configure tried to run them automatically.)
Then I get to try to actually *compile* the dang thing!  :-)

Paul Allen


-- 
------------------------------------------------------------------------
Paul L. Allen                       | pallen@atc.boeing.com
Boeing Advanced Technology Center   | ...!uw-beaver!bcsaic!pallen