我愿意将参数传递给jshell脚本.例如,我会喜欢这样的事情:
jshell myscript.jsh "some text"
Run Code Online (Sandbox Code Playgroud)
然后在脚本中的某个变量中提供字符串"some text".
但是,jshell只需要一个文件列表,因此答案是:
File 'some text' for 'jshell' is not found.
Run Code Online (Sandbox Code Playgroud)
有没有办法将参数正确传递给jshell脚本?
到目前为止,我唯一的解决方案是在调用脚本时使用环境变量:
ARG="some test" jshell myscript.jsh
Run Code Online (Sandbox Code Playgroud)
然后我可以在脚本中访问它:
System.getenv().get("ARG")
Run Code Online (Sandbox Code Playgroud)