exec

package
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: Apache-2.0 Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cmd

type Cmd struct {
	*exec.Cmd
	Trace       bool      // Print composed command before execution.
	TraceWriter io.Writer // Where to write the trace output.
}

Cmd represents a command to be executed, with options to control its behavior. The Cmd struct embeds the standard library's exec.Cmd, adding additional fields to control the command's output and tracing.

func Command

func Command(name string, arg ...string) (*Cmd, error)

Command creates a new Cmd struct with the given name and arguments. It looks up the absolute path of the executable using execabs.LookPath, and sets up the Cmd with the necessary environment and output streams. The Cmd is configured to trace the command execution by setting Trace to true and TraceWriter to os.Stdout.

func (*Cmd) Run

func (c *Cmd) Run() error

Run runs the command and waits for it to complete. If there is an error starting the command, it is returned. Otherwise, the command is waited for and its exit status is returned.

Jump to

Keyboard shortcuts

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