summaryrefslogtreecommitdiff
path: root/scripts/functions
diff options
context:
space:
mode:
authorYann E. MORIN" <yann.morin.1998@anciens.enib.fr>2011-01-25 20:59:03 (GMT)
committerYann E. MORIN" <yann.morin.1998@anciens.enib.fr>2011-01-25 20:59:03 (GMT)
commit8efc6dae8a781e3fc058cda0b49a0a6cfd745bb5 (patch)
tree4dfc251f7be1bb889d2c0beacd69c72ac68448ef /scripts/functions
parent94be1f470c148afe1b7b2a7e43b886c4ddea2e15 (diff)
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" <yann.morin.1998@anciens.enib.fr>
Diffstat (limited to 'scripts/functions')
-rw-r--r--scripts/functions18
1 files changed, 18 insertions, 0 deletions
diff --git a/scripts/functions b/scripts/functions
index 0bc16f7..ba92d11 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 <message>
CT_Abort() {