[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Not operator (~) fail on arithmetic expansion.
From: |
Chet Ramey |
Subject: |
Re: Not operator (~) fail on arithmetic expansion. |
Date: |
Mon, 28 Nov 2016 14:40:24 -0800 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.5.0 |
On 11/27/16 12:33 PM, Bize Ma wrote:
> Bash Version: 4.4
> Patch Level: 5
> Release Status: release
>
> Description:
> The ~ operator is called not, and does a one's complement of the
> following value. That works correctly with
>
> $ echo $(( ~1 ))
> -2
>
> Even with
>
> $ echo $(( ~0 ))
> -1
>
> But fails with this:
>
> $ echo $((~0))
> bash: /home/user: syntax error: operand expected (error token is
> "/home/user")
Yes, this is a problem. Thanks for the report. I'll fix it in the
next devel branch push. For the time being, you can include the
leading space to suppress the unwanted tilde expansion.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/