From 63d6f4abc0eea08480718da47dfdf5995001b219 Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Thu, 14 Nov 2024 00:53:08 +0000 Subject: [PATCH] When invoking `cl -?`, set stdin to null This ensures the help output is never paginated. --- src/tool.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/tool.rs b/src/tool.rs index c34bc2b2..cf49b6b9 100644 --- a/src/tool.rs +++ b/src/tool.rs @@ -5,7 +5,7 @@ use std::{ ffi::{OsStr, OsString}, io::Write, path::{Path, PathBuf}, - process::Command, + process::{Command, Stdio}, sync::RwLock, }; @@ -158,14 +158,16 @@ impl Tool { cargo_output.print_debug(&stdout); // https://gitlab.kitware.com/cmake/cmake/-/blob/69a2eeb9dff5b60f2f1e5b425002a0fd45b7cadb/Modules/CMakeDetermineCompilerId.cmake#L267-271 - let accepts_cl_style_flags = run(Command::new(path).arg("-?"), path, &{ - // the errors are not errors! - let mut cargo_output = cargo_output.clone(); - cargo_output.warnings = cargo_output.debug; - cargo_output.output = OutputKind::Discard; - cargo_output - }) - .is_ok(); + // stdin is set to null to ensure that the help output is never paginated. + let accepts_cl_style_flags = + run(Command::new(path).arg("-?").stdin(Stdio::null()), path, &{ + // the errors are not errors! + let mut cargo_output = cargo_output.clone(); + cargo_output.warnings = cargo_output.debug; + cargo_output.output = OutputKind::Discard; + cargo_output + }) + .is_ok(); let clang = stdout.contains(r#""clang""#); let gcc = stdout.contains(r#""gcc""#);