GNU readline
Encyclopedia
GNU readline is a software library that provides line-editing and history capabilities for interactive programs with a command-line interface
Command-line interface
A command-line interface is a mechanism for interacting with a computer operating system or software by typing commands to perform specific tasks...

, such as Bash. It is currently maintained by Chet Ramey as part of the GNU Project
GNU Project
The GNU Project is a free software, mass collaboration project, announced on September 27, 1983, by Richard Stallman at MIT. It initiated GNU operating system development in January, 1984...

.

It allows users to move the text cursor, search the command history
Command History
Command history is a feature in many operating system shells, computer algebra programs, and other software that allows the user to recall, edit and rerun previous commands....

, control a kill ring (a more flexible version of a copy/paste clipboard) and use tab completion on a text terminal.

Readline key bindings
Keyboard shortcut
In computing, a keyboard shortcut is a finite set of one or more keys that invoke a software or operating system operation when triggered by the user. A meaning of term "keyboard shortcut" can vary depending on software manufacturer...

 are taken from the text editor
Text editor
A text editor is a type of program used for editing plain text files.Text editors are often provided with operating systems or software development packages, and can be used to change configuration files and programming language source code....

 Emacs
Emacs
Emacs is a class of text editors, usually characterized by their extensibility. GNU Emacs has over 1,000 commands. It also allows the user to combine these commands into macros to automate work.Development began in the mid-1970s and continues actively...

, but can be customized. As a cross-platform
Cross-platform
In computing, cross-platform, or multi-platform, is an attribute conferred to computer software or computing methods and concepts that are implemented and inter-operate on multiple computer platforms...

 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
Free software
Free software, software libre or libre software is software that can be used, studied, and modified without restriction, and which can be copied and redistributed in modified or unmodified form either without restriction, or with restrictions that only ensure that further recipients can also do...

 library which is licensed under the GNU General Public License
GNU General Public License
The GNU General Public License is the most widely used free software license, originally written by Richard Stallman for the GNU Project....

 (GPL) instead of the GNU Lesser General Public License
GNU Lesser General Public License
The GNU Lesser General Public License or LGPL is a free software license published by the Free Software Foundation . It was designed as a compromise between the strong-copyleft GNU General Public License or GPL and permissive licenses such as the BSD licenses and the MIT License...

 (LGPL). Free software libraries are often licensed under the LGPL, for example, the GNU C Library
GNU C Library
The GNU C Library, commonly known as glibc, is the C standard library released by the GNU Project. Originally written by the Free Software Foundation for the GNU operating system, the library's development has been overseen by a committee since 2001, with Ulrich Drepper from Red Hat as the lead...

, GNU gettext and FLTK
FLTK
FLTK is a cross-platform GUI library developed by Bill Spitzak and others. Made with 3D graphics programming in mind, it has an interface to OpenGL, but it is also suitable for general GUI programming....

.

A developer of an 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 license. 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.

This type of reciprocal licensing scheme is generally known as copyleft
Copyleft
Copyleft is a play on the word copyright to describe the practice of using copyright law to offer the right to distribute copies and modified versions of a work and requiring that the same rights be preserved in modified versions of the work...

 (more precisely the GPL and the LGPL are examples of strong and weak copyleft licenses respectively), and has ramifications for readline's integration into free software applications whose licences don't have any copyleft provisions (these licenses are usually referred to as permissive licenses).

Licensing GNU Readline under a a strong copyleft license like the GPL means that, if a developer of an 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 its licensing to comply with the copyleft conditions of GNU Readline is CLISP
CLISP
In computing, CLISP is an implementation of the programming language Common Lisp originally developed by Bruno Haible and Michael Stoll for the Atari ST...

, an implementation of Common Lisp
Common Lisp
Common Lisp, commonly abbreviated CL, is a dialect of the Lisp programming language, published in ANSI standard document ANSI INCITS 226-1994 , . From the ANSI Common Lisp standard the Common Lisp HyperSpec has been derived for use with web browsers...

. Originally released in 1987, it changed to the GPL license in 1992, after an email exchange between one of CLISP's original author's, Bruno Haible, and Richard Stallman
Richard Stallman
Richard Matthew Stallman , often shortened to rms,"'Richard Stallman' is just my mundane name; you can call me 'rms'"|last= Stallman|first= Richard|date= N.D.|work=Richard Stallman's homepage...

, in which Stallman argued 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.

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 with the licensing conditions of readline on development mailing lists. Other developers have responded by stating that this is a waste of time.

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
Glasgow Haskell Compiler
The Glorious Glasgow Haskell Compilation System, more commonly known as the Glasgow Haskell Compiler or GHC, is an open source native code compiler for the functional programming language Haskell. The lead developers are Simon Peyton Jones and Simon Marlow...

 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
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

 :

  1. include
  2. include
  3. include
  4. include
  5. include


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*/
}
}

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
    BSD licenses
    BSD licenses are a family of permissive free software licenses. The original license was used for the Berkeley Software Distribution , a Unix-like operating system after which it is named....

  • Haskeline - pure Haskell
    Haskell (programming language)
    Haskell is a standardized, general-purpose purely functional programming language, with non-strict semantics and strong static typing. It is named after logician Haskell Curry. In Haskell, "a function is a first-class citizen" of the programming language. As a functional programming language, the...

     readline replacement with a BSD3 licence
    BSD licenses
    BSD licenses are a family of permissive free software licenses. The original license was used for the Berkeley Software Distribution , a Unix-like operating system after which it is named....

  • rlwrap - tools that provides readline functionality while running a command that does not already have it
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK