-
Notifications
You must be signed in to change notification settings - Fork 358
Survey breaks when stdin is piped (eg unix pipe) #328
Comments
When input is a pipe, Or are you using a pipe for testing your program that uses survey? Currently, reading from a pipe you are also likely to hit #282 — terminal state is not cleaned up. |
Piping stdin & stdout are two separate things, with different use cases: Our program can benefit from being the last element in a pipeline, while primarily used interactively. The prompts also look nice, no matter if they are interactive.
That's what we currently do, until this is resolved. But there is no reason for |
I was trying to use a CLI with heredoc that errored and landed here debugging that. The library used is this 'survey' that does not take bash style heredoc for inputs. |
Currently survey does not support reading from piped stdin.
The issue lies in several layers:
with piped stdin,
Cursor.Location()
(called by all prompts implicitly) fails withio.EOF
:survey/terminal/cursor.go
Lines 106 to 109 in f45c05b
Subsequently, no input is read, and control commands printed instead of being applied.
RuneReader
does not treatio.EOF
as end of input, but aborts and returns it as error, which is unnecessary (e.g.MultiLine
input waiting for 3 newlines until it continues)I'm not exactly sure how a piped stdin differs from a terminal stdin, so I don't know how to fix this.
One step surely would be to change
Cursor
, so that it detects piped stdin, and switches to a NO-OP mode?The text was updated successfully, but these errors were encountered: