|
From: | Martijn Dekker |
Subject: | Re: [patch #10070] toggle invert flag when reading `!' |
Date: | Thu, 3 Jun 2021 14:44:56 +0200 |
User-agent: | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 |
Op 24-05-21 om 17:47 schreef Chet Ramey:
On 5/22/21 2:45 PM, Vincent Menegaux wrote:Previously, these commands: [[ ! 1 -eq 1 ]]; echo $? [[ ! ! 1 -eq 1 ]]; echo $? would both result in `1', since parsing `!' set CMD_INVERT_RETURN instead of toggling it.Interestingly, ksh93 produces the same result as bash. I agree that it's more intuitive to toggle it.
Also interesting is that '!' as an argument to the simple 'test'/'[' command does work as expected (on both bash and ksh93): 'test ! ! 1 -eq 1' and '[ ! ! 1 -eq 1 ]' return 0/true.
Even the man page for [[ is identical for bash and ksh93: | ! expression | True if expression is false.This suggests it's supposed to be a logical negation operator, i.e. '!' is implicitly documented to negate another '!'. Bolsky & Korn's 1995 ksh book, p. 167, is slightly more explicit about it: "! test-expression. Logical negation of test-expression."
I also note that multiple '!' negators in '[[' work as expected on mksh, yash and zsh.
So, it seems clear that this is an actual bug in bash and ksh. I see it's been fixed in the bash devel tree now. I'll fix it in ksh 93u+m.
-- || modernish -- harness the shell || https://github.com/modernish/modernish || || KornShell lives! || https://github.com/ksh93/ksh
[Prev in Thread] | Current Thread | [Next in Thread] |