[Top][All Lists]

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

Re: declare overrides errexit

From: Sascha Ziemann
Subject: Re: declare overrides errexit
Date: Fri, 24 Sep 2010 15:52:04 +0200

>> Description:
>>       The errexit option does not work, if an error occures in a declare 
>> statement.
> There is no error, because `declare' is defined to return success if the
> variable assignment is performed without an error.

As far as I know about interpreters the arguments of an assignment get
first evaluated before the assignment is performed.

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.


reply via email to

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