From 4ca33c110451cab121d8e060e85eae23e2d0f071 Mon Sep 17 00:00:00 2001
From: Katsu Kawakami <kkawa1570@gmail.com>
Date: Mon, 23 Mar 2015 22:20:20 -0400
Subject: [PATCH] Check if stdin is from a tty

---
 src/lib.rs | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/lib.rs b/src/lib.rs
index a93251b6..5a892be6 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,3 +1,16 @@
-#[test]
-fn it_works() {
+#![feature(libc)]
+extern crate libc;
+
+pub fn readline() -> Option<String> {
+    // Buffer to hold readline input
+    let buffer = String::new();
+
+    let isatty = unsafe { libc::isatty(libc::STDIN_FILENO as i32) } != 0; 
+    if isatty  {
+        println!("stdin is a tty");
+    } else {
+        println!("stdin is not a tty");
+    }
+
+    buffer
 }
-- 
GitLab