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 bf9b6245 for ; Mon, 19 Aug 2019 07:02:26 +0000 (UTC) Received: (qmail 25062 invoked by alias); 19 Aug 2019 07:02:20 -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: 44690 Received: (qmail 8196 invoked by uid 1010); 19 Aug 2019 07:02:20 -0000 X-Qmail-Scanner-Diagnostics: from mail-wr1-f48.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.221.48):SA:0(-0.1/5.0):. Processed in 1.598326 secs); 19 Aug 2019 07:02:20 -0000 X-Envelope-From: stephane.chazelas@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.221.48 as permitted sender) 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== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state: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=RfYDRhdc0e8kBjIQXQ59dhniTq7LR1HVdju5gijQhAkc+bNqix2bkbro60t66z3/Bi PtCsy1w/wxFXXYcsP+34DxirATGuGsrlLTr9RCyzzRBGBbQ+SKqs/BLfsOuyq669nqSS Hm3wOTle86tSMe+4JOUZor+y3Hc3APXJKloYVaVQYg0x8wgkko5ryXfANEha7bhPW5sm NULu7x3I9VdFVgB5rEBP8uHM6/b3KOjFRr/lq0Er2uYjoMsWEAQ/rHgKrVcaEFHA2rQq W85Aeq9r0jKp++UHyj57EehHMARWSDOamhl2SZobQXJH60D9bI1qJOkVdKpTWSBiM5yK OKLA== X-Gm-Message-State: APjAAAVU/qURloJtOqrNbfV3vX1uuDONPd7dzKGpdbZxBS9m0UQqt+NN nAnqWJQSAr0MBrlVKOiGUQ4= X-Google-Smtp-Source: APXvYqzdi2cXMFJB8Lq3OO4OGU/q/E+Hq9hU7B3HTnOqF8iDyvsxBuR+e/1CP9vDFlUwNRoHtmy9CQ== X-Received: by 2002:a5d:4448:: with SMTP id x8mr25893909wrr.119.1566198105380; Mon, 19 Aug 2019 00:01:45 -0700 (PDT) Date: Mon, 19 Aug 2019 08:01:43 +0100 From: Stephane Chazelas To: Sebastian Gniazdowski Cc: Zsh hackers list Subject: Re: [bug] Problem with functions -s (string arg) math function & specific input Message-ID: <20190819070143.diqagwrdxx7ayp2m@chaz.gmail.com> Mail-Followup-To: Sebastian Gniazdowski , Zsh hackers list References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20171215 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