From cc045ab53c19b2b056faa33e2f977cdcfffe6d20 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Thu, 22 Jan 2026 19:01:42 +0800 Subject: [PATCH] Fix output of bin/generate-samples.sh in tmux (#22772) * bin/generate-samples: Remove warning about sleep The sleep itself has been commented out for a long time (commit 04fa53b69266 from September 2023, to be specific). Signed-off-by: Stephen Finucane * bin/generate-samples: Fix output on tmux Commit 23dae2bcd8c9 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 * update error message, trigger build failur * trigger build failure * Revert "trigger build failure" This reverts commit 29536fab8a1f1980f393b36421341492079764a0. * add back null check --------- Signed-off-by: Stephen Finucane Co-authored-by: Stephen Finucane --- bin/generate-samples.sh | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/bin/generate-samples.sh b/bin/generate-samples.sh index 197eb918391..f2bcd570cb6 100755 --- a/bin/generate-samples.sh +++ b/bin/generate-samples.sh @@ -47,26 +47,26 @@ For example: echo "$header" -if [[ ${#files[@]} -eq 1 && "${files[0]}" != *'*'* ]]; then - # shellcheck disable=SC2086 - # shellcheck disable=SC2068 - java ${JAVA_OPTS} -jar "$executable" generate -c ${files[0]} ${args[@]} -else - echo "Please press CTRL+C to stop or the script will continue in 5 seconds." - #sleep 5 - if [ ${#files[@]} -eq 0 ]; then - files=("${root}"/bin/configs/*.yaml) - fi +tmpfile=$(mktemp) +trap "rm -f $tmpfile" EXIT - # shellcheck disable=SC2086 - # shellcheck disable=SC2068 - 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 - echo "Found exception(s) when running the generator(s) to update the samples." - export GENERATE_ERROR=1 - fi +if [[ ${#files[@]} -eq 1 && "${files[0]}" != *'*'* ]]; then + # shellcheck disable=SC2086 + # shellcheck disable=SC2068 + java ${JAVA_OPTS} -jar "$executable" generate -c ${files[0]} ${args[@]} 2>&1 | tee "$tmpfile" + retcode=${PIPESTATUS[0]} +else + if [ ${#files[@]} -eq 0 ]; then + files=("${root}"/bin/configs/*.yaml) + fi + + # shellcheck disable=SC2086 + # shellcheck disable=SC2068 + java ${JAVA_OPTS} -jar "$executable" batch ${BATCH_OPTS} --includes-base-dir "${root}" --fail-fast -- ${files[@]} 2>&1 | tee "$tmpfile" + retcode=${PIPESTATUS[0]} fi -if [[ -n "$GENERATE_ERROR" ]]; then +if [[ $retcode -ne 0 ]] || grep -q -i "at org.openapitools" "$tmpfile"; then echo "Found exception(s) when running the generator(s) to update the samples." exit 1 fi