gobash

package module
v0.0.0-...-d1567f4 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2026 License: MIT Imports: 25 Imported by: 0

README

go-bash

A virtual bash environment with an in-memory filesystem, written in Go and designed for AI agents.

Broad support for standard Unix commands and bash syntax with optional network access, SQLite, and (planned) JavaScript and Python runtimes.

go-bash is inspired by just-bash (TypeScript) — similar bash constructs, builtin set, and VFS shape — but running in-process under a Go runtime, with CGO_ENABLED=0 builds and no os/exec reachable from script context.

Note: This is beta software. The public API is stable, but byte-level output of some builtins may shift as we close gaps against real bash. Pin a version in go.mod. See security model.

Quick Start

go get github.com/mark3labs/go-bash@latest
package main

import (
    "context"
    "fmt"

    gobash "github.com/mark3labs/go-bash"
)

func main() {
    ctx := context.Background()
    b, _ := gobash.New(gobash.BashOptions{})
    _, _ = b.Exec(ctx, `echo "Hello" > greeting.txt`, gobash.ExecOptions{})
    res, _ := b.Exec(ctx, "cat greeting.txt", gobash.ExecOptions{})
    fmt.Println(res.Stdout)   // "Hello\n"
    fmt.Println(res.ExitCode) // 0
}

Each Exec() call gets its own isolated shell state — environment variables, functions, and working directory reset between calls. The filesystem is shared across calls, so files written in one Exec() are visible in the next.

Custom Commands

Extend go-bash with your own Go commands using command.Define:

import (
    "context"
    "fmt"
    "io"
    "strings"

    gobash "github.com/mark3labs/go-bash"
    "github.com/mark3labs/go-bash/command"
)

hello := command.Define("hello", func(ctx context.Context, args []string, c *command.Context) command.Result {
    name := "world"
    if len(args) > 1 {
        name = args[1]
    }
    fmt.Fprintf(c.Stdout, "Hello, %s!\n", name)
    return command.Result{ExitCode: 0}
})

upper := command.Define("upper", func(ctx context.Context, args []string, c *command.Context) command.Result {
    data, _ := io.ReadAll(c.Stdin)
    fmt.Fprint(c.Stdout, strings.ToUpper(string(data)))
    return command.Result{ExitCode: 0}
})

b, _ := gobash.New(gobash.BashOptions{
    CustomCommands: []command.Command{hello, upper},
})

b.Exec(ctx, "hello Alice", gobash.ExecOptions{})    // "Hello, Alice!\n"
b.Exec(ctx, "echo 'test' | upper", gobash.ExecOptions{}) // "TEST\n"

Custom commands receive a command.Context with FS, Cwd, Env, Stdin, Stdout, Stderr, Fetch (network Doer), and Exec (for sub-shell invocation). They participate in pipes, redirections, exit-code semantics, and set -e propagation like any builtin.

Custom commands override builtins with the same name — useful for swapping in a stricter curl or a tracing cat.

Supported Commands

Click to expand the full builtin list
File Operations

cat, cp, file, ln, ls, mkdir, mv, readlink, rm, rmdir, split, stat, touch, tree

Text Processing

awk, base64, column, comm, cut, diff, expand, fold, grep (+ egrep, fgrep), head, join, md5sum, nl, od, paste, printf, rev, rg, sed, sha1sum, sha256sum, sort, strings, tac, tail, tr, unexpand, uniq, wc, xargs

Data Processing

jq (JSON), sqlite3 (SQLite — opt-in via sqlite subpackage for the real runtime), xan (CSV), yq (YAML/XML/TOML/CSV)

Optional Runtimes
  • sqlite3 — pure-Go modernc.org/sqlite, opt-in via sqlite.Register
  • js-exec (JavaScript) — planned
  • python3 / pythonplanned
Compression & Archives

gzip (+ gunzip, zcat), tar

Navigation & Environment

basename, cd, dirname, du, echo, env, export, find, hostname, printenv, pwd, tee

Shell Utilities

alias, bash, chmod, clear, date, expr, false, help, history, seq, sh, sleep, time, timeout, true, unalias, which, whoami

Network

curl, html-to-markdown (require network configuration)

All commands support --help for usage information.

Shell Features
  • Pipes: cmd1 | cmd2
  • Redirections: >, >>, 2>, 2>&1, <, heredocs
  • Command chaining: &&, ||, ;
  • Variables: $VAR, ${VAR}, ${VAR:-default}, arrays
  • Positional parameters: $1, $2, $@, $#
  • Glob patterns: *, ?, [...], ** (with globstar)
  • Brace expansion: {1..10}, {a,b,c}
  • Command substitution: $(cmd), `cmd`
  • Process substitution: <(cmd), >(cmd)
  • If statements: if COND; then CMD; elif COND; then CMD; else CMD; fi
  • Functions: function name { ... } or name() { ... }
  • Local variables: local VAR=value
  • Loops: for, while, until
  • Symbolic links: ln -s target link
  • Hard links: ln target link
  • Source / .: source script.sh, . script.sh
  • Eval: eval "..."
  • Aliases: alias name='cmd', controlled by shopt expand_aliases
  • Shell options: shopt, set -e, set -u, set -o pipefail

Configuration

b, _ := gobash.New(gobash.BashOptions{
    // Initial files seeded into the in-memory FS.
    Files: map[string]gobash.FileInit{
        "/data/file.txt": {Content: []byte("content")},
    },
    // Initial environment.
    Env: map[string]string{"MY_VAR": "value"},
    // Starting directory (default: /home/user).
    Cwd: "/app",
    // Execution limits — see "Execution Protection" below.
    ExecutionLimits: &gobash.ExecutionLimits{
        MaxCallDepth: intPtr(50),
    },
})

// Per-Exec overrides.
b.Exec(ctx, "echo $TEMP", gobash.ExecOptions{
    Env: map[string]string{"TEMP": "value"},
    Cwd: "/tmp",
})

// Pass stdin to the script.
b.Exec(ctx, "cat", gobash.ExecOptions{
    Stdin: strings.NewReader("hello from stdin\n"),
})

// Start with a clean environment.
b.Exec(ctx, "env", gobash.ExecOptions{
    ReplaceEnv: true,
    Env:        map[string]string{"ONLY": "this"},
})

// Pass arguments without shell escaping (like spawnSync).
b.Exec(ctx, "grep", gobash.ExecOptions{
    Args: []string{"-r", "TODO", "src/"},
})

// Cancel long-running scripts via context.
ctx, cancel := context.WithTimeout(parent, 5*time.Second)
defer cancel()
b.Exec(ctx, "while true; do sleep 1; done", gobash.ExecOptions{})
Timezone

date defaults to UTC (%Z=UTC, %z=+0000) regardless of the host clock, so the sandbox does not leak the host timezone. To opt into a specific zone, pass TZ as an initial env var:

