diff --git a/tools/bazel b/tools/bazel index 77d675f8e02..44bafbfb056 100755 --- a/tools/bazel +++ b/tools/bazel @@ -147,8 +147,14 @@ if [ "$skip_python" == "1" ]; then exec "$bazel_real" "$@" fi +wrapper_output_all=0 +if [[ -n "${MONGO_WRAPPER_OUTPUT_ALL}" ]] || [[ -n "${CI}" ]]; then + wrapper_output_all=1 +fi -if [[ "$SLOW_PATH" == "1" ]] && [[ -z "${MONGO_WRAPPER_OUTPUT_ALL}" ]]; then +wrapper_redirect_output=0 +if [[ "$SLOW_PATH" == "1" ]] && [[ "$wrapper_output_all" == "0" ]]; then + wrapper_redirect_output=1 ORIGINAL_ARGS=("$@") # Save original terminal output FDs @@ -293,11 +299,15 @@ fi if [[ $autocomplete_query == 1 ]]; then plus_targets=$(&3 + if [[ "$wrapper_redirect_output" == "1" ]]; then + echo $query_output $plus_targets | tr " " "\n" >&3 + else + echo $query_output $plus_targets | tr " " "\n" + fi else trap 'cleanup_logfile' EXIT # Slow path: restore stdout/stderr so Bazel prints normally - if [[ -z "${MONGO_WRAPPER_OUTPUT_ALL}" ]]; then + if [[ "$wrapper_redirect_output" == "1" ]]; then exec 1>&3 2>&4 fi diff --git a/tools/bazel.bat b/tools/bazel.bat index d54c7dcd2e3..24a4fe67383 100644 --- a/tools/bazel.bat +++ b/tools/bazel.bat @@ -86,8 +86,16 @@ rem Set up environment variables for terminal output (for engflow_check.py) rem On Windows, we use CON device for console output rem Note: Windows doesn't support file descriptor duplication like Unix, rem so we'll set these to indicate console output should go to CON -set "MONGO_WRAPPER_STDOUT_FD=CON" -set "MONGO_WRAPPER_STDERR_FD=CON" +if not "%MONGO_WRAPPER_OUTPUT_ALL%"=="" ( + set "MONGO_WRAPPER_STDOUT_FD=" + set "MONGO_WRAPPER_STDERR_FD=" +) else if not "%CI%"=="" ( + set "MONGO_WRAPPER_STDOUT_FD=" + set "MONGO_WRAPPER_STDERR_FD=" +) else ( + set "MONGO_WRAPPER_STDOUT_FD=CON" + set "MONGO_WRAPPER_STDERR_FD=CON" +) rem === Start timing === set STARTTIME=%TIME%