[Top][All Lists]

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

Re: Question about arithmetic logic.

From: Roman Rakus
Subject: Re: Question about arithmetic logic.
Date: Mon, 18 Apr 2011 16:49:51 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20110307 Fedora/3.1.9-0.39.b3pre.fc14 Lightning/1.0b3pre Thunderbird/3.1.9

On 04/18/2011 04:30 PM, 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:

typeset -i ss=0

(( ss ))
echo $?        # Returns 1. Expected because it should be
                # the same as (( ss != 0 )) No?

(( ss ))
echo $?        # Also says 1. Should this be 0 because it should be the
                # success result same as (( ss != 0 ))

But if I use an operator...
(( ! ss ))    # Says 0.

(( ! ss ))    # Says 1.

So it seems to me that if I do not use the logical not operator, then the arithmetic test is doing a test to see if the string value of ss is not null (or something like that). Is this a bug? A feature? Or am I doing it wrong?


I can't reproduce it. Tried bash-4.0.38 and bash-4.1.7


reply via email to

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