shellcmd

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package shellcmd provides unified cross-platform shell resolution and command construction shared by capabilities (sh.exec / sh.checks) and background tasks (Manager.Start).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildCommand

func BuildCommand(ctx context.Context, name, cmdLine string) (*exec.Cmd, error)

BuildCommand resolves shell `name` and builds an *exec.Cmd for `cmdLine`, using raw Win32 CmdLine for `cmd` on Windows so embedded double quotes are not mangled into `\"` by Go's argv escaper.

func BuildResolvedCommand

func BuildResolvedCommand(ctx context.Context, exe string, args []string, dialect, cmdLine string) *exec.Cmd

BuildResolvedCommand constructs an *exec.Cmd from an already-resolved (exe, args, dialect) tuple.

func ConfigureCmdLine

func ConfigureCmdLine(_ *exec.Cmd, _, _, _ string)

ConfigureCmdLine is a no-op on non-Windows platforms.

func DefaultShellName

func DefaultShellName() string

DefaultShellName returns the default shell dialect for the current OS ("pwsh" | "cmd" | "sh").

func IsNotFound

func IsNotFound(err error) bool

IsNotFound reports whether err indicates a valid shell dialect whose binary is missing on this host.

func IsWSLSystemBash

func IsWSLSystemBash(p string) bool

IsWSLSystemBash reports whether p points to the Windows WSL bash.exe launcher (e.g. C:\Windows\System32\bash.exe), which executes inside a Linux distribution rather than on the Windows host.

func Resolve

func Resolve(name string) (exe string, args []string, dialect string, err error)

Resolve maps a shell name ("" -> DefaultShellName) to its executable path, invocation args, and canonical dialect.

Types

type Error

type Error struct {
	NotFound bool
	Msg      string
}

Error classifies shell resolution failures so callers can map NotFound vs BadArgs.

func (*Error) Error

func (e *Error) Error() string

Jump to

Keyboard shortcuts

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