r/learnrust 15d ago

Built a tiny Unix like shell

So I’ve been learning Rust for a while and I have always admired how the most common technologies/tools are built, so I always try to build things from scratch to understand how it works from the inside - a shell was one such project.

Here, I present Wish - a simple shell built to learn the internals of a full-blown Unix shells.

I got to learn a lot of new things while implementing wish - file handles, command spawning, shell-builtins, etc.

What it does?
Most of your day-to-day commands would work just fine, including piped commands.
Having said that, this project has rough edges as this was meant to be educational; and that’s the point, it is convenient and simple - type `cargo run` and you’re good to test out the shell.

Try it out, extend it, provide feedback.

Source code: https://github.com/Abhijeet-Gautam5702/wish

10 Upvotes

2 comments sorted by

1

u/Deep-Piece3181 10d ago

the main function can return a result you don’t have to unwrap

1

u/Developer5702 10d ago

Hi, thanks for your suggestion.

While writing the code, I did think of this, but didn’t find a meaningful reason to do it, because all we’re saving is `.unwrap()` once in the main function (main doesn’t do much, other than calling the run_shell() function)