Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14943

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

From Chet Ramey <chet.ramey@case.edu>
Newsgroups gnu.bash.bug
Subject Re: Error on arithmetic evaluation of `~0`.
Date 2018-12-22 12:02 -0500
Organization ITS, Case Western Reserve University
Message-ID <mailman.6138.1545498179.1284.bug-bash@gnu.org> (permalink)
References <CAFra36gW8Csu-84oRLV7QsR7PbiMYq6g7WnMktjfnrSdTys38g@mail.gmail.com> <20181220131258.43wcmxlxbogquuoo@eeg.ccf.org>

Show all headers | View raw


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/

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Re: Error on arithmetic evaluation of `~0`. Chet Ramey <chet.ramey@case.edu> - 2018-12-22 12:02 -0500

csiph-web