Skip to content

find: stop the -printf format at \c - #910

Merged
sylvestre merged 1 commit into
uutils:mainfrom
jayhemnani9910:printf-backslash-c-stops
Oct 24, 2026
Merged

sylvestre merged 1 commit into
uutils:mainfrom
jayhemnani9910:printf-backslash-c-stops

Conversation

@jayhemnani9910

Copy link
Copy Markdown
Contributor

GNU find's manual says \c in a -printf format means "Stop printing from this format immediately and flush the output." Here it only flushes, and the rest of the format is still printed:

$ ./target/debug/find a big -maxdepth 0 -printf '%p\c%s\n' -printf 'Z'
a80
Zbig1048577
Z
$ find a big -maxdepth 0 -printf '%p\c%s\n' -printf 'Z'    # GNU find 4.10.0
aZbigZ

The output loop now breaks after the flush. Later actions still run, as in GNU (the Z above), and -fprintf goes through the same code.

Tests: test_printf_backslash_c_stops_the_format checks that %f\c%s\n prints only the name. It fails on main. cargo test: 429 passed (428 on main), clippy and rustfmt clean. Compared A\cB\n, %p\c%s\n, \c, x\n\cy, [%f]\c and %p\n, each followed by another -printf, with GNU find 4.10.0: all the same.

Copilot AI balanced review requested due to automatic review settings October 20, 2026 05:56

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 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.

@codecov

codecov Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.58%. Comparing base (f967bc1) to head (caea6a0).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #910   +/-   ##
=======================================
  Coverage   92.57%   92.58%           
=======================================
  Files          37       37           
  Lines        7746     7754    +8     
  Branches      393      393           
=======================================
+ Hits         7171     7179    +8     
  Misses        435      435           
  Partials      140      140           

☔ 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 20, 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:printf-backslash-c-stops (caea6a0) with main (f967bc1)

Open in CodSpeed

@github-actions

Copy link
Copy Markdown

Commit ccabaef has test result changes:

GNU findutils testsuite:

Test results comparison:
  Current:   TOTAL: 495 / PASSED: 426 / FAILED: 68 / SKIPPED: 1
  Reference: TOTAL: 495 / PASSED: 425 / FAILED: 69 / SKIPPED: 1

Changes from main branch:
  TOTAL: +0
  PASSED: +1
  FAILED: -1

Test improvements (1):
  + tests/find/printf_escape_c

bfs testsuite:

Test results comparison:
  Current:   TOTAL: 317 / PASSED: 275 / FAILED: 36 / SKIPPED: 6
  Reference: TOTAL: 317 / PASSED: 274 / FAILED: 37 / SKIPPED: 6

Changes from main branch:
  TOTAL: +0
  PASSED: +1
  FAILED: -1

Test improvements (1):
  + gnu/printf_escapes

\c flushed the output but went on with the rest of the format, so
-printf "%f\c%s\n" printed the size and newline too. GNU find stops
printing from that format there: "Stop printing from this format
immediately and flush the output."
Copilot AI balanced review requested due to automatic review settings October 21, 2026 13:36
@jayhemnani9910
jayhemnani9910 force-pushed the printf-backslash-c-stops branch from ccabaef to caea6a0 Compare October 21, 2026 13:36

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 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.

@github-actions

Copy link
Copy Markdown

Commit caea6a0 has test result changes:

GNU findutils testsuite:

Test results comparison:
  Current:   TOTAL: 495 / PASSED: 426 / FAILED: 68 / SKIPPED: 1
  Reference: TOTAL: 495 / PASSED: 425 / FAILED: 69 / SKIPPED: 1

Changes from main branch:
  TOTAL: +0
  PASSED: +1
  FAILED: -1

Test improvements (1):
  + tests/find/printf_escape_c

bfs testsuite:

Test results comparison:
  Current:   TOTAL: 316 / PASSED: 274 / FAILED: 36 / SKIPPED: 6
  Reference: TOTAL: 317 / PASSED: 274 / FAILED: 37 / SKIPPED: 6

Changes from main branch:
  TOTAL: -1
  PASSED: +0
  FAILED: -1

Test improvements (1):
  + gnu/printf_escapes

No result in this run (1) - hung, crashed, or renamed:
  ? posix/o (was PASS)


let matcher = Printf::new("%f\\c%s\n", None).unwrap();
assert!(matcher.matches(&file_info, &mut deps.new_matcher_io()));
assert_eq!("abbbc", deps.get_output_as_string());

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.

in a new PR, could you please also add a test with a second -printf after the \c, to show the next action still runs?

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.

Added in #919.

@sylvestre
sylvestre merged commit 148f36f into uutils:main Oct 24, 2026
34 checks passed
@jayhemnani9910
jayhemnani9910 deleted the printf-backslash-c-stops branch November 13, 2026 14:33
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.

3 participants