mirror of
https://github.com/dockur/proxmox.git
synced 2026-07-27 16:54:51 +07:00
feat: Improve boolean helpers (#91)
This commit is contained in:
+12
-4
@@ -34,15 +34,23 @@ strip() {
|
||||
}
|
||||
|
||||
enabled() {
|
||||
case "$(strip "${1:-}")" in
|
||||
Y|y|YES|Yes|yes|TRUE|True|true|1|ON|On|on) return 0 ;;
|
||||
|
||||
local value
|
||||
value=$(strip "${1:-}")
|
||||
|
||||
case "${value,,}" in
|
||||
y|yes|true|1|on|enable|enabled) return 0 ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
disabled() {
|
||||
case "$(strip "${1:-}")" in
|
||||
N|n|NO|No|no|FALSE|False|false|0|OFF|Off|off) return 0 ;;
|
||||
|
||||
local value
|
||||
value=$(strip "${1:-}")
|
||||
|
||||
case "${value,,}" in
|
||||
n|no|none|false|0|off|disable|disabled) return 0 ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user