bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: remove paths


From: Paul Jarc
Subject: Re: remove paths
Date: Thu, 19 Jul 2001 15:16:39 -0400
User-agent: Gnus/5.090004 (Oort Gnus v0.04) Emacs/20.7

"MrEye" <address@hidden> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]