From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: zsh-workers-return-43607-ml=inbox.vuxu.org@zsh.org X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id b7cefbe1 for ; Fri, 5 Oct 2018 09:14:59 +0000 (UTC) Received: (qmail 29612 invoked by alias); 5 Oct 2018 09:14:44 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 43607 Received: (qmail 17460 invoked by uid 1010); 5 Oct 2018 09:14:44 -0000 X-Qmail-Scanner-Diagnostics: from mailout2.w1.samsung.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(210.118.77.12):SA:0(-6.9/5.0):. Processed in 2.356457 secs); 05 Oct 2018 09:14:44 -0000 X-Envelope-From: p.stephenson@samsung.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20181005091436euoutp02eead600dee6ac1834f56108dc3a94822~aq5RzH5gc0339303393euoutp02N DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1538730876; bh=jG3Kex1Q7n8omiLzAjsZ9Sp7mrPLlPqp8WiR5JcZ2Ks=; h=Subject:From:To:Date:In-Reply-To:References:From; b=YbyA3/r5pfbXFWZvf5P/e1zHViYBNaydeE2Ddh06COHiPEzuE1SMChE4u/+hV8mhJ 62+Myjy6OX06FKsXkoLl8MShqGpJCmjyQoM3g/PdRNmQypbCsHL94gS3vvkdk5LpVY WzTM/f5NE6ofUZJrTDC77Qafeb55Uqo5DdC6sxos= X-AuditID: cbfec7f5-34dff700000012c6-5d-5bb72b7b6d24 Subject: Re: Parse error (lack thereof) on incomplete loops From: Peter Stephenson To: "zsh-workers@zsh.org" Date: Fri, 5 Oct 2018 10:14:33 +0100 In-Reply-To: X-Mailer: Evolution 3.18.5.2-0ubuntu3.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrAIsWRmVeSWpSXmKPExsWy7djP87rV2tujDVZe1rU42PyQyYHRY9XB D0wBjFFcNimpOZllqUX6dglcGdceb2MtWMlX8ffHfqYGxuXcXYycHBICJhKTJxxl72Lk4hAS WMEocantPguE08ck8XnDPFYIp5dJYuLW56wwLTvunYBqWc4o0d7zhgWual3rGWYI5zSjxM/p M9kgnPOMEvcurmIG6RcWsJbYvugHC4jNJmAoMXXTbEYQW0RAX+Lin1tgNouAisSL83fB9nEK BEqc6vzHDLFbQ2LDzWNMIDavgKDEyZlPwOYwC8hLNG+dDbZZQuAxm8TrGxCDeAXKJG5eW8oC 0ewi8f1eN5QtLPHq+BZ2CFtG4vTkHhaI5nZGiTWTXrNDOD2MEpuO3mGEqLKW6Lt9EcjmAFqn KbF+lz5E2FHix+ZWdpCwhACfxI23ghAH8UlM2jadGSLMK9HRJgRRrSaxo2krI0RYRuLpGoUJ jEqzkHwzC8k3sxBWLWBkXsUonlpanJueWmycl1quV5yYW1yal66XnJ+7iRGYDk7/O/51B+O+ P0mHGAU4GJV4eF8ob4sWYk0sK67MPcQowcGsJMIbXgIU4k1JrKxKLcqPLyrNSS0+xCjNwaIk zrts3sZoIYH0xJLU7NTUgtQimCwTB6dUAyPLheiti619/tz8mC46TeOfn9pMQxMPnhXX09JF XWa+YlMoMbnxTlq8dpdafN62foktYqUf0uUvRNRqHDhS87nq+XHt3AYTs8ysCW0OzPuEHReu n11Vs9hwz+/2nwJr3pQEvtt1p7t+a6O+c1vwvY70Wsvzm9XceNRrLjYbCUvJby5JW3XaS4ml OCPRUIu5qDgRACWI2hUDAwAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpmkeLIzCtJLcpLzFFi42I5/e/4Pd0q7e3RBke261kcbH7I5MDoserg B6YAxig9m6L80pJUhYz84hJbpWhDCyM9Q0sLPSMTSz1DY/NYKyNTJX07m5TUnMyy1CJ9uwS9 jGuPt7EWrOSr+PtjP1MD43LuLkZODgkBE4kd906wdzFycQgJLGWUWNa5iBUiISPx6cpHdghb WOLPtS42iKJuJonps+YyQTinGSWOXp4C1X6eUWJR30k2kBZeAUOJaZuaWEBsYQFrie2LfoDZ bEDxqZtmM4LYIgL6Ehf/3AKzWQRUJF6cvwu2mlMgUOJU5z9miKG3mSQWHDnIBJJgFtCUaN3+ G+omDYkNN48xQSwTlDg58wkLRI28RPPW2cwTGIVmIWmZhaRsFpKyBYzMqxhFUkuLc9Nzi430 ihNzi0vz0vWS83M3MQIjYNuxn1t2MHa9Cz7EKMDBqMTDO0FxW7QQa2JZcWXuIUYJDmYlEd7w EqAQb0piZVVqUX58UWlOavEhRlOgjyYyS4km5wOjM68k3tDU0NzC0tDc2NzYzEJJnPe8QWWU kEB6YklqdmpqQWoRTB8TB6dUA+MK/f2lf9ssvgRWcM5YdDIyzdKgiFPw2qfpC33nP4pbMTU9 Y42QnmHfs5+8VwTfBGtkv0nXmaUaefTzsm2zJkeIx//4mjMzY+2ko4tX90//eejKPiHnjwKz 3hizHtSMONh1Z5p96i6/wIQvG07u71NU7Dxs/FHZ8qaHyK7wW8Ztly3+XVtuGMKuxFKckWio xVxUnAgA5rMNdZYCAAA= Message-Id: <20181005091435eucas1p26edaafb362de339b01c3cb5780fbd108~aq5QQQ6pF1496014960eucas1p2g@eucas1p2.samsung.com> X-CMS-MailID: 20181005091435eucas1p26edaafb362de339b01c3cb5780fbd108 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20181004154947epcas4p2441e109a2c4e060bf39f0f6925e98241 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181004154947epcas4p2441e109a2c4e060bf39f0f6925e98241 References: <20181004163158eucas1p234a045be013b5463d8db44314ed217dc~adN28lJmq0822408224eucas1p2F@eucas1p2.samsung.com> On Thu, 2018-10-04 at 13:34 -0700, Bart Schaefer wrote: > My problem with it is that it's not consistent. >  > set -x > { while false > while false > } >  > The shell is now in an infinite loop executing "false".  Can this > really be intentional? What's happening here is to do with while false; do   print Never executed done print $? This prints 0.  So the body of the last "while false" is actually irrelevant. The original expression is parsed as {   while {     false     while false; do     done     }; do   done } which is an infinite loop because of the point above.  Or, in other words, it's the same as {   while false     true } This also used to give a parse error for the same reason.  However, apart from that there's nothing new --- you can see that even with NO_SHORT_LOOPS, while false; true; do print Looping; done (where that "true" could be a "while false" loop, if you like) has been an infinite loop since way back when.  The only new feature is that all the "do ... done" clause has become optional if it's possible to infer there's nothing there.  That seems to me entirely consistent. Without a "do" while doesn't know where the expression ends.  That's fundamental to how SHORT_LOOPS works and why I regard it as so ill-defined as to be useless in all but the simplest cases.  This new (accidental) feature is giving it a particularly straightforward way of telling it where the expression ends. Anyway, I'm perfectly happy either restoring the parse error or not, depending on the opinions of people more likely to use or fall foul of this kind of syntax but I don't think the reason "it's all a bit weird" is good enough on its own for restoring it.  Short loops *are* weird. pws