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

2016-11-28 Thread Chet Ramey
On 11/27/16 12:33 PM, Bize Ma wrote: > 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 > >

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

2016-11-28 Thread Eric Blake
On 11/27/2016 11:54 PM, L A Walsh wrote: > Does ~ get home dirs for UID's? I thought it only worked > for usernames? I would think that allowing user names that were > all numeric would be confusing for software that accept either UID's or > usernames. Can usernames even begin with a number?

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

2016-11-28 Thread Greg Wooledge
On Sun, Nov 27, 2016 at 09:54:59PM -0800, L A Walsh wrote: > Does ~ get home dirs for UID's? I thought it only worked > for usernames? imadev:~$ id uid=563(wooledg) gid=22(pgmr) groups=1002(webauth),208(opgmr) imadev:~$ echo ~563 ~563

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

2016-11-28 Thread Andreas Schwab
On Nov 28 2016, John McKown wrote: > 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

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

2016-11-27 Thread Eduardo Bustamante
Except that this is *inside* arithmetic context. Bash is definitely doing something wrong here: dualbus@hp:~$ for sh in bash zsh ksh93 mksh dash posh; do $sh -c 'echo $0 $((~0))' $sh; done bash: /home/dualbus: syntax error: operand expected (error token is "/home/dualbus") zsh -1 ksh93 -1 mksh -1

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

2016-11-27 Thread John McKown
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

Not operator (~) fail on arithmetic expansion.

2016-11-27 Thread Bize Ma
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