GNU Readline

Last updated
GNU Readline
Original author(s) Brian Fox
Developer(s) Chet Ramey
Initial release1989;36 years ago (1989)
Stable release
8.2 [1]   OOjs UI icon edit-ltr-progressive.svg / 26 September 2022
Preview release
8.3-alpha [2]   OOjs UI icon edit-ltr-progressive.svg / 22 April 2024
Repository
Written in C
Type Library
License 2009: GPL-3.0-or-later [a]
1997: GPL-2.0-or-later [b]
1994: GPL-1.0-or-later [c]
Website www.gnu.org/software/readline/   OOjs UI icon edit-ltr-progressive.svg

GNU Readline is a software library that provides in-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.

Contents

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. As a cross-platform library, readline allows applications on various systems to exhibit identical line-editing behavior.

Editing modes

Readline supports both Emacs and vi editing modes, which determine how keyboard input is interpreted as editor commands. See Editor war § Comparison.

Emacs keyboard shortcuts

Emacs editing mode key bindings are taken from the text editor Emacs.

On some systems, Esc must be used instead of Alt, because the Alt shortcut conflicts with another shortcut. For example, pressing Alt+f in Xfce's terminal emulator window does not move the cursor forward one word, but activates "File" in the menu of the terminal window, unless that is disabled in the emulator's settings.

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). Free software libraries are far more often licensed under the GNU Lesser General Public License (LGPL), for example, the GNU C Library, GNU gettext and FLTK. A developer of an application who chooses to link to an LGPLv3 licensed library can use any license that does not: "restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications". [4] But linking to a GPLv3 licensed library such as Readline requires the entire combined resulting application to be licensed under the GPLv3 when distributed, to comply with section 5 of the GPL. [5] [6]

This licensing was chosen by the FSF on the hopes that it would encourage software to switch to the GPL. [7] An important example of an application changing its 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, [8] after an email exchange between one of CLISP's original authors, Bruno Haible, and Richard Stallman, in which Stallman argued [9] 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. [10]

Another response has been to not use this in some projects, making text input use the primitive Unix terminal driver for editing.

Alternative libraries

Alternative libraries have been created with other licenses so they can be used by software projects which want to implement command line editing functionality, but be released with a non-GPL license.

Sample code

The following code is in C and must be linked against the readline library by passing a -lreadline flag to the compiler:

#include<stdlib.h>#include<stdio.h>#include<readline/readline.h>#include<readline/history.h>intmain(){// Configure readline to auto-complete paths when the tab key is hit.rl_bind_key('\t',rl_complete);// Enable historyusing_history();while(1){// Display prompt and read inputchar*input=readline("prompt> ");// Check for EOF.if(!input)break;// Add input to readline history.add_history(input);// Do stuff...// Free buffer that was allocated by readlinefree(input);}return0;}

Bindings

Non-C programming languages that provide language bindings for readline include

Support for readline alternatives differ among these bindings.

Notes

  1. GPL-3.0-or-later since version 6.0 (2009-02-20).
  2. GPL-2.0-or-later from version 2.1 (1997-06-05) until version 5.2 (2006-10-11).
  3. GPL-1.0-or-later from ? until version 2.0 (1994-08-04).
  4. A part of pseudoterminals or PTYs (for Linux), which is evident from the terminal configuration tools such as stty; in typical Linux distribution the PTY master endpoint treats special characters as signals to be sent to slaves e.g.SIGINT [3]

Related Research Articles

<span class="mw-page-title-main">Bash (Unix shell)</span> GNU replacement for the Bourne shell

Bash, short for Bourne-Again SHell, is a shell program and command language supported by the Free Software Foundation and first developed for the GNU Project by Brian Fox. Designed as a 100% free software alternative for the Bourne shell, it was initially released in 1989. Its moniker is a play on words, referencing both its predecessor, the Bourne shell, and the concept of rebirth.

<span class="mw-page-title-main">GNU Lesser General Public License</span> Free-software license

The GNU Lesser General Public License (LGPL) is a free-software license published by the Free Software Foundation (FSF). The license allows developers and companies to use and integrate a software component released under the LGPL into their own software without being required by the terms of a strong copyleft license to release the source code of their own components. However, any developer who modifies an LGPL-covered component is required to make their modified version available under the same LGPL license. For proprietary software, code under the LGPL is usually used in the form of a shared library, so that there is a clear separation between the proprietary and LGPL components. The LGPL is primarily used for software libraries, although it is also used by some stand-alone applications.

The MIT License is a permissive software license originating at the Massachusetts Institute of Technology (MIT) in the late 1980s. As a permissive license, it puts very few restrictions on reuse and therefore has high license compatibility.

