summaryrefslogtreecommitdiffstats
path: root/lib/puppet/util.rb
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2010-11-04 13:53:23 -0700
committerJames Turnbull <james@lovedthanlost.net>2010-11-12 15:02:00 +1100
commitb15231df5842df2ea83b779b22e6756e51bc39d0 (patch)
tree34978db4a199ccca92e35c66e154851bc60fff27 /lib/puppet/util.rb
parentea435a43dc97487d054271a9efb208f361408339 (diff)
downloadpuppet-b15231df5842df2ea83b779b22e6756e51bc39d0.tar.gz
puppet-b15231df5842df2ea83b779b22e6756e51bc39d0.tar.xz
puppet-b15231df5842df2ea83b779b22e6756e51bc39d0.zip
Fix for #4299 -- Don't require which
We already had an internal implementation of which hiding under an assumed name (Puppet::Util.binary); this commit calls it out of hiding and uses it consisantly.
Diffstat (limited to 'lib/puppet/util.rb')
-rw-r--r--lib/puppet/util.rb13
1 files changed, 4 insertions, 9 deletions
diff --git a/lib/puppet/util.rb b/lib/puppet/util.rb
index 1a5acaf22..850d147e2 100644
--- a/lib/puppet/util.rb
+++ b/lib/puppet/util.rb
@@ -198,7 +198,7 @@ module Util
end
end
- def binary(bin)
+ def which(bin)
if bin =~ /^\//
return bin if FileTest.file? bin and FileTest.executable? bin
else
@@ -209,7 +209,7 @@ module Util
end
nil
end
- module_function :binary
+ module_function :which
# Execute the provided command in a pipe, yielding the pipe object.
def execpipe(command, failonfail = true)
@@ -378,15 +378,10 @@ module Util
def memory
unless defined?(@pmap)
- pmap = %x{which pmap 2>/dev/null}.chomp
- if $CHILD_STATUS != 0 or pmap =~ /^no/
- @pmap = nil
- else
- @pmap = pmap
- end
+ @pmap = which('pmap')
end
if @pmap
- return %x{pmap #{Process.pid}| grep total}.chomp.sub(/^\s*total\s+/, '').sub(/K$/, '').to_i
+ %x{#{@pmap} #{Process.pid}| grep total}.chomp.sub(/^\s*total\s+/, '').sub(/K$/, '').to_i
else
0
end