summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorOhad Levy <ohadlevy@gmail.com>2009-10-12 10:17:22 +0800
committerJames Turnbull <james@lovedthanlost.net>2009-10-13 20:50:04 +1100
commit54ded1bd2b8c023d6e480c21f1b2b03f3b7859ba (patch)
treed3331a0054079ebf69ee19ec65adbb59d960965c /lib/puppet
parent4c3c2799364cc970a144c63eb92ae58f086f280c (diff)
downloadpuppet-54ded1bd2b8c023d6e480c21f1b2b03f3b7859ba.tar.gz
puppet-54ded1bd2b8c023d6e480c21f1b2b03f3b7859ba.tar.xz
puppet-54ded1bd2b8c023d6e480c21f1b2b03f3b7859ba.zip
Fixes #1719, this avoids calling the external binary *which* everytime we are looking for a binary
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/util.rb17
1 files changed, 6 insertions, 11 deletions
diff --git a/lib/puppet/util.rb b/lib/puppet/util.rb
index e1e699286..6f83c7ac5 100644
--- a/lib/puppet/util.rb
+++ b/lib/puppet/util.rb
@@ -185,19 +185,14 @@ module Util
def binary(bin)
if bin =~ /^\//
- if FileTest.file? bin and FileTest.executable? bin
- return bin
- else
- return nil
- end
+ return bin if FileTest.file? bin and FileTest.executable? bin
else
- x = %x{which #{bin} 2>/dev/null}.chomp
- if x == ""
- return nil
- else
- return x
- end
+ ENV['PATH'].split(File::PATH_SEPARATOR).each do |dir|
+ dest=File.join(dir, bin)
+ return dest if FileTest.file? dest and FileTest.executable? dest
+ end
end
+ return nil
end
module_function :binary