问题
I'm using Apache CLI to parse command line arguments. One of my arguments is a filter that takes a string MyApp -f "search for this string"
I thought when i do cmdLine.getOptionValue("f")
it would return: search for this string
However it just returns search
What should I do to ensure that the entire string is retrieved, apparently just wrapping it in double quotes doesn't seem to work.
I'm on ubuntu.
回答1:
I think passing the string with extra single quotes should work:
MyApp -f "'search for this string'"
回答2:
On Windows the argument must be surrounded with double quotes. On Unix you can use simple quotes, double quotes, or escape the space with a backslash.
来源:https://stackoverflow.com/questions/18839069/apache-cli-option-value-with-whitespace