Skip to content

42sin/minishell

Repository files navigation


Logo

Minishell

As beautiful as a shell
Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Features
  5. License

About The Project

Subject PDF

This is the first group project of the 42 core curriculum. The objective of this project is to create a simple bash-like shell. There were specific Project specifications, like only being allowed to use a few low-level functions and POSIX system calls. If you want to know more about the requirements, take a look at the Subject PDF. This project was done in collaboration with Florian Bindereif

(back to top)

Getting Started

The Project was mainly tested on macOS, but it should work on all UNIX/LINUX based systems.

Prerequisites

To run the Minishell, you need to install the readline library first, which can be done like this:

brew install readline

Or

apt-get install libreadline-dev

Installation

  1. Clone the repo
    git clone https://github.com/42sin/minishell.git && cd minishell
  2. Change the readline path inside of the Makefile, you can see your path with brew info readline
    -I/usr/local/opt/readline/include
    -L/usr/local/opt/readline/lib
  3. Compile the project
    make
  4. Run the minishell
    ./minishell

(back to top)

Usage

You can use the minishell as you would use any other Shell to execute commands. We handled a lot of unnecessary things that were not specifially required by the Subject, which you can read more about in Features

Here is an example of a basic command using some of the control operators.

This is a more advanced example where you can see the implementation of Here Documents, the variable used as a delimiter isn't expanded but the ones used inside of the Here Document are expanded.

(back to top)

Features

Basics:

  • History of previously entered commands
  • Search and launch the right executable (based on the PATH variable, using a relative or an absolute path)
  • Environment variables ($ followed by a sequence of characters) expand to their values
  • Wildcards *
  • Ctrl-C, Ctrl-D, and Ctrl-\ behave like in bash
  • (single quotes - prevent from interpreting meta-characters in quoted sequence)
  • " (double quotes - prevent from interpreting meta-characters in quoted sequence except for $)
  • $? expands to the last exit status
  • | Output of a command is connected to the input of the next Command
  • && and || with parenthesis for priorities

Builtins:

  • echo with -n
  • cd (relative or absolute path, ~ for HOME)
  • pwd
  • export without arguments or with a new environment variable to be set
  • unset
  • env
  • exit [exit_status]

Redirections:

  • [n] < file Redirecting Input
  • [n] << limiter Here Documents with environment variable handling
  • [n] > file Redirecting Output
  • [n] >> file Appending Redirected Output

(back to top)

License

Distributed under the MIT License. See LICENSE for more information.

(back to top)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published