mirror of
https://github.com/inspec/inspec
synced 2024-11-27 15:10:44 +00:00
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:
commit
1e6090b49a
1 changed files with 9 additions and 1 deletions
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue