Running command with with space argument value with apache command line

无人久伴 提交于 2019-12-14 03:44:09

问题


I'm using apache command line library and I want to execute from java program

git stash list --format=%gd:%at:%B --grep="some text with space"

this is the code commandLine.addArgument( "--grep=\"" + filter+"\"", false); it is run on windows without any problem but on linux does not. If i execute the command from terminal it is execute correctly

I also tried to let apache library to put quoting

commandLine.addArgument( "--grep=" + filter);

but i get

fatal: bad revision '"--grep=text message"'

回答1:


While there is a bug around quotes managements in Common Exec, this answers suggests:

// When writing a command with space use double "
cmdLine.addArgument(--grep=\"\"" + filter+"\"\"", false"\"\"",false);


来源:https://stackoverflow.com/questions/24257546/running-command-with-with-space-argument-value-with-apache-command-line

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