path: don't add directories to PATH if they don't exist
This commit is contained in:
parent
27035f0a29
commit
cc80cae223
1 changed files with 2 additions and 0 deletions
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
# Add custom bin dirs to PATH if they exist and are not already in PATH.
|
# Add custom bin dirs to PATH if they exist and are not already in PATH.
|
||||||
while read -r dir; do
|
while read -r dir; do
|
||||||
|
[ -d "$dir" ] || continue # skip if directory doesn't exist
|
||||||
case ":${PATH:=$dir}:" in
|
case ":${PATH:=$dir}:" in
|
||||||
*:"$dir":*) ;; # already in PATH -> ignore
|
*:"$dir":*) ;; # already in PATH -> ignore
|
||||||
*) PATH="$dir:$PATH" ;; # not yet in PATH -> prepend it
|
*) PATH="$dir:$PATH" ;; # not yet in PATH -> prepend it
|
||||||
|
@ -32,6 +33,7 @@ export PATH
|
||||||
# available.
|
# available.
|
||||||
command -v manpath >/dev/null 2>&1 && MANPATH="$(unset MANPATH; manpath)"
|
command -v manpath >/dev/null 2>&1 && MANPATH="$(unset MANPATH; manpath)"
|
||||||
while read -r dir; do
|
while read -r dir; do
|
||||||
|
[ -d "$dir" ] || continue # skip if directory doesn't exist
|
||||||
case ":${MANPATH:=$dir}:" in
|
case ":${MANPATH:=$dir}:" in
|
||||||
*:"$dir":*) ;; # already in MANPATH -> ignore
|
*:"$dir":*) ;; # already in MANPATH -> ignore
|
||||||
*) MANPATH="$dir:$MANPATH" ;; # not yet in MANPATH -> prepend it
|
*) MANPATH="$dir:$MANPATH" ;; # not yet in MANPATH -> prepend it
|
||||||
|
|
Loading…
Add table
Reference in a new issue