Skip to content

🐚 A fully functional mini shell written in C as part of the 42 school curriculum. Implements key shell features like built-in commands, pipelines, redirections (<, >, >>, <<), and environment variable expansion. Designed to mimic basic Bash behavior while exploring process creation, parsing, file descriptors, and terminal signal handling.

Notifications You must be signed in to change notification settings

elsayedamine/MINISHELL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🐚 Minishell

A simple Unix shell recreated in C as part of the 42 school curriculum. The project aims to deepen understanding of process creation, file descriptors, parsing, and terminal behaviors by implementing core shell features from scratch.


πŸ“Œ Project Description

Minishell is a simple shell built in C, mimicking behavior of Bash for essential features. It allows execution of user commands, supports built-in functions, handles redirections and pipelines, and includes basic environment variable expansion.

This project strengthens skills in:

  • Process management (fork, execve, wait)
  • Input parsing & tokenization
  • Signal handling (SIGINT, SIGQUIT)
  • File descriptor manipulation
  • Linked list data structures
  • Memory and error management

βœ… Features

  • βœ… Prompt display and interactive input loop
  • βœ… Command execution (both built-in and system binaries)
  • βœ… Built-in commands: cd, echo, env, exit, export, pwd, unset
  • βœ… Environment variable support ($VAR)
  • βœ… Redirections: <, >, >>, << (heredoc)
  • βœ… Piping with |
  • βœ… Quote handling (', ") with proper parsing
  • βœ… Signal management (e.g., Ctrl-C, Ctrl-\)
  • βœ… Error handling (syntax and execution)
  • βœ… Exit status propagation

πŸ“‚ Bonus / Extra Features (Optional)

  • These are not required but can boost your grade or show off your skills:
  • Wildcard expansion (*)
  • Subshells: (...)
  • Logical operators: &&, ||
  • Command grouping with {} or (...)
  • History handling (using readline)
  • Line editing (readline handles this)
  • Custom builtins (e.g., help or clear)

πŸ”§ Installation & Usage

# Clone the repo
git clone https://github.com/aelsayed1337/minishell.git
cd minishell

# Compile
make

# Run
./minishell

πŸ—‚οΈ Example Commands

$ echo "Hello World"
$ export USERNAME=amin
$ echo $USERNAME
$ ls -l | grep ".c" > sources.txt
$ cat << EOF
> multiline
> input
> EOF

βš™οΈ Technical Details

  • Language: C (C89/C99)
  • Libraries: readline, standard C libs, libft
  • Structures: Custom AST for command parsing, linked lists for token tracking
  • Memory: Fully leak-free (checked with Valgrind)

πŸ“ Project Structure

minishell/
β”‚
β”œβ”€β”€ libft/         # Custom standard C library
β”œβ”€β”€ parsing/        # Tokenizer and syntax parser
β”œβ”€β”€ execution/      # Command execution & redirection
β”œβ”€β”€ builtins/      # Built-in commands
└── Makefile

πŸ‘€ Authors

About

🐚 A fully functional mini shell written in C as part of the 42 school curriculum. Implements key shell features like built-in commands, pipelines, redirections (<, >, >>, <<), and environment variable expansion. Designed to mimic basic Bash behavior while exploring process creation, parsing, file descriptors, and terminal signal handling.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published