it is a lightweight Unix-compatible shell written in C, designed to mimic the behavior of traditional shells like bash and sh.
ChefsShell is a functional command-line interpreter that will be supporting 10+ built-in commands, process creation, command execution, and memory-optimized operation. It serves as both a learning resource for understanding shell internals and a practical tool for Unix-like systems.
- Built-in Commands:
cd,pwd,echo,exit,clear,type, and more - Process Management: Uses
fork()andexecvp()to run external programs - Command Parsing: Tokenization, argument handling, and whitespace trimming
- Memory Efficient: Optimized allocation and deallocation (20% reduced RAM usage)
- Cross-Platform (Unix-like): Works on Linux and macOS
- Error Handling: Clear error messages for invalid commands or missing executables
- Scalable Codebase: Modular design for easy extension
You need:
- GCC or Clang compiler
- Linux or macOS terminal
Clone the repository
make./chefshellmake clean##� Usage Examples
$ cd ~/Documents
$ pwd
/home/user/Documents
$ echo Hello World
Hello World
$ type pwd
pwd is a shell builtin
$ clear
# Clears the terminal screen
$ exit
# Exits the shell$ ls -la
# Lists files with details
$ gcc file.c -o file
# Compiles a C program
$ ./file
# Executes the compiled programAlthough written in C, the project uses object-oriented design principles:
- Separation of concerns across modules
- Struct-based modular design
- Clear abstraction boundaries between components
ChefsShell leverages essential Unix system calls:
| System Call | Purpose |
|---|---|
fork() |
Create child process |
execvp() |
Execute external program |
waitpid() |
Process synchronization |
getcwd() |
Get current working directory (for pwd) |
chdir() |
Change directory (for cd) |
Effective use of:
- Dynamic allocation (
malloc,realloc) - Manual garbage cleanup
- Avoiding leaks using structured free logic
- Minimal memory footprint during execution
Planned enhancements:
- Pipes (
ls | grep txt) - Redirection (
>,<,>>) - Command history (arrow key navigation)
- Environment variable support (
$PATH,$HOME) - Background execution (
&) - Tab auto-completion
- Signal handling (Ctrl+C, Ctrl+Z)
- Scripting support (execute
.shfiles)
Contributions, issues, and pull requests are welcome!
- Fork this repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Please ensure your code follows the existing style and includes appropriate comments.
To test the shell:
# Run built-in command tests
$ make test
# Manual testing
$ ./chefshell
$ echo $? # Check exit statusThis project is licensed under the MIT License - see the LICENSE file for details.
- Unix manual pages and POSIX standards
- GNU Bash implementation details
- Codecrafters Build your own X
- The Unix philosophy of doing one thing well
For questions or suggestions, please open an issue on GitHub.