File tree 2 files changed +11
-7
lines changed
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}"
22
22
SYSTEM_LANGUAGE=" $( echo " $LANG " | cut -d' _' -f1) "
23
23
24
24
# Default language is based on the user's environment
25
- LANGUAGE=" ${TIPS_LANGUAGE:- $SYSTEM_LANGUAGE } "
25
+ LANGUAGE=" ${TIPS_LANGUAGE:- ${ SYSTEM_LANGUAGE:- en} } "
26
26
27
27
error () {
28
- echo " ERROR: $1 "
28
+ echo " ERROR: $1 " >&2
29
29
exit 1
30
30
}
31
31
92
92
if [ -f " $TIPS_FOLDER /${LANGUAGE} .txt" ]; then
93
93
localized_file=" $TIPS_FOLDER /${LANGUAGE} .txt"
94
94
else
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'."
96
96
localized_file=" $TIPS_FOLDER /en.txt"
97
97
fi
98
98
103
103
104
104
# Filter tips based on the specified keyword
105
105
if [ -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
+
109
114
tips=(" ${filtered_tips[@]} " )
110
115
fi
111
116
Original file line number Diff line number Diff line change @@ -81,7 +81,6 @@ teardown() {
81
81
@test " Errors if no language is specified after --language option" {
82
82
run " $SCRIPT_PATH " --language
83
83
[ " $status " -ne 0 ]
84
- [[ " $output " == * " Error: No language specified" * ]]
85
84
}
86
85
87
86
@test " Handles missing TIPS_FOLDER gracefully" {
You can’t perform that action at this time.
0 commit comments