Merge pull request #190 from chef/improve-cmd-exist

Merged change 95430051-98b0-4866-9a74-e18625c80704

From review branch improve-cmd-exist into master

Signed-off-by: drichter <drichter@chef.io>
This commit is contained in:
chef-delivery 2015-11-02 03:19:36 -08:00
commit 1e6090b49a

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