[arch-projects] [devtools] [PATCH 1/2] common: fix arg concatenation and unreachable statement
Dave Reisner
dreisner at archlinux.org
Mon Jun 2 00:16:24 EDT 2014
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
More information about the arch-projects
mailing list