Documentation
¶
Index ¶
- Constants
- Variables
- func BufferReturn(line parsing.LineInfo, rest *[]byte) (buf *bytes.Buffer, ...)
- func DquoteString(value string) string
- func ErrOut[T any](line parsing.LineInfo, rest *[]byte) func(span int, msg string, args ...any) (T, []byte, error)
- func FormatAssignment(key, value string) string
- func FormatString(value string) string
- func IsAlphaOrUnderscore(c rune) bool
- func IsDigit(c rune) bool
- func ParseAssignment(line parsing.LineInfo, rest []byte) (key, value string, newRest []byte, err error)
- func ParseIdentifier(line parsing.LineInfo, rest []byte) (identifier string, newRest []byte, err error)
- func ParseShellString(li parsing.LineInfo, rest []byte) (value string, newRest []byte, err error)
- func ParseShellStringDquote(li parsing.LineInfo, rest []byte) (value string, newRest []byte, err error)
- func ParseShellStringRaw(li parsing.LineInfo, rest []byte) (value string, newRest []byte, err error)
- func ParseShellStringSquote(li parsing.LineInfo, rest []byte) (value string, newRest []byte, err error)
- func TrimSpace(s []byte) []byte
- type ArgsAndFiles
- type Closure
- type Code
- type Command
- type CommandFunc
- type Env
- type InlineFile
- type OverlayFS
- type UnknownCommandError
- type Vars
Constants ¶
View Source
const ( // DquoteSpecialChars are characters that could interrupt // a double-quoted shell string unless escaped. DquoteSpecialChars = "$\r\n\t\"`" // DquoteNonliteralChars are characters whose escaped form // does not not end with their literal value. // For example, "\$" has a literal value of "$", so is not included. // But "\n" does not have a literal value of "n", so it is included. DquoteNonliteralChars = "\r\n\t" // SpecialChars are characters that could interrupt a raw shell string // unless quoted or escaped. SpecialChars = DquoteSpecialChars + `!()[]{}<>|!&*? ;#'"\` )
Variables ¶
View Source
var DefaultCommands = map[string]CommandFunc{ "cat": Cat, "echo": Echo, "false": False, "true": True, }
View Source
var ErrNoMatch = errors.New("no match")
Functions ¶
func BufferReturn ¶
func DquoteString ¶
func FormatAssignment ¶
func FormatString ¶
FormatString returns value if it is not empty and it equals its raw shell string rendering. Otherwise, we escape as needed and wrap it in double-quotes.
func IsAlphaOrUnderscore ¶
func ParseAssignment ¶
func ParseIdentifier ¶
func ParseShellString ¶
func ParseShellStringDquote ¶
func ParseShellStringRaw ¶
func ParseShellStringSquote ¶
Types ¶
type ArgsAndFiles ¶
type ArgsAndFiles struct {
Args []string
Files []InlineFile
}
func ParseWhitespaceThenArgs ¶
type Command ¶
type Command struct {
Name string
// Col points to the first char of the command name, not the assignments.
Col int
Vars Vars
Args []string
InlineFiles []InlineFile
}
func ParseCommand ¶
type CommandFunc ¶
type Env ¶
type Env struct {
LineInfo parsing.LineInfo
Col int // points to cmd name, not assignments
Vars Vars
Files fs.FS
Library map[string]CommandFunc
Stdout io.Writer
Stderr io.Writer
}
func (Env) LookupCommand ¶
func (e Env) LookupCommand( cmd string, ) (CommandFunc, error)
type InlineFile ¶
func (InlineFile) Run ¶
func (inlineFile InlineFile) Run( stdout, stderr io.Writer, ) (Code, error)
Run the subprogram.
func (InlineFile) String ¶
func (f InlineFile) String() string
type UnknownCommandError ¶
type UnknownCommandError string
func (UnknownCommandError) Error ¶
func (e UnknownCommandError) Error() string
Click to show internal directories.
Click to hide internal directories.