This project is a custom implementation of a shell, similar to bash or zsh. It is a school project that aims to create a simple yet functional command-line interpreter.
The Minishell project is a classic exercise in system programming. It involves parsing user input, managing processes, and interacting with the operating system's kernel. This implementation is written in C and uses the readline library for input handling.
The project is structured into several modules:
shell/: Core shell functionality, history, and utilities.environment/: Environment variable management.runtime/: Command execution, redirection, and expansion.lexical_a/: Lexical analysis and tokenization.syntax_a/: Syntax analysis and here-doc handling.builtins/: Implementation of built-in commands likecd,echo,pwd, etc.optimization/: Command and here-doc optimization.library/: Containslibftandget_next_line.
To get a local copy up and running, follow these simple steps.
You need to have git and make installed on your system. You also need the readline library.
On Debian/Ubuntu, you can install it with:
sudo apt-get install libreadline-dev
- Clone the repo
git clone https://your_repo_link/minishell.git - Navigate to the project directory
cd minishell - Compile the project
make
This will create the minishell executable in the root directory.
To start the shell, run the following command:
./minishell
You will be greeted with a new prompt, ready to accept your commands.
Here are some examples of what you can do with Minishell:
-
Simple commands
ls -l -
Pipes
cat file1 | grep "hello" -
Redirections
ls > file.txt cat < file.txt -
Here-doc
cat << EOF hello world EOF -
Built-in commands
echo "Hello, World!" cd /path/to/dir pwd export VAR="value" unset VAR env exit
To remove the object files, run:
make clean
To remove the object files and the minishell executable, run:
make fclean