Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This project was developed as part of the 42 Coding School curriculum by cvizcain and gisidro-

Minishell

Grade Norminette Language 42

Description

Minishell is a simple UNIX shell implemented in C as part of the 42 School curriculum. The goal of the project is to recreate the core functionality of a POSIX-compliant shell — similar to Bash — from scratch.

The shell supports interactive command input with history, execution of external binaries via PATH resolution or explicit paths, a full set of built-in commands, I/O redirections, pipes, environment variable expansion, and correct signal handling. The bonus part extends the shell with logical operators (&&, ||), sub-shell grouping with parentheses, and wildcard (*) expansion in the current directory.

Key features

  • Prompt & history – displays a prompt and keeps a command history (navigable with arrow keys)
  • Command execution – resolves executables using PATH, relative paths, or absolute paths
  • Built-in commandsecho, cd, pwd, export, unset, env, exit
  • Redirections< (input), > (output), >> (append), << (here-doc)
  • Pipes – chains commands with |
  • Variable expansion$VAR and $? (exit status of last command)
  • Quoting – single quotes preserve literals; double quotes preserve literals except $
  • SignalsCtrl-C (new prompt), Ctrl-D (exit), Ctrl-\ (ignored in interactive mode)
  • Bonus&& / || operators, () grouping, * glob expansion

Instructions

Requirements

Linux (Debian/Ubuntu):

  • cc compiler
  • GNU make
  • readline development library:
sudo apt-get install libreadline-dev

Compilation

Build the mandatory part:

make

Build with bonus features (&&, ||, (), *):

make bonus

Running

./minishell

The shell starts in interactive mode. Type commands just like in Bash.

Usage examples

# Basic command
$ echo "Hello, World!"
Hello, World!

# Pipe
$ ls -la | grep ".c"

# Redirections
$ echo "log entry" >> log.txt
$ cat < log.txt

# Here-doc
$ cat << EOF
> line one
> EOF

# Variable expansion
$ export MY_VAR=42
$ echo $MY_VAR
42
$ echo $?
0

# Bonus – logical operators and grouping
$ (echo "a" && echo "b") || echo "c"
a
b

# Bonus – wildcard expansion
$ ls *.c

Built-in commands

Command Description
echo [-n] [string] Print text to stdout; -n suppresses the trailing newline
cd [path] Change the current working directory
pwd Print the current working directory
export [KEY=VALUE] Set or display environment variables
unset KEY Remove an environment variable
env Print all environment variables
exit [n] Exit the shell with optional exit code

Resources

References

AI Usage

AI tools were used in this project for the following purposes:

  • Testing – to help create and run test cases that verify correct shell behaviour
  • Documentation – for drafting parts of the inline code documentation
  • Understanding – to help understand specific aspects of the codebase and underlying system concepts

All AI-assisted content was reviewed, tested, and validated manually by the project authors.

About

Minishell is a simple UNIX shell implemented in C as part of the 42 School curriculum. The goal of the project is to recreate the core functionality of a POSIX-compliant shell — similar to Bash — from scratch.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages