Skip to content

Latest commit

 

History

137 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Minishell        42 logo little

Language: C

Introduction

Minishell is a Unix shell recreation project written in C, developed as the first group project (duo) at 42 School The goal is to design a minimal Bash-like shell, handling user input, executing commands, and managing the environment using low-level system calls.

This project introduces essential topics such as:

  • Process creation and synchronization
  • File descriptors and redirection
  • Pipes
  • Signal handling
  • Terminal interaction and input parsing

📚 GNU Bash Manual (Reference)


Features

Command Execution

  • Parses and executes commands using execve.
  • Supports absolute, relative, and PATH-based executables.
  • Internal handling of built-in commands (no child process spawned).

Built-in Commands

  • echo [-n]
  • cd [dir]
  • pwd
  • export
  • unset
  • env
  • exit

Input Parsing

  • Handles 'single quotes' and "double quotes".
  • Expands environment variables like $USER or $?.

Redirections

  • < standard input
  • > standard output (overwrite)
  • >> standard output (append)
  • << heredoc support

Pipes

  • Fully supports pipelines (|) chaining multiple commands.

Signal Handling

  • Ctrl-C: resets prompt
  • Ctrl-D: exits shell
  • Ctrl-\: ignored in interactive mode

Global Variable Policy

  • Only one global variable allowed (to track signal values).

Usage

1. Build the project

make

2. Launch the shell

./minishell

3. Example session

$> echo "Hello, world!"
Hello, world!

$> export MOOD=calm
$> echo "Today I feel $MOOD"
Today I feel calm

$> cat << EOF
> This is a heredoc input
> EOF
This is a heredoc input

Team Members


Valgrind Suppression

This project uses the readline library, which causes known false-positive memory leaks in Valgrind.
A suppression file (supp.supp) is included to ignore these.

🔧 Usage

valgrind --leak-check=full --show-leak-kinds=all --suppressions=./supp.supp ./minishell

Technical Notes

  • Compliant with the 42 coding norm
  • Uses the readline library for input and history
  • Memory must be managed strictly (except readline leaks)
  • Only one global variable
  • Makefile includes: all, clean, fclean, re, and bonus

Screenshot

Capture d’écran 2024-08-02 à 02 34 22

About

A bash-like shell in C — parsing, pipes, redirections, env variables, signals & built-ins. 42 project.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages