diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-04-05 20:58:24 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-04-05 20:58:24 +0000 |
| commit | 4ab74ce60963eb543c5e2aa4bb3bd696bf2a5438 (patch) | |
| tree | 1b0b2171fdf1fb61567638d899423864857c282b /lib/puppet | |
| parent | 50ffa7f6b0885e2fb2e1e468c04dfec81f21e011 (diff) | |
| download | puppet-4ab74ce60963eb543c5e2aa4bb3bd696bf2a5438.tar.gz puppet-4ab74ce60963eb543c5e2aa4bb3bd696bf2a5438.tar.xz puppet-4ab74ce60963eb543c5e2aa4bb3bd696bf2a5438.zip | |
Fixing checks so that they can run even if the set cwd does not exist
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1087 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet')
| -rwxr-xr-x | lib/puppet/type/exec.rb | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/lib/puppet/type/exec.rb b/lib/puppet/type/exec.rb index 0f4e42bcd..6c15e1c7f 100755 --- a/lib/puppet/type/exec.rb +++ b/lib/puppet/type/exec.rb @@ -128,12 +128,6 @@ module Puppet self.checkexe - if cwd = self.parent[:cwd] - unless File.directory?(cwd) - self.fail "Working directory '%s' does not exist" % cwd - end - end - # We need a dir to change to, even if it's just the cwd dir = self.parent[:cwd] || Dir.pwd tmppath = ENV["PATH"] @@ -449,11 +443,25 @@ module Puppet end # Run a command. - def run(command) + def run(command, check = false) output = nil status = nil tmppath = ENV["PATH"] - dir = self[:cwd] || Dir.pwd + + dir = nil + + if dir = self[:cwd] + unless File.directory?(dir) + if check + dir = nil + else + self.fail "Working directory '%s' does not exist" % dir + end + end + end + + dir ||= Dir.pwd + debug "Executing '#{command}'" begin # Do our chdir |
