public String cliToBeelineCmd(String cmd) {
    if (cmd == null)
      return null;
    if (cmd.toLowerCase().equals("quit") || cmd.toLowerCase().equals("exit")) {
      return BeeLine.COMMAND_PREFIX + cmd;
    } else if (cmd.startsWith("!")) {
      String shell_cmd = cmd.substring(1);
      return "!sh " + shell_cmd;
    } else { // local mode
      // command like dfs
      return cmd;
    }
  }
Extract and clean up the first command in the input.
beeline/src/java/org/apache/hive/beeline/Commands.java