public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Kevin O'Gorman" <kogorman@gmail.com>
To: gentoo-user@lists.gentoo.org
Subject: Re: [gentoo-user] bash wizardry needed: PATH and MANPATH grow and grow and grow
Date: Wed, 24 May 2006 07:58:48 -0700	[thread overview]
Message-ID: <9acccfe50605240758n51991430hc3a15305f0f74133@mail.gmail.com> (raw)
In-Reply-To: <169ffc030605231306m37b7e90ayda8315a8b84dff44@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1597 bytes --]

On 5/23/06, znx <znxster@gmail.com> wrote:
>
> On 21/05/06, Kevin O'Gorman <kogorman@gmail.com> wrote:
> >  Does anyone know a nice little idiom for de-duping a colon-list like
> PATH
> > or MANPATH?
>
> Yeah this is something that constantly annoyed me, I forget where I
> found this (although I moved it to a function), it is not of my
> creation.
>
> To ensure no confusion with the below paste, I have additionally
> placed this in a text file:
> http://kutzooi.co.uk/cleanpath.sh.txt
>
> function cleanpath {
>                 # Removes duplicates from PATH style variables
>         local variable='PATH'
>         if [ $# -eq 1 ]
>         then
>                 variable="$1"
>         fi
>         local var="${1:-${variable}}" oldpath newpath=: entry
>         oldpath="${!var}:"
>         while [ -n "$oldpath" ]; do
>                 entry="${oldpath%%:*}"
>                 oldpath="${oldpath#*:}"
>                 [ "${entry:0:1}" = / ] && [ -n "${newpath##*:$entry:*}" ]
> && \
>                         [ -d "$entry" ] && newpath="$newpath$entry:"
>         done
>         newpath="${newpath#:}"
>         eval "$var"'="${newpath%:}"'
> }
>
> cleanpath                                       # defaults to PATH
> cleanpath MANPATH
> cleanpath LD_LIBRARY_PATH
>
> Hope this helps.
> Mark
>
> --
> gentoo-user@gentoo.org mailing list
>
> This _does_ help.  It's mysterious enough that I tested it, and it seems
to work
except that it removes "." from any path.  This is not quite what I want.

++ kevin


-- 
Kevin O'Gorman, PhD

[-- Attachment #2: Type: text/html, Size: 3346 bytes --]

  reply	other threads:[~2006-05-24 15:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-21 22:56 [gentoo-user] bash wizardry needed: PATH and MANPATH grow and grow and grow Kevin O'Gorman
2006-05-23 20:06 ` znx
2006-05-24 14:58   ` Kevin O'Gorman [this message]
2006-05-26  1:27     ` znx
2006-05-27  2:52       ` Kevin O'Gorman
2006-06-03 21:11         ` znx
2006-07-05 19:33           ` Boyd Stephen Smith Jr.
2006-07-07 18:31             ` Kevin O'Gorman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9acccfe50605240758n51991430hc3a15305f0f74133@mail.gmail.com \
    --to=kogorman@gmail.com \
    --cc=gentoo-user@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox