*X-seq*: zsh-workers 48656*From*: Vincent Lefevre <vincent@xxxxxxxxxx>*To*: zsh-workers@xxxxxxx*Cc*: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>*Subject*: Re: sh emulation POSIX non-conformances ("inf"/"Inf" in arithmetic expressions)*Date*: Thu, 22 Apr 2021 17:31:00 +0200*Archived-at*: <https://zsh.org/workers/48656>*In-reply-to*: <20210413071742.tisslgg5fdqbageg@chazelas.org>*List-id*: <zsh-workers.zsh.org>*Mail-followup-to*: zsh-workers@xxxxxxx, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>*References*: <7FD930F4-37CD-402B-9A06-893818856199@dana.is> <CAH+w=7aAZKpT0f5LT7RaoCehyO6UZe6FimzuQqOP4o=+EwZs2w@mail.gmail.com> <F56FD538-0428-4D03-BBE2-6E53154EC0EA@dana.is> <CAH+w=7a6sjNJsDv4KJyW-o45+Q7GNEp7_TL4LGd-os1ozF8T9A@mail.gmail.com> <20210411175726.hxnm33mxoska2tsm@chazelas.org> <20210411193154.zkekzvb4o6xmriwo@chazelas.org> <CAH+w=7aAeEMDJX9q4M9jvb0Z8nhYuOdHRk_N4KS91yKP5B5eLQ@mail.gmail.com> <20210413071742.tisslgg5fdqbageg@chazelas.org>

On 2021-04-13 08:17:42 +0100, Stephane Chazelas wrote: > 2021-04-12 13:41:58 -0700, Bart Schaefer: > > On Sun, Apr 11, 2021 at 12:32 PM Stephane Chazelas > > <stephane@xxxxxxxxxxxx> wrote: > > > > > > $ zsh --emulate sh -c 'inf=42; echo $((inf))' > > > Inf > > > > > > (POSIX requires 42 there). > > > > Is that because "Inf" is case-sensitive, or because POSIX requires > > evaluating the variable? E.g. what does > > That was because "inf" in an arithmetic expression, where inf is > the name of a variable whose contents is an integer constant > (decimal, octal or hex) is meant to represent the corresponding > integer number (and an empty or unset variable is meant to yield > 0).. I think that it would have been better if zsh chose something that does not correspond to the name of a variable, e.g. @Inf@ and @NaN@ (this is what MPFR does, so that it cannot be confused with numbers in large bases, where letters are used as digits). > I think it would be worth documenting that nan and inf are > recognised in arithmetic expressions (and warn against using > variables with the same name). IMHO, zsh should also output a warning when such variables are used. -- Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <https://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

**Follow-Ups**:**Re: sh emulation POSIX non-conformances ("inf"/"Inf" in arithmetic expressions)***From:*Bart Schaefer

**References**:**[PATCH] Document imperfections in POSIX/sh compatibility***From:*dana

**Re: [PATCH] Document imperfections in POSIX/sh compatibility***From:*Bart Schaefer

**Re: [PATCH] Document imperfections in POSIX/sh compatibility***From:*dana

**Re: [PATCH] Document imperfections in POSIX/sh compatibility***From:*Bart Schaefer

**sh emulation POSIX non-conformances (Was: [PATCH] Document imperfections in POSIX/sh compatibility)***From:*Stephane Chazelas

**Re: sh emulation POSIX non-conformances ("inf"/"Inf" in arithmetic expressions)***From:*Stephane Chazelas

**Re: sh emulation POSIX non-conformances ("inf"/"Inf" in arithmetic expressions)***From:*Bart Schaefer

**Re: sh emulation POSIX non-conformances ("inf"/"Inf" in arithmetic expressions)***From:*Stephane Chazelas

Messages sorted by: Reverse Date, Date, Thread, Author