-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
cli: Fix stdin parsing #2877
cli: Fix stdin parsing #2877
Conversation
@@ -255,15 +250,18 @@ func TestArgumentParsing(t *testing.T) { | |||
|
|||
// Use a temp file to simulate stdin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment above does not match anymore what is done below.
I don't like this solution much as we are again introducing trap of depending on type of input (named pipe in this case) to work. Are you sure that it will work the same with for example unnamed pipes or under docker? About whether you should use Other thing is I don't know any command that work like |
@Kubuxu @thomas-gardner how about instead of having the arguments be strings here, we make them some kind of interface. that way, we can push through the parsing here without having to read from stdin, and then when we actually get to the command we can read from stdin as we need it. |
As I talked with @whyrusleeping it would be very hard to parse parameters on demand as for the fact that parameters are transported over HTTP. @lgierth could you weigh in? |
the biggest issue for me right now is that |
I don't think we can successfully get away with not checking what type of thing stdin is. |
I agree with @Kubuxu on this. If we allow stdin input, it should have to be specified on the command line. I do not like the idea at all of a command behaving differently if I pipe something into it, vs if I just run it from the terminal. Sometimes I just run command that take input from stdin and just manually enter the data, useful in debugging and exploring how a command works. |
My solution for that is to make |
@Kubuxu alright, lets go ahead with that. Explicit selecting stdin in all cases. |
I now agree that this is really aberrant behaviour for a UNIX command @Kubuxu , a couple questions:
and what should happen if a $filename doesn't exist? ===STALE=== 0: FileArgs are unchanged, so slick lines like
will work as before. 1: Commands will not (should not?) run differently when strings are
2: Manual input can be requested with a hyphen,
but a pipe will take precedence:
===STALE=== |
Answers:
Non existing filename should depend on the command or wherever it is handled now. My proposition would change:
My idea is to model |
The close is unintentional. @Kubuxu, how does this look? |
@thomas-gardner as you removed the branch you will have to create new PR. It looks generally good. I would also add go test to check that there are no StringArgs with EnableStdin called to root out the noise from code. The test can be written similarly to: #2648 We will also need sharness regression tests so this behaviour (hanging on |
Also as the message is only cosmetic we can make is so it is only displayed if stdin is character input device. Thank you for work you are putting into it. |
@Kubuxu requested to nuke
EnableStdin
onStringArg
, but I reckon it's (slightly) better to just fix the parsing & avoid having to wonder, is this a valid pipeline or do I need to use xargs?EDIT(Kubuxu, for tracking): Resolves #2877, Resolves #2870