mirror of
https://github.com/inspec/inspec
synced 2024-11-27 07:00:39 +00:00
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:
parent
1e14bbdf9d
commit
3da8fd1e98
1 changed files with 5 additions and 1 deletions
|
@ -50,7 +50,11 @@ module Inspec::Resources
|
||||||
return false if inspec.os.name.nil? || inspec.os.name == 'mock'
|
return false if inspec.os.name.nil? || inspec.os.name == 'mock'
|
||||||
|
|
||||||
if inspec.os.linux?
|
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?
|
elsif inspec.os.windows?
|
||||||
res = inspec.backend.run_command("Get-Command \"#{@command}\"")
|
res = inspec.backend.run_command("Get-Command \"#{@command}\"")
|
||||||
elsif inspec.os.unix?
|
elsif inspec.os.unix?
|
||||||
|
|
Loading…
Reference in a new issue