path functions: remove duplicate

This commit is contained in:
ville rantanen
2017-06-06 09:26:54 +03:00
parent 2649769d05
commit cd20e1d90e
2 changed files with 8 additions and 5 deletions

View File

@@ -383,6 +383,12 @@ function path_add_current {
echo Path "$1" not found >&2
return
}
export PATH=$( echo ${p}:$PATH | awk -F: '{for (i=1;i<=NF;i++) { if ( !x[$i]++ ) printf("%s:",$i); }}' | sed 's,:\+$,,g' )
export PATH="${p}:$PATH"
path_remove_ducplicates
echo PATH=$PATH
}
function path_remove_duplicates {
# Remove duplicates in PATH
PATH=$( echo $PATH | awk -F: '{for (i=1;i<=NF;i++) { if ( !x[$i]++ ) printf("%s:",$i); }}' | sed 's,:\+$,,g' )
export PATH
}