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 44690
- From: Stephane Chazelas <stephane.chazelas@xxxxxxxxx>
- To: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- Subject: Re: [bug] Problem with functions -s (string arg) math function & specific input
- Date: Mon, 19 Aug 2019 08:01:43 +0100
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=00TjYRM+CxxK/S64NmAUWfavdISR3Cd5b30IweszlSE=; b=Gbv0qQsADL+m4cGOylwrdKyBeFR6n+ZDNbhb/AcNTB24Dc2vy+aWPy3DoV8d2VESCV hbD4B/kKO2ow5cGphTtOHf7JfW+vrr6omBYfcj8H6pRjlhvYHwQBWU2vcvg+GzqRB7gq UJAYrT1Po5oSCmyufEPgeq1ETtVWxpyisIbhokRPU40JJtOC0oCEYGErTJrsS5mjdwtT cgoiTYzv5RDSRJafLSd68mioRIsbQYHhrZFnR2XCudnRp4YEN2+Zu1P+L9IL/jmKbVPM ix+ufdZ0Ibm5KMaVRYVas+t0L3FsQ8UtCTc1Dgwb4tHzlj5Uvz34G+nDfrFRGJRKvoRi Xjjg==
- In-reply-to: <CAKc7PVDCL9q+x+WXAUv5Mf+otvV6pmaMeTSo-EA07_5cOD49qQ@mail.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>
- Mail-followup-to: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAKc7PVDCL9q+x+WXAUv5Mf+otvV6pmaMeTSo-EA07_5cOD49qQ@mail.gmail.com>
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
arithmetic expression.
Just like in:
a='1] + b[2'
echo $((b[$a]))
you're evaluating the b[1] + b[2] arithmetic expression.
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author