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

Re: Error in zshaddhistory() should not prevent command from running

Bart Schaefer wrote on Fri, Dec 30, 2016 at 22:13:27 -0800:
> [Fourth attempt sending this, primenet is blocking gmail again.]

Two came through.

> Should this actually be in callhookfunc() itself?  I note that the doc
> warns about errors in precmd killing off periodic, or else I'd say it
> ought to be.

I'd be wary of swallowing errors by default.  That said, we could change
callhookfunc()'s signature to remind callers that they may want to clear
errors; for example, an 'ignore_errors' boolean parameter that the
precmd() callsite can set to false and zshaddhistory() to true.

> Possibly more controversial, why run this hook at all when nothing is
> being added?

Playing devil's advocate, I see two reasons:

1) Compatibility.  https://xkcd.com/1172/

2) It's easier to call the user-provided hook function on one more case
that it can easily ignore, than not to do so and to leave the user with
no easy alternative.  (It does seem easier to handle multiline commands
with zshaddhistory() than with, say, wrapping accept-line(), since the
latter fires for each line, not just for the complete command.)



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