shell

package
v0.0.0-...-f9a56e6 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package shell handles shell command execution with timeout support.

Index

Constants

View Source
const DefaultTimeout = 30

DefaultTimeout is the default command timeout in seconds.

Variables

This section is empty.

Functions

func DetectShell

func DetectShell() (string, error)

DetectShell finds an available Unix shell in PATH. Prefers bash, falls back to sh. Windows shells (cmd.exe, PowerShell) are not supported.

func IsShellAvailable

func IsShellAvailable(shell string) bool

IsShellAvailable checks if a specific shell is available.

Types

type RunResult

type RunResult struct {
	// Stdout is the standard output of the command.
	Stdout string
	// Stderr is the standard error of the command.
	Stderr string
	// ExitCode is the exit code of the command.
	ExitCode int
	// TimedOut indicates whether the command timed out.
	TimedOut bool
}

RunResult contains the result of a shell command execution.

type Runner

type Runner struct {
	// Shell is the shell command to use (e.g., "bash -c", "sh -c").
	// If empty, auto-detection is used.
	Shell string
	// Timeout is the default timeout in seconds for commands.
	// If 0, the DefaultTimeout constant is used.
	Timeout int
}

Runner executes shell commands with timeout support.

func NewRunner

func NewRunner() *Runner

NewRunner creates a new shell runner with auto-detected shell.

func (*Runner) Run

func (r *Runner) Run(command, workingDir, shell string, timeout int) (string, error)

Run executes a command and returns the output. Implements the orchestration.ShellRunner interface.

func (*Runner) RunWithResult

func (r *Runner) RunWithResult(command, workingDir, shell string, timeout int) (RunResult, error)

RunWithResult executes a command and returns detailed result.

Jump to

Keyboard shortcuts

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