Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bug with test and quoted comparisons



On 2025-11-21 23:09, Stephane Chazelas wrote:
On 2025-11-21 22:51, brian m. carlson wrote:
[...]
+ zsh -f -c emulate sh; test 2 ">" 1
zsh:1: condition expected: >
[...]

Note that the < and > operators of the POSIX test aka [ utility has only been added since the 2024 edition of the standard (after this request: https://www.austingroupbugs.net/view.php?id=375) and there hasn't been any release of zsh since that edition came out.

Not sure why zsh disables it in sh emulation though. Supporting it there would not have made it non-compliant to POSIX versions prior to 2024 (not that zsh targets POSIX compliance anyway)
[...]

Ah sorry, I read the question too quickly, I see zsh's test / [ supports <, > neither in sh emulation nor outside sh emulation and only recognises them in the Korn-style [[ ... ]] construct.

The rest of what I said still stands:
- zsh should add support for <, > in its [ / test operator to comply to POSIX 2024 (or more to the point, to be able to run code written to POSIX 2024 especially when in sh emulation). Thanks for bringing that up. - if writing a portable script, you may want to restrict yourself to POSIX 2018 (or maybe even 2016) feature set as there are still 10 year old non-eol systems out there.

--
Stephane




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