"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