Résumé ↗Say hello
← All work

A custom UNIX shell written in C from scratch, built as a collaboration project at ALX.

Client
ALX Software Engineering
Role
Software Engineer
Type
Collaboration project
Year
2023
obafisayo@hsh-demo: ~/simple_shell · ./hshrunning
hsh: the simple_shell from github.com/obafisayo/simple_shell, running in your browser. Parsing, builtins and error messages follow the C source. Programs like ls and cat are simulated. Type `help` to start. Ctrl+C cancels a line, Ctrl+D exits, Ctrl+L clears.
Try

Overview

hsh is a UNIX command interpreter written in C, built to match /bin/sh's output and error messages.

It was a collaboration project in the ALX Software Engineering programme, built as a pair.

Simple Shell implements process management with fork, execve and wait, a command-line parser with PATH resolution and tokenisation, and manual memory management.

Beyond the basics it handles ; separated commands, single, double and escaped quotes with multi-line input, # comments, aliases (including trailing-space chaining), $?, $$ and environment variable expansion, and eight builtins: alias, cd, env, exec, exit, help, setenv and unsetenv.

What I did
  • Parser and tokenizer
  • Builtins
  • PATH resolution
  • Error output parity with sh
(About the demo above)

The terminal above runs a TypeScript port that follows the C source: the same parsing order, builtins, help text and error messages. Browsers cannot fork or execve, so programs like ls and cat are simulated against a copy of the real repository.

(The problem)

Understanding how a UNIX shell works at the systems level, using only the C standard library.

(Outcome)

100% project score with zero memory leaks across all edge cases.

(Stack)
  • C
(Next project)Logirate