Re: Arithmetic evaluation of negative numbers with base prefix

2019-06-19 Thread Chet Ramey
On 6/18/19 11:20 AM, Greg Wooledge wrote: > Seems kinda weird to continue calling it "ksh93" if it's being changed, > but I don't make the decisions. Korn once explained it as the "ksh93 language definition." So there are multiple implementations of that language. -- ``The lyf so short, the cra

Re: Arithmetic evaluation of negative numbers with base prefix

2019-06-19 Thread Chet Ramey
On 6/18/19 12:13 PM, Ilkka Virta wrote: > On 18.6. 18:20, Greg Wooledge wrote: >> On Tue, Jun 18, 2019 at 10:27:48AM -0400, Chet Ramey wrote: >>> $ ksh93 -c 'echo ${.sh.version}' >>> Version ABIJM 93v- 2014-09-29 >>> $ ksh93 -c 'echo $(( 10# ))' >>> ksh93:  10# : arithmetic syntax error >> >> I gue

Re: Arithmetic evaluation of negative numbers with base prefix

2019-06-19 Thread Chet Ramey
On 6/17/19 9:30 AM, Jeremy Townshend wrote: > Ilkka Virta's email helpfully pointed me to a somewhat related debate that > occurred about 11 months ago. I agree with your comment in this debate: > > "There would be a good case for rejecting the '10#' because it's missing > the value." I'll

Re: Arithmetic evaluation of negative numbers with base prefix

2019-06-18 Thread Ilkka Virta
On 18.6. 18:20, Greg Wooledge wrote: On Tue, Jun 18, 2019 at 10:27:48AM -0400, Chet Ramey wrote: $ ksh93 -c 'echo ${.sh.version}' Version ABIJM 93v- 2014-09-29 $ ksh93 -c 'echo $(( 10# ))' ksh93: 10# : arithmetic syntax error I guess most Linux distributions are not shipping the 2014 version

Re: Arithmetic evaluation of negative numbers with base prefix

2019-06-18 Thread Greg Wooledge
On Tue, Jun 18, 2019 at 10:27:48AM -0400, Chet Ramey wrote: > $ ksh93 -c 'echo ${.sh.version}' > Version ABIJM 93v- 2014-09-29 > $ ksh93 -c 'echo $(( 10# ))' > ksh93: 10# : arithmetic syntax error I guess most Linux distributions are not shipping the 2014 version of ksh93 yet...? wooledg:~$ ksh

Re: Arithmetic evaluation of negative numbers with base prefix

2019-06-18 Thread Chet Ramey
On 6/18/19 1:52 AM, Ilkka Virta wrote: > I still wish this could be fixed to do the useful thing without any > workarounds, given it's what ksh and zsh do I'm surprised people keep saying this. $ ksh93 -c 'echo ${.sh.version}' Version ABIJM 93v- 2014-09-29 $ ksh93 -c 'echo $(( 10# ))' ksh93: 10

Re: Arithmetic evaluation of negative numbers with base prefix

2019-06-17 Thread Ilkka Virta
On 17.6. 18:47, Greg Wooledge wrote: On Mon, Jun 17, 2019 at 02:30:27PM +0100, Jeremy Townshend wrote: In the meantime it would seem cautionary to advise against the pitfall of using base# prefixed to variables (contrary to mywiki.wooledge.org/ArithmeticExpression) unless you can be confident th

Re: Arithmetic evaluation of negative numbers with base prefix

2019-06-17 Thread Greg Wooledge
On Mon, Jun 17, 2019 at 02:30:27PM +0100, Jeremy Townshend wrote: > In the meantime it would seem cautionary to advise against the pitfall of > using base# prefixed to variables (contrary to > mywiki.wooledge.org/ArithmeticExpression) unless you can be confident that > they will never be decremente

Re: Arithmetic evaluation of negative numbers with base prefix

2019-06-17 Thread Jeremy Townshend
Dear Chet Many thanks for your impressively swift response. It is enlightening to see how these expressions are parsed. For the record, whilst I can now see how they are parsed, it feels particularly unsatisfactory that the following two expressions yield the same result when the variable i happ

Re: Arithmetic evaluation of negative numbers with base prefix

2019-06-14 Thread Ilkka Virta
On 14.6. 17:19, Jeremy Townshend wrote: echo $((10#-1)) # -1 as expected Earlier discussion about the same on bug-bash: https://lists.gnu.org/archive/html/bug-bash/2018-07/msg00015.html Bash doesn't support the minus (or plus) sign following the 10#. I think the expression above seem

Re: Arithmetic evaluation of negative numbers with base prefix

2019-06-14 Thread Chet Ramey
On 6/14/19 10:19 AM, Jeremy Townshend wrote: > Bash Version: 4.4 > Patch Level: 19 > Release Status: release > > Description: > Unexpected and undocumented behaviour for arithmetic evaluation of > negative numbers when prefixed with the optional "base#" (e.g. 10#${i}). The > base prefix m

Arithmetic evaluation of negative numbers with base prefix

2019-06-14 Thread Jeremy Townshend
Configuration Information [Automatically generated, do not change]: 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='pc' -DLOCALEDIR='/usr/share/locale' -DPACKA