ansiweather

Weather in terminal, with ANSI colors and Unicode symbols
Log | Files | Refs | README | LICENSE

commit c6fc7700bebd2b9eb46a477ef7317ad0a3933d7e
parent 1bf0200d33d84187b22efcd9aafea09075452e8d
Author: Andrei Neculau <andrei.neculau@gmail.com>
Date:   Sat, 23 Nov 2013 12:27:14 +0100

Change detection of BSD vs GNU date

Previous detection was checking for uname Linux/Debian,
but Debian can run in a GNU environment as well.

Ref: http://stackoverflow.com/questions/8747845/how-can-i-detect-bsd-vs-gnu-version-of-date-in-shell-script

Diffstat:
Mansiweather | 8+++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/ansiweather b/ansiweather @@ -144,10 +144,12 @@ weather=$($fetch_cmd "http://api.openweathermap.org/data/2.5/$api_cmd?q=$locatio function epoch_to_date { unamestr=$(uname) - if [[ "$unamestr" == 'Linux' ]]; then - ret=$(date -d @$1 +"%a %b %d") - else + if date -j -r $1 +"%a %b %d" > /dev/null 2>&1; then + # BSD ret=$(date -j -r $1 +"%a %b %d") + else + # GNU + ret=$(date -d @$1 +"%a %b %d") fi echo $ret }