Skip to content

Commit 0318481

Browse files
committed
fixup! refactor(weather): Fix timeout, reduce calls, apply shellcheck
use tr for lowercase due to OSX bash3.2
1 parent fdbd77b commit 0318481

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

scripts/weather.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ function format_weather_info() {
5454
_show_location="$2"
5555

5656
local _weather _temp _location
57-
_weather="${_raw%%"${DELIM}"*}" # slice temp and location to get weather
58-
_temp="${_raw#*"${DELIM}"}" # slice weather to get temp and location
59-
_temp="${_temp%%"${DELIM}"*}" # slice location to get temp
60-
_temp="${_temp/+/}" # slice "+" from "+74°F"
61-
_location="${_raw##*"${DELIM}"}" # slice weather and temp to get location
62-
[ "${_location//[^,]/}" == ",," ] &&
63-
_location="${_location%,*}" # slice country if it exists
64-
65-
case "${_weather,,}" in
57+
_weather="${_raw%%"${DELIM}"*}" # slice temp and location to get weather
58+
_weather=$(printf '%s' "$_weather" | tr '[:upper:]' '[:lower:]') # lowercase weather, OSX’s bash3.2 does not support ${v,,}
59+
_temp="${_raw#*"${DELIM}"}" # slice weather to get temp and location
60+
_temp="${_temp%%"${DELIM}"*}" # slice location to get temp
61+
_temp="${_temp/+/}" # slice "+" from "+74°F"
62+
_location="${_raw##*"${DELIM}"}" # slice weather and temp to get location
63+
[ "${_location//[^,]/}" == ",," ] && _location="${_location%,*}" # slice country if it exists
64+
65+
case "$_weather" in
6666
'snow')
6767
_weather=''
6868
;;

0 commit comments

Comments
 (0)