• Bug#1068338: ksh93u+m: "test ! = -o a" exits with 0 instead of 1

    From Martijn Dekker@21:1/5 to All on Fri May 23 17:40:01 2025
    This issue is now tracked upstream, here: https://github.com/ksh93/ksh/issues/858

    --
    || modernish -- harness the shell
    || https://github.com/modernish/modernish
    ||
    || KornShell lives!
    || https://github.com/ksh93/ksh

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Vincent Lefevre@21:1/5 to Martijn Dekker on Fri May 23 17:50:02 2025
    Control: tags -1 upstream
    Control: forwarded -1 https://github.com/ksh93/ksh/issues/858

    On 2025-05-23 16:58:59 +0200, Martijn Dekker wrote:
    This issue is now tracked upstream, here: https://github.com/ksh93/ksh/issues/858

    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.

    --
    Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
    100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
    Work: CR INRIA - computer arithmetic / Pascaline project (LIP, ENS-Lyon)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Martijn Dekker@21:1/5 to All on Mon May 26 16:40:01 2025
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)