private int execute(ConsoleReader reader, boolean exitOnError) {
    int lastExecutionResult = ERRNO_OK;
    Character mask = (System.getProperty("jline.terminal", "").equals("jline.UnsupportedTerminal")) ? null
                       : ConsoleReader.NULL_MASK;

    while (!exit) {
      try {
        // Execute one instruction; terminate on executing a script if there is an error
        // in silent mode, prevent the query and prompt being echoed back to terminal
        String line = (getOpts().isSilent() && getOpts().getScriptFile() != null) ? reader
            .readLine(null, mask) : reader.readLine(getPrompt());

        // trim line
        if (line != null) {
          line = line.trim();
        }

        if (!dispatch(line)) {
          lastExecutionResult = ERRNO_OTHER;
          if (exitOnError) {
            break;
          }
        } else if (line != null) {
          lastExecutionResult = ERRNO_OK;
        }

      } catch (Throwable t) {
        handleException(t);
        return ERRNO_OTHER;
      }
    }
    return lastExecutionResult;
  }
Start accepting input from stdin, and dispatch it
to the appropriate {@link CommandHandler} until the
global variable <code>exit</code> is true.
beeline/src/java/org/apache/hive/beeline/BeeLine.java