Skip to main content

Module shell_parser

Module shell_parser 

Source
Expand description

Shell script parser for bash -lc and similar commands.

This module parses shell commands like:

bash -lc "git status && cargo check"

Into individual command vectors for independent safety checking:

[["git", "status"], ["cargo", "check"]]

Phase 4 Implementation: Uses tree-sitter for accurate bash AST parsing. Falls back to basic tokenization for minimal shell syntax.

Functionsยง

parse_bash_lc_commands
Parses bash -lc "script" style invocations
parse_shell_commands
Parses a shell script into individual commands using tree-sitter bash grammar
parse_shell_commands_tree_sitter
Parses a shell script using tree-sitter bash grammar only (no fallback tokenization).
prewarm_bash_parser
Ensures the bash tree-sitter parser is initialized.