diff options
author | Victor Lowther <victor.lowther@gmail.com> | 2009-05-06 18:14:07 -0500 |
---|---|---|
committer | Victor Lowther <victor.lowther@gmail.com> | 2009-05-06 18:14:07 -0500 |
commit | 2daad8297459f68fc5ad0fd4b0a2aa8ba918621d (patch) | |
tree | cb0b36040267fe00810987163caede86984956df | |
parent | 46e3db3d321579217edbea90c1ddf6f98ea1f38b (diff) |
Add is_set function to make checking boolean variables easier.
The definition of a boolean variable is one that is set to "true", "yes" "1",
or that is set to the null value.
-rw-r--r-- | pm/functions.in | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/pm/functions.in b/pm/functions.in index bd0705c..fab9b38 100644 --- a/pm/functions.in +++ b/pm/functions.in @@ -3,8 +3,19 @@ # Common functionality for the hooks. +# If a variable is set to true, yes, 1, or is simply set with no value, +# return 0, otherwise return 1. +is_set() +{ + case ${1-UNSET} in + [Tt][Rr][Uu][Ee]|[Yy][Ee][Ss]|1|'') return 0;; + *) return 1;; + esac +} + # for great debugging! -[ "${PM_DEBUG}" = "true" ] && set -x +is_set "${PM_DEBUG}" && set -x + # try to take the lock. Fail if we cannot get it. try_lock() @@ -246,3 +257,4 @@ dbus_send () { command dbus-send "$@" 2>/dev/null || return $NA } + |