Add exit code and some slight changes.

This commit is contained in:
vonavi 2013-09-25 23:11:13 +03:00
parent 1b2cb0e255
commit 9d20d77cf5

View File

@ -4,7 +4,7 @@ repo=fat0troll/lorchess
tournament=autumn2013 tournament=autumn2013
# Variables # Variables
digit='[[:digit:]]' digit='[[:digit:]]\+'
# Colors # Colors
cyan='\\033[01;36m' cyan='\\033[01;36m'
@ -19,7 +19,7 @@ args=$(getopt --options p: --longoptions player: -- "$@")
# Note the quotes around `$ARGS': they are essential! # Note the quotes around `$ARGS': they are essential!
eval set -- "$args" eval set -- "$args"
if [[ $1 == -p || $1 == --player ]];then if [[ $1 == -p || $1 == --player ]]; then
name=$2 name=$2
shift 2 shift 2
fi fi
@ -33,14 +33,16 @@ for tour in $@; do
url=https://raw.github.com/$repo/master/$tournament/tour_$tour/tour_info url=https://raw.github.com/$repo/master/$tournament/tour_$tour/tour_info
echo ">>>" echo ">>>"
curl -q --silent $url | while read line;do curl -q --silent $url | while read line; do
if [[ -z $line ]];then if [[ -z $line ]]; then
echo echo
elif [[ -z $name || `echo "$line" | egrep "Тур|=|Время|$name"` ]];then elif [[ -z $name || $(egrep "Тур|=|Время|$name" <<< "$line") ]]; then
# Colorize output # Colorize output
line=$(echo "$line" | sed "s/${digit}/${cyan}\0${restore}/g") line=$(sed "s/${digit}/${cyan}\0${restore}/g" <<< "$line")
[[ -n $name ]] && line=$(echo "$line" | sed "s/${name}/${red}\0${restore}/g") [[ -n $name ]] && line=$(sed "s/${name}/${red}\0${restore}/g" <<< "$line")
echo -e $line echo -e $line
fi fi
done done
done done
exit 0