ClowniSH

A POSIX-like shell implementation that occasionally overrides command output with humorous alternatives and teases the user on their behavior. I made this project to deepen my understanding of shell internals as well as the POSIX APIs that handle file I/O and process management. The project's "trollish" behavior is inspired by sentiments I've seen expressed during my time participating in FOSS forums over the past decade.

Tech Stack

Category Technology Used
Language C
Compiler GCC
Build System GNU Make
Libraries GNU Readline
Testing Framework TCL Expect
Compression Tool gzip
Operating System Linux (POSIX adherence assumed)
License GNU General Public License V2

Core Features

Additional Tomfoolery*

* These features can be disabled by enabling polite mode.

Challenges & Solutions

One of the challenges in implementing the core features was anticipating the various ways that a user may interact with the shell, a user piping 32 commands is not out of the question.

The user could see the same teasing message multiple times during a single instance of the shell in earlier versions, but a flag was implemented to prevent this from occurring.

The frequency of command overrides had to be calibrated to a low enough level to avoid making the project completely unusable.

Testing

I settled on using the TCL Expect testing framework, which was designed to automate work with interactive CLI applications. The script tests the following:

Lessons Learned

I was familiar with the concept of REPL loops from writing a text adventure game in 2024, but it was interesting to see the differences between tokenizing a string using strtok instead of the more modern split method in QString.

I was surprised at how straightforward the dup2 function, which duplicates file descriptors, makes I/O stream redirection.

Since this was my first time implementing integration testing, TCL Expect and its syntax was entirely new to me.

Future Plans

While I have taken the core features as far as I want to, I may revisit this in the future to expand on its personality.

Further Reading

View Source Code on Github