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: Andreas Schwab
Subject: Re: Error on arithmetic evaluation of `~0`.
Date: Thu, 20 Dec 2018 14:46:52 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1.90 (gnu/linux)

On Dez 20 2018, Greg Wooledge <address@hidden> 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 has been fixed in bash 5.0.

> 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.

POSIX says that arithmetic expressions are not subject to tilde
expansion.  IMHO bash shouldn't do that either for indexed array
subscripts, since they are arithmetic expressions.

Andreas.

-- 
Andreas Schwab, SUSE Labs, address@hidden
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."



reply via email to

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