Skip to content

FlorentBelotti/42_cursus_minishell

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

42_cursus_minishell---------------------------------------------------

C

Summary---------------------------------------------------

Introduction---------------------------------------------------

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.

Common Instructions---------------------------------------------------

  • 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, and re.

Mandatory Part---------------------------------------------------

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, and ctrl-\.
  • Implement built-in commands: echo, cd, pwd, export, unset, env, and exit.

Code Overview---------------------------------------------------

Parsing

(To be filled by partner)

Execution

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 the cd built-in command.
  • ft_echo.c: Implementation of the echo built-in command.
  • ft_env.c: Implementation of the env built-in command.
  • ft_exit.c: Implementation of the exit built-in command.
  • ft_export.c: Implementation of the export built-in command.
  • ft_pwd.c: Implementation of the pwd built-in command.
  • ft_unset.c: Implementation of the unset built-in command.

Feedback---------------------------------------------------

By Florent Belotti

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.

Organization and Task Distribution---------------------------------------------------

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.

Execution Breakdown---------------------------------------------------

For this project, I divided the execution into four main parts:

  1. 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.

  2. 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.

  3. 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.

  4. 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.

Conclusion---------------------------------------------------

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.

Thanks---------------------------------------------------

Thanks to ZomDev for his guidance and help throughout this project.

Releases

No releases published

Packages

No packages published

Languages

  • C 83.6%
  • Makefile 16.4%