-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-26543 correct parsing of shell args with GetoptLong #4000
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
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
🎊 +1 overall
This message was automatically generated. |
) | ||
opts.ordering = GetoptLong::REQUIRE_ORDER |
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.
Is this going to break back compat somewhere?
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.
no, this ordering option should bring us closer to before HBASE-24772 was introduced. I reasonably believe it is compatible with our parsing prior to that change.
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.
for those interested in more details here are the docs for Ruby GetoptLong's ordering:
https://ruby-doc.org/stdlib-3.0.3/libdoc/getoptlong/rdoc/GetoptLong.html#method-i-ordering-3D
specifically, this patch expressly has us use REQUIRE_ORDER
:
REQUIRE_ORDER :
Options are required to occur before non-options.
Processing of options ends as soon as a word is encountered that has not been preceded by an appropriate option flag.
I believe this matches the behavior of our manual cli argument parsing prior to HBASE-24772.
Note that by default GetoptLong picks an ordering based on an environment variable we don't set. The default in that case is PERMUTE
:
PERMUTE :
Options can occur anywhere in the command line parsed. This is the default behavior.
Every sequence of words which can be interpreted as an option (with or without argument) is treated as an option; non-option words are skipped.
This ordering option is why after HBASE-24772, and prior to this patch, passing in IRB's "ignore .irbrc" flag ( -f
) would cause our shell to crash with an "I don't know what that option is supposed to mean".
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
LGTM |
Signed-off-by: Mike Drob <mdrob@apache.org>
Signed-off-by: Mike Drob <mdrob@apache.org> (cherry picked from commit dda337f)
Signed-off-by: Mike Drob <mdrob@apache.org> (cherry picked from commit dda337f)
…etoptLong (apache#4000) Signed-off-by: Mike Drob <mdrob@apache.org> (cherry picked from commit dda337f) (cherry picked from commit 9048507) Change-Id: I48f9c38241aa5e546d77f87e2ce3645cba9ce507
Since Ruby's getoptlong library can't handle config definitions of the form
-Dkey=value
, we preprocess all args to pull out config definitions.After that preprocessing, the remaining changes correct our use of the getoptlong library so we have the same cli handling as prior to using the getoptlong library.
Local testing, see HBASE-26543 for previous behavior: