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=-1.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, LONGWORDS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 31488 invoked from network); 15 Nov 2021 17:40:35 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 15 Nov 2021 17:40:35 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1636998035; b=LWEW9rSpAQI9mPTtBJpIATuv2Lou02A02EPqQuLhRpt04Ob3CRy3psDakYPwMseWq5yzGDA8G5 d0rFnYwuR466nDczrDLNDpND+tKQhgTab1sBhn8KyeMtp2WTnmMYafxFFDWdeP1D4pKa6Sz2aC 2DvuuNnjEWO0Xg5HxBDeMclBOZ7A8Tmri8eqCn1eb51LqryUNyKSpIGsaaOj/fnieWFblWBHvJ E/sV5Qhk7lYQZAEgsGAUADPN/yGn4frt1xriEGXTc4bPUQcRXoR6kdOTliKw3oCCV1B9GMMwsf yWCoLHlcgY1YfblGR+Myo8hU3gID0I8rmCKSGRiQ5vROFg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (lb2-smtp-cloud7.xs4all.net) smtp.remote-ip=194.109.24.28; dmarc=none header.from=inlv.org; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1636998035; bh=nQwXzg5o0vtOhs5s/6QjPxBh0vqRmmO2L6PS1c95Hvc=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Subject:From:To: MIME-Version:Date:Message-ID:DKIM-Signature; b=icw8Lr91PFCYWzkbxV2pRrVvdnGIHqp4yn2ngjGPqf3km7JmsCOqf1FpwuTqR1JZsEU/+YcarM 7qckg1FacssDC15fT8h6HGuQwPKlNiQCP4NDBi+aEVfKVNMPXbEwIc/q4sp1zrhyJ8neC4VMaM iOlWEHZpMJHufN72vvv/xUwXExFJLEhoQsYAc+dFSau5n0lEciGcQTOZ0BQonnHGzAHqMbMbLX KaBFAXZb8Llm4gnV5DCOZisEsQ41VBeVrWkRbAM7PjN5ejM49LlLLNLSkeUebXGH3XJEEdO+vI FwnHrrhAg4OtAdPA6uCRB3pDF0ElENLOs8HIyYbSftmnmg==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:Subject:From:To:MIME-Version:Date:Message-ID:Reply-To:Cc: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References; bh=jnFmP6ftK0hvoQRSOefrnAKlph2e1xYLnwbiGgCDq38=; b=I7tnqvjxZZ7VVIJCxa25BPvpGj miUkK2wyIOd1S4MVNqHUCny7mbH1/RlCjzqvcq9TyK0j/c9Lskf5udIxVOskiz2EoOX72NkaKYoA+ lv7ImTz3IANUOmaLiMJPX6SjOJip+aiAJNu2g5BLAj+GpQzGN9HzK0vfcx3xvdHsdiAK+/r5og4xh A3U57BYt3CzzTqM4k1tu145/kU7K4maWzL04KOCgC2yPjjJUhyPn0+Dz5Dhf48uR31rKRt2kRf2MM 2i4ea3UUaQk0aGsYsXWtgbrdN9sk8na7jP7E5UpJCwkb4jhICUGkf/i6++yAwZ4+a5H39JAwoXS6o utidEmog==; Received: from authenticated user by zero.zsh.org with local id 1mmfy6-000JMg-Cc; Mon, 15 Nov 2021 17:40:34 +0000 Authentication-Results: zsh.org; iprev=pass (lb2-smtp-cloud7.xs4all.net) smtp.remote-ip=194.109.24.28; dmarc=none header.from=inlv.org; arc=none Received: from lb2-smtp-cloud7.xs4all.net ([194.109.24.28]:45581) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1mmfxr-000J7s-Q1; Mon, 15 Nov 2021 17:40:20 +0000 Received: from cust-839a4cd3 ([IPv6:fc0c:c184:1742:62a6:ec35:71f7:b085:244]) by smtp-cloud7.xs4all.net with ESMTPA id mfxpmLIeACMnAmfxqmJBmY; Mon, 15 Nov 2021 18:40:19 +0100 Message-ID: Date: Mon, 15 Nov 2021 18:40:17 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:91.0) Gecko/20100101 Thunderbird/91.3.0 Content-Language: en-CA To: Zsh hackers list From: Martijn Dekker Subject: [BUG] POSIX arith: inf, nan should be variables Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4xfFPlrKtX2/9qbc3/AYHtN8H2MBVwoos1nYdQAZSmWitNbMd1U44m5ZsEikJvFMo5aAZccLYA8VbqBa2O4sbg5XY8cN2jCfEeuqBqHVxWWa0hMwR8h+5Q pNUZGTIoJhvcZvKbSJm0/wWrI9i7ERykvD+shx+630670A4Nm0Gkr+LlWSyq+6AMH7lS5w8XgR+vpodheCcsT0cZ7JF+WoUmpoPbPkdD2sJloCcbiYUoDPBC D7t0wvMSCc1cNKndzMPGzgDTlv9w/saUuO/3JTiGG4iv6atNJ0hnWeSau+g0zQKS X-Seq: 49590 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: $ zsh --emulate sh -c 'inf=1; nan=2; echo $((inf)) $((nan))' Inf NaN Expected: 1 2 This is a POSIX compliance issue that ksh93 also has (I've just fixed in ksh 93u+m). I can see why this is needed for full floating point arithmetic support, but in POSIX sh, all case variants of inf and nan are perfectly legitimate variables that portable scripts should be able to use, including in arithmetic evaluation. Their recognition should be turned off for sh emulation, but not for ksh emulation as ksh93's native mode also supports floating point arithmetic. So, what shell option to tie that to? That's a bit difficult. It needs to be an option that is on for sh, but off for ksh (or vice versa). A comparison of 'set -o' output between sh and ksh modes shows that the options are limited to the following: bsdecho ignorebraces kshglob kshoptionprint localoptions localtraps octalzeroes promptbang sharehistory singlelinezle The only one of those that has anything to do with an arithmetic context is octalzeroes, so that one may be the least bad one to choose. The preliminary patch below does that. Perhaps octalzeroes could be renamed to something like posixmath, so that it becomes legitimate to attach this and any other POSIX arithmetic quirks to this option without further crowding the shell option space. Thoughts/opinions? --- a/Src/math.c +++ b/Src/math.c @@ -863,7 +863,7 @@ zzlex(void) p = ptr; ptr = ie; - if (ie - p == 3) { + if (ie - p == 3 && !isset(OCTALZEROES)) { if ((p[0] == 'N' || p[0] == 'n') && (p[1] == 'A' || p[1] == 'a') && (p[2] == 'N' || p[2] == 'n')) { -- || modernish -- harness the shell || https://github.com/modernish/modernish || || KornShell lives! || https://github.com/ksh93/ksh