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