Skip to content

anonymousc/minishell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Minishell

A minimal shell implementation written in C. Minishell replicates core features of bash, including command execution, pipes, redirections, environment variable expansion, and built-in commands.

Features

  • Command Execution – Run external binaries resolved via $PATH
  • Pipes – Chain commands with |
  • Redirections – Input (<), output (>), append (>>), and heredoc (<<)
  • Built-in Commandscd, pwd, echo, export, env, unset, exit
  • Environment Variables$VAR expansion and $? for the last exit status
  • Quote Handling – Single quotes (literal) and double quotes (with expansion)
  • Signal HandlingCtrl+C, Ctrl+D, Ctrl+\
  • Memory Management – Centralized garbage collector to prevent leaks

Project Structure

.
├── main.c                  # Entry point – read, parse, execute loop
├── Makefile                # Build configuration
├── include/
│   └── minishell.h         # Type definitions and function declarations
├── parsing/
│   ├── lexer/              # Tokenization of input
│   ├── syntax/             # Syntax validation
│   ├── expansion/          # Environment variable and tilde expansion
│   └── parser/             # Build execution structures from tokens
├── execution/
│   ├── builtins/           # Built-in command implementations
│   ├── executer_core/      # Command execution engine
│   ├── heredoc/            # Heredoc processing
│   └── redirections/       # I/O redirection handling
└── others/
    ├── MiniLibc/           # Custom C library (strings, ctypes, printf)
    ├── garbage_collector/  # Memory tracking and cleanup
    ├── signals.c           # Signal handlers
    └── envadd.c            # Environment variable utilities

Requirements

  • C compiler – GCC or Clang
  • GNU Make
  • readline librarylibreadline-dev (Debian/Ubuntu) or readline (macOS via Homebrew)

Build

make        # Compile the project
make clean  # Remove object files
make fclean # Remove object files and the executable
make re     # Full rebuild

Usage

./minishell

Once running, minishell displays a prompt and accepts commands just like bash:

minishell$ echo "Hello, World!"
Hello, World!
minishell$ ls -la | grep .c | wc -l
1
minishell$ export MY_VAR=42
minishell$ echo $MY_VAR
42
minishell$ exit

Authors

About

minishell

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors