Skip to content

procrastinator-101/minishell

Repository files navigation

Minishell

A small Unix shell written in C. It handles tokenizing, parsing, expanding variables, redirections, pipelines, and command execution. The project is inspired by the behavior of Bash, implementing a simplified version of its core features.


Overview

minishell reads user input, breaks it into tokens, builds command structures, applies expansions, and executes commands using POSIX system calls. It supports basic shell features like pipes, redirections, and environment variable management.


Features

  • Tokenizer + lexer
  • Parser for simple commands & pipelines
  • Environment variable management
  • Word/variable expansion
  • Redirections (>, >>, <)
  • Pipelines (cmd1 | cmd2 | cmd3)
  • Builtins

Build & Run

git clone https://github.com/procrastinator-101/minishell.git
cd minishell
make
./minishell

Readline Dependency

minishell uses the readline library for command-line input.

If you don't have readline installed on your system, you need to install it and update the Makefile paths accordingly.

Installing readline

macOS (Homebrew):

brew install readline

Ubuntu/Debian:

sudo apt-get install libreadline-dev

Linking readline

In the Makefile, update the LIBS and INCLUDES variables to point to your readline installation path:

LIBS = /path/to/readline/lib
INCLUDES = /path/to/readline/include

For example, on macOS with Homebrew, it might look like:

LIBS = /Users/$(USER)/.brew/opt/readline/lib
INCLUDES = /Users/$(USER)/.brew/opt/readline/include

Then run make re to build the project with readline support.

Common Makefile targets

make        # build
make clean  # remove object files
make fclean # full clean (including binary)
make re     # rebuild

Usage

Run ./minishell to start the shell. Enter commands as you would in a standard Unix shell.

$ ls -la
$ echo $HOME
$ echo "hello" > out.txt
$ cat file.txt | grep abc | wc -l
$ export MYVAR=ok
$ echo $MYVAR

Type exit to quit the shell, or press Ctrl + D.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors