Skip to content

minishell, a 42 school team project to rebuild a tiny bash, using C language. Build with @Thais-Malheiros

License

Notifications You must be signed in to change notification settings

biralavor/42_minishell

Repository files navigation



Minishell, a tiny version of Bash -> B.orn A.gain SH.ell

The terminal is a file, therefor it treats all inputs as strings

Screenshot from 2024-08-20 15-11-03

Our Development Status

But first, let's talk about our TDD - Test Driven Development

What we are testing, until so far:

  • initial_errors, like unmachted quotes and parentheses
  • mixed quotes
  • crazy parentheses counter
  • creating the token linked list
  • syntax validations for words, pipes, and, or, pipes mixed with and and or
  • syntax validations for redirect_input, redirect_output, redirect_output_append, redirect_heredoc, mixed redirects, subshell
  • syntax rules for archive, word_after_archive, redirect_with_another_redirect
  • syntax rules for reorganize_redirects

Screenshot from 2024-07-15 19-26-19

1. Tokenization

  • Define Tokens for possible user's input:

Screenshot from 2024-08-05 16-42-40

2. Lexer

  • The hability to label specific strings as tokens, like below:

Check this test: echo oi > tudo > bem com voce > ?

Screenshot from 2024-07-15 19-29-04

3. Parser, or Syntax Grammar

  • The goal here is to create syntax grammar validations to avoid have a future binary tree with execution erros
  • We created Automata States, just to have a better workflow

Screenshot from 2024-08-05 16-58-40

4. Apply Redirect rules in Parse

  • The goal here is to:
    • Detects if there is more then one redirect type
    • If so, it move tokens to a new order, for an easier futher execution

Remember this test from Lexer? echo oi > tudo > bem com voce > ?

Screenshot from 2024-07-15 19-29-04

Now, we got un updated result:

Screenshot from 2024-08-05 16-56-17

6. Build the Binary Tree, in recursive mode

Screenshot from 2024-09-12 12-29-38

7. Preparing Execution in Binary Tree

The Binary Tree will be executed, following the metacharacters rules:

Screenshot from 2024-09-12 12-28-23

8. Execute

Screenshot from 2024-09-12 12-36-59

8.1. Expansion of special tokens

  • Expansion for:
    • Quotes "
    • tilde ~
    • dollar sign $

Screenshot from 2024-09-12 12-16-10

8.2 Built-ins

  • Built-in Detectors
  • Built-in Manager
  • Built-in Runners

Built-ins, if detected, or classic commands. Therefor, also have a bool builtin_detector() and void builtin_manager for both types of built-ins. If the input isn't a Built-in, it runs execve. We have two built-in categories for our minishell version:

  • Builtins without argument, like: env, pwd, exit.
  • Builtins with argument, like: echo, cd, export, unset.

Built-in Detectors

Screenshot from 2024-08-20 15-02-07

Built-in Manager

Screenshot from 2024-08-20 15-03-49

Built-in Runners, goes like this:

Screenshot from 2024-08-20 15-04-45

8.3 Command Manager

Screenshot from 2024-09-12 12-49-23

42sp Team Project:

About

minishell, a 42 school team project to rebuild a tiny bash, using C language. Build with @Thais-Malheiros

Resources

License

Stars

Watchers

Forks

Packages

No packages published