Skip to content
/ 0-shell Public template

A minimalist Unix-like shell built in Rust, fast, reliable, and still evolving πŸ¦€ .

Notifications You must be signed in to change notification settings

BenaliOssama/0-shell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

82 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🐚 0-shell β€” A Minimalist Unix-like Shell in Rust

Authors

πŸ‘¨β€πŸ’» Omar Ait Benhammou πŸ‘¨β€πŸ’» Oussama Benali πŸ‘¨β€πŸ’» Mohamed El-Fihry πŸ‘¨β€πŸ’» Ibrahim El Harraq


🚧 Project Status: Work in Progress

We’re still actively developing and improving 0-shell.
Our team is continuously refining command handling, optimizing performance, and adding new features such as better error handling, I/O redirection, and enhanced piping support.

Stay tuned β€” future updates will bring more stability, usability, and functionality!

🧭 Overview

0-shell is a minimalist Unix-like shell implemented entirely in Rust, designed to run on Unix systems without depending on existing shells (like bash or sh) or external binaries.

Our shell handles core file system operations, process control, and command execution using Rust’s system-level abstractions, ensuring safety, robustness, and efficiency β€” ideal for embedded Linux or lightweight system environments.


βš™οΈ Features

βœ… Core Commands Implemented

Each command is written from scratch using Rust’s standard library and low-level system calls:

Command Description Supported Options
echo Prints text to standard output β€”
cd Changes the current working directory β€”
pwd Prints the current working directory β€”
ls Lists directory contents -l, -a, -F
cat Displays file contents β€”
cp Copies files β€”
mv Moves or renames files β€”
rm Removes files or directories -r
mkdir Creates directories β€”
exit Exits the shell β€”

🧩 Bonus Feature: Piping (|)

We implemented command piping, allowing output from one command to serve as input to another.

Example:

$ echo "hello world" | cat
hello world

Our shell uses inter-process communication (IPC) via Unix pipes and Rust’s std::os::unix::io API to connect child processes efficiently.


🧠 Learning Objectives

Through this project, we learned how to:

  • Use system calls for file and process management in Rust
  • Manage user input and shell loops
  • Handle process creation and synchronization (fork, exec, etc.)
  • Implement error handling and graceful exit on EOF (Ctrl+D)
  • Explore Unix design principles and shell behavior

πŸ’» Usage

Build

make

Run

make run

Example Session

$ pwd
/home/student
$ mkdir test && cd test
$ echo "Rust is fast!" > file.txt
$ cat file.txt
Rust is fast!
$ ls -l
-rw-r--r-- 1 user user 13 Nov 12 15:30 file.txt
$ echo "piping works" | cat
piping works
$ exit

⚠️ Error Handling

Unrecognized commands are handled gracefully:

$ something
Command 'something' not found

Pressing Ctrl+D exits the shell without crashing.


🎨 Future Improvements

Potential enhancements include:

  • Auto-completion for commands and paths
  • Command history
  • Environment variables ($HOME, $PATH)
  • Colorized prompt and output
  • I/O redirection (>, <)
  • Command chaining (;)

🧰 Technical Details

  • Language: Rust
  • System API: POSIX (via std::os::unix and nix crate equivalents if used)
  • Memory Safety: Fully guaranteed by Rust ownership model
  • Platform: Linux / Unix-based systems

πŸ“¦ Repository

πŸ”— 0-shell on Zone01 Oujda Git


🧾 License

This project is developed for educational purposes as part of the Zone01 Oujda curriculum. All contributors hold equal ownership of the code.

About

A minimalist Unix-like shell built in Rust, fast, reliable, and still evolving πŸ¦€ .

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5