On Mon, Apr 06, 2015 at 10:31:49AM -0500, Eduardo A. Bustamante López wrote:
> dualbus@yaqui ~ % 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