Method: Facter::Core::Execution::Posix#which

Defined in:
lib/facter/custom_facts/core/execution/posix.rb

#which(bin) ⇒ Object

Since:

  • 2.0.0



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/facter/custom_facts/core/execution/posix.rb', line 16

def which(bin)
  if absolute_path?(bin)
    return bin if File.executable?(bin) && FileTest.file?(bin)
  else
    search_paths.each do |dir|
      dest = File.join(dir, bin)
      return dest if File.executable?(dest) && FileTest.file?(dest)
    end
  end
  nil
end