There is no bug. Simply, your expectations on when the DEBUG trap runs are wrong.
The `script2' I provided ran with set -T is the closest you'll get to what you expect, but, since DEBUG runs *before* the source command, it'll not work as you want. -- Eduardo Bustamante https://dualbus.me/