Sha256: e248b31660b35552b2c4668636baca380912eab5b8080b14b450242ead608d47

Contents?: true

Size: 854 Bytes

Versions: 5

Compression:

Stored size: 854 Bytes

Contents

# 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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
inspec-2.1.81 lib/resources/bash.rb
inspec-2.1.21 lib/resources/bash.rb
inspec-2.1.10 lib/resources/bash.rb
inspec-2.0.32 lib/resources/bash.rb
inspec-2.0.17 lib/resources/bash.rb