interp

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2017 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Overview

Package interp implements an interpreter that executes shell programs. It aims to support POSIX.

This package is a work in progress and EXPERIMENTAL; its API is not subject to the 1.x backwards compatibility guarantee.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExitCode

type ExitCode uint8

func (ExitCode) Error

func (e ExitCode) Error() string

type RunError

type RunError struct {
	syntax.Position
	Text string
}

func (RunError) Error

func (e RunError) Error() string

type Runner

type Runner struct {
	// TODO: syntax.Node instead of *syntax.File?
	File *syntax.File

	// Env specifies the environment of the interpreter.
	// If Env is nil, Run uses the current process's environment.
	Env []string

	// Dir specifies the working directory of the command. If Dir is
	// the empty string, Run runs the command in the calling
	// process's current directory.
	Dir string

	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer

	// Context can be used to cancel the interpreter before it finishes
	Context context.Context
	// contains filtered or unexported fields
}

A Runner interprets shell programs. It cannot be reused once a program has been interpreted.

Note that writes to Stdout and Stderr may not be sequential. If you plan on using an io.Writer implementation that isn't safe for concurrent use, consider a workaround like hiding writes behind a mutex.

func (*Runner) Run

func (r *Runner) Run() error

Run starts the interpreter and returns any error.

Jump to

Keyboard shortcuts

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