b, _ := gobash.New(gobash.BashOptions{
    Env: map[string]string{"TZ": "America/New_York"},
})
b.Exec(ctx, "date", gobash.ExecOptions{})
// Mon Jun  1 09:30:00 EDT 2026

-u always forces UTC; an unset or invalid $TZ falls back to UTC. Setting TZ exposes that timezone to scripts running in the sandbox, so only pass a value you are comfortable revealing — forwarding the host's real $TZ (e.g. os.Getenv("TZ")) reintroduces the disclosure that the UTC default exists to prevent.

Exec Options
Option Type Description
Env map[string]string Environment variables for this execution only
Cwd string Working directory for this execution only
Stdin io.Reader Standard input passed to the script
Stdout io.Writer Where stdout goes; nil → captured into ExecResult.Stdout
Stderr io.Writer Where stderr goes; nil → captured into ExecResult.Stderr
Args []string Additional argv passed directly to the first command (bypasses shell parsing; does not change $1, $2, ...)
ReplaceEnv bool Start with empty env instead of merging (default: false)
RawScript bool Skip leading-whitespace normalization (default: false)

Cancellation is via context.Context — the first argument to Exec.

Filesystem Options

Four filesystem implementations:

memfs (default) — pure in-memory filesystem, no disk access:

import gobash "github.com/mark3labs/go-bash"

b, _ := gobash.New(gobash.BashOptions{
    Files: map[string]gobash.FileInit{
        "/data/config.json": {Content: []byte(`{"key": "value"}`)},
        // Lazy: called on first read, cached. Never called if written before read.
        "/data/large.csv": {Lazy: func(ctx context.Context) ([]byte, error) {
            return []byte("col1,col2\na,b\n"), nil
        }},
        // Remote: fetch on first read.
        "/data/remote.txt": {Lazy: func(ctx context.Context) ([]byte, error) {
            resp, err := http.Get("https://example.com")
            if err != nil { return nil, err }
            defer resp.Body.Close()
            return io.ReadAll(resp.Body)
        }},
    },
})

overlayfs — copy-on-write over a real directory. Reads come from disk, writes stay in memory:

import (
    gobash "github.com/mark3labs/go-bash"
    "github.com/mark3labs/go-bash/fs/overlayfs"
)

overlay, _ := overlayfs.New(overlayfs.Options{Root: "/path/to/project"})
b, _ := gobash.New(gobash.BashOptions{FS: overlay, Cwd: "/path/to/project"})

b.Exec(ctx, "cat package.json", gobash.ExecOptions{})      // reads from disk
b.Exec(ctx, `echo "modified" > package.json`, gobash.ExecOptions{}) // in memory

rwfs — direct read-write access to a real directory. Use this if you want the agent to be able to write to your disk:

import "github.com/mark3labs/go-bash/fs/rwfs"

rw, _ := rwfs.New(rwfs.Options{Root: "/path/to/sandbox"})
b, _ := gobash.New(gobash.BashOptions{FS: rw})

b.Exec(ctx, `echo "hello" > file.txt`, gobash.ExecOptions{}) // writes to real disk

Keep rwfs pointed at a workspace directory, not at the installed go-bash module or any other trusted runtime code. Guest-writable roots should stay separate from trusted code.

mountfs — mount multiple filesystems at different paths. Combines read-only and read-write filesystems into a unified namespace:

import (
    "github.com/mark3labs/go-bash/fs/memfs"
    "github.com/mark3labs/go-bash/fs/mountfs"
    "github.com/mark3labs/go-bash/fs/overlayfs"
    "github.com/mark3labs/go-bash/fs/rwfs"
)

// Set up the base + mounts.
ro, _ := overlayfs.New(overlayfs.Options{Root: "/path/to/knowledge", ReadOnly: true})
rw, _ := rwfs.New(rwfs.Options{Root: "/path/to/workspace"})
m, _ := mountfs.New(mountfs.Options{
    Base: memfs.New(),
    Mounts: []mountfs.Mount{
        {Path: "/mnt/knowledge", FileSystem: ro},
        {Path: "/home/agent", FileSystem: rw},
    },
})

b, _ := gobash.New(gobash.BashOptions{FS: m, Cwd: "/home/agent"})

b.Exec(ctx, "ls /mnt/knowledge", gobash.ExecOptions{})       // from knowledge base
b.Exec(ctx, "cp /mnt/knowledge/doc.txt ./", gobash.ExecOptions{}) // cross-mount copy
b.Exec(ctx, `echo "notes" > notes.txt`, gobash.ExecOptions{}) // writes to workspace

Optional Capabilities

Network Access

Network access is disabled by default. Enable it with the Network option:

import "github.com/mark3labs/go-bash/network"

// Allow specific URLs with GET/HEAD only (safest).
b, _ := gobash.New(gobash.BashOptions{
    Network: &network.Config{
        AllowedURLPrefixes: []network.AllowedURLEntry{
            {URL: "https://api.github.com/repos/myorg/"},
            {URL: "https://api.example.com"},
        },
    },
})

// Allow specific URLs with additional methods.
b, _ = gobash.New(gobash.BashOptions{
    Network: &network.Config{
        AllowedURLPrefixes: []network.AllowedURLEntry{
            {URL: "https://api.example.com"},
        },
        AllowedMethods: []string{"GET", "HEAD", "POST"}, // default: ["GET", "HEAD"]
    },
})

// Inject credentials via header transforms (secrets never enter the sandbox).
b, _ = gobash.New(gobash.BashOptions{
    Network: &network.Config{
        AllowedURLPrefixes: []network.AllowedURLEntry{
            {URL: "https://public-api.com"}, // no transforms
            {
                URL: "https://ai-gateway.vercel.sh",
                Transform: []network.RequestTransform{{
                    Headers: map[string]string{
                        "Authorization": "Bearer " + os.Getenv("API_TOKEN"),
                    },
                }},
            },
        },
    },
})

// Allow all URLs and methods (use with caution).
b, _ = gobash.New(gobash.BashOptions{
    Network: &network.Config{DangerouslyAllowFullAccess: true},
})

Note: The curl command exists in the registry whether or not network is configured. With no network config, curl returns "network disabled" and exits non-zero.

Allow-List Security

The allow-list enforces:

  • Origin matching: URLs must match the exact origin (scheme + host + port)
  • Path prefix: Only paths starting with the specified prefix are allowed (case-sensitive)
  • HTTP method restrictions: Only GET and HEAD by default (configure AllowedMethods for more)
  • Redirect protection: Redirects to non-allowed URLs are blocked; the allow-list is re-checked at every hop
  • Header transforms: Headers in Transform are injected at the fetch boundary and override any user-supplied headers with the same name, preventing credential substitution from inside the sandbox. Headers are re-evaluated on each redirect so credentials are never leaked to non-transform hosts.
  • Private-range deny: When DenyPrivateRanges: true, the resolver rejects RFC-1918 / link-local / loopback addresses before dial, blocking SSRF to cloud metadata endpoints.
Using curl
# Fetch and process data
curl -s https://api.example.com/data | grep pattern

# Download and convert HTML to Markdown
curl -s https://example.com | html-to-markdown

# POST JSON data
curl -X POST -H "Content-Type: application/json" \
  -d '{"key":"value"}' https://api.example.com/endpoint
SQLite Support

The sqlite3 builtin ships as a stub in the default registry. For the real runtime (pure-Go modernc.org/sqlite), import the sqlite subpackage and call Register:

import gbsqlite "github.com/mark3labs/go-bash/sqlite"

b, _ := gobash.New(gobash.BashOptions{})
_ = gbsqlite.Register(b, gbsqlite.Options{Timeout: 5 * time.Second})

// Query in-memory database
b.Exec(ctx, `sqlite3 :memory: "SELECT 1 + 1"`, gobash.ExecOptions{})

// Query file-based database
b.Exec(ctx, `sqlite3 data.db "SELECT * FROM users"`, gobash.ExecOptions{})

File DBs shuttle through os.MkdirTemp for the query duration and write back to the VFS via c.FS.WriteFile on cleanup. Concurrent writers race the cleanup; last writer wins.

Queries run with a configurable timeout (default 5 s) enforced via context.WithTimeout + a goroutine that closes the DB on ctx.Done().

JavaScript Support

Planned. When implemented, the jsexec/ subpackage will provide js-exec backed by github.com/dop251/goja (pure Go, no cgo). The TS port uses QuickJS; the Go port will use goja for the same CGO_ENABLED=0 guarantee.

Python Support

Planned. Unlike just-bash (which embeds CPython compiled to WASM), go-bash will NOT embed CPython. The pythonexec/ subpackage will expose a Runtime interface that the host implements — typically by routing to docker run python:3.13 or a real python3 binary the host opts into. This is an intentional divergence; see DECISIONS.md for the rationale.

AST Transform Plugins

Parse bash scripts into an AST, transform them, and serialize back to bash. Good for instrumenting scripts (e.g., capturing per-command stdout/stderr) or extracting metadata before execution.

import (
    gobash "github.com/mark3labs/go-bash"
    "github.com/mark3labs/go-bash/transform"
    "github.com/mark3labs/go-bash/transform/plugins/collector"
    "github.com/mark3labs/go-bash/transform/plugins/tee"
)

// Standalone pipeline — output can be run by any shell.
pipeline := transform.New()
pipeline.Use(tee.New(tee.Options{OutputDir: "/tmp/logs"}))
pipeline.Use(collector.New())
result, _ := pipeline.Transform("echo hello | grep hello")
result.Script                                // transformed bash string
result.Metadata["command-collector"]        // {"commands": ["echo", "grep", "tee"]}

// Integrated API — Exec() auto-applies transforms and returns metadata.
b, _ := gobash.New(gobash.BashOptions{})
b.RegisterTransformPlugin(collector.New())
res, _ := b.Exec(ctx, "echo hello | grep hello", gobash.ExecOptions{})
res.Metadata["command-collector"]            // {"commands": ["echo", "grep"]}

See the package docs for the full API, built-in plugins, and how to write custom plugins.

Sandbox API

The sandbox/ subpackage is a drop-in replacement for @vercel/sandbox — same API surface, but runs entirely in-process with the virtual filesystem. Start with go-bash for development and testing, swap in a real sandbox when you need a full VM.

import "github.com/mark3labs/go-bash/sandbox"

sb, _ := sandbox.Create(ctx, sandbox.Options{Cwd: "/app"})

// Write files to the virtual filesystem.
sb.WriteFiles(ctx, map[string]string{
    "/app/script.sh": `echo "Hello World"`,
    "/app/data.json": `{"key": "value"}`,
})

// Run commands and get results.
cmd, _ := sb.RunCommand(ctx, sandbox.RunCommandParams{
    Cmd:  "bash",
    Args: []string{"/app/script.sh"},
})
stdout, _ := cmd.Stdout()    // "Hello World\n"
fin, _ := cmd.Wait()
fmt.Println(fin.ExitCode)    // 0

// Read files back.
content, _ := sb.ReadFile(ctx, "/app/data.json")

// Create directories.
sb.MkDir(ctx, "/app/logs", sandbox.MkDirOptions{Recursive: true})

// Clean up (no-op for Bash, but API-compatible).
sb.Stop(ctx)

CLI

CLI Binary

Install globally for a sandboxed CLI:

go install github.com/mark3labs/go-bash/cmd/gobash@latest

# Execute inline script.
gobash -c 'ls -la && cat package.json | head -5'

# Execute with specific project root.
gobash -c 'grep -r "TODO" src/' --root /path/to/project

# Pipe script from stdin.
echo 'find . -name "*.go" | wc -l' | gobash

# Execute a script file.
gobash ./scripts/deploy.sh

# Get JSON output for programmatic use.
gobash -c 'echo hello' --json
# {"stdout":"hello\n","stderr":"","exitCode":0}

The CLI uses overlayfs — reads come from the real filesystem, but all writes stay in memory and are discarded after execution (unless --allow-write is supplied).

Important: The project root is mounted at /home/user/project. Use this path (or relative paths from the default cwd) to access your files inside the sandbox.

Options:

Flag Description
-c <script> Execute script from argument
--root <path> Root directory (default: current directory)
--cwd <path> Working directory in sandbox (default: project mount point)
--allow-write Allow write operations (default: read-only)
--python Accept the flag for just-bash compat (no-op until Phase 16)
--javascript Accept the flag for just-bash compat (no-op until Phase 15)
-e, --errexit Exit on first error
--json Output as JSON
--no-network Explicitly disable network (default)
--network-allow PREFIX Allow network requests to PREFIX (repeatable; go-bash-specific)
-h, --help Show help
-v, --version Show version

The flags are a strict superset of just-bash's CLI — every invocation that works against just-bash works against gobash, with go-bash-specific additions (--no-network, --network-allow) documented above.

Execution Protection

go-bash protects against infinite loops, deep recursion, and runaway output with configurable limits:

b, _ := gobash.New(gobash.BashOptions{
    ExecutionLimits: &gobash.ExecutionLimits{
        MaxCallDepth:      intPtr(100),
        MaxCommandCount:   intPtr(10000),
        MaxLoopIterations: intPtr(10000),
        MaxAwkIterations:  intPtr(10000),
        MaxSedIterations:  intPtr(10000),
    },
})

All limits have defaults. Error messages tell you which limit was hit via *gobash.ExecutionLimitError — use errors.As to inspect.

