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

bin/elasticsearch: add help, fix endless loop #8729

Closed
wants to merge 2 commits into from

Conversation

t-lo
Copy link

@t-lo t-lo commented Dec 1, 2014

This change adds command line help for all options to the es start script.
Both -h and --help options are accepted.

Also, an endless busy loop in the long options parser was fixed: running the script with a long opt parameter w/o value (e.g. elasticsearch --buuuurrrnn) the long option parser would end up in an endless busy loop.

Fixes #2168
Fixes #7104

Thilo Fromm added 2 commits December 1, 2014 15:19
This change adds command line help for all options to the es start script.
Both '-h' and '--help' options are accepted.

Also, an endless busy loop in the long options parser was fixed: running the
script with a long opt parameter w/o value (e.g. "elasticsearch --buuuurrrnn")
the long option parser would end up in an endless busy loop.

Signed-off-by: Thilo Fromm <github@thilo-fromm.de>
@clintongormley clintongormley added review :Delivery/Packaging RPM and deb packaging, tar and zip archives, shell and batch scripts labels Dec 1, 2014
@s1monw
Copy link
Contributor

s1monw commented Dec 1, 2014

LGTM - @spinscale can you take another look please?

@dadoonet
Copy link
Member

dadoonet commented Dec 2, 2014

I think we should have the same help option for elasticsearch.bat.

shift
continue
}
properties="$properties -Des.${1#--}=$2"
shift 2
Copy link
Contributor

Choose a reason for hiding this comment

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

cant we just call shift ; shift (which will throw an error as expected if there are no more arguments) instead of shift 2 and the whole if-statement thing?

Copy link
Author

Choose a reason for hiding this comment

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

shift; shift will silently fail (i.e. the second shift will when only one argument is present), no error will be reported. My rationale for the [ ] statement (and accompanying echo) was to mimic the error message reported by getopt (which is used to parse the short options). So you will get the same error message if you miss a mandatory value for both short and long options.

Copy link
Contributor

Choose a reason for hiding this comment

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

more userfriendly is always better. Sounds good! Thx for the explanation

@spinscale
Copy link
Contributor

left one minor question, maybe we can do it a bit more simple here?

Apart from that it looks good.

@t-lo
Copy link
Author

t-lo commented Dec 2, 2014

@dadoonet Let me take a look at this. Time to de-dust my Windows VM I guess :)

@t-lo
Copy link
Author

t-lo commented Dec 2, 2014

@dadoonet I just looked at elasticsearch.bat - afaict it doesn't take any command line arguments.

@dadoonet
Copy link
Member

dadoonet commented Dec 2, 2014

I think but might be wrong that %* means all parameters.

What happened if you run for example bin\elasticsearch -v?

@t-lo
Copy link
Author

t-lo commented Dec 2, 2014

Ah, I see, you're right, command line options are passed directly to the Java runtime. The batch file itself however does not seem to take any arguments. Afaict running elasticsearch.bat -v does nothing; there does not seem to be a Windows command line equivalent for printing the ES version (other than calling java org.elasticsearch.Version directly).

@dadoonet
Copy link
Member

dadoonet commented Dec 2, 2014

But the process exits, right?

Still, to me this is not a big concern. As long as we don't document in docs the option -h... :)
This could be part of another issue/PR if we need to have it as well in windows.

@t-lo
Copy link
Author

t-lo commented Dec 2, 2014

But the process exits, right?

It does - however, it's the Java process which does not like the command line argument, not the batch file.

There's a significant difference between the Linux and Windows start scripts. The Linux script "understands" command line arguments, parses them, and generates a different set of arguments/options for the Elasticsearch Java binary. The Windows script otoh just passes options to the Java binary w/o looking at them. Since the Windows script does not "understand" what it passes to ES it wouldn't make much sense imho to implement command line help / documentation in the batch file.

@dadoonet
Copy link
Member

dadoonet commented Dec 2, 2014

Agreed. Basically on windows, there are no command line options apart the -v.

+1 for merging it. Will do in a few minutes.

@dadoonet
Copy link
Member

dadoonet commented Dec 2, 2014

Thanks!

Merged in master with e92ff00 and in 1.x (1.5) with ba327d4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Delivery/Packaging RPM and deb packaging, tar and zip archives, shell and batch scripts >enhancement Team:Delivery Meta label for Delivery team v1.5.0 v2.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OS X: elasticsearch --argument hangs Suggestion: make man page or better CLI help
6 participants