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

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



On Fri, 5 Feb 2016 17:46:24 +0000
Peter Stephenson <p.stephenson@xxxxxxxxxxx> wrote:
> On Fri, 05 Feb 2016 18:34:06 +0100
> Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx> wrote:
> > That was my question. The path has *-unique in type, this could be
> > viewed as a guard that no repetition is possible, but the guard is
> > avoided by assigning to PATH. That's from one point of view
> > unexpected.
> 
> It wasn't your question, but you can of course make PATH unique too, and
> I suppose an additional lesson is that for least surprises you might
> want always to do
> 
> typeset -U path PATH

The behaviour doesn't look like it's documented, at least not in the
obvious place.  The language might be a bit clunky for a shell manual.

diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo
index fb630a7..a15f4c2 100644
--- a/Doc/Zsh/builtins.yo
+++ b/Doc/Zsh/builtins.yo
@@ -1980,6 +1980,11 @@ item(tt(-U))(
 For arrays (but not for associative arrays), keep only the first
 occurrence of each duplicated value.  This may also be set for
 colon-separated special parameters like tt(PATH) or tt(FIGNORE), etc.
+Note the flag takes effect on assignment, and the type of the
+variable being assigned to is determinative; for variables with
+shared values it is therefore recommended to set the flag for
+all interfaces, e.g. `tt(typeset -U PATH path)'.
+
 This flag has a different meaning when used with tt(-f); see below.
 )
 item(tt(-Z) [ var(n) ])(



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