From 2436729d6f65335ca945f0f22112099856d560fe Mon Sep 17 00:00:00 2001 From: =?utf8?q?Elan=20Ruusam=C3=A4e?= Date: Sat, 22 Jan 2011 20:07:59 +0000 Subject: [PATCH] - add to PATH only existing dirs Changed files: etc/profile -> 1.53 --- etc/profile | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/etc/profile b/etc/profile index be96eac..b758efd 100644 --- a/etc/profile +++ b/etc/profile @@ -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 -- 2.44.0