Documentation ¶
Index ¶
- Constants
- func BashifyPath(absolutePath string) (string, error)
- func BashifyPathEnv(pathList string) (string, error)
- func CmdExitCode(cmd *exec.Cmd) (code int)
- func CmdString(c *exec.Cmd) string
- func Command(name string, arg ...string) *exec.Cmd
- func DecodeCmd(cmd string) (string, []string)
- func EnvMapToSlice(envMap map[string]string) []string
- func EnvSliceToMap(envSlice []string) map[string]string
- func ExecSimple(bin string, args []string, env []string) (string, string, error)
- func ExecSimpleFromDir(dir, bin string, args []string, env []string) (string, string, error)
- func Executable() string
- func ExecutableName() string
- func ExecutablePaths(env map[string]string) ([]string, error)
- func Executables(bins []string) ([]string, error)
- func Execute(command string, arg []string, optSetter func(cmd *exec.Cmd) error) (int, *exec.Cmd, error)
- func ExecuteAndForget(command string, args []string, opts ...func(cmd *exec.Cmd) error) (*os.Process, error)
- func ExecuteAndPipeStd(command string, arg []string, env []string) (int, *exec.Cmd, error)
- func ExecuteInBackground(command string, args []string, opts ...func(cmd *exec.Cmd) error) (*exec.Cmd, *bytes.Buffer, *bytes.Buffer, error)
- func FilterExesOnPATH(executable string, PATH string, filter func(exe string) bool) []string
- func FindExeInside(executable string, PATH string) string
- func FindExeOnPATH(executable string, PATH string) string
- func Getwd() (string, error)
- func GetwdUnsafe() string
- func InheritEnv(env map[string]string) map[string]string
- func IsAccessDeniedError(err error) bool
- func IsAdmin() (bool, error)
- func IsNotExistError(err error) bool
- func NotExistError() error
- func OpenEditor(filename string) error
- func OpenURI(input string) error
- func PropagateEnv() error
- func SetStringValue(key RegistryKey, name string, valType uint32, value string) error
- func SysProcAttrForBackgroundProcess() *syscall.SysProcAttr
- func SysProcAttrForNewProcessGroup() *syscall.SysProcAttr
- func UniqueExes(exePaths []string, pathext string) ([]string, error)
- type RegistryKey
- type ShellEscape
Constants ¶
const ExeExtension = ""
const LineSep = "\n"
LineSep is the line separator character string used on the GOOS
Variables ¶
This section is empty.
Functions ¶
func BashifyPath ¶
BashifyPath takes a windows style path and turns it into a bash style path eg. C:\temp becomes /c/temp
func BashifyPathEnv ¶
func CmdExitCode ¶
CmdExitCode returns the exit code of a command
func CmdString ¶
CmdString returns a human-readable description of c. This is a copy of the Go 1.13 (cmd.String) function
func DecodeCmd ¶
DecodeCmd takes an encoded command and decodes it by returning a shell variant based on the OS we're on
func EnvMapToSlice ¶
func EnvSliceToMap ¶
func ExecSimpleFromDir ¶
func Executable ¶
func Executable() string
Executable returns the resolved path to the currently running executable.
func ExecutableName ¶
func ExecutableName() string
ExecutableName returns the name of the executable called with the extension removed and falls back to the command used to call the executable.
func Executables ¶
Executables will find all directories that contain executables from the provided list of paths
func Execute ¶
func Execute(command string, arg []string, optSetter func(cmd *exec.Cmd) error) (int, *exec.Cmd, error)
Execute will run the given command and with optional settings for the exec.Cmd struct
func ExecuteAndForget ¶
func ExecuteAndForget(command string, args []string, opts ...func(cmd *exec.Cmd) error) (*os.Process, error)
ExecuteAndForget will run the given command in the background, returning immediately.
func ExecuteAndPipeStd ¶
ExecuteAndPipeStd will run the given command and pipe stdin, stdout and stderr
func ExecuteInBackground ¶
func ExecuteInBackground(command string, args []string, opts ...func(cmd *exec.Cmd) error) (*exec.Cmd, *bytes.Buffer, *bytes.Buffer, error)
ExecuteInBackground runs the command in background and returns a buffers for stdout and stderr
func FilterExesOnPATH ¶
FindExeOnPATH returns the first path from the PATH env var for which the executable exists
func FindExeInside ¶
func FindExeOnPATH ¶
FindExeOnPATH returns the first path from the PATH env var for which the executable exists
func Getwd ¶
Getwd is an alias of os.Getwd which wraps the error in our localized error message and FailGetWd, which is user facing (doesn't get logged)
func GetwdUnsafe ¶
func GetwdUnsafe() string
func InheritEnv ¶
InheritEnv returns a union of the given environment and os.Environ(). If the given environment and os.Environ() share any environment variables, the former's will be used over the latter's.
func IsAccessDeniedError ¶
IsAccessDeniedError is primarily used to determine if an operation failed due to insufficient permissions (e.g. attempting to kill an admin process as a normal user)
func IsNotExistError ¶
func NotExistError ¶
func NotExistError() error
func OpenEditor ¶
func PropagateEnv ¶
func PropagateEnv() error
func SetStringValue ¶
func SetStringValue(key RegistryKey, name string, valType uint32, value string) error
func SysProcAttrForBackgroundProcess ¶
func SysProcAttrForBackgroundProcess() *syscall.SysProcAttr
func SysProcAttrForNewProcessGroup ¶
func SysProcAttrForNewProcessGroup() *syscall.SysProcAttr
SysProcAttrForNewProcessGroup returns a SysProcAttr structure configured to start a process with a new process group
Types ¶
type RegistryKey ¶
type RegistryKey interface { GetStringValue(name string) (val string, valtype uint32, err error) SetStringValue(name, value string) error SetExpandStringValue(name, value string) error DeleteValue(name string) error Close() error }
func CreateCurrentUserKey ¶
func CreateCurrentUserKey(path string) (RegistryKey, bool, error)
func CreateUserKey ¶
func CreateUserKey(path string) (RegistryKey, bool, error)
func OpenSystemKey ¶
func OpenSystemKey(path string) (RegistryKey, error)
func OpenUserKey ¶
func OpenUserKey(path string) (RegistryKey, error)
type ShellEscape ¶
type ShellEscape struct {
// contains filtered or unexported fields
}
ShellEscape serve to escape arguments passed to shell commands
func NewBashEscaper ¶
func NewBashEscaper() *ShellEscape
NewBashEscaper creates a new instance of ShellEscape that's configured for escaping bash style arguments
func NewBatchEscaper ¶
func NewBatchEscaper() *ShellEscape
NewBatchEscaper creates a new instance of ShellEscape that's configured for escaping batch style arguments
func NewCmdEscaper ¶
func NewCmdEscaper() *ShellEscape
NewCmdEscaper creates a new instance of ShellEscape that's configured for escaping cmd arguments
func (*ShellEscape) Escape ¶
func (s *ShellEscape) Escape(value string) string
Escape will escape any characters that require escaping for the purpose of quoting
func (*ShellEscape) EscapeLineEnd ¶
func (s *ShellEscape) EscapeLineEnd(value string) string
EscapeLineEnd will escape any line end characters that require escaping for the purpose of quoting
func (*ShellEscape) Quote ¶
func (s *ShellEscape) Quote(value string) string
Quote implements SubShell.Quote