Repository navigation
find: print special bits and no padding in -printf %m - #891
Conversation
Mask the mode with 0o7777 instead of 0o777 and drop the three-digit padding, as GNU find does: 4755 is printed as 4755, 044 as 44.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #891 +/- ##
==========================================
+ Coverage 92.27% 92.55% +0.27%
==========================================
Files 35 36 +1
Lines 7576 7732 +156
Branches 393 393
==========================================
+ Hits 6991 7156 +165
+ Misses 443 436 -7
+ Partials 142 140 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Merging this PR will not alter performance
|
| let temp_dir = Builder::new().prefix("example").tempdir().unwrap(); | ||
| let temp_dir_path = temp_dir.path().to_string_lossy(); | ||
|
|
||
| for (mode, expected) in [(0o4755, "4755 -rwsr-xr-x"), (0o044, "44 ----r--r--")] { |
There was a problem hiding this comment.
almost the same code as test_printf_permissions just above
could you please add (0o755, "755 -rwxr-xr-x") here and remove the old test?
Review: keep one permissions test that covers 755 along with the special-bit and short-mode cases.
|
Done: |
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
|
Thanks for your PR |
Part of #890.
-printf %mmasked the mode with0o777and padded it to three digits, so a setuid binary printed755,/tmpprinted777and a 044 file printed044. GNU find printsmode & 07777in plain octal:4755,1777,44. This uses{:o}ofmode & 0o7777and adds a unit test for 4755 and 044.On a tree with setuid, setgid, sticky, 000, 044 and 7777 modes,
-printf '%m %p\n'output is now identical to GNU find 4.9.0.cargo fmt --check,cargo clippy --all-targets -- -D warningsandcargo testpass.Written with AI assistance (Claude); I have reviewed the change.