From: Joerg Woelke Date: Fri, 30 Jul 2010 15:19:53 +0000 (+0200) Subject: zshrc: Silence warning in weather() and make func more verbose. X-Git-Tag: v0.3.84~39 X-Git-Url: https://git.grml.org/?a=commitdiff_plain;h=59b681d221dfdc091d4be594dfdd1a9767606350;hp=3591a4c2133ad10b9b4a456402a9bb9e6019084b;p=grml-etc-core.git zshrc: Silence warning in weather() and make func more verbose. --- diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index 55268d0..3f7269a 100644 --- a/etc/zsh/zshrc +++ b/etc/zsh/zshrc @@ -4276,34 +4276,39 @@ weather() { return 1 } + local VERBOSE="yes" # TODO: Make this a command line switch + + local ODIR=`pwd` local PLACE="${1:u}" - local FILE="$HOME/.weather/$PLACE" - local LOG="$HOME/.weather/log" + local DIR="${HOME}/.weather" + local LOG="${DIR}/log" - [[ -d $HOME/.weather ]] || { - print -n "Creating $HOME/.weather: " - mkdir $HOME/.weather + [[ -d ${DIR} ]] || { + print -n "Creating ${DIR}: " + mkdir ${DIR} print 'done' } print "Retrieving information for ${PLACE}:" print - wget -T 10 --no-verbose --output-file=$LOG --output-document=$FILE --timestamping http://weather.noaa.gov/pub/data/observations/metar/decoded/$PLACE.TXT + cd ${DIR} && wget -T 10 --no-verbose --output-file=$LOG --timestamping http://weather.noaa.gov/pub/data/observations/metar/decoded/$PLACE.TXT if [[ $? -eq 0 ]] ; then if [[ -n "$VERBOSE" ]] ; then - cat $FILE + cat ${PLACE}.TXT else - DATE=$(grep 'UTC' $FILE | sed 's#.* /##') - TEMPERATURE=$(awk '/Temperature/ { print $4" degree Celcius / " $2" degree Fahrenheit" }' $FILE| tr -d '(') + DATE=$(grep 'UTC' ${PLACE}.TXT | sed 's#.* /##') + TEMPERATURE=$(awk '/Temperature/ { print $4" degree Celcius / " $2" degree Fahrenheit" }' ${PLACE}.TXT | tr -d '(') echo "date: $DATE" echo "temp: $TEMPERATURE" fi else print "There was an error retrieving the weather information for $PLACE" >&2 cat $LOG + cd $ODIR return 1 fi + cd $ODIR } # }}}