Skip to content

raz0229/badmash-shell

Repository files navigation

Badmash Shell 😈

Badmash Shell Logo

A minimal yet powerful Unix-like shell written in C, featuring command execution, built-in utilities, pipelines, redirections, history support, auto-completion, and a custom lexer/expansion engine.

Badmash Shell is designed as a learning-focused implementation of shell internals --- including parsing, tokenization, execution pipelines, and process management --- while still being practical to use.


✨ Features

🧠 Core Shell Functionality

  • Interactive shell loop using GNU Readline
  • Command history support
  • Auto-completion for:
    • Built-in commands
    • Executables found in $PATH
  • Execution of external programs via execvp
  • Background process execution (&)
  • Sequential commands using ;

⚙️ Built-in Commands

Command Description


echo Print arguments to stdout pwd Print current working directory cd Change directory exit Exit the shell history Display command history type Identify built-in commands or external executables


🔗 Pipelines

Supports Unix-style pipelines:

ls | grep txt | wc -l

🔁 Redirection Support

Standard redirections:

>   stdout overwrite
>>  stdout append
<   stdin redirect

Numeric redirections:

2> errors.txt
1>> output.log

🧾 Lexer & Tokenization

Custom lexer recognizes: - Words - Quotes (' and ") - Escape sequences - Pipes (|) - Semicolons (;) - Background operator (&) - Input/output redirection operators


🏗️ Execution Engine

  • Detects built-ins vs external commands
  • Uses fork() + execvp()
  • Implements pipelines
  • Manages FD redirection
  • Supports background execution

🧱 Project Structure

src/
├── main.c
├── commands.c
├── executor.c
├── shell_lexer.c
└── CMakeLists.txt

🛠️ Build Instructions

Dependencies

  • GCC or Clang
  • CMake ≥ 3.13
  • GNU Readline development library

Ubuntu/Debian:

sudo apt install build-essential cmake libreadline-dev

Arch:

sudo pacman -S base-devel cmake readline

Fedora:

sudo dnf install gcc cmake readline-devel

Build

git clone <your-repo-url>
cd <repo>
mkdir build && cd build
cmake ..
make

Run

./badmash

👨‍💻 Author

Raz

About

A simple, fast and elegant wannabe shell program

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors