public static String trimCommand(String command) {
    if (CliUtil.isNullOrEmpty(command))
      return command;

    int len = command.length();
    int st = 0;

    while ((st < len) && (command.charAt(st) <= ' ')) {
      st++;
    }
    while ((st < len) && ((command.charAt(len - 1) <= ' ')
        || command.charAt(len - 1) == ';')) {
      len--;
    }
    return ((st > 0) || (len < command.length())) ? command.substring(st, len) : command;
  }
Trims: leading spaces; trailing spaces and ";"s
@param command input String to trim
@return trimmed String
samza-sql-shell/src/main/java/org/apache/samza/sql/client/util/CliUtil.java