bug-bash
[Top][All Lists]
Advanced

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

Re: Second trap invocation is ignored?


From: Eduardo A . Bustamante López
Subject: Re: Second trap invocation is ignored?
Date: Mon, 6 Apr 2015 08:10:03 -0500
User-agent: Mutt/1.5.23 (2014-03-12)

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:

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

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



reply via email to

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