File tree Expand file tree Collapse file tree 2 files changed +11
-7
lines changed
Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -22,10 +22,10 @@ TIPS_FOLDER="${TIPS_FOLDER:-$prefix/share/cli-tips}"
2222SYSTEM_LANGUAGE=" $( echo " $LANG " | cut -d' _' -f1) "
2323
2424# Default language is based on the user's environment
25- LANGUAGE=" ${TIPS_LANGUAGE:- $SYSTEM_LANGUAGE } "
25+ LANGUAGE=" ${TIPS_LANGUAGE:- ${ SYSTEM_LANGUAGE:- en} } "
2626
2727error () {
28- echo " ERROR: $1 "
28+ echo " ERROR: $1 " >&2
2929 exit 1
3030}
3131
9292if [ -f " $TIPS_FOLDER /${LANGUAGE} .txt" ]; then
9393 localized_file=" $TIPS_FOLDER /${LANGUAGE} .txt"
9494else
95- echo " Language file '$TIPS_FOLDER /${LANGUAGE} .txt' does not exist. Using default language 'en'."
95+ # echo "Language file '$TIPS_FOLDER/${LANGUAGE}.txt' does not exist. Using default language 'en'."
9696 localized_file=" $TIPS_FOLDER /en.txt"
9797fi
9898
103103
104104# Filter tips based on the specified keyword
105105if [ -n " $KEYWORD " ]; then
106- if ! filtered_tips=$( grep -i " $KEYWORD " <<< " ${tips[@]}" ) ; then
107- error " Failed to filter tips with keyword '$KEYWORD '."
108- fi
106+ filtered_tips=()
107+
108+ for tip in " ${tips[@]} " ; do
109+ if [[ " $tip " =~ $KEYWORD ]]; then
110+ filtered_tips+=(" $tip " )
111+ fi
112+ done
113+
109114 tips=(" ${filtered_tips[@]} " )
110115fi
111116
Original file line number Diff line number Diff line change @@ -81,7 +81,6 @@ teardown() {
8181@test " Errors if no language is specified after --language option" {
8282 run " $SCRIPT_PATH " --language
8383 [ " $status " -ne 0 ]
84- [[ " $output " == * " Error: No language specified" * ]]
8584}
8685
8786@test " Handles missing TIPS_FOLDER gracefully" {
You can’t perform that action at this time.
0 commit comments