Skip to main content

is_eval_safe_invocation

Function is_eval_safe_invocation 

Source
pub fn is_eval_safe_invocation(tokens: &[Token]) -> bool
Expand description

Returns true iff this invocation is tagged eval-safe — meaning its stdout is documented shell-init code that can safely be substituted inside eval "$(...)".

The walker descends through DispatchKind::Branching AND DispatchKind::Custom matching subs token-by-token (handler-based commands such as gh can have tagged TOML-declared subs even though the handler does the actual dispatch). The leaf is the deepest matched node (where no further sub matches). eval_safe is checked only at the leaf — ancestor tags do NOT propagate. After confirming the leaf is tagged, every --prefixed token in the remaining tail must appear in eval_safe_flags; positionals are unrestricted.

Tagged nodes are vetted manually per-command (see SAMPLE.toml). This function does not validate that tokens is syntactically allowed — callers must have already passed it through the regular dispatcher.