bug-bash
[Top][All Lists]
Advanced

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

Re: Bug with local variable


From: Pierre Gaston
Subject: Re: Bug with local variable
Date: Tue, 14 Sep 2010 11:04:03 +0300

On Tue, Sep 14, 2010 at 10:27 AM, Mario Jungwirth
<mario.jungwirth@ocilion.com> wrote:
> Hello
>
> I found a bug with local variable.
> My source (The directory dosn't exists!!!)
>
> function test()
> {
>    local myreturn=$(ls -la /directoryNotExists)
>    echo "return value=$?"
> }
>
> The "return value" is now 0!
> If i remove the "local" the "return value" is 2 <-- this is correct.
>
> Is this a bug or do I something wrong?
>
> Mfg
> Mario Jungwirth
>
>
>
It has been discussed several times here, see for instance:

http://lists.gnu.org/archive/html/bug-bash/2010-03/msg00007.html

Keeping local declaration and assignment on separate lines avoid
little troubles like this:
local myreturn
myreturn=$(command)



reply via email to

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