bash

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2026 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewProcessGroupExecHandler added in v1.1.2

func NewProcessGroupExecHandler(killTimeout time.Duration) interp.ExecHandlerFunc

NewProcessGroupExecHandler returns an ExecHandlerFunc that runs external commands with proper job control. The child process is placed in its own process group and made the foreground process group of the terminal. This means:

  • When user presses Ctrl+C, SIGINT goes to the child process (not gsh)
  • The child can handle or die from SIGINT naturally
  • gsh remains unaffected and continues after the child exits

This is the standard Unix job control model used by zsh/bash for foreground jobs.

The killTimeout parameter specifies how long to wait after sending SIGINT before sending SIGKILL when the context is cancelled programmatically.

func RunBashCommand added in v0.4.0

func RunBashCommand(ctx context.Context, runner *interp.Runner, command string) (string, string, error)

RunBashCommand runs a bash command in the main runner and captures stdout/stderr. WARNING: This temporarily redirects the runner's stdio, which is not thread-safe. Consider using RunBashCommandInSubShell for safer concurrent execution.

func RunBashCommandInSubShell

func RunBashCommandInSubShell(ctx context.Context, runner *interp.Runner, command string) (string, string, error)

RunBashCommandInSubShell runs a bash command in a subshell and captures stdout/stderr. Returns stdout, stderr, and any error. Non-zero exit codes are returned as errors. Deprecated: Use RunBashCommandInSubShellWithExitCode for better exit code handling.

func RunBashCommandInSubShellWithExitCode added in v1.0.0

func RunBashCommandInSubShellWithExitCode(ctx context.Context, runner *interp.Runner, command string) (string, string, int, error)

RunBashCommandInSubShellWithExitCode runs a bash command in a subshell and captures stdout/stderr. Returns stdout, stderr, exit code, and any execution error. A non-zero exit code is NOT treated as an error - check the exit code separately.

func RunBashScriptFromFile

func RunBashScriptFromFile(ctx context.Context, runner *interp.Runner, filePath string) error

RunBashScriptFromFile parses and runs a bash script from a file. The script is executed in the provided runner (not a subshell).

func RunBashScriptFromReader

func RunBashScriptFromReader(ctx context.Context, runner *interp.Runner, reader io.Reader, name string) error

RunBashScriptFromReader parses and runs a bash script from an io.Reader. The script is executed in the provided runner (not a subshell).

Types

This section is empty.

Jump to

Keyboard shortcuts

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