pub struct HeredocAssembler { /* private fields */ }Expand description
Assembles a heredoc body part-by-part, applying POSIX <<- leading-tab
stripping to the source rather than to the materialized result.
Leading tabs that were literal in the heredoc source are stripped; a tab
that arrives via an interpolation ($var value, $(cmd) output) at line
start is preserved, because POSIX strips tabs from source lines before
parameter expansion (bash agrees). Callers feed literal segments through
push_literal and interpolated values through
push_interpolated. With strip_tabs == false
this is a plain concatenation.
This replaces materialize-then-strip_leading_tabs, which ate tabs that
came from a variable’s value.
Implementations§
Source§impl HeredocAssembler
impl HeredocAssembler
pub fn new(strip_tabs: bool) -> Self
Sourcepub fn push_literal(&mut self, literal: &str)
pub fn push_literal(&mut self, literal: &str)
Append a literal source segment, stripping leading tabs at line starts
when in <<- mode.
Sourcepub fn push_interpolated(&mut self, value: &str)
pub fn push_interpolated(&mut self, value: &str)
Append an interpolated value verbatim. The interpolation terminates the leading-tab run for the current source line — even when it expands to empty — so a following literal tab on the same source line is mid-line and kept.