A lightweight POSIX shell written in C with modern features like command history, tab completion, job control, and alias support.
- Command Execution: Execute system commands with full argument support
- Pipelines: Chain commands with
|operator - Redirection: Support for
>,>>,<, and2>(stdout, append, stdin, stderr) - Logic Operators: Sequential (
;), conditional (&&,||) command execution - Background Jobs: Run commands in background with
&and manage withjobs,fg
- Command History: Navigate previous commands with arrow keys (stored in
~/.vshl_history) - Tab Completion: Auto-complete commands and filenames
- Aliases: Create command shortcuts with
aliasandunalias - Startup Config: Auto-loads
~/.vshlrcon launch for persistent settings
cd [dir]- Change directory (supports~expansion)export VAR=value- Set environment variablesunset VAR- Remove environment variablesalias name="command"- Create command aliasunalias name- Remove aliasjobs- List background jobsfg [job_id]- Bring job to foregroundexit [code]- Exit shell
- Globbing: Wildcard expansion with
*(match all) and?(match one) - Environment Expansion:
$VAR,${VAR}, and~expansion - Signal Handling: Ctrl-C interrupts current job, Ctrl-Z suspends to background
- Quote Handling: Single and double quotes, backslash escaping
- GCC compiler
- GNU Make
- libedit library (for macOS/BSD) or libreadline (for Linux)
make./vshlOn first launch, vshl creates ~/.vshlrc with default settings. Customize it with:
# Environment variables
export PATH="$PATH:$HOME/bin"
export EDITOR=vim
# Aliases
alias ll="ls -la"
alias gs="git status"The codebase has been hardened against common vulnerabilities:
- Buffer overflow protection with bounds checking
- NULL pointer validation for all allocations
- Error handling for system calls (fork, dup2, kill)
- Safe signal handling with sig_atomic_t
- Input validation for environment variables and job IDs
- Globbing in Quotes: Wildcards expand even inside quotes (
ls "*.c"behaves likels *.c) - No Noclobber: Output redirection (
>) always overwrites files - Limited Expansion: No command substitution, arithmetic expansion, or special parameters (
$?,$$, etc.) - Tilde Expansion: Only
~(not~user) is supported
include/ Header files
├── builtins.h
├── executor.h
├── globbing.h
├── jobs.h
├── parser.h
├── shell.h
├── signals.h
└── utils.h
src/ Source files
├── builtins.c
├── executors.c
├── globbing.c
├── jobs.c
├── parsers.c
├── shell.c
├── signals.c
├── utils.c
├── main.c
├── alias.c
└── line_editing.c