summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-11-29 17:58:51 -0500
committerJune McEnroe <june@causal.agency>2019-11-29 17:58:51 -0500
commitbaa2d525e39f19957f54a3dd35840f3b5d415067 (patch)
treec622082e84addd526a30ef8f42a755bb81c3e85f
parentClear PATH before populating it again (diff)
downloadsrc-baa2d525e39f19957f54a3dd35840f3b5d415067.tar.gz
src-baa2d525e39f19957f54a3dd35840f3b5d415067.zip
Only add existing directories to PATH
Diffstat (limited to '')
-rw-r--r--home/.profile9
1 files changed, 5 insertions, 4 deletions
diff --git a/home/.profile b/home/.profile
index 6309b091..2d34ed83 100644
--- a/home/.profile
+++ b/home/.profile
@@ -1,9 +1,10 @@
-_PATH=$PATH
-PATH=
+_PATH=$PATH PATH=
+path() { [ -d "$1" ] && PATH="${PATH}${PATH:+:}${1}"; }
 for prefix in '' /usr/local /usr/pkg /usr /opt/pkg ~/.local; do
-	PATH=${PATH}${PATH:+:}${prefix}/sbin:${prefix}/bin
+	path "${prefix}/sbin"
+	path "${prefix}/bin"
 done
-PATH=$PATH:/usr/games
+path /usr/games
 
 export PAGER=less
 export LESS=FRX