Sha256: 811a84423261f24d40ab4ed6ac9facd479487dcfd5d95db7ba2f58cd3791f33a

Contents?: true

Size: 917 Bytes

Versions: 11

Compression:

Stored size: 917 Bytes

Contents

require "inspec/utils/command_wrapper"
require "inspec/resources/command"

module Inspec::Resources
  class Bash < Cmd
    name "bash"
    supports platform: "unix"
    supports platform: "esx"

    desc "Run a command or script in BASH."
    example <<~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')
    EXAMPLE

    def initialize(command, options = {})
      @raw_command = command
      options[:shell] = "bash" if options.is_a?(Hash)
      super(CommandWrapper.wrap(command, options))
    end

    def resource_id
      @raw_command || "bash"
    end

    def to_s
      "Bash command #{@raw_command}"
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
inspec-core-6.8.11 lib/inspec/resources/bash.rb
inspec-core-5.22.58 lib/inspec/resources/bash.rb
inspec-core-5.22.55 lib/inspec/resources/bash.rb
inspec-core-6.8.1 lib/inspec/resources/bash.rb
inspec-core-5.22.40 lib/inspec/resources/bash.rb
inspec-core-6.6.0 lib/inspec/resources/bash.rb
inspec-core-5.22.36 lib/inspec/resources/bash.rb
inspec-core-5.22.29 lib/inspec/resources/bash.rb
inspec-core-5.22.3 lib/inspec/resources/bash.rb
inspec-core-5.21.29 lib/inspec/resources/bash.rb
inspec-core-5.18.14 lib/inspec/resources/bash.rb