[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 'declare' does not honor '-e' in command substituted assignments - a
From: |
Dan Douglas |
Subject: |
Re: 'declare' does not honor '-e' in command substituted assignments - a bug ? |
Date: |
Sat, 09 Aug 2014 14:46:25 -0500 |
User-agent: |
KMail/4.13.3 (Linux/3.16.0; KDE/4.13.3; x86_64; ; ) |
On Saturday, August 09, 2014 04:34:11 PM Jason Vas Dias wrote:
> Good day bash list -
>
> I don't understand why this emits any output :
> $ ( set -e; declare v=$(false); echo 'Should not get here'; )
> Should not get here
> $
>
> While this does not:
> $ ( set -e; v=$(false); echo 'Should not get here'; )
> $
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_01
"If there is no command name, but the command contained a command
substitution, the command shall complete with the exit status of the
last
command substitution performed. Otherwise, the command shall complete
with
a zero exit status."
The declaration commands return the status of the command itself, which masks
the status of assignments. To get the status, either perform the declaration
and assignment separately, or use a temporary variable to store the status. For
set -e the former is the only option.
--
Dan Douglas