Skip to content →

Add readline support to anything!

CLIPS is a widely used public domain tool for building expert systems that was developed by NASA. I can’t really say enough good stuff about it. It provides a Lisp-like language, compiles cleanly, has no dependencies to speak of, and is both embeddable and extensible. It also includes an interactive shell which is indispensable while learning the system, debugging, or just trying things out.

I haven’t used CLIPS for a long while, but I recently had reason to grab the newest version from SourceForge. I soon remembered my only real complaint about CLIPS: it doesn’t have one dependency that I could live with it having: libreadline. It’s just an annoyance and probably says more about my habit of bouncing on my up and down arrow keys while thinking than it does about CLIPS. But still.

My first thought was that I should just hack readline support into it. That would be easy enough. My second thought was that it might be cooler to write a wrapper that would just add readline support to, not only CLIPS, but any other program that would benefit from it. Not so easy, but doable. So, I decided I’d try to rough it out in Perl. I got about an hour into it and was reading the source for IO::Pty when I thought that maybe I should see if this had already been done.

A quick search on Google and the first hit was to rlwrap by Hans Lub. Check it out.

Published in Geek Stuff


Leave a Reply

Your email address will not be published. Required fields are marked *