Documentation
¶
Index ¶
- func ContainsExpansion(w *Word) bool
- type ArithmCmd
- type Assign
- type BinaryCmd
- type BinaryOp
- type Block
- type CallExpr
- type CmdSubst
- type Command
- type DblQuoted
- type DeclClause
- type Expansion
- type File
- type ForClause
- type Heredoc
- type IfClause
- type LetClause
- type Lit
- type ParamExp
- type ParamExpOp
- type Redirect
- type SglQuoted
- type Stmt
- type Subshell
- type TestClause
- type TimeClause
- type WhileClause
- type Word
- type WordIter
- type WordPart
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContainsExpansion ¶
ContainsExpansion checks if a word has any unquoted expansions.
Types ¶
type CallExpr ¶
type CallExpr struct {
Assigns []*Assign
Args []*Word
Heredocs []*Heredoc // <<DELIM heredocs attached to this command
// MergeStderr is set when the command had a `2>&1` redirection,
// causing the shell to send the command's stderr down its stdout.
MergeStderr bool
// Redirect is set when the command's stdout is redirected to a file via
// `> file` or `>> file`. The shell buffers stdout and commits it as a
// single atomic whole-object write (never a stream).
Redirect *Redirect
}
CallExpr is a simple command: optional assignments followed by words.
type CmdSubst ¶
type CmdSubst struct {
Stmts []*Stmt
}
CmdSubst represents command substitution $(...).
type Command ¶
type Command interface {
// contains filtered or unexported methods
}
Command is implemented by all command AST nodes.
type DblQuoted ¶
type DblQuoted struct{ Parts []WordPart }
DblQuoted is a double-quoted string with nested expansions.
type DeclClause ¶
DeclClause represents export/local/declare/readonly.
type Expansion ¶
type Expansion struct {
Op ParamExpOp
Word *Word
}
Expansion holds the operator and word for parameter expansion modifiers.
type File ¶
type File struct {
Stmts []*Stmt
}
File is the top-level AST node representing a parsed shell input.
type Heredoc ¶
type Heredoc struct {
Delimiter string // e.g. "EOF"
StripTabs bool // true when opener was `<<-DELIM` (strips leading TABs)
Body string // body text, filled in by the lexer
}
Heredoc holds the body of a `<<DELIM` here-document. Body is captured verbatim by the lexer at the first newline after the heredoc opener.
Variable expansion inside the body is intentionally NOT supported in this shell — heredocs are always treated as if the delimiter were quoted (i.e. `<<'EOF'`). This keeps the implementation small and matches the dominant use case: piping multi-line content into commands like `kb publish`.
type IfClause ¶
IfClause represents if/elif/else. A plain "else" is encoded as &IfClause{Then: body} with nil Cond.
type ParamExpOp ¶
type ParamExpOp int
ParamExpOp is the operator in a parameter expansion.
const ( DefaultUnset ParamExpOp = iota // ${VAR-word} DefaultUnsetOrNull // ${VAR:-word} AlternateUnset // ${VAR+word} AlternateUnsetOrNull // ${VAR:+word} AssignUnset // ${VAR=word} AssignUnsetOrNull // ${VAR:=word} ErrorUnset // ${VAR?word} ErrorUnsetOrNull // ${VAR:?word} )
type TestClause ¶
type TestClause struct {
Words []*Word
}
TestClause represents [[ ... ]] test expressions.
type WhileClause ¶
WhileClause represents while/until loops.