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.
-
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-Fflags.pwd: Display the current working directory.cat: Concatenate and display file contents.cp: Copy files and directories.rm: Remove files and directories (supports-rflag 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+Dgracefully.
-
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 $.
- Displays a
- Low-Level System Calls:
- Commands implemented using system calls like
syscall.Open,syscall.Read, etc., avoiding high-level abstractions.
- Commands implemented using system calls like
- Interrupt Management:
- Handle
Ctrl+Cgracefully without terminating the shell.
- Handle
- 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).
- Support for command chaining (e.g.,
- Enhanced Aesthetics:
- Add color coding for directories, files, and error messages.
- 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.
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$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.
- Clone the repository:
git clone https://github.com/your-username/0-shell.git
- Navigate to the project directory:
cd 0-shell - Compile the program (example for C):
gcc -o 0-shell shell.c
- Fork the repository.
- Create a new branch:
git checkout -b feature-name
- Commit your changes:
git commit -m "Add feature-name" - Push the branch:
git push origin feature-name
- Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
- Inspired by the simplicity of BusyBox.
- Thanks to the Unix community for extensive documentation and resources.