Field Default
MaxCallDepth 100
MaxCommandCount 10 000
MaxLoopIterations 10 000
MaxAwkIterations 10 000
MaxSedIterations 10 000
MaxJqIterations 10 000
MaxSqliteTimeout 5 s
MaxPythonTimeout 10 s
MaxJsTimeout 10 s
MaxGlobOperations 100 000
MaxStringLength 10 MiB
MaxArrayElements 100 000
MaxHeredocSize 10 MiB
MaxSubstitutionDepth 50
MaxBraceExpansionResults 10 000
MaxOutputSize 10 MiB
MaxFileDescriptors 1024
MaxSourceDepth 100

Security Model

  • The shell only has access to the provided filesystem.
  • All execution happens in-process, without VM isolation. The code base is designed to be robust against the structural attacks that JavaScript-based sandboxes have to defend against (prototype pollution, eval, dynamic import()) — those vectors do not exist in Go.
  • There is no network access by default. When enabled, requests are checked against URL prefix allow-lists and HTTP-method allow-lists at every hop.
  • Python and JavaScript execution are off by default — those are opt-in subpackages that represent additional security surface.
  • Execution is protected against infinite loops, deep recursion, and runaway output with configurable limits.
  • os/exec is not imported in the runtime package — no code path exists from the script to a host process.
  • Use a real container (Vercel Sandbox, Firecracker, etc.) if you need a full VM with arbitrary binary execution.

See THREAT_MODEL.md for the full threat model, including a "What Go gives us for free" section explaining the structural advantages over the TypeScript reference implementation.

Default Layout

When created without options, Bash provides a Unix-like directory structure:

  • /home/user — default working directory (and $HOME)
  • /bin — contains stubs for all built-in commands
  • /usr/bin — additional binary directory
  • /tmp — temporary files directory
  • /etc/hostname — synthesized hostname
  • /proc/self/status — synthesized procfs entry with virtualized PID / UID

Commands can be invoked by path (e.g., /bin/ls) or by name.

AI Agent Instructions

For AI agents wiring go-bash into a tool-use loop, see AGENTS.md — it covers the standard agent-tool setup, filesystem choices, network policy, custom commands, and common failure modes you'll want to surface back to the model.

Status

go-bash is feature-complete for its core runtime, builtins, sandbox API, and CLI:

Area Status
Runtime + builtins Complete
SQLite runtime Complete
Sandbox API Complete
CLI Complete
JavaScript runtime (via goja) Deferred
Python runtime (via host hook) Pending

Contributing

If you're working on go-bash internals (not using it as a library), start with AGENTS.md and the package-level docs.

License

MIT. See LICENSE.

Documentation

Overview

Package gobash provides a sandboxed bash environment with a virtual filesystem.

gobash is a feature-for-feature Go port of the just-bash TypeScript interpreter (github.com/vercel-labs/just-bash). The public surface, the phase-by-phase build plan, and the resolved design decisions live in The spec at the repository root.

Phase 1 status

Only the public skeleton is implemented: Bash, BashOptions, ExecOptions, BashExecResult, the limits/error types, and a stub Exec that delegates to mvdan.cc/sh/v3. The virtual filesystem (Phase 3), command registry (Phase 8), and network layer (Phase 9) are not yet wired. Until the virtual filesystem lands, file operations in scripts hit the host disk through mvdan/sh's default handlers.

Concurrency

A *Bash is safe for concurrent Exec calls; calls serialize on an internal mutex.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AbortedError

type AbortedError struct {
	Reason string
}

AbortedError is returned when execution was aborted for a reason other than a limit or context cancellation (for example, a transform-plugin veto).

func (*AbortedError) Error

func (e *AbortedError) Error() string

type ArithmeticError

type ArithmeticError struct {
	Msg string
}

ArithmeticError reports an arithmetic-expansion failure such as division by zero or an unparseable expression inside $((…)).

func (*ArithmeticError) Error

func (e *ArithmeticError) Error() string

type Bash

type Bash struct {
	// contains filtered or unexported fields
}

Bash is a reusable shell environment. Concurrent Exec calls on a single *Bash are safe; they serialize on an internal mutex.

Phase 5 scope

Parsing now goes through gobash/parser.Parse (which already enforces the §4.2 parser-side hard limits), and the mvdan/sh runner is built by gobash/interp.BuildRunner — moving the VFS handlers, the commandExecHandler middleware, and the runner.Dir-not-interp.Dir quirk out of bash.go and into the bridge package. Bash.Exec still owns: per-call limit state (CallHandler closure + MaxOutputSize ringbuf), env-mutation propagation across Exec calls, the loop-sentinel AST rewrite, and the final result shape.

Still missing (per build order): command registry (Phase 8), network (Phase 9), built-in commands (Phases 10–11). Until the registry lands, the commandExecHandler stub in the interp package falls through to mvdan/sh's DefaultExecHandler, which means unknown commands still reach the host via os/exec. That is the explicit gap Phase 8 closes.

func New

func New(opts BashOptions) (*Bash, error)

New constructs a Bash environment from the supplied options. The zero value of BashOptions is valid and yields sane defaults; New returns a non-nil error only when option validation fails (no failure modes exist in Phases 1–2).

func (*Bash) Aliases

func (b *Bash) Aliases() command.AliasTable

Aliases returns the live per-Bash alias table. Hosts can use this to seed aliases before running scripts; the `alias` / `unalias` built-ins read and mutate the same table.

func (*Bash) Exec

func (b *Bash) Exec(ctx context.Context, script string, opts ExecOptions) (BashExecResult, error)

Exec parses and runs a bash script against this environment.

A non-zero exit code is reported via BashExecResult.ExitCode and does NOT produce a non-nil error. The returned error is reserved for harness failures: parse errors (*ParseError), execution-limit overruns (*ExecutionLimitError), context cancellation (context.Canceled / context.DeadlineExceeded), and host-side I/O failures.

Concurrent Exec calls on the same *Bash serialize via an internal mutex.

Per the resolved decisions in the spec, background jobs (`&`) and `wait` run synchronously with virtual PIDs; `wait` is a no-op. Function definitions made inside a script live only for that Exec.

The following limits from the spec are enforced in this phase: MaxCommandCount, MaxLoopIterations, MaxCallDepth, MaxOutputSize. The remaining limits land in their owning phases (Phase 4 for expansion caps, Phase 11 for source-depth via the source/. builtin, etc.).

func (*Bash) FS

func (b *Bash) FS() gbfs.FileSystem

FS returns the virtual filesystem this Bash is bound to. Useful for host-side inspection or post-Exec assertions in tests.

func (*Bash) History

func (b *Bash) History() command.HistoryRing

