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:
> } You can certainly argue that the "normal effect" of a ZERR trap is not
> } to cause an error, and it's certainly possible to argue that yet more
> } hacked-up special cases and additional bug-prone complexity in the trap
> } code are warranted.
> Well, that's just it.  An even stronger argument than the no-man's
> land proposition, is that errflag should *not* be propagated out of
> a ZERR trap.  This would not accomplish what Raúl wants, because it
> would mean that *neither* TRAPZERR nor "trap ... ZERR" would be
> capable of "raising an exception" -- in effect we'd be removing a
> special-case, not adding one.

    But as I told in one of my last messages, that's ok too. My
problem is not really about not being able to throw an exception from
a trap, but having one kind of trap that works and another that
doesn't with no special reason. I will be equally happy if this is
shown in the documentation or the special-case removed.

    This said, being able to throw an exception from a trap is IMHO
desirable. In the end, both traps and exceptions are tools for doing
cleanup or recovering from errors, so common usage is not a bad idea.

    Of course, even in the case of not being able to throw exceptions
from traps, is more or less easy (assuming that shell scripts are
short snippets of code in the common case) to implement a way of
throwing exceptions if some trap is invoked, by setting a variable
and doing a busy loop or something like that, so... Not the best
solution but it's a suitable one.

    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