Conversation
|
@apurtell @NihalJain @virajjasani Can you please help with review. |
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request. Check if the Files changed in this pull request are included in default exclusions.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
f136c1d to
d8e0b45
Compare
| set -- | ||
| CLASS='jdk.internal.jshell.tool.JShellToolProvider' | ||
| init_jshell_args | ||
| JSHELL_ARGS+=(-q "$JSH_SCRIPT") |
There was a problem hiding this comment.
This unconditionally appends -q regardless of what's in HBASE_JSHELL_ARGS. This will make bin/hbase myscript.jsh fail immediately with exit 1 in many cases (e.g. any --feedback <mode> other than literally -q)
There was a problem hiding this comment.
Good catch — confirmed: jshell exits 1 with Only one feedback option (--feedback, -q, -s, or -v) may be used. when -q is appended on top of a user --feedback from HBASE_JSHELL_ARGS.
Fixed in the latest push: script mode only defaults to -q when none of --feedback / -q / -s / -v is already set.
Mirror the existing .rb -> org.jruby.Main path with dispatch for .jsh (JShellToolProvider) and .java (JEP 330 single-file source launch). JShell script mode defaults to --execution local so System.exit() propagates as the process exit code, honors a user-supplied --execution / --execution=<spec> from HBASE_JSHELL_ARGS, and passes positional args via HBASE_JSH_ARG_N / HBASE_JSH_ARG_COUNT. Interactive jshell and *.jsh share init_jshell_args so defaults cannot drift. Document script.jsh / Script.java in show_usage and the arg convention in the header, hbase-env.sh, and hbase_startup.jsh. Use HBASE_PROC_NAME=jsh|java for -Dproc_* and a JAVA_MAIN argv array so empty CLASS (JEP 330) does not create a spurious argument and paths with spaces stay intact. Only default -q for scripts when HBASE_JSHELL_ARGS does not already set a feedback mode (--feedback / -q / -s / -v).
d8e0b45 to
f71498c
Compare
| # unless the user already passed --execution / --execution=<spec>. | ||
| init_jshell_args() { | ||
| if [ -n "${HBASE_JSHELL_ARGS}" ]; then | ||
| read -r -a JSHELL_ARGS <<< "${HBASE_JSHELL_ARGS}" |
There was a problem hiding this comment.
Please either:
- explicitly document that HBASE_JSHELL_ARGS cannot contain whitespace-bearing arguments, or
- add a parsing approach that supports values such as a startup file path containing spaces.
| echo " clean Run the HBase clean up script" | ||
| fi | ||
| echo " jshell Run a jshell with HBase on the classpath" | ||
| echo " script.jsh Run a JShell script non-interactively (args via HBASE_JSH_ARG_N)" |
There was a problem hiding this comment.
Can we move these besides CLASSNAME, at the end? Currently, I am not sure if this help arg is clear; it might seem like hbase script.jsh is in itself a command and not a placeholder.
|
I checked-out out this PR and ran few tests via https://gist.github.com/NihalJain/0d5f0370598b7e730b0106ab8f3f0d0b Overall this PR LGTM! |
|
On a side note, please refrain from using force push, it destroys commit history and review experience. |
Summary
bin/hbasedispatch for.jsh(JShellToolProvider) and.java(JEP 330 single-file source launch), mirroring the existing.rb→org.jruby.Mainpath.HBASE_JSH_ARG_N/HBASE_JSH_ARG_COUNT; forward args natively for.java.init_jshell_argsfor interactivejshelland*.jsh: optionalhbase_startup.jsh, default--execution local(honors user--execution/--execution=<spec>).-qonly when no feedback option is already set inHBASE_JSHELL_ARGS.HBASE_PROC_NAME=jsh|javafor-Dproc_*;JAVA_MAINargv array so emptyCLASSand paths with spaces are handled safely.This is the replacement path for retiring the standalone JRuby scripts under
bin/.JIRA: https://issues.apache.org/jira/browse/HBASE-30419
Test plan
bin/hbase path/to/script.jsh arg1 arg2—System.exitpropagates; args readable viaHBASE_JSH_ARG_*bin/hbase path/to/Script.java arg1 arg2— args reachmain; path with spaces worksHBASE_JSHELL_ARGS='--feedback verbose' bin/hbase script.jshdoes not fail with "Only one feedback option"HBASE_JSHELL_ARGS='--execution=jdi:...' bin/hbase script.jshdoes not append a second--execution localbin/hbase --helplistsscript.jsh/Script.java