scripts/functions
changeset 2051 57cda75fd174
parent 2044 20dd8cef1c8a
child 2079 d2ceb140371d
child 2092 18da1aa1beab
     1.1 --- a/scripts/functions	Thu Jul 29 19:30:37 2010 +0200
     1.2 +++ b/scripts/functions	Fri Jul 30 17:50:34 2010 +0200
     1.3 @@ -137,18 +137,16 @@
     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 +# Remove entries referring to . and other relative paths
     1.9  # Usage: CT_SanitizePath
    1.10  CT_SanitizePath() {
    1.11      local new
    1.12 -    local tmp
    1.13 +    local p
    1.14      local IFS=:
    1.15      for p in $PATH; do
    1.16 -        # Replace any occurence of . with $(pwd -P)
    1.17 -        # Use /tmp as a default if the directory is non-existent
    1.18 -        # Do not add /tmp in the PATH
    1.19 -        tmp="$( cd /tmp; cd "${p}" 2>/dev/null || true; pwd -P )"
    1.20 -        if [ "${tmp}" != "/tmp" ]; then
    1.21 +        # Only accept absolute paths;
    1.22 +        # Note: as a special case the empty string in PATH is equivalent to .
    1.23 +        if [ -n "${p}" -a -z "${p%%/*}" ]; then
    1.24              new="${new}${new:+:}${p}"
    1.25          fi
    1.26      done