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

Re: PATCH: skip command from debug trap



"Rocky Bernstein" wrote:
> But given the choice of adding
>    1) an option in the return statement everywhere that is specific to
> just "trap DEBUG" or
>    2) specifying what specific numbers do when on a return from "trap DEBUG",
> 
> isn't 2) simpler and more consistent with programming in shell
> languages work? I take it as a given that every function or command is
> going to have error codes that are somewhat arbitrary and that I'm not
> going to intuit.

I'm in two minds about this.  If we didn't have the existing rule that
any non-zero return status from TRAPDEBUG, or any explicit return from
within an inline trap, forced an immediate return, then I'd agree simply
adding to the set of useful statuses was cleaner and more natural.  As
it is, we're now forced to pick some numeric value the user wouldn't
naturally want to return from am enclosing context (since the return
value is propagated).

The option to return seems to me natural enough, because as "return"
means "just return", so "return with an option" means "return but with
slightly different semantics".  Having a different return status meaning
to execute different code (rather than simply provide a different test
for the caller, as normal) is an unusual enough effect that it doesn't
strike me as the unequivocal answer.

But, whatever.  If there's a number we all really like to mean "skip",
we can go with that.  It's already working, is easy to document, and
doesn't need any changes to parsing.

(By the way, it wouldn't be too hard, if not completely trivial, to pass
down the code about to be executed in a variable, say DEBUG_CMD_LINE, as
reconstructed text, i.e. the same sort of format as what you get if you
get the shell to output a shell function that's already loaded.  But
it's messy enough that I won't unless it's definitely useful.)

-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/



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