From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 14946 invoked from network); 7 Mar 2021 16:37:30 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 7 Mar 2021 16:37:30 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1615135050; b=qHwmoIdjCL81RKWGPx7BSGuxiDwtUoA4tswD2tkyN0DPvRx035Fb17WAGPMEk33JtB2nOK19/e h/MTKZy09moFA4fHGEP8ZVjmNTqvcdMqA2h73oygLyHn/b5ui6YXwnRPu/L+EdncOUAAlDTK3k EYKS4GTyrFbvt8JPGR67jqdwY6Ae1zKCayCj3rTuUck04Za+YeL36MAifQ0xOKJye3Ya4OnkTZ zm6j/EBmm8MJ0dIE0nN05RiUUMV4XeerADlYGenS5XFzANr+fPMY5kckkKT5E5tJ+9l7uagDz/ zFeVR2OOqrnDn87NfAc6ENyv/dgziUOY3MWhDUqLXd/PPQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail.zaclys.net) smtp.remote-ip=178.33.93.72; dmarc=none header.from=fsfe.org; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1615135050; bh=vRAUVAgaWwoEApHWj7Xfkrl+ykLcAr1kp+ORlztrLZc=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:MIME-Version:Message-ID:Date:Subject:To:From: DKIM-Signature; b=CwFyGLl4tJOMkoZ4rsGJsItxDplM9YX5FmEvaZ/1V8YdmI7IhHr6uwZH0lOun0YdD66I1B4kTE VSNBwrfWFTfV9sH+3F0sRdjMpxBNCJzqXr3WcY/v7dtDAIOJLvv8Ddp0rhbw3kDtahbkBMePgm dmyiYjYJYtKRFJGOv1tN21plN0I3BNkNc2yXEwazvQtMxHh6VHWdWE8dLbyk10RBCcXSz3gvtL OjOiUfOBpvTppcCGL+IxVNxL6/MlDGrdEX/fzGKW4SaAMWNF4ajUQjbDpxxdfoMlZE8I20VuNc Whs6W+QXDy197IVBqhN3rysMiRio1x6VrCkh66LHE3Wjbw==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:MIME-Version:Message-ID: Date:Subject:To:From:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References; bh=mZy7tWtDIwlrpiHX+nPG1055VCAkTakU11nyKSRpbaE=; b=DyUslo4qSXu8bqZ+Ta27I/XVdu 5ZwQsRIPzE7wE0PR2Zv0pkGxpjx9mEMP/gNC0C4GuD/k5Dd0YMldZbkuh0hV2fqmE/q1k7HYIP9Kc V99vsK3xt9MpLtg+hXNXKJRLrPGfloJXtrwI6/uaDI2+sbmsFtArJ2UeGJDay29SCpOtEjeA1GWqD ANuSa9YUJ+ylUKNNQOnBwK7s8HUG1TT4yo+higPnu2VM03ubs/8LygxQSFeomqRNOmuscjz5bvzIM CyUNQisJUrtek02dPeAElmojIvonw9iAFIYWpRW1YgA/DbqT3qsbIybRIJoT7fJcbnNfHbJwuFkcp mimjL6BQ==; Received: from authenticated user by zero.zsh.org with local id 1lIwPI-000HqA-52; Sun, 07 Mar 2021 16:37:28 +0000 Authentication-Results: zsh.org; iprev=pass (mail.zaclys.net) smtp.remote-ip=178.33.93.72; dmarc=none header.from=fsfe.org; arc=none Received: from mail.zaclys.net ([178.33.93.72]:43691) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1lIwP1-000Hge-Ck; Sun, 07 Mar 2021 16:37:12 +0000 Received: from EiMaegg.local.EiMaegg (c-185-110-91-124.customer.ggaweb.ch [185.110.91.124] (may be forged)) (authenticated bits=0) by mail.zaclys.net (8.14.7/8.14.7) with ESMTP id 127Gb9Hf026598 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Sun, 7 Mar 2021 17:37:10 +0100 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.zaclys.net 127Gb9Hf026598 Authentication-Results: mail.zaclys.net; dmarc=fail (p=none dis=none) header.from=fsfe.org Authentication-Results: mail.zaclys.net; spf=fail smtp.mailfrom=klt@fsfe.org From: "Nikolaus Thiel" To: zsh-workers@zsh.org Subject: zmathfunc: min, max, sum throw error if result equals 0 Date: Sun, 07 Mar 2021 17:37:09 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (darwin) MIME-Version: 1.0 Content-Type: text/plain X-Seq: 48146 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: There seems to be a bug in zmathfunc: When the result of min, max or sum equals 0, the functions throw an error. If they are used within a script with the option "set -e" then the script aborts, cf. test script below. I have confirmed this behaviour on two systems: (1) Apple MacBook Air, Ubuntu 20.04.2 LTS Linux Luftbuch 5.4.0-66-generic #74-Ubuntu SMP Wed Jan 27 22:54:38 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux zsh 5.8 (x86_64-ubuntu-linux-gnu) (2) Apple iMac, macOS 11.2.2 Darwin Kernel Version 20.3.0: Thu Jan 21 00:07:06 PST 2021; root:xnu-7195.81.3~1/RELEASE_X86_64 zsh 5.8 (x86_64-apple-darwin20.0) -------- Test Script -------- #!/usr/bin/env zsh set -e OS=$(uname) if [[ ${OS} == "Darwin" ]]; then ### Mac OS X source /usr/share/zsh/5.8/functions/zmathfunc else ### Ubuntu 20.04 source /usr/share/zsh/functions/Math/zmathfunc fi echo "OS = ${OS}" zsh --version echo "works fine" x=$(( min(2,-1,3) )) echo "min(2,1,3) = $((x))" x=$(( max(2,-1,3) )) echo "max(2,-1,3) = $((x))" x=$(( sum(2,-1,3) )) echo "sum(2,-1,3) = $((x))" echo "min, max, sum throw an error if result=0" echo " => set -e causes script to abort" x=$(( sum(-2,2) )) echo "sum(-2,2) = $((x))" x=$(( min(2,0,3) )) echo "min(2,0,3) = $((x))" x=$(( max(-2,0,-3) )) echo "max(-2,0,-3) = $((x))" -------- Output on Mac OS X -------- OS = Darwin zsh 5.8 (x86_64-apple-darwin20.0) works fine min(2,1,3) = -1 max(2,-1,3) = 3 sum(2,-1,3) = 4 min, max, sum throw an error if result=0 => set -e causes script to abort -------- Output on Ubuntu -------- OS = Linux zsh 5.8 (x86_64-ubuntu-linux-gnu) works fine min(2,1,3) = -1 max(2,-1,3) = 3 sum(2,-1,3) = 4 min, max, sum throw an error if result=0 => set -e causes script to abort