- Introduction
- Common Instructions
- Mandatory Part
- Code Overview
- Feedback
- Organization and Task Distribution
- Execution Breakdown
- Conclusion
- Thanks
The Minishell project is about creating a simple shell similar to bash. This project helps in understanding processes, file descriptors, and signal handling by implementing a functional command-line interface.
- The project must be written in C and conform to the coding norm.
- Functions must handle errors gracefully without causing unexpected termination (e.g., segmentation faults).
- All allocated memory must be properly freed to avoid leaks.
- A Makefile must be provided to compile the project with the necessary flags: -Wall, -Wextra, and -Werror.
- The Makefile should include at least the rules:
$(NAME)
,all
,clean
,fclean
, andre
.
Your Minishell must implement the following features:
- Display a prompt when waiting for a new command.
- Have a working history feature.
- Search and launch the right executable based on the PATH variable or using a relative or an absolute path.
- Handle single and double quotes, environment variables, and special characters like
$
and?
. - Implement redirections:
<
,>
,<<
, and>>
. - Implement pipes
|
. - Handle signals:
ctrl-C
,ctrl-D
, andctrl-\
. - Implement built-in commands:
echo
,cd
,pwd
,export
,unset
,env
, andexit
.
(To be filled by partner)
The execution part of the Minishell project includes the following files:
cmd_exec_utils.c
: Utility functions for command execution.cmd_exec.c
: Main command execution logic.cmd_path.c
: Handles the resolution of executable paths.cmd_process.c
: Manages the creation and handling of child processes.cmd_utils.c
: Additional utility functions for command processing.handle_pipes.c
: Functions to handle piping between commands.handle_redirections.c
: Functions to handle input and output redirections.builtin_path.c
: Functions related to path handling for built-in commands.builtin_utils.c
: Utility functions for built-in command handling.ft_cd.c
: Implementation of thecd
built-in command.ft_echo.c
: Implementation of theecho
built-in command.ft_env.c
: Implementation of theenv
built-in command.ft_exit.c
: Implementation of theexit
built-in command.ft_export.c
: Implementation of theexport
built-in command.ft_pwd.c
: Implementation of thepwd
built-in command.ft_unset.c
: Implementation of theunset
built-in command.
Minishell is one of the most daunting projects for 42 students, primarily due to feedback from previous cohorts. It’s our first group project, which means learning to collaborate on developing a program. Finding a good working dynamic with your partner is crucial.
This project is complex and often requires rethinking certain parts to integrate all necessary components. After completing a significant portion of the project, it is essential to redo series of tests whenever there is a change in logic to fix bugs. Therefore, it is important not to overload with tests and to remain reasonable about their number to validate the subject.
In our group, named "the brute and the cunning", ZomDev and I decided to clearly separate our responsibilities: he handled the parsing, and I took care of the execution. ZomDev, being slightly ahead in the curriculum, started before I did. His work on parsing allowed me to quickly develop an execution logic.
For this project, I divided the execution into four main parts:
-
Redirections:
It was crucial to define a method that would allow calling the same redirection function regardless of the execution case. This part took a lot of time, especially since I wasn't very comfortable with the concept after the Pipex project. Now, I feel more confident and proficient in this area.
-
Execution Loop:
Coming from Pipex, the execution loop seemed more straightforward, although Minishell required some adjustments, particularly for implementing certain builtins and managing memory leaks.
-
Implementing Builtins:
This part was the simplest, resembling the logic of the piscine and the first projects at the school. It didn't pose much difficulty.
-
Error Code Management:
My inexperience led me to consider this aspect only at the end of the "mechanical" development of the execution. This forced me to rethink part of the organization of my execution and perform tedious tasks, such as changing the return of certain functions. I suggest considering error management from the beginning, systematically researching the possible errors for each part of the execution and implementing them immediately.
Overall, my experience with Minishell was less stressful than some of my peers. Although I felt some pressure as my blackhole approached, being only a month away from the submission date, I benefited from the support of my more experienced partner. We collaborated effectively when I encountered difficulties and stayed focused on the execution.
Even if the project is complex, it significantly contributed to my learning in C. I feel more comfortable with managing processes and file descriptors than before, and I gained a deeper understanding of what a shell is and how it works.