问题
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