Minishell is a simplified bash implementation written in C. It is designed to demonstrate mastery of process creation, synchronization, file descriptor management, and signal handling.
The project involves building a shell that can interpret and execute commands, handle pipes and redirections, and manage environment variables, mimicking the behavior of the popular bash shell.
- GCC or Clang compiler
makereadlinelibrary
# Install readline on Linux (Ubuntu/Debian)
sudo apt-get install libreadline-devThe project utilizes a Makefile to manage the build process.
| Command | Action |
|---|---|
make |
Compiles the minishell executable. |
make clean |
Removes object files. |
make fclean |
Removes object files and the executable. |
make re |
Recompiles the project from scratch. |
Run the executable to start the shell session.
./minishellYou can run commands just like in a standard bash shell.
minicecco:/home/s/Minishell> ls -la
minicecco:/home/s/Minishell> grep "int" main.c | wc -l
minicecco:/home/s/Minishell> echo "Hello 42" > hello.txt- Parsing: Tokenizes input, handles quotes (
'and"), and expands environment variables. - Execution: Uses
fork(),execve(), andwaitpid()to execute commands. - Pipes: Implements inter-process communication using
pipe()anddup2(). - Signals: Handles
Ctrl-C,Ctrl-D, andCtrl-\to mimic bash behavior.
The shell includes its own implementation of the following built-ins:
echo(with-n)cd(relative and absolute paths)pwdexportunsetenvexit
Supports standard input/output redirections:
<: Input redirection>: Output redirection<<: Here-document>>: Append output