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)
Thu, Apr 11, 2:58 PM
Unknown Object (File)
Wed, Apr 10, 3:39 AM
Unknown Object (File)
Thu, Apr 4, 11:03 PM
Unknown Object (File)
Fri, Mar 22, 7:00 AM
Unknown Object (File)
Jan 28 2024, 6:40 PM
Unknown Object (File)
Jan 11 2024, 5:48 AM
Unknown Object (File)
Dec 23 2023, 3:02 AM
Unknown Object (File)
Dec 19 2023, 6:28 PM
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.