Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Exception handling and "trap" vs. TRAPNAL()



    Hi Bart :)

 * Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> dixit:
> On Oct 1,  5:37pm, DervishD wrote:
> } Subject: Re: Exception handling and "trap" vs. TRAPNAL()
> }
> }     Hi Peter :)
> }  * Peter Stephenson <pws@xxxxxxx> dixit:
> } > Add some "print"s to the trap to see when it's triggering.
> } 
> }     The trap is triggering just in the "false" statement, and the
> } TRAPZERR works perfectly, it's the "trap" kind which is failing.
> I ran this with "set -x" (much better than inserting print statements)

    I did exactly the same, and the "trap" didn't caused the always
block to run but the TRAPZERR bit did.

> } Can I do anything to make it work (except patching zsh)?
> I don't think so.

    Well, then I'll use explicit throw commands instead of ZERR. The
code will be a bit messier but I'll try to use TRAPZERR whenever
possible until the ¿bug? is fixed. I am still not sure whether this
is a bug or a feature:

    trap 'false' DEBUG

    true
    [[ $? -eq 1 ]] && print "What?"

    This snippet doesn't print anything, and won't do even if using
TRAPDEBUG and "return 1" instead of "false". So ignoring errors from
inline traps make those traps and the TRAPNAL ones semantically
identical (TRAPNAL is a function, but its return value seems to be
ignored). Apart from this, I cannot think of a reason :?

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736 | http://www.dervishd.net
http://www.pleyades.net & http://www.gotesdelluna.net
It's my PC and I'll cry if I want to...



Messages sorted by: Reverse Date, Date, Thread, Author