command resource: Add exist? for Alpine Linux (#2768)

This allows `command('foo').exist?` to work on Alpine Linux.

Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com>
This commit is contained in:
Jerry Aldrich 2018-03-02 04:02:58 -10:00 committed by Jared Quick
parent 1e14bbdf9d
commit 3da8fd1e98

View file

@ -50,7 +50,11 @@ module Inspec::Resources
return false if inspec.os.name.nil? || inspec.os.name == 'mock'
if inspec.os.linux?
res = inspec.backend.run_command("bash -c 'type \"#{@command}\"'")
res = if inspec.platform.name == 'alpine'
inspec.backend.run_command("which \"#{@command}\"")
else
inspec.backend.run_command("bash -c 'type \"#{@command}\"'")
end
elsif inspec.os.windows?
res = inspec.backend.run_command("Get-Command \"#{@command}\"")
elsif inspec.os.unix?