Merge pull request #148 from nickjwhite/tesstrainbetterargs

Use shell quoting rather than pluses to separate font arguments in tesstrain.sh
This commit is contained in:
zdenop 2015-11-27 21:56:40 +01:00
commit d025616af5
2 changed files with 13 additions and 11 deletions

View File

@ -17,7 +17,7 @@
# USAGE:
#
# tesstrain.sh
# --fontlist FONTS_STR # A plus-separated list of fontnames to train on.
# --fontlist FONTS # A list of fontnames to train on.
# --fonts_dir FONTS_PATH # Path to font files.
# --lang LANG_CODE # ISO 639 code.
# --langdata_dir DATADIR # Path to tesseract/training/langdata directory.

View File

@ -89,19 +89,21 @@ parse_flags() {
case ${ARGV[$i]} in
--)
break;;
--fontlist) # Expect a plus-separated list of names
if [[ -z ${ARGV[$j]} ]] || [[ ${ARGV[$j]:0:2} == "--" ]]; then
err_exit "Invalid value passed to --fontlist"
fi
local ofs=$IFS
IFS='+'
FONTS=( ${ARGV[$j]} )
IFS=$ofs
i=$j ;;
--fontlist)
fn=0
FONTS=""
while test $j -lt ${#ARGV[@]}; do
test -z "${ARGV[$j]}" && break
test `echo ${ARGV[$j]} | cut -c -2` = "--" && break
FONTS[$fn]="${ARGV[$j]}"
fn=$((fn+1))
j=$((j+1))
done
i=$((j-1)) ;;
--exposures)
exp=""
while test $j -lt ${#ARGV[@]}; do
test -z ${ARGV[$j]} && break
test -z "${ARGV[$j]}" && break
test `echo ${ARGV[$j]} | cut -c -2` = "--" && break
exp="$exp ${ARGV[$j]}"
j=$((j+1))