Skip to content

jqrsound/Minishell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

92 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Minishell

C Badge Shell Badge 42 Badge

Minishell is a 42 school project that recreates a simplified Unix shell in C.

Overview

Minishell is a command-line shell written in C that mimics key Bash-like behavior.
It handles parsing, execution, redirections, pipes, environment variables, and built-in commands.

Features

  • Prompt display and command history.
  • Parsing of commands, quotes, pipes, and redirections.
  • Environment variable expansion, including $?.
  • Built-in commands:
    • echo
    • cd
    • pwd
    • export
    • unset
    • env
    • exit
  • Execution of external commands using the system PATH.
  • Input/output redirections.
  • Heredoc support.
  • Signal handling for interactive shell behavior.

Key learning objectives:

  • Lexical analysis and parsing
  • Process creation and execve
  • File descriptor manipulation
  • Signal handling (SIGINT, SIGQUIT)
  • Memory management without leaks

Build

make

Run

./minishell

Example

$ ./minishell
minishell$ echo "Hello World"
Hello World
minishell$ echo $?
0
minishell$ ls -la | grep Makefile | wc -l
1
minishell$ cat << EOF > test.txt
> line1
> line2
> EOF
minishell$ cat test.txt
line1
line2
minishell$ exit

Signals

  • Ctrl+C (SIGINT) → sends SIGINT to active process
  • Ctrl+D → exit shell

Notes

This project focuses on process management, file descriptors, signal handling, and shell behavior.
Its behavior is designed to stay close to bash where required by the project rules.

Authors

About

Minishell is a 42 school project that recreates a simplified Unix shell in C. It handles parsing, execution, redirections, pipes, environment variables, and built-in commands.

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Contributors