From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9490 invoked from network); 26 Feb 1997 17:55:32 -0000 Received: from euclid.skiles.gatech.edu (list@130.207.146.50) by coral.primenet.com.au with SMTP; 26 Feb 1997 17:55:32 -0000 Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id MAA12334; Wed, 26 Feb 1997 12:34:42 -0500 (EST) Resent-Date: Wed, 26 Feb 1997 12:34:42 -0500 (EST) From: (Zoltan T. Hidvegi) Message-Id: <9702261726.AA21058@lotto.fishkill.ibm.com> Subject: Re: Short loops? In-Reply-To: <970226091139.ZM16361@candle.brasslantern.com> from Bart Schaefer at "Feb 26, 97 09:11:39 am" To: schaefer@nbn.com Date: Wed, 26 Feb 1997 12:26:05 -0500 (EST) Cc: zsh-workers@math.gatech.edu (Zsh workers list) X-Mailer: ELM [version 2.4ME+ PL31 (25)] Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Resent-Message-ID: <"VXrDe2.0.f03.nG75p"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/2929 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu Bart Schaefer wrote: > The doc ought to get changed, then. The two entries for `while' (and > similarly for all the "short" variants) read: > > `while LIST do LIST done' > `while LIST { LIST }' > > The first and second uses of LIST both require either a newline or a > trailing semicolon; the fourth use of LIST may have a newline or a > semicolon or not, without affecting the result; and the third use > requires not only that there NOT be a newline or semicolon, but also > that the list ends with a [[ ]] (( )) ( ) or { } construct. No. No one of the above four LIST require any trailing semicolons or newlines. As decribed in the manual, reserved words like do, done, { are only recognized in command position. If you write while true { ... } then { is not in command position, it is simply an argument to true. Words are in command position after a newline or a semicolon or after )) or ]] or after do, then, {, } etc. Zsh has to know that { is not a simple argument to a command, but a reserved word. The { echo } case works and seems to be an exception to this rule but is really a pathologic special case handled explicitely in lex.c and it only works if ignorebraces is not set. This syntax worked in bash-1.14 but it no longer works in bash-2.0 because it violates POSIX. When ignorebraces is set (e.g. in sh mode) the following is perfectly valid: while true { echo foo } do ... done Here true is invoked with four arguments: {, echo, foo and }. Zoltan