Skip to content

A minimal Bash-like shell written in C, supporting built-in commands, pipes, redirections, signals, and environment variables

Notifications You must be signed in to change notification settings

mfaria-p/minishell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Minishell

Our own little Bash

Minishell is a simple shell implementation that mimics the behavior of the GNU Bash shell. It supports built-in commands, redirections, pipes, signal handling, and an interactive command-line interface.

Print_screen


πŸ“– Table of Contents


πŸš€ Features

βœ”οΈ Display a prompt when waiting for a new command πŸ–₯️
βœ”οΈ Maintain a working history of commands
βœ”οΈ Search and launch the correct executable (via PATH, relative, or absolute path)
βœ”οΈ Avoid using more than one global variable for signal handling
βœ”οΈ Correctly handle unclosed quotes and special characters
βœ”οΈ Handle:

  • Single quotes ('): Prevents meta-character interpretation
  • Double quotes ("): Prevents meta-character interpretation except for $

βœ”οΈ Implement redirections:

  • < Redirect input
  • > Redirect output
  • << Read input until a specified delimiter appears (without history update)
  • >> Append output to a file

βœ”οΈ Implement pipes (|) for command chaining
βœ”οΈ Support environment variables ($VAR) and exit status ($?)
βœ”οΈ Handle signals:

  • Ctrl+C: Displays a new prompt on a new line
  • Ctrl+D: Exits the shell
  • Ctrl+\: Does nothing

βœ”οΈ Implement the following built-in commands:

  • echo (with -n option)
  • cd (supports relative/absolute paths)
  • pwd
  • export
  • unset
  • env
  • exit

βœ”οΈ Memory-leak free πŸ”₯


πŸ”§ Built-in Commands

Command Description
echo Prints text to the terminal. Supports the -n option (no newline).
cd Changes the current directory (supports relative and absolute paths).
pwd Prints the current working directory.
export Sets environment variables.
unset Unsets environment variables.
env Displays the environment variables.
exit Exits the shell.

πŸ”„ Redirections

Symbol Description
< Redirects input from a file.
> Redirects output to a file.
<< Reads input until a line containing a specified delimiter appears.
>> Redirects output to a file (append mode).

πŸ”— Pipes

Symbol Description
| Pipes the output of one command into the input of another.

⚑ Signal Handling

Keybinding Behavior
Ctrl+C Displays a new prompt on a new line.
Ctrl+D Exits the shell.
Ctrl+\ Does nothing.

🌍 Environment Variables

Variable Description
$VAR Expands to the value of the specified environment variable.
$? Expands to the exit status of the last executed command.

πŸ“₯ Installation

To install and run Minishell, follow these steps:

  1. Clone the repository:

    git clone https://github.com/mfaria-p/minishell.git
  2. Navigate to the project directory:

    cd minishell
  3. Build the project:

    make
  4. Run Minishell:

    ./minishell

πŸ“š Resources

GNU Bash manual
readline: libreadline-dev

πŸ‘¨β€πŸ’» Authors

Enjoy your experience with our Minishell! πŸš€πŸŽ‰

About

A minimal Bash-like shell written in C, supporting built-in commands, pipes, redirections, signals, and environment variables

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •