bug-bash
[Top][All Lists]
Advanced

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

Re: Not operator (~) fail on arithmetic expansion.


From: John McKown
Subject: Re: Not operator (~) fail on arithmetic expansion.
Date: Sun, 27 Nov 2016 18:06:32 -0600

Not replying for Chet, who will have the definitive answer, I will say that I, personally, think that is working as designed. ~ 0 (with space between) is definitely the "not" operator. But without the middle space, ~0, where there is a white space character in front of the tilde, looks to me like the normal "get the home directory for the following id" processing. Eg: ~0 gets the home for the 0 user (same as ~user) whereas in "a~0", then tilde is simply a character. This is basically how ever other Bourne type shell seems to work.

On Sun, Nov 27, 2016 at 2:33 PM, Bize Ma <address@hidden> wrote:
Configuration Information: 
Machine: x86_64 
OS: linux-gnu 
Compiler: gcc 
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' -DCONF_VENDOR 
uname output: Linux zeus 4.8.0-1-amd64 #1 SMP Debian 4.8.5-1 (2016-10-28) x86_64 GNU/Linux 
Machine Type: x86_64-pc-linux-gnu 

Bash Version: 4.4 
Patch Level: 5 
Release Status: release 

Description: 
  The ~ operator is called not, and does a one's complement of the following value. That works correctly with  

   $ echo $(( ~1 )) 
   -2 

Even with 

   $ echo $(( ~0 )) 
   -1 

But fails with this: 

   $ echo $((~0)) 
   bash: /home/user: syntax error: operand expected (error token is "/home/user")        



Repeat-By: 
    
  Use $((~0)) (without spaces) to generate the error.



--
Heisenberg may have been here.


Maranatha! <><
John McKown

reply via email to

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