2024-09-19 04:31:48 +00:00
|
|
|
#!/usr/bin/env -S sh -c 'echo "Not a user script. source(aka .) only"'
|
|
|
|
|
|
|
|
# Remove duplicates from PATH
|
|
|
|
OLDPATH="$PATH"; NEWPATH=""; colon=""
|
|
|
|
while [ "${OLDPATH#*:}" != "$OLDPATH" ]; do
|
|
|
|
entry="${OLDPATH%%:*}"; search=":${OLDPATH#*:}:"
|
|
|
|
[ "${search#*:"$entry":}" = "$search" ] && [[ -d $entry ]] && NEWPATH="$NEWPATH$colon$entry" && colon=:
|
|
|
|
OLDPATH="${OLDPATH#*:}"
|
|
|
|
done
|
|
|
|
NEWPATH="$NEWPATH:$OLDPATH"
|
|
|
|
export PATH="$NEWPATH"
|
|
|
|
unset NEWPATH OLDPATH colon entry search
|
2024-11-25 02:52:17 +00:00
|
|
|
|
|
|
|
[[ -n "${DBG}" ]] && echo "${PATH//:/\n}"
|
|
|
|
|