minishell - shell tokenizer, AST parser, and executor in C
  • C 97%
  • Makefile 3%
Find a file
2026-08-03 17:55:04 +02:00
0_Libft Minishell initial commit 2026-08-03 17:55:04 +02:00
1_Srcs Minishell initial commit 2026-08-03 17:55:04 +02:00
Makefile Minishell initial commit 2026-08-03 17:55:04 +02:00
minishell.h Minishell initial commit 2026-08-03 17:55:04 +02:00
README.md Minishell initial commit 2026-08-03 17:55:04 +02:00
supp.supp Minishell initial commit 2026-08-03 17:55:04 +02:00

This project has been created as part of the 42 curriculum by acaspar, clao.

Description :

The main goal of minishell is to reproduce the shell. We will use bash as a reference for the project. We have to implement 7 built-in(PWD, ECHO, CD, ENV, EXPORT, UNSET, EXIT) and handle external commands (ls, cat for example) based on the PATH variable, using relative relative or absolute path. We will have a working history, we also need to handle 3 actions (Crtl-C, Ctrl-D, Ctrl-) like bash. We will also need to handle redirections ( < , << , >, >>). The pipes will work like the project PIPEX . We need to expand variable ( $USER = acaspar) in some case (double quote yes but single quote no), we also need to handle the exit status of the most recently executed foreground pipeline. Because we do the bonus, we also need to make || && and * working well. A lot of specific case are hidden and you will have to communicate with people and do research to find them.

Instruction :

To compile, you need to use "make" or "make re" and after "./minishell".

When you launch ./minishell you re inside the minishell and can do the test you need to do.

To use valgrind and supress the leak from readline you need to use :

valgrind --leak-check=full --show-leak-kinds=all --track-fds=yes --trace-children=yes --suppressions=supp.supp ./minishell

To try test without env you have to use "env -i ./minishell" and so you won t have env and external command won t work.

You can try logical operator like that for example:

echo a || echo b && echo c

this will print :

a c

Resources :

The use of AI was really usefull to find special and hiden cases / interactions of bash that we had no idea. The MAN was usefull too for what is needed or not, like the export built in with no argument say "When no arguments are given, the results are unspecified."

koor.fr helped us to discover what a new function is supposed to do.

https://harm-smits.github.io/42docs/projects/minishell showed us how to start and separate the project into differents parts. So we made each other a balanced amout of work.

The peer to peer was also crucial for this project to check if we didn t forget specials cases or if we respected the rules of the subject.

Technical choices

We did the project in 4 differents steps:

1 - Lexer :Tokenizes the input string into distinct meaningful units. 2 - Parser :Organizes tokens into an executable command structure. 3 - Expander : Handles environment variables (e.g., $VAR) and wildcards (*). 4 - Executor : Processes the command tree, handles pipes, redirections, logical operators, external command and built_in.