shell

package
v0.65.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package shell is the binary's door to every external command that is not git; gitx stays separate because its reads mirror bin/f10-load-project.sh. Every entry point is a variable so tests can substitute it: nothing here should launch a browser or block on a pager under `go test`.

Index

Constants

This section is empty.

Variables

View Source
var Capture = func(ctx context.Context, dir, name string, args ...string) (Result, error) {
	return run(ctx, dir, nil, name, args...)
}

Capture runs name in dir. A non-zero exit is a Result, not an error, since the driver contract reserves an exit code with a meaning and classifying codes belongs to the caller; only a command that could not start is an error.

View Source
var CaptureInput = func(ctx context.Context, dir, input, name string, args ...string) (Result, error) {
	return run(ctx, dir, strings.NewReader(input), name, args...)
}

CaptureInput is Capture with input on stdin, for a driver's write verbs.

View Source
var Has = func(name string) bool {
	_, err := LookPath(name)

	return err == nil
}

Has reports whether name is on PATH.

View Source
var LookPath = exec.LookPath

LookPath finds name on PATH, as exec.LookPath does.

View Source
var Passthrough = func(ctx context.Context, dir, name string, args ...string) error {
	cmd := exec.CommandContext(ctx, name, args...)
	cmd.Dir = dir
	cmd.Stdin, cmd.Stdout, cmd.Stderr = os.Stdin, os.Stdout, os.Stderr

	return cmd.Run()
}

Passthrough runs name in dir wired straight to this process's streams. A pager, an editor and `gh --web` all want the terminal, not a buffer.

View Source
var Pipe = func(ctx context.Context, dir, input, name string, args ...string) error {
	cmd := exec.CommandContext(ctx, name, args...)
	cmd.Dir = dir
	cmd.Stdin = strings.NewReader(input)
	cmd.Stdout, cmd.Stderr = os.Stdout, os.Stderr

	return cmd.Run()
}

Pipe runs name with input on its stdin and the terminal on its output: what a pager needs.

Functions

func Detached added in v0.58.0

func Detached(exe string, args ...string) error

Detached starts exe in its own session and lets it go: it outlives the hook that starts it.

func Editor

func Editor() []string

Editor is VISUAL, EDITOR, then the OS opener, split on fields since values carry arguments ("code -w").

func EnvOf added in v0.62.0

func EnvOf(ctx context.Context) []string

EnvOf is the environment WithEnv set on ctx, nil for none.

func Group added in v0.58.0

func Group(ctx context.Context, dir, script string, waitDelay time.Duration) ([]byte, error)

Group runs script under sh -c in dir, in a process group of its own that a cancelled ctx kills whole, so the script's children die with it; waitDelay stops reading a pipe an orphan still holds. It returns the combined output.

func Opener

func Opener() string

Opener is the OS's "open this thing" command, or "" where there is none.

func WithEnv added in v0.62.0

func WithEnv(ctx context.Context, env []string) context.Context

WithEnv runs the commands Capture starts under ctx with env instead of this process's environment: the daemon calling a tool for a session it does not belong to.

Types

type Result

type Result struct {
	Stdout string
	Stderr string
	Code   int
}

A Result is one finished command: its trimmed streams and its exit code.

Jump to

Keyboard shortcuts

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