]> git.pld-linux.org Git - projects/setup.git/commitdiff
- add to PATH only existing dirs
authorElan Ruusamäe <glen@pld-linux.org>
Sat, 22 Jan 2011 20:07:59 +0000 (20:07 +0000)
committerElan Ruusamäe <glen@pld-linux.org>
Sat, 22 Jan 2011 20:07:59 +0000 (20:07 +0000)
Changed files:
    etc/profile -> 1.53

etc/profile

index be96eacc4eb679f02e7d48fa1062d7679da33ba2..b758efd6f6ad25b350b87cdbbd33eb23218e836c 100644 (file)
@@ -4,14 +4,15 @@
 # System wide environment and startup programs
 # Functions and aliases go into the shells dependent startup files
 
-# returns TRUE if $1 contains $2
-strstr() {
+# returns TRUE if $1 contains $2 and $2 is a dir
+checkpath() {
+       test -d "$2" || return 0
        [[ $1 = *$2* ]] && return 0 || return 1
 }
-strstr "$PATH" /usr/X11R6/bin || PATH="$PATH:/usr/X11R6/bin"
-strstr "$PATH" /usr/local/bin || PATH="$PATH:/usr/local/bin"
-strstr "$PATH" "$HOME/bin" || PATH="$PATH:$HOME/bin"
-unset strstr
+checkpath "$PATH" /usr/X11R6/bin || PATH="$PATH:/usr/X11R6/bin"
+checkpath "$PATH" /usr/local/bin || PATH="$PATH:/usr/local/bin"
+checkpath "$PATH" "$HOME/bin" || PATH="$PATH:$HOME/bin"
+unset checkpath
 
 USER=`id -un`
 LOGNAME=$USER
This page took 0.072878 seconds and 4 git commands to generate.