TinyShell is a simple, minimalist shell implementation written in C, designed for educational purposes. It demonstrates the core concepts of how a shell works, including reading input, parsing commands, and executing system commands or built-in functions.
- Basic command parsing and execution.
- Built-in commands:
cd,help, andexit. - Execution of system commands via
execvp. - Simple loop for command input and execution.
To compile and run TinyShell, you need:
- A C compiler (e.g.,
gcc,clang). - Standard development tools (
make, etc.) if you wish to use a Makefile.
To compile TinyShell, navigate to the source code directory and run:
gcc -o tinysh main.cAfter compilation, you can start TinyShell by running:
./tinyshYou will be greeted with a simple prompt (> ) where you can type your commands.
cd [directory]- Change the current working directory.help- Display information about built-in commands.exit- Exit TinyShell.
To add new built-in commands:
- Define a new function for the command in the source code.
- Add the command name and function to the
builtin_strandbuiltin_funcarrays, respectively. - Ensure your command function returns
1to continue execution, or0to signal TinyShell to exit.
TinyShell is open-source software distributed under the MIT license. Feel free to modify, distribute, and use it as you see fit.
- This project is inspired by Stephen Brennan's tutorial on writing a shell in C.
- Special thanks to everyone who contributed to testing and providing feedback for TinyShell.
Enjoy experimenting with TinyShell!