Allow `read` builtin to take input from non-tty `stdin`
Created by: huntergoldstein
Reproduction: Attempt to have read
take input from anything except a terminal, for example:
$ echo foo | read bar
Expected behavior:
$ echo foo | read bar
$ echo $bar
foo
Actual behavior:
$ echo foo | read bar
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { repr: Custom(Custom { kind: Other, error: StringError("Unable to get Termios attribute.") }) }', /checkout/src/libcore/result.rs:860:4
$ echo $bar
<no output>
Build information:
-
git rev-parse HEAD
: 2c62ffb8
The solution to this is to have the read
builtin determine if its stdin
is a tty or not; if so, it will use the nice liner
prompt, otherwise it will read the next line from stdin
.