mirror of
https://github.com/inspec/inspec
synced 2024-11-14 00:47:10 +00:00
7b23fa479c
* Add correct `supports platform` to resources. Signed-off-by: Miah Johnson <miah@chia-pet.org> * Remove 'os_family' and update platforms to specify what they did. Signed-off-by: Miah Johnson <miah@chia-pet.org> * Add esx and cisco to generic resources. Signed-off-by: Jared Quick <jquick@chef.io>
35 lines
819 B
Ruby
35 lines
819 B
Ruby
# encoding: utf-8
|
|
|
|
require 'utils/command_wrapper'
|
|
require 'resources/command'
|
|
|
|
module Inspec::Resources
|
|
class Bash < Cmd
|
|
name 'bash'
|
|
supports platform: 'unix'
|
|
desc 'Run a command or script in BASH.'
|
|
example "
|
|
describe bash('ls -al /') do
|
|
its('stdout') { should match /bin/ }
|
|
its('stderr') { should eq '' }
|
|
its('exit_status') { should eq 0 }
|
|
end
|
|
|
|
# Specify the path of the executable:
|
|
bash('...', path: '/bin/bash')
|
|
|
|
# Specify arguments (defaults to -c)
|
|
bash('...', args: '-x -c')
|
|
"
|
|
|
|
def initialize(command, options = {})
|
|
@raw_command = command
|
|
options[:shell] = 'bash' if options.is_a?(Hash)
|
|
super(CommandWrapper.wrap(command, options))
|
|
end
|
|
|
|
def to_s
|
|
"Bash command #{@raw_command}"
|
|
end
|
|
end
|
|
end
|