[zsh] Fix some coding amateur hour in the *_path functions

This commit is contained in:
Eryn Wells 2023-03-30 10:44:00 -07:00
parent dd7de9628e
commit 21ebcac9d5
3 changed files with 8 additions and 8 deletions

View file

@ -3,13 +3,13 @@
append_to_path() { append_to_path() {
local should_export_path=1 local should_export_path=1
local verbose=0 local should_be_verbose=0
while getopts "ve" opt; do while getopts "ve" opt; do
case $opt in case $opt in
"e") should_export_path=1;; "e") should_export_path=1;;
"+e") should_export_path=0;; "+e") should_export_path=0;;
"v") verbose=1;; "v") should_be_verbose=1;;
*) ;; *) ;;
esac esac
done done
@ -18,12 +18,12 @@ append_to_path() {
local path_to_add=$@[$OPTIND] local path_to_add=$@[$OPTIND]
if [[ -d "$path_to_add" ]]; then if [[ -d "$path_to_add" ]]; then
if (( $verbose )); then if (( $should_be_verbose )); then
echo "Appending $path_to_add to \$path" echo "Appending $path_to_add to \$path"
fi fi
path+="$path_to_add" path+="$path_to_add"
else else
if (( $verbose )); then if (( $should_be_verbose )); then
echo "$path_to_add doesn't exist" echo "$path_to_add doesn't exist"
fi fi
result=0 result=0

View file

@ -9,11 +9,11 @@ init_path() {
case $opt in case $opt in
"v") should_be_verbose=1;; "v") should_be_verbose=1;;
"+v") should_be_verbose=0;; "+v") should_be_verbose=0;;
*) >&2 echo "$0: unknown option '$opt'" ;; *) ;;
esac esac
done done
local verbose_flag local verbose_flag=''
if (( $should_be_verbose )); then if (( $should_be_verbose )); then
verbose_flag='-v' verbose_flag='-v'
fi fi

View file

@ -17,12 +17,12 @@ prepend_to_path() {
local path_to_add=$@[$OPTIND] local path_to_add=$@[$OPTIND]
if [[ -d "$path_to_add" ]]; then if [[ -d "$path_to_add" ]]; then
if (( $verbose )); then if (( $should_be_verbose )); then
echo "Prepending $path_to_add to \$path" echo "Prepending $path_to_add to \$path"
fi fi
path=("$path_to_add" $path) path=("$path_to_add" $path)
else else
if (( $verbose )); then if (( $should_be_verbose )); then
echo "$path_to_add doesn't exist" echo "$path_to_add doesn't exist"
fi fi
result=0 result=0