Minishell is a simple UNIX shell implementation developed as part of the 42 School curriculum. The project aims to recreate a basic shell environment, mimicking the behavior of the Bash shell, and to deepen understanding of processes, file descriptors, and system calls.
- Written in C
- Implements a minimal shell with support for:
- Command execution
- Built-in commands:
echo,cd,pwd,export,unset,env,exit - Redirections:
>,<,>>,<< - Pipes:
| - Environment variable expansion
- Signal handling (
Ctrl+C,Ctrl+\,Ctrl+D) - Command history navigation (up/down arrows)
- Utilizes system calls such as
fork,execve,waitpid,pipe,dup2,signal,kill,getcwd,chdir,open,close,read,write,malloc,free,perror,exit,printf,access,readline,rl_clear_history,rl_on_new_line,rl_replace_line,rl_redisplay,add_history, andrl_replace_line.
- Implement a prompt that displays and waits for user input
- Parse and execute simple commands with arguments
- Implement built-in commands:
echo(with-noption)cd(with relative or absolute paths)pwd(no options)export(with no options)unset(with no options)env(with no options or arguments)exit(with exit status)
- Handle redirections:
>: redirect output<: redirect input>>: append output<<: here-document
- Implement pipes (
|) to connect multiple commands - Expand environment variables in commands (e.g.,
$HOME,$PATH) - Handle signals:
Ctrl+C: terminate current processCtrl+\: quit shellCtrl+D: exit shell
- Implement command history navigation using up/down arrows
| Key Combination | Action |
|---|---|
Enter |
Execute the current command |
Up / Down |
Navigate through command history |
Ctrl + C |
Terminate the current process |
Ctrl + \ |
Quit the current process |
Ctrl + D |
Exit the shell |
Clone and build the project:
git clone https://github.com/IzaroArbaiza/Minishell.git
cd Minishell && makeRun the shell:
./minishell