[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Second trap invocation is ignored?
From: |
Chet Ramey |
Subject: |
Re: Second trap invocation is ignored? |
Date: |
Sat, 11 Apr 2015 13:23:43 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 |
On 4/10/15 5:27 PM, Scott Bronson wrote:
> On Fri, Apr 10, 2015 at 8:16 AM, Chet Ramey <chet.ramey@case.edu> wrote:
>> On 4/6/15 11:58 AM, Greg Wooledge wrote:
>>> I'd be fine with that, but then why does "source ./foo" create a DEBUG
>>> trap at the global scope the *first* time?
>>
>> Because there's nothing to save and restore.
>
> Just curious: why not restore the state of emptiness that
> existed before? Why treat these two states differently?
> (presence of trap vs. absence of trap)
Two reasons: it worked better with the common case of sourcing a file that
provided a trap definition, and it paralleled how the -T option worked
with shell functions.
It's a bug that a DEBUG trap definition in a sourced file gets discarded
when an existing old value is restored. That's inconsistent with how
source is supposed to work, since the shell doesn't have local trap
scoping.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/
- Re: Second trap invocation is ignored?, (continued)
- Re: Second trap invocation is ignored?, Greg Wooledge, 2015/04/06
- Re: Second trap invocation is ignored?, Eduardo A . Bustamante López, 2015/04/06
- Re: Second trap invocation is ignored?, Scott Bronson, 2015/04/06
- Re: Second trap invocation is ignored?, Eduardo A . Bustamante López, 2015/04/06
- Re: Second trap invocation is ignored?, Greg Wooledge, 2015/04/06
- Re: Second trap invocation is ignored?, Scott Bronson, 2015/04/06
- Re: Second trap invocation is ignored?, Eduardo A . Bustamante López, 2015/04/06
- Re: Second trap invocation is ignored?, Greg Wooledge, 2015/04/06
- Re: Second trap invocation is ignored?, Chet Ramey, 2015/04/10
- Re: Second trap invocation is ignored?, Scott Bronson, 2015/04/10
- Re: Second trap invocation is ignored?,
Chet Ramey <=
Re: Second trap invocation is ignored?, Scott Bronson, 2015/04/06
Re: Second trap invocation is ignored?, Chet Ramey, 2015/04/10