interpreter

package
v4.1.3 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EvaluateEnv

func EvaluateEnv(ctx context.Context, script []byte, args []string, envs []string) ([]string, error)

EvaluateEnv evaluates the environment variable script and returns the list of variables set in the script. Command execution is disabled along with redirection.

func GetEnv

func GetEnv(hc interp.HandlerContext) []string

GetEnv returns an the list of all exported environment variables within the context of the shell interpreter.

Types

type OpenHandler

type OpenHandler func(path string, flag int, perm os.FileMode) (io.ReadWriteCloser, error)

OpenHandler defines function prototype for shell interpreter file handler registration.

type Shell

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

Shell defines the shell interpreter.

func New

func New(r io.Reader, name string, args []string, envs []string, runnerOptions ...interp.RunnerOption) (s *Shell, err error)

New returns a shell interpreter instance.

func (*Shell) LookPath

func (s *Shell) LookPath(ctx context.Context, cmd string) (string, error)

LookPath returns the absolute path for the command passed in argument within the context of the shell interpreter.

func (*Shell) RegisterOpenHandler

func (s *Shell) RegisterOpenHandler(path string, handler OpenHandler)

RegisterOpenHandler registers a shell interpreter file handler.

func (*Shell) RegisterShellBuiltin

func (s *Shell) RegisterShellBuiltin(name string, builtin ShellBuiltin)

RegisterShellBuiltin registers a shell interpreter builtin.

func (*Shell) Run

func (s *Shell) Run(ctx context.Context) error

Run runs the shell interpreter.

func (*Shell) Status

func (s *Shell) Status() uint8

Status returns the exit code status of the shell interpreter.

type ShellBuiltin

type ShellBuiltin func(ctx context.Context, args []string) error

ShellBuiltin defines function prototype for shell interpreter builtin registration.

Jump to

Keyboard shortcuts

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