From d57bc132ada4c8c1c0ec9b7634be8588fa2298cb Mon Sep 17 00:00:00 2001 From: vonavi Date: Thu, 8 Jan 2015 13:26:28 +0300 Subject: [PATCH] Script 'parse-games': modify the setup function. --- parse-games | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/parse-games b/parse-games index fd727f3..52a8513 100755 --- a/parse-games +++ b/parse-games @@ -8,17 +8,13 @@ REPO_DIR= TOURNAMENT= function parse_setup { - [[ -z $REPO_DIR ]] && REPO_DIR=`dirname "$0"` - # Convert REPO_DIR to an absolute path - [[ ! $REPO_DIR =~ ^/ ]] && REPO_DIR=$(cd ${REPO_DIR}; pwd) + : ${REPO_DIR:=`dirname "$0"`} # If no tournament given, set it to the last one if [[ -z $TOURNAMENT ]]; then local year_dir=$(ls -1 -d ${REPO_DIR}/[0-9][0-9][0-9][0-9]/ | tail -1) TOURNAMENT=$(ls -1 -d ${year_dir}[0-9]-*/ | tail -1 \ - | sed -E "s|${REPO_DIR}/(.*)|\1|") - # Remove the trailing slash - TOURNAMENT=${TOURNAMENT%/} + | sed -E "s|${REPO_DIR}/(.*)/|\1|") fi } @@ -57,7 +53,7 @@ ply_ini=${REPO_DIR}/${TOURNAMENT}/players.ini ply_count=$(grep "^\[player" "$ply_ini" | wc -l) tour_seq=$(ls -1 -d ${REPO_DIR}/${TOURNAMENT}/tours/[0-9][0-9]/ \ - | sed -E "s|${REPO_DIR}/${TOURNAMENT}/tours/([0-9]{2})/|\1|") + | sed -E "s|${REPO_DIR}/${TOURNAMENT}/tours/([0-9]{2})/|\1|") game_counter=1 for tour in $tour_seq; do