Skip to content

lasere77/minishell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

44 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

This project has been created as part of the 42 curriculum by mcolin, ykolacze.

PROJECT 42 : Minishell >_

This project will allow you to explore the shell, or command language interpreter, for the GNU operating system, Bourne Again Shell, more commonly known as bash.

πŸ“– Description Minishell

The Minishell project consists of recreating a mini command interpreter (shell) in C, similar to bash, but with a limited and specific set of features. It is a core project of the common curriculum, as it combines parsing, process management, signals, and memory.

🧠 what we have learned

  • Undertsand the mechanics of bash.

  • How to execute a binary from our own program and make multiple executables communicate with each other

  • Understand signals, and how to handle them with the launch of another executable

  • Understand the use of environment

πŸ“œ None of this would have been possible without you. Thank you.

eblondee: πŸ‘‘ Thank you for all the hours spent teaching us strace! 🧦

ehode: 🐐 Thank you for destroying our minishell multiple times! πŸ‘οΈ

rgramati: πŸ—Ώ Thanks for ALL, literally! πŸ₯–

🌳 Tree

show

.
|-- Makefile
|-- README.md
|-- includes
|   |-- built_in.h
|   |-- ctx.h
|   |-- execute.h
|   |-- here_doc.h
|   |-- minishell.h
|   |-- parse.h
|   |-- sig.h
|   `-- utils.h
|-- libft
|   |-- Makefile
|   |-- includes
|   |   `-- libft.h
|   `-- srcs
|       |-- ft_atoi.c
|       |-- ft_bzero.c
|       |-- ft_calloc.c
|       |-- ft_free_double.c
|       |-- ft_isalnum.c
|       |-- ft_isalpha.c
|       |-- ft_isascii.c
|       |-- ft_isdigit.c
|       |-- ft_isprint.c
|       |-- ft_itoa.c
|       |-- ft_lstadd_back.c
|       |-- ft_lstadd_front.c
|       |-- ft_lstclear.c
|       |-- ft_lstdelone.c
|       |-- ft_lstiter.c
|       |-- ft_lstlast.c
|       |-- ft_lstmap.c
|       |-- ft_lstnew.c
|       |-- ft_lstsize.c
|       |-- ft_memchr.c
|       |-- ft_memcmp.c
|       |-- ft_memcpy.c
|       |-- ft_memmove.c
|       |-- ft_memset.c
|       |-- ft_putchar_fd.c
|       |-- ft_putendl_fd.c
|       |-- ft_putnbr_fd.c
|       |-- ft_putstr_fd.c
|       |-- ft_split.c
|       |-- ft_strchr.c
|       |-- ft_strcmp.c
|       |-- ft_strdup.c
|       |-- ft_striteri.c
|       |-- ft_strjoin.c
|       |-- ft_strlcat.c
|       |-- ft_strlcpy.c
|       |-- ft_strlen.c
|       |-- ft_strmapi.c
|       |-- ft_strncmp.c
|       |-- ft_strnlen.c
|       |-- ft_strnstr.c
|       |-- ft_strrchr.c
|       |-- ft_strtrim.c
|       |-- ft_substr.c
|       |-- ft_tolower.c
|       |-- ft_toupper.c
|       `-- get_next_line.c
|-- srcs
|   |-- built_in
|   |   |-- cd
|   |   |   |-- cd.c
|   |   |   |-- cd_utils.c
|   |   |   `-- cd_utils2.c
|   |   |-- echo.c
|   |   |-- env.c
|   |   |-- exit
|   |   |   |-- exit.c
|   |   |   `-- exit_utils.c
|   |   |-- export
|   |   |   |-- export.c
|   |   |   `-- export_parse.c
|   |   `-- pwd.c
|   |-- ctx
|   |   |-- ctx_destroy.c
|   |   |-- ctx_init.c
|   |   |-- declare_x.c
|   |   `-- env_init_default.c
|   |-- execute
|   |   |-- cmd_to_arg.c
|   |   |-- execute.c
|   |   |-- execute_built_in.c
|   |   |-- execute_chunk.c
|   |   |-- execute_cmd.c
|   |   |-- forgotten_child.c
|   |   `-- manage_redir.c
|   |-- here_doc
|   |   |-- get_here_doc.c
|   |   |-- here_doc.c
|   |   `-- parse_limiter.c
|   |-- minishell.c
|   |-- parse
|   |   |-- expand.c
|   |   |-- get_next_token.c
|   |   |-- parse.c
|   |   |-- parse_block.c
|   |   |-- parse_line.c
|   |   |-- parse_token_list.c
|   |   |-- syntax_error.c
|   |   `-- valid_line.c
|   |-- sig
|   |   `-- signal.c
|   `-- utils
|       |-- close.c
|       |-- env_utils.c
|       |-- error.c
|       |-- exec_utils.c
|       |-- free.c
|       |-- ft_split_expand.c
|       |-- ft_split_readline.c
|       |-- parse_utils.c
|       `-- utils.c
`-- valgrind.supp

πŸ“Œ Instructions

We use the folowing flags to compile the project: cc -MP -MMD -Wall -Werror -Wextra -g

  • make (doing the mandatory project minishell).
  • make clean (clean objects directories an files).
  • make fclean (clean all).
  • make re (clean all and remake).

πŸ› οΈ Commands

How to run it

The program should be executed as follows:

./minishell

It should behave like bash, within the limits of the project restrictions.

Valgrind

You can use these valgrind options to check for leaks, file descriptors, children and suppress leaks from readline:

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

ℹ️ Ressources

man bash

built-in

errno code

readline

strace

Pipeline

evolution of the parsing pipeline
The firts pipline

context struct:

First struct

syntax error:

syntax error

parse commands:

parse commands

The final pipline

context struct:

Final struct

syntax error:

syntax error

parse readline:

parse readline

parse cmd:

parse cmd

parse redir:

parse redir

execution

Pipeline execution

this is the global structure of the execution.

execute_pipeline

execution management:

execution management

conclusion

This project has taught us so much !!!
We never imagined we could take a project this far before.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors