From f2b5378e06c300a7b79f9c435b4e393944344c87 Mon Sep 17 00:00:00 2001
From: Thomas Juerges <4-jurges@users.noreply.git.astron.nl>
Date: Tue, 28 Apr 2020 12:29:23 +0200
Subject: [PATCH] Correct test for path starting with /hosthome/

---
 tools/ConfigDb/dump_ConfigDb.sh   | 1 +
 tools/ConfigDb/load_ConfigDb.sh   | 5 +++--
 tools/ConfigDb/update_ConfigDb.sh | 5 +++--
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/tools/ConfigDb/dump_ConfigDb.sh b/tools/ConfigDb/dump_ConfigDb.sh
index f5e04cf18..bbd97a220 100755
--- a/tools/ConfigDb/dump_ConfigDb.sh
+++ b/tools/ConfigDb/dump_ConfigDb.sh
@@ -2,4 +2,5 @@ if [ ${#} -ne 1 ]; then
     echo "You must provide a file name for the TANGO_HOST DB dump!"
     exit -1
 fi
+
 docker exec -it dsconfig python -m dsconfig.dump > ${1}
diff --git a/tools/ConfigDb/load_ConfigDb.sh b/tools/ConfigDb/load_ConfigDb.sh
index e3fe552e1..f60d32501 100755
--- a/tools/ConfigDb/load_ConfigDb.sh
+++ b/tools/ConfigDb/load_ConfigDb.sh
@@ -1,9 +1,10 @@
 if [ ${#} -ne 1 ]; then
     echo "You must provide a file name for the TANGO_HOST DB dump!"
     exit -1
-# Check if the filename begins with /hosthome:
-elif [ ${1##/hosthome/} != ${1//\/hosthome\//} ]; then
+# Check if the filename begins with /hosthome/:
+elif [ ${1:0:10} != /hosthome/ ]; then
     echo "You must provide a filename that begins with \"/hosthome/\".  Why is that?  Because the file needs to be stored from within the container to the hosts file system and your HOME directory will be mounted as /hosthome."
     exit -2
 fi
+
 docker exec -it ${TANGO_CONTAINER_ENV} dsconfig json2tango --write ${1}
diff --git a/tools/ConfigDb/update_ConfigDb.sh b/tools/ConfigDb/update_ConfigDb.sh
index 80febaecc..d17af1ad1 100755
--- a/tools/ConfigDb/update_ConfigDb.sh
+++ b/tools/ConfigDb/update_ConfigDb.sh
@@ -1,9 +1,10 @@
 if [ ${#} -ne 1 ]; then
     echo "You must provide a file name for the TANGO_HOST DB dump!"
     exit -1
-# Check if the filename begins with /hosthome:
-elif [ ${1##/hosthome/} != ${1//\/hosthome\//} ]; then
+# Check if the filename begins with /hosthome/:
+elif [ ${1:0:10} != /hosthome/ ]; then
     echo "You must provide a filename that begins with \"/hosthome/\".  Why is that?  Because the file needs to be stored from within the container to the hosts file system and your HOME directory will be mounted as /hosthome."
     exit -2
 fi
+
 docker exec -it ${TANGO_CONTAINER_ENV} dsconfig json2tango --update ${1}
-- 
GitLab