Skip to content

aniasse/0-shell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

0-Shell

Overview

The 0-Shell project involves creating a simple Unix shell to execute basic commands. The shell will allow you to interact with the Unix system by running commands, creating and managing processes, and synchronizing their execution. The goal is to build a minimal but functional shell, much like BusyBox, focusing on simplicity and core functionality.


Features

  • Basic Command Execution:

    • echo: Display a string or variables.
    • cd: Change the current working directory.
    • ls: List directory contents, including support for -l, -a, and -F flags.
    • pwd: Display the current working directory.
    • cat: Concatenate and display file contents.
    • cp: Copy files and directories.
    • rm: Remove files and directories (supports -r flag for recursive deletion).
    • mv: Move or rename files and directories.
    • mkdir: Create directories.
    • exit: Exit the shell.
  • Error Handling:

    • Custom error messages for invalid commands or operations.
    • Manage interruptions such as Ctrl+D gracefully.
  • Minimalistic Prompt:

    • Displays a $ prompt to signal readiness for a command.
    • Path display (bonus): Show the current path in the prompt, e.g., ~/Desktop/0-shell $.

Bonus Features

  • Low-Level System Calls:
    • Commands implemented using system calls like syscall.Open, syscall.Read, etc., avoiding high-level abstractions.
  • Interrupt Management:
    • Handle Ctrl+C gracefully without terminating the shell.
  • Auto-Completion:
    • Suggest or auto-complete commands and file paths while typing.
  • Piping and Redirection:
    • Support for command chaining (e.g., ls | grep file) and output/input redirection (e.g., ls > output.txt).
  • Enhanced Aesthetics:
    • Add color coding for directories, files, and error messages.

Requirements

  • Programming Language:
    • Use a compiled language such as C, Rust, or Go.
    • Interpreted languages are not allowed.
  • Good Practices:
    • Ensure clean, maintainable code following standard coding conventions.
  • Unix System Focus:
    • Explore Unix APIs for process creation and synchronization.

Usage

student$ ./0-shell
$ cd dev
$ pwd
dev
$ ls -l
total 0
crw-------  1 root   root     10,    58 Feb  5 09:21 acpi_thermal_rel
crw-r--r--  1 root   root     10,   235 Feb  5 09:21 autofs
drwxr-xr-x  2 root   root           540 Feb  5 09:21 block
crw-------  1 root   root     10,   234 Feb  5 09:21 btrfs-control
drwxr-xr-x  3 root   root            60 Feb  5 09:20 bus
$ something
Command 'something' not found
$ echo "Hello There"
Hello There
$ exit
student$

Learning Objectives

By completing this project, you will:

  • Deepen your understanding of Unix systems.
  • Explore process creation and synchronization using system calls.
  • Build and manage a command-line interface.
  • Learn the syntax and functionality of basic shell commands.
  • Improve your skills in low-level programming and error handling.

Installation

  1. Clone the repository:
    git clone https://github.com/your-username/0-shell.git
  2. Navigate to the project directory:
    cd 0-shell
  3. Compile the program (example for C):
    gcc -o 0-shell shell.c

Contributing

  1. Fork the repository.
  2. Create a new branch:
    git checkout -b feature-name
  3. Commit your changes:
    git commit -m "Add feature-name"
  4. Push the branch:
    git push origin feature-name
  5. Open a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.


Acknowledgments

  • Inspired by the simplicity of BusyBox.
  • Thanks to the Unix community for extensive documentation and resources.

About

Migration of 0-shell from Zone01 Dakar Gitea

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages