Build Your Own Shell using Rust

submited by
Style Pass
2024-12-14 03:30:06

This is a tutorial on building your own shell using Rust, in the spirit of the build-your-own-x list. Creating a shell is a great way to understand how the shell, terminal emulator, and OS work together.

A shell is a program which allows you to control your computer. It does this largely by making it easy to launch other applications. But a shell on it's own isn't an interactive application.

Most users interact with the shell through a terminal emulator. A concise description of a terminal emulator by user geirha follows:

The terminal emulator (often just called terminal) is "just the window", yes. It runs a text based program, which by default is your login shell (which is bash in Ubuntu). When you type characters in the window, the terminal draws these characters in the window in addition to sending it to the shell's (or other program's) stdin. The characters the shell outputs to stdout and stderr get sent to the terminal, which in turn draws these characters in the window.

In this tutorial, we'll write our own shell and run it inside our normal terminal emulator (wherever you'd typically cargo run).

Leave a Comment