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


Groups > gnu.bash.bug > #14935 > unrolled thread

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

Started byAndreas Schwab <schwab@suse.de>
First post2018-12-20 14:46 +0100
Last post2018-12-20 14:46 +0100
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Error on arithmetic evaluation of `~0`. Andreas Schwab <schwab@suse.de> - 2018-12-20 14:46 +0100

#14935 — Re: Error on arithmetic evaluation of `~0`.

FromAndreas Schwab <schwab@suse.de>
Date2018-12-20 14:46 +0100
SubjectRe: Error on arithmetic evaluation of `~0`.
Message-ID<mailman.5996.1545313999.1284.bug-bash@gnu.org>
On Dez 20 2018, Greg Wooledge <wooledg@eeg.ccf.org> 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, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web