You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
-printf panics on an invalid-UTF-8 format string (exit 101) #816
A -printf format string that is not valid UTF-8 panics during argument collection, before the format parser is ever reached.
$ find d -printf $'%\xff|\n'thread 'main' panicked at ...: called `Result::unwrap()` on an `Err` value
$ echo$?101
The panic is in std::env::args, which panics on non-UTF-8 arguments. Collecting via std::env::args_os and handling the invalid-UTF-8 case explicitly would let this produce a normal error (or match GNU, which accepts arbitrary bytes in the format string and passes them through).
I would like to work on this. My proposed minimal fix is to collect arguments with std::env::args_os() and return a normal diagnostic when an argument cannot be converted to UTF-8, rather than panicking. Could a maintainer confirm that a normal error is the desired behavior for now, instead of adding byte-preserving -printf support in the same change?
Activity
discrete-proof-notes commentedon Aug 7, 2026
I would like to work on this. My proposed minimal fix is to collect arguments with
std::env::args_os()and return a normal diagnostic when an argument cannot be converted to UTF-8, rather than panicking. Could a maintainer confirm that a normal error is the desired behavior for now, instead of adding byte-preserving-printfsupport in the same change?find: avoid panic on a non-UTF-8 argument
find: avoid panic on a non-UTF-8 argument
find: avoid panic on a non-UTF-8 argument