[pathmunge] added function to prevent duplicates in PATH variable
parent
a044ad5f59
commit
cf3728c5aa
|
|
@ -361,3 +361,21 @@ all_groups ()
|
|||
cat $file | sort | uniq
|
||||
rm $file
|
||||
}
|
||||
|
||||
if ! type pathmunge > /dev/null 2>&1
|
||||
then
|
||||
function pathmunge () {
|
||||
_about 'prevent duplicate directories in you PATH variable'
|
||||
_group 'lib helpers'
|
||||
_example 'pathmunge /path/to/dir is equivalent to PATH=/path/to/dir:$PATH'
|
||||
_example 'pathmunge /path/to/dir after is equivalent to PATH=$PATH:/path/to/dir'
|
||||
|
||||
if ! [[ $PATH =~ (^|:)$1($|:) ]] ; then
|
||||
if [ "$2" = "after" ] ; then
|
||||
export PATH=$PATH:$1
|
||||
else
|
||||
export PATH=$1:$PATH
|
||||
fi
|
||||
fi
|
||||
}
|
||||
fi
|
||||
|
|
|
|||
Loading…
Reference in New Issue