From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9022 invoked from network); 7 Nov 2006 17:18:32 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.7 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 7 Nov 2006 17:18:32 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 46778 invoked from network); 7 Nov 2006 17:18:26 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 7 Nov 2006 17:18:26 -0000 Received: (qmail 28806 invoked by alias); 7 Nov 2006 17:18:24 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 22977 Received: (qmail 28797 invoked from network); 7 Nov 2006 17:18:23 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 7 Nov 2006 17:18:23 -0000 Received: (qmail 46499 invoked from network); 7 Nov 2006 17:18:23 -0000 Received: from vms046pub.verizon.net (206.46.252.46) by a.mx.sunsite.dk with SMTP; 7 Nov 2006 17:18:17 -0000 Received: from torch.brasslantern.com ([71.116.118.106]) by vms046.mailsrvcs.net (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) with ESMTPA id <0J8D009G6EKQGQI0@vms046.mailsrvcs.net> for zsh-workers@sunsite.dk; Tue, 07 Nov 2006 11:14:51 -0600 (CST) Received: from torch.brasslantern.com (localhost.localdomain [127.0.0.1]) by torch.brasslantern.com (8.13.1/8.13.1) with ESMTP id kA7HEnRF001098 for ; Tue, 07 Nov 2006 09:14:50 -0800 Received: (from schaefer@localhost) by torch.brasslantern.com (8.13.1/8.13.1/Submit) id kA7HEnlG001097 for zsh-workers@sunsite.dk; Tue, 07 Nov 2006 09:14:49 -0800 Date: Tue, 07 Nov 2006 09:14:49 -0800 From: Bart Schaefer Subject: Re: Hooks In-reply-to: To: "Zsh hackers list" Message-id: <061107091449.ZM1096@torch.brasslantern.com> MIME-version: 1.0 X-Mailer: OpenZMail Classic (0.9.2 24April2005) Content-type: text/plain; charset=us-ascii References: <5db995410611060845y53f673e6je029a9c60659f116@mail.gmail.com> <20061106174053.GA4323@sc> <5db995410611061314l26e089b8wb214da46064c8235@mail.gmail.com> <20061106215051.GB4323@sc> <20061107081800.GA4420@sc> <20061107104916.d01e2fa5.pws@csr.com> Comments: In reply to "Nikolai Weibull" "Re: Hooks" (Nov 7, 7:12am) 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.