X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=.profile.d%2FPATH.bashrc;h=3113f75a54ddec55d0fff56c08de953c377c5ee8;hb=832c2a2fe8a769c0fe7d8d441148fbf82e762a4c;hp=a7d44205bae2f8480e61479bf08141aaca185d02;hpb=104b025d33b8cf5f9d42bda3ac3d158eb7a07701;p=profile.git diff --git a/.profile.d/PATH.bashrc b/.profile.d/PATH.bashrc index a7d4420..3113f75 100644 --- a/.profile.d/PATH.bashrc +++ b/.profile.d/PATH.bashrc @@ -1,11 +1,9 @@ -# $Id$ -# # Path information is stored on separate lines in XXXdirs. # We extract each directory exists and add it to the appropriate PATH. # # Location of the XXXdirs files. -DIR=$HOME/.profile.d +DIR="$HOME/.profile.d" # Set one path to be the same as another. function copypath() { @@ -14,7 +12,7 @@ function copypath() { # Sanitise and export. path="$(eval echo \$$oldpath)" - [ -z "$path" ] || eval export $newpath="$path" + [ -z "$path" ] || eval "export $newpath='$path'" unset path newpath oldpath } @@ -27,20 +25,30 @@ function makepath() { # Check the file exists. [ -e "$DIR/$dirs" ] || return + # Set IFS to newline only so that we can read $(embedded shell commands). + JGD=$IFS + IFS=' +' # Read them. path= - for dir in $(cat "$DIR/$dirs"); do + while read dir; do + dir=$(eval echo "$dir") [ -d "$dir" ] || continue path="$path:$dir" - done + done < "$DIR/$dirs" + unset dir + + # Restore IFS. + IFS=$JGD + unset JGD # Sanitise path. path=${path#:} [ -z "$path" ] && return # Export. - eval export $newpath="$path" + eval "export $newpath='$path'" unset path newpath dirs } @@ -49,8 +57,8 @@ makepath PATH bindirs makepath C_INCLUDE_PATH incdirs copypath CPLUS_INCLUDE_PATH C_INCLUDE_PATH makepath LD_LIBRARY_PATH libdirs -copypath LD_RUN_PATH LD_LIBRARY_PATH +copypath LD_RUN_PATH PATH makepath MANPATH mandirs makepath PKG_CONFIG_PATH pkgdirs -unset sedscr makepath copypath +unset dirs copypath makepath newpath