Skip to content

Commit 76a3970

Browse files
authored
When invoking cl -?, set stdin to null (#1288)
1 parent a0441c3 commit 76a3970

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/tool.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::{
55
ffi::{OsStr, OsString},
66
io::Write,
77
path::{Path, PathBuf},
8-
process::Command,
8+
process::{Command, Stdio},
99
sync::RwLock,
1010
};
1111

@@ -158,14 +158,16 @@ impl Tool {
158158
cargo_output.print_debug(&stdout);
159159

160160
// https://gitlab.kitware.com/cmake/cmake/-/blob/69a2eeb9dff5b60f2f1e5b425002a0fd45b7cadb/Modules/CMakeDetermineCompilerId.cmake#L267-271
161-
let accepts_cl_style_flags = run(Command::new(path).arg("-?"), path, &{
162-
// the errors are not errors!
163-
let mut cargo_output = cargo_output.clone();
164-
cargo_output.warnings = cargo_output.debug;
165-
cargo_output.output = OutputKind::Discard;
166-
cargo_output
167-
})
168-
.is_ok();
161+
// stdin is set to null to ensure that the help output is never paginated.
162+
let accepts_cl_style_flags =
163+
run(Command::new(path).arg("-?").stdin(Stdio::null()), path, &{
164+
// the errors are not errors!
165+
let mut cargo_output = cargo_output.clone();
166+
cargo_output.warnings = cargo_output.debug;
167+
cargo_output.output = OutputKind::Discard;
168+
cargo_output
169+
})
170+
.is_ok();
169171

170172
let clang = stdout.contains(r#""clang""#);
171173
let gcc = stdout.contains(r#""gcc""#);

0 commit comments

Comments
 (0)