[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bash expr problem/bug... 0$val
From: |
Hugh Sasse |
Subject: |
Re: bash expr problem/bug... 0$val |
Date: |
Fri, 19 Aug 2005 16:44:16 +0100 (WEST) |
On Fri, 19 Aug 2005, bloodman@trzcianka.eu.org wrote:
Description:
bash-expr problems...
if a=500 i expect "c: 500", but produce 320
if a="z" i expect "c: 0", but produce 40
[...]
Repeat-By:
<bash># a=500; b="0$[a]"; c=$[b]; echo -e "a: $a\nb: $b\nc: $c\n"
[...]
c: 320
c = 0500 i.e, octal 500 = 320 decimal
<bash># a=50; b="0$[a]"; c=$[b]; echo -e "a: $a\nb: $b\nc: $c\n"
[...]
c: 40
c = 050 i.e, octal 50 = 40 decimal
<bash># a="z"; b="0$[a]"; c=$[b]; echo -e "a: $a\nb: $b\nc: $c\n"
[...]
c: 0
0 is same in all bases.
<bash># last example produces correct (for me) behaviour... ;)
Hugh