Skip to content

d3bvstack/minishell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

319 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

minishell

minishell-cover-image

What is this?

This is our take on the 42 minishell project: a small Unix-like shell built in C.

This project was developed by:


d3bvstack

marcogmurciano

The goal was not to clone Bash 1:1, but to build a shell that feels real in day-to-day use: run commands, chain programs with pipes, redirect input/output, use environment variables, handle signals properly, and support the essential builtins you expect.

If libft was about learning C fundamentals, minishell is where everything starts to click together: parsing, process management, file descriptors, signals, and error handling all in one place.

What can this minishell do?

At a high level, you can:

  • Run external commands from PATH or by direct path (/bin/ls, ./my_program)
  • Chain commands with pipes (|)
  • Redirect input/output with <, >, >>
  • Use heredoc (<<) to feed multiline input
  • Expand environment variables ($HOME, $USER) and last exit code ($?)
  • Work with single and double quotes
  • Use core builtins to navigate and manage your environment
  • Handle Ctrl+C and Ctrl+\ in a shell-appropriate way

In short: enough to feel like a real shell while staying within minishell scope.

Builtins included

  • echo with -n flag
  • cd
  • pwd
  • export
  • unset
  • env
  • exit

What this project covers (learning-wise)

This project forced me to connect several core systems topics:

  • Tokenizing and parsing user input into executable structures
  • Building and executing pipelines across multiple processes
  • Managing redirections and heredoc safely
  • Tracking and propagating exit statuses
  • Coordinating parent/child signal behavior
  • Maintaining environment state between commands
  • Cleaning up memory and resources in long-running interactive loops

What this minishell does not try to be

This is a pedagogical shell, not a full Bash replacement.

So things like advanced Bash features are out of scope here (for example: &&, ||, command substitution, wildcards/globbing, job control, aliases, etc.).

Build and run

From the project root:

make
./bin/minishell

Useful targets:

make clean
make fclean
make re

Project structure (quick view)

  • src/tokenization: splits raw input into tokens
  • src/syntax: builds command structures and validates syntax
  • src/expansion: handles $VARIABLE and $? expansion
  • src/execution: runs commands, pipelines, redirections, heredoc logic
  • src/builtins: shell builtins
  • src/signals: interactive signal behavior
  • src/environment: environment list/array management

Final note

This project is where "I know C syntax" turns into "I can build systems software with C".

It is opinionated, scoped, and intentionally not everything under the sun, but it covers the heart of what makes a shell a shell.

About

A simple Unix shell implementation in C, supporting command execution, built-in commands, environment variables, pipes, and redirections. Developed as part of the 42 school curriculum to deepen understanding of process management and shell behavior.

Topics

Resources

Stars

Watchers

Forks

Contributors