[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ ! ! hey ] -> [: too many arguments
From: |
Emanuele Torre |
Subject: |
Re: [ ! ! hey ] -> [: too many arguments |
Date: |
Fri, 24 Jun 2022 01:13:38 +0200 |
On 22/06/23 11:08 PM, Steffen Nurpmeso wrote:
> or even
> bash -c 'if [ ! ! hey = hey ]; then echo du; fi'
> bash -c 'if [ ! false = 1 ]; then echo du; fi'
`! ! hey = hey' is the same as `! ( ! ( hey = hey ) )', so
"not not true => true".
It probably works correctly because `! ! hey = hey' are five terms.
The bug only occurs for 3 or 4 terms tests:
bash-5.1$ test ! ! hey ; printf %s\\n "$?"
bash: test: too many arguments
2
bash-5.1$ test ! ! ! hey ; printf %s\\n "$?"
bash: test: too many arguments
2
bash-5.1$ test ! ! ! ! hey ; printf %s\\n "$?"
0
bash-5.1$ test ! ! ! ! ! hey ; printf %s\\n "$?"
1
test(1) needs to treat the 0 to 4 arguments expressions specially
according to POSIX so the bug is probably only in the code that
implements those special cases.
-emanuele6