bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Error on arithmetic evaluation of `~0`.


From: Chet Ramey
Subject: Re: Error on arithmetic evaluation of `~0`.
Date: Sat, 22 Dec 2018 12:02:47 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:52.0) Gecko/20100101 Thunderbird/52.9.1

On 12/20/18 8:12 AM, Greg Wooledge wrote:

> The issue you're reporting appears to be present in arithmetic contexts
> in general, not only arrays:
> 
> wooledg:~$ echo $((~0))
> bash: /home/wooledg: syntax error: operand expected (error token is 
> "/home/wooledg")

This is what was fixed post-bash-4.4. I left the array subscript expansion
unchanged for backwards compatibility.

> It appears that bash is performing tilde expansion when there's no
> whitespace in front of the tilde, or bitwise negation if there is
> whitespace.

Because tilde expansion only happens on the first character of a string,
or following an unquoted `=' or `:'.

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://tiswww.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]