Page MenuHomeFreeBSD

find: Add GNU find's -printf
Needs ReviewPublic

Authored by imp on Jan 20 2023, 7:50 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Dec 7, 1:59 AM
Unknown Object (File)
Thu, Dec 5, 11:14 PM
Unknown Object (File)
Wed, Dec 4, 9:03 AM
Unknown Object (File)
Mon, Nov 25, 1:55 AM
Unknown Object (File)
Sat, Nov 23, 8:47 PM
Unknown Object (File)
Sat, Nov 23, 7:49 AM
Unknown Object (File)
Fri, Nov 22, 7:53 AM
Unknown Object (File)
Thu, Nov 21, 2:08 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 Skipped
Unit
Tests Skipped
Build Status
Buildable 54507
Build 51396: arc lint + arc unit

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
15

probably added by accident :D

16

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
16

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
105

\\ needs to be special-cased to not warn

143
usr.bin/find/function.c
1415

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
270

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

282

typo

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

usr.bin/find/find.1
1042

This should be written out or removed. Otherwise LGTM.