shell

package
v1.0.14 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Shell interpreting command lines inside the process, starting only the programs a line names

Index

Constants

View Source
const Dialect = "icebath's own shell, interpreting every command line in process with no other shell underneath"

Sentence telling a model what runs its command lines

View Source
const Name = "icebath"

What prompts and tool descriptions call the shell

Variables

View Source
var Builtins = builtins()

Names the interpreter handles itself, every other command starting the program of that name on PATH

Functions

func Join

func Join(words []string) (string, error)

Line that the shell splits back into exactly these words

func Parse

func Parse(line string) (*syntax.File, error)

Program parsed from a command line

func Words

func Words(line string) ([]string, error)

Words of a line as the shell splits them, quotes removed and expansions kept as written, nothing run

Types

type Cmd

type Cmd struct {
	Line string
	// Working directory, the process working directory when empty
	Dir string
	// KEY=VALUE pairs layered over the environment of the process
	Env []string
	// Standard input of the line, closed when nil
	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer
}

One command line to run in a fresh shell with its own streams

func (Cmd) Run

func (c Cmd) Run(ctx context.Context) (int, error)

Exit code of the line, with an error only when the shell cannot start or ctx ends it

type Command

type Command struct {
	Text string
	// Runs commands the line does not spell out, through substitution, eval or source
	Hidden bool
}

One simple command a line runs, as written

func Commands

func Commands(line string) ([]Command, error)

Simple commands of line in the order written, those inside substitutions and compound bodies included

type Options

type Options struct {
	// Starting directory, the process working directory when empty
	Dir string
	// KEY=VALUE pairs layered over the environment of the process
	Env []string
}

Settings a shell starts with

type Result

type Result struct {
	ExitCode int
	// Exit code of every stage of the last pipeline the line ran, empty when it ran none
	Pipeline []int
	// Command name of every stage of that pipeline, empty for a stage that was not a plain call
	Commands []string
	Dir      string
	// The line ended the shell with exit, so the next line starts a fresh one in the same directory
	Exited bool
	// The context ended before the line did and everything it started was killed
	Killed bool
}

How a command line ended and the working directory it left behind

type Shell

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

One persistent interpreter whose variables, functions, aliases and directory carry over between lines

func New

func New(o Options) (*Shell, error)

Starts a shell in the configured directory

func (*Shell) Close

func (s *Shell) Close()

Kills everything the shell started that is still running and releases it

func (*Shell) Dir

func (s *Shell) Dir() string

Working directory the next line starts in

func (*Shell) Fork

func (s *Shell) Fork() (*Shell, error)

Copy of the shell as it stands, running lines beside it on its own state and dying with it

func (*Shell) Run

func (s *Shell) Run(ctx context.Context, line string, stdout, stderr io.Writer) Result

Runs line to completion with stdin closed, killing everything it started when ctx ends first

Jump to

Keyboard shortcuts

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