You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While recursing with -R (follow all symlinks), GNU grep reports a symlink whose target
does not exist (FILE: No such file or directory) and a symlink that leads back to an
ancestor (DIR: warning: recursive directory loop), and exits 2. uu_grep drops both
without a word and exits 0. Named on the command line the same dangling link is reported by
both tools, so only entries found during the walk are affected.
Related but different: #162 (-R skips FIFOs, sockets and devices).
Exposed by the GNU test symlink (grep -R '^' in a directory with a dangling link and a
link to . must exit 2).
$ LC_ALL=C /usr/bin/grep -R needle
/usr/bin/grep: self: warning: recursive directory loop
/usr/bin/grep: broken: No such file or directory
real.txt:needle
# Exit code: 2
Test
#[cfg(unix)]#[test]fndereference_recursive_reports_dangling_link_and_loop(){let(scene,mut c) = ucmd();
scene.fixtures.mkdir_all("top");
scene.fixtures.write("top/kept.txt","moss\n");
scene.fixtures.symlink_file("missing-target","top/dead");
scene.fixtures.symlink_dir(".","top/again");
c.args(&["-R","moss","top"]).fails_with_code(2).stdout_is("top/kept.txt:moss\n").stderr_contains("top/dead: No such file or directory").stderr_contains("recursive directory loop");}
Activity
grep: report dangling symlinks and directory loops with -R