On 12/3/12 11:07 AM, Chet Ramey wrote:
> On 12/3/12 10:50 AM, Robert Schiele wrote:
>> On Mon, Dec 3, 2012 at 4:25 PM, Chet Ramey <chet.ra...@case.edu> wrote:
>>> Since the `source' command is called in a context where all commands within
>>> it should have the `errexit' flag disabled, bash chooses to satisfy this
>>> requirement by turning off the flag that (internally) represents errexit.
>>> Under most circumstances, however, that state is externally visible as the
>>> value of the -e option.
>>>
>>> Note that the behavior of suppressing the effect of the errexit option is
>>> correct.  The value of the -e option in $- should be unaffected, though.
>>
>> Ah, now I start to understand how this is supposed to work. I also
>> realized that it is not possible within the function to turn on the
>> flag again with another internal set -e. Is that also part of the
>> design, meaning there is no way to have an effective set -e within a
>> function in case it was called in that context?
> 
> Correct.  When called in a context where errexit is ignored, attempts to
> turn errexit on are ineffective.

I should note that there's a potential problem with the effect of turning
on set -e in a sourced file even when it's called from a function in a
context where errexit is ignored.

Bash allows set -e to be enabled within the sourced file and have its
usual short-circuiting effect.  That's probably not quite the right thing
to do, so I will have to take a look at it.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    c...@case.edu    http://cnswww.cns.cwru.edu/~chet/

Reply via email to