A POSIX-compliant shell in Rust, built for the CodeCrafters "Build Your Own Shell" challenge. Line editing and tab completion via rustyline; pipeline stages run concurrently, one thread per stage. A rewrite of my earlier C++ attempt.
- Builtins:
echo,pwd,cd(with~expansion),type,history,exit - External commands resolved via
PATH(checks the executable bit on every entry) - Quoting: single quotes, double quotes, and backslash escaping, following the
POSIX rule that inside double quotes
\only escapes",\,$and` - Redirection:
>,1>,>>,1>>for stdout,2>,2>>for stderr - Pipelines:
cmd1 | cmd2 | cmd3, one thread per stage - Tab completion of builtins and all
PATHexecutables - History:
history [n],history -r/-w/-a <file>, loads$HISTFILEon startup and saves on exit; appends only the entries added since the last save
$ ./your_program.sh
$ echo 'hello world' | tr a-z A-Z > /tmp/out.txt
$ history 2- How shell quoting works: the difference between single and double quotes, and when a backslash is special vs. literal
- How to wire up a command's input and output to pipes, files, or the terminal
- Running pipeline stages concurrently, so every command in
a | b | cruns at the same time - Adding line editing and tab completion with the rustyline library
| File | Role |
|---|---|
src/main.rs |
The entire shell: REPL + history (main), quoting/redirection parsing (PipelineCommand::new), pipeline setup (Pipeline::new), builtins + external spawn (PipelineCommand::run), tab completion (CommandCompleter) |