Help us shape the future of Go! Take the 2026 Go Developer Survey

shell

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package shell runs a repository-owned command through the system shell. It is the one effectful edge shared by the checks the Evaluation stage adjudicates (§10, §19.2) and the sensors maintenance loops watch (§15): both run a maintainer-authored `sh -c <command>` and branch on whether it ran and how it exited. Centralizing it keeps the single gosec justification in one place — the command is repository config, never model or critic input.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NotRun

func NotRun(exitCode int, ran bool) bool

NotRun reports whether a (exitCode, ran) result means the command could not be run at all: the process never started, or the shell reported not-found (127) or not-executable (126). Callers treat this as "tool unavailable" — pointing the worker at a repair hint — distinct from a command that ran and exited non-zero.

Types

type Runner

type Runner struct{}

Runner runs a command as `sh -c <command>`. The zero value is ready to use; a caller holds it behind its own point-of-use interface so tests inject a fake.

func (Runner) Run

func (r Runner) Run(ctx context.Context, command, dir string) (exitCode int, ran bool)

Run executes command via the shell in dir (empty dir means the current directory), discarding its output. ran is false only when the process could not start — an absent shell, or a canceled context; a command that started and exited non-zero still ran, and its status is exitCode. exitCode is 0 on a clean exit and -1 when the command never ran. There is no error return: a non-zero exit is a result to branch on (a failed check, a sensed departure), not a failure of the caller.

func (Runner) RunIO

func (Runner) RunIO(
	ctx context.Context,
	command, dir string,
	stdout, stderr io.Writer,
) (exitCode int, ran bool)

RunIO is Run with the child's stdout and stderr wired to the given writers, so a caller that invokes a declared tool (§13, `adh tool run`) can surface or capture its output. A nil writer discards that stream (this is how Run works). The exitCode/ran contract is identical to Run.

Jump to

Keyboard shortcuts

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