Ramblings of an aging IT geek
← Ramblings of an aging IT geek
rust

i rewrote a 40-line shell script in rust and i'd do it again

A small log-tidying CLI I rebuilt in Rust to learn the language, and an honest take on whether the effort paid off for something this trivial.

Rust source code on a terminal

The tool does almost nothing: it walks a directory, finds log files older than a threshold, and either lists them or deletes them. It was a forty-line shell script for years and it worked fine. So rewriting it in Rust was, by any sensible measure, a waste of an evening.

I did it anyway, partly to learn the language properly and partly because the shell version had quietly accumulated edge cases. Filenames with spaces, the find flag I could never remember, a dry-run mode bolted on with an if. Small papercuts, but papercuts.

Rust made me say out loud what the script had been getting away with. clap gave me a real --dry-run flag and a proper --help for free. Errors I'd been ignoring with 2>/dev/null became things I had to actually handle, and a couple of them turned out to be real: a permissions case the script had been silently swallowing for years.

Was it worth it for a tool this size? Strictly, no. The compile-times-and-borrow-checker tax on something this trivial is hard to justify. But I learned more from this daft little program than from any tutorial, the binary is one file with no runtime to install, and I trust it in a way I never quite trusted the script. For learning, absolutely worth it. I just wouldn't put that in the business case.