Skip to content
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

Change logic of stdin input to be last and only if required #2822

Merged
merged 4 commits into from
Jun 15, 2016

Conversation

Kubuxu
Copy link
Member

@Kubuxu Kubuxu commented Jun 7, 2016

This PR changes how stdin is used while parsing arguments. Current behaviour is that stdin is used for non-required and variadic arguments which causes confusion.

After the change the stdin is used only in case of missing required argument or if explicitly mentioned by the user with -.

Question: Should we print on stderr when ipfs command is listening for stdin to clear up possible confusing hang even more?

Aims to resolve #2748

License: MIT
Signed-off-by: Jakub Sztandera [email protected]

@Kubuxu Kubuxu force-pushed the feature/stdin-stable branch 4 times, most recently from 33f8192 to 3134bff Compare June 8, 2016 11:05
@Kubuxu Kubuxu changed the title [WIP] Change logic of stdin input to be last and only if required Change logic of stdin input to be last and only if required Jun 8, 2016
@Kubuxu Kubuxu added the need/review Needs a review label Jun 8, 2016
@whyrusleeping
Copy link
Member

@Kubuxu could you provide a couple examples of how this changes command line usage for the end user? Does it have any effect on things like echo "test" | ipfs add ?

@Kubuxu
Copy link
Member Author

Kubuxu commented Jun 13, 2016

No it doesn't for the most part.

It changes behaviour if parameter is optional user as has to explicitly specify that he wants to use stdin using - argument. So it changes usage of for example ipfs init where the file arugment is optional. To initialize repo from stdin one has to do echo '{... config ... } | ipfs init -.

As argument for add is required it will wait for input. I think we should add a message on stderr about it as currently ipfs add will display help, with this patch it will silently wait for user input.

Something along the lines of:
Reading standard input, <Ctrl-D> to finish. $CMD_PATH -h for more information.
if input is a terminal. It would greatly reduce confusion when command doesn't return.

@RichardLitt can you check wording of that?

#
# Based on the Bash documentation example.

# Hello Chet,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this?

@RichardLitt
Copy link
Member

Looks fine to me from a wording perspective. Not sure what that shell script is.

or if user asks for it

License: MIT
Signed-off-by: Jakub Sztandera <[email protected]>
License: MIT
Signed-off-by: Jakub Sztandera <[email protected]>
…fig""

This reverts commit 77ef391.

License: MIT
Signed-off-by: Jakub Sztandera <[email protected]>
This tests expects ipfs init with no arguments to work
even with occuipied stdin.
License: MIT
Signed-off-by: Jakub Sztandera <[email protected]>
@whyrusleeping
Copy link
Member

tried this out, works good on my end. makes docker a bit happier.

Thanks @Kubuxu !

@whyrusleeping whyrusleeping merged commit e5e2f2c into master Jun 15, 2016
@whyrusleeping whyrusleeping deleted the feature/stdin-stable branch June 15, 2016 18:32
@whyrusleeping whyrusleeping added this to the Ipfs 0.4.3 milestone Jun 21, 2016
# Upon time-out expiration SIGTERM (15) is sent to the process. If the signal
# is blocked, then the subsequent SIGKILL (9) terminates it.
#
# Based on the Bash documentation example.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kubuxu did you write this? if not, what is the license?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is Public Domain, I had previously credited the original author but removed it with other comments as for @RichardLitt 's request. I shouldn't have removed the author line, it was a signature for a short letter there.

Copy link
Member

@jbenet jbenet Aug 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

licensing and author lines need to be back before release.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should address the license issue: #3152

@jbenet
Copy link
Member

jbenet commented Aug 27, 2016

IIRC, this PR introduced a bunch of complexity and breaking changes. Have these been resolved? if so, where? (this may be ahead in my CR)

@jbenet
Copy link
Member

jbenet commented Aug 27, 2016

Found it #2902

@Kubuxu Kubuxu self-assigned this Aug 27, 2016
@jbenet
Copy link
Member

jbenet commented Aug 28, 2016

More here #2952

@jbenet
Copy link
Member

jbenet commented Aug 28, 2016

would be good to isolate all these commits and see a diff between v0.4.2..v0.4.3-rc3 with just all of the commits of these PRs. to ensure things got reverted appropriately

@ghost
Copy link

ghost commented Aug 28, 2016

would be good to isolate all these commits and see a diff between v0.4.2..v0.4.3-rc3 with just all of the commits of these PRs. to ensure things got reverted appropriately

I tried to somewhat group the 0.4.3-rc1 changelog entries logically, but the ones for stdin didn't turn out that well :) some entries are pretty good though and we should continue to aim for properly editorialized changelogs (i.e. logically grouped and structured)

@ghost
Copy link

ghost commented Aug 28, 2016

I tried to somewhat group the 0.4.3-rc1 changelog entries logically, but the ones for stdin didn't turn out that well :) some entries are pretty good though and we should continue to aim for properly editorialized changelogs (i.e. logically grouped and structured)

tl;dr merges don't map to changelog entries

@jbenet jbenet mentioned this pull request Aug 28, 2016
58 tasks
@Kubuxu Kubuxu removed their assignment Aug 29, 2016
@@ -0,0 +1,83 @@
#!/bin/bash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a bit concerned that this script is written in bash.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chriscool we removed this script in #3152

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I saw it afterwards. Thanks for having written something more portable!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need/review Needs a review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ipfs init fails with no stdin
5 participants