From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23360 invoked from network); 29 Sep 2005 03:07:59 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 29 Sep 2005 03:07:59 -0000 Received: (qmail 39801 invoked from network); 29 Sep 2005 03:07:53 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 29 Sep 2005 03:07:53 -0000 Received: (qmail 8680 invoked by alias); 29 Sep 2005 03:07:45 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9459 Received: (qmail 8657 invoked from network); 29 Sep 2005 03:07:44 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 29 Sep 2005 03:07:44 -0000 Received: (qmail 38619 invoked from network); 29 Sep 2005 03:07:43 -0000 Received: from wproxy.gmail.com (64.233.184.192) by a.mx.sunsite.dk with SMTP; 29 Sep 2005 03:07:42 -0000 Received: by wproxy.gmail.com with SMTP id 68so9666wra for ; Wed, 28 Sep 2005 20:07:41 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:references; b=lxDbBYEr1Y3L+j57VcxTrXhKNyzRsRHhUZtdj4z85+fJfG/rrcDlZ0KJI7qtSkQsc7HZHjG2EGCGy16sTRhe7v/u54ZaHykJJK7qAWjY1DQDM19y4K+po5gOgnH+Sgd7WeamOM9rIWdmephtPPPrY5UNHw4o6+mzdtizEOGvNgo= Received: by 10.54.34.54 with SMTP id h54mr334877wrh; Wed, 28 Sep 2005 20:07:41 -0700 (PDT) Received: by 10.54.80.19 with HTTP; Wed, 28 Sep 2005 20:07:41 -0700 (PDT) Message-ID: <7c737f30050928200751eae4b8@mail.gmail.com> Date: Wed, 28 Sep 2005 20:07:41 -0700 From: Deliverable Mail Reply-To: Deliverable Mail To: Bart Schaefer , zsh-users@sunsite.dk Subject: Re: add-path, rm-path In-Reply-To: <1050929030313.ZM25022@candle.brasslantern.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_553_14442623.1127963261291" References: <7c737f3005092815162ea22b0c@mail.gmail.com> <1050929030313.ZM25022@candle.brasslantern.com> X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,HTML_20_30, HTML_MESSAGE,RCVD_BY_IP autolearn=no version=3.0.4 ------=_Part_553_14442623.1127963261291 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I must say I'm impressed even more with zsh. So far it has absolutely everything imaginable! Thanks for all the fish. :) Cheers, Alexy On 9/28/05, Bart Schaefer wrote: > > On Sep 28, 3:16pm, Deliverable Mail wrote: > } > } Many people have python-esque scripts which add a path to a PATH-like > } variable only if it's not there already, or remove it from there > completely. > } I wonder whether zsh has it embedded? > > Zsh has three components that together accomplish this. The first is > automatic linkage between arrays and colon-separated scalars, in this > case the array "path" and the scalar "PATH". > > The second is "typeset -U" for creating self-uniquifying arrays. > > The third is ${array:#pattern} for removing elements matching a pattern > from an array. > > The only time you need a function is when you want to control the order > in which the single remaining instance of a duplicated element appears > in the array, after de-duping. The "typeset -U" behavior is to keep > the one with the lowest array index, even if that means inserting a new > element and deleting an existing equivalent one. > ------=_Part_553_14442623.1127963261291 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
I must say I'm impressed even more with zsh.  So far it has absol= utely everything imaginable!  Thanks for all the fish.  :)
 
Cheers,
Alexy
 
On 9/28/05, = Bart Schaefer <schaefer= @brasslantern.com> wrote:
On Sep 28,  3:16pm, De= liverable Mail wrote:
}
} Many people have python-esque scripts which= add a path to a PATH-like
} variable only if it's not there already, or remove it from there comp= letely.
} I wonder whether zsh has it embedded?

Zsh has three com= ponents that together accomplish this.  The first is
automatic= linkage between arrays and colon-separated scalars, in this
case the array "path" and the scalar "PATH".
The second is "typeset -U" for creating self-uniquifying arrays.=

The third is ${array:#pattern} for removing elements matching a pat= tern
from an array.

The only time you need a function is when you wan= t to control the order
in which the single remaining instance of a dupli= cated element appears
in the array, after de-duping.  The &quo= t;typeset -U" behavior is to keep
the one with the lowest array index, even if that means inserting a new=
element and deleting an existing equivalent one.
=
------=_Part_553_14442623.1127963261291--