-
Notifications
You must be signed in to change notification settings - Fork 440
Description
The example in #738 made me realize that the CommandLine.setSplitQuotedStrings
functionality should not be advertised as prominently as it is currently. This function may not do what many users think it does!
Essentially, setSplitQuotedStrings
is mostly for backwards compatibility, for applications that want the pre-3.7 behaviour of simply splitting regardless of quotes. When this setting is true
, input like this
-x a,b,"c,d,e",f,"xxx,yyy"
is parsed as:
a
b
"c
d
e"
f
"xxx
yyy"
The original documentation did not clearly explain this. I updated the user manual (still unpublished) and the javadoc to better reflect what it actually does.
Most applications should leave this setting to the default (false
), giving the expected output of first a
, then b
, then c,d,e
, then f
, and finally xxx,yyy
. It is unlikely that applications really want to simply split regardless of quotes, unless they have custom quote handling behaviour.
Perhaps CommandLine.setSplitQuotedStrings
should be deprecated to discourage casual users from enabling this. Applications that do need this behaviour can use the ParserSpec.splitQuotedStrings(boolean)
API. This is more cumbersome, but that is not necessarily a bad thing in this case.