Documentation
¶
Overview ¶
Package execx provides convenience extensions to os/exec, to collect richer exit errors.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Cmdline ¶
Cmdline returns an approximation of the command line invocation equivalent to cmd. The returned string is the concatenation of filepath.Base(cmd.Path) and cmd.Args, separated by spaces.
Note that Cmdline does not produce shell-safe output, and does not account for environment variables. Cmdline should be used for strictly informative purposes, such as logging or debugging.
func Wrap ¶
Wrap wraps an *exec.ExitError in a *ExitError, decorating it with additional details about the command. For convenience, Wrap also makes the following decisions:
If err is nil, Wrap returns nil.
If err is not of type *exec.ExitError, it is returned unchanged.
If err is of type *exec.ExitError, but did not originate from cmd, it is returned unchanged.
Types ¶
type ExitError ¶
type ExitError struct { // The original ExitError returned by os/exec. *exec.ExitError // Path is the path of the command which was executed. Path string // Args holds command line arguments. Args []string // Dir holds the working directory for the child process. Dir string // ParentEnv is the environment of the parent process. ParentEnv env.Map // ChildEnv is the environment of the child process. ChildEnv env.Map }
ExitError wraps an *os/exec.ExitError with additional details.
func (*ExitError) Cmdline ¶
Cmdline returns the concatenation of filepath.Base(e.Path) and e.Args, separated by spaces. See func Cmdline.
func (*ExitError) Format ¶
Format implements fmt.Formatter for *ExitError as follows:
If the verb is anything other than 'v', Format emits no output.
For "%v", Format emits e.Cmdline(), the exit status of the process, and standard error output, if it was captured.
For "%+v", Format emits everything "%v" emits, and some additional details about the child process: its working directory, its user and system CPU time, its environment, etc.