read builtin detects if `stdin` is a TTY
Created by: huntergoldstein
Changes introduced by this pull request:
- Added
sys::isatty
which emulateslibc
'sisatty
-
read
builtin detects ifstdin
is a TTY: if so, it usesliner
, otherwise it reads line by line assigning each new variable to each line
Drawbacks: If we have input like:
Foo
Bar
Baz
and call
$ read foo bar < input
The last line of input will be lost. Is this desirable? Or should we make like Bash's read
which uses the last variable as the sink for remaining input. If so, we could make it an array of lines.
Fixes: Closes #474 (closed). Disclaimer: this does not resolve all issues mentioned in the issue i.e.:
echo "foo" | read bar
will do nothing as read bar
is executed in a subshell.
State: Good to go barring the issue mentioned in Drawbacks