Module: SystemCommand::Mixin

Overview

This module is part of an internal API. This module may only be used internally in repositories owned by Homebrew, except in casks or formulae. Third parties should avoid using this module if possible, as it may be removed or changed without warning.

Helper functions for calling run.

Instance Method Summary collapse

Instance Method Details

#command_sandbox ⇒ Sandbox?

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



22
# File 'system_command.rb', line 22

def command_sandbox = nil

#system_command(executable, args: [], sudo: false, sudo_as_root: false, env: {}, input: [], must_succeed: false, print_stdout: false, print_stderr: true, debug: nil, verbose: nil, secrets: [], chdir: nil, timeout: nil) ⇒ SystemCommand::Result

This method is part of an internal API. This method may only be used internally in repositories owned by Homebrew, except in casks or formulae. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Run a fallible system command.

Parameters:

  • executable (String, Pathname)
  • args (Array<String, Integer, Float, Pathname>) (defaults to: [])
  • sudo (Boolean, nil) (defaults to: false)
  • sudo_as_root (Boolean) (defaults to: false)
  • env (Hash{String => String, Boolean, PATH, nil}) (defaults to: {})
  • input (String, Array<String>) (defaults to: [])
  • must_succeed (Boolean) (defaults to: false)
  • print_stdout (Boolean, Symbol) (defaults to: false)
  • print_stderr (Boolean, Symbol) (defaults to: true)
  • debug (Boolean, nil) (defaults to: nil)
  • verbose (Boolean, nil) (defaults to: nil)
  • secrets (String, Array<String>) (defaults to: [])
  • chdir (String, Pathname, nil) (defaults to: nil)
  • timeout (Integer, Float, nil) (defaults to: nil)

Returns:



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'system_command.rb', line 45

def system_command(executable, args: [], sudo: false, sudo_as_root: false, env: {}, input: [],
                   must_succeed: false, print_stdout: false, print_stderr: true, debug: nil, verbose: nil,
                   secrets: [], chdir: nil, timeout: nil)
  if (sandbox = command_sandbox)
    Kernel.raise ArgumentError, "Sandboxed commands cannot use sudo" if sudo || sudo_as_root

    return sandbox.capture(executable, args:, env:, input:, must_succeed:, print_stdout:, print_stderr:,
                           debug:, verbose:, secrets:, chdir:, timeout:)
  end

  SystemCommand.run(executable, args:, sudo:, sudo_as_root:, env:, input:, must_succeed:, print_stdout:,
                    print_stderr:, debug:, verbose:, secrets:, chdir:, timeout:)
end

#system_command!(executable, args: [], sudo: false, sudo_as_root: false, env: {}, input: [], print_stdout: false, print_stderr: true, debug: nil, verbose: nil, secrets: [], chdir: nil, timeout: nil) ⇒ SystemCommand::Result

This method is part of an internal API. This method may only be used internally in repositories owned by Homebrew, except in casks or formulae. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Run an infallible system command.

Parameters:

Returns:



79
80
81
82
83
84
# File 'system_command.rb', line 79

def system_command!(executable, args: [], sudo: false, sudo_as_root: false, env: {}, input: [],
                    print_stdout: false, print_stderr: true, debug: nil, verbose: nil, secrets: [],
                    chdir: nil, timeout: nil)
  system_command(executable, args:, sudo:, sudo_as_root:, env:, input:, must_succeed: true, print_stdout:,
                 print_stderr:, debug:, verbose:, secrets:, chdir:, timeout:)
end