Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CallContext ¶
type CallContext struct {
Stdout io.Writer
Stderr io.Writer
Stdin *os.File
// InLoop is true when the builtin runs inside a for loop.
InLoop bool
// LastExitCode is the exit code from the previous command.
LastExitCode uint8
// OpenFile opens a file within the shell's path restrictions.
OpenFile func(ctx context.Context, path string, flags int, mode os.FileMode) (io.ReadWriteCloser, error)
// PortableErr normalizes an OS error to a POSIX-style message.
PortableErr func(err error) string
}
CallContext provides the capabilities available to builtin commands. It is created by the Runner for each builtin invocation.
func (*CallContext) Errf ¶
func (c *CallContext) Errf(format string, a ...any)
Errf writes a formatted string to stderr.
func (*CallContext) Outf ¶
func (c *CallContext) Outf(format string, a ...any)
Outf writes a formatted string to stdout.
type HandlerFunc ¶
type HandlerFunc func(ctx context.Context, callCtx *CallContext, args []string) Result
HandlerFunc is the signature for a builtin command implementation.
func Lookup ¶
func Lookup(name string) (HandlerFunc, bool)
Lookup returns the handler for a builtin command.
type Result ¶
type Result struct {
// Code is the exit status code.
Code uint8
// Exiting signals that the shell should exit (set by the "exit" builtin).
Exiting bool
// BreakN > 0 means break out of N enclosing loops.
BreakN int
// ContinueN > 0 means continue from N enclosing loops.
ContinueN int
}
Result captures the outcome of executing a builtin command.
Click to show internal directories.
Click to hide internal directories.