Blame SOURCES/rear-pr2675.patch

f88787
diff --git a/usr/share/rear/lib/framework-functions.sh b/usr/share/rear/lib/framework-functions.sh
f88787
index 4878216b..e919bdbf 100644
f88787
--- a/usr/share/rear/lib/framework-functions.sh
f88787
+++ b/usr/share/rear/lib/framework-functions.sh
f88787
@@ -121,7 +121,7 @@ function cleanup_build_area_and_end_program () {
f88787
             sleep 2
f88787
             umount_mountpoint_lazy $BUILD_DIR/outputfs
f88787
         fi
f88787
-        remove_temporary_mountpoint '$BUILD_DIR/outputfs' || BugError "Directory $BUILD_DIR/outputfs not empty, can not remove"
f88787
+        remove_temporary_mountpoint "$BUILD_DIR/outputfs" || BugError "Directory $BUILD_DIR/outputfs not empty, can not remove"
f88787
         rmdir $v $BUILD_DIR >&2
f88787
     fi
f88787
     Log "End of program reached"
f88787
diff --git a/usr/share/rear/lib/global-functions.sh b/usr/share/rear/lib/global-functions.sh
f88787
index c1a11615..0f8f362d 100644
f88787
--- a/usr/share/rear/lib/global-functions.sh
f88787
+++ b/usr/share/rear/lib/global-functions.sh
f88787
@@ -317,7 +317,20 @@ function url_path() {
f88787
 
f88787
 ### Returns true if one can upload files to the URL
f88787
 function scheme_accepts_files() {
f88787
-    local scheme=$1
f88787
+    # Be safe against 'set -eu' which would exit 'rear' with "bash: $1: unbound variable"
f88787
+    # when scheme_accepts_files is called without an argument
f88787
+    # by bash parameter expansion with using an empty default value if $1 is unset or null.
f88787
+    # Bash parameter expansion with assigning a default value ${1:=} does not work
f88787
+    # (then it would still exit with "bash: $1: cannot assign in this way")
f88787
+    # but using a default value is practicable here because $1 is used only once
f88787
+    # cf. https://github.com/rear/rear/pull/2675#discussion_r705018956
f88787
+    local scheme=${1:-}
f88787
+    # Return false if scheme is empty or blank (e.g. when OUTPUT_URL is unset or empty or blank)
f88787
+    # cf. https://github.com/rear/rear/issues/2676
f88787
+    # and https://github.com/rear/rear/issues/2667#issuecomment-914447326
f88787
+    # also return false if scheme is more than one word (so no quoted "$scheme" here)
f88787
+    # cf. https://github.com/rear/rear/pull/2675#discussion_r704401462
f88787
+    test $scheme || return 1
f88787
     case $scheme in
f88787
         (null|tape|obdr)
f88787
             # tapes do not support uploading arbitrary files, one has to handle them
f88787
@@ -341,7 +354,10 @@ function scheme_accepts_files() {
f88787
 ### Returning true does not imply that the URL is currently mounted at a filesystem and usable,
f88787
 ### only that it can be mounted (use mount_url() first)
f88787
 function scheme_supports_filesystem() {
f88787
-    local scheme=$1
f88787
+    # Be safe against 'set -eu' exit if scheme_supports_filesystem is called without argument
f88787
+    local scheme=${1:-}
f88787
+    # Return false if scheme is empty or blank or more than one word, cf. scheme_accepts_files() above
f88787
+    test $scheme || return 1
f88787
     case $scheme in
f88787
         (null|tape|obdr|rsync|fish|ftp|ftps|hftp|http|https|sftp)
f88787
             return 1
f88787
@@ -560,7 +576,7 @@ function umount_url() {
f88787
 
f88787
     RemoveExitTask "perform_umount_url '$url' '$mountpoint' lazy"
f88787
 
f88787
-    remove_temporary_mountpoint '$mountpoint' && RemoveExitTask "remove_temporary_mountpoint '$mountpoint'"
f88787
+    remove_temporary_mountpoint "$mountpoint" && RemoveExitTask "remove_temporary_mountpoint '$mountpoint'"
f88787
     return 0
f88787
 }
f88787