Coder Social home page Coder Social logo

minishell-42's Introduction

Minishell

Minishell Project


→ As beautiful as a shell

Minishell is a 42-school project that aims to introduce us to the world of shells by recoding our mini-bash, a program that can parse, execute, and launch executables along with some built-in commands.

→ Used functions :

readline, rl_clear_history, rl_on_new_line, rl_replace_line, rl_redisplay, add_history, printf, malloc, free, write, access, open, read, close, fork, waitpid, signal, kill, exit, getcwd, chdir, execve, dup2, pipe, perror.

This is an overview of the project :

Group 8.png

→ Lexer :

  • input: Readline output
  • output: tokenized linked list
  • the objective of this step is to split the readline output using tokens (defined macros)
  • used tokens: WORD, REDIRECTION, PIPE, AND, SEMI, PARENTHESIS

→ Syntax analyzer:

  • input: tokenized linked list
  • output:
    • in case of no syntax error: same tokenized linked list.
    • in case of a syntax error: printed error type.
  • the objective of this step is to check all possible command syntax errors (if you have a doubt about an error take bash as a reference).

→ Parser :

  • input: tokenized linked list
  • output: commands linked list
  • we can split this step into 2 sub-steps
    • handling redirections (input, output, append, heredoc).
    • add command to the linked list with their file descriptors (in and out).

→ Execution :

  • input: commands linked list
  • if everything went okay in the past steps we have 2 different cases to communicate between the commands (processes):
    • if there are $N$ commands we initialize $N-1$ pipes to communicate between the processes we create.
    • In another case, if there’s some kind of redirection, it takes the priority
  • the only step left is to verify if the command is available or not there are two ways to handle it depending on the command itself
    • relative path
    • absolute path
  • in this part, the commands are ready to be executed

alwan.png

What is Env or Environment?

  • shell maintains an environment that includes a set of variables defined by a name, a user initialization, and system initialization.

What is Lexer or Tokenization?

What is Syntax Analysis:

  • It analyses the syntactical structure and checks if the given input is in the correct syntax of the programming language or not.

minishell-42's People

Contributors

younessabtaouri avatar yabtaour avatar amineredasaf avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

amineredasaf

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.