|
|
Log in / Subscribe / Register

A shell in Rust could be really cool

A shell in Rust could be really cool

Posted Feb 12, 2025 21:20 UTC (Wed) by walters (subscriber, #7396)
In reply to: A shell in Rust could be really cool by koverstreet
Parent article: Rewriting essential Linux packages in Rust

There is https://www.nushell.sh/ and I use it as my interactive shell, which I'm *mostly* happy with - but man I have to say the biggest problem is I often spawn "stock" containers and virtual machines and those all default to bash so there's this unavoidable context switching.

But on the topic of scripts and testing - in bootc I started to try to use nushell for some of our integration tests which are *mostly* just forking external processes, but have about 10% where you really want things like arrays.

You can get a good sense of what this is like from e.g. this test:
https://github.com/containers/bootc/blob/main/tests/boote...

A notable plus is that it's super easy to parse JSON from a subprocess without falling back to jq and thinking about its mini-language and then parsing that back into bash.

But a downside is we've been caught twice by subtle incompatible nushell changes:
- https://github.com/containers/bootc/pull/911/commits/6f80...
- https://github.com/containers/bootc/pull/937/commits/28e8...

I hope this won't happen too much more often...

---

If you want to approach this a different way and write a regular Rust program but fork subprocesses with as little ceremony and overhead as possible, I heartily recommend https://crates.io/crates/xshell

It's really cool because it makes use of Rust macros to do what you can't easily do in Go or Python - correctly quote subprocess arguments referring to Rust local variables.


to post comments


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds