You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# @todo add support for option_defaults_indexes if a user requests it
854
-
local index item INDEX=-1 VALUE LABEL VISUAL RETURN items=() returns=() defaults=() items_count can_skip_prompt='no' defaults_indexes=() defaults_count=0 defaults_last=-1 fallbacks_indexes=() fallbacks_count=0 fallbacks_last=-1
886
+
local index item INDEX=-1 VALUE LABEL VISUAL RETURN MATCH items=() returns=() defaults=() items_count can_skip_prompt='no' defaults_indexes=() defaults_count=0 defaults_last=-1 fallbacks_indexes=() fallbacks_count=0 fallbacks_last=-1
855
887
for((index =0; index <${#inputs[@]}; index = index + inputs_step));do
856
888
# index considers inputs_step, INDEX is only each item (label/value combo)
857
889
INDEX=$((INDEX +1))
@@ -881,26 +913,6 @@ function choose_() (
881
913
fi
882
914
fi
883
915
884
-
# enable if default
885
-
if [[ $option_default_all=='yes' ]];then
886
-
defaults[INDEX]='yes'
887
-
else
888
-
if [[ ${#defaults_exact[@]}-ne 0 ]];then# bash v3 compat
889
-
foritemin"${defaults_exact[@]}";do
890
-
if [[ $VALUE=="$item" ]];then
891
-
defaults[INDEX]='yes'
892
-
fi
893
-
done
894
-
fi
895
-
if [[ ${#defaults_fuzzy[@]}-ne 0 ]];then# bash v3 compat
896
-
foritemin"${defaults_fuzzy[@]}";do
897
-
if __string_has_case_insensitive_substring "$VALUE""$item";then
898
-
defaults[INDEX]='yes'
899
-
fi
900
-
done
901
-
fi
902
-
fi
903
-
904
916
# generate what is used
905
917
if [[ -n$option_visual ]];then
906
918
eval"VISUAL=\"$option_visual\""
@@ -911,17 +923,45 @@ function choose_() (
911
923
__print_lines "${style__error}Invalid visual=[$VISUAL] for label=[$LABEL] value=[$VALUE], all must be non-empty.${style__end__error}">/dev/stderr
912
924
return 22 # EINVAL 22 Invalid argument
913
925
fi
926
+
items+=("$VISUAL")
914
927
if [[ -n$option_return ]];then
915
928
eval"RETURN=\"$option_return\""
916
929
else
917
930
RETURN="$VALUE"
918
931
fi
919
932
if [[ -z$RETURN ]];then
920
-
__print_lines "${style__error}Invalid return=[$RETURN] for label=[$LABEL] value=[$VALUE], all must be non-empty.${style__end__error}">/dev/stderr
933
+
__print_lines "${style__error}Invalid return=[$RETURN] for label=[$LABEL] value=[$VALUE] visual=[$VISUAL], all must be non-empty.${style__end__error}">/dev/stderr
921
934
return 22 # EINVAL 22 Invalid argument
922
935
fi
923
-
items+=("$VISUAL")
924
936
returns+=("$RETURN")
937
+
938
+
# enable if default
939
+
if [[ $option_default_all=='yes' ]];then
940
+
defaults[INDEX]='yes'
941
+
else
942
+
forMATCHin"${option_matches[@]}";do
943
+
eval"MATCH=\"$MATCH\""
944
+
if [[ -z$MATCH ]];then
945
+
__print_lines "${style__error}Invalid match=[$MATCH] for label=[$LABEL] value=[$VALUE] visual=[$VISUAL] return=[$RETURN], all must be non-empty.${style__end__error}">/dev/stderr
946
+
return 22 # EINVAL 22 Invalid argument
947
+
fi
948
+
949
+
if [[ ${#defaults_exact[@]}-ne 0 ]];then# bash v3 compat
950
+
foritemin"${defaults_exact[@]}";do
951
+
if [[ $MATCH=="$item" ]];then
952
+
defaults[INDEX]='yes'
953
+
fi
954
+
done
955
+
fi
956
+
if [[ ${#defaults_fuzzy[@]}-ne 0 ]];then# bash v3 compat
957
+
foritemin"${defaults_fuzzy[@]}";do
958
+
if __string_has_case_insensitive_substring "$MATCH""$item";then
959
+
defaults[INDEX]='yes'
960
+
fi
961
+
done
962
+
fi
963
+
done
964
+
fi
925
965
done
926
966
items_count="${#items[@]}"
927
967
if [[ $items_count-eq 1 &&$option_required=='yes' ]];then
Copy file name to clipboardExpand all lines: init.sh
+2-3Lines changed: 2 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -62,7 +62,8 @@ else
62
62
DOROTHY_LOAD='no'# this must be outside the below if, to ensure DOROTHY_LOAD is reset, and DOROTHY_LOADED is respected, otherwise posix shells may double load due to cross-compat between dotfiles (.profile along with whatever they support)
63
63
if [ -z"${DOROTHY_LOADED_SHARED_SCOPE-}" ];then
64
64
# `-dash` is macos login shell, `dash` is manual `dash -l` invocation (as $- doesn't include l in dash)
0 commit comments