Skip to content
SailMasterGPublic

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Latest commit

 

History

204 Commits

Folders and files

Repository files navigation

This project has been created as part of the 42 curriculum by chguerre, rpinheir

C/C++ CI

Description

Minishell is a 42 team project where it's main goal is to build a simplified shell. In this project, the goal is to have a working shell with the same behaviour as bash, or at least what is possible to do.

Main functional parts of Minishell project:

1. Parsing:

The parsing must get the input from the user and categorize each word into a categorize it. Per example a pipe '|' is of category PIPE, a command like cat Readme.md are splitted then into two words (by whitespaces) and categorized 'cat' is a WORD and README.md is also a WORD. After each word in the input is categorized, we will then build what is called an AST, where everything is linked, the first node of commands have all the arguments and all the redirections that have been built by the parser. Per example ``` cat << EOF | grep $USER > user.txt:

2. Execution

Its in this part where we are going to setup the pipes, open files and execute the commands from the AST that was built by the parsing, see how many commands, open each file (fd) and setup the initialisation to have a working redirection and piping to execute properly the command given as input. Within the scope, we manage pipes, redirections, Posix signals like SIGINT (CTRL+C), build history based on recent inputs. There is also a environment cloning where we must manage environment variables, and so also using '$?' to get the exit status of the most recent execution and be able tokens expand variables with character '$'.

3. Built-ins

This part is where we build commands such as echo or even export, instead of using system programs we program our own following the same behaviour as bash built-ins.

Instructions

To build the project:

make

To run it you can either:

make run

or

./minishell

This will launch the program and will run until you close it (Ctr+D, exit, etc...)

Feel free to test with those examples:

ls -la
cat << A << B
ls | grep .c | wc -l
cat README.md | grep "Instructions"
cat << eof > here.log | cat here.log | grep "$USER"
USER
$USER
eof

Resources

AI usage

AI has been used for debugging purposes only, it has also been used to introduce new notions aside from reading other sources to get a better understanding quicker. Other than that, no AI has been used to do the coding in our place.

Minishell 42 Guides

Parsing/Lexer Theory

Videos

Others:

  • Code crafters -- non 42 project that is also very close to what we have to do

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages