From 92baf2b71dfac31f0d2204eff97faca94c3f4b2e Mon Sep 17 00:00:00 2001 From: Iain Patterson Date: Tue, 2 Dec 2014 13:48:39 +0000 Subject: [PATCH] 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. --- .profile.d/cdpath.bashrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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" -- 2.7.4