bug-bash
[Top][All Lists]
Advanced

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

Re: Question about arithmetic logic.


From: Chet Ramey
Subject: Re: Question about arithmetic logic.
Date: Mon, 18 Apr 2011 10:55:39 -0400
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9

On 4/18/11 10:30 AM, Steven W. Orr wrote:
> I happen to be running
> 
> GNU bash, version 4.0.35(1)-release (x86_64-redhat-linux-gnu)
> 
> I create an integer variable and assign it either a 0 or a 1. The
> arithmetic test always returns success regardless of value. For example:

$ cat x20
unset ss; ss=0; ((ss)); echo $?
unset ss; ss=1; ((ss)); echo $?
unset ss; ss=0; ((! ss)); echo $?
unset ss; ss=1; ((! ss)); echo $?

unset ss; typeset -i ss; ss=0; ((ss)); echo $?
unset ss; typeset -i ss; ss=1; ((ss)); echo $?
unset ss; typeset -i ss; ss=0; ((! ss)); echo $?
unset ss; typeset -i ss; ss=1; ((! ss)); echo $?

unset ss; typeset -i ss=0; ((ss)); echo $?
unset ss; typeset -i ss=1; ((ss)); echo $?
unset ss; typeset -i ss=0; ((! ss)); echo $?
unset ss; typeset -i ss=1; ((! ss)); echo $?
$ ../bash-4.0-patched/bash ./x20
1
0
0
1
1
0
0
1
1
0
0
1
$ ../bash-4.1-patched/bash ./x20
1
0
0
1
1
0
0
1
1
0
0
1
$ ../bash-4.2-patched/bash ./x20
1
0
0
1
1
0
0
1
1
0
0
1

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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