diff options
| author | Philippe Altherr <philippe.altherr@gmail.com> | 2026-04-21 23:07:54 +0200 |
|---|---|---|
| committer | Oliver Kiddle <opk@zsh.org> | 2026-04-30 21:27:12 +0200 |
| commit | b2fb112ea602866c8f17b2a7156f00ef223dd3e9 (patch) | |
| tree | c6e7364e12e66cac7177141ca1b20aedfdd8fbcf | |
| parent | github #168: complete apt history commands (diff) | |
| download | zsh-b2fb112ea602866c8f17b2a7156f00ef223dd3e9.tar zsh-b2fb112ea602866c8f17b2a7156f00ef223dd3e9.tar.gz zsh-b2fb112ea602866c8f17b2a7156f00ef223dd3e9.tar.bz2 zsh-b2fb112ea602866c8f17b2a7156f00ef223dd3e9.tar.lz zsh-b2fb112ea602866c8f17b2a7156f00ef223dd3e9.tar.xz zsh-b2fb112ea602866c8f17b2a7156f00ef223dd3e9.tar.zst zsh-b2fb112ea602866c8f17b2a7156f00ef223dd3e9.zip | |
54383: Fix WATCH/watch tying
| -rw-r--r-- | ChangeLog | 3 | ||||
| -rw-r--r-- | Src/Modules/watch.c | 15 | ||||
| -rw-r--r-- | Src/module.c | 5 | ||||
| -rw-r--r-- | Test/V01zmodload.ztst | 11 |
4 files changed, 23 insertions, 11 deletions
@@ -1,5 +1,8 @@ 2026-04-30 Oliver Kiddle <opk@zsh.org> + * Philippe Altherr: 54383: Src/Modules/watch.c, Src/module.c, + Test/V01zmodload.ztst: Fix WATCH/watch tying + * Christopher Bock: github #168: Completion/Debian/Command/_apt: add apt history commands diff --git a/Src/Modules/watch.c b/Src/Modules/watch.c index bb27ab9db..f23819b25 100644 --- a/Src/Modules/watch.c +++ b/Src/Modules/watch.c @@ -695,8 +695,10 @@ static struct builtin bintab[] = { }; static struct paramdef partab[] = { - PARAMDEF("WATCH", PM_SCALAR|PM_SPECIAL, &watch, NULL), - PARAMDEF("watch", PM_ARRAY|PM_SPECIAL, &watch, NULL), + PARAMDEF("WATCH", PM_SCALAR|PM_SPECIAL|PM_TIED, &watch, + NULL /* &colonarr_gsu (see setup_()) */), + PARAMDEF("watch", PM_ARRAY|PM_SPECIAL|PM_TIED, &watch, + NULL /* &vararray_gsu (see setup_() */), }; static struct features module_features = { @@ -739,15 +741,6 @@ boot_(UNUSED(Module m)) { static char const * const default_watchfmt = DEFAULT_WATCHFMT; - 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. diff --git a/Src/module.c b/Src/module.c index 659bc3544..0b5cd5649 100644 --- a/Src/module.c +++ b/Src/module.c @@ -1085,6 +1085,9 @@ addparamdef(Paramdef d) */ switch (PM_TYPE(pm->node.flags)) { case PM_SCALAR: + if (pm->node.flags & PM_TIED) + pm->ename = ztrdup(casemodify(pm->node.nam, CASMOD_LOWER)); + /* fall-through */ case PM_NAMEREF: pm->gsu.s = d->gsu ? (GsuScalar)d->gsu : &varscalar_gsu; break; @@ -1099,6 +1102,8 @@ addparamdef(Paramdef d) break; case PM_ARRAY: + if (pm->node.flags & PM_TIED) + pm->ename = ztrdup(casemodify(pm->node.nam, CASMOD_UPPER)); pm->gsu.a = d->gsu ? (GsuArray)d->gsu : &vararray_gsu; break; diff --git a/Test/V01zmodload.ztst b/Test/V01zmodload.ztst index daf49cd72..ec55e0f95 100644 --- a/Test/V01zmodload.ztst +++ b/Test/V01zmodload.ztst @@ -236,6 +236,17 @@ fi 0d:Autoload a module via a math function + if [[ $mods[(r)zsh/watch] == zsh/watch ]]; then + zmodload -u zsh/watch + WATCH=foo:bar + typeset -p WATCH watch + else + ZTST_skip="zsh/watch module not available" + fi +0:Autoload tied parameters +>typeset -g -T WATCH watch=( foo bar ) +>typeset -g -aT WATCH watch=( foo bar ) + # Test module aliases zmodload -A example=zsh/example |
