Skip to main content

Module command_cwd

Module command_cwd 

Source
Expand description

Which directory a command’s segments actually run in (GH #1661, #1662).

A tool call carries one cwd, but the command it runs may move: cd repo && grep -rn … . walks a tree the call never named, and cd "$SCRATCH" && curl -o shot.png … writes to a directory that is sanctioned for exactly that. Judging either against the call’s cwd alone gets the answer wrong — too lenient in the first case, too strict in the second.

Only a plain leading cd <literal> is followed. Anything the shell would have to evaluate — a variable, a substitution, pushd, a subshell — leaves the directory unknown, and an unknown directory is reported as such rather than guessed at.

Structs§

SegmentCwd
One command segment together with the directory it runs in.

Functions§

final_cwd
The directory in effect once every segment has run.
join_in
Join rel under base, keeping a POSIX-rooted base POSIX.
segments_with_cwd
Split command into segments, tracking cd as it goes.