Re: [PATCH] Fix WATCH/watch tying

Philippe Altherr <[email protected]>
Newsgroups gmane.comp.shells.zsh.devel
Message-ID <CAGdYchu8=ReJosUGYFs5Jp7tFHCsm-3iJQOpK72H3XShsNVsPg@mail.gmail.com>
>
> The test only tries one way of tying, also, what happens if I try to
> add a tied parameter where the array version is already uppercase, or
> vice versa (possibly a bit paranoid question)?


As a module writer, you are free to not use the new auto-tying by not
adding PM_TIED to any of your paramdef instances and keep using ad hoc code
to perform the tying. For more general auto-tying support one would
probably have to add an ename field to the paramdef
<https://github.com/zsh-users/zsh/blob/f72168a30e7115aae3e90f2374b448e1d4518bd6/Src/zsh.h#L2082>
struct and add a new parameter to some of the PARAMDEF macros defined
below. That's a lot of change for something very rarely used. Since all the
Zsh provided tied parameters seem to use the lowercase/uppercase rule, it
looks a little overkill to go that route. The watch module is the only Zsh
provided module that declares a tied parameter.


> Also#2, does this
> actually matter? The manpage doesn't seem to claim the parameters will
> be tied anyway.
>

Arguably the patch could simply remove the non-functional code. The two
parameters are tied on a data level (assigning one modifies the other) but
not on a metadata level; Zsh doesn't know about the tying and thus fails to
update an exported WATCH when watch is modified and fails to unset both
parameters when one is unset. The following example exposes all these cases:

zmodload zsh/watch
WATCH=a:b:c
echo watch="($watch)"
export WATCH
watch=(x y z)
echo WATCH=$WATCH
zsh -c 'echo WATCH=$WATCH'
unset watch
typeset -p WATCH watch

Output with patch:
watch=(a b c)
WATCH=x:y:z
WATCH=x:y:z

Output without patch:
watch=(a b c)
WATCH=x:y:z
WATCH=a:b:c
export WATCH=''

Even though it's minor details, given that only very little new code is
needed to fix them, I think it's worth it.

Philippe
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.