2009/10/12 Ohad Levy <[email protected]>:
> Signed-off-by: Ohad Levy <[email protected]>
> ---
> lib/puppet/util.rb | 17 ++++++-----------
> 1 files changed, 6 insertions(+), 11 deletions(-)
Generally good - one small cross platform change commented inline.
>
> diff --git a/lib/puppet/util.rb b/lib/puppet/util.rb
> index e1e6992..bc7e145 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(":").each do |dir|
Can you split on File::PATH_SEPARATOR for cross platform support
> + dest=File.join(dir, bin)
> + return dest if FileTest.file? dest and FileTest.executable?
> dest
> + end
> end
> + retun nil
> end
> module_function :binary
Paul
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Puppet Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/puppet-dev?hl=en
-~----------~----~----~----~------~----~------~--~---