[zsh] Move func/ directory to zsh/functions
This commit is contained in:
parent
91da2fc583
commit
7c08c5131f
53 changed files with 1 additions and 1 deletions
31
zsh/functions/bool
Normal file
31
zsh/functions/bool
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
# Eryn Wells <eryn@erynwells.me>
|
||||
# vim: set ft=zsh:
|
||||
|
||||
function bool {
|
||||
if [[ "$1" =~ '^-?[0-9]+$' ]]; then
|
||||
if (( $1 == 0 )); then
|
||||
echo "no"
|
||||
return 1
|
||||
else
|
||||
echo "yes"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
local lowercase_value=${(L)1}
|
||||
|
||||
if [[ "$lowercase_value" == "yes" || "$lowercase_value" == "true" ]]; then
|
||||
echo "yes"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ "$lowercase_value" == "no" || "$lowercase_value" == "false" ]]; then
|
||||
echo "no"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "no"
|
||||
return 1
|
||||
}
|
||||
|
||||
bool "$@"
|
||||
Loading…
Add table
Add a link
Reference in a new issue