GNU Readline
Original author(s) | Brian Fox |
---|---|
Developer(s) | Chet Ramey |
Initial release | 1989 |
Repository | |
Written in | C |
Operating system | Various |
Type | Library |
License | GNU General Public License |
Website | Official website |
GNU readline is a software library that provides line-editing and history capabilities for interactive programs with a command-line interface, such as Bash. It is currently maintained by Chet Ramey as part of the GNU Project.
It allows users to move the text cursor, search the command history, control a kill ring (a more flexible version of a copy/paste clipboard) and use tab completion on a text terminal.
Readline key bindings are taken from the text editor Emacs, but can be customized. As a cross-platform library, readline allows applications on various systems to exhibit identical line-editing behavior.
Choice of the GPL as GNU Readline's license
GNU Readline is notable for being a free software library which is licensed under the GNU General Public License (GPL) instead of the GNU Lesser General Public License (LGPL). Free software libraries are often licensed under the LGPL, for example, the GNU C Library, GNU gettext and FLTK.
A developer of a proprietary licensed or permissively licensed application who chooses to link to an LGPL licensed library when building a new application is required to have the LGPL licensed library which it uses remain under the LGPL when distributing the combined resulting application. The part of the combined application excluding the LGPL licensed library can remain under the original proprietary or permissive license.[1] This is in contrast to a developer choosing to use a GPL licensed library to create a new application, in which case the entire combined resulting application is required to be licensed under the GPL when distributed, to comply with section 5 of the GPL.[2][3]
This type of reciprocal licensing scheme is generally known as copyleft (more precisely the GPL is a strong copyleft license, while the LGPL is a weak copyleft license), and has ramifications for readline's integration into software that isn't under a copyleft license.
Licensing GNU Readline under a a strong copyleft license like the GPL means that, if a developer of a proprietary or permissively licensed application chooses to link that application with the readline library, they are obligated to change the license of the resulting application to the GPL if they wish to distribute the resulting application.
Implications of GNU Readline's GPL license
An important example of an application changing it's licensing to comply with the copyleft conditions of GNU Readline is CLISP, an implementation of Common Lisp. Originally released in 1987, it changed to the GPL license in 1992,[4] after an email exchange between one of CLISP's original author's, Bruno Haible, and Richard Stallman, in which Stallman argued[5] that the linking of readline in CLISP meant that Haible was required to re-license CLISP under the GPL if he wished to distribute the implementation of CLISP which used readline.[6]
Since its initial release, some developers of permissively licensed software who have wanted to use the GNU readline library in their applications have occasionally expressed their annoyance[7] with the licensing conditions of readline on development mailing lists. Other developers have responded by stating that this is a waste of time.[8]
Alternative command line editing libraries which are permissively licensed can be used by software projects which want to implement command line editing functionality, but wish to remain under a permissive license. For example the Glasgow Haskell Compiler uses Haskeline (which is licenced under the 3 clause BSD license). Similar libraries are listed in the external links.
Sample code
The following code is in C :
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <readline/readline.h>
#include <readline/history.h>
int main()
{
char* input, shell_prompt[100];
for(;;)
{
// getting the current user 'n path
snprintf(shell_prompt, sizeof(shell_prompt), "%s:%s $ ", getenv("USER"), getcwd(NULL, 1024));
// inputing...
input = readline(shell_prompt);
// eof
if (!input)
break;
// path autocompletion when tabulation hit
rl_bind_key('\t', rl_complete);
// adding the previous input into history
add_history(input);
/*do stuff*/
}
}
Notes and References
- ^ "GNU Lesser General Public License". The GNU Lesser General Public License v3.0 - GNU Project. Free Software Foundation. 2007. Retrieved 2011-09-3.
{{cite web}}
: Check date values in:|accessdate=
(help) - ^ "GNU General Public License". The GNU General Public License v3.0 - GNU Project. Free Software Foundation. 2007. Retrieved 2011-09-3.
{{cite web}}
: Check date values in:|accessdate=
(help) - ^ "Frequently Asked Questions about the GNU licenses". Frequently Asked Questions about the GNU Licenses - GNU Project. Free Software Foundation. 2010. Retrieved 2011-09-3.
{{cite web}}
: Check date values in:|accessdate=
(help) - ^ "CLISP copyright notice". CLISP repository. 1992. Retrieved 2011-09-3.
{{cite web}}
: Check date values in:|accessdate=
(help) - ^ "Why CLISP is under GPL". CLISP repository. 1992. Retrieved 2011-09-3.
{{cite web}}
: Check date values in:|accessdate=
(help) - ^ "License - why GNU GPL?". Frequently Asked Questions (With Answers) about CLISP. CLISP team. Retrieved 2011-09-3.
{{cite web}}
: Check date values in:|accessdate=
(help) - ^ Momjian, Bruce (2001). "GPL, readline, and static/dynamic linking". PostgreSQL development mailing list. Retrieved 2011-09-3.
This would seem to imply that our dynamic linking of libreadline in PostgreSQL backend binaries makes the distribution of backend binaries fall under the GPL. (Of course, we can use *BSD libedit now.) Let me add I don't agree with this, and find the whole GPL heavy-handedness very distasteful.
{{cite web}}
: Check date values in:|accessdate=
(help); line feed character in|quote=
at position 201 (help) - ^ Myers, Nathan (2001). "Re: GPL, readline, and static/dynamic linking". PostgreSQL development mailing list. Retrieved 2011-09-3.
Please, not this again. Is there a piss-and-moan-about-the-GPL schedule posted somewhere? Either PG is in compliance, or it's not. Only libreadline's copyright holder has the right to complain if it's not. There is no need to speculate; if we care about compliance, we need only ask the owner. If the owner says we're violating his license, then we can comply, or negotiate, or stop using the code. The GPL is no different from any other license, that way. Complaining about the terms on something you got for nothing has to be the biggest waste of time and attention I've seen on this list.
{{cite web}}
: Check date values in:|accessdate=
(help)
External links
- GNU readline homepage
- The Tecla command-line editing library - readline replacement with an MIT-style licence
- Editline Library (libedit) - readline replacement with a BSD-style licence
- Haskeline - pure Haskell readline replacement with a BSD3 licence
- rlwrap - tools that provides readline functionality while running a command that does not already have it