Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: sh emulation POSIX non-conformances ("inf"/"Inf" in arithmetic expressions)
- X-seq: zsh-workers 48687
- From: Stephane Chazelas <stephane@xxxxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Cc: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: sh emulation POSIX non-conformances ("inf"/"Inf" in arithmetic expressions)
- Date: Sat, 24 Apr 2021 08:33:04 +0100
- Archived-at: <https://zsh.org/workers/48687>
- In-reply-to: <CAH+w=7bvMEMHRZguzK-gCyfQ1sQEzD5ucvHBNZkNLdb5Z0ztFw@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- Mail-followup-to: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxx>
- References: <CAH+w=7aAeEMDJX9q4M9jvb0Z8nhYuOdHRk_N4KS91yKP5B5eLQ@mail.gmail.com> <20210413071742.tisslgg5fdqbageg@chazelas.org> <20210422153100.GD154089@zira.vinc17.org> <CAH+w=7a2XgrCqYAuDD4QYm7DBnNsshZQN6MazEVL0L-wngLTZg@mail.gmail.com> <20210423164525.GA2033191@zira.vinc17.org> <CAH+w=7ZMWJjB_tnGHW7kvkMr8MO4QQXuobjRMQeyxmTcK4fbyw@mail.gmail.com> <55222-1619218004.791735@3FXq.NU49.vlrg> <CAH+w=7bDEkJ5sw5JUs8_aPy+ix1Q9Wo8ghbZ0xD8puUtYHHYEw@mail.gmail.com> <0f0a356e-2499-427f-a8f4-c485d1d64e6e@www.fastmail.com> <CAH+w=7bvMEMHRZguzK-gCyfQ1sQEzD5ucvHBNZkNLdb5Z0ztFw@mail.gmail.com>
BTW, there's also:
$ var=42 zsh -c 'printf "%g\n" var'
42
$ Infinity=42 zsh -c 'printf "%g\n" Infinity'
inf
In ksh93:
$ var=42 ksh -c 'printf "%g\n" var'
42
$ Infinity=42 ksh -c 'printf "%g\n" Infinity'
42
POSIX leaves it implementation-defined whether %g/%f... are
supported, but I'd expect it requires that "inf" output in the
second case where it is (as that's what strtod() returns), so
zsh would be more compliant than ksh in that regard.
There's still possibly scope for improving documentation.
IMO, the code doesn't need to be changed to add warnings.
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author