From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists.gentoo.org ([140.105.134.102] helo=robin.gentoo.org) by nuthatch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1Fhwz2-0000kd-1H for garchives@archives.gentoo.org; Sun, 21 May 2006 23:05:12 +0000 Received: from robin.gentoo.org (localhost [127.0.0.1]) by robin.gentoo.org (8.13.6/8.13.6) with SMTP id k4LN3WHw004161; Sun, 21 May 2006 23:03:32 GMT Received: from py-out-1112.google.com (py-out-1112.google.com [64.233.166.178]) by robin.gentoo.org (8.13.6/8.13.6) with ESMTP id k4LMucq8030865 for ; Sun, 21 May 2006 22:56:38 GMT Received: by py-out-1112.google.com with SMTP id z59so1406326pyg for ; Sun, 21 May 2006 15:56:38 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type; b=LVX8R+IQQUavXAiYnP32s7Qv8KJxtAq1SZI3qxa+SR9qXlDZQdU6zHNfEZFKQ/iThxrAan+GmU/8ew723pBxez14veguFWM5bKy9xKx4Gmwqp7KHYd8ZClhhniHP5xjQ1wym4qZNZVYqlQRMOk45pVsDpYjdVDn7dVeiAtCXp2U= Received: by 10.35.88.17 with SMTP id q17mr188645pyl; Sun, 21 May 2006 15:56:38 -0700 (PDT) Received: by 10.35.105.8 with HTTP; Sun, 21 May 2006 15:56:38 -0700 (PDT) Message-ID: <9acccfe50605211556h542921a9kbd79da6a016e2101@mail.gmail.com> Date: Sun, 21 May 2006 15:56:38 -0700 From: "Kevin O'Gorman" To: gentoo-user@lists.gentoo.org Subject: [gentoo-user] bash wizardry needed: PATH and MANPATH grow and grow and grow Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-user@gentoo.org Reply-to: gentoo-user@lists.gentoo.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_33457_14645765.1148252198212" X-Archives-Salt: d8ed9d25-f212-434b-b726-fdc14f6bd563 X-Archives-Hash: 3d41757613933cf897b36d4bc91880a9 ------=_Part_33457_14645765.1148252198212 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I have inherited some pretty gnarly dotfiles that I don't really want to fool with too much, but I'm also unhappy with what they do to my environment. They keep adding the same things over and over to some of the variables. Does anyone know a nice little idiom for de-duping a colon-list like PATH o= r MANPATH? It has to retain one copy of each duplicate, preserving the order of *first= * appearances. I know how to avoid duplicates when I do the coding myself: case :$PATH: in *:mynewthing:*) ;; *) export PATH=3D$PATH:mynewthing esac I'm just not sure how best to turn the colon-list into something I can iterate over. Obviously, I use bash. ++ kevin --=20 Kevin O'Gorman, PhD ------=_Part_33457_14645765.1148252198212 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I have inherited some pretty gnarly dotfiles that I don't really want to fo= ol with too much,
but I'm also unhappy with what they do to my environment.  They keep a= dding the
same things over and over to some of the variables.

Does anyone know a nice little idiom for de-duping a colon-list like PATH o= r MANPATH?
It has to retain one copy of each duplicate, preserving the order of *first= * appearances.
I know how to avoid duplicates when I do the coding myself:
       case :$PATH: in
             *:= mynewthing:*) ;;
             *)= export PATH=3D$PATH:mynewthing
       esac

I'm just not sure how best to turn the colon-list into something I can iter= ate over.

Obviously, I use bash.

++ kevin

--
Kevin O'Gorman, PhD
------=_Part_33457_14645765.1148252198212-- -- gentoo-user@gentoo.org mailing list