mirror of
https://github.com/inspec/inspec
synced 2024-11-23 13:13:22 +00:00
improve command.exist? for more operating systems
This commit is contained in:
parent
74ddf2c5f1
commit
d470803c37
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