Skip to content

a minimal Unix-like shell written in Rust. It mimics the behavior of sh and supports basic commands with a focus on learning system programming concepts

Notifications You must be signed in to change notification settings

MohcineDev/0-shell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

0-Shell

0-Shell is a minimal Unix-like shell written in Rust. It mimics the behavior of sh and supports basic commands with a focus on learning system programming concepts, including file handling, metadata inspection, and process management.


Features

  • Execute standard shell commands: echo, pwd, cd, ls, exit.
  • ls implementation mimics GNU ls -al formatting:
    • Displays permissions, owner, group, size, modification time.
    • Supports hidden files and symbolic links.
    • Case-insensitive sorting, ignoring leading symbols for alphabetic order.
    • Correctly handles . and .. entries.
  • Safe printing to handle broken pipes (prevents panics).
  • Simple command parsing with multi-line input support for quoted strings.

Usage

  1. Clone the repository:
git clone <repo_url>
cd zero-shell
  1. Build and run the shell:
cargo run
  1. Example commands:
~$ pwd
/home/user

~$ ls -al
drwxr-xr-x   5 user  user      4096 Aug 27 12:09 .
drwxr-xr-x  23 user  user      4096 Aug 25 13:00 ..
-rw-r--r--   1 user  user         0 Aug 26 17:50 example.txt

Project Structure

  • src/main.rs — Entry point and main loop.
  • src/lib.rs — Core functions (command handlers, ls, utilities).
  • src/ls.rs — Implementation of ls command, including metadata formatting and sorting.

Notes

  • This shell is for learning purposes and does not support advanced shell features like piping, redirection, or background processes yet.
  • The sorting logic in ls is inspired by GNU ls and uses case-insensitive comparison and leading-symbol ignoring to approximate the correct order.

License

MIT License

About

a minimal Unix-like shell written in Rust. It mimics the behavior of sh and supports basic commands with a focus on learning system programming concepts

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages