From 76a397013c04738f239474d3b989db903ab486ff Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Thu, 14 Nov 2024 09:19:13 +0100 Subject: [PATCH] When invoking `cl -?`, set stdin to null (#1288) --- 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""#);