improve command.exist? for more operating systems

This commit is contained in:
Christoph Hartmann 2015-11-02 12:00:15 +01:00
parent 74ddf2c5f1
commit d470803c37

View file

@ -35,7 +35,15 @@ class Cmd < Inspec.resource(1)
end end
def exist? def exist?
res = inspec.backend.run_command("type \"#{@command}\" > /dev/null") if inspec.os.linux?
res = inspec.backend.run_command("bash -c 'type \"#{@command}\"'")
elsif inspec.os.windows?
res = inspec.backend.run_command("where.exe \"#{@command}\"")
elsif inspec.os.unix?
res = inspec.backend.run_command("type \"#{@command}\"")
else
fail "`command(#{@command}).exits?` is not suported on you OS."
end
res.exit_status.to_i == 0 res.exit_status.to_i == 0
end end