virt-what.in: get effective uid in a portable way
authorAssaf Gordon <assafgordon@gmail.com>
Mon, 15 Sep 2014 18:58:19 +0000 (18:58 +0000)
committerRichard W.M. Jones <rjones@redhat.com>
Mon, 20 Jun 2016 12:30:17 +0000 (08:30 -0400)
$EUID is bash-specific. Use the POSIX-compatible 'id -u' instead.

virt-what.in

index 1532b90..3feeb60 100644 (file)
@@ -74,8 +74,9 @@ exec_prefix=@exec_prefix@
 PATH="${root}@libexecdir@:${root}/sbin:${root}/usr/sbin:${PATH}"
 
 # Check we're running as root.
+EFFUID=$(id -u) || fail "failed to get current user id"
 
-if [ "x$root" = "x" ] && [ "$EUID" -ne 0 ]; then
+if [ "x$root" = "x" ] && [ "$EFFUID" -ne 0 ]; then
     fail "this script must be run as root"
 fi