sh

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package sh to run command programing

Index

Constants

This section is empty.

Variables

View Source
var (

	// DefaultRunner use to execute with package
	DefaultRunner, _ = New()
)
View Source
var Dir = interp.Dir

Dir sets the interpreter's working directory. If empty, the process's current directory is used.

View Source
var Env = interp.Env

Env sets the interpreter's environment. If nil, a copy of the current process's environment is used.

View Source
var Params = interp.Params

Params populates the shell options and parameters. For example, Params("-e", "--", "foo") will set the "-e" option and the parameters ["foo"], and Params("+e") will unset the "-e" option and leave the parameters untouched.

This is similar to what the interpreter's "set" builtin does.

View Source
var StdIO = interp.StdIO

StdIO configures an interpreter's standard input, standard output, and standard error. If out or err are nil, they default to a writer that discards the output.

Functions

func Run

func Run(s string, opts ...Option) error

Run use default runner to run command

Types

type Option

type Option = func(*interp.Runner) error

Option configuration

type Runner

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

Runner container runner configuration to execute command

func New

func New(opts ...Option) (*Runner, error)

New create a runner

func (*Runner) Run

func (r *Runner) Run(ctx context.Context, s string, opts ...Option) error

Run to execute with a runner we wont to handle sh file, so need to read them all at first but we can use a special char to mark this content is a file like: @, let's do it.

Jump to

Keyboard shortcuts

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