shellline

package
v1.0.0-rc.6 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const MaxLineBytes = 64 * 1024
View Source
const UnknowableTarget = "(not statically knowable)"

Variables

This section is empty.

Functions

func ArgTokens

func ArgTokens(v any) []string

func DecodeEscapes

func DecodeEscapes(s string) string

func DigitValue

func DigitValue(c byte) int

func DisplayWords

func DisplayWords(words []string) string

func FlattenDisplay

func FlattenDisplay(parts []string) string

func LenientWords

func LenientWords(call *syntax.CallExpr) []string

func LiteralAssignments

func LiteralAssignments(file *syntax.File) map[string]string

func LiteralWord

func LiteralWord(word *syntax.Word) (string, bool)

func ModeRequested

func ModeRequested(args map[string]any) bool

func ParseEscapedNumber

func ParseEscapedNumber(s string, base, maxDigits int) (value byte, width int, ok bool)

func ParseFile

func ParseFile(src string) (file *syntax.File, bashOnly bool, ok bool)

func Parses

func Parses() int64

func ResolveAssignedWords

func ResolveAssignedWords(call *syntax.CallExpr, assigns map[string]string) ([]string, bool)

func SoleParamName

func SoleParamName(word *syntax.Word) (string, bool)

func Structural

func Structural(trusted Kind, goos string) bool

func UnescapeDoubleQuoted

func UnescapeDoubleQuoted(s string) string

func UnescapeUnquoted

func UnescapeUnquoted(s string) string

func WithKind

func WithKind(ctx context.Context, kind string) context.Context

func WordName

func WordName(word *syntax.Word) (string, bool)

Types

type Kind

type Kind string
const (
	KindPOSIX      Kind = "sh"
	KindPowerShell Kind = "powershell"
	KindCmd        Kind = "cmd"
	KindUnknown    Kind = "unknown"
)

func KindFromContext

func KindFromContext(ctx context.Context) Kind

func NormalizeKind

func NormalizeKind(s string) Kind

type Line

type Line struct {
	Readable     bool
	Parsed       bool
	BashOnly     bool
	Steps        []Step
	File         *syntax.File
	Redirects    []Redirect
	CommandSubst bool
	ProcessSubst bool
	ArithmExp    bool
	Background   bool
	Negated      bool
	Coprocess    bool
	Control      bool
	Pipelines    int
}

func LineFromArgs

func LineFromArgs(args map[string]any, kind Kind, goos string) (Line, bool)

func Parse

func Parse(src string, kind Kind, goos string) Line

type Operator

type Operator string
const (
	OpStart Operator = ""
	OpAnd   Operator = "&&"
	OpOr    Operator = "||"
	OpSeq   Operator = ";"
	OpPipe  Operator = "|"
)

type Redirect

type Redirect struct {
	Op      string
	Target  string
	Heredoc bool
}

func RedirectView

func RedirectView(redir *syntax.Redirect) Redirect

type Step

type Step struct {
	Operator Operator
	Name     string
	Base     string
	Display  string
	Words    []string
	Literal  bool
	ArgCount int
	Assigns  []string
}

func StepFromCall

func StepFromCall(call *syntax.CallExpr) Step

func WordsFromValues

func WordsFromValues(words []string) Step

Jump to

Keyboard shortcuts

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