【问题标题】:Running command with with space argument value with apache command line使用apache命令行运行带有空格参数值的命令
【发布时间】:2014-06-17 07:01:41
【问题描述】:

我正在使用 apache 命令行库,我想从 java 程序中执行

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

这是代码 commandLine.addArgument("--grep=\"" + filter+"\"", false); 它在windows上运行没有任何问题,但在linux上没有。 如果我从终端执行命令,它会正确执行

我也试过让apache库放引用

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

但我明白了

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

【问题讨论】:

    标签: java git apache command


    【解决方案1】:

    虽然有一个bug around quotes managements in Common Exec,但这个answers suggests

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

    【讨论】:

      猜你喜欢
      • 2018-12-14
      • 1970-01-01
      • 1970-01-01
      • 2011-08-23
      • 2014-05-22
      • 2011-04-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多