On a project I'm working on, I'm trying to make it accept user commands and provide history with the up arrow. I'm aiming to keep this project free of dependencies, and I don't want to have to require people to also install the readline development files just to compile my project. Does anyone know of a simple drop-in replacement for GNU Readline that provides only simple functionality?
6 Answers
Editline. It has a BSD-style license.
EDIT: Older versions of editline were quite simple. Here's one with just two C files and a header, a total of about 1500 lines of code. We've been using it for years.

- 42,793
- 6
- 62
- 96
I found one. antirez of Redis fame has come up with linenoise, a much simpler alternative.

- 16,289
- 7
- 37
- 48
-
2I'm sure non-English users will love it when your program barfs on text they try to type in their own languages.... – R.. GitHub STOP HELPING ICE Feb 12 '11 at 21:46
Most systems have readline installed, so I don't see that as being too much of an issue.
Secondly, I don't think there's any drop-in replacement for the GNU Readline library. You're going to have to stick with it. :(
Edit 5/11/2016: This answer is outdated, and any edit I'd make would be borrowing almost completely from the other, more correct answers. Summary: see linenoise and editline for modern readline alternatives.

- 10,879
- 7
- 50
- 81
-
Yeah, it doesn't look like I'm getting around it. I've checked the alternatives, like Editline and libtecla, but they don't satisfy the "simple" requirement. I'm just going to have to lump it. – Justin Poliey Dec 11 '09 at 02:01
-
I'd rather not say that. [clisp](http://clisp.cvs.sourceforge.net/viewvc/clisp/clisp/doc/Why-CLISP-is-under-GPL) is the first one to convert to GPL because of readline. [here](http://lwn.net/Articles/428111/) is an article about readline and GPL. – Yasushi Shoji Aug 26 '12 at 16:40
-
1I'd update this answer -- neither Windows or Mac OS X has readline installed -- that's a very large proportion of users! – Chris Jefferson May 11 '16 at 08:19
-
Probably should just delete my answer...I think it's a bit outdated. Edit: Turns out you can't delete an accepted answer. – Dan Loewenherz May 11 '16 at 23:02
-
@ChrisJefferson Huh. You're right. Mac OS X actually includes compatibility code for code that asks for readline, mapping the calls to editline. Interesting. – uliwitness May 12 '16 at 07:04
The editline library is yet another alternative. From the README:
The editline library was created by Simmule Turner and Rich Salz back in 1992. At the time they chose to distribute the code under a "C News-like" copyright, see the file LICENSE for details.
[...]
This version of the editline library is a fork off the Minix3 sources. Other know versions, often based off of the original comp.sources.unix posting are:
- Debian libeditline, http://packages.qa.debian.org/e/editline.html
- Heimdal, http://www.h5l.org
- Festival speech-tools, http://festvox.org/festival/
- Steve Tell's editline patches, http://www.cs.unc.edu/~tell/dist.html
The most intersting patches and bug fixes from each fork have been merged here.

- 4,028
- 1
- 26
- 47
BusyBox contains command line editing code similar to readline, but much smaller and simpler, with full support for UTF-8. It would probably be easy to make it into an independent library.

- 208,859
- 35
- 376
- 711
editline(libedit) doesn't support multi-byte characters yet.
I also agree with Dan Loewenherz, the readline library is wide spread. For example, most linux distribution ships bash with readline. Most python distribution also ships with readline. If your project needs a readline-like library, it's a good idea to use GNU readline library since it's a popular choice and users may have it installed on the OS already.

- 28,682
- 5
- 48
- 60
-
2As of 2010-04-24 editline can be built with utf-8 support using `./configure --enable-widec`. – Graham Miln Jun 05 '14 at 16:54
-
3As of 2016-06-18 editline is always built with unicode (wide-char/UTF-8) support, and `--enable-widec` flag is deprecated. – AndreyT Oct 04 '16 at 14:37
-
1`If your project needs a readline-like library, it's a good idea to use GNU readline library since it's a popular choice and users may have it installed on the OS already.` Note that readline itself, and thus the resulting combined derived work (i.e. the binary), is GPL, which may or may not suit a particular project. – Ivan Vučica Oct 30 '18 at 11:48