I have the following string I'm trying to pass to system on a Win 7 machine. It should be creating the .git directory in a repo but using system it does not (though a similar approach does work on a Linux box so this is a Windows specific problem).
system( "cd C:/Users/trinker/Desktop/foo2 && \"C:\\Program Files (x86)\\Git\\bin\\git.exe\" init" )
C:/Users/trinker/Desktop/foo2 is the location of a repo. C:\\Program Files (x86)\\Git\\bin\\git.exe is the location of git on my system.
When I run the above nothing happens. No message, nadda. But is I run cat on the string and paste it directly into the command line it runs, gives the following message and creates .git in the appropriate place.
So running...
cat("cd C:/Users/trinker/Desktop/foo2 && \"C:\\Program Files (x86)\\Git\\bin\\git.exe\" init")
Pasting this into the command line...
cd C:/Users/trinker/Desktop/foo2 && "C:\Program Files (x86)\Git\bin\git.exe" init
Gives...
Initialized empty Git repository in C:/Users/trinker/Desktop/foo2/.git/
...Which is good
So I can do it outside of R with the same string but not within R. What do I need to do to the first string where I use system to make it run as if though I cat and pasted into the command line? An answer is great but I'd like to know what's going on here so I can address similar circumstances in the future with accessing the Windows command line with system.