uutils/findutils

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

开放

#816 创建于 2026年8月7日

 (1 条评论) (0 个反应) (0 位负责人)Rust (98 个派生)user submission
good first issue

仓库指标

星标
 (639 个星标)
PR 合并指标
 (平均合并 26天 6小时) (30 天内合并 46 个 PR)

描述

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

贡献者指南