Tuesday, 3 September 2013

Using system with windows

Using system with windows

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/
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 the command line/system.

No comments:

Post a Comment