Method: Unix::Pkg#check_for_command

Defined in:
lib/beaker/host/unix/pkg.rb

#check_for_command(name) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/beaker/host/unix/pkg.rb', line 10

def check_for_command(name)
  result = exec(Beaker::Command.new("which #{name}"), :accept_all_exit_codes => true)
  case self['platform']
  when /solaris-10/
    # solaris 10 appears to have considered `which` to have run successfully,
    # even if the command didn't exist, so it'll return a 0 exit code in
    # either case. Instead we match for the phrase output when a match isn't
    # found: "no #{name} in $PATH", reversing it to match our API
    !( result.stdout.match(/^no\ #{name}\ in\ /) )
  else
    result.exit_code == 0
  end
end