dotfiles/bin/consolidate-path

14 lines
233 B
Text
Raw Normal View History

2022-08-24 08:07:33 +00:00
#!/bin/bash
# Usage: PATH="$(consolidate-path "$PATH")"
#
# Remove duplicate entries from PATH.
result=":"
IFS=:
for p in $1; do
[[ "$result" == *:"$p":* ]] || result="${result}${p}:"
done
result="${result#:}"
echo "${result%:}"