2016-07-25 39 views
2

我试图在shell脚本中运行robocopy(这是一个git钩子)。它工作正常,直到我添加选项/XObat和sh之间的命令行参数语法有什么区别?

于是命令:

robocopy source destination a.txt 

作品正确.BAT和sh文件。

但命令

robocopy source destination a.txt /XO 

在.SH失败,错误:

ERROR : Invalid Parameter #3 : "C:/Program Files/Git/XO"

,而它正常工作在bat文件。

所以问题出在/XO选项robocopy;更具体地说,shell脚本将参数传递给robocopy的方式。

请提出解决方案。

+0

所以,这个混帐bash的是基于Cygwin的或MSYS?与['msys'这个问题不应该出现](http://sourceforge.net/mailarchive/message.php?msg_id=8686481)。 – anishsane

+0

检查http://stackoverflow.com/questions/13701218/windows-path-to-posix-path-conversion-in-bash/13702694#13702694 – anishsane

回答

0

如果您为此使用Git Bash,它会智能地将Unix风格的选项转换为Windows风格的选项。因此,举例来说,下面的命令:

robocopy source destination a.txt -xo 

会告诉你,这是使用/xo选项:

------------------------------------------------------------------------------- 
    ROBOCOPY  ::  Robust File Copy for Windows 
------------------------------------------------------------------------------- 

    Started : Tue Feb 06 15:58:53 2018 

    Source : c:\gitbashdir\source 
    Dest : c:\gitbashdir\destination\ 

    Files : a.txt 

    Options : /COPY:DAT /XO /R:1000000 /W:30 

    : blah blah blah : 

    Ended : Tue Feb 06 15:58:53 2018 
相关问题