From 59b681d221dfdc091d4be594dfdd1a9767606350 Mon Sep 17 00:00:00 2001 From: Joerg Woelke Date: Fri, 30 Jul 2010 17:19:53 +0200 Subject: [PATCH] zshrc: Silence warning in weather() and make func more verbose. --- etc/zsh/zshrc | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) 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 } # }}} -- 2.1.4