<span class="mw-page-title-main">GNU nano</span> Text editor for Unix-like computing systems

GNU nano is a text editor for Unix-like computing systems or operating environments using a command line interface. It emulates the Pico text editor, part of the Pine email client, and also provides additional functionality. Unlike Pico, nano is licensed under the GNU General Public License (GPL). Released as free software by Chris Allegretta in 1999, nano became part of the GNU Project in 2001. The logo resembles the lowercase form of the Greek letter Eta (η).

ncurses Text-based user interface API

ncurses is a programming library for creating textual user interfaces (TUIs) that work across a wide variety of terminals; it is written in a way that attempts to optimize the commands that are sent to the terminal, so as reduce the latency experienced when updating the displayed content.

<span class="mw-page-title-main">Scroll Lock</span> Computer key

Scroll Lock is a lock key on most IBM-compatible computer keyboards. Depending on the operating system, it may be used for different purposes, and applications may assign functions to the key or change their behavior depending on its toggling state. The key is not frequently used, and therefore some reduced or specialized keyboards lack Scroll Lock altogether.

vi (text editor) Keyboard-oriented text editor

vi is a screen-oriented text editor originally created for the Unix operating system. The portable subset of the behavior of vi and programs based on it, and the ex editor language supported within these programs, is described by the Single Unix Specification and POSIX.

<span class="mw-page-title-main">Text box</span> Boxes where text is entered in computing

A text box also called an input box, text field or text entry box, is a control element of a graphical user interface, that should enable the user to input text information to be used by a program. Human Interface Guidelines recommend a single-line text box when only one line of input is required, and a multi-line text box only if more than one line of input may be required. Non-editable text boxes can serve the purpose of simply displaying text.

<span class="mw-page-title-main">Text-based user interface</span> Type of interface based on outputting to or controlling a text display

In computing, text-based user interfaces (TUI), is a retronym describing a type of user interface (UI) common as an early form of human–computer interaction, before the advent of bitmapped displays and modern conventional graphical user interfaces (GUIs). Like modern GUIs, they can use the entire screen area and may accept mouse and other inputs. They may also use color and often structure the display using box-drawing characters such as ┌ and ╣. The modern context of use is usually a terminal emulator.

The International Alphabet of Sanskrit Transliteration (IAST) is a transliteration scheme that allows the lossless romanisation of Indic scripts as employed by Sanskrit and related Indic languages. It is based on a scheme that emerged during the 19th century from suggestions by Charles Trevelyan, William Jones, Monier Monier-Williams and other scholars, and formalised by the Transliteration Committee of the Geneva Oriental Congress, in September 1894. IAST makes it possible for the reader to read the Indic text unambiguously, exactly as if it were in the original Indic script. It is this faithfulness to the original scripts that accounts for its continuing popularity amongst scholars.

<span class="mw-page-title-main">BusyBox</span> Collection of Unix tools

BusyBox is a software suite that provides several Unix utilities in a single executable file. It runs in a variety of POSIX environments such as Linux, Android, and FreeBSD, although many of the tools it provides are designed to work with interfaces provided by the Linux kernel. It was specifically created for embedded operating systems with very limited resources. The authors dubbed it "The Swiss Army knife of Embedded Linux", as the single executable replaces basic functions of more than 300 common commands. It is released as free software under the terms of the GNU General Public License v2, after controversially deciding not to move to version 3.

This article provides basic comparisons for notable text editors. More feature details for text editors are available from the Category of text editor features and from the individual products' articles. This article may not be up-to-date or necessarily all-inclusive.

gPHPedit is a discontinued UTF-8-compatible IDE for web development in PHP using the GNOME desktop environment. gPHPedit is built using Scintilla. It was originally written by Andy Jeffries, and was maintained by Anoop John. It is similar to gedit with the difference that it is designed for PHP and HTML text editing. The last version is 0.9.91, released on July 5, 2006. It is free software licensed under the terms of the GNU General Public License (GPL),

A permissive software license, sometimes also called BSD-like or BSD-style license, is a free-software license which instead of copyleft protections, carries only minimal restrictions on how the software can be used, modified, and redistributed, usually including a warranty disclaimer. Examples include the GNU All-permissive License, MIT License, BSD licenses, Apple Public Source License and Apache license. As of 2016, the most popular free-software license is the permissive MIT license.

In computing, Control-V is a key stroke with a variety of uses including generation of a control character in ASCII code, also known as the synchronous idle (SYN) character. The key stroke is generated by typing Ctrl+V. On MacOS based systems usually ⌘ Cmd+V is used instead.

<span class="mw-page-title-main">Unicode input</span> Input characters using their Unicode code points

