From 98c6210d06155a6d69213b0de2ad2028120dc4ac Mon Sep 17 00:00:00 2001 From: Alex Epstein Date: Sat, 25 Nov 2017 12:29:31 -0500 Subject: [PATCH] Fixing weather grabbing initials for states with two words --- weather/weather | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/weather/weather b/weather/weather index b961f6c..1f58bdc 100755 --- a/weather/weather +++ b/weather/weather @@ -40,7 +40,11 @@ getIPWeather() if [[ $country == "US" ]]; then ## if were in the us id rather not use longitude and latitude so the output is nicer city=$(httpGet ipinfo.io/city) > /dev/null region=$(httpGet ipinfo.io/region) > /dev/null - region=$(echo "$region" | cut -c "1-2" | tr "[:lower:]" "[:upper:]") + if [[ $(echo $region | wc -w) == 2 ]];then + region=$(echo $region | grep -Eo "[A-Z]*" | tr -d "[:space:]") + else + region=$(echo "$region" | cut -c "1-2" | tr "[:lower:]" "[:upper:]") + fi httpGet $locale.wttr.in/$city,$region$1 else ## otherwise we are going to use longitude and latitude location=$(httpGet ipinfo.io/loc) > /dev/null