We run from a non-interactive shell, so the exec which is inevitably called will replace the current process and 'die' will never run under any circumstances. Also fix a bug with the su fallback which would cause multiple arguments to be concatenated without any whitespace between them. --- lib/common.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/common.sh b/lib/common.sh index b885080..e4bb91f 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -236,8 +236,9 @@ check_root() { (( EUID == 0 )) && return if type -P sudo >/dev/null; then exec sudo -- "$@" + elif type -P su >/dev/null; then + exec su root -c "$(printf ' %q' "$@")" else - exec su root -c "$(printf '%q' "$@")" + die 'This script must be run as root.' fi - die 'This script must be run as root.' } -- 1.9.3