setup: etc/profile - add to PATH only existing dirs

glen glen at pld-linux.org
Sat Jan 22 21:08:04 CET 2011


Author: glen                         Date: Sat Jan 22 20:08:04 2011 GMT
Module: setup                         Tag: HEAD
---- Log message:
- add to PATH only existing dirs

---- Files affected:
setup/etc:
   profile (1.52 -> 1.53) 

---- Diffs:

================================================================
Index: setup/etc/profile
diff -u setup/etc/profile:1.52 setup/etc/profile:1.53
--- setup/etc/profile:1.52	Wed May 27 13:43:22 2009
+++ setup/etc/profile	Sat Jan 22 21:07:59 2011
@@ -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
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/setup/etc/profile?r1=1.52&r2=1.53&f=u



More information about the pld-cvs-commit mailing list