Zsh Mailing List Archive
Messages sorted by:
- X-seq: zsh-workers 22977
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: "Zsh hackers list" <zsh-workers@xxxxxxxxxx>
- Subject: Re: Hooks
- Date: Tue, 07 Nov 2006 09:14:49 -0800
- In-reply-to: <dbfc82860611070711u322a6948m675ef9a38d097717@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <5db995410611060845y53f673e6je029a9c60659f116@xxxxxxxxxxxxxx> <20061106174053.GA4323@sc> <5db995410611061314l26e089b8wb214da46064c8235@xxxxxxxxxxxxxx> <20061106215051.GB4323@sc> <Pine.OSX.4.61.0611061617370.1112@xxxxxxxxxxxxxxx> <20061107081800.GA4420@sc> <20061107104916.d01e2fa5.pws@xxxxxxx> <dbfc82860611070711u322a6948m675ef9a38d097717@xxxxxxxxxxxxxx>
On Nov 7, 7:12am, Nikolai Weibull wrote:
} > This is even further away from the original subject, but I've often felt
} > that functions like preexec and chpwd are getting a bit overloaded and
} > are unnecessarily hard to maintain automatically. It would be easy to
} > add an array which could contain names of functions to be executed,
} > similar to Emacs hooks.
} > However, I'm not sure if it's really needed.
} Yes, please do add.
Having previously implemented a shell-like language in which there was
such a set of hooks, I'll point out that there really ought to be a
well-defined semantics rather than simply executing every one of an
array of functions. (I suppose that can *be* the defined semantics,
but it's not all that useful a one.)
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?
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?
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.)
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.
Messages sorted by: