shell

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 28, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package shell is the argv-only exec wrapper. Every argument is passed as a distinct argv element. No shell string is ever composed. If a downstream

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyBinary = errors.New("shell: bin is empty")

ErrEmptyBinary is returned when Exec or Capture is called with "".

Functions

func PathResolver

func PathResolver(bin string) (string, error)

PathResolver is the default resolver. Looks the binary up on $PATH.

Types

type Resolver

type Resolver func(bin string) (string, error)

Resolver turns a binary name into an executable path. Pluggable so tests can avoid touching the real $PATH.

type Runner

type Runner struct {
	Stdout io.Writer
	Stderr io.Writer
	Stdin  io.Reader
	// Resolve locates a binary. Defaults to PathResolver when nil.
	Resolve Resolver
	// Env, when non-nil, is appended to os.Environ() and passed to the
	// child as cmd.Env. Used by the egress-proxy plumbing to inject
	Env []string
}

Runner executes subprocesses on behalf of coily verbs. Build one in main with the default Resolver and plumb it through to verbs that need it.

func (*Runner) Capture

func (r *Runner) Capture(ctx context.Context, bin string, argv ...string) ([]byte, error)

Capture runs bin with argv and returns stdout as bytes. Stderr is forwarded to the Runner's Stderr (defaulting to discard if nil). Useful for verbs

func (*Runner) Exec

func (r *Runner) Exec(ctx context.Context, bin string, argv ...string) error

Exec runs bin with argv, streaming stdin/stdout/stderr through the Runner's fields. Returns the underlying exec error on failure.

func (*Runner) ExecIn

func (r *Runner) ExecIn(ctx context.Context, dir, bin string, argv ...string) error

ExecIn is like Exec but runs the child with cmd.Dir set to dir. Used by coily exec when the matched coily.yaml lives in a direct child of cwd:

Jump to

Keyboard shortcuts

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