1

I have a plugin that uses the Plexus Commandline to invoke some external process and capture the output. One of the arguments is in a funny format with spaces and quotes, e.g. --range:"25 Aug 2008"-"04 Aug 2009". I have no way to change the required format of the argument, but Plexus detects the spaces in the argument and wraps the whole thing in quotes.

So

call --range:"25 Aug 2008"-"04 Aug 2009"

becomes

call "--range:"25 Aug 2008"-"04 Aug 2009""

and the invocation fails.

Can I make plexus stop escaping the arguments?

matt b
  • 138,234
  • 66
  • 282
  • 345
talk to frank
  • 1,821
  • 4
  • 20
  • 21

1 Answers1

1

The Commandline object uses a Shell to interact with the local environment, you can configure the Shell to override the default escaping process to not escape any quotes:

Commandline cl = new Commandline("call");
commandline.getShell().setQuotedArgumentsEnabled(false);

Be aware that this means that none of the arguments will be enquoted, so use it with care!

Rich Seller
  • 83,208
  • 23
  • 172
  • 177