Minishell is a simplified version of a Unix shell designed as a project for understanding and implementing essential shell functionalities. It replicates core behaviors of bash, focusing on process management, file descriptors, and interprocess communication. This project challenges developers to dive deep into the world of system programming, memory management, and user interaction.
- Command Prompt: Displays a customizable prompt while waiting for user input.
- Command Execution: Executes binaries using
PATH
or relative/absolute paths. - Command History: Keeps a history of executed commands for easy recall.
- Redirections:
- Input (
<
): Redirects input from a file. - Output (
>
): Redirects output to a file. - Append (
>>
): Redirects output in append mode. - Here-doc (
<<
): Reads input until a specified delimiter is encountered.
- Input (
- Pipes (
|
): Connects the output of one command to the input of another.
- Expansion: Handles
$VAR
to expand environment variables. - Exit Status: Implements
$?
to display the exit status of the last executed command.
- Handles
ctrl-C
,ctrl-D
, andctrl-\
signals:ctrl-C
: Interrupts the current command and shows a new prompt.ctrl-D
: Exits the shell.ctrl-\
: Does nothing, similar to bash.
Minishell implements the following built-in commands:
echo
: Supports the-n
option.cd
: Changes the current working directory.pwd
: Prints the current working directory.export
: Adds or modifies environment variables.unset
: Removes environment variables.env
: Displays all environment variables.exit
: Exits the shell with a specified exit code.
- Logical Operators: Supports
&&
and||
with parenthesis for priority. - Wildcards (
*
): Matches patterns in the current directory.
- Written in C.
- Memory management ensures no leaks (excluding
readline
library leaks). - Compatible with the following system calls and libraries:
readline
,fork
,execve
,pipe
,dup2
,signal
, and many more.
- Clone the repository and navigate to the project directory.
- Compile the shell using the provided Makefile:
make
- Run Minishell:
./minishell
- Type commands as you would in a typical shell.
Minishell is not just about writing code; it's about understanding the foundational concepts of Unix-like systems. By creating this mini bash, you’ll gain insights into the intricacies of shells and the challenges of system-level programming. Dive in and make your shell as beautiful as possible!