risor-io / risor

Fast and flexible scripting for Go developers and DevOps.
https://risor.io
Apache License 2.0
611 stars 26 forks source link

REPL should error if no tty #134

Closed applejag closed 9 months ago

applejag commented 9 months ago

Example:

risor > file.txt

This blocks until I press Ctrl+D. The content of file.txt is then also this:

Risor

>>> ^M>>> o^M>>> oh^M>>> oh ^M>>> oh n^M>>> oh no^M>>> oh no ^M>>> oh no i^M>>> oh no im^M>>> oh no im ^M>>> oh no im s^M>>> oh no im st^M>>> oh no im stu^M>>> oh no im stuc^M>>> oh no im stuck

(the ^M is actually the CR escape code in my terminal, shown as I copied the result from cat file.txt instead of the file's raw content)

The case where this trips me up is when I want to run something via risor, but forget the file as argument, pipe the result into something else, but then its just stuck.

Suggest an error like:

$ risor > file.txt
cannot show repl: stdout or stderr is not a tty