Lobsters | 原文链接 | 2026-09-06 收录

指着错误说话:uutils 给 coreutils 引入编译器式诊断

来源: uutils.org — 2026-08-31

概述

uutils 的核心工具自 0.11.0 起,为解析类错误引入了「编译器式」诊断——像 rustc 那样用一个尖号(caret)明确指出是哪个参数、甚至哪个字符让解析器绊倒。它只作用于那些「小语言」参数:test 表达式、chmod 模式、sort key、tr 集合等。当 stderr 是终端时,错误会回显参数为源码行 + 尖号标记 + 一句语法帮助,比传统「告诉你错在哪、却不告诉你在哪一行错」的 Unix 错误友好得多。

核心要点

金句

When one of those fails to parse, what you actually want to know is which argument, or which character of it, the parser tripped over. rustc has been answering that question with a caret for years.
返回 Lobsters 首页