Repository navigation
Closes the known gaps listed in 1.1.0's README, following the review by
@_shift_MIND (Claude + Codex, round after round). Every gap= row in tests/cases.py
is now a real expectation.
Added
-
One parser for the whole text. Quotes and heredocs span lines;
\-newline joins lines;<<counts only as an
unquoted operator (not inside quotes,$((…))or<<<);<<\EOF,<<-, several heredocs on one line;
redirections are dropped with their target (2>/dev/null rm -rf $D);$'…'is decoded; zsh$=Dis dynamic;
~+is the working directory, and a quoted"~"is a plain name. -
Command heads behind any wrapper. The command is the first
rm/find/shell/… word behind a wrapper, so
wrapper options need no table:env -u X,sudo -u U,timeout -s KILL 60,exec -a,caffeinate -i,
stdbuf,coproc,watch,busybox,grm,function f {, and GNU prefixes of--recursive(--rec). -
Quoted expansions are judged by their values. An unknown variable is empty, so
rm -rf "$D"/*isrm -rf /*.
$HOME,$PWD,$(pwd),$(git rev-parse --show-toplevel),${D:-.},${D%/*},${D?}and literal
assignments earlier in the command (D=/; rm -rf "$D") are resolved. Only"${D:?}"guarantees a value. -
Globs and braces are expanded against the filesystem and every match is judged:
.git/*,repo/*,.[!.]*,
*/.git,**/.git,{..,x}. Anything inside a.gitdirectory is protected. -
Strings the shell parses again are checked:
bash -c,sh -c,zsh -lc,eval,trap,env -S,su -c,
watch, a here-string or a heredoc fed to a shell,echo … | sh, and the$(…)/ backticks of an unquoted heredoc. -
findis judged likerm -runless a name test narrows it (a literal character, not negated, not able to match
.git):find ., the implicit.,-mindepth,-type f,-name '*',-regex '.*', an-obranch.-H -L -P
are skipped;-exec /bin/rm,-execdir,-okand-exec sh -ccount as deletes. -
xargs rm -ris blocked unless the input is NUL- or newline-separated (-0,-d '\n'). -
cdis followed:cd .. && rm -rf repo,pushd,env -C,sudo -D;( … )restores the directory; after;
both the old and the new directory count (the cd may have failed);cd x || exitandif cd x; thenare certain.
cd build && rm -rf *is no longer blocked. -
Scripts:
bash FILE/source FILEare read whatever the extension; a quoted script variable ("$S"); 8 levels
deep; a heredoc written to a file (>,tee, a variable target) and run later in the same command. -
Edit / MultiEdit are judged on the file they produce, and only the issues an edit adds are reported (an unrelated
edit to a legacy script passes). Write is judged the same way against the file it replaces. -
~/.claudeand~/.sshare protected;rsync --delete*is judged on its destination ("$DST/"with an empty DST
is/). -
The Monitor tool is checked like Bash.
--installupgrades an existing entry (its matcher gains the missing
tools, its command is updated) instead of reporting "already registered"; it warns on Windows. -
Review panel (four reviewers: shell parser, values and globs, find/xargs/cd, scripts and edits; their rows are
P1-*intests/cases.py). Fixed on their findings:$(…)is read like the shell reads it: an apostrophe in a"$(cat <<'EOF' … EOF)"commit message no longer
hides the rest of the command; comments andcasepatterns inside$(…)too.- Wrappers are read with their option arities (
sudo -u "$U",timeout "$T",env FOO=$X,flock FILE -c,
/usr/bin/time -v,noglob), sotimeout 30 git rm -r --cached .is no longer taken forrm. bash -euo pipefail FILE,bash -s ARGS, positional arguments (bash -c '…' _ ~,./x.sh .,f ~for a
function defined in the same command),trap --,su -lc,evalthat changes directory, andbash -c "$CMD"
with CMD assigned in the same command.- Unquoted heredocs are judged as the text the shell receives (
\$Dis$D;$OUTis its known value). - Scripts written with
echo/printfand run,>>appends, a script rewritten and run again, more than 8 levels
of scripts (blocks), NUL bytes in scripts (no crash), and a bare command name no longer looked up in the cwd. findprimaries are evaluated in order and per-obranch inside parentheses; a name pattern built from a
variable, or one that matches names inside.git(-name objects), does not narrow unless.gitis pruned;
a narrowed find that matches the working directory by name blocks;-type lnarrows;find … -print0 | xargs -0 rmandls | xargs -d '\n' rm -rare judged by what they print.cd x &&+ newline,cd x || { …; exit; },set -e,if ! cd x,cd --,env -C..,$(cd .. && pwd),
$(dirname …),$(mktemp -d),~-and$OLDPWDafter a cd.- Conditional and
+=assignments,${V:=w},${V%…}/${V#…}of known values, globs,~and braces infor
lists,{~,x}, a directory holding a repository one level down,~/.claude/hooksand~/.claude/projects,
rsyncoption arguments and sources without a trailing slash,*.*. - Limits: the glob budget is per glob, a huge brace range is cheap, too many values block, and checking stops
after 5 s (and blocks) instead of running into the hook timeout. - Edit diffs count repeated issues; Write/Edit of
~/.bashrc,.envrc,.husky/*and.git/hooks/*is checked. --installleaves a*or empty matcher alone, adds a separate entry instead of widening one shared with
another hook, recognises our hook by its file name, refuses malformed settings, and backs up only on change.
-
Review panel, round 2 (an adversary and a regression reviewer on the round-1 fixes; rows
P2-*):$(…): the wordcaseas an argument ("$(echo edge case)") and a heredoc closed byEOF)no longer hide
the rest of the command."$@"and"${A[@]}"are judged element by element when the arguments are known (bash -c 'rm -rf "$@"' _ ~,
f ~,./x.sh ~); arrays (DIRS=(. build)); exported andNAME=valueprefix variables reach scripts and
bash -c;sourceruns in the caller's shell (its variables, functions and cd stay);$0/BASH_SOURCEare set
for scripts;RM=rm; $RM -rf;source <(echo …);echo … | tee x.sh && bash x.sh;printf '%s\n' ….- Variables after
if/case/loops and&&chains: an assignment used in its own branch is certain; after the
block every path's value counts (if/elseandcasewith a*)arm cover every path).esaccloses the case. - Functions are checked where they are called, with the call's arguments; a call is followed once per distinct
arguments and a function calling itself is not followed (sourcing nvm took 5 s and blocked; it takes ~0.5 s now).
A function that is never called is checked once with unknown arguments. find: an unknown name pattern (-name "$PAT") does not narrow; real branch names inside.gitare tested;
-path ./.git -prune -o … -print0 | xargs -0 rmpasses; nested-repetition regexes are not run (they could hang).cd -follows OLDPWD,popdthe pushd stack;eval "cd x" && …;set +o errexit,set -- -e; a function that
always exits after||;sudo -Hu root;env "NAME=$V";xargs -I{}(whole lines) is accepted.>>reports only what it adds; caches of clones (~/.cache/pre-commit,build/_deps,.terraform, cargo, Go)
are not protected as "a directory holding a repository"; a submodule or linked worktree (.gitis a file) does
not protect its parent directory, since its history lives elsewhere (the directory itself is still protected).--installno longer adds a second entry on every run for a shared entry, and raises a timeout below 10 s.
Changed
- Block messages say why:
would delete the filesystem root contents (when D is empty or unset). - Git's temporary state inside
.git(rebase-merge,rebase-apply,sequencer,worktrees/<name>) may be
deleted; everything else inside.gitis protected.