diff -r 5921089b34bd -r ace1d90c9b15 scripts/functions --- a/scripts/functions Tue Apr 13 22:54:57 2010 +0200 +++ b/scripts/functions Thu Jul 29 19:30:37 2010 +0200 @@ -137,6 +137,24 @@ CT_DoLog ${level:-INFO} "(elapsed: ${elapsed_min}:${elapsed_sec}.${elapsed_csec})" } +# Remove entries referring to ., /tmp and non-existing directories from $PATH +# Usage: CT_SanitizePath +CT_SanitizePath() { + local new + local tmp + local IFS=: + for p in $PATH; do + # Replace any occurence of . with $(pwd -P) + # Use /tmp as a default if the directory is non-existent + # Do not add /tmp in the PATH + tmp="$( cd /tmp; cd "${p}" 2>/dev/null || true; pwd -P )" + if [ "${tmp}" != "/tmp" ]; then + new="${new}${new:+:}${p}" + fi + done + PATH="${new}" +} + # Abort the execution with an error message # Usage: CT_Abort CT_Abort() {