Skip to main content

effective_cwd

Function effective_cwd 

Source
pub fn effective_cwd(
    pipeline: &ParsedPipeline,
    session_cwd: &str,
) -> Vec<String>
Expand description

Determine the effective working directory for each git command in a pipeline.

Tracks cd <path> segments that propagate through && or ; operators. Pipe, pipe-err, or, and background operators reset to session cwd since cd in those contexts runs in a subshell or on the failure path.

Also handles git -C <path> by checking any git segment for a -C flag.

Returns a list of effective CWDs — one for each git segment encountered. If no git segments exist, returns a single-element vec with the final tracked CWD (preserving the previous behavior for non-git pipelines).