-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support usage in scenarios where stdin
/ stdout
are pipes (but stderr
is a TTY)
#129
Comments
Usually when stdout is redirected, the user does not want a command prompt on stderr. I'm not likely to make that the default behaviour. |
Take for example the following simple use-case where
At the moment, the user stares at a blank screen, because Similar examples could be:
At the moment Now regarding my proposal of always using |
Sorry, you can't use There may be a way to attach input to the current TTY (looked up from stderr) instead of using stdin, but that's outside of the scope of liner (which is trying to be both as simple and as cross-platform as possible) |
...I thought I left the following comment earlier, but I must have forgotten to press the Comment button: In addition to the above, your suggested change breaks anyone who has a workflow of "./my-liner-tool < command_list > output". Even if I wanted to make this change, I cannot change behaviour that wildly without also changing the package name (or major version number, same thing). |
Yes you can. I have already done this for my usage of https://github.com/cipriancraciun/z-run/blob/master/sources/lib/input.go#L52-L58 The basic idea is this: if the process is attached to a TTY then, unless the process is part of a pipeline, all For example running
Yes, that can be achieved by opening
I agree that backward compatibility should be kept. Thus perhaps a new constructor could be added that takes the input / output streams to be used. (And perhaps a wrapper that supplies |
This seems like a reasonable suggestion. |
Usually in almost all circumstances
/dev/sdterr
is a TTY; meanwhile/dev/stdin
and/or/dev/stdout
can be redirected to files or pipes. (In fact if/dev/stderr
is not a TTY, most likely the other two are inherited or poorly set-up, and this process isn't meant to handle the terminal.)At the moment
liner
checks if any ofstdin
orstdout
are redirected, and if so degrades to a "dumb" terminal:liner/input.go
Lines 38 to 49 in abb5e9d
My proposal (which I could implement if accepted) is to either:
/dev/stderr
for both input and output and check that itself is a TTY;stdin
orstdout
seems to be redirected, check if perhapsstderr
is a TTY and use that;I currently use
liner
in such a scenario, and for the moment I replacesyscall.Stdin
/syscall.Stdout
withsyscall.Stderr
and it seems to do the trick. However this hack works in my limited case, but as said I'm willing to code this proposed feature.The text was updated successfully, but these errors were encountered: