Fix PATH manipulation bug in bash profile
This bug caused entries to not be removed if they were already present in the beginning of the list before being prepended. This could lead to duplication of entires, usually this ended up being /usr/local/bin.
This commit is contained in:
parent
77cd259e28
commit
c0b024974a
1 changed files with 1 additions and 1 deletions
|
@ -36,7 +36,7 @@ export VIMINIT='let $MYVIMRC="$XDG_CONFIG_HOME/vim/vimrc" | source $MYVIMRC'
|
|||
prepend_dir() { # 1: dir to add, 2: variable to manipulate
|
||||
[ -d "$1" -a -n "$2" ] || return
|
||||
local list="${!2}" # capture current value
|
||||
list=${list#"$1sep"} # remove dir from beginning
|
||||
list=${list#"$1:"} # remove dir from beginning
|
||||
list=${list//":$1:"/:} # remove dir from middle
|
||||
list=${list%":$1"} # remove dir from end
|
||||
printf -v "$2" "$1${list:+":$list"}" # add in front (use : only if empty)
|
||||
|
|
Loading…
Add table
Reference in a new issue