Skip to content

Commit 50fb39e

Browse files
committed
choose: fix regression
/ref 264076e add `__case_insensitive_compare_contains`
1 parent 8f13d0a commit 50fb39e

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

commands/choose

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ function choose_() (
919919
fi
920920
done
921921
for item in "${defaults_fuzzy[@]}"; do
922-
if __case_insensitive_compare "$MATCH" "$item"; then
922+
if __case_insensitive_compare_contains "$MATCH" "$item"; then
923923
defaults[INDEX]='yes'
924924
fi
925925
done

sources/bash.bash

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,10 @@ if [[ $BASH_VERSION_MAJOR -eq 5 && $BASH_VERSION_MINOR -ge 1 ]]; then
955955
function __case_insensitive_compare {
956956
[[ ${1@L} == "${2@L}" ]] || return $?
957957
}
958+
function __case_insensitive_compare_contains {
959+
# trunk-ignore(shellcheck/SC2053)
960+
[[ ${1@L} == *"${2@L}"* ]] || return $?
961+
}
958962
function __case_insensitive_compare_pattern {
959963
# trunk-ignore(shellcheck/SC2053)
960964
[[ ${1@L} =~ ${2@L} ]] || return $?
@@ -1001,6 +1005,9 @@ else
10011005
function __case_insensitive_compare {
10021006
[[ ${1,,} == "${2,,}" ]] || return $?
10031007
}
1008+
function __case_insensitive_compare_contains {
1009+
[[ ${1,,} == *"${2,,}"* ]] || return $?
1010+
}
10041011
function __case_insensitive_compare_pattern {
10051012
# trunk-ignore(shellcheck/SC2053)
10061013
[[ ${1,,} =~ ${2,,} ]] || return $?
@@ -1056,6 +1063,10 @@ else
10561063
shopt -s nocasematch
10571064
[[ $1 == "$2" ]] || return $?
10581065
)
1066+
function __case_insensitive_compare_contains () (
1067+
shopt -s nocasematch
1068+
[[ $1 == *"$2"* ]] || return $?
1069+
)
10591070
function __case_insensitive_compare_pattern () (
10601071
shopt -s nocasematch
10611072
# trunk-ignore(shellcheck/SC2053)

0 commit comments

Comments
 (0)