From c155de66ecd3ce9537a96afff03ac82742bee19e Mon Sep 17 00:00:00 2001
From: Andre Anjos <andre.anjos@idiap.ch>
Date: Fri, 23 Jun 2017 13:54:44 +0200
Subject: [PATCH] Fix variable assignment

---
 gitlab/functions.sh | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/gitlab/functions.sh b/gitlab/functions.sh
index c173d42..7a82b73 100644
--- a/gitlab/functions.sh
+++ b/gitlab/functions.sh
@@ -264,26 +264,22 @@ dav_upload_folder() {
   fi
 
   find "$1" | while read -r fname; do
-    # make sure the location has at least 1 '/' at the end
-    # more than 1 '/' together (e.g. '//') is interpreted as 1 '/'
-    local safe_remote_prefix="$2/"
-
     # replace the local path prefix ('../folder1/folder2/folder-to-upload/')
     # with the server path prefix ('private-upload/docs/test/')
     # to make something like '../folder1/folder2/folder-to-upload/test.txt'
     # into 'private-upload/docs/test.txt'
-    local server_path="${fname/$1/$safe_remote_prefix}"
+    local server_path="${fname}/${1}/${2}"
 
     # if its a file...
-    if [[ -f "$fname" ]]; then
+    if [[ -f "${fname}" ]]; then
       # upload the file ...
-      dav_upload "$fname" "$server_path"
+      dav_upload "${fname}" "${server_path}"
     else
       # if its a dir, create the dir
-      dav_mkdir "$server_path"
+      dav_mkdir "${server_path}"
     fi
 
-    log_info "Successfully copied folder $1 with curl"
+    log_info "Successfully copied folder ${1} with curl"
   done
 }
 
-- 
GitLab