13 lines
470 B
Bash
13 lines
470 B
Bash
|
#!/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
|