Merge pull request #15 from gwenn/piped
Fix when stdin is not interactive (file or pipe)
diff --git a/README.md b/README.md
index 0d52724..871fe2d 100644
--- a/README.md
+++ b/README.md
@@ -62,7 +62,7 @@
- Unicode (UTF-8) (linenoise supports only ASCII)
- Word completion (linenoise supports only line completion)
- Filename completion
- - History search ([Searching for Commands in the History]http://cnswww.cns.cwru.edu/php/chet/readline/readline.html#SEC8)
+ - History search ([Searching for Commands in the History](http://cnswww.cns.cwru.edu/php/chet/readline/readline.html#SEC8)
## ToDo
diff --git a/src/lib.rs b/src/lib.rs
index bed8121..f021bfa 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -715,8 +715,11 @@
fn readline_direct() -> Result<String> {
let mut line = String::new();
- try!(io::stdin().read_line(&mut line));
- Ok(line)
+ if try!(io::stdin().read_line(&mut line)) > 0 {
+ Ok(line)
+ } else {
+ Err(error::ReadlineError::Eof)
+ }
}
/// Line editor
@@ -782,6 +785,15 @@
}
}
+impl<'completer> fmt::Debug for Editor<'completer> {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ f.debug_struct("State")
+ .field("unsupported_term", &self.unsupported_term)
+ .field("stdin_isatty", &self.stdin_isatty)
+ .finish()
+ }
+}
+
#[cfg(test)]
mod test {
use std::io::Write;