| Crates.io | oak-bash |
| lib.rs | oak-bash |
| version | 0.0.1 |
| created_at | 2025-10-20 10:48:56.030901+00 |
| updated_at | 2026-01-23 04:16:37.982104+00 |
| description | High-performance incremental Bash parser for the oak ecosystem with flexible configuration, supporting shell scripting and automation workflows. |
| homepage | https://github.com/ygg-lang/oaks |
| repository | https://github.com/ygg-lang/oaks |
| max_upload_size | |
| id | 1891742 |
| size | 71,350 |
High-performance incremental Bash parser for the oak ecosystem with flexible configuration, optimized for script analysis and automation.
Oak Bash is a robust parser for Bash, designed to handle complete Bash syntax including modern features like conditionals, loops, and functions. Built on the solid foundation of oak-core, it provides both high-level convenience and detailed AST generation for script analysis and automation.
Basic example:
use oak_bash::{Parser, BashLanguage, SourceText};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let parser = Parser::new();
let source = SourceText::new(r#"
#!/bin/bash
NAME="World"
echo "Hello, $NAME!"
if [ "$NAME" == "World" ]; then
echo "It's a small world."
fi
"#);
let result = parser.parse(&source);
println!("Parsed Bash script successfully.");
Ok(())
}
use oak_bash::{Parser, BashLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
#!/bin/bash
echo "Hello"
"#);
let result = parser.parse(&source);
println!("Parsed Bash script successfully.");
use oak_bash::{Parser, BashLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
ls -la /tmp
grep "error" /var/log/syslog
"#);
let result = parser.parse(&source);
println!("Parsed Bash commands successfully.");
use oak_bash::{Parser, BashLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new("echo \"Hello World\"");
let result = parser.parse(&source);
// Token information is available in the parse result
use oak_bash::{Parser, BashLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
if [ -f /tmp/file ]; then
echo "File exists"
else
echo "File does not exist"
fi_invalid
"#);
let result = parser.parse(&source);
if let Err(e) = result.result {
println!("Parse error: {:?}", e);
}
The parser generates a comprehensive AST with the following main structures:
Oak Bash integrates seamlessly with:
Check out the examples directory for comprehensive examples:
Contributions are welcome!
Please feel free to submit pull requests at the project repository or open issues.