From: jan AT digicash DOT com (Jan Nieuwenhuizen) Subject: Re: bash-2.x 24 Jul 1998 21:21:14 -0700 Message-ID: <199807240814.KAA13117.cygnus.gnu-win32@digicash.com> References: <980723165331 DOT AA29283 DOT SM AT nike DOT ins DOT cwru DOT edu> To: yodl AT icce DOT rug DOT nl Cc: hanwen AT cs DOT uu DOT nl, gnu-win32 AT cygnus DOT com, chet AT po DOT cwru DOT edu On Thursday, 23 July 1998, Chet Ramey writes: > Posting by Chet Ramey : > > jan AT digicash DOT 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 AT po DOT CWRU DOT Edu Jan. Jan Nieuwenhuizen | 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 AT cygnus DOT com" with one line of text: "help".