Skip to content

find: respect symlink following in -lname and -ilname - #941

Open
zhangpan2001 wants to merge 1 commit into
uutils:mainfrom
zhangpan2001:fix/lname-followed-symlinks
Open

zhangpan2001 wants to merge 1 commit into
uutils:mainfrom
zhangpan2001:fix/lname-followed-symlinks

Conversation

@zhangpan2001

Copy link
Copy Markdown
Contributor

-lname and -ilname matched valid symlinks even when find followed them with -H, -L or -follow, because both matchers always read the link target. GNU makes both false for followed symlinks; with -H, only command-line starting points are followed. Check the entry's file type first so followed links no longer match. Dangling links still match.

Add tests for both predicates on command-line paths and descendants, covering dangling links and -follow before and after the predicate.

@codecov

codecov Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.81%. Comparing base (3b14698) to head (d5658b4).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #941      +/-   ##
==========================================
+ Coverage   92.79%   92.81%   +0.01%     
==========================================
  Files          37       37              
  Lines        8038     8042       +4     
  Branches      403      404       +1     
==========================================
+ Hits         7459     7464       +5     
+ Misses        437      436       -1     
  Partials      142      142              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed

codspeed Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning

⚠️ 15 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 20 untouched benchmarks


Comparing zhangpan2001:fix/lname-followed-symlinks (d5658b4) with main (d1ddcce)

Open in CodSpeed

Comment thread tests/test_find.rs Outdated
.no_stderr();
}

#[cfg(any(unix, windows))]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this cfg? it is always true for what we build

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, i got it, removed.

Comment thread tests/test_find.rs Outdated
}

let mut command = ucmd();
command.current_dir(root).env("LC_ALL", "C");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could the cases carry the args directly (before/after the predicate)? the mode == "-follow" branches are a bit hard to follow

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, I updated the cases to pass the arguments and expected outputs directly.

-lname and -ilname matched valid symlinks even when find followed them
with -H, -L or -follow, because both matchers always read the link
target. GNU makes both false for followed symlinks; with -H, only
command-line starting points are followed. Check the entry's file type
first so followed links no longer match. Dangling links still match.

Add tests for both predicates on command-line paths and descendants,
covering dangling links and -follow before and after the predicate.
@zhangpan2001
zhangpan2001 force-pushed the fix/lname-followed-symlinks branch from 1553741 to d5658b4 Compare November 3, 2026 03:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants