Documentation
¶
Overview ¶
Package batch implements the DOS batch file execution engine.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CallSignal ¶
CallSignal is returned by CALL. When Label is non-empty it is a local subroutine call (CALL :label); otherwise Path names the batch file to invoke.
func (CallSignal) Error ¶
func (c CallSignal) Error() string
type ExitBatchSignal ¶
type ExitBatchSignal struct{ Code int }
ExitBatchSignal is returned by EXIT /B to end the current batch subroutine (or the current batch file) without exiting the shell.
func (ExitBatchSignal) Error ¶
func (e ExitBatchSignal) Error() string
type ExitError ¶
type ExitError struct{ Code int }
ExitError is returned by the EXIT builtin to signal the shell to exit.
type GotoSignal ¶
type GotoSignal struct{ Label string }
GotoSignal is returned by GOTO to signal the batch engine to jump to a label.
func (GotoSignal) Error ¶
func (g GotoSignal) Error() string
type State ¶
type State struct {
// contains filtered or unexported fields
}
State is the execution state for a running batch file.
func Load ¶
Load reads a batch file and returns a ready State. args[0] should be the script path (%0); args[1:] are %1..%9.
func (*State) Goto ¶
Goto sets the program counter to the line after the named label. The special label EOF (or :EOF) jumps past the end of the file. Returns an error if the label is not found.
func (*State) Run ¶
func (s *State) Run( runLine func(string) error, runBatch func(dosPath string, args []string) error, stderr io.Writer, ) error
Run executes the batch file line by line.
- runLine executes a single expanded line (typically Shell.RunLine).
- runBatch executes a nested batch file given a DOS path and args (for CALL).
- stderr receives diagnostic messages.
Run returns a non-nil error only for ExitError (shell exit) or unexpected errors propagated from runLine.