shellexec

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package shellexec runs bounded shell commands with workspace-validated initial working directories and process-tree cleanup.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoShell = errors.New("shellexec: no shell found")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Root           *workspace.Root
	Shell          string
	DefaultTimeout time.Duration
	MaxTimeout     time.Duration
	KillGrace      time.Duration
	Env            []string
	ExtraEnv       map[string]string
	OutputLimit    outputlimit.Policy
}

Config defines process, environment, timeout, and output-capture policy.

type Executor

type Executor struct {
	// contains filtered or unexported fields
}

Executor holds immutable policy shared by independent command invocations.

func New

func New(cfg Config) (*Executor, error)

New validates and resolves an executor configuration.

func (*Executor) Run

func (e *Executor) Run(ctx context.Context, req Request) (*Result, error)

Run executes a command with stdout and stderr captured independently.

func (*Executor) RunMerged

func (e *Executor) RunMerged(ctx context.Context, req Request) (Result, error)

RunMerged executes a command with stdout and stderr connected to one stream, preserving the order in which the process writes to the shared descriptor.

func (*Executor) Shell

func (e *Executor) Shell() string

Shell returns the resolved shell executable.

type Request

type Request struct {
	Command string
	Dir     string
	Stdin   string
	Timeout time.Duration
}

Request describes one fresh, non-interactive shell invocation.

type Result

type Result struct {
	Stdout       string
	Stderr       string
	ExitCode     int
	Signal       string
	TimedOut     bool
	Killed       bool
	Duration     time.Duration
	Dir          string
	StdoutReport outputlimit.Report
	StderrReport outputlimit.Report
}

Result describes command output and process termination. A non-zero command exit is represented here and is not a Run error.

Jump to

Keyboard shortcuts

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