lib/omnibus/util.rb
def shellout(*args)
      options = args.last.kind_of?(Hash) ? args.pop : {}
      options = SHELLOUT_OPTIONS.merge(options)

      command_string = args.join(" ")
      in_msys = options.delete(:in_msys_bash) && ENV["MSYSTEM"]
      # Mixlib will handle escaping characters for cmd but our command might
      # contain '. For now, assume that won't happen because I don't know
      # whether this command is going to be played via cmd or through
      # ProcessCreate.
      command_string = "bash -c \'#{command_string}\'" if in_msys

      # Grab the log_level
      log_level = options.delete(:log_level)

      # Set the live stream if one was not given
      options[:live_stream] ||= log.live_stream(:internal)

      # Since Mixlib::ShellOut supports :environment and :env, we want to
      # standardize here
      if options[:env]
        options[:environment] = options.fetch(:environment, {}).merge(options[:env])
      end

      # Log any environment options given
      unless options[:environment].empty?
        log.public_send(log_level, log_key) { "Environment:" }
        options[:environment].sort.each do |key, value|
          log.public_send(log_level, log_key) { "  #{key}=#{value.inspect}" }
        end
      end

      # Log the actual command
      log.public_send(log_level, log_key) { "$ #{command_string}" }

      cmd = Mixlib::ShellOut.new(command_string, options)
      cmd.environment["HOME"] = "/tmp" unless ENV["HOME"]
      cmd.run_command
      cmd
    end
def shellout(*args)
      options = args.last.kind_of?(Hash) ? args.pop : {}
      options = SHELLOUT_OPTIONS.merge(options)

      command_string = args.join(" ")
      in_msys = options.delete(:in_msys_bash) && ENV["MSYSTEM"]
      # Mixlib will handle escaping characters for cmd but our command might
      # contain '. For now, assume that won't happen because I don't know
      # whether this command is going to be played via cmd or through
      # ProcessCreate.
      command_string = "bash -c \'#{command_string}\'" if in_msys

      # Grab the log_level
      log_level = options.delete(:log_level)

      # Set the live stream if one was not given
      options[:live_stream] ||= log.live_stream(:internal)

      # Since Mixlib::ShellOut supports :environment and :env, we want to
      # standardize here
      if options[:env]
        options[:environment] = options.fetch(:environment, {}).merge(options[:env])
      end

      # Log any environment options given
      unless options[:environment].empty?
        log.public_send(log_level, log_key) { "Environment:" }
        options[:environment].sort.each do |key, value|
          log.public_send(log_level, log_key) { "  #{key}=#{value.inspect}" }
        end
      end

      # Log the actual command
      log.public_send(log_level, log_key) { "$ #{command_string}" }

      cmd = Mixlib::ShellOut.new(command_string, options)
      cmd.environment["HOME"] = "/tmp" unless ENV["HOME"]
      cmd.run_command
      cmd
    end
Shells out and runs +command+.

 @overload shellout(command, options = {})
   @param command [String]
   @param options [Hash] the options passed to the initializer of the
     +Mixlib::ShellOut+ instance.
 @overload shellout(command_fragments, options = {})
   @param command [Array<String>] command argv as individual strings
   @param options [Hash] the options passed to the initializer of the
     +Mixlib::ShellOut+ instance.
 @return [Mixlib::ShellOut] the underlying +Mixlib::ShellOut+ instance
   which has +stdout+, +stderr+, +status+, and +exitstatus+
   populated with results of the command.