Skip to content

find: escape special characters in -ls and -fls names, as GNU does - #935

Open
jayhemnani9910 wants to merge 1 commit into
uutils:mainfrom
jayhemnani9910:ls-escape-names
Open

jayhemnani9910 wants to merge 1 commit into
uutils:mainfrom
jayhemnani9910:ls-escape-names

Conversation

@jayhemnani9910

Copy link
Copy Markdown
Contributor

-ls and -fls print names as they are, so a name with a newline spans two lines and one with a space can't be told apart from two fields:

$ touch 'sp ace' $'new\nline' 'é'
$ find . -type f -ls       # name column only
GNU 4.10:    main:
./\303\251    ./é
./new\nline  ./new
./sp\ ace    line
             ./sp ace

GNU find writes them with print_name_with_quoting (lib/listfile.c): a backslash before \, space and ", \n \b \r \t \f for those controls, and three octal digits for every other byte outside !..~. The link target after -> gets the same. This is not ls -b: " is escaped, \a is \007, and non-ASCII bytes are octal in any locale. -print, -printf %p and -print0 still print names unchanged.

New test find_ls_escapes_special_characters_in_names fails on main; cargo test passes, clippy and fmt clean. The names above now print as GNU prints them.

Copilot AI balanced review requested due to automatic review settings October 30, 2026 03:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

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.

@codecov

codecov Bot commented Oct 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.21053% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.77%. Comparing base (d71f324) to head (4b04867).

Files with missing lines Patch % Lines
src/find/matchers/ls.rs 84.21% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #935      +/-   ##
==========================================
- Coverage   92.79%   92.77%   -0.03%     
==========================================
  Files          37       37              
  Lines        8038     8055      +17     
  Branches      403      403              
==========================================
+ Hits         7459     7473      +14     
- Misses        437      440       +3     
  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 Oct 30, 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 jayhemnani9910:ls-escape-names (4b04867) with main (d71f324)

Open in CodSpeed

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