[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: remove paths
From: |
MrEye |
Subject: |
Re: remove paths |
Date: |
Fri, 20 Jul 2001 08:41:24 -0400 |
Thank you.
"Paul Jarc" <prj@po.cwru.edu> wrote in message
m3ofqg91aq.fsf@multivac.cwru.edu">news:m3ofqg91aq.fsf@multivac.cwru.edu...
> "MrEye" <notell@hate_spam.com> writes:
> > How do you remove a directory path from the $PATH variable?
>
> With effort. I use this function to remove duplicate entries from
> PATH and similar variables; season to taste.
>
> function cleanpath {
> local var="${1:-PATH}" 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%:}"'
> }
>
>
> paul