code: public static String quoteArgument(String argument) {
          if (QUOTED_STRING.matcher(argument).matches() || !UNESCAPED_SPACE_OR_QUOTES.matcher(argument).find()) {
              // assume the argument is well-formed if it's already quoted or if there are no unescaped spaces or quotes
              return argument;
          }
  
          return String.format("\"%s\"", DOUBLE_QUOTE.matcher(argument).replaceAll(Matcher.quoteReplacement("\\") + "$1"));
      }
docs: Surrounds a string with double quotes if it is not already surrounded by single or double quotes, or if it contains
  unescaped spaces, single quotes, or double quotes. When surrounding with double quotes, this method will only escape
  double quotes in the String.
  
  This method assumes the argument is well-formed if it was already surrounded by either single or double quotes.
  
  @param argument String to quote
  @return the quoted String, if not already quoted