Permalink
Browse files

Test for root in a portable fashion.

  Rather than using this:

        if [ "$UID" = 0 ]; then

  We now use the more portable construct:

        if [ "$(id -ru)" = 0 ]; then

  Thanks to `checkbashisms` for the fix.
  • Loading branch information...
1 parent 4e3d64c commit b79e54ec63fba9850027d345d60617f7afd7efb7 @skx committed Apr 21, 2013
Showing with 5 additions and 2 deletions.
  1. +5 −2 flush-firewall
View
@@ -2,7 +2,7 @@
#
# About
# -----
-# Flush the system's firewall - leaving it defenseless.
+# Flush the system's firewall - leaving the host defenseless.
#
#
# License
@@ -20,7 +20,10 @@
PATH=/usr/sbin:/sbin:/bin:/usr/bin
-if [ "$UID" = 0 ]; then
+#
+# If we're root we don't use sudo.
+#
+if [ "$(id -ru)" = 0 ]; then
SUDO=""
else
SUDO="sudo"

0 comments on commit b79e54e

Please sign in to comment.