Skip to content

grep: read devices and special files under -R when recursing - #254

Open
yunusarda-sudo wants to merge 1 commit into
uutils:mainfrom
yunusarda-sudo:grep-dereference-recursive-read-devices
Open

yunusarda-sudo wants to merge 1 commit into
uutils:mainfrom
yunusarda-sudo:grep-dereference-recursive-read-devices

Conversation

@yunusarda-sudo

Copy link
Copy Markdown
Contributor

When recursing directory hierarchies, GNU grep reads special files (FIFOs, sockets, device nodes) under -R (--dereference-recursive), but skips them under -r (--recursive) unless -D read is explicitly specified.

In src/searcher.rs, check whether devices should be read based on config.device_mode:

  • DeviceMode::Read: read
  • DeviceMode::Skip: skip
  • DeviceMode::Default: read if config.follow_symlinks (-R), otherwise skip

Fixes #162

GNU grep reads FIFOs, sockets and device nodes encountered under -R
(--dereference-recursive), and skips them only under -r (--recursive).

Fixes uutils#162
@codecov

codecov Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 97.18%. Comparing base (bf6f25e) to head (b51372d).

Files with missing lines Patch % Lines
src/searcher.rs 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #254      +/-   ##
==========================================
- Coverage   97.22%   97.18%   -0.04%     
==========================================
  Files           6        6              
  Lines        2270     2274       +4     
  Branches      245      245              
==========================================
+ Hits         2207     2210       +3     
- Misses         63       64       +1     
Flag Coverage Δ
macOS_latest 98.09% <80.00%> (-0.05%) ⬇️
ubuntu_latest 98.09% <80.00%> (-0.05%) ⬇️
windows_latest 0.00% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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 25, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning

⚠️ 1 benchmark is 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

✅ 10 untouched benchmarks
⏩ 17 skipped benchmarks1


Comparing yunusarda-sudo:grep-dereference-recursive-read-devices (b51372d) with main (bf6f25e)

Open in CodSpeed

Footnotes

  1. 17 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

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.

grep - grep -R skips FIFOs, sockets and devices found while recursing; GNU reads them

1 participant