Expand description
Shell command parsing backed by tree-sitter-bash.
Public API:
parse_with_substitutions— decomposes a shell command into a recursiveParsedPipelinetree.has_output_redirection— mutation-detection for redirects.dump_ast— diagnostic output.
The parser uses tree-sitter-bash for a full AST, then walks it to
produce segments joined by operators. Substitutions ($(), backticks,
<(), >()) are recursively parsed into nested pipelines — the
result is a tree that can be evaluated bottom-up (catamorphism).
§Control flow handling
Shell keywords (for, if, while, case) are grammar structure,
not commands. The walker recurses into their bodies and extracts the
actual commands as segments.
§Redirection propagation
When a control flow construct has output redirection
(e.g. for ... done > file), it propagates to inner segments via
ShellSegment::redirection.
Functions§
- dump_
ast - Diagnostic: dump the tree-sitter AST and parsed pipeline.
- has_
output_ redirection - Check whether
commandcontains output redirection. - parse_
with_ substitutions - Parse a shell command into a recursive pipeline tree.