Skip to content

vanl0/minishell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

141 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Minishell, building a shell

A demanding project at 42 School that, once completed, marks a significant improvement in programming skills. The premise is rather simple, create a program that recreates a shell, including its most commonly used features such as pipes, redirections, signals and built-ins using exclusively C language.

This project takes a closer look at the functioning of the commands and interface we use everyday to move ourselves through the computer.

The work was divided into two main components: the lexer and the parser. The lexer is responsible for analyzing and validating the input provided by the user or from a file descriptor. It detects syntax errors, such as incorrect use of quotes (" or ') or other special symbols, and tokenizes the input into structured elementsβ€”typically separating the command from its arguments and redirections. This organization allows the parser to efficiently interpret and execute the commands, without worrying about low-level input validation.

Input: echo "Hello $USER" > greeting.txt
     β”‚
     β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚     Lexer     β”‚ --> β”‚     Parser    β”‚ --> β”‚   Executor    β”‚     β”‚   Output      β”‚
β”‚---------------β”‚     β”‚---------------β”‚     β”‚---------------β”‚     β”‚---------------β”‚
β”‚ - Tokenize    β”‚     β”‚ - Validate    β”‚     β”‚ - Run command β”‚     β”‚ greeting.txt  β”‚
β”‚ - Detect ""   β”‚     β”‚ - Expand vars β”‚     β”‚ - Builtin     β”‚     β”‚ contains:     β”‚
β”‚ - Separate    β”‚     β”‚ - Redirectionsβ”‚     β”‚ - Redirect >  β”‚     β”‚ "Hello <USER>"β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

About

Recreating a shell from scratch, including its most commonly used features such as pipes, redirections, signals and built-ins using exclusively C language.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors