From 4d60aef61c29835ba6f44c1aa4da19e937f75c37 Mon Sep 17 00:00:00 2001 From: Thomas Neidhart Date: Thu, 14 Dec 2023 10:42:05 +0100 Subject: [PATCH] Fix joinPathOS method that fails on solaris (#3572) * Fix joinPathOS method that fails on solaris, used IFS together with tr to remove duplicate slashes which should work anywhere. * Apply fix also for joinPath function. * Take review comments into account. --- sbin/common/common.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sbin/common/common.sh b/sbin/common/common.sh index 638da169e..d4e9d8ddb 100755 --- a/sbin/common/common.sh +++ b/sbin/common/common.sh @@ -98,7 +98,7 @@ function setDockerVolumeSuffix() { # Joins multiple parts to a valid file path for the current OS function joinPathOS() { - local path=$(printf '/%s' "${@}" | sed 's|/\+|/|g') + local path=$(echo "/${*}" | tr ' ' / | tr -s /) if [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "msys" ]]; then path=$(cygpath -w "${path}") fi @@ -107,7 +107,7 @@ function joinPathOS() { # Joins multiple parts to a valid file path using slashes function joinPath() { - local path=$(printf '/%s' "${@}" | sed 's|/\+|/|g') + local path=$(echo "/${*}" | tr ' ' / | tr -s /) echo "${path}" }