exec

package
v0.0.0-...-f4e3d25 Latest Latest
Warning

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

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

Documentation

Overview

Package exec wires together the parser, environment, filesystem map, builtins, and external command execution into a running shell.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Shell

type Shell struct {
	Env              *env.Env
	DriveMap         *fsmap.DriveMap
	Builtins         *builtins.Registry
	Config           *config.Config
	EchoOn           bool
	ErrorLevel       int
	DelayedExpansion bool

	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer
	// contains filtered or unexported fields
}

Shell is the central execution context.

func New

func New(e *env.Env, dm *fsmap.DriveMap, reg *builtins.Registry, cfg *config.Config) *Shell

New returns a Shell ready for use. Stdin/Stdout/Stderr default to the process streams.

func (*Shell) Completer

func (s *Shell) Completer() func(string) []string

Completer returns a liner-compatible tab-completion function.

Completion rules:

  • First word: offer builtin names and executables found in PATH.
  • Later word that looks like a DOS path: list matching filesystem entries.

func (*Shell) RunBatch

func (s *Shell) RunBatch(dosPath string, args []string) error

RunBatch loads and executes a DOS batch file. dosPath may be a DOS-style path (C:\scripts\foo.bat) or a plain Unix path. args are the positional parameters %1..%9; dosPath becomes %0.

func (*Shell) RunBatchContent

func (s *Shell) RunBatchContent(name string, content []byte) error

RunBatchContent executes batch content supplied as raw bytes (e.g. from stdin). name is used only for diagnostics.

func (*Shell) RunLine

func (s *Shell) RunLine(line string) error

RunLine parses and executes a single command line.

Returns a non-nil error only for sentinel conditions (e.g. batch.ExitError). Command-not-found and syntax errors set s.ErrorLevel and return nil.

func (*Shell) RunStartupScripts

func (s *Shell) RunStartupScripts(home string) (int, bool)

RunStartupScripts runs each existing startup script in order. Returns (code, true) when a script exits the shell via ExitError. Returns (0, false) when all scripts complete normally.

Jump to

Keyboard shortcuts

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