Read about set -T in the manual. Also, you have an error in your trap
definition. The $1 inside "..." will expand at *definition* time, not when the
trap is executed. See:

    dualbus@yaqui ~/t % cat script
    echo '
    trap "echo $1" DEBUG
    ' > ./trapcmd
    
    source ./trapcmd first
    source ./trapcmd second
    dualbus@yaqui ~/t % bash script
    first
    dualbus@yaqui ~/t % bash -T script
    first
    first
    dualbus@yaqui ~/t % cat script2
    echo '
    trap "echo \$1" DEBUG
    ' > ./trapcmd
    
    source ./trapcmd first
    source ./trapcmd second
    dualbus@yaqui ~/t % bash script2
    
    dualbus@yaqui ~/t % bash -T script2
    
    second

-- 
Eduardo Bustamante
https://dualbus.me/

Reply via email to