This project implements a simple UNIX command interpreter shell in C programming language, capable of running commands in both interactive and non-interactive modes. It provides a basic understanding of how shells work and serves as a starting point for further exploration and customization.
- Runs in both interactive (REPL) and non-interactive modes
- Implements built-in
exit
andenv
commands - Splits input into tokens using a delimiter
- Forks processes to execute commands from
$PATH
- Searches across list of paths to locate commands
- Outputs error if command not found
- Counts number of commands executed
shell
- Decides whether to run in interactive or non-interactive mode
shell_interactive
- Implements REPL loop prompting for user input
shell_noninteractive
- Reads input from stdin and executes
handle_execution
- Parses input and executes commands
execute_fork
- Spawns process and runs command using execve
Input/Output
- Implement output redirection (> and >>)
- Implement input redirection (< and <<)
- Implement pipes (|) to connect commands
Additional Builtins
- Add more built-in commands like echo, help etc.
User Customization
- Set up initialization script to run on shell start
- Add command history and search
- Support tab autocompletion
Error Handling
- Improve control-C signal handling
- Enhance error messages and logging
Batch/Scripting
- Support running script files with multiple commands
- Handle line continuation with backslash
- Add conditional logic and loops
Ensure you have the following installed:
- C Compiler (e.g., GCC)
- Standard C Library Headers
Clone the repository and compile the source code:
git clone https://github.com/mohamedtharwat000/simple_shell.git
cd simple_shell
gcc -o your_shell_name *.c
Run the shell:
./your_shell
Enter commands interactively.
Run the shell with a script:
./your_shell < script.txt
Provide a script with commands to execute non-interactively.
Contributions are welcome! Here are some ways you can contribute to this project:
- Report bugs and issues
- Fix bugs and issues
- Add new validation functionality
- Improve styling and overall UX
- Refactor code to improve quality
- Write documentation and improve existing docs
To contribute:
- Fork the repository
- Create a new branch
- Make your changes and commit them
- Push your branch and submit a pull request
I will review pull requests and provide feedback.
This project is open source and available under the MIT License.
Created by Mohammed Khalid and Mostafa Mokhtar