bash_interop/stack/mod.rs
1//! A bash call stack, as an instrument records it — both halves.
2//!
3//! `stack.bash` ships bash's five parallel arrays as they are; [`Columns`]
4//! puts them back together. What comes out is a [`Stack`]: the frames one
5//! instrument reported, innermost first, never empty.
6
7mod columns;
8mod frame;
9
10pub use columns::{Args, Columns};
11pub use frame::{Frame, Site, Source, Stack};
12
13/// `__bc_stack`, which ships the five arrays. Private: an instrument reaches
14/// it through [`with_walk`], which is what puts it in the right place.
15const BASH: &str = include_str!("stack.bash");
16
17/// The frame walk, and a tool's own bash after it — the order the shells
18/// source them in.
19///
20/// `__bc_stack` has to be defined before anything calls it, so every
21/// instrument that reports a walk is built here rather than by joining strings
22/// at each tool.
23pub fn with_walk(bash: &[&str]) -> String {
24 let mut all = vec![BASH];
25 all.extend_from_slice(bash);
26
27 all.join("\n")
28}
29
30#[cfg(test)]
31mod tests;