Skip to content

🐚 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.

Notifications You must be signed in to change notification settings

RogerioLS/Minishell-42sp

Repository files navigation

🐚 Minishell | 42 SP

Norminette Build Static Badge 42 São Paulo License Code size in bytes Top language Last commit Repo size Languages GitHub repo file count (file type) Discord


In this project, students are tasked with building a program that executes in a loop*, prompting the user for a command (or sequence of commands**), interpreting the inserted input and then executing the command, finally returning the prompt back to the user, until it is terminated by the user.

This minishell is able to run any commands that can be found in the $PATH variable or otherwise in a specified path; redirect input and outputs with redirection operators, as well as some built-in functionalities, and also supports the wildcard character *.

*Commonly referred to as REPL - Read, Evaluate and Print Loop. Learn more about the REPL studying this diagram. image

**Also know as pipelines, that is, a sequence of terminal commands separated by the pipe character |.


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
    • << DELIMITER displays a new prompt, reads user input until reaching DELIMITER, redirects user input to command input (does not update history)
  • Environment variables (i.e. $USER or $VAR) that expand to their values.
    • $? expands to the exit status of the most recently executed foreground pipeline.
  • User keyboard signals:
    • ctrl-c displays a new prompt line.
    • ctrl-d exits minishell
    • ctrl-\ does nothing

However, Minishell does not support \, ;, &&, ||, or wildcards.


Useful Resources for the Minishell Project

🇺🇸 Articles in English about the concepts tackled in this project:

🇫🇷 Articles en français sur les concepts abordés dans ce projet :

Other useful links:

Download and use this project

$> git clone https://github.com/RogerioLS/Minishell-42sp
$> cd Minishell-42sp
$> make
$> ./minishell

If you want to exit the minishell, simply type in the command exit or press ctrl+D. There ya go!


Note

Because of 42 School norm requirements:

  • Each function can't have more than 25 lines of code.
  • All variables are declared and aligned at the top of each function.
  • Project should be created just with allowed functions otherwise it's cheating.

About

🐚 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.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •