D
Duckz King_duckz
Hello everyone, I've been searching on google for a while now but I
can't find any solution to my question. Basically I want to be able to
specify the working directory for any external command I might launch,
without using ugly globals :S
What I'm trying to write is a wrapper class for git. As a client, I want
to be able to write, for example:
and of course I don't want to know what's happening inside status().
In order to invoke git I'm doing `git status`, or `"c:/program
files/git/bin/sh.exe" -c "git status"`, depending on the OS and other
things. The problem is, backticks as well as %x, system and friends rely
on Dir.pwd, so in order to get a valid result from git I should do:
which I'd rather avoid for its obvious fragility:
Any suggestions?
can't find any solution to my question. Basically I want to be able to
specify the working directory for any external command I might launch,
without using ugly globals :S
What I'm trying to write is a wrapper class for git. As a client, I want
to be able to write, for example:
Code:
git = GitWrapper.new
puts git.status
and of course I don't want to know what's happening inside status().
In order to invoke git I'm doing `git status`, or `"c:/program
files/git/bin/sh.exe" -c "git status"`, depending on the OS and other
things. The problem is, backticks as well as %x, system and friends rely
on Dir.pwd, so in order to get a valid result from git I should do:
Code:
def status()
Dir.chdir("some/dir") do
return `git status`
end
end
Code:
git = GitWrapper.new
a = Thread.new {10000.times do {Dir.chdir("some/other/dir");
do_some_work(); `rm -rf '*'`}}
puts git.status() # OMG!!!!!111
a.join
Any suggestions?