public String handleMultiLineCmd(String line) throws IOException {
    line = HiveStringUtils.removeComments(line);
    Character mask = (System.getProperty("jline.terminal", "").equals("jline.UnsupportedTerminal")) ? null
                       : jline.console.ConsoleReader.NULL_MASK;

    while (isMultiLine(line) && beeLine.getOpts().isAllowMultiLineCommand()) {
      StringBuilder prompt = new StringBuilder(beeLine.getPrompt());
      if (!beeLine.getOpts().isSilent()) {
        for (int i = 0; i < prompt.length() - 1; i++) {
          if (prompt.charAt(i) != '>') {
            prompt.setCharAt(i, i % 2 == 0 ? '.' : ' ');
          }
        }
      }
      String extra;
      //avoid NPE below if for some reason -e argument has multi-line command
      if (beeLine.getConsoleReader() == null) {
        throw new RuntimeException("Console reader not initialized. This could happen when there "
            + "is a multi-line command using -e option and which requires further reading from console");
      }
      if (beeLine.getOpts().isSilent() && beeLine.getOpts().getScriptFile() != null) {
        extra = beeLine.getConsoleReader().readLine(null, mask);
      } else {
        extra = beeLine.getConsoleReader().readLine(prompt.toString());
      }

      if (extra == null) { //it happens when using -f and the line of cmds does not end with ;
        break;
      }
      extra = HiveStringUtils.removeComments(extra);
      if (extra != null && !extra.isEmpty()) {
        line += "\n" + extra;
      }
    }
    return line;
  }
Extract and clean up the first command in the input.
beeline/src/java/org/apache/hive/beeline/Commands.java