Closed cabello closed 5 years ago
Great catch. Confirmed in my machine. I can't promise taking a look at it really quickly. But I'll try it at least next week. (If you see a patch before this, please open a PR). This may have a huge impact in running scripts in pipes.
Thank you.
Perhaps related to https://github.com/piotrmurach/tty-prompt/issues/49
Checking here that input.tty?
and input.isatty
is false when pipeing and true calling the script directly.
But perhaps this check is not reliable between platforms.
No methods from HighLine::Terminal::IOConsole
works correctly (when pipeing. eg: terminal_size)
This points to us that we should identify early and use another terminal class to handle it (to be created).
Ruby stdlib io/console has advanced a little from my last touch at this code. Now we have things like getpass
(http://ruby-doc.org/stdlib-2.6/libdoc/io/console/rdoc/IO/generic_readable.html#method-i-getpass). Some things in HighLine should be directly relying on it.
Well, currently we treat input, output as being from the same "type". But when pipeing input can be a file and output a terminal.
I've just assembled a quick and dirt fix. Released https://rubygems.org/gems/highline/versions/2.0.1 @cabello could you please give me any feedback if this fix is enough for your software. I'll probably look at this later for a better solution.
The HighLine's assumption that input and output is the same type is broken.
I just confirmed this works as expected. Thanks for the quick fix.
Hi π ,
We've been using highline with much success! π Thanks for making this project open source.
I just noticed an issue present in both 1.7 and 2.0 when executing scripts not in a TTY and setting
echo
tofalse
.Script to reproduce issue
script.rb
:Command to reproduce the issue:
echo 'something' | ruby script.rb
Output in 2.x:
It breaks and there is no recovery after that. It works as expected when
echo
istrue
.Output in 1.X:
It works even though it includes warnings.
Thanks again π