exec

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: GPL-2.0, GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package exec provides helpers for running system commands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Has

func Has(command string) bool

Has reports whether a command exists in PATH.

func Run

func Run(command string, args ...string) error

Run executes a command with inherited stdio. Returns an error if the exit code is non-zero.

func RunCode

func RunCode(command string, args ...string) int

RunCode executes a command with inherited stdio and returns the exit code. Use this when the caller needs to branch on specific exit codes.

func RunSilent

func RunSilent(command string, args ...string) error

RunSilent executes a command, discarding stdout and stderr. Returns an error if the exit code is non-zero.

func Sh

func Sh(command string) string

Sh executes a shell string via "sh -c" and returns trimmed stdout. Errors are silently ignored — use RunCapture if you need them.

Types

type Result

type Result struct {
	ExitCode int
	Stdout   []byte
	Stderr   []byte
}

Result holds the output of a captured command.

func RunCapture

func RunCapture(command string, args ...string) (Result, error)

RunCapture executes a command and captures stdout and stderr.

Jump to

Keyboard shortcuts

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