1
Fork 0

Script 'schedule': fix regexps.

master
vonavi 2014-04-27 19:34:14 +04:00
parent 0d8249a7ae
commit bdf3444c63
1 changed files with 8 additions and 8 deletions

View File

@ -8,7 +8,7 @@ TOURNAMENT="2014/1-tabiyas"
# Version information # Version information
VERSION="0.3" VERSION="0.3"
argv0=${0##*/} argv0="${0##*/}"
usage() { usage() {
cat <<EOF cat <<EOF
@ -125,7 +125,7 @@ get_tour_num() {
} }
get_tour_dates() { get_tour_dates() {
local date_re="[0-9?]{2}\\.[0-9?]{2}\\.[0-9?]{4}" local date_re="[0-9?]{2}\.[0-9?]{2}\.[0-9?]{4}"
if [[ "$1" =~ "Время проведения:"\ *($date_re)\ *[-—]\ *($date_re) ]]; then if [[ "$1" =~ "Время проведения:"\ *($date_re)\ *[-—]\ *($date_re) ]]; then
date_beg="${BASH_REMATCH[1]}" date_end="${BASH_REMATCH[2]}" date_beg="${BASH_REMATCH[1]}" date_end="${BASH_REMATCH[2]}"
@ -138,8 +138,8 @@ get_tour_dates() {
} }
keep_game_info() { keep_game_info() {
local date_re="([0-9?]{2})\\.([0-9?]{2})\\.([0-9?]{4})" local date_re="([0-9?]{2})\.([0-9?]{2})\.([0-9?]{4})"
local res_re="(0|1|0\\.5):(0|1|0\\.5)" local res_re="(0|1|0\.5):(0|1|0\.5)"
local line="$1" keep=1 local line="$1" keep=1
if [[ "$line" =~ ($date_re)\ *[-—]\ *([^\ ]+)\ *($res_re)?\ *([^\ ]+) ]]; then if [[ "$line" =~ ($date_re)\ *[-—]\ *([^\ ]+)\ *($res_re)?\ *([^\ ]+) ]]; then
@ -187,12 +187,12 @@ info_output_term() {
# PLAYER is a part of 'game_url' or 'result' # PLAYER is a part of 'game_url' or 'result'
[[ "$name" =~ ^http:// || "$name" =~ ^(1-0|0-1|1/2)$ ]] && continue [[ "$name" =~ ^http:// || "$name" =~ ^(1-0|0-1|1/2)$ ]] && continue
line=$(sed -E "s/(${name})/\\$(tput setaf 1)\1\\$(tput sgr0)/g" <<< "$line") line=$(sed -E "s/(${name})/$(tput setaf 1)\1$(tput sgr0)/g" <<< "$line")
done done
fi fi
# Highlight result # Highlight result
line=$(sed -E "s/ (1-0|0-1|1\\/2)( |$)/ \\$(tput setaf 6)\1\\$(tput sgr0)\2/g" <<< "$line") line=$(sed -E "s/ (1-0|0-1|1\/2)( |$)/ $(tput setaf 6)\1$(tput sgr0)\2/g" <<< "$line")
echo "$line" echo "$line"
done done
@ -239,11 +239,11 @@ info_output_html() {
checkargs() { checkargs() {
if [[ "$OPTARG" =~ ^-[apflhv]$ ]]; then if [[ "$OPTARG" =~ ^-[apflhv]$ ]]; then
echo "Option -${opt}: argument not found" echo "Option -${opt}: argument not found" 1>&2
exit 1 exit 1
fi fi
if [[ "$opt" == f && ! "$OPTARG" =~ ^(term|html|lor)$ ]]; then if [[ "$opt" == f && ! "$OPTARG" =~ ^(term|html|lor)$ ]]; then
echo "Incorrect FORMAT specified" echo "Incorrect FORMAT specified" 1>&2
exit 1 exit 1
fi fi
} }