Merge pull request #576 from stweil/shellcheck

Fix some issues reported by shellcheck (SC2004, SC2006)
This commit is contained in:
zdenop 2016-12-15 08:30:30 +01:00 committed by GitHub
commit a0201831c3
5 changed files with 43 additions and 43 deletions

View File

@ -35,14 +35,14 @@ dist-hook:
# Need to remove .svn directories from directories # Need to remove .svn directories from directories
# added using EXTRA_DIST. $(distdir)/tessdata would in # added using EXTRA_DIST. $(distdir)/tessdata would in
# theory suffice. # theory suffice.
rm -rf `find $(distdir) -name .svn` rm -rf $(find $(distdir) -name .svn)
rm -rf `find $(distdir) -name .git` rm -rf $(find $(distdir) -name .git)
rm -rf `find $(distdir) -name .deps` rm -rf $(find $(distdir) -name .deps)
rm -rf `find $(distdir) -name .libs` rm -rf $(find $(distdir) -name .libs)
rm -rf `find $(distdir) -name *.o` rm -rf $(find $(distdir) -name *.o)
rm -rf `find $(distdir) -name *.lo` rm -rf $(find $(distdir) -name *.lo)
rm -rf `find $(distdir) -name *.la` rm -rf $(find $(distdir) -name *.la)
rm -rf `find $(distdir)/training -executable -type f` rm -rf $(find $(distdir)/training -executable -type f)
rm -rf $(distdir)/doc/html/* rm -rf $(distdir)/doc/html/*
ScrollView.jar: ScrollView.jar:

View File

@ -36,11 +36,11 @@ do
mkdir -p $new mkdir -p $new
echo "Set $old -> $new" echo "Set $old -> $new"
#The pages file had - instead of _ so fix it and add the extension. #The pages file had - instead of _ so fix it and add the extension.
for page in `cat $old/PAGES` for page in $(cat $old/PAGES)
do do
echo "${page%-*}_${page#*-}.$ext" echo "${page%-*}_${page#*-}.$ext"
done >$new/pages done >$new/pages
for f in `cat $new/pages` for f in $(cat $new/pages)
do do
#Put a tif extension on the tif files. #Put a tif extension on the tif files.
cp $old/${old}_B/$f $new/$f.tif cp $old/${old}_B/$f $new/$f.tif

View File

@ -81,30 +81,30 @@ do
# Count the errors on all the pages. # Count the errors on all the pages.
$bindir/counttestset.sh $imdir/$set/pages $bindir/counttestset.sh $imdir/$set/pages
# Get the old character word and nonstop word errors. # Get the old character word and nonstop word errors.
olderrs=`cat testing/reports/1995.$set.sum | cut -f3` olderrs=$(cat testing/reports/1995.$set.sum | cut -f3)
oldwerrs=`cat testing/reports/1995.$set.sum | cut -f6` oldwerrs=$(cat testing/reports/1995.$set.sum | cut -f6)
oldnswerrs=`cat testing/reports/1995.$set.sum | cut -f9` oldnswerrs=$(cat testing/reports/1995.$set.sum | cut -f9)
# Get the new character word and nonstop word errors and accuracy. # Get the new character word and nonstop word errors and accuracy.
cherrs=`head -4 testing/reports/$set.characc |tail -1 |cut -c1-9 | cherrs=$(head -4 testing/reports/$set.characc |tail -1 |cut -c1-9 |
tr -d '[:blank:]'` tr -d '[:blank:]')
chacc=`head -5 testing/reports/$set.characc |tail -1 |cut -c1-9 | chacc=$(head -5 testing/reports/$set.characc |tail -1 |cut -c1-9 |
tr -d '[:blank:]'` tr -d '[:blank:]')
wderrs=`head -4 testing/reports/$set.wordacc |tail -1 |cut -c1-9 | wderrs=$(head -4 testing/reports/$set.wordacc |tail -1 |cut -c1-9 |
tr -d '[:blank:]'` tr -d '[:blank:]')
wdacc=`head -5 testing/reports/$set.wordacc |tail -1 |cut -c1-9 | wdacc=$(head -5 testing/reports/$set.wordacc |tail -1 |cut -c1-9 |
tr -d '[:blank:]'` tr -d '[:blank:]')
nswderrs=`grep Total testing/reports/$set.wordacc |head -2 |tail -1 | nswderrs=$(grep Total testing/reports/$set.wordacc |head -2 |tail -1 |
cut -c10-17 |tr -d '[:blank:]'` cut -c10-17 |tr -d '[:blank:]')
nswdacc=`grep Total testing/reports/$set.wordacc |head -2 |tail -1 | nswdacc=$(grep Total testing/reports/$set.wordacc |head -2 |tail -1 |
cut -c19-26 |tr -d '[:blank:]'` cut -c19-26 |tr -d '[:blank:]')
# Compute the percent change. # Compute the percent change.
chdelta=`deltapc $cherrs $olderrs` chdelta=$(deltapc $cherrs $olderrs)
wdelta=`deltapc $wderrs $oldwerrs` wdelta=$(deltapc $wderrs $oldwerrs)
nswdelta=`deltapc $nswderrs $oldnswerrs` nswdelta=$(deltapc $nswderrs $oldnswerrs)
sumfile=$rdir/$vid.$set.sum sumfile=$rdir/$vid.$set.sum
if [ -r testing/reports/$set.times ] if [ -r testing/reports/$set.times ]
then then
total_time=`timesum testing/reports/$set.times` total_time=$(timesum testing/reports/$set.times)
if [ -r testing/reports/prev/$set.times ] if [ -r testing/reports/prev/$set.times ]
then then
paste testing/reports/prev/$set.times testing/reports/$set.times | paste testing/reports/prev/$set.times testing/reports/$set.times |
@ -125,9 +125,9 @@ do
fi fi
done done
# Compute grand total percent change. # Compute grand total percent change.
chdelta=`deltapc $totalerrs $totalolderrs` chdelta=$(deltapc $totalerrs $totalolderrs)
wdelta=`deltapc $totalwerrs $totaloldwerrs` wdelta=$(deltapc $totalwerrs $totaloldwerrs)
nswdelta=`deltapc $totalnswerrs $totaloldnswerrs ` nswdelta=$(deltapc $totalnswerrs $totaloldnswerrs)
tfile=$rdir/$vid.total.sum tfile=$rdir/$vid.total.sum
echo "$vid Total $totalerrs - $chdelta% $totalwerrs\ echo "$vid Total $totalerrs - $chdelta% $totalwerrs\
- $wdelta% $totalnswerrs - $nswdelta%" >$tfile - $wdelta% $totalnswerrs - $nswdelta%" >$tfile

View File

@ -45,7 +45,7 @@
# appropriate --fonts_dir path. # appropriate --fonts_dir path.
source `dirname $0`/tesstrain_utils.sh source "$(dirname $0)/tesstrain_utils.sh"
ARGV=("$@") ARGV=("$@")
parse_flags parse_flags
@ -53,7 +53,7 @@ parse_flags
mkdir -p ${TRAINING_DIR} mkdir -p ${TRAINING_DIR}
tlog "\n=== Starting training for language '${LANG_CODE}'" tlog "\n=== Starting training for language '${LANG_CODE}'"
source `dirname $0`/language-specific.sh source "$(dirname $0)/language-specific.sh"
set_lang_specific_parameters ${LANG_CODE} set_lang_specific_parameters ${LANG_CODE}
initialize_fontconfig initialize_fontconfig
@ -61,7 +61,7 @@ initialize_fontconfig
phase_I_generate_image 8 phase_I_generate_image 8
phase_UP_generate_unicharset phase_UP_generate_unicharset
phase_D_generate_dawg phase_D_generate_dawg
if (( ${LINEDATA} )); then if ((LINEDATA)); then
phase_E_extract_features "lstm.train" 8 "lstmf" phase_E_extract_features "lstm.train" 8 "lstmf"
make__lstmdata make__lstmdata
else else

View File

@ -26,7 +26,7 @@ OVERWRITE=0
LINEDATA=0 LINEDATA=0
RUN_SHAPE_CLUSTERING=0 RUN_SHAPE_CLUSTERING=0
EXTRACT_FONT_PROPERTIES=1 EXTRACT_FONT_PROPERTIES=1
WORKSPACE_DIR=`mktemp -d` WORKSPACE_DIR=$(mktemp -d)
# Logging helper functions. # Logging helper functions.
tlog() { tlog() {
@ -42,7 +42,7 @@ err_exit() {
# if the program file is not found. # if the program file is not found.
# Usage: run_command CMD ARG1 ARG2... # Usage: run_command CMD ARG1 ARG2...
run_command() { run_command() {
local cmd=`which $1` local cmd=$(which $1)
if [[ -z ${cmd} ]]; then if [[ -z ${cmd} ]]; then
err_exit "$1 not found" err_exit "$1 not found"
fi fi
@ -95,7 +95,7 @@ parse_flags() {
FONTS="" FONTS=""
while test $j -lt ${#ARGV[@]}; do while test $j -lt ${#ARGV[@]}; do
test -z "${ARGV[$j]}" && break test -z "${ARGV[$j]}" && break
test `echo ${ARGV[$j]} | cut -c -2` = "--" && break test $(echo ${ARGV[$j]} | cut -c -2) = "--" && break
FONTS[$fn]="${ARGV[$j]}" FONTS[$fn]="${ARGV[$j]}"
fn=$((fn+1)) fn=$((fn+1))
j=$((j+1)) j=$((j+1))
@ -105,7 +105,7 @@ parse_flags() {
exp="" exp=""
while test $j -lt ${#ARGV[@]}; do while test $j -lt ${#ARGV[@]}; do
test -z "${ARGV[$j]}" && break test -z "${ARGV[$j]}" && break
test `echo ${ARGV[$j]} | cut -c -2` = "--" && break test $(echo ${ARGV[$j]} | cut -c -2) = "--" && break
exp="$exp ${ARGV[$j]}" exp="$exp ${ARGV[$j]}"
j=$((j+1)) j=$((j+1))
done done
@ -219,7 +219,7 @@ generate_font_image() {
--text=${TRAINING_TEXT} ${TEXT2IMAGE_EXTRA_ARGS} --text=${TRAINING_TEXT} ${TEXT2IMAGE_EXTRA_ARGS}
check_file_readable ${outbase}.box ${outbase}.tif check_file_readable ${outbase}.box ${outbase}.tif
if (( ${EXTRACT_FONT_PROPERTIES} )) && if ((EXTRACT_FONT_PROPERTIES)) &&
[[ -r ${TRAIN_NGRAMS_FILE} ]]; then [[ -r ${TRAIN_NGRAMS_FILE} ]]; then
tlog "Extracting font properties of ${font}" tlog "Extracting font properties of ${font}"
run_command text2image ${common_args} --font="${font}" \ run_command text2image ${common_args} --font="${font}" \
@ -243,7 +243,7 @@ phase_I_generate_image() {
CHAR_SPACING="0.0" CHAR_SPACING="0.0"
for EXPOSURE in $EXPOSURES; do for EXPOSURE in $EXPOSURES; do
if (( ${EXTRACT_FONT_PROPERTIES} )) && [[ -r ${BIGRAM_FREQS_FILE} ]]; then if ((EXTRACT_FONT_PROPERTIES)) && [[ -r ${BIGRAM_FREQS_FILE} ]]; then
# Parse .bigram_freqs file and compose a .train_ngrams file with text # Parse .bigram_freqs file and compose a .train_ngrams file with text
# for tesseract to recognize during training. Take only the ngrams whose # for tesseract to recognize during training. Take only the ngrams whose
# combined weight accounts for 95% of all the bigrams in the language. # combined weight accounts for 95% of all the bigrams in the language.
@ -424,7 +424,7 @@ phase_C_cluster_prototypes() {
# Phase S : (S)hape clustering # Phase S : (S)hape clustering
phase_S_cluster_shapes() { phase_S_cluster_shapes() {
if (( ! ${RUN_SHAPE_CLUSTERING} )); then if ((! RUN_SHAPE_CLUSTERING)); then
tlog "\n=== Shape Clustering disabled ===" tlog "\n=== Shape Clustering disabled ==="
return return
fi fi
@ -557,7 +557,7 @@ make__traineddata() {
mkdir -p ${OUTPUT_DIR} mkdir -p ${OUTPUT_DIR}
fi fi
local destfile=${OUTPUT_DIR}/${LANG_CODE}.traineddata; local destfile=${OUTPUT_DIR}/${LANG_CODE}.traineddata;
if [[ -f ${destfile} ]] && (( ! ${OVERWRITE} )); then if [[ -f ${destfile} ]] && ((! OVERWRITE)); then
err_exit "File ${destfile} exists and no --overwrite specified"; err_exit "File ${destfile} exists and no --overwrite specified";
fi fi
tlog "Moving ${TRAINING_DIR}/${LANG_CODE}.traineddata to ${OUTPUT_DIR}" tlog "Moving ${TRAINING_DIR}/${LANG_CODE}.traineddata to ${OUTPUT_DIR}"