sh

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ExecCommand = executeCommand

Alias for os/exec.Command to allow mocking the command executions in tests. see https://npf.io/2015/06/testing-exec-command/ for more information about.

Functions

func ExecSudoCommand

func ExecSudoCommand(command string, args ...string) *exec.Cmd

ExecSudoCommand executes the given command in the same way as os.ExecCommand would do it. But with the difference that ExecSudoCommand prefixes the command with sudo.

func InitSudo

func InitSudo() error

Executes echo with sudo and connected stdin, stdout and stderr to ask for the users password. This allows to use sudo for commands which internal process stdout and stderr which are not connected to the current tty.

func IsExitCode

func IsExitCode(err error, exitCode int) bool

IsExitCode checks the given error for a process exit error and if the exit code is the expected one.

func RunCmd

func RunCmd(command string, args ...string) (string, error)

RunCmd executes the given command including the current environment and returns the combined output as string.

func RunSudoCmd

func RunSudoCmd(command string, args ...string) (string, error)

RunSudoCmd executes the given command including the current environment using sudo and returns the combined output as string.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL