From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 31218 invoked from network); 19 Jun 2020 06:39:06 -0000 Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with ESMTPUTF8; 19 Jun 2020 06:39:06 -0000 Received: (qmail 19389 invoked by alias); 19 Jun 2020 06:38:56 -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: Sender: zsh-workers@zsh.org X-Seq: 46074 Received: (qmail 27516 invoked by uid 1010); 19 Jun 2020 06:38:56 -0000 X-Qmail-Scanner-Diagnostics: from wout5-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.3/25842. spamassassin: 3.4.4. Clear:RC:0(64.147.123.21):SA:0(-2.7/5.0):. Processed in 3.513662 secs); 19 Jun 2020 06:38:56 -0000 X-Envelope-From: vq@larryv.me X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at spf.messagingengine.com designates 64.147.123.21 as permitted sender) X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrudejhedgudduudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpegtggfuhfgjfffgkfhfvffosehtqhhmtdhhtdejnecuhfhrohhmpefnrgif rhgvnhgtvggpgggvlhojiihquhgviicuoehvqheslhgrrhhrhihvrdhmvgeqnecuggftrf grthhtvghrnhepkedttdejleejveffkeeuhfeuudeltefhgfffvdekfedtteeitedtueeg teegueelnecuffhomhgrihhnpehophgvnhhgrhhouhhprdhorhhgnecukfhppedutddtrd duvddrudekgedrvdegieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgr ihhlfhhrohhmpehvqheslhgrrhhrhihvrdhmvg X-ME-Proxy: Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.14\)) Subject: Re: bad math expression: illegal character: " From: =?utf-8?Q?Lawrence_Vel=C3=A1zquez?= In-Reply-To: Date: Fri, 19 Jun 2020 02:38:15 -0400 Cc: Bart Schaefer , zsh-workers@zsh.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <17B9983F-268E-469C-9506-D5333528A805@larryv.me> To: Mikael Magnusson X-Mailer: Apple Mail (2.3445.104.14) > On Jun 18, 2020, at 7:19 AM, Mikael Magnusson = wrote: >=20 >> On 6/18/20, Bart Schaefer wrote: >>=20 >>> On Fri, Jun 5, 2020 at 2:02 PM Lawrence Vel=C3=A1zquez = wrote: >>>=20 >>>> On Jun 5, 2020, at 2:18 PM, Artur Renault = >>>>=20 >>>> while (( "$#" )); do >>>>=20 >>>> repro.sh:1: bad math expression: illegal character: " >>>=20 >>> For what it's worth, dash also rejects this. I assume that it and >>> zsh are just more strict about what constitutes a math expression. >>=20 >> Does anybody know if this is something we should change for sh >> emulation, or is it merely another unspecified POSIX corner-case? >=20 > If this is a POSIX requirement, it must have been very specific about > when quotes should be allowed (bash): >=20 > $ (( "0" )); echo $? > 1 > $ echo $(( "0" )) > bash: "0" : syntax error: operand expected (error token is ""0" ") Looks like the bash behavior changed at some point? % /bin/bash --version | head -n 1 GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin18) % /bin/bash -c '(( "0" )); echo $?' 1 % /bin/bash -c 'echo $(( "0" ))' /bin/bash: "0" : syntax error: operand expected (error token is ""0" = ") % /opt/local/bin/bash --version | head -n 1 GNU bash, version 5.0.17(1)-release (x86_64-apple-darwin18.7.0) % /opt/local/bin/bash -c '(( "0" )); echo $?' 1 % /opt/local/bin/bash -c 'echo $(( "0" ))' 0 Anyway, unless I'm missing something, POSIX seems pretty clear about this, as far as $((...)) goes: The expression shall be treated as if it were in double-quotes, except that a double-quote inside the expression is not treated specially. The shell shall expand all tokens in the expression for parameter expansion, command substitution, and **quote removal**. [Emphasis mine.] Next, the shell shall treat this as an arithmetic expression and substitute the value of the expression. = https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#= tag_18_06_04 vq=