Skip to content

Vlad-PLK/MINISHELL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📟 minishell

Score Duration Peer(s)
125 / 100 🕓 8 week(s) 👷🏻 Yes

This team project is a program that reproduces the bash shell. It includes prompt, persistent history, several builtins, full support for quotes (double and single), redirections and piping, shell variables and environment variables and their expansion, signal processing, support for logical operators, subshells and wildcards.


📋 Table of contents

TOP ⬆️

👀 Overview

General

  • Display a prompt while waiting for an input.
  • Search order for binaries identical to bash.
  • Executes the correct binaries.

History

  • Supports session history.
  • Supports persistent history (file storage).

Builtins

  • Implements builtins echo, cd, pwd, export, unset, env and exit.

Quotes

  • Supports simple quotes '' and double quotes "".
  • Supports unclosed double quotes.
  • Supports unclosed simple quotes.

Redirections

  • Supports pipe | redirections.
  • Supports <, > and >> file redirections.
  • Supports heredoc << redirections.
  • Supports herestring <<< redirections.

Variables

  • Supports environment variables.
  • Supports shell variables.
  • Shell variables can be exported with export.
  • Supports variable $?.

Signals

  • Supports signals CTRL-C, CTRL-D and CTRL-\ in passive and interactive mode.

Operators

  • Supports logical operators && and ||.

Subshell

  • Supports the execution of subshells in parentheses ().

Delimiters

  • Supports token ; as delimiter.
  • Supports incomplete lines ending with |, && or ||.

Wildcard

  • Supports wildcard * in the basename of any absolute or relative path.

Comments

  • Supports inline comments with token #.

TOP ⬆️

📦 Requirements

sudo apt -y install clang-12 make libreadline-dev

TOP ⬆️

💾 Installation

1. Get the project

git clone https://github.com/Vlad-PLK/MINISHELL.git

2. Build the project

make -j$(nproc)

🔵 Info: The minishell executable will be created in the project root directory.


3. Run the project

./minishell

TOP ⬆️

⚡️ Usage

Double quotes:

minishell$ echo "Like a shell: $SHELL"
Like a shell: 42-minishell/minishell

Simple quotes:

minishell$ echo 'Like a shell: $SHELL'
Like a shell: $SHELL

Unclosed quotes:

minishell$ echo "Hello 
> world!"
Hello 
world!

Pipe redirection:

minishell$ echo "Hello world!" | cat --number
     1  Hello world!

File redirection:

minishell$ echo "Hello world #1" > a.txt
minishell$ echo "Hello world #2" >> a.txt
minishell$ cat --number < a.txt
     1  Hello world #1
     2  Hello world #2

Heredoc:

minishell$ cat << DEL
> Hello
> world!
> DEL
Hello 
world!

Herestring:

minishell$ cat <<< "Hello world!\n"
Hello world!

Environment variables:

minishell$ export A="Hello world!"; echo $A
Hello world!

Shell variables:

minishell$ A="Hello world!"; echo $A
Hello world!

Logical operators:

minishell$ echo "A" && echo "B" || echo "C" && echo "D"
A
B
D

Subshell:

minishell$ echo "A" && echo "B" || (echo "C" && echo "D")
A
B

Delimiters:

minishell$ echo Hello; echo world!
Hello
world!

Incomplete lines:

minishell$ echo "Hello world!" |
> wc -w
2
minishell$ echo -n "Hello " &&
> echo "world!"
Hello world!
minishell$ echo "Hello " ||
> echo "world!"
Hello

Wildcards:

minishell$ echo includes/m*.h
includes/minishell.h

Comments:

minishell$ echo "Hello world!" # It's an inline comments!
Hello world!

TOP ⬆️

🛠️ Makefile

Rule Action
allCompile.
cleanDelete all generated object files
fcleanApply clean, lcleanand delete the executable.
lcleanApply fclean to all used libraries.
reApply fclean and force recompile.

TOP ⬆️

About

42 PROJECT : MINISHELL

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published