1.1 --- a/scripts/functions Sun Jul 18 00:34:38 2010 +0200
1.2 +++ b/scripts/functions Thu Jul 29 19:30:37 2010 +0200
1.3 @@ -137,6 +137,24 @@
1.4 CT_DoLog ${level:-INFO} "(elapsed: ${elapsed_min}:${elapsed_sec}.${elapsed_csec})"
1.5 }
1.6
1.7 +# Remove entries referring to ., /tmp and non-existing directories from $PATH
1.8 +# Usage: CT_SanitizePath
1.9 +CT_SanitizePath() {
1.10 + local new
1.11 + local tmp
1.12 + local IFS=:
1.13 + for p in $PATH; do
1.14 + # Replace any occurence of . with $(pwd -P)
1.15 + # Use /tmp as a default if the directory is non-existent
1.16 + # Do not add /tmp in the PATH
1.17 + tmp="$( cd /tmp; cd "${p}" 2>/dev/null || true; pwd -P )"
1.18 + if [ "${tmp}" != "/tmp" ]; then
1.19 + new="${new}${new:+:}${p}"
1.20 + fi
1.21 + done
1.22 + PATH="${new}"
1.23 +}
1.24 +
1.25 # Abort the execution with an error message
1.26 # Usage: CT_Abort <message>
1.27 CT_Abort() {