sh

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2025 License: MIT Imports: 49 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BuiltinCommands = []string{
	"true", "false", "exit", "set", "shift", "unset",
	"echo", "printf", "break", "continue", "pwd", "cd",
	"wait", "builtin", "trap", "type", "source", ".", "command",
	"dirs", "pushd", "popd", "umask", "alias", "unalias",
	"fg", "bg", "getopts", "eval", "test", "[", "exec",
	"return", "read", "mapfile", "readarray", "shopt",
}

bash commands

View Source
var CoreUtilsCommands = []string{
	"base64", "basename", "cat", "chmod", "cp", "date", "dirname", "find", "gzip", "head", "ls", "mkdir",
	"mktemp", "mv", "rm", "shasum", "sleep", "tac", "tail", "tar", "time", "touch", "wget", "xargs",
}

internal commands

Functions

func ClearAllEnv added in v0.0.5

func ClearAllEnv(keeps []string)

ClearAllEnv clears all environment variables except for the keeps

func DecodeFileFlag added in v0.0.7

func DecodeFileFlag(flag int) string

func DecodeFilePerm added in v0.0.7

func DecodeFilePerm(perm fs.FileMode) string

func Gosh

func Gosh(ctx context.Context, vs *VirtualSystem, script string, args []string) error

Gosh executes a script provided in the argument. If no arguments are provided, it will execute in interactive mode if standard input supports it. This function manages errors and exits appropriately.

func IsCoreUtils added in v0.0.6

func IsCoreUtils(s string) bool

func IsShell added in v0.0.4

func IsShell(s string) bool

return true if the last elemment is or ends in sh/bash

func ParseFlags added in v0.0.7

func ParseFlags(args []string) (string, string, []string)

Parse parses flag definitions from the argument list, which should not include the command name. Return root, script, and remaining non flag args

func Run added in v0.0.6

func Run(parent context.Context, vs *VirtualSystem, script string, args []string) error

func RunCoreUtils added in v0.0.6

func RunCoreUtils(ctx context.Context, vs *VirtualSystem, args []string) (bool, error)

func VirtualExecHandler

func VirtualExecHandler(vs *VirtualSystem) func(next interp.ExecHandlerFunc) interp.ExecHandlerFunc

func VirtualOpenHandler

func VirtualOpenHandler(vs *VirtualSystem) interp.OpenHandlerFunc

func VirtualReadDirHandler2

func VirtualReadDirHandler2(vs *VirtualSystem) interp.ReadDirHandlerFunc2

func VirtualStatHandler

func VirtualStatHandler(vs *VirtualSystem) interp.StatHandlerFunc

Types

type ExecHandler added in v0.0.3

type ExecHandler func(context.Context, []string) (bool, error)

func NewDummyExecHandler added in v0.0.3

func NewDummyExecHandler(vs *VirtualSystem) ExecHandler

type IOE added in v0.0.2

type IOE struct {
	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer
}

standard IO

func NewStdIOE added in v0.0.8

func NewStdIOE() *IOE

func NewStringIOE added in v0.0.8

func NewStringIOE(s string) *IOE

type StringIOE added in v0.0.8

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

type VirtualSystem

type VirtualSystem struct {
	IOE *IOE

	// Roots     []string
	Workspace vfs.Workspace
	System    vos.System

	ExecHandler ExecHandler

	MaxTimeout int
}

func NewLocalSystem

func NewLocalSystem(roots []string, ioe *IOE) (*VirtualSystem, error)

func NewVirtualSystem

func NewVirtualSystem(s vos.System, ws vfs.Workspace, ioe *IOE) *VirtualSystem

func (*VirtualSystem) NewRunner added in v0.0.4

func (vs *VirtualSystem) NewRunner(opts ...interp.RunnerOption) (*interp.Runner, error)

func (*VirtualSystem) RunInteractive added in v0.0.6

func (vs *VirtualSystem) RunInteractive(ctx context.Context) error

func (*VirtualSystem) RunPath added in v0.0.4

func (vs *VirtualSystem) RunPath(ctx context.Context, path string) error

func (*VirtualSystem) RunReader added in v0.0.6

func (vs *VirtualSystem) RunReader(ctx context.Context) error

func (*VirtualSystem) RunScript added in v0.0.4

func (vs *VirtualSystem) RunScript(ctx context.Context, script string) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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