Skip to content
/ bsh Public

Bash-like shell (builtins, piping) written in C

Notifications You must be signed in to change notification settings


Repository files navigation


Build Status

Bob's finally coming out of his shell.

bsh             __
    ___        |  "---.
  ."   ". -o)  |      |
<|_______|/`   |__,---;
  UU   UU ====|_______|
Welcome to Bob shell.

See for more info on running the test suite, contributing to the project, and improving the documentation.


macOS and Ubuntu are currently supported and tested. This project requires CMake version 2.8 or higher to build.


brew install cmake


sudo apt-get install cmake libbsd-dev libreadline-dev pkg-config

After these dependencies are installed:

git clone
cd bsh
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug -GNinja ..
# Build
cmake --build .
# Run
cmake --build . --target run


Doxygen is required to build documentation:


brew install doxygen


sudo apt-get install doxygen

To generate the documentation:

mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug -GNinja ..
cmake --build . --target doc
# open doc/html/index.html

Dependencies Explained

CMake is the build system used for this project. Originally, this started as a simple Makefile, but it grew more complicated until eventually cmake became the more viable option.

libbsd-dev is required on Ubuntu to get access to strlcpy and strlcat, two functions that make working with strings much easier. This paper does a good job of explaining the design intentions of these functions.

libreadline-dev is required on Ubuntu to embed readline in an application. readline is only used to grab text from the user; its history capabilities are not used and are instead re-implemented as a learning exercise.

pkg-config is required on Ubuntu to help install libbsd. It makes it easier to port this project to other systems because it helps us avoid hard-coding dependencies.

doxygen is a tool to generate documentation. Source comments are annotated using a JavaDoc-like style, which doxygen uses to create HTML and PDFs.

check is the unit-testing framework chosen for this project. It is one of the most popular C unit-testing frameworks and works well with cmake.

Feature Road Map

  1. write the parser
  2. basic shell support
  3. Extra history features
    • history -s num and history num
  4. which
  5. dirs, pushd, popd
  6. alias
  7. pipe
  8. advanced I/O
  9. fg/bg
  10. printenv/setenv
  11. shell scripting: if/then,while,for
  12. tab completion and command prompt editing
  13. up and down arrows to scroll through history list
  14. relax constrains (allow prog>outfile)
  15. terminal support
  16. port to Windows


These resources have been invaluable to me while working on this project:

  1. Cornell CS414 Summer 2004 by Jeanna Matthews
  2. GNU History Library
  3. Bash source code
  4. Implementing a Job Control Shell
  5. The C Programming Language, 2nd Edition


The awesome "geek tortoise" ascii art was found on Retrojunkie.


Bash-like shell (builtins, piping) written in C






No releases published