public void processSelectDatabase(CliSessionState ss) throws IOException, CommandProcessorException {
    String database = ss.database;
    if (database != null) {
      processLineExitOnFailure("use " + database + ";");
    }
  }
Split the line by semicolon by ignoring the ones in the single/double quotes.
cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java