From 8efc6dae8a781e3fc058cda0b49a0a6cfd745bb5 Mon Sep 17 00:00:00 2001 From: "Yann E. MORIN\"" Date: Tue, 25 Jan 2011 21:59:03 +0100 Subject: scripts: fix double slash in paths Computed paths may contain double slashes. This is not an issue but it is just ugly to look at. Signed-off-by: "Yann E. MORIN" --- scripts/functions | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'scripts/functions') diff --git a/scripts/functions b/scripts/functions index 0bc16f7f..ba92d118 100644 --- a/scripts/functions +++ b/scripts/functions @@ -159,6 +159,24 @@ CT_SanitizePath() { PATH="${new}" } +# Sanitise the directory name contained in the variable passed as argument: +# - remove duplicate / +# Usage: CT_SanitiseVarDir CT_PREFIX_DIR +CT_SanitiseVarDir() { + local var + local old_dir + local new_dir + + for var in "$@"; do + eval "old_dir=\"\${${var}}\"" + new_dir="$( printf "${old_dir}" \ + |sed -r -e 's:/+:/:g;' \ + )" + eval "${var}=\"${new_dir}\"" + CT_DoLog DEBUG "Sanitised '${var}': '${old_dir}' -> '${new_dir}'" + done +} + # Abort the execution with an error message # Usage: CT_Abort CT_Abort() { -- cgit v1.2.3