pub struct ShellSegment {
pub command: String,
pub words: Vec<Word>,
pub redirection: Option<Redirection>,
pub substitutions: Vec<SubstitutionSpan>,
}Expand description
A single evaluable command within a compound pipeline.
Fields§
§command: StringThe command text, exactly as it appears in the source (trimmed).
Substitution syntax ($(), backticks, <(), >()) is preserved
verbatim — the substitutions field carries
the recursively-parsed contents with byte positions into this text.
words: Vec<Word>Pre-tokenized word list as tree-sitter understood word boundaries.
Unlike shlex tokenization of command, this
correctly preserves substitution syntax as single tokens. For
example, export FOO=$(echo test) BAR=baz produces
["export", "FOO=$(echo test)", "BAR=baz"] — shlex would
incorrectly split inside the $(...).
Quotes are stripped: "foo bar" becomes foo bar. Both
tree-sitter extraction and shlex fallback produce unquoted tokens.
Substitution delimiters ($(...), `...`, <(...)) are
preserved as-is since they are semantic, not syntactic wrappers.
Falls back to shlex/whitespace tokenization when tree-sitter does not provide word-level structure (e.g. unknown node types or heredoc loose words). The fallback is documented per node type in the parser source.
redirection: Option<Redirection>Output redirection detected on a wrapping construct.
When the parser extracts commands from inside a control-flow block
that has output redirection (e.g. for ... done > file), the
redirect is not present in the segment’s command text. This field
carries the redirection so the eval layer can escalate the decision.
substitutions: Vec<SubstitutionSpan>Substitutions within this segment’s command text, in source order.
Each substitution is evaluated before this segment’s command.
start/end byte offsets index into command.
Trait Implementations§
Source§impl Clone for ShellSegment
impl Clone for ShellSegment
Source§fn clone(&self) -> ShellSegment
fn clone(&self) -> ShellSegment
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more