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=DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 18961 invoked from network); 19 Jun 2020 15:36:31 -0000 Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with ESMTPUTF8; 19 Jun 2020 15:36:31 -0000 Received: (qmail 18203 invoked by alias); 19 Jun 2020 15:36:19 -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: 46078 Received: (qmail 6396 invoked by uid 1010); 19 Jun 2020 15:36:19 -0000 X-Qmail-Scanner-Diagnostics: from mail-vs1-f47.google.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(209.85.217.47):SA:0(-2.0/5.0):. Processed in 2.461577 secs); 19 Jun 2020 15:36:19 -0000 X-Envelope-From: sgniazdowski@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.217.47 as permitted sender) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=bTPFkc/bnQUh17iS/trj2lMHRvuOGeK4Ot/kJ63yI04=; b=mQVNTihMK+St5R8/mmArDM5SpchpTiVqCgm/tGJVBs+6gboNRr+EGNtPkV/8RLhtYN y0ddi6Eg99e0UmegSBSbXT4KtHp3DY3XhVq/M1YF05TmHExT4GusOuSaZ/0dJu6ROOAV UzUmoRB0szgxzYvbzfYnezN/ELFXMnPk9jCeM1YX9Chhg5m7v2E1QnvH6de4J3xSmLrT t/Hoai23oyepezrgeUbBzHD6iV8b3JRfgkUL0QuEXb3LtC7Fq+ZihtiKR/3YekxiXbPB 9SlThxJB9F7QJ3YUpgjUBolI2FZ1TomEXah3bWdRZPK8TTOe8XWl0QWkHXNkRE3fgMvq VomA== X-Gm-Message-State: AOAM530nfRFhEyerHAOUUchrYFPzZBRnbTj/I5M3/7X1+w7Bf8LaSS5h +aQJEyby7rp7VgT7PpU+MIQmpRBwjg3WGt1Bd9g= X-Google-Smtp-Source: ABdhPJwxVWG+e/q7Tlb/HL4dPClaZhioLz14V8Tvc+fhd0qaiGqCF9KCYamIABZXS62qbR48HOCEPoVpMneT73RmVJA= X-Received: by 2002:a67:fd75:: with SMTP id h21mr4421281vsa.77.1592580941185; Fri, 19 Jun 2020 08:35:41 -0700 (PDT) MIME-Version: 1.0 References: <17B9983F-268E-469C-9506-D5333528A805@larryv.me> In-Reply-To: From: Sebastian Gniazdowski Date: Fri, 19 Jun 2020 17:35:25 +0200 Message-ID: Subject: Re: bad math expression: illegal character: " To: =?UTF-8?Q?Lawrence_Vel=C3=A1zquez?= Cc: Mikael Magnusson , Bart Schaefer , Zsh hackers list Content-Type: multipart/alternative; boundary="00000000000046877705a871a51f" --00000000000046877705a871a51f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Maybe a bash emulation could be added? Equal to: emulate zsh -o noshglob -o braceexpand -o kshglob + the quotes inside (( ))? emulate already accepts "bash" as the emulation level. On Fri, 19 Jun 2020 at 08:39, Lawrence Vel=C3=A1zquez wrote: > > On Jun 18, 2020, at 7:19 AM, Mikael Magnusson wrote= : > > > >> On 6/18/20, Bart Schaefer wrote: > >> > >>> On Fri, Jun 5, 2020 at 2:02 PM Lawrence Vel=C3=A1zquez > wrote: > >>> > >>>> On Jun 5, 2020, at 2:18 PM, Artur Renault < > Artur.Renault@microsoft.com> > >>>> > >>>> while (( "$#" )); do > >>>> > >>>> repro.sh:1: bad math expression: illegal character: " > >>> > >>> 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. > >> > >> Does anybody know if this is something we should change for sh > >> emulation, or is it merely another unspecified POSIX corner-case? > > > > If this is a POSIX requirement, it must have been very specific about > > when quotes should be allowed (bash): > > > > $ (( "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 --=20 Sebastian Gniazdowski News: https://twitter.com/ZdharmaI IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zinit Blog: http://zdharma.org --00000000000046877705a871a51f--