This project simulates the functionality of the Unix Bash shell.

Minishell

This project simulates the functionality of the unix Bash shell.

Description

The project aim was to recreate the functionality of the unix Bash shell on a smaller scale. It is part of the obligatory projects at the 42-Heilbronn coding school in Heilbronn, Germany. Project Rules: The following functions were allowed, any function not included in this list was forbidden:

readline, rl_clear_history, rl_on_new_line,
rl_replace_line, rl_redisplay, add_history,
printf, malloc, free, write, access, open, read,
close, fork, wait, waitpid, wait3, wait4, signal,
sigaction, kill, exit, getcwd, chdir, stat,
lstat, fstat, unlink, execve, dup, dup2, pipe,
opendir, readdir, closedir, strerror, perror,
isatty, ttyname, ttyslot, ioctl, getenv, tcsetattr,
tcgetattr, tgetent, tgetflag, tgetnum, tgetstr,
tgoto, tputs

Features

The following functionality is included:

  • Execution of executables: Executables are first searched for in the $PATH environment variable. If nothing is found, the relative/absolute path is used to search for the executable.

    Example: "ls -la" or "minishell"

  • Redirections: Using <, <<, >, or <<, the input and output can be redirected if the commands and files are valid.

    Example: Input: echo hello > out.txt Behavior: The output of "echo hello" is written into the file "out.txt". The file is created if it does not exist. An error is shown if the user does not have the neccessary access rights for the file.*

  • Pipes: Using |, the output of one command can be piped to the input of the next.

    Example: Input: echo hello | grep h Behavior: The output of the command "echo hello" is used as the input of the command grep h. "hello" will be printed to the standard output.

  • Environment variables: Environment variables with the prefix $ are expanded to their corresponding values.

    Example: Input: echo $PATH Behavior: The value of the environment value "PATH" is written to the standard output.

  • Exit Status: $? expands to the exit status of the most recently executed foreground pipeline.

    Example: Input echo $? Behavior The exit code of the last executed pipeline command is printed to the standard output

  • ctrl-C, ctrl-D, ctrl-: See Bash behavior
  • Quotes: Quote interpretation is close to the original behavior in bash

    Example: Input echo 'hello $PATH' Behavior Due to the single quotes, the $PATH variable is interpreted as a string, not as an environment variable. "hello $PATH" is written to the standard output.

  • Builtins: The following functions were reprogrammed from scratch and are builtin in the minishell. This means they are always available and independent from the $PATH variable:
    • echo with option -n
    • cd with only a relative or absolute path
    • pwd with no options
    • export with no options
    • unset with no options
    • env with no options or arguments
    • exit with no options

Technologies

  • Programming language: C (C11)

Usage

Prerequisites

  • Must be a Unix-based system. Please note: Depending on your build, you might get problems during compilation or execution. Code was tested in Unix 5.11.0-43-generic
  • The Readline library must be installed.
    sudo apt-get install libreadline6 libreadline6-dev
    
  • GNU Make must be installed
    sudo apt-get install make
    

Compilation and execution

  • Clone the repository to your system
git clone [email protected]:realisticDonut/Minishell.git
  • Navigate to the /minishell directory in the terminal
  • execute the make command
  • execute the minishell with ./minishell
  • Input commands just like in the original Bash
Similar Resources

A faithful transposition of the key features/functionality of @itm4n's PPLDump project as a BOF.

PPLDump BOF Who worked on this? Justin Lucas (@the_bit_diddler) Brad Campbell (@hackersoup) What is this? Jokingly, an exercise of my own personal san

Dec 28, 2022

Project is to port original Zmodem for Unix to CP/M and provide binaries and source code for platform specific modification as needed. Based on 1986 C source code by Chuck Forsberg

Zmodem-CP-M This repository is intended to foster a RetroBrewComputers community effort to port the original Zmodem source code for Unix to CP/M so ev

Aug 31, 2022

Project is to port original Zmodem for Unix to CP/M and provide binaries and source code for platform specific modification as needed. Based on 1986 C source code by Chuck Forsberg

Zmodem4CPM This repository is intended to foster a RetroBrewComputers community effort to port the original Zmodem source code for Unix to CP/M so eve

Aug 31, 2022

Not related to software bugs and exploits; this repo contains snippets of code that demonstrate some interesting functionality or a handy trick.

Proof-of-Concept Not related to software bugs and exploits; this repo contains snippets of code that demonstrate some interesting functionality or a h

