uutils/findutils

`-printf` panics on an invalid-UTF-8 format string (exit 101)

Ouverte

#816 ouverte le 7 août 2026

 (1 commentaire) (0 réaction) (0 personne assignée)Rust (96 forks)user submission
good first issue

Métriques du dépôt

Stars
 (635 étoiles)
Métriques de merge PR
 (Merge moyen 26j 6h) (46 PRs mergées en 30 j)

Description

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

Guide contributeur