GNU Readline

Last updated
GNU Readline
Original author(s) Brian Fox
Developer(s) Chet Ramey
Initial release1989;35 years ago (1989)
Stable release
8.2 [1]   OOjs UI icon edit-ltr-progressive.svg / 26 September 2022
Repository
Written in C
Type Library
License 2009: GPL-3.0-or-later [lower-alpha 1]
1997: GPL-2.0-or-later [lower-alpha 2]
1994: GPL-1.0-or-later [lower-alpha 3]
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 LGPL licensed library can use any license for the application. [3] But linking to a GPL licensed library such as Readline requires the entire combined resulting application to be licensed under the GPL when distributed, to comply with section 5 of the GPL. [4] [5]

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

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 [2]

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 renewal.

<span class="mw-page-title-main">LaTeX</span> Document preparation software system

LaTeX is a software system for typesetting documents. LaTeX markup describes the content and layout of the document, as opposed to the formatted text found in WYSIWYG word processors like Microsoft Word, LibreOffice Writer and Apple Pages. The writer uses markup tagging conventions to define the general structure of a document, to stylise text throughout a document, and to add citations and cross-references. A TeX distribution such as TeX Live or MiKTeX is used to produce an output file suitable for printing or digital distribution.

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 providing an application programming interface (API) that allows the programmer to write text-based user interfaces (TUI) in a terminal-independent manner. It is a toolkit for developing "GUI-like" application software that runs under a terminal emulator. It also optimizes screen changes, in order to reduce the latency experienced when using remote shells.

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">XEmacs</span>

XEmacs is a graphical- and console-based text editor which runs on almost any Unix-like operating system as well as Microsoft Windows. XEmacs is a fork, based on a version of GNU Emacs from the late 1980s. Any user can download, use, and modify XEmacs as free software available under the GNU General Public License version 2 or any later version.

<span class="mw-page-title-main">Control key</span> Key on computer keyboards

In computing, a Control keyCtrl is a modifier key which, when pressed in conjunction with another key, performs a special operation. Similarly to the Shift key, the Control key rarely performs any function when pressed by itself. The Control key is located on or near the bottom left side of most keyboards, with many featuring an additional one at the bottom right.

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

A text 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.

<span class="mw-page-title-main">AutoHotkey</span> Automation-focused scripting language for Windows

AutoHotkey is a free and open-source custom scripting language for Microsoft Windows, primarily designed to provide easy keyboard shortcuts or hotkeys, fast macro-creation and software automation to allow users of most computer skill levels to automate repetitive tasks in any Windows application. It can easily extend or modify user interfaces. The installation package includes an extensive help file; web-based documentation is also available.

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),

In computing, Control-X or ^X is the key combination of the control key and a key usually labelled "X", typically used to cut selected text and save it to the clipboard ready to paste elsewhere. There is some disagreement whether the action moves with the key labelled "X" or stays in the lower-left location on keyboards with different letter arrangements.

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

GNU Emacs is a free software text editor. It was created 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. Its tag line is "the extensible self-documenting text editor."

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.3, released March 2024.

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

The GNU General Public License is a series of widely used free software licenses, or copyleft, that guarantee end users the four freedoms to run, study, share, and modify the software. The license was the first copyleft for general use, and 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.

<span class="mw-page-title-main">Spacemacs</span> Free software

Spacemacs is a configuration framework for GNU Emacs. It can take advantage of all of GNU Emacs' features, including both graphical and command-line user interfaces, and being executable under X Window System and within a Unix shell terminal. It is free and open-source software (FOSS) released under the GPL-3.0-or-later license.

References

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