shellconfig

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package shellconfig resolves the bash shell PiG runs commands through, mirroring upstream packages/coding-agent/src/utils/shell.ts getShellConfig and getBashShellConfig. Upstream never consults $SHELL: commands use bash syntax, so a login shell such as zsh or fish is not a substitute.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindExecutableOnPath

func FindExecutableOnPath(executable string) string

FindExecutableOnPath asks the platform lookup command for the first match of executable: `where` on Windows, where the match must also pass the access check (nodefs.Access) because `where` can report a path that does not exist, and `which` elsewhere, whose output is trusted so Termux and special file systems work. It returns "" when the command fails, times out, or finds nothing.

Ports packages/coding-agent/src/utils/shell.ts (findExecutableOnPath).

func FirstMatch

func FirstMatch(output string, windows bool, exists func(string) bool) string

FirstMatch is the first line of the lookup command's output. On Windows the path must also exist according to exists, which upstream checks with accessSync(F_OK), not existsSync, so a runnable Microsoft Store alias is found.

func IsLegacyWSLBashPath

func IsLegacyWSLBashPath(path string) bool

IsLegacyWSLBashPath mirrors upstream isLegacyWslBashPath: the path is the WSL launcher bash.exe in the System32 or Sysnative directory of the Windows directory in SystemRoot, which need not be C:\Windows.

Ports packages/coding-agent/src/utils/shell.ts (isLegacyWslBashPath).

Types

type Config

type Config struct {
	Path string
	Args []string
	// CommandTransport mirrors upstream ShellConfig.commandTransport: "stdin"
	// writes the command to the shell's stdin instead of appending it to the
	// arguments (legacy WSL bash.exe). Empty means argv.
	CommandTransport string
}

Config is the resolved shell binary and its leading arguments. The command string is appended as the final argument when spawning, unless CommandTransport is "stdin".

func Default

func Default() (Config, error)

Default resolves the shell on unix, mirroring upstream getShellConfig's unix branch (shell.ts). It never errors.

Ports packages/coding-agent/src/utils/shell.ts (getShellConfig, unix branch).

func ForBash

func ForBash(shell string) Config

ForBash mirrors upstream getBashShellConfig: legacy WSL bash reads the command from stdin, every other bash takes it after -c.

Ports packages/coding-agent/src/utils/shell.ts (getBashShellConfig).

Jump to

Keyboard shortcuts

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