Fix detecting piped input#27
Open
Burrito-Bazooka wants to merge 2 commits into
Open
Conversation
Fixes case when used inside Python script which is not run from a tty, I bet there are a few other cases it fixes as well.
Author
|
Hey, are there any problems with this PR? Not that I need it quickly. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes case when used (through subprocess) inside Python script which is not run from a tty, I bet there are a few other cases it fixes as well.
edit: I actually encountered the behaviour while making a HexChat script which uses shell commands (among them, xerox). xerox behaved differently depending on whether I ran HexChat from a terminal, or from a desktop launcher. /e
edit2 (17 Jul): To be clear, the rest of this message is just to demonstrate why the current behaviour is buggy. They aren't files I want committed./e2
Files
isatty_test1.py (executable):
isatty_test2.py
isatty_test3.py (executable - same as test2 but writes to a file so that we can run it without a tty):
Tests
(on Linux, Debian testing (stretch/sid))
In a terminal
./isatty_test1.pyOutput:
In a terminal
python3 ./isatty_test2.pyOutput:
Running isatty_test3.py as an executable from my file manager to capture buggy behaviour
(note that no input was piped in, but the first output doesn't match xerox's current expectations)
Output (test3.out):
In terminal
./isatty_test1.py < test3.outOutput:
In a terminal
cat ./test3.out | ./isatty_test1.pyOutput: