Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Should (t)path = array-unique-special work this way



Sebastian Gniazdowski wrote on Sun, Feb 14, 2016 at 11:04:02 +0100:
> On 5 February 2016 at 18:15, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> >
> > Q: Why doesn't -U appear in the "declare -p" output?
> > A: Good question.  It doesn't appear for non-special arrays either.  It
> >    may be intentional because -U isn't a POSIX-supported option, but I
> >    suspect it's just an accidental omission.
> 
> Wanted to write a snapshot feature, basically declare -p > snapshot;
> setopt typesetsilent; source ./snapshot, but the omission of -U is
> quite a blocker. Other interesting thing is that typeset -a a doesn't
> fully redefine a, uniqueness still holds if it was present.

If the parameter already exists, 'typeset' will modify it rather than
replace it.  For example, 'typeset x=foo; readonly x; echo $x' prints
'foo' rather than an empty string.

You might need to call 'unset' before calling 'typeset'?  I'm not sure
whether that has any edgecases to beware of.



Messages sorted by: Reverse Date, Date, Thread, Author