bug-bash
[Top][All Lists]
Advanced

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

Question about the return value of 'local'


From: Francis Moreau
Subject: Question about the return value of 'local'
Date: Thu, 13 Dec 2012 09:34:43 +0100

Hello,

I found that the return value of 'local' keyword is counter intuitive
when the value of the assignment is an expression returning false. In
that case the return value of local is still true. For example:

  local foo=$(echo bar; false)

returns true whereas:

  foo=$(echo bar; false)

returns false, that is removing the 'local' keyword has the opposite behaviour.

The help of 'local' is rather obscure about the description on its return value:

    Returns success unless an invalid option is supplied, an
    error occurs, or the shell is not executing a function.

"an error occurs" is rather meaningless IMHO.

Could anybody explain me why 'local' returns true in this case ?

Also I tried to find in the documentation, where the specification of
the return value of an asignment is but have failed. Could anybody
point me out the location ?

Thanks
--
Francis



reply via email to

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