Skip to content

Commit 7b0a7fd

Browse files
committed
do not spawn pager if not tty
1 parent 08b6beb commit 7b0a7fd

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

src/Cargo.lock

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/librustc_driver/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ serialize = { path = "../libserialize" }
3535
syntax = { path = "../libsyntax" }
3636
syntax_ext = { path = "../libsyntax_ext" }
3737
syntax_pos = { path = "../libsyntax_pos" }
38+
isatty = "0.1"

src/librustc_driver/lib.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ extern crate log;
5656
extern crate syntax;
5757
extern crate syntax_ext;
5858
extern crate syntax_pos;
59+
extern crate isatty;
5960

6061
use driver::CompileController;
6162
use pretty::{PpMode, UserIdentifiedItem};
@@ -100,6 +101,8 @@ use syntax::feature_gate::{GatedCfg, UnstableFeatures};
100101
use syntax::parse::{self, PResult};
101102
use syntax_pos::{DUMMY_SP, MultiSpan};
102103

104+
use isatty::stdout_isatty;
105+
103106
#[cfg(test)]
104107
pub mod test;
105108

@@ -373,7 +376,11 @@ fn handle_explain(code: &str,
373376
text.push('\n');
374377
}
375378

376-
show_content_with_pager(&text);
379+
if stdout_isatty() {
380+
show_content_with_pager(&text);
381+
} else {
382+
print!("{}", text);
383+
}
377384
}
378385
None => {
379386
early_error(output, &format!("no extended information for {}", code));

0 commit comments

Comments
 (0)