Unicode input is method to add a specific Unicode character to a computer file; it is a common way to input characters not directly supported by a physical keyboard. Characters can be entered either by selecting them from a display, by typing a certain sequence of keys on a physical keyboard, or by drawing the symbol by hand on touch-sensitive screen. In contrast to ASCII's 96 element character set, Unicode encodes hundreds of thousands of graphemes (characters) from almost all of the world's written languages and many other signs and symbols besides.

<span class="mw-page-title-main">GNU Emacs</span> GNU version of the Emacs text editor

GNU Emacs is a text editor and suite of free software tools. Its development began in 1984 by GNU Project founder Richard Stallman, based on the Emacs editor developed for Unix operating systems. GNU Emacs has been a central component of the GNU project and a flagship project of the free software movement.

<span class="mw-page-title-main">Free-software license</span> License allowing software modification and redistribution

A free-software license is a notice that grants the recipient of a piece of software extensive rights to modify and redistribute that software. These actions are usually prohibited by copyright law, but the rights-holder of a piece of software can remove these restrictions by accompanying the software with a software license which grants the recipient these rights. Software using such a license is free software as conferred by the copyright holder. Free-software licenses are applied to software in source code and also binary object-code form, as the copyright law recognizes both forms.

Emacs, originally named EMACS, is a family of text editors that are characterized by their extensibility. The manual for the most widely used variant, GNU Emacs, describes it as "the extensible, customizable, self-documenting, real-time display editor". Development of the first Emacs began in the mid-1970s, and work on GNU Emacs, directly descended from the original, is ongoing; its latest version is 29.4 , released June 2024.

<span class="mw-page-title-main">GNU General Public License</span> Series of free software licenses

The GNU General Public Licenses are a series of widely used free software licenses, or copyleft licenses, that guarantee end users the freedoms to run, study, share, or modify the software. The GPL was the first copyleft license available for general use. It was originally written by Richard Stallman, the founder of the Free Software Foundation (FSF), for the GNU Project. The license grants the recipients of a computer program the rights of the Free Software Definition. The licenses in the GPL series are all copyleft licenses, which means that any derivative work must be distributed under the same or equivalent license terms. It is more restrictive than the Lesser General Public License, and even further distinct from the more widely-used permissive software licenses such as BSD, MIT, and Apache.

References

  1. Chet Ramey (26 September 2022). "Readline-8.2 Release available" . Retrieved 26 September 2022.
  2. "readline.git - The GNU Readline library" . Retrieved 7 August 2024.
  3. "pty(7) - Linux manual page". man7.org. Retrieved 2021-09-30.
  4. "GNU Lesser General Public License". The GNU Lesser General Public License v3.0 - GNU Project. Free Software Foundation. 2007. Retrieved 2011-09-03.
  5. "GNU General Public License". The GNU General Public License v3.0 - GNU Project. Free Software Foundation. 2007. Retrieved 2011-09-03.
  6. "Frequently Asked Questions about the GNU licenses". Frequently Asked Questions about the GNU Licenses - GNU Project. Free Software Foundation. 2010. Retrieved 2011-09-03.
  7. "Why you shouldn't use the Lesser GPL for your next library". Why you shouldn't use the Lesser GPL for your next library - GNU Project - Free Software Foundation. Free Software Foundation. 2016. Retrieved 2019-10-15.
  8. "CLISP copyright notice". CLISP repository. 1992. Retrieved 2011-09-03.
  9. "Why CLISP is under GPL". CLISP repository. 1992. Retrieved 2023-01-19.
  10. "License - why GNU GPL?". Frequently Asked Questions (With Answers) about CLISP. CLISP team. Retrieved 2011-09-03.
  11. "editline(3) - NetBSD Manual Pages". NetBSD . Retrieved 2022-09-13. Command Line Editor Library (libedit, -ledit)
  12. Editline Library (libedit)
  13. "MariaDB/server/blob/10.2/BUILD/SETUP.sh". MariaDB repository. MariaDB Foundation. Retrieved 2017-10-24.
  14. "php/php-src/tree/master/ext/readline". PHP repository. The PHP Group. Retrieved 2017-10-24.
  15. Sanfilippo, Salvatore (10 May 2020). "antirez/linenoise". GitHub .
  16. "Applications and libraries". Haskell wiki. haskell.org. Retrieved 2017-10-24.
  17. Judah Jacobson. "judah/haskeline: A Haskell library for line input in command-line programs". Haskeline repository. Retrieved 2017-10-24.
  18. "PowerShell/PSReadLine: A bash inspired readline implementation for PowerShell". PSReadLine repository. Retrieved 2023-12-20.
  19. "Module: Readline (Ruby 3.0.2)".