Page MenuHomeFreeBSD

find: Add GNU find's -printf
ClosedPublic

Authored by imp on Jan 20 2023, 7:50 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Oct 13, 4:13 PM
Unknown Object (File)
Sat, Oct 11, 3:07 AM
Unknown Object (File)
Wed, Oct 8, 7:49 AM
Unknown Object (File)
Thu, Oct 2, 9:17 AM
Unknown Object (File)
Fri, Sep 19, 9:01 AM
Unknown Object (File)
Sep 11 2025, 3:25 AM
Unknown Object (File)
Sep 8 2025, 5:24 AM
Unknown Object (File)
Jul 29 2025, 9:46 AM
Subscribers

Details

Summary

Implements most of gnu find's -printf predicate. However, the '#', '-',
'.' and size format modifiers are unimplemented, as are %P, %H, %F, %y,
and %Y formats. Follows what I think it should do based on the info
page, I've not looked at the gnu find code.

Sponsored by: Netflix

NOTE: Man page needs work. Also, this is the perfect case for tests additions, which also haven't been added yet.
Test Plan

Added several people that have touched find in the past few years to get review
Several are docs committers that can help me write the man page.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

imp requested review of this revision.Jan 20 2023, 7:50 PM
imp created this revision.
bapt added inline comments.
usr.bin/find/Makefile
13

probably added by accident :D

14

nitpicking here, but maybe consider open_memstream instead of sbuf? it will avoid adding an extra link to sbuf library for a very limited usage. feel free to totally ignore this nitpicking comment

usr.bin/find/Makefile
14

Sure. I resisted for a while, but the conversion was quicker than arguing :)

imp marked 2 inline comments as done.
usr.bin/find/printf.c
106

\\ needs to be special-cased to not warn

144
usr.bin/find/function.c
1410

We only need to force stat if certain formats are used. If it's just %p/%f/%h and literals, no stat calls are necessary.

usr.bin/find/printf.c
271

This will run off the end of the string if *fmt == '\0'.

283

typo

Usually LGTM, besides the part of the XXX (see comment).

usr.bin/find/find.1
1077

This should be written out or removed. Otherwise LGTM.

This revision was not accepted when it landed; it landed in state Needs Review.Jul 25 2025, 4:35 PM
This revision was automatically updated to reflect the committed changes.
usr.bin/find/function.c
1410

Oh my. Seems like I overlooked this. Fixed in a followup commit. Thanks for catching it.

usr.bin/find/printf.c
106

I'm not sure how to parse this. Can you say again in another way?