On Mon, Apr 6, 2015 at 6:10 AM, Eduardo A. Bustamante López <dual...@gmail.com> wrote: > Read about set -T in the manual.
Hi, I did, over and over. :) I didn't see anything about -T being unnecessary the first time you set a trap from a sourced script, but being required every time thereafter. (quick parentheses: I'm not quite sure if sourcing a file is supposed to share ALL script contexts, or be more like calling a function. If the former, -T would never be required, and if the latter, -T would always be required. Just curious, is this documented anywhere?) > Also, you have an error in your trap > definition. The $1 inside "..." will expand at *definition* time, not when the > trap is executed. See: But I want it to expand at definition time. That makes it easy to see if the trap call worked or not. Here's the bug with explicit expansion: echo "trap 'echo first' DEBUG" > script1 echo "trap 'echo second' DEBUG" > script2 . ./script1 . ./script2 I would expect the trap calls in script1 and script2 to behave identically. Instead, script1's trap is set, but script2's trap is ignored. Thanks for the reply. - Scott