Skip to content

bewerner/minishell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Minishell

Minishell is a simple shell implementation inspired by bash, created as part of the 42 school core curriculum. This project focuses on process management, pipes, file descriptors, and command interpretation, allowing users to execute commands with the same behavior as a standard shell.

Features

Core Functionality

  • Custom command prompt
  • Command history navigation
  • Command execution using PATH variable or relative/absolute paths
  • Signal handling

Command Parsing

  • The command line gets parsed and tokenized into an abstract syntax tree
  • Proper handling of single and double quotes
  • Environment variable expansion
  • Exit status variable expansion ($?)

Redirections

  • Output redirection (>)
  • Append output redirection (>>)
  • Input redirection (<)
  • Heredoc (<<): Read input until a specified delimiter

Pipes

  • Command pipeline support (|): Connect output of one command to input of another

Builtins

  • echo with -n option
  • cd without options
  • pwd without options
  • export without options
  • unset without options
  • exit without options
  • env without options or arguments

Bonus

  • Logical operators && and ||
  • Support for both interactive and non-interactive shell
  • Unclosed quotes handling: Allows continuation of input over multiple lines until quotes are closed (like bash)

Dependencies

This project requires the GNU Readline library to handle command line input and history.

Ubuntu/Debian

sudo apt-get install libreadline-dev

macOS with Homebrew

brew install readline

Arch Linux

sudo pacman -S readline

Installation

git clone https://github.com/yourusername/minishell.git
cd minishell
make

Usage

Interactive Mode

./minishell

Non-Interactive Mode

echo "ls -la" | ./minishell
./minishell < commands.txt

About

A simple bash-like shell written in C

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published