From: Iain Patterson Date: Tue, 2 Dec 2014 13:48:39 +0000 (+0000) Subject: Ensure the CWD precedes PROFILE_HOME in new CDPATH. X-Git-Url: http://git.iain.cx/?a=commitdiff_plain;h=92baf2b71dfac31f0d2204eff97faca94c3f4b2e;p=profile.git Ensure the CWD precedes PROFILE_HOME in new CDPATH. If CDPATH was set to PROFILE_HOME, as was the case when becoming a user with no default CDPATH, we would end up in the unexpected situation of typing, say, "cd .ssh" from the target user's home directory but actually changing to the profile user's .ssh directory. The new logic for CDPATH is as follows: Do nothing if CDPATH already contains PROFILE_HOME. Otherwise set it to . if empty then unconditionally append PROFILE_HOME. --- diff --git a/.profile.d/cdpath.bashrc b/.profile.d/cdpath.bashrc index 4b8fda8..68efbff 100644 --- a/.profile.d/cdpath.bashrc +++ b/.profile.d/cdpath.bashrc @@ -1 +1 @@ -[ -n "$PROFILE_HOME" ] && CDPATH="${CDPATH:+$CDPATH:}$PROFILE_HOME" +[ -n "$PROFILE_HOME" -a "${CDPATH/:$PROFILE_HOME}" = "$CDPATH" ] && CDPATH="${CDPATH:-.}:$PROFILE_HOME"