}
public void run() {
try {
threadIO.setStreams(consoleInput, out, err);
SecuredCommandProcessorImpl secCP = null;
if (secured) {
secCP = createSecuredCommandProcessor();
}
thread = Thread.currentThread();
CommandSessionHolder.setSession(session);
running = true;
pipe.start();
Properties brandingProps = Branding.loadBrandingProperties(terminal);
welcome(brandingProps);
setSessionProperties(brandingProps);
String scriptFileName = System.getProperty(SHELL_INIT_SCRIPT);
executeScript(scriptFileName);
while (running) {
try {
String command = readAndParseCommand();
if (command == null) {
break;
}
//session.getConsole().println("Executing: " + line);
Object result = session.execute(command);
if (result != null) {
session.getConsole().println(session.format(result, Converter.INSPECT));
}
} catch (InterruptedIOException e) {
//System.err.println("^C");
// TODO: interrupt current thread
} catch (InterruptedException e) {
//interrupt current thread
} catch (CloseShellException e) {
break;
} catch (Throwable t) {
ShellUtil.logException(session, t);
}
}
if (secured) {
try {
secCP.close();
} catch (Throwable t) {
// Ignore
}
}
close(true);