Skip to content

Commit 4605232

Browse files
committed
auto merge of #14315 : kballard/rust/stdreader_isatty, r=alexcrichton
StdWriter has .isatty(). StdReader can trivially vend the same function, and someone asked today on IRC how to call isatty() on stdin.
2 parents 4afc15e + dc921c1 commit 4605232

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/libstd/io/stdio.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,16 @@ pub struct StdReader {
290290
inner: StdSource
291291
}
292292

293+
impl StdReader {
294+
/// Returns whether this stream is attached to a TTY instance or not.
295+
pub fn isatty(&self) -> bool {
296+
match self.inner {
297+
TTY(..) => true,
298+
File(..) => false,
299+
}
300+
}
301+
}
302+
293303
impl Reader for StdReader {
294304
fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
295305
let ret = match self.inner {

0 commit comments

Comments
 (0)