Nov 19, 2022

This repository contains toy ImPlot applications that demonstrate some of the library's functionality

This repository contains toy ImPlot applications that demonstrate some of the library's functionality

ImPlot Demos This repository contains toy ImPlot applications that demonstrate some of the library's functionality.

Dec 28, 2022

A hobby and performance-oriented Linux® distribution that provides aesthetics and practical functionality.

Heiwa/Linux A hobby and performance-oriented Linux® distribution that provides aesthetics and practical functionality.

Apr 29, 2022

weggli is a fast and robust semantic search tool for C and C++ codebases. It is designed to help security researchers identify interesting functionality in large codebases.

weggli is a fast and robust semantic search tool for C and C++ codebases. It is designed to help security researchers identify interesting functionality in large codebases.

weggli is a fast and robust semantic search tool for C and C++ codebases. It is designed to help security researchers identify interesting functionality in large codebases.

Dec 28, 2022

WisBlock API takes care of all the LoRaWAN, BLE, AT command functionality

WisBlock API takes care of all the LoRaWAN, BLE, AT command functionality

WisBlock-API Targeting low power consumption, this Arduino library for RAKwireless WisBlock Core modules takes care of all the LoRaWAN, BLE, AT comman

Dec 7, 2022

A software serial driver package by using the hardware timer capture / comparison functionality.

Soft serial 1.简介 Soft serial 是利用硬件定时器捕获/比较功能实现软件模拟串口的软件包。 1.1目录结构 Soft serial 软件包目录结构如下所示: soft_serial ├───inc // 头文件目录 │

Jul 14, 2022
Minishell - This project aims to recreate most of the bash shell.
Minishell - This project aims to recreate most of the bash shell.

minishell Contents Info How to use Clone repo and submodules Linux dependencies MAC dependencies Compile and execute Install Features Built-in command

Jun 9, 2022
Neo - Simulates the digital rain from "The Matrix" (cmatrix clone with 32-bit color and Unicode support)
Neo - Simulates the digital rain from

neo WARNING: neo may cause discomfort and seizures in people with photosensitive epilepsy. User discretion is advised. neo recreates the digital rain

Dec 28, 2022
Unix pager (with very rich functionality) designed for work with tables. Designed for PostgreSQL, but MySQL is supported too. Works well with pgcli too. Can be used as CSV or TSV viewer too. It supports searching, selecting rows, columns, or block and export selected area to clipboard.
Unix pager (with very rich functionality) designed for work with tables. Designed for PostgreSQL, but MySQL is supported too. Works well with pgcli too. Can be used as CSV or TSV viewer too. It supports searching, selecting rows, columns, or block and export selected area to clipboard.

Unix pager (with very rich functionality) designed for work with tables. Designed for PostgreSQL, but MySQL is supported too. Works well with pgcli too. Can be used as CSV or TSV viewer too. It supports searching, selecting rows, columns, or block and export selected area to clipboard.

Jan 4, 2023
A shell for unix and linux systems

Snash A shell for unix/linux A shell for unix and linux systems. This is still a work in progress and ALOT has yet to be implemented. Snash stands for

Dec 2, 2022
BlaanSh is a Unix-like shell.

BlaanSh BlaanSh is a Unix-like shell written in C language by @os-moussao and @awbx, this shell was inspired by Bash. Content Features Brief Summary L

Nov 9, 2022
My_Shell is a user-defined interactive shell written in C that works similar to the original shell in linux

MY_SHELL Overview My_Shell is a user-defined interactive shell written in C that works similar to the original shell and it can execeute many of the l

Nov 22, 2021
Blog post on using a custom Bash builtin to parse INI config files

Writing a Bash Builtin in C to Parse INI Configs Why Not Just Parse INI Configs With Bash? Shell languages such as Bash excel at certain tasks, such a

Oct 8, 2022
hooking the execve syscall, to randomly sabotage typed bash commands.

Syscall hooks A small project of hooking the execve() syscall, to randomly sabotage typed bash commands. This project was tested on 5.11.0-38-generic.

Aug 2, 2022
This program try to recreate bash --posix comportement in certain limite

minishell : petitcoquillage This program try to recreate bash --posix comportement in certain limite Execution : To execute this Program you have to b

Dec 9, 2022
File path converter for Windows & Git Bash

windows-git-bash-path-converter Motivation Made this because it was so mad to convert path between Windows and Git Bash How to use Windows file path t

Mar 15, 2022