Subject: Re: "for" behaviour in /bin/sh
To: der Mouse <mouse@Rodents.Montreal.QC.CA>
From: Shyeah right. What am I gonna do with a gun rack? <greywolf@starwolf.starwolf.com>
List: current-users
Date: 07/14/1998 00:51:07
No, I think you folks misunderstood me.

What I said was that:

for foo in ; do bar; done

produces a syntax error everywhere else.

HOWEVER, if invoked as

for foo in $x; do bar; done

it works correctly.  Something about the parser sees all the parameters
there and manages to do the right thing in the latter case.

I'm not arguing that the NetBSD behaviour in the former case is bad --
indeed, you'd think it'd evaluate the correct way there, too -- but,
according to the specifications and "real world examples" provided by
every single bourne (!again) shell out there, our implementation is 
(unfortunately) wrong, which is a shame and makes no sense whatsoever.

Bottom line:  The one without the variable pukes, the one with the
variable, empty or not, does NOT puke.  Go figure.



				--*greywolf;
--
     _________________________   _________________________ 
    |     NEW HAMPSHIRE       | |     NEW HAMPSHIRE       |
    |                         | |                         |
    | #   # ##### #####  ###  | |    #  ####   #### ####  |
    | ##  # #       #   #   # | |   ##  #   # #     #   # |
    | # # # ###     #     ##  | |  # #  ####   ###  #   # |
    | #  ## #       #    #    | | ##### #   #     # #   # |
    | #   AT&T###   #   ##### | |    #  ####  ####  ####  |
    | LIVE ^  FREE   OR   DIE | | LIVE    FREE   OR   DIE |
    `-------------------------' `-------------------------'