A fully-featured, memory-safe shell implementation built from scratch
Recreating the magic of bash with advanced features, robust error handling, and production-quality memory management
Minishell is a comprehensive shell implementation that replicates the core functionality of bash. This project demonstrates mastery of:
- System Programming - Process creation, inter-process communication, signal handling
- Memory Management - Custom garbage collector, leak prevention, buffer overflow protection
- Parsing & Lexical Analysis - Command parsing, variable expansion, wildcard matching
- Advanced Shell Features - Pipelines, redirections, built-in commands, environment management
- Interactive Command Line with readline integration
- Command Execution with PATH resolution
- Built-in Commands:
echo,cd,pwd,export,unset,env,exit - Environment Variable Management with dynamic expansion
- Pipeline Support - Multi-command pipelines with proper process management
- I/O Redirection - Input/Output redirection (
<,>,>>) - Here Documents - Interactive input with delimiters (
<<) - Variable Expansion - Dynamic variable substitution (
$VAR,$?) - Wildcard Matching - Glob pattern expansion (
*.c) - Signal Handling - Proper SIGINT and SIGQUIT handling
- Memory Safety - Custom garbage collector prevents leaks
- Error Handling - Comprehensive error management with proper exit codes
- Debug Mode - Built-in debugging capabilities for development
- Valgrind Clean - Zero memory leaks, production-ready
Advanced debugging features showing tokenization, parsing, and execution flow
Our systematic approach to tackling complex challenges through organized task management
Key Challenges Conquered:
- โ Memory Management - Implemented dual garbage collectors for command vs environment memory
- โ Buffer Overflow Prevention - Dynamic allocation for variable expansion
- โ Fork Memory Leaks - Child process memory cleanup
- โ Signal Handling - Proper signal management in interactive mode
- โ Pipeline Execution - Complex multi-process coordination
- โ Variable Expansion - Safe, dynamic string processing
- โ Wildcard Matching - Efficient glob pattern implementation
minishell/
โโโ ๐ฏ Core
โ โโโ minishell.c # Main program loop
โ โโโ minishell.h # Global definitions
โ โโโ Makefile # Build system
โโโ ๐ง Lexer & Parser
โ โโโ lexer/ # Tokenization & variable expansion
โ โโโ parser/ # Command parsing & AST generation
โโโ โ๏ธ Executor
โ โโโ executor/ # Command execution & built-ins
โ โโโ signals/ # Signal management
โโโ ๐ง Utilities
โ โโโ utils/ # Helper functions & utilities
โ โโโ gc/ # Garbage collection system
โโโ ๐ Debug
โโโ debugging/ # Development & debugging tools
typedef struct s_minishell {
t_gc gc; // Command-specific memory (cleaned per command)
t_gc env_gc; // Environment memory (persistent across commands)
// ... other components
} t_minishell;- Input Processing โ Tokenization โ Parsing โ AST Generation
- Command Resolution โ Built-in Detection โ PATH Lookup
- Process Management โ Fork/Exec โ Pipeline Coordination
- Memory Cleanup โ Garbage Collection โ Resource Deallocation
- GCC compiler
- GNU Readline library
- Make build system
- Linux/Unix environment
# Clone the repository
git clone <repository-url>
cd MINI_SHELL
# Build the project
make
# Run minishell
./minishell# Basic commands
minishell$ echo "Hello, World!"
minishell$ pwd
minishell$ cd /tmp
# Pipelines
minishell$ ls -la | grep "\.c" | wc -l
# Variable expansion
minishell$ export MY_VAR="test"
minishell$ echo $MY_VAR
# Redirections
minishell$ echo "Hello" > output.txt
minishell$ cat < input.txt >> output.txt
# Here documents
minishell$ cat << EOF
> This is a here document
> EOF# Enable debug mode
make debug
./minishell
# Clean build
make clean && make- Valgrind Clean - Zero memory leaks detected
- Buffer Overflow Protection - Dynamic allocation prevents crashes
- Double-Free Prevention - Garbage collector manages all allocations
- Built-in Commands - All bash built-ins implemented
- Pipeline Testing - Complex multi-command pipelines
- Edge Cases - Comprehensive error handling
- Signal Testing - Proper signal behavior verification
- Memory Usage - Efficient allocation with automatic cleanup
- Execution Speed - Optimized command processing
- Reliability - Robust error handling and recovery
This project represents collaborative excellence in system programming, showcasing:
- Advanced C Programming - Complex data structures, memory management
- System Programming - Process control, IPC, signal handling
- Software Architecture - Clean, maintainable, scalable design
- Problem Solving - Systematic approach to complex challenges
- Team Collaboration - Coordinated development using Kanban methodology
- โ Zero Memory Leaks - Production-grade memory management
- โ Full Bash Compatibility - Complete feature implementation
- โ Advanced Debugging - Comprehensive development tools
- โ Robust Architecture - Scalable, maintainable codebase
- System Programming Mastery - Deep understanding of Unix systems
- Memory Management Expertise - Custom allocator implementation
- Advanced C Skills - Complex project architecture in C
- Software Engineering - Professional development practices

