aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sh/functions.sh18
1 files changed, 18 insertions, 0 deletions
diff --git a/sh/functions.sh b/sh/functions.sh
index 99c83989..2be38a65 100644
--- a/sh/functions.sh
+++ b/sh/functions.sh
@@ -101,6 +101,24 @@ uniqify() {
echo "${result# *}"
}
+yesno()
+{
+ [ -z "$1" ] && return 1
+
+ case "$1" in
+ [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) return 0;;
+ [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) return 1;;
+ esac
+
+ local value=
+ eval value=\$${1}
+ case "${value}" in
+ [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) return 0;;
+ [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) return 1;;
+ *) vewarn "\$${1} is not set properly"; return 1;;
+ esac
+}
+
KV_to_int() {
[ -z $1 ] && return 1