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). For a long time "sh" emulation was intended more for SysV sh emulation than POSIX sh emulation, which might be the reason.
POSIX expr and awk have always supported < and > though (using strcoll(), not strcmp()). You may want to use those instead to support systems that haven't been updated to POSIX 2024.
POSIX 2024 comes with a few new features that are still not very widespread like the $'...' form of quotes from ksh93 which has only very recently been added to dash, or the *? non-greedy extended regexp operator (from perl) which not many regexp engines support. It's premature to assume all systems are compliant to that.
-- Stephane