Skip to content

Commit 25a42ea

Browse files
bertskystweil
authored andcommitted
fixed failure report for tesstrain commands:
- with `set -e` in effect, looking at stdout to detect failure is too late
1 parent 56427b8 commit 25a42ea

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

src/training/tesstrain_utils.sh

+6-13
Original file line numberDiff line numberDiff line change
@@ -69,21 +69,14 @@ err_exit() {
6969
# if the program file is not found.
7070
# Usage: run_command CMD ARG1 ARG2...
7171
run_command() {
72-
local cmd=$(which $1)
73-
if [[ -z ${cmd} ]]; then
74-
for d in api training; do
75-
cmd=$(which $d/$1)
76-
if [[ ! -z ${cmd} ]]; then
77-
break
78-
fi
79-
done
80-
if [[ -z ${cmd} ]]; then
81-
err_exit "$1 not found"
82-
fi
83-
fi
72+
local cmd
73+
cmd=$(which $1 || \
74+
for d in api training; do
75+
which $d/$1 && break
76+
done) || err_exit "'$1' not found"
8477
shift
8578
tlog "[$(date)] ${cmd} $@"
86-
if ! "${cmd}" "$@" 2>&1 1>&2 | tee -a ${LOG_FILE}; then
79+
if ! "${cmd}" "$@" |& tee -a ${LOG_FILE}; then
8780
err_exit "Program $(basename ${cmd}) failed. Abort."
8881
fi
8982
}

0 commit comments

Comments
 (0)