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

Re: Hooks

Bart Schaefer wrote:
> For example, if one of the functions causes an error condition (the
> sort of thing that would jump to the final clause of an "always" block)
> is the whole chain aborted, or only the one function?

Currently we don't reset the errflag.  In some cases (precmd and
periodic) we abort all precommand processing on a failure: this is how
it has always worked, for suitable values of "always", in the case of
chained activities before a prompt.  This probably needs to be
documented, however it works.

> Related but more subtle, if a function returns a non-zero status,
> should that affect the rest of the functions in the array in any way?
> Put another way, are there rules for cascading the hooks?

I thought of this, but decided it wasn't that helpful.  The whole point
of being able to do this automatically is that you shouldn't care what
other functions are doing.  However, maybe there's a counterexample.

> And what is the value of "$@" when these functions are called?  Does
> is differ depending on which hook array they're in?  (The signatures
> of preexec, precmd, and chpwd are quite different.)

It's the same as the currently defined function for that context.
That seems the only sensible way of doing it.

> I'd suggest that, at least as a first pass, rather than coded up in C,
> this be implmented with a few functions distributed in Functions/Misc
> and designed to be installed as preexec, precmd, and/or chpwd.

Certainly I could mimic the current system in shell functions, but I'm
not sure what that gains: the whole point of doing it in C is that you
can rely on it always being there.  I will certainly consider changes to
the current system.

I made one screwup: preexec_functions aren't handled unless preexec
exists as well.  I've used a different optimisation to avoid needing the
argument handling if there's nothing to do.

Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070

To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php

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