Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID
	autolearn=ham autolearn_force=no version=3.4.1
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=brasslantern-com.20150623.gappssmtp.com; s=20150623;
        h=from:message-id:date:in-reply-to:comments:references:to:subject
         :mime-version:content-type;
        bh=+LK1z6ZX59D2HX3xJ70MJ5eTxbkGfAIgiH5uUUDqWSY=;
        b=IOJlZfBVBUm1Hi+VMcQ5YzYxNAM6wSg4B7gS5JpRgEgtshHdnIx8j9LeahbazToAoG
         w6wi+dLXVKIOqqVRgjDhWFncwEpOo8egCy2sOrFC4xeImk2EGyRDrNj4b/YNmg7UYN0V
         eEf22TSYdHx+0IY9Q2MD/WXZLSuQrvVtMRIzsrOWN0PyMXs8+q3mGQ0mqDa3Myye4IR/
         JQhkozsWy30lyJYOT8AXUgyxXZaQ/TQmaHzmDMzMXmMmpeNfxRtjMVPa7S85c4gF5ai2
         qJ3Np0pq2N1i3P5YM4kvkBAczVmrtnSpKP4bYx8temV3U/0IL4jghGxE9xHJNIfk5IJz
         +RkQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:from:message-id:date:in-reply-to:comments
         :references:to:subject:mime-version:content-type;
        bh=+LK1z6ZX59D2HX3xJ70MJ5eTxbkGfAIgiH5uUUDqWSY=;
        b=d2Ok0lAJDOyIK18OgFIEVrxyUm1tG8V6nc66BaH1uj20x2Ad3sxAtnA0L6CJd3p9L0
         I6ZoMxKP0Zcd6OKtI4l9GIYe8V6m2Xi6J3i5mr9P8JXC1vF6UK3ugFOgY8RrFL/GMXJ2
         3mJrlAsZoW4JszIOUvplPPPHo/8anFO+Up4PEfdMEywTK+bQpY52NKgxDocwDhmn1UCE
         SjfkhxUL66ZVSncR432sudQw1gfX/EcO2zGdI7jo4zyvPB16eEBXZAiMA+pfzDBq5fbm
         nbg+r16+f6HnND90Ndd1C9x/sHhgZThnjR0t4pYS+PjtKdWh4ijLQOAi7NdWVtG/W05V
         p+Rw==
X-Gm-Message-State: AG10YOSq+ZNxZOWbRZvkrJs0YT+0jCaXhqQGyvPWPN2EorY4MOQscVntroHiK0TRJFBbew==
X-Received: by 10.98.43.73 with SMTP id r70mr21430532pfr.4.1454692544020;
        Fri, 05 Feb 2016 09:15:44 -0800 (PST)
From: Bart Schaefer <schaefer@brasslantern.com>
Message-Id: <160205091543.ZM29723@torch.brasslantern.com>
Date: Fri, 5 Feb 2016 09:15:43 -0800
In-Reply-To: <CAKc7PVCDHQDc=sby5wGNEtWCA6omFhmP8uPWbsPXwTQv9tDqFw@mail.gmail.com>
Comments: In reply to Sebastian Gniazdowski <sgniazdowski@gmail.com>
        "Should (t)path = array-unique-special work this way" (Feb  5,  2:45pm)
References: <CAKc7PVCDHQDc=sby5wGNEtWCA6omFhmP8uPWbsPXwTQv9tDqFw@mail.gmail.com>
X-Mailer: OpenZMail Classic (0.9.2 24April2005)
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: Should (t)path = array-unique-special work this way
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Seq: zsh-workers 37889

On Feb 5,  2:45pm, Sebastian Gniazdowski wrote:
}
} typeset -U path
} PATH="$PATH:/component/nr1"
} path+="/component/nr2"
} PATH="/component/nr2:$PATH"
} print "${(t)path}"
} declare -p path

I'm not really sure what question(s) you're asking.

Aside:
 Although it works to append to an array with path+="/component/nr2",
 it's really not good form.  Get used to path+=("/component/nr2") and
 you'll have much less trouble later.

Back to main topic:

} Outputs:
} array-unique-special

So far so good.

} typeset -a path
} path=( /component/nr2 /usr/local/bin /usr/bin /bin /usr/games /component/nr1 /component/nr2 )

For 5.3, this will change to

typeset -a path=( /component/nr2 /usr/local/bin /usr/bin /bin /usr/games /component/nr1 /component/nr2 )

Other things you might be asking about:

Q: Why is nr2 repeated when path is declared -U ?
A: Because it's repeated in $PATH.  Array uniqueness of tied arrays is
   only applied when assigning to the array; when assigning to the tied
   scalar, the array faithfully copies the value of the scalar.  If this
   were not the case, you could end up with a feedback loop (scalar is
   changed -> array uniquifies -> scalar changes again -> etc.).  This
   in turn is because scalars don't have a "uniqueness" property, so if
   the user is explicitly assigning to the scalar then we presume it is
   expected to reflect the value so assigned.

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.

