From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.3 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RDNS_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 Received: (qmail 7555 invoked from network); 23 Mar 2020 06:54:39 -0000 Received-SPF: pass (primenet.com.au: domain of zsh.org designates 203.24.36.2 as permitted sender) receiver=inbox.vuxu.org; client-ip=203.24.36.2 envelope-from= Received: from unknown (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with ESMTP; 23 Mar 2020 06:54:39 -0000 Received: (qmail 17367 invoked by alias); 23 Mar 2020 06:54:28 -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: 45607 Received: (qmail 1735 invoked by uid 1010); 23 Mar 2020 06:54:28 -0000 X-Qmail-Scanner-Diagnostics: from mail-io1-f46.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.2/25758. spamassassin: 3.4.2. Clear:RC:0(209.85.166.46):SA:0(-2.0/5.0):. Processed in 1.913164 secs); 23 Mar 2020 06:54:28 -0000 X-Envelope-From: mikachu@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.166.46 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:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=2cbmfUCCONXNzeB1Isk2Fq8+wpHXO1qRG2jYNVdDa4U=; b=EAEcghsIobV17Xk7cNYkRcT/TSqvbEKgsuyvGnv75khQuxe4NAiF35qaCruOVqbYB2 xMyZMSlJ382x905daj5qjms2c1V/HVBHqI3xc7BhdotpZO767i3OyhBeoAa+Vq3mAYyw mWqhyvk3pugmFFyH/7FHa7jjJOaJ3CiheuO74+cQtof6CLgZ7h7GAVcNWwVaoRCuyd1l LNyll9HFdocW0v7oOefWU/v6lHPJi//ZpnTDbZHGzsBCyrAyTGUZ3t1oGHG7uubIV4vP 36+hjSYM+kD1es+MWKsV67VIdA4o4wHQ+GAS7YJqfgwg0inCLFBngiAWWjwZuKkGvCZ/ X5IQ== X-Gm-Message-State: ANhLgQ12cEN9SU1EIjt3TdYJbK4koEL7CweiI9otCuK8b/5WUqza1GE/ invV4R5d3fzSFNHeyqN0LbTySplsWX9P5L3sfnw25g== X-Google-Smtp-Source: ADFU+vu4+cHEjugPuVkF9U1mIedsFFflPHngd6UVwJycgpVSZlvnKC1VAFxaMPWSoKcNfOmEH3UPkBfv+JDboBitIso= X-Received: by 2002:a6b:6d16:: with SMTP id a22mr7022244iod.182.1584946432279; Sun, 22 Mar 2020 23:53:52 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20200323053155.6644a1d6@tarpaulin.shahaf.local2> References: <20200317032945.696066ab@tarpaulin.shahaf.local2> <20200323053155.6644a1d6@tarpaulin.shahaf.local2> From: Mikael Magnusson Date: Mon, 23 Mar 2020 07:53:51 +0100 Message-ID: Subject: Re: globbing in the repeat-count word gives "illegal character" To: Daniel Shahaf Cc: zsh-workers@zsh.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On 3/23/20, Daniel Shahaf wrote: > Mikael Magnusson wrote on Tue, 17 Mar 2020 19:37 +0100: >> On 3/17/20, Daniel Shahaf wrote: >> > [[[ >> > $ Src/zsh -f >> > % cd "$(mktemp -d)" >> > % repeat ? true >> > zsh: bad math expression: illegal character: \M-W >> > % >> > ]]] >> > >> > [[[ >> > frame #1: 0x0000000000487eac zsh`matheval(s=3D"\x97") at math.c:1479 >> > 1476 x =3D mathevall(s, MPREC_TOP, &junk); >> > 1477 mtok =3D xmtok; >> > 1478 if (*junk) >> > -> 1479 zerr("bad math expression: illegal character: %c", >> > *junk); >> > 1480 return x; >> > 1481 } >> > 1482 >> > (lldb) p *junk >> > (char) $0 =3D '\x97' >> > ]]] >> > >> > [[[ >> > % ag 0x97 | cat >> > Src/zsh.h:191:#define Quest ((char) 0x97) >> > % >> > ]]] >> >> Not limited to globbing characters, >> >> % repeat { false >> zsh: bad math expression: illegal character: \M-O > > And what about this one? =E2=80=94 > . > % repeat 2*2 pwd > zsh: bad math expression: illegal character: \M-G > > What's the expected behaviour on this one? Should it report a different > error, or perform globbing, or take =C2=AB2*2=C2=BB as a valid arithmetic > expression and run 4 iterations of the loop body? Same as for return, I feel, ie, % () { return 2*2 } (anon): no matches found: 2*2 % () { return 2\*2 }; echo $? 4 But if, due to hysterical raisins, globbing never runs for repeat here, I guess we may as well just have it do arithmetic unquoted there... but#2 it's probably confusing wrt spaces around the * in that case... So yeah, I guess I'm not too sure :). My brain isn't in zsh-code-mode so I can't comment on the rest... > Code-wise, execrepeat() calls singsub() when the "has tokens" flag is set= : > > 487 int > 487 execrepeat(Estate state, UNUSED(int do_exec)) > 488 { > =E2=8B=AE > 500 lastval =3D 0; > 501 tmp =3D ecgetstr(state, EC_DUPTOK, &htok); > 502 if (htok) > 503 singsub(&tmp); > 504 count =3D mathevali(tmp); > 505 if (errflag) > 506 return 1; > > When singsub() returns, there are still tokens in the string (Quest, > Inbrace, or Star, respectively). Is that expected, or should singsub() > have converted those tokens to their ASCII equivalents? > > Is the fix just to call untokenize() after singsub()? Some singsub() > callers do this, but some don't, and I haven't figured out the rule (if > there is one). I tried this and it seemed to work, but=E2=80=A6 > > Cheers, > > Daniel > --=20 Mikael Magnusson