On Fri, 19 Aug 2005, [EMAIL PROTECTED] 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


_______________________________________________
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash

Reply via email to