X-Git-Url: https://git.distorted.org.uk/~mdw/distorted-keys/blobdiff_plain/a218eb121bc640b2821aa21f208f082881b7fc29..aa8478931ce8fa13b56f260da29241f38c18ab76:/keyfunc.sh.in diff --git a/keyfunc.sh.in b/keyfunc.sh.in index dca8dee..c68fec1 100644 --- a/keyfunc.sh.in +++ b/keyfunc.sh.in @@ -187,6 +187,19 @@ checkident () { check "$1" "$R_IDENT" "$2"; } checkword () { check "$1" "$R_WORD" "$2"; } checklabel () { check "$1 label" "$R_LABEL" "$2"; } +## Boolean canonification. +boolify () { + var=$1 what=$2 + + eval v=\$$var + case $v in + 1 | y | yes | on | t | true) v=t ;; + 0 | n | no | off | f | false | nil) v=nil ;; + *) echo >&2 "$quis: bad boolean $what \`$v'"; exit 1 ;; + esac + eval $var=\$v +} + ###-------------------------------------------------------------------------- ### Key storage and properties.