Documentation
¶
Overview ¶
Package shellrun runs a POSIX shell script in-process (mvdan.cc/sh), so the same script behaves identically on every OS — including Windows, where no `sh` binary is on PATH. External programs the script invokes (npm, go, docker, ...) are resolved by the interpreter's default exec handler, which uses LookPathDir: PATH search plus PATHEXT on Windows.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PortableCommands ¶
func PortableCommands() map[string]CommandFunc
PortableCommands returns in-process grep and rg (minimal) implementations for scripts that must run where those tools are absent. Supported: -q -i -s -n -F -E -r -e PATTERN, --include/--exclude/ --exclude-dir, then FILE... (directories need -r). Without -E or -F a grep pattern is a POSIX basic regular expression, as GNU grep reads it.
Types ¶
type CommandFunc ¶
type CommandFunc func(ctx context.Context, dir string, args []string, stdin io.Reader, stdout, stderr io.Writer) int
CommandFunc is an in-process command. args excludes the command name. Return an interp.ExitStatus-compatible error via ExitCode(n).
type ExitError ¶
type ExitError struct{ Code int }
ExitError is returned when the script exits non-zero.
type Options ¶
type Options struct {
// Dir is the working directory; empty inherits the process cwd.
Dir string
// Env overlays the process environment; overlay keys win.
Env map[string]string
// Stdout/Stderr default to io.Discard when nil.
Stdout, Stderr io.Writer
// Commands maps command names to in-process implementations that take
// precedence over PATH lookup (e.g. a portable grep).
Commands map[string]CommandFunc
}
Options configures one Run.