$ show uutils/coreutils
This repository is a comprehensive Rust reimplementation of the GNU coreutils, providing approximately 100 standard Unix command-line utilities (cat, cp, cut, df, du, echo, false, fmt, head, id, kill, ln, ls, mv, nl, od, ptx, pwd, rm, seq, tac, tee, tr, tty, wc, who, yes, arch, base32, base64, basenc, chmod, chroot, comm, csplit, date, dirname, dircolors, expand, expr, factor, fold, groups, hostid, hostname, install, join, link, logname, md5sum, mkdir, mkfifo, mknod, mktemp, more, nice, nohup, nproc, numfmt, paste, pathchk, pinky, pr, printenv, printf, readlink, realpath, rmdir, sha*sum, shred, shuf, sleep, sort, split, stat, stdbuf, stty, sum, sync, tail, test, timeout, touch, tr, truncate, tsort, tty, uname, unexpand, uniq, unlink, uptime, users, vdir, wc, who, whoami, yes, and more). The project aims to be a drop-in replacement for GNU coreutils with exact output matching, improved error diagnostics, comprehensive internationalization, and cross-platform support (Linux, macOS, *BSD, Windows, WASI). It has been adopted by Ubuntu starting from version 25.10. Architecturally, each utility lives in its own crate under src/uu/, with a shared library crate (uucore) providing common infrastructure: error handling (UResult, UError), display helpers (Quotable, println_verbatim), argument parsing (via clap with localization), diagnostics (caret-based error messages), internationalization (Fluent translations, ICU-based locale support), platform abstractions (Unix, Windows, WASI), and various utility modules (encoding, checksums, quoting styles, parsers, permissions, etc.). The project supports both individual binary builds and a multicall binary (coreutils) that dispatches based on argv[0]. A separate binary (uudoc) generates manpages and shell completions. Key data flows are standard for CLI tools: utilities read from stdin or files, process the input according to command-line options, and write results to stdout or files. The project places heavy emphasis on correctness and compatibility, with an extensive test suite (unit tests, integration tests, fuzzing, benchmarks) and continuous integration that compares output against GNU coreutils. External dependencies include clap (argument parsing), Fluent (localization), ICU (locale-aware collation and formatting), and various platform-specific crates for system calls and file operations. The codebase demonstrates strong engineering practices: modular design, feature-gated compilation, platform-specific backends, SIMD optimizations (wc, tr, encoding), multi-threaded external sort, and careful security patterns (O_NOFOLLOW, O_EXCL, TOCTOU avoidance). It is actively maintained with frequent commits, responsive issue triage, and regular releases.
The LLM identified 6 files worth highlighting for reuse:
Provides SIMD-accelerated encoding and decoding for multiple bases (Base64, Base64-url, Base32, Base32-hex, Base16, Base2, Z85, Base58). The implementation uses platform-specific SIMD intrinsics (AVX2, SSE2) for high throughput and falls back to portable algorithms. This module is self-contained, exposes a clean API, and can be extracted into any Rust project needing efficient binary-to-text encoding.
Implements shell-safe quoting for displaying filenames and other strings in error messages and output. Handles single quotes, double quotes, and dollar-single-quote styles with proper escaping. This is a self-contained utility that can be reused in any CLI tool that needs to display arbitrary strings safely in a shell context.
Parses human-readable size strings with SI (1000-based) and IEC (1024-based) suffixes (e.g., '10K', '2.5M', '1GiB'). Handles fractional values, multiple suffixes, and overflow detection. The parser is parameterized by block size and can be used by any utility that accepts size arguments (dd, truncate, fallocate, etc.). It is well-tested and independent of the rest of the codebase.
Implements a high-performance multi-threaded merge for external sorting. Uses mpsc channels, a binary heap, and background reader threads to merge multiple sorted runs efficiently. Supports compressed temporary files via a trait interface. The merge logic is generic and can be extracted for any project needing to merge multiple sorted streams with minimal memory overhead.
Implements the tee utility with a MultiWriter that can write to multiple outputs simultaneously. On Linux, it uses splice() and tee() syscalls for zero-copy data transfer between file descriptors, significantly improving throughput. The writer handles errors per output without aborting others. This pattern is reusable for any tool that needs to duplicate output streams efficiently.
Provides a caret-based error diagnostic system that highlights the exact position of an error in a command-line argument or input. Supports multi-line snippets, colorized output, and localization. This is a self-contained module that can be extracted to add user-friendly error messages to any CLI application, especially those with complex argument parsing.