From 21ebcac9d5b69444fb650cf3d6eb97c95551b2a6 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Thu, 30 Mar 2023 10:44:00 -0700 Subject: [PATCH] [zsh] Fix some coding amateur hour in the *_path functions --- zsh/func/append_to_path | 8 ++++---- zsh/func/init_path | 4 ++-- zsh/func/prepend_to_path | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/zsh/func/append_to_path b/zsh/func/append_to_path index 50fb717..ba99cef 100644 --- a/zsh/func/append_to_path +++ b/zsh/func/append_to_path @@ -3,13 +3,13 @@ append_to_path() { local should_export_path=1 - local verbose=0 + local should_be_verbose=0 while getopts "ve" opt; do case $opt in "e") should_export_path=1;; "+e") should_export_path=0;; - "v") verbose=1;; + "v") should_be_verbose=1;; *) ;; esac done @@ -18,12 +18,12 @@ append_to_path() { local path_to_add=$@[$OPTIND] if [[ -d "$path_to_add" ]]; then - if (( $verbose )); then + if (( $should_be_verbose )); then echo "Appending $path_to_add to \$path" fi path+="$path_to_add" else - if (( $verbose )); then + if (( $should_be_verbose )); then echo "$path_to_add doesn't exist" fi result=0 diff --git a/zsh/func/init_path b/zsh/func/init_path index 8edb939..64e9227 100644 --- a/zsh/func/init_path +++ b/zsh/func/init_path @@ -9,11 +9,11 @@ init_path() { case $opt in "v") should_be_verbose=1;; "+v") should_be_verbose=0;; - *) >&2 echo "$0: unknown option '$opt'" ;; + *) ;; esac done - local verbose_flag + local verbose_flag='' if (( $should_be_verbose )); then verbose_flag='-v' fi diff --git a/zsh/func/prepend_to_path b/zsh/func/prepend_to_path index efeac1b..2f29460 100644 --- a/zsh/func/prepend_to_path +++ b/zsh/func/prepend_to_path @@ -17,12 +17,12 @@ prepend_to_path() { local path_to_add=$@[$OPTIND] if [[ -d "$path_to_add" ]]; then - if (( $verbose )); then + if (( $should_be_verbose )); then echo "Prepending $path_to_add to \$path" fi path=("$path_to_add" $path) else - if (( $verbose )); then + if (( $should_be_verbose )); then echo "$path_to_add doesn't exist" fi result=0