Jump to content
 







Main menu
   


Navigation  



Main page
Contents
Current events
Random article
About Wikipedia
Contact us
Donate
 




Contribute  



Help
Learn to edit
Community portal
Recent changes
Upload file
 








Search  

































Create account

Log in
 









Create account
 Log in
 




Pages for logged out editors learn more  



Contributions
Talk
 



















Contents

   



(Top)
 


1 Editing modes  



1.1  Emacs keyboard shortcuts  







2 Choice of the GPL as GNU Readline's license  



2.1  Alternative libraries  







3 Sample code  





4 Bindings  





5 Notes  





6 References  





7 External links  














GNU Readline






Čeština
Deutsch
Ελληνικά
فارسی
Français


Polski
Português
Русский


 

Edit links
 









Article
Talk
 

















Read
Edit
View history
 








Tools
   


Actions  



Read
Edit
View history
 




General  



What links here
Related changes
Upload file
Special pages
Permanent link
Page information
Cite this page
Get shortened URL
Download QR code
Wikidata item
 




Print/export  



Download as PDF
Printable version
 
















Appearance
   

 






From Wikipedia, the free encyclopedia
 

(Redirected from Readline)

GNU Readline
Original author(s)Brian Fox
Developer(s)Chet Ramey
Initial release1989; 35 years ago (1989)
Stable release

8.2[1] Edit this on Wikidata / 26 September 2022

Repository
Written inC
TypeLibrary
License2009: GPL-3.0-or-later[a]
1997: GPL-2.0-or-later[b]
1994: GPL-1.0-or-later[c]
Websitewww.gnu.org/software/readline/ Edit this on Wikidata

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.

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

[edit]

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

[edit]

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+finXfce'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

[edit]

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

[edit]

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

[edit]

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>

int main()
{
    // Configure readline to auto-complete paths when the tab key is hit.
    rl_bind_key('\t', rl_complete);

    // Enable history
    using_history();

    while (1) {
        // Display prompt and read input
        char* 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 readline
        free(input);
    }
    return 0;
}

Bindings

[edit]

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

Support for readline alternatives differ among these bindings.

Notes

[edit]
  1. ^ GPL-3.0-or-later since version 6.0 (2009-02-20).
  • ^ GPL-2.0-or-later from version 2.1 (1997-06-05) until version 5.2 (2006-10-11).
  • ^ GPL-1.0-or-later from ? until version 2.0 (1994-08-04).
  • ^ 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]
  • References

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

    Categories: 
    Free software programmed in C
    GNU Project software
    Text user interface libraries
    Termcap
    Hidden categories: 
    Articles with short description
    Short description is different from Wikidata
     



    This page was last edited on 25 May 2024, at 12:26 (UTC).

    Text is available under the Creative Commons Attribution-ShareAlike License 4.0; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.



    Privacy policy

    About Wikipedia

    Disclaimers

    Contact Wikipedia

    Code of Conduct

    Developers

    Statistics

    Cookie statement

    Mobile view



    Wikimedia Foundation
    Powered by MediaWiki