inspec/lib/resources/bash.rb

36 lines
834 B
Ruby
Raw Normal View History

2016-04-18 12:47:27 +00:00
# encoding: utf-8
require 'utils/command_wrapper'
require 'resources/command'
module Inspec::Resources
class Bash < Cmd
name 'bash'
supports platform: 'unix'
2016-04-18 12:47:27 +00:00
desc 'Run a command or script in BASH.'
example <<~EXAMPLE
2016-04-18 12:47:27 +00:00
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')
EXAMPLE
2016-04-18 12:47:27 +00:00
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