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