Skip to main content

parse_with_substitutions

Function parse_with_substitutions 

Source
pub fn parse_with_substitutions(command: &str) -> (ParsedPipeline, Vec<String>)
Expand description

Parse a shell command string into a pipeline of segments and a list of extracted substitution contents.

§Returns

(pipeline, substitutions) where:

  • pipeline.segments — one ShellSegment per evaluable command, with __SUBST__ placeholders where substitutions were extracted.
  • pipeline.operators — the shell operators (&&, ||, ;, |, |&) between consecutive segments.
  • substitutions — the inner command text of each outermost $(), backtick, <(), or >() substitution, in source order. The eval layer evaluates these recursively.

§Trivial case

When the command is a single simple statement with no substitutions and no control flow unwrapping, the original command text is returned as-is in a single segment. This lets the eval layer’s evaluate_single fast path work on the exact input text.