Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

severity style, pr 2675 #352

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion usr/share/rear/lib/_input-output-functions.sh
Expand Up @@ -898,7 +898,7 @@ function cleanup_build_area_and_end_program () {
# which is not yet sourced in case of early Error() in usr/sbin/rear
if has_binary remove_temporary_mountpoint ; then
# It is a bug in ReaR if BUILD_DIR/outputfs was not properly umounted and made empty by the scripts before:
remove_temporary_mountpoint '$BUILD_DIR/outputfs' || BugError "Directory $BUILD_DIR/outputfs not empty, cannot remove"
remove_temporary_mountpoint "$BUILD_DIR/outputfs" || BugError "Directory $BUILD_DIR/outputfs not empty, cannot remove"
fi
if ! rmdir $v "$BUILD_DIR" ; then
LogPrintError "Could not remove build area $BUILD_DIR (something still exists therein)"
Expand Down
22 changes: 19 additions & 3 deletions usr/share/rear/lib/global-functions.sh
Expand Up @@ -344,7 +344,20 @@ function url_path() {

### Returns true if one can upload files to the URL
function scheme_accepts_files() {
local scheme=$1
# Be safe against 'set -eu' which would exit 'rear' with "bash: $1: unbound variable"
# when scheme_accepts_files is called without an argument
# by bash parameter expansion with using an empty default value if $1 is unset or null.
# Bash parameter expansion with assigning a default value ${1:=} does not work
# (then it would still exit with "bash: $1: cannot assign in this way")
# but using a default value is practicable here because $1 is used only once
# cf. https://github.com/rear/rear/pull/2675#discussion_r705018956
local scheme=${1:-}
# Return false if scheme is empty or blank (e.g. when OUTPUT_URL is unset or empty or blank)
# cf. https://github.com/rear/rear/issues/2676
# and https://github.com/rear/rear/issues/2667#issuecomment-914447326
# also return false if scheme is more than one word (so no quoted "$scheme" here)
# cf. https://github.com/rear/rear/pull/2675#discussion_r704401462
test $scheme || return 1
case $scheme in
(null|tape|obdr)
# tapes do not support uploading arbitrary files, one has to handle them
Expand All @@ -368,7 +381,10 @@ function scheme_accepts_files() {
### Returning true does not imply that the URL is currently mounted at a filesystem and usable,
### only that it can be mounted (use mount_url() first)
function scheme_supports_filesystem() {
local scheme=$1
# Be safe against 'set -eu' exit if scheme_supports_filesystem is called without argument
local scheme=${1:-}
# Return false if scheme is empty or blank or more than one word, cf. scheme_accepts_files() above
test $scheme || return 1
case $scheme in
(null|tape|obdr|rsync|fish|ftp|ftps|hftp|http|https|sftp)
return 1
Expand Down Expand Up @@ -682,7 +698,7 @@ function umount_url() {

RemoveExitTask "perform_umount_url '$url' '$mountpoint' lazy"

remove_temporary_mountpoint '$mountpoint' && RemoveExitTask "remove_temporary_mountpoint '$mountpoint'"
remove_temporary_mountpoint "$mountpoint" && RemoveExitTask "remove_temporary_mountpoint '$mountpoint'"
return 0
}

Expand Down