From fa0e59ea3911a7660c39ac07f994eee23dc4d450 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Fri, 1 Aug 2025 10:38:48 -0700 Subject: [PATCH] [zsh] Autoload the bool function --- zsh/func/bool | 26 +++++++++++++------------- zshrc | 1 + 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/zsh/func/bool b/zsh/func/bool index c5bf961..1fe2567 100644 --- a/zsh/func/bool +++ b/zsh/func/bool @@ -2,30 +2,30 @@ # vim: set ft=zsh: function bool { - if [[ $1 -eq 0 ]]; then - echo "no" - return false + 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" ]]; then + if [[ "$lowercase_value" == "yes" || "$lowercase_value" == "true" ]]; then echo "yes" - return true + return 0 fi - if [[ "$lowercase_value" == "no" ]]; then + if [[ "$lowercase_value" == "no" || "$lowercase_value" == "false" ]]; then echo "no" - return false - fi - - if [[ "$lowercase_value" =~ '^[0-9]+$' ]]; then - echo "yes" - return true + return 1 fi echo "no" - return false + return 1 } bool "$@" diff --git a/zshrc b/zshrc index 8f70595..da1297d 100644 --- a/zshrc +++ b/zshrc @@ -21,6 +21,7 @@ fi do_init_functions zsh_init_rc_functions +autoload -Uz bool autoload -Uz g autoload -Uz nethack autoload -Uz pw