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.
- 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
;
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
Supports Unix-style pipelines:
ls | grep txt | wc -l
Standard redirections:
> stdout overwrite
>> stdout append
< stdin redirect
Numeric redirections:
2> errors.txt
1>> output.log
Custom lexer recognizes: - Words - Quotes (' and ") - Escape
sequences - Pipes (|) - Semicolons (;) - Background operator (&) -
Input/output redirection operators
- Detects built-ins vs external commands
- Uses
fork()+execvp() - Implements pipelines
- Manages FD redirection
- Supports background execution
src/
├── main.c
├── commands.c
├── executor.c
├── shell_lexer.c
└── CMakeLists.txt
- 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
git clone <your-repo-url>
cd <repo>
mkdir build && cd build
cmake ..
make
./badmash
Raz
