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.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 22540 invoked from network); 6 Nov 2021 00:18:07 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 6 Nov 2021 00:18:07 -0000 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:Message-ID:Date:Content-ID: Content-Type:MIME-Version:Subject:To:References:From:In-reply-to:cc:Reply-To: Content-Transfer-Encoding:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=9WTLnXGs3L9WGb3S46i+BUFnHO7/kI0z1kYn06SDbKU=; b=mNO7ALAdOZyYPfklTQHzakmnIO BgGwhNw+PmUZdV514HPTH9QLelML2K5kSqwJazRdHXYsk733LfG50e/TSBV/p7wnGUTSVDyOadO9x b/V735TvKLtQaxDDgddHW8Ce1xIVDW4byYGZ6f4eREuW/U1v6/mvJcnYRHzk9np8gQexPZbb0F7/c ZfVuqfbzkLOgKhHciW+f6Sb1Y5Zp5AeFa2gsBYt+TvJzoyB+PJ3wSmX3FzdbCTUriJvC+kJsWeJhD xaJx5aBLWHa1CypyOUKeHeESRle2PbMUQRp2rd3otnDSQCiP+Vww1bbFG8b+W9Ux11eMapxHHlo6q 2+/nkQEw==; Received: from authenticated user by zero.zsh.org with local id 1mj9PK-000LQe-7K; Sat, 06 Nov 2021 00:18:06 +0000 Received: from authenticated user by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1mj9P2-000L9F-Lk; Sat, 06 Nov 2021 00:17:48 +0000 Received: from [192.168.178.21] (helo=hydra) by mail.kiddle.eu with esmtp(Exim 4.94.2) (envelope-from ) id 1mj9P1-000BE4-7X; Sat, 06 Nov 2021 01:17:47 +0100 cc: Zsh workers In-reply-to: From: Oliver Kiddle References: <41833-1635545739.955327@NiDy.UqMC.wWcd> <99024-1635725195.643285@RFFV.JZgp.GVTq> To: Bart Schaefer Subject: Re: PATCH: separate watch/log functionality out into a module MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <43154.1636157867.1@hydra> Date: Sat, 06 Nov 2021 01:17:47 +0100 Message-ID: <43155-1636157867.215533@Ne4o.Iiwb.hwym> X-Seq: 49544 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: On 31 Oct, Bart Schaefer wrote: (reordering Bart's reply here) > I think you're misinterpreting what's happening. If I use gdb: Yes, you're right so I retract most of what I said. I'm used to just prefixing commands to export values but the assignment is, of course, taking place in the initial shell. > Hm. What would the right behavior be? Do we need a flag on the > autoloaded parameter for whether the value is [not?] allowed to come > from the environment? PM_DONTIMPORT seems potentially relevant. I'm not sure whether PM_DONTIMPORT really helps at all. It is probably necessary this way but even with env, we do get: env options=foo zsh -df zsh: Can't add module parameter `options': parameter already exists But for a parameter like WATCH, it'd ideally load the module and use the imported value. Is it an important feature that $WATCH can come from the environment? With sh emulation we don't get that error message which was really what I was concerned about. > (this is all without your patches) I don't think my patches will have changed anything in this regard other than for what happens with $watch and $WATCH. On further testing zsh/watch does need to better guard against one of them coming from the environment. They can only be tied if both are there. The patch below covers this case. Can someone with a Mac confirm something: have they disabled the log builtin because it clashed with an external command. I did have a link for their code modifications but the link appears to be broken. A log(1) man page does seem to exist based on a web search. If watch is a module, hopefully they include it in future and only disable the autoloading. Oliver diff --git a/Src/Modules/watch.c b/Src/Modules/watch.c index 02f0562fc..5ce604c63 100644 --- a/Src/Modules/watch.c +++ b/Src/Modules/watch.c @@ -640,8 +640,8 @@ static struct builtin bintab[] = { }; static struct paramdef partab[] = { - PARAMDEF("WATCH", PM_TIED|PM_SCALAR|PM_SPECIAL, &watch, &colonarr_gsu), - PARAMDEF("watch", PM_TIED|PM_ARRAY|PM_SPECIAL, &watch, &vararray_gsu), + PARAMDEF("WATCH", PM_SCALAR|PM_SPECIAL, &watch, &colonarr_gsu), + PARAMDEF("watch", PM_ARRAY|PM_SPECIAL, &watch, &vararray_gsu), }; static struct features module_features = { @@ -679,12 +679,16 @@ int boot_(UNUSED(Module m)) { static char const * const default_watchfmt = DEFAULT_WATCHFMT; - Param pm; - if ((pm = (Param) paramtab->getnode(paramtab, "watch"))) - pm->ename = "WATCH"; - if ((pm = (Param) paramtab->getnode(paramtab, "WATCH"))) - pm->ename = "watch"; + Param pma = (Param) paramtab->getnode(paramtab, "watch"); + Param pms = (Param) paramtab->getnode(paramtab, "WATCH"); + if (pma && pms && pma->u.arr == watch && pms->u.arr == watch) { + /* only tie the two parameters if both were added */ + pma->ename = "WATCH"; + pms->ename = "watch"; + pma->node.flags |= PM_TIED; + pms->node.flags |= PM_TIED; + } watch = mkarray(NULL); /* These two parameters are only set to defaults if not set.