Skip to content

Commit dc921c1

Browse files
committed
Add .isatty() method to StdReader
StdWriter has .isatty(). StdReader can trivially vend the same function, and someone asked today on IRC how to call isatty() on stdin.
1 parent e546452 commit dc921c1

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)