Op 23-05-2025 om 17:40 schreef Vincent Lefevre:
I had forgotten to mention it, but I have already reported the bug
upstream
https://github.com/ksh93/ksh/issues/740
but it was closed.
I've now given it a deeper reconsideration, but my conclusion was the same in
the end: won't fix for native ksh93 mode, already fixed for POSIX mode (though
I did find a bug in the POSIX mode fix, and fixed that).
My rationale from <https://github.com/ksh93/ksh/issues/858>:
| OK, let's take a step back and consider this again from first
| principles.
|
| On bash, and all other non-ksh93 shells:
|
| $ bash -c 'test ! foo -o bar; echo $?'
| 1
| $ bash -c 'test \( ! foo -o bar \); echo $?'
| 0
|
| This is an outright absurdity. It should behave the same with or without
| the redundant parentheses.
|
| The 0 (true) result is the logical outcome. test foo tests for the
| non-emptiness of the string foo (true). test ! foo inverts that, so
| tests for the emptiness of the string foo (false). An -o is a logical
| OR. So test ! foo -o bar /should/ return 0/true, as the expression to
| the left of the -o is false but the one to the right is true.
|
| Also note that [[ avoids this absurdity and behaves logically:
|
| $ bash -c '[[ ! foo || bar ]]; echo $?'
| 0
| $ ksh -o posix -c '[[ ! foo || bar ]]; echo $?'
| 0
|
| The problem is that POSIX has a blanket rule about test with four
| arguments that requires the specific case of test ! foo -o bar to be
| effectively treated as test ! \( foo -o bar \), which is absurd.
|
| So, the bug here is not in ksh93, but in POSIX versions up to
| POSIX-1.2017. The -o and -a operators should have been exempt from that
| rule on grounds of basic logic. In POSIX-1.2024, it's a moot point, as
| -o, -a, and parentheses were removed. Had it still been relevant, I
| would be reporting this to the Austin group as a bug in POSIX.
|
| The POSIX mode is already compliant with this absurdity as of 9b259c94.
| I do not believe native ksh93 mode should follow suit.
This Debian issue should probably be closed now.
--
|| modernish -- harness the shell
|| https://github.com/modernish/modernish
||
|| KornShell lives!
|| https://github.com/ksh93/ksh