[Top][All Lists]

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

Re: Second trap invocation is ignored?

From: Greg Wooledge
Subject: Re: Second trap invocation is ignored?
Date: Mon, 6 Apr 2015 11:58:01 -0400
User-agent: Mutt/

On Mon, Apr 06, 2015 at 10:31:49AM -0500, Eduardo A. Bustamante López wrote:
> address@hidden ~ % bash -c 'trap "echo bar" DEBUG; source /dev/fd/0; :' <<< 
> 'trap "echo foo" DEBUG; :' 
> bar
> foo
> bar
> Here, the first `bar' is executed before `source'. Then, we enter a new
> `scope', or whatever this is called. Then, there's `foo', due to the `:' 
> called
> inside the sourced script. After we `return' from the sourced script, `bar' is
> written, before the `:' from the main script (the -c one).
> So, essentially, we have two DEBUG traps set at the same time, living in
> different scopes. (DEBUG, RETURN and ERR are the only ones special here, I
> think).

I'd be fine with that, but then why does "source ./foo" create a DEBUG
trap at the global scope the *first* time?

reply via email to

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