Skip to content

Commit

Permalink
fixed failure report for tesstrain commands:
Browse files Browse the repository at this point in the history
- with `set -e` in effect, looking at stdout
  to detect failure is too late
  • Loading branch information
bertsky authored and stweil committed Apr 6, 2019
1 parent 56427b8 commit 25a42ea
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions src/training/tesstrain_utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,14 @@ err_exit() {
# if the program file is not found.
# Usage: run_command CMD ARG1 ARG2...
run_command() {
local cmd=$(which $1)
if [[ -z ${cmd} ]]; then
for d in api training; do
cmd=$(which $d/$1)
if [[ ! -z ${cmd} ]]; then
break
fi
done
if [[ -z ${cmd} ]]; then
err_exit "$1 not found"
fi
fi
local cmd
cmd=$(which $1 || \
for d in api training; do
which $d/$1 && break
done) || err_exit "'$1' not found"
shift
tlog "[$(date)] ${cmd} $@"
if ! "${cmd}" "$@" 2>&1 1>&2 | tee -a ${LOG_FILE}; then
if ! "${cmd}" "$@" |& tee -a ${LOG_FILE}; then
err_exit "Program $(basename ${cmd}) failed. Abort."
fi
}
Expand Down

0 comments on commit 25a42ea

Please sign in to comment.