Minishell
Minishell is a 42 school team project to create a basic shell program in C. It implements redirections and pipes, as well as environment variables and some builtin commands.
Install / Use
/learn @mcombeau/MinishellREADME
minishell
<p align="center"> <img src="https://github.com/mcombeau/mcombeau/blob/main/42_badges/minishelle.png" alt="Minishell 42 project badge"/> </p>Minishell is a 42 school team project to create a basic shell program in C. It implements redirections and pipes, as well as environment variable expansions and the cd, echo, env, exit, export, pwd and unset builtin commands.
This project has been archived in the state it was in at the time of evaluation.
Status
Validated 11/11/2022. Grade: 99%.
Usage
Clone the repository with the minitester submodule:
git clone --recurse-submodules git@github.com:mcombeau/minishell.git
To compile:
cd minishell && make
To run the program:
./minishell
A prompt will appear. You may enter your commands to be executed.
To run the included tester:
cd minitester/ && bash minitester.sh
Supported Features
Minishell is a miniature shell program based on Bash. Minishell supports:
- Prompt display
- Command history (up and down arrows)
- System executables available from the environment (
ls,cat,grep, etc.) - Local executables (
./minishell) - Builtin commands :
echo(and option-n)cd(with only a relative or absolute path)pwd(no options)export(no options)unset(no options)env(no options or arguments)exit(with exit number but no other options)
- Pipes
|which redirect output from one command to input for the next - Redirections:
>redirects output>>redirects output in append mode<redirects input<< DELIMITERdisplays a new prompt, reads user input until reachingDELIMITER, redirects user input to command input (does not update history)
- Environment variables (i.e.
$USERor$VAR) that expand to their values.$?expands to the exit status of the most recently executed foreground pipeline.
- User keyboard signals:
ctrl-cdisplays a new prompt line.ctrl-dexits minishellctrl-\does nothing
However, Minishell does not support \, ;, &&, ||, or wildcards.
Useful Resources for the Minishell Project
:us: Articles in English about the concepts tackled in this project:
- Creating and Killing Child Processes in C
- Pipe: an Inter-Process Communication Method
- Sending and Intercepting a Signal in C
- Handling a File by its Descriptor in C
- Errno and Error Management in C
:fr: Articles en français sur les concepts abordés dans ce projet :
- Créer et tuer des processus fils en C
- Pipe : une méthode de communication inter-processus
- Envoyer et intercepter un signal en C
- Manipuler un fichier à l’aide de son descripteur en C
- Errno et la gestion d’erreur en C
Other useful links:
- Bash reference manual
- Introduction to Systems Programming: a Hands-on Approach, Chapter 5. Writing Your Own Shell
- Stephen Brennan's Tutorial - Write a Shell in C
- The Open Group Base Specifications, Shell Command Language
- A Guide to Unix Shell Quoting
- Austin Tripp's Quick Tutorial on Bash Quotes
Made by aquesada and mcombeau
Related Skills
node-connect
339.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.9kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
339.3kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.9kCommit, push, and open a PR
