Fix potential errors in scripts

This commit is contained in:
Abhishek Keshri 2022-08-13 17:11:48 +05:30
parent 8c7f582b53
commit c1493ce604
No known key found for this signature in database
GPG key ID: 87ABE188E6B98D1C
7 changed files with 31 additions and 31 deletions

View file

@ -36,16 +36,16 @@ display_weather()
fi
weather_information=$(fetch_weather_information $display_weather)
weather_condition=$(echo $weather_information | rev | cut -d ' ' -f2- | rev) # Sunny, Snow, etc
temperature=$(echo $weather_information | rev | cut -d ' ' -f 1 | rev) # +31°C, -3°F, etc
unicode=$(forecast_unicode $weather_condition)
weather_condition=$(echo "$weather_information" | rev | cut -d ' ' -f2- | rev) # Sunny, Snow, etc
temperature=$(echo "$weather_information" | rev | cut -d ' ' -f 1 | rev) # +31°C, -3°F, etc
unicode=$(forecast_unicode "$weather_condition")
echo "$unicode${temperature/+/}" # remove the plus sign to the temperature
}
forecast_unicode()
{
weather_condition=$(echo $weather_condition | awk '{print tolower($0)}')
weather_condition=$(echo "$weather_condition" | awk '{print tolower($0)}')
if [[ $weather_condition =~ 'snow' ]]; then
echo '❄ '