Script 'parse-games': modify the setup function.

This commit is contained in:
vonavi 2015-01-08 13:26:28 +03:00
parent e9bafd8838
commit d57bc132ad

View File

@ -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
}