Skip to content
Tech News
← Back to articles

Pointing at the error: compiler-style diagnostics in uutils coreutils

read original get The Rust Programming Language, 2nd Edition (No Starch Press) → more articles
Why This Matters

This article highlights a significant advancement in command-line tools by introducing compiler-style error diagnostics in coreutils. This innovation enhances user experience by providing precise, visual error localization, making debugging and understanding errors more intuitive for both developers and consumers. It represents a step forward in making command-line interfaces more user-friendly and accessible, especially for complex argument parsing scenarios.

Key Takeaways
Worth a Look

The Rust Programming Language, 2nd Edition (No Starch Press) — uutils coreutils is a Rust rewrite of the classic Unix tools, and this official No Starch Press guide is the standard way to learn the language behind it. If reading about ariadne-style caret diagnostics makes you want to hack on the project yourself, this is the book to start with.

See The Rust Programming Language, 2nd Edition (No Starch Press) on Amazon → Affiliate link — we may earn a commission on purchases, at no extra cost to you. Product picked by AI based on this article; it is not a tested recommendation.

Pointing at the error: compiler-style diagnostics in uutils coreutils

Sylvestre Ledru

For 50 years, Coreutils have never stopped evolving. Now, we're pushing that innovation further by rethinking how they report errors.

Unix tools report errors as a single line on stderr. That line says what went wrong, not where. For most commands there is nowhere else to point anyway, but a few take arguments that are small languages: a test expression, a chmod mode, a sort key, a tr set. 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, and ariadne puts the same rendering one dependency away. The idea of bringing it to a command-line tool comes from uutils awk, which already reports errors in an awk program that way; coreutils arguments are smaller languages, but they parse just the same. Starting with 0.11.0, coreutils uses it. When stderr is a terminal, a parse error is printed as a report: the arguments are echoed back as a source line, a caret marks the culprit, and a help line explains the syntax when we have something useful to say about it.

What it looks like

Start with tr , whose GNU message assumes you already know what a collating sequence is.

Before:

tr $ tr 'qw[y-b]' x tr: range-endpoints of 'y-b' are in reverse collating sequence order

After:

... continue reading