2

I am trying to run robocopy (Windows robust copy) in a shell script (which is actually a git hook). It works fine until I add the option /XO.

So the command:

robocopy source destination a.txt

works correctly in .bat and .sh file.

But the command

robocopy source destination a.txt /XO

fails in .sh with error:

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

whereas it works correctly in bat file.

So the problem is with the /XO option to robocopy; more specifically, the way shells script passes the parameter to robocopy.

Kindly suggest a solution.

Mofi
  • 46,139
  • 17
  • 80
  • 143
vintrojan
  • 1,277
  • 1
  • 12
  • 22
  • So, this git bash is based on cygwin or msys? with [`msys`this problem should not arise](http://sourceforge.net/mailarchive/message.php?msg_id=8686481). – anishsane Jul 25 '16 at 11:35
  • Check http://stackoverflow.com/questions/13701218/windows-path-to-posix-path-conversion-in-bash/13702694#13702694 – anishsane Jul 25 '16 at 11:35

1 Answers1

1

If you're using Git Bash for this, it intelligently transforms Unix-style options in to Windows-style ones. So, for example, the command:

robocopy source destination a.txt -xo

will show you that it's using the /xo option:

-------------------------------------------------------------------------------
   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
paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953