A modern C++ reimplementation of a POSIX-compatible interactive shell inspired by GNU Bash. It aims for high fidelity behavior with pipelines, redirections, expansions, job control, readline/history, aliases, functions, and builtins.
- Pipelines, redirections (>, >>, <, n>&m, here-strings, here-docs)
- Expansions: tilde, parameter (${VAR}, ${VAR}), command substitution
$(...), arithmetic $ ((...)), globbing, IFS word splitting, brace expansion - Builtins: cd, echo, pwd, export, unset, set, shift, alias/unalias, test/[ , source (.), true/false, wait, jobs, fg, bg
- Readline prompts with PS1/PS2 escapes; history persistence
- Job control: pipelines in process groups, foreground/background, notifications
- Functions: multi-line definitions name() { ... } and function name() { ... }
- CMake ≥ 3.16
- A C++20 compiler (AppleClang/Clang/GCC)
- GNU Readline and (n)curses libraries (Homebrew:
brew install readline)
cd /Users/bfox/CLIENTS/BJF/brash
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -jThis produces the executable: build/brash.
Interactive:
./build/brashExecute a command stream (non-interactive):
echo 'echo hello' | ./build/brash- On macOS with Homebrew readline, you may need:
before configuring.
export LDFLAGS="-L/opt/homebrew/opt/readline/lib" \ CPPFLAGS="-I/opt/homebrew/opt/readline/include"
- Echo behavior:
echoimplements -n/-e/-E and backslash escapes as in Bash.