Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
go-bash/options.go at master · mark3labs/go-bash · GitHub
Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Events
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mark3labs
go-bash
Repository navigation
Code
Issues
Pull requests
1
(1)
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
go-bash
/
options.go
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
163 lines (143 loc) · 6.55 KB
master
Breadcrumbs
go-bash
/
options.go
Copy path
Top
File metadata and controls
Code
Blame
163 lines (143 loc) · 6.55 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
package
gobash
import
(
"io"
"github.com/mark3labs/go-bash/command"
"github.com/mark3labs/go-bash/fs"
"github.com/mark3labs/go-bash/network"
"github.com/mark3labs/go-bash/transform"
)
// 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
BashOptions
struct
{
// Env is copied at construction. Each Exec starts from this base; script
// mutations and per-call overrides never persist to later Exec calls.
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. Non-zero values override ExecutionLimits; zero means unset.
// Use ExecutionLimits pointer fields to request a zero budget.
// Negative effective limits are rejected by New. Prefer ExecutionLimits.
MaxCallDepth
int
MaxCommandCount
int
MaxLoopIterations
int
}
// ExecOptions configures a single Exec call. Per-call settings override
// the per-Bash defaults.
type
ExecOptions
struct
{
// Env is merged into a fresh copy of the constructor environment.
Env
map
[
string
]
string
// ReplaceEnv starts with only Env instead of the constructor environment.
ReplaceEnv
bool
Cwd
string
// RawScript disables upstream-style leading indentation normalization.
// By default heredoc bodies and multiline quoted content are preserved.
RawScript
bool
Stdin
io.
Reader
Stdout
io.
Writer
Stderr
io.
Writer
// Args is appended literally after expansion at the first real command
// dispatch (including commands in substitutions/functions). It is consumed
// once per Exec, never by loop instrumentation. No quoting, splitting,
// globbing, or shell evaluation is applied to these strings. Args does not
// initialize shell positional parameters ($1, $@).
Args
[]
string
}
// 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
ProcessInfo
struct
{
PID
int
PPID
int
UID
int
GID
int
}
// 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
SleepFunc
=
command.
SleepFunc
// TraceFunc receives instrumentation events emitted by the runtime.
// Aliased to command.TraceFunc; see note on SleepFunc.
type
TraceFunc
=
command.
TraceFunc
// InvokeToolFunc is the host hook invoked from JavaScript-side tool calls.
// It returns the tool's JSON-serialized result.
// Aliased to command.InvokeToolFunc.
type
InvokeToolFunc
=
command.
InvokeToolFunc
// 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
TraceEvent
=
command.
TraceEvent
// Logger receives structured log records emitted by the runtime.
type
Logger
interface
{
Info
(
msg
string
,
fields
map
[
string
]
any
)
Debug
(
msg
string
,
fields
map
[
string
]
any
)
}
// JavaScriptConfig configures the opt-in JavaScript runtime (Phase 15).
type
JavaScriptConfig
struct
{
Bootstrap
string
InvokeTool
InvokeToolFunc
}
// 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
PythonConfig
struct
{}
You can’t perform that action at this time.