Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [bug] Problem with functions -s (string arg) math function & specific input
- X-seq: zsh-workers 44691
- From: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- To: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: [bug] Problem with functions -s (string arg) math function & specific input
- Date: Mon, 19 Aug 2019 11:53:14 +0200
- 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==
- In-reply-to: <20190819070143.diqagwrdxx7ayp2m@chaz.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAKc7PVDCL9q+x+WXAUv5Mf+otvV6pmaMeTSo-EA07_5cOD49qQ@mail.gmail.com> <20190819070143.diqagwrdxx7ayp2m@chaz.gmail.com>
On Mon, 19 Aug 2019 at 09:01, Stephane Chazelas
<stephane.chazelas@xxxxxxxxx> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author