From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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,FREEMAIL_FROM,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 4e47ba2a for ; Mon, 19 Aug 2019 09:54:09 +0000 (UTC) Received: (qmail 20452 invoked by alias); 19 Aug 2019 09:54:02 -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: 44691 Received: (qmail 28617 invoked by uid 1010); 19 Aug 2019 09:54:02 -0000 X-Qmail-Scanner-Diagnostics: from mail-ua1-f46.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.101.2/25545. spamassassin: 3.4.2. Clear:RC:0(209.85.222.46):SA:0(-0.1/5.0):. Processed in 1.307161 secs); 19 Aug 2019 09:54:02 -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.222.46 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=udJfePUy2Ey09dmDKP5ubm38cVjNjwZbWJGfRT5Q4Jw=; b=dzaczcmvRwxrRSRVWJPEeIQCgU9X6ydUByaCZYn8kq60hV+sjEYPuREhdZaXhAW1h1 Ve+3TLAzbEpcckmUlYeClLgeBUBdH2Tzd121XJuyvETGNpkqnSFwVNzSddfSk1LpNtFL VxvVWWfxNu5/fW9LdpUhGD8GhLwAl9UoxQEoFXoD21nSFdgmZ5iWPAsbQyhBlaIfvHKW dQZw0XJ/88lsdp9INt3FUntXT4xl+4HBCADbxf8Nx5OKRpwQ1c4xgPOSMvABel9wz2+z D07xOXUgcLXKUsaadCQoNkiz/Un2YYy9IRKPK/hV9Mo262CEd6Kv4lgUZlwkMsdSmrm/ md2g== 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; bh=udJfePUy2Ey09dmDKP5ubm38cVjNjwZbWJGfRT5Q4Jw=; b=gArCeQWDmxScOUGozcR9aX+Pqnqu50qMaltMdqHM+HS5+66ymZd3asYdsbSW48Qnup cC6RRGalSmHdHMQ68tV0Autrvk3MzWVt4sW6QEsX4Ih1VM07US0wwQ1gUGH7EuZ1aZk+ P/Vb317wvpKKWHrfHphmqhqSJb6qG0uNgOWl5FkdjjGrFcAYwzEvn9i5qZHYYmOeqzOr eiFDbovYlKeITuvBlBMt66x1Ksr8/6KAnRri+H4WTnPAyuQM5ZlqHCpeT0p3NuNbOUIf ZYW+ZQt97HiAZsxpnq0RImjIG45VelPBdVltsacEWMZHsqjaa6mXLd8TlogxlkYqpDHW T8Cg== X-Gm-Message-State: APjAAAUMa+ycJRozWutMNxeZS2u0FM7QOj/g1Z9pXzT9eU0AY80euhX9 Vf2gchz5Rx+9B/59YI2lQMCfyfWNiJkCthVPCYU= X-Google-Smtp-Source: APXvYqz3NdiaJlkPOgJSwizq0fspc420z1yAkh89dYJYMq8UGLGQbZlzKG8Qm9equPoG6Rt6LcYlDFDLS2JOjl5Z+do= X-Received: by 2002:ab0:641:: with SMTP id f59mr12226620uaf.82.1566208406402; Mon, 19 Aug 2019 02:53:26 -0700 (PDT) MIME-Version: 1.0 References: <20190819070143.diqagwrdxx7ayp2m@chaz.gmail.com> In-Reply-To: <20190819070143.diqagwrdxx7ayp2m@chaz.gmail.com> From: Sebastian Gniazdowski Date: Mon, 19 Aug 2019 11:53:14 +0200 Message-ID: Subject: Re: [bug] Problem with functions -s (string arg) math function & specific input To: Sebastian Gniazdowski , Zsh hackers list Content-Type: text/plain; charset="UTF-8" On Mon, 19 Aug 2019 at 09:01, Stephane Chazelas wrote: > 2019-08-19 03:00:24 +0200, Sebastian Gniazdowski: > > Hello, > > the contents of the string argument seems to be evaluated in some way > > (while it shouldn't). Reproducing snippet: > > > > mtest() { print ${#1}; } > > functions -s -M mtest 1 1 mtest > > input=') &>/dev/null' > > (( mtest($input) )) > > > > Output: > > 0 > > zsh: bad math expression: operand expected at `>/dev/null...' > [...] > > Expansions are done first, and then the result evaluated as > an arithmetic expression. That's a POSIX requirement (for > $((...))) > > So here, you're evaluating the: > > mtest() &>/dev/null So it seems that ${MATCH//\)/\\\)} should suffice to fix this problem, as it seems that once a string is within parens (correctly), further expansions are put on hold for the -s functions. -- Sebastian Gniazdowski News: https://twitter.com/ZdharmaI IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin Blog: http://zdharma.org