2

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"'
L4zy
  • 327
  • 2
  • 13

1 Answers1

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);
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250