Skip to content

Commit 588b3a9

Browse files
committed
bin/generate-samples: Fix output on tmux
Commit 23dae2b reworked this script to start capturing exceptions but the mechanism used was crude and broke output on tmux, since `/dev/pts/0` is hardcoded to a specific pseudo-terminal but each tmux pane gets its own pts. Rework this to use files instead. Signed-off-by: Stephen Finucane <stephen@that.guru>
1 parent 77fecf2 commit 588b3a9

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

bin/generate-samples.sh

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,24 +47,26 @@ For example:
4747

4848
echo "$header"
4949

50+
tmpfile=$(mktemp)
51+
trap "rm -f $tmpfile" EXIT
52+
5053
if [[ ${#files[@]} -eq 1 && "${files[0]}" != *'*'* ]]; then
51-
# shellcheck disable=SC2086
52-
# shellcheck disable=SC2068
53-
java ${JAVA_OPTS} -jar "$executable" generate -c ${files[0]} ${args[@]}
54+
# shellcheck disable=SC2086
55+
# shellcheck disable=SC2068
56+
java ${JAVA_OPTS} -jar "$executable" generate -c ${files[0]} ${args[@]} 2>&1 | tee "$tmpfile"
57+
retcode=${PIPESTATUS[0]}
5458
else
55-
if [ ${#files[@]} -eq 0 ]; then
56-
files=("${root}"/bin/configs/*.yaml)
57-
fi
59+
if [ ${#files[@]} -eq 0 ]; then
60+
files=("${root}"/bin/configs/*.yaml)
61+
fi
5862

59-
# shellcheck disable=SC2086
60-
# shellcheck disable=SC2068
61-
if java ${JAVA_OPTS} -jar "$executable" batch ${BATCH_OPTS} --includes-base-dir "${root}" --fail-fast -- ${files[@]} 2>&1 | tee /dev/pts/0 | grep -q -i "exception"; then
62-
echo "Found exception(s) when running the generator(s) to update the samples."
63-
export GENERATE_ERROR=1
64-
fi
63+
# shellcheck disable=SC2086
64+
# shellcheck disable=SC2068
65+
java ${JAVA_OPTS} -jar "$executable" batch ${BATCH_OPTS} --includes-base-dir "${root}" --fail-fast -- ${files[@]} 2>&1 | tee "$tmpfile"
66+
retcode=${PIPESTATUS[0]}
6567
fi
6668

67-
if [[ -n "$GENERATE_ERROR" ]]; then
69+
if [[ $retcode -ne 0 ]] || grep -q -i "exception" "$tmpfile"; then
6870
echo "Found exception(s) when running the generator(s) to update the samples."
6971
exit 1
7072
fi

0 commit comments

Comments
 (0)