shell

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package shell runs (sh) task bodies through the pure-Go mvdan/sh interpreter. It NEVER shells out to the system shell (Principle V), so default-task behavior is identical across Linux, macOS, and Windows. Body lines run on a single persistent Runner so cd and exported variables carry across lines.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, taskName string, lines []Line, opts Options) error

Run executes the body lines sequentially on one interpreter, echoing each command to stderr unless suppressed, honoring @ (no echo) and - (continue on error) per line, and returning an *ExecError on the first uncontinued failure.

Types

type ExecError

type ExecError struct {
	Task string
	Line string
	Span token.Span
	Code int
	Err  error
}

ExecError reports a body-line failure: the task, the offending line, and the underlying exit code (or shell error).

func (*ExecError) Error

func (e *ExecError) Error() string

func (*ExecError) Unwrap

func (e *ExecError) Unwrap() error

type Line

type Line struct {
	Text            string
	NoEcho          bool
	ContinueOnError bool
	Span            token.Span
}

Line is one interpolated body line plus its per-line sigils.

type Options

type Options struct {
	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer
	Dir    string   // working directory ("" => current)
	Env    []string // KEY=VALUE pairs (nil => inherit os.Environ)
	Quiet  bool     // suppress command echo
	// EchoStyle, if non-nil, wraps each echoed command line for display (e.g.
	// dimming). It is applied only AFTER the NoEcho/Quiet suppression check, so
	// it never causes a suppressed line to appear, and must add only zero-width
	// styling without altering the line's text.
	EchoStyle func(string) string
}

Options configures a shell run.

Jump to

Keyboard shortcuts

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