bug-bash
[Top][All Lists]
Advanced

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

Re: declare overrides errexit


From: Marc Herbert
Subject: Re: declare overrides errexit
Date: Fri, 24 Sep 2010 15:34:27 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.9) Gecko/20100907 Fedora/3.1.3-1.fc13 Thunderbird/3.1.3

Le 24/09/2010 14:52, Sascha Ziemann a écrit :

> The expression:
> 
> declare a='x'$(false)
> 
> means: concatenate the string 'x', which evaluates to itself, and the
> output of a sub shell, which performs the false command, and assign
> the concatenated value to the variable a.
> 
> This means that the sub shell fails *before* 'declare' starts. So I
> think it should not matter what declare returns, because the script
> should have been terminated already.

The *subshell* exits. But this does not force its "declaring" parent
script to exit.


Also note this difference:

set -e ; declare a=$(         false; echo something ); echo $a
  => "something"
set -e ; declare a=$( set -e; false; echo something ); echo $a
  => <nothing>





reply via email to

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