From 264bcd36c17ea1da7eb73c3340b8bef280a88fbc Mon Sep 17 00:00:00 2001 From: Johannes Stezenbach Date: Thu, 29 Jul 2010 19:30:37 +0200 Subject: scripts: remove . from $PATH Add CT_SanitizePath function which removes entries referring to ., /tmp and non-existing directories from $PATH, and call it early in the build script. If . is in PATH, gcc-4.4.4 build breaks: [ALL ] checking what assembler to use... /tmp/build/targets/arm-unknown-linux-uclibcgnueabi/build/gcc-core-static/arm-unknown-linux-uclibcgnueabi/bin/as ... [ALL ] config.status: creating as i.e. "as" is supposed to be the arm-unknown-linux-uclibcgnueabi cross assembler, but config.status creates a local "as" script which is calling the host assembler. Signed-off-by: Johannes Stezenbach [Yann E. MORIN: style fixes + explanations] Signed-off-by: "Yann E. MORIN" (transplanted from 20dd8cef1c8adff0aa3e78ae6d7acfbc45ed5a83) --- scripts/functions | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'scripts/functions') diff --git a/scripts/functions b/scripts/functions index e991a189..b2189a41 100644 --- a/scripts/functions +++ b/scripts/functions @@ -137,6 +137,24 @@ CT_DoEnd() 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() { -- cgit v1.2.3