History returns the live per-Bash command history ring. The runtime does NOT currently push parsed commands into the ring; hosts can populate it (or read from the `history` built-in's view) directly.

func (*Bash) RegisterTransformPlugin

func (b *Bash) RegisterTransformPlugin(p transform.Plugin)

RegisterTransformPlugin appends a transform-pipeline plugin to the per-Bash plugin slice. The plugin runs on every subsequent Exec call (parse → plugins → serialize → re-parse → run) and its metadata payload is surfaced in BashExecResult.Metadata under the plugin's Name().

Calls to RegisterTransformPlugin acquire b.mu, so it is safe to call concurrently from outside Exec. Calling from inside a plugin's own Transform method or from a custom command's Run (which both hold b.mu) will deadlock — don't do that.

func (*Bash) Registry

func (b *Bash) Registry() *command.Registry

Registry returns the command dispatch registry. The returned pointer is the live registry consulted by every Exec call; mutating it between calls is supported (additional Register calls will be honored by subsequent Execs). Concurrent Register calls are NOT safe — if a host needs that, wrap your own mutex around the Register sites.

func (*Bash) Shopt

func (b *Bash) Shopt() command.ShoptTable

Shopt returns the live per-Bash shell-option table. Hosts can pre-seed options (e.g. `expand_aliases`) before running scripts; the `shopt` builtin reads and mutates the same table.

type BashExecResult

type BashExecResult struct {
	ExecResult
	Env      map[string]string
	Metadata map[string]any
}

BashExecResult is the result type returned by Bash.Exec. It embeds ExecResult and adds the post-execution exported environment plus a free-form Metadata bag populated by registered transform plugins (Phase 13).

type BashOptions

type BashOptions struct {
	Env             map[string]string
	Cwd             string
	ExecutionLimits *ExecutionLimits
	Python          *PythonConfig
	JavaScript      *JavaScriptConfig
	Sleep           SleepFunc
	Logger          Logger
	Trace           TraceFunc
	ProcessInfo     *ProcessInfo

	// Files seeds the initial in-memory filesystem with the given
	// path → FileInit entries. When FS is also supplied, Files is
	// applied to that FileSystem instead of constructing a new memfs.
	Files map[string]fs.FileInit

	// FS replaces the default in-memory filesystem. When nil, gobash
	// creates an empty memfs.FS at construction time. When non-nil,
	// any Files entries are applied to FS via the FileSystem methods.
	FS fs.FileSystem

	// Commands restricts which built-in commands are registered. A
	// nil slice registers every built-in (the default); a non-nil
	// slice filters to exactly the named subset. CustomCommands are
	// NOT filtered through this list — they always register.
	//
	// Phase 8 lands the filter wiring; Phase 10 lands the built-ins
	// the filter actually selects from. Until Phase 10 the only
	// observable effect is on Bash.Registry().Names() and the
	// derived the spec /bin/X stub set.
	Commands []command.Name

	// CustomCommands override or extend the built-in registry. Each
	// entry is registered last, so any name collision with a built-in
	// is resolved in favor of the CustomCommand. Tests use this hook
	// to inject deterministic sample commands without touching the
	// built-in registration order.
	CustomCommands []command.Command

	// Fetch is the network Doer used by Phase 10's `curl` and any
	// future network-touching built-in. When non-nil it overrides
	// the default SecureFetch built from Network; tests use this hook
	// to inject stub Doers. When nil, gobash falls back to
	// network.NewSecureFetch(Network). Combining Fetch != nil with
	// Network != nil is legal: Network is ignored.
	Fetch network.Doer

	// Network is the allow-list and policy used to build the default
	// SecureFetch Doer when Fetch is nil. When both Fetch and Network
	// are nil, command.Context.Fetch is nil at dispatch time and
	// network-touching built-ins must error out cleanly.
	Network *network.Config

	// TransformPlugins is the ordered list of transform-pipeline
	// plugins applied to every Exec call on this Bash. The plugins
	// are appended to the per-Bash slice at New() time; hosts can
	// add more later via Bash.RegisterTransformPlugin. Each plugin's
	// metadata payload surfaces in BashExecResult.Metadata under the
	// plugin's Name(). When the slice is empty, Exec runs the
	// fast-path that skips the parse → serialize → re-parse round
	// trip entirely (no observable effect from Phase 13).
	TransformPlugins []transform.Plugin

	// Deprecated convenience knobs — honored to match the just-bash TS
	// surface. Prefer ExecutionLimits.
	MaxCallDepth      int
	MaxCommandCount   int
	MaxLoopIterations int
}

BashOptions configures a Bash environment at construction time.

Phase 1 wires only the fields whose types are defined in this package. Subsequent phases extend this struct in place —:

  • Phase 3 added Files (map[string]FileInit) and FS (fs.FileSystem)
  • Phase 8 added Commands ([]command.Name) and CustomCommands
  • Phase 9 adds Fetch (network.Doer) and Network (*network.Config)

All adds are field-only; existing fields keep their names and meaning.

type ExecOptions

type ExecOptions struct {
	Env        map[string]string
	ReplaceEnv bool
	Cwd        string
	RawScript  bool
	Stdin      io.Reader
	Stdout     io.Writer
	Stderr     io.Writer
	// Args is appended to the first command bypassing parsing. Wiring
	// lands in Phase 5 alongside the interpreter bridge; declared here
	// to freeze the public surface.
	Args []string
}

ExecOptions configures a single Exec call. Per-call settings override the per-Bash defaults.

type ExecResult

type ExecResult struct {
	Stdout   string
	Stderr   string
	ExitCode int
}

ExecResult is the basic outcome of a script execution. A non-zero ExitCode is not, by itself, an error.

type ExecutionLimitError

type ExecutionLimitError struct {
	Limit string
	Value int
}

ExecutionLimitError is returned by Exec when a script trips an execution limit threshold. Use errors.As to extract the offending Limit name and the configured Value at the time of the failure.

Enforcement of each limit lands across multiple phases (counters live in Phase 2, expansion-side caps in Phase 4); the error type itself is part of the Phase 1 public surface.

func (*ExecutionLimitError) Error

func (e *ExecutionLimitError) Error() string

type ExecutionLimits

type ExecutionLimits struct {
	MaxCallDepth             *int
	MaxCommandCount          *int
	MaxLoopIterations        *int
	MaxAwkIterations         *int
	MaxSedIterations         *int
	MaxJqIterations          *int
	MaxSqliteTimeout         *time.Duration
	MaxPythonTimeout         *time.Duration
	MaxJsTimeout             *time.Duration
	MaxGlobOperations        *int
	MaxStringLength          *int
	MaxArrayElements         *int
	MaxHeredocSize           *int
	MaxSubstitutionDepth     *int
	MaxBraceExpansionResults *int
	MaxOutputSize            *int
	MaxFileDescriptors       *int
	MaxSourceDepth           *int
}

ExecutionLimits caps script behavior. A nil field falls through to the documented default; a non-nil pointer field overrides per-construction. The full default table is frozen in the spec

type ExitError

type ExitError struct {
	Code int
}

ExitError is the internal signal raised by the `exit N` builtin. The runtime translates it into BashExecResult.ExitCode at the Exec boundary; it is therefore rarely observed by callers but is exported for parity with the just-bash error class.

func (*ExitError) Error

func (e *ExitError) Error() string

type InvokeToolFunc

type InvokeToolFunc = command.InvokeToolFunc

InvokeToolFunc is the host hook invoked from JavaScript-side tool calls. It returns the tool's JSON-serialized result. Aliased to command.InvokeToolFunc.

type JavaScriptConfig

type JavaScriptConfig struct {
	Bootstrap  string
	InvokeTool InvokeToolFunc
}

JavaScriptConfig configures the opt-in JavaScript runtime (Phase 15).

type LexerError

type LexerError struct {
	Msg  string
	Line int
	Col  int
}

LexerError reports a lexer/tokenizer-level failure.

func (*LexerError) Error

func (e *LexerError) Error() string

type Logger

type Logger interface {
	Info(msg string, fields map[string]any)
	Debug(msg string, fields map[string]any)
}

Logger receives structured log records emitted by the runtime.

type ParseError

type ParseError = parser.ParseError

ParseError is the typed error returned by the parser front-end. It is defined in the parser subpackage and re-exported here via a type alias so existing call sites and tests that reference gobash.ParseError continue to compile unchanged.

Consumers should match it with errors.As against either spelling.

type PosixFatalError

type PosixFatalError struct {
	Msg  string
	Code int
}

PosixFatalError signals a POSIX-mode fatal shell error (e.g. `set -e` hitting a non-zero command in a POSIX-mandated context).

func (*PosixFatalError) Error

func (e *PosixFatalError) Error() string

type ProcessInfo

type ProcessInfo struct {
	PID  int
	PPID int
	UID  int
	GID  int
}

ProcessInfo carries virtualized process identifiers exposed to scripts via $$, $PPID, etc. Zero value yields the package defaults (see The spec: PID=1, PPID=0, UID=1000, GID=1000).

type PythonConfig

type PythonConfig struct{}

PythonConfig configures the opt-in Python hook (Phase 16). The Runtime field is added in Phase 16 once the PythonRuntime interface is defined; the zero value here exists so callers can pass *PythonConfig today without breaking when the field is introduced.

type ResolvedLimits

type ResolvedLimits = command.Limits

ResolvedLimits is ExecutionLimits with all defaults applied. The runtime threads a value of this type rather than ExecutionLimits so internal callsites never have to nil-check.

As of Phase 10 ResolvedLimits is a type alias for command.Limits so the dispatch Context can carry the same struct without conversion; the alias keeps the gobash.ResolvedLimits public surface stable.

func DefaultLimits

func DefaultLimits() ResolvedLimits

DefaultLimits returns the fully-resolved default execution limits. The values are law — they must match the spec exactly. Tests assert this; do not adjust either side without updating the spec.

func ResolveLimits

func ResolveLimits(in *ExecutionLimits) ResolvedLimits

ResolveLimits returns the effective limits, applying defaults to any nil-valued field of in. A nil in yields the defaults verbatim.

type SecurityViolationError

type SecurityViolationError struct {
	Msg string
}

SecurityViolationError mirrors the just-bash class of the same name. The Go port enforces its threat model architecturally (no os/exec, virtual FS, allow-listed network) so this error type is rarely emitted; it is kept for direct API parity so host code that switches on it ports over.

func (*SecurityViolationError) Error

func (e *SecurityViolationError) Error() string

type SleepFunc

type SleepFunc = command.SleepFunc

SleepFunc replaces the real time.Sleep used by `sleep`, `timeout`, and related builtins. Returning a non-nil error aborts the sleeping call. Aliased to command.SleepFunc so dispatch Contexts and BashOptions share a single underlying func signature (no conversion needed).

type TraceEvent

type TraceEvent = command.TraceEvent

TraceEvent describes a single instrumentation point. Aliased to command.TraceEvent so the dispatch Context's Trace hook and a host-supplied BashOptions.Trace share one type.

type TraceFunc

type TraceFunc = command.TraceFunc

TraceFunc receives instrumentation events emitted by the runtime. Aliased to command.TraceFunc; see note on SleepFunc.

Directories

Path Synopsis
Package ast defines the typed Go AST that mirrors the just-bash TypeScript shape in src/ast/types.ts.
Package ast defines the typed Go AST that mirrors the just-bash TypeScript shape in src/ast/types.ts.
Package builtins is the meta-package that side-effect-imports every Phase 10 built-in.
Package builtins is the meta-package that side-effect-imports every Phase 10 built-in.
alias
Package alias implements the `alias` built-in.
Package alias implements the `alias` built-in.
awk
Package awk implements the `awk` built-in.
Package awk implements the `awk` built-in.
base64
Package base64 implements the `base64` built-in.
Package base64 implements the `base64` built-in.
basename
Package basename implements the `basename` built-in.
Package basename implements the `basename` built-in.
bash
Package bash implements the `bash` built-in.
Package bash implements the `bash` built-in.
breakcmd
Package breakcmd implements the `break` shell built-in.
Package breakcmd implements the `break` shell built-in.
cat
Package cat implements the `cat` built-in.
Package cat implements the `cat` built-in.
cd
Package cd implements the `cd` shell built-in.
Package cd implements the `cd` shell built-in.
chmod
Package chmod implements the `chmod` built-in.
Package chmod implements the `chmod` built-in.
clear
Package clear implements the `clear` built-in.
Package clear implements the `clear` built-in.
colon
Package colon implements the `:` (colon) shell built-in.
Package colon implements the `:` (colon) shell built-in.
column
Package column implements the `column` built-in.
Package column implements the `column` built-in.
comm
Package comm implements the `comm` built-in.
Package comm implements the `comm` built-in.
compgen
Package compgen implements the `compgen` shell built-in.
Package compgen implements the `compgen` shell built-in.
complete
Package complete implements the `complete` shell built-in.
Package complete implements the `complete` shell built-in.
compopt
Package compopt implements the `compopt` shell built-in.
Package compopt implements the `compopt` shell built-in.
continuecmd
Package continuecmd implements the `continue` shell built-in.
Package continuecmd implements the `continue` shell built-in.
cp
Package cp implements the `cp` built-in.
Package cp implements the `cp` built-in.
curl
Package curl implements the `curl` built-in.
Package curl implements the `curl` built-in.
cut
Package cut implements the `cut` built-in.
Package cut implements the `cut` built-in.
date
Package date implements the `date` built-in.
Package date implements the `date` built-in.
declare
Package declare implements the `declare` shell built-in.
Package declare implements the `declare` shell built-in.
diff
Package diff implements the `diff` built-in.
Package diff implements the `diff` built-in.
dirname
Package dirname implements the `dirname` built-in.
Package dirname implements the `dirname` built-in.
dirs
Package dirs implements the `dirs` shell built-in.
Package dirs implements the `dirs` shell built-in.
du
Package du implements the `du` built-in.
Package du implements the `du` built-in.
echo
Package echo implements the `echo` built-in.
Package echo implements the `echo` built-in.
egrep
Package egrep implements the `egrep` built-in — grep with the extended-regex (-E) mode as the default.
Package egrep implements the `egrep` built-in — grep with the extended-regex (-E) mode as the default.
env
Package env implements the `env` built-in.
Package env implements the `env` built-in.
eval
Package eval implements the `eval` shell built-in.
Package eval implements the `eval` shell built-in.
exit
Package exit implements the `exit` shell built-in.
Package exit implements the `exit` shell built-in.
expand
Package expand implements the `expand` built-in.
Package expand implements the `expand` built-in.
export
Package export implements the `export` shell built-in.
Package export implements the `export` shell built-in.
expr
Package expr implements the `expr` built-in.
Package expr implements the `expr` built-in.
falsecmd
Package falsecmd implements the `false` built-in.
Package falsecmd implements the `false` built-in.
fgrep
Package fgrep implements the `fgrep` built-in — grep with the fixed-string (-F) mode as the default.
Package fgrep implements the `fgrep` built-in — grep with the fixed-string (-F) mode as the default.
file
Package file implements the `file` built-in.
Package file implements the `file` built-in.
find
Package find implements the `find` built-in.
Package find implements the `find` built-in.
fold
Package fold implements the `fold` built-in.
Package fold implements the `fold` built-in.
getopts
Package getopts implements the `getopts` shell built-in.
Package getopts implements the `getopts` shell built-in.
grep
Package grep implements the `grep`, `egrep`, and `fgrep` built-ins.
Package grep implements the `grep`, `egrep`, and `fgrep` built-ins.
gunzip
Package gunzip implements the `gunzip` built-in — gzip with the decompress mode as the default.
Package gunzip implements the `gunzip` built-in — gzip with the decompress mode as the default.
gzip
Package gzip implements the `gzip`, `gunzip`, and `zcat` built-ins.
Package gzip implements the `gzip`, `gunzip`, and `zcat` built-ins.
hash
Package hash implements the `hash` shell built-in.
Package hash implements the `hash` shell built-in.
head
Package head implements the `head` built-in.
Package head implements the `head` built-in.
help
Package help implements the `help` built-in.
Package help implements the `help` built-in.
history
Package history implements the `history` built-in.
Package history implements the `history` built-in.
hostname
Package hostname implements the `hostname` built-in.
Package hostname implements the `hostname` built-in.
htmltomarkdown
Package htmltomarkdown implements the `html-to-markdown` built-in.
Package htmltomarkdown implements the `html-to-markdown` built-in.
jobs
Package jobs implements the `jobs` shell built-in.
Package jobs implements the `jobs` shell built-in.
join
Package join implements the `join` built-in.
Package join implements the `join` built-in.
jq
Package jq implements the `jq` built-in.
Package jq implements the `jq` built-in.
let
Package let implements the `let` shell built-in.
Package let implements the `let` shell built-in.
ln
Package ln implements the `ln` built-in.
Package ln implements the `ln` built-in.
local
Package local implements the `local` shell built-in.
Package local implements the `local` shell built-in.
ls
Package ls implements the `ls` built-in.
Package ls implements the `ls` built-in.
mapfile
Package mapfile implements the `mapfile` / `readarray` shell built-ins.
Package mapfile implements the `mapfile` / `readarray` shell built-ins.
md5sum
Package md5sum implements the `md5sum` built-in.
Package md5sum implements the `md5sum` built-in.
mkdir
Package mkdir implements the `mkdir` built-in.
Package mkdir implements the `mkdir` built-in.
mv
Package mv implements the `mv` built-in.
Package mv implements the `mv` built-in.
nl
Package nl implements the `nl` built-in.
Package nl implements the `nl` built-in.
od
Package od implements the `od` built-in.
Package od implements the `od` built-in.
paste
Package paste implements the `paste` built-in.
Package paste implements the `paste` built-in.
popd
Package popd implements the `popd` shell built-in.
Package popd implements the `popd` shell built-in.
printenv
Package printenv implements the `printenv` built-in.
Package printenv implements the `printenv` built-in.
printf
Package printf implements the `printf` built-in (/ §10.18 details).
Package printf implements the `printf` built-in (/ §10.18 details).
pushd
Package pushd implements the `pushd` shell built-in.
Package pushd implements the `pushd` shell built-in.
pwd
Package pwd implements the `pwd` built-in.
Package pwd implements the `pwd` built-in.
read
Package read implements the `read` shell built-in.
Package read implements the `read` shell built-in.
readlink
Package readlink implements the `readlink` built-in.
Package readlink implements the `readlink` built-in.
readonly
Package readonly implements the `readonly` shell built-in.
Package readonly implements the `readonly` shell built-in.
returncmd
Package returncmd implements the `return` shell built-in.
Package returncmd implements the `return` shell built-in.
rev
Package rev implements the `rev` built-in.
Package rev implements the `rev` built-in.
rg
Package rg implements the `rg` (ripgrep) built-in subset (/ Wave D).
Package rg implements the `rg` (ripgrep) built-in subset (/ Wave D).
rm
Package rm implements the `rm` built-in.
Package rm implements the `rm` built-in.
rmdir
Package rmdir implements the `rmdir` built-in.
Package rmdir implements the `rmdir` built-in.
sed
Package sed implements the `sed` built-in.
Package sed implements the `sed` built-in.
seq
Package seq implements the `seq` built-in.
Package seq implements the `seq` built-in.
set
Package set implements the `set` shell built-in.
Package set implements the `set` shell built-in.
sh
Package sh implements the `sh` built-in — a thin shim around the `bash` built-in.
Package sh implements the `sh` built-in — a thin shim around the `bash` built-in.
sha1sum
Package sha1sum implements the `sha1sum` built-in.
Package sha1sum implements the `sha1sum` built-in.
sha256sum
Package sha256sum implements the `sha256sum` built-in.
Package sha256sum implements the `sha256sum` built-in.
shopt
Package shopt implements the `shopt` shell built-in.
Package shopt implements the `shopt` shell built-in.
sleep
Package sleep implements the `sleep` built-in.
Package sleep implements the `sleep` built-in.
sort
Package sort implements the `sort` built-in.
Package sort implements the `sort` built-in.
source
Package source implements the `source` and `.` shell built-ins.
Package source implements the `source` and `.` shell built-ins.
split
Package split implements the `split` built-in.
Package split implements the `split` built-in.
sqlite3
Package sqlite3 registers a stub `sqlite3` built-in (// §14).
Package sqlite3 registers a stub `sqlite3` built-in (// §14).
stat
Package stat implements the `stat` built-in.
Package stat implements the `stat` built-in.
strings
Package strings implements the `strings` built-in.
Package strings implements the `strings` built-in.
tac
Package tac implements the `tac` built-in.
Package tac implements the `tac` built-in.
tail
Package tail implements the `tail` built-in.
Package tail implements the `tail` built-in.
tar
Package tar implements the `tar` built-in.
Package tar implements the `tar` built-in.
tee
Package tee implements the `tee` built-in.
Package tee implements the `tee` built-in.
test
Package test implements the `[` and `test` shell built-ins.
Package test implements the `[` and `test` shell built-ins.
time
Package time implements the `time` built-in.
Package time implements the `time` built-in.
timeout
Package timeout implements the `timeout` built-in.
Package timeout implements the `timeout` built-in.
touch
Package touch implements the `touch` built-in.
Package touch implements the `touch` built-in.
tr
Package tr implements the `tr` built-in.
Package tr implements the `tr` built-in.
trap
Package trap implements the `trap` shell built-in.
Package trap implements the `trap` shell built-in.
tree
Package tree implements the `tree` built-in.
Package tree implements the `tree` built-in.
truecmd
Package truecmd implements the `true` built-in.
Package truecmd implements the `true` built-in.
umask
Package umask implements the `umask` shell built-in.
Package umask implements the `umask` shell built-in.
unalias
Package unalias implements the `unalias` built-in.
Package unalias implements the `unalias` built-in.
unexpand
Package unexpand implements the `unexpand` built-in.
Package unexpand implements the `unexpand` built-in.
uniq
Package uniq implements the `uniq` built-in.
Package uniq implements the `uniq` built-in.
unset
Package unset implements the `unset` shell built-in.
Package unset implements the `unset` shell built-in.
wait
Package wait implements the `wait` shell built-in.
Package wait implements the `wait` shell built-in.
wc
Package wc implements the `wc` built-in.
Package wc implements the `wc` built-in.
which
Package which implements the `which` built-in.
Package which implements the `which` built-in.
whoami
Package whoami implements the `whoami` built-in.
Package whoami implements the `whoami` built-in.
xan
Package xan implements the `xan` CSV toolkit built-in.
Package xan implements the `xan` CSV toolkit built-in.
xargs
Package xargs implements the `xargs` built-in.
Package xargs implements the `xargs` built-in.
yq
Package yq implements the `yq` data-format swiss-army built-in.
Package yq implements the `yq` data-format swiss-army built-in.
zcat
Package zcat implements the `zcat` built-in — `gunzip -c` shorthand.
Package zcat implements the `zcat` built-in — `gunzip -c` shorthand.
cmd
gobash command
Command gobash is the CLI entry point for the go-bash runtime.
Command gobash is the CLI entry point for the go-bash runtime.
Package command defines the Command interface every gobash builtin implements, the Context value those builtins receive at dispatch time, the Result value they return, and the Registry that maps names to implementations.
Package command defines the Command interface every gobash builtin implements, the Context value those builtins receive at dispatch time, the Result value they return, and the Registry that maps names to implementations.
fs
Package fs defines the virtual filesystem interface used by go-bash and utility functions for path manipulation.
Package fs defines the virtual filesystem interface used by go-bash and utility functions for path manipulation.
fstest
Package fstest provides a contract test suite shared by every FileSystem implementation in go-bash.
Package fstest provides a contract test suite shared by every FileSystem implementation in go-bash.
memfs
Package memfs implements an in-memory FileSystem suitable for use as the default backing store of a Bash sandbox.
Package memfs implements an in-memory FileSystem suitable for use as the default backing store of a Bash sandbox.
mountfs
Package mountfs implements a mount-table FileSystem composed of one or more child FileSystems mounted at virtual paths over a base FS.
Package mountfs implements a mount-table FileSystem composed of one or more child FileSystems mounted at virtual paths over a base FS.
overlayfs
Package overlayfs implements an overlay FileSystem where writes land in an in-memory overlay and reads come from the overlay-or-real-disk union.
Package overlayfs implements an overlay FileSystem where writes land in an in-memory overlay and reads come from the overlay-or-real-disk union.
realfs
Package realfs holds the security helpers shared by the read-write and overlay filesystems.
Package realfs holds the security helpers shared by the read-write and overlay filesystems.
rwfs
Package rwfs implements a read-write FileSystem that maps virtual paths under a sandbox root onto the host filesystem.
Package rwfs implements a read-write FileSystem that maps virtual paths under a sandbox root onto the host filesystem.
internal
alias
Package alias implements parse-time alias expansion for go-bash.
Package alias implements parse-time alias expansion for go-bash.
builtinutil
Package builtinutil contains small helpers shared by Phase 10's Wave A built-in command packages.
Package builtinutil contains small helpers shared by Phase 10's Wave A built-in command packages.
cmpfixture
Package cmpfixture is the comparison-test harness for go-bash.
Package cmpfixture is the comparison-test harness for go-bash.
ringbuf
Package ringbuf provides a bounded output writer used by the bash runtime to enforce the spec's MaxOutputSize limit.
Package ringbuf provides a bounded output writer used by the bash runtime to enforce the spec's MaxOutputSize limit.
runtimestate
Package runtimestate carries the per-Bash mutable state shared between built-in commands and the runtime.
Package runtimestate carries the per-Bash mutable state shared between built-in commands and the runtime.
Package interp builds and configures the mvdan.cc/sh/v3/interp runner with the gobash customization hooks.
Package interp builds and configures the mvdan.cc/sh/v3/interp runner with the gobash customization hooks.
Package network is the gobash secure HTTP layer.
Package network is the gobash secure HTTP layer.
Package parser exposes the public Parse / ParseString entry points and the typed ParseError returned on failure.
Package parser exposes the public Parse / ParseString entry points and the typed ParseError returned on failure.
Package sandbox is an OPTIONAL convenience wrapper around *gobash.Bash that mimics the shape of Vercel's @vercel/sandbox SDK so code targeting that hosted runtime can swap to go-bash as a drop-in local mock.
Package sandbox is an OPTIONAL convenience wrapper around *gobash.Bash that mimics the shape of Vercel's @vercel/sandbox SDK so code targeting that hosted runtime can swap to go-bash as a drop-in local mock.
Package sqlite is the OPTIONAL `sqlite3` runtime for go-bash.
Package sqlite is the OPTIONAL `sqlite3` runtime for go-bash.
Package transform exposes the Serialize entry point that renders an *ast.Script back to bash source.
Package transform exposes the Serialize entry point that renders an *ast.Script back to bash source.
plugins/collector
Package collector implements the CommandCollectorPlugin: a read-only transform plugin that walks the parsed AST and reports the command name of every leaf SimpleCommand it encounters.
Package collector implements the CommandCollectorPlugin: a read-only transform plugin that walks the parsed AST and reports the command name of every leaf SimpleCommand it encounters.
plugins/tee
Package tee implements the TeePlugin: a transform plugin that wraps every non-trivial pipeline stage with `| tee /OUT/<idx>-<cmd>.stdout.txt` so the host can post-mortem the per-stage output of a script.
Package tee implements the TeePlugin: a transform plugin that wraps every non-trivial pipeline stage with `| tee /OUT/<idx>-<cmd>.stdout.txt` so the host can post-mortem the per-stage output of a script.

Jump to

Keyboard shortcuts

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