diff options
author | Johannes Stezenbach <js@sig21.net> | 2010-07-30 17:50:34 +0200 |
---|---|---|
committer | Yann E. MORIN" <yann.morin.1998@anciens.enib.fr> | 2010-07-30 17:50:34 +0200 |
commit | 6d084fb565bcf1fd4705aa88aeba5fa869b73cad (patch) | |
tree | cdd8371ee532e669e0c599a7a4b9eb5998e6f422 | |
parent | 143f02e0ce81ec8886bbdfd73f139eadb910cfe3 (diff) | |
download | crosstool-ng-6d084fb565bcf1fd4705aa88aeba5fa869b73cad.tar.gz crosstool-ng-6d084fb565bcf1fd4705aa88aeba5fa869b73cad.tar.bz2 crosstool-ng-6d084fb565bcf1fd4705aa88aeba5fa869b73cad.zip |
Fix CT_SanitizePath
Replace the over-engineered and buggy test in CT_SanitizePath
with a straight forward string pattern match, and also
handle empty PATH elements which are qeuivalent to ".".
Thanks-To: Arnaud Lacombe <lacombar@gmail.com>
Signed-off-by: Johannes Stezenbach <js@sig21.net>
-rw-r--r-- | scripts/functions | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/scripts/functions b/scripts/functions index 0250f051..16f894ba 100644 --- a/scripts/functions +++ b/scripts/functions @@ -137,18 +137,16 @@ CT_DoEnd() CT_DoLog ${level:-INFO} "(elapsed: ${elapsed_min}:${elapsed_sec}.${elapsed_csec})" } -# Remove entries referring to ., /tmp and non-existing directories from $PATH +# Remove entries referring to . and other relative paths # Usage: CT_SanitizePath CT_SanitizePath() { local new - local tmp + local p 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 + # Only accept absolute paths; + # Note: as a special case the empty string in PATH is equivalent to . + if [ -n "${p}" -a -z "${p%%/*}" ]; then new="${new}${new:+:}${p}" fi done |