Path: csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: Andreas Schwab Newsgroups: gnu.bash.bug Subject: Re: Error on arithmetic evaluation of `~0`. Date: Thu, 20 Dec 2018 14:46:52 +0100 Lines: 25 Approved: bug-bash@gnu.org Message-ID: References: <20181220131258.43wcmxlxbogquuoo@eeg.ccf.org> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: usenet.stanford.edu 1545313999 6874 208.118.235.17 (20 Dec 2018 13:53:19 GMT) X-Complaints-To: action@cs.stanford.edu Cc: bug-bash To: Bize Ma Envelope-to: bug-bash@gnu.org X-Virus-Scanned: by amavisd-new at test-mx.suse.de X-Yow: I want to so HAPPY, the VEINS in my neck STAND OUT!! In-Reply-To: <20181220131258.43wcmxlxbogquuoo@eeg.ccf.org> (Greg Wooledge's message of "Thu, 20 Dec 2018 08:12:58 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1.90 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 195.135.220.15 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:14935 On Dez 20 2018, 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 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."