Apache CLI option value with whitespace

徘徊边缘 提交于 2020-01-03 07:18:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!