This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: bash-2.x


On Thursday, 23 July 1998, Chet Ramey writes:
> Posting by Chet Ramey <chet@nike.ins.cwru.edu>:
> > jan@digicash.com writes:
> > > Hi,
> > > 
> > > After all this trouble with bash, i downloaded bash-docs-2.02,
> > > and it says:
> > > 
> > >        for name [ in word; ] do list ; done
> > 			   ^
> > 
> > > 
> > >     10:55:25 mub ~/ftp/gnu/bash-2.02$ for i in ;do echo $i; done
> > >     bash: syntax error near unexpected token `;d'
> > > 
> > > It looks like a bug in bash-2.02(-release)
> 
> No.  It is not a bug.  If the `in' keyword is supplied, a non-empty
> wordlist must be specified before the list terminator (the semicolon
> or newline).  

In that case, there's a bug in the doco, and in bash-1.14 :-(

> The text between the square brackets in the synopsis indicates an
> optional unit, with one problem, described below.  You can either
> supply `in words' or nothing. 

Yes, i know that.  But the documentation also states that if the
optional unit is present, a part of it may be empty:

        [..]
	If the expansion of the items following in results in an 
	empty list, no  commands are executed, and the return status 
	is 0.

>From that i read that if 'expansion of items following in' (='word')
is empty, that's ok too.  This seems a lot more natural to me, and
it's certainly handier to allow an empty loop than to have the caller
check wether the expansion will be empty or not.

> The description should more properly read
> 
> 	for name [ in word ] ; do list ; done
> 
> This is a documentation bug in the manual page that will be corrected
> for the bash-2.03 release.  The texinfo document has the correct syntax.

Yet oneOther reason to have a fully-automatic yodl2texinfo converter 
soon :-)

>From the texinfo pages of bash-2.02:

    `for'
	 The syntax of the `for' command is:

	      for NAME [in WORDS ...]; do COMMANDS; done
	 Expand WORDS, and execute COMMANDS once for each member in the
	 resultant list, with NAME bound to the current member.  If `in
	 WORDS' is not present, `in "$@"' is assumed.  The return status is
	 the exit status of the last command that executes.  If there are
	 no items in the expansion of WORDS, no commands are executed, and
	 the return status is zero.

which states the same thing: if WORDS is empty, that's fine.

It would be Better to fix bash-2.x, than to fix it's doco, IMHO.

Otherwise, this would mean that from bash-2.0 on our GNU system, we'll 
have to do things like:

    FOO = $wilcard
    [..]
    if test "x$FOO" != "x"; then
	    for i in $FOO; do 
		   $bar $i
	    done;
    fi

> Chet Ramey, Case Western Reserve University	Internet: chet@po.CWRU.Edu

Jan.

Jan Nieuwenhuizen <jan@digicash.com> | GNU LilyPond - The Music Typesetter
http://www.digicash.com/~jan         | http://www.digicash.com/~jan/lilypond

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]