From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 28517 invoked from network); 12 Aug 2021 04:40:57 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 12 Aug 2021 04:40:57 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1628743257; b=eB1AEkT92OJ+3Fx7T4lquayoWvwTxN1Y1yvh3nSRZbPfxneMBixa8BCWnUbevqgQfBmd2mbHrE 6VZIuMYW/ZrH013FfngIR8F+1H76FdGyIIqhwoQdg4SrdaN3q9nWZ8qbR7QemSDtET6rl/Q7mS Kw0q4uj4Itk7E6bANPB48IT0rA88AbaE762ISyYEN3hNvVVOPhrUVvkvRZK7/H3Wc6NVAGvJzq XLmVqUIOX8frn//HqBeknkp1j3PVhgLaAzQjG8D3nOSlynTBKaCF1eEIyGbXpL9kgxmVK+7axH n8QAXKg0v7AVY5Q1vgzx4rdLiUC1p43lgMhu85Ua8GABFQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (a.mx.sigpipe.cz) smtp.remote-ip=37.221.242.114; dmarc=none header.from=sigpipe.cz; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1628743257; bh=yf/kyxjYtTFnHBibwryc9uxnjSsJHEXfChHGyQcP348=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:DKIM-Signature; b=SGAzb68QszIwJfMpVHMp9eiyikqJwVw3apVdjItnXCZ0cAlYVXXhVlFucBYNqdgsNdvgYaWzI0 lejzIXlYkhW52graMDJSIEBc7bdXkbHFrxqhqeSJWwa4KqxJ6p3XkwAZdhp2T8/whAvCEpCvK/ PM33UM6bbjmDBOLBg+sZH5tPVK+jKesLaeXBP30StZwg9iotF8rHMp8MmoXskju6vrJx79myGH teS1kf/2C/4BlCXQWeLUtAqWJ7ge3i0BIifx+GHXMz3Y9aLNor2MGjH0o2P36w/6OY6zLQgyZl zXBpRG+QO8/WM121Es7zXOs0mkqVVDZ4aJhiFskGfWCWpQ==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=mhn8b9NERAJLdEiwUePeBN5t+vGdO9sUg3xEIamE1ZU=; b=BavaO2Rxal7EqUHNENU3agGhgy 3ByPN6glNO04T+bPJOh0V1JinkjqTUF0eOkXmj15nqc0xRx/9ROQGCD9wI7CPQlVGm5RR4NSagWFq rDDg7vzyXkt4sTOo4HgGZASexPBtL4e649uZ4NxfCsKqfoxl7Hkp06866Nj2Lij+eLjSQKt4ByWtw oawqMC+eBWG9i2NFgzACSjVoF7vEYk+hYQWQnU8xsOu6tYfjNJzmhN8n0cSCKzc4rIEa+uVaZ72lh zR3dpkGvN6WmtcfWDvsiPGXS0q2JnowFzZo2/lnMPPJXvR6TIGWZU0nnxuBz1DM2gAzJ/+btbRnKx bpHMduAA==; Received: from authenticated user by zero.zsh.org with local id 1mE2WW-0006Ck-CD; Thu, 12 Aug 2021 04:40:56 +0000 Authentication-Results: zsh.org; iprev=pass (a.mx.sigpipe.cz) smtp.remote-ip=37.221.242.114; dmarc=none header.from=sigpipe.cz; arc=none Received: from a.mx.sigpipe.cz ([37.221.242.114]:3910) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1mE2Vf-0005TW-UP; Thu, 12 Aug 2021 04:40:06 +0000 Received: by a.mx.sigpipe.cz (Postfix, from userid 1001) id CE34E1558664E2; Thu, 12 Aug 2021 06:40:02 +0200 (CEST) Date: Thu, 12 Aug 2021 06:40:02 +0200 From: Roman Neuhauser To: Bart Schaefer Cc: Zsh Users Subject: Re: chpwd, precmd hooks have "zsh" in $0 Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Seq: 26926 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: # schaefer@brasslantern.com / 2021-08-10 10:31:00 -0700: > On Tue, Aug 10, 2021 at 4:33 AM Roman Neuhauser wrote: > > and is it too late to reverse the course, gut the half-assed implementation > > with one written using shell functions? > > There's no need to be offensive about it, but yes, it's too late. The > implementation actually has all the interfaces it needs to populate > FUNCTION_ARGZERO properly, it was just never noticed/found necessary > to do so. sorry, i didn't think much about the wording, and didn't mean to be offencisve. if you (someone) can finish it i'll be grateful. > > > I'm not sure what the desired behavior is here. callhookfunc() could > > > dummy up a LinkNode any time its lnklst argument is empty, and then > > > all the hooks would behave in the manner preexec behaves when history > > > is enabled; or doshfunc() could do the same, in which case every > > > hook-array function would have its own name in $0; or neither of the > > > above is appropriate and we should document the current behavior. > > > > what are the downsides of (2) for users of the shell? > > Theoretically, a function might prefer to know that it was being > called as a consequence of being found in a given hook list, vs. being > called directly. That might argue for (1). yes, but there's other ways to let a function know it's being called as part of a particular hook array. there's only one reasonable way of letting a function know the name it was called with. > > function a b { ... } > ab.log > > precmd_functions=(a) > > preexec_functions=(b) > > > > calls the function with $0 == "a" in precmd, "b" in preexec, > > and that their runtime output goes to ab.log. hooks do neither > > and TRAPNAL functions only the first. :( > > I'm not sure what "the first" is here? use the correct name for a function defined with multiple names. > Anyway, having output redirections on function definitions is another > thing that was added quite late in the long history of the shell -- i know, it was me who asked for it back then. Date: Thu, 24 Jul 2014 14:23:31 +0200 From: Roman Neuhauser To: zsh-users@zsh.org Subject: io-redirect in function definitions > originally, the redirect would have been connected to the "function" > command itself -- so there may be circumstances where you have to > write > > function a b { { ... } > ab.log } > > to be sure of getting what you meant there. PWS may have more to say about it. sure, a workaround exists and it's just a pair of braces and an indentation level away. my bitching here isn't motivated by difficulty to achieve the effect with existing means. i want the shell to be simpler, conceptually smaller by having one kind of functions: those that have their name in $0 and which don't forget redirections defined after their body. requests for changes "just" for the sake of some principles may be annoying so i'll add that this conversation exists because i wanted to use a single function in several hooks and modify its behavior based on the hook name: function generic-hook { local hooks=${1}_functions work with ${(P)hooks} } -- roman