in gshell/gshell-core/src/main/java/org/apache/servicemix/kernel/gshell/core/LocalConsole.java [104:143]
public void run() {
try {
String[] args = mainService.getArgs();
// If a command was specified on the command line, then just execute that command.
if (args != null && args.length > 0) {
waitForFrameworkToStart();
log.info("Executing Shell with arguments: " + Arrays.toString(args));
StringBuilder sb = new StringBuilder();
for (String arg : args) {
sb.append(arg).append(" ");
}
Object value = shell.execute(sb.toString());
if (mainService != null) {
if (value instanceof Number) {
mainService.setExitCode(((Number) value).intValue());
} else {
mainService.setExitCode(value != null ? 1 : 0);
}
log.info("Exiting shell due to terminated command");
}
} else {
shell.run();
}
} catch (ExitNotification e) {
if (mainService != null) {
mainService.setExitCode(0);
}
log.info("Exiting shell due received exit notification");
} catch (Throwable e) {
if (mainService != null) {
mainService.setExitCode(-1);
}
log.error("Exiting shell due to caught exception " + e, e);
} finally {
try {
shell.close();
} catch (Throwable t) {}
asyncShutdown();
}
}