[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ ! ! hey ] -> [: too many arguments
From: |
Chet Ramey |
Subject: |
Re: [ ! ! hey ] -> [: too many arguments |
Date: |
Thu, 23 Jun 2022 17:58:23 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 |
On 6/23/22 5:08 PM, Steffen Nurpmeso wrote:
Chet Ramey wrote in
<4169f2cd-d81c-29b7-918c-156b447c5220@case.edu>:
|On 6/23/22 9:39 AM, Steffen Nurpmeso wrote:
|> I stumbled over a bug in the MUA i maintain, and when checking
|> against what shells do with lonely unary ! i then came to this:
|>
|> #?0|kent:tmp$ dash -c 'if [ ! ! hey ]; then echo du; fi'
|> du
|> #?0|kent:tmp$ bash -c 'if [ ! ! hey ]; then echo du; fi'
|> bash: line 1: [: too many arguments
|> #?0|kent:tmp$ busybox.static sh -c 'if [ ! ! hey ]; then echo du; fi'
|> du
|
|Thanks for the report. This appears to have existed for over thirty years,
|and you're the first one to report it.
Hey. For a C programmer things like
bash -c 'if [ ! hey = hey ]; then echo du; fi'
or even
bash -c 'if [ ! ! hey = hey ]; then echo du; fi'
bash -c 'if [ ! false = 1 ]; then echo du; fi'
seem often more strange .. and is handled the same by all above
shells.
Sure. This one isn't a common idiom for shell programmers, apparently.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/