adoroszlai commented on code in PR #7727: URL: https://github.com/apache/ozone/pull/7727#discussion_r1930459798
########## hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/Shell.java: ########## @@ -83,16 +93,31 @@ public void run(String[] argv) { // failure will be reported by regular, non-interactive run } - if (interactive) { + if (executionMode != null && (executionMode.interactive || !executionMode.command.isEmpty())) { spec.name(""); // use short name (e.g. "token get" instead of "ozone sh token get") - new REPL(this, getCmd(), (PicocliCommandsFactory) getCmd().getFactory()); + installBatchExceptionHandler(); + new REPL(this, getCmd(), (PicocliCommandsFactory) getCmd().getFactory(), executionMode.command); } else { TracingUtil.initTracing("shell", getOzoneConf()); String spanName = spec.name() + " " + String.join(" ", argv); TracingUtil.executeInNewSpan(spanName, () -> super.run(argv)); } } + private void installBatchExceptionHandler() { + // exit on first error in batch mode + if (!executionMode.interactive) { Review Comment: > Is this line correct so we only install the handler if it is NOT interactive? Yes, it is correct. > Interactive=true is batch mode, right? There are 3 exclusive modes: 1. regular: no options, one command to be executed 2. interactive: `--interactive` option, starts the shell and lets you run commands interactively, seeing results before typing the next one. This provides completion, help, etc. 3. batch: one or more `--execute` options, runs each in the same process without further interaction. Main benefit is just reduced startup latency on second and later items in the batch. Exit on first error only applies to batch mode. Errors in interactive mode are not fatal, since you have control over the process, can simply correct the previous problem. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@ozone.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@ozone.apache.org For additional commands, e-mail: issues-h...@ozone.apache.org