Add a yesno function to check the boolean value of a variable
This commit is contained in:
parent
7cf049cb35
commit
4b28587704
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user