2

Minishell — 42 Barcelona

Minishell is a fully functional Unix shell recreation built in C as part of the 42 Barcelona curriculum. It implements command parsing, pipes, redirections, environment variables, signal handling and process control, mimicking the behavior of Bash while respecting strict memory and coding standards.

🐚 Minishell

Minishell is a Unix-like shell developed entirely in C following the strict rules of the 42 Barcelona curriculum.
The project recreates essential shell behavior: parsing, pipes, redirections, environment variables, signals, and process execution, all while ensuring zero memory leaks and handling complex edge cases.


šŸš€ Features

šŸ”¹ Command Execution

  • Handles simple commands (ls, echo, grep, etc.)
  • PATH resolution
  • Built-in optimization for internal commands

šŸ”¹ Pipes (|)

Support for executing pipelines such as:

šŸ”¹ Redirections

  • Input <
  • Output >
  • Append >>
  • Heredoc <<

šŸ”¹ Builtins Implemented

  • cd
  • echo
  • pwd
  • export
  • unset
  • env
  • exit

šŸ”¹ Signals

  • Custom handling for:
    • Ctrl+C
    • Ctrl+\
    • Ctrl+D

šŸ”¹ Error & Memory Management

  • No leaks (checked with valgrind)
  • Graceful error messages
  • Defensive programming against invalid syntax

🧠 What I Learned

  • Tokenization, parsing and abstract syntax tree logic
  • Linux process management (fork, execve, wait)
  • File descriptors and dup2()
  • Handling race conditions and edge cases
  • Writing clean and modular low-level C code
  • Full debugging workflow using Valgrind & GDB

šŸ”— Repository

šŸ‘‰ GitHub: https://github.com/zmetreveli/minishell