GNU Readline

维基百科,自由的百科全书
(重定向自Readline
跳转到导航 跳转到搜索
GNU Readline
File:Heckert GNU white.svg
原作者布莱恩·福克斯
开发者Chet Ramey
首次发布1989年,​37年前​(1989
当前版本8.2(2022年9月26日,​3年前​(2022-09-26
源代码库
  • {{URL|example.com|可选的显示文本}}
Module:EditAtWikidata第29行Lua错误:attempt to index field 'wikibase' (a nil value)
编程语言C
引擎
    Module:EditAtWikidata第29行Lua错误:attempt to index field 'wikibase' (a nil value)
    类型
    许可协议GNU通用公共许可证
    网站tiswww.case.edu/php/chet/readline/rltop.html

    GNU Readline是一个软件库,可为具有命令行界面(例如Bash)的交互式程序提供行编辑器和历史记录功能。是GNU计划的一部分,目前由Chet Ramey维护。

    用户可以移动文本光标,搜索命令历史,控制kill ring(一个更灵活的剪贴板),并在文本终端上使用Tab键自动完成。作为一个跨平台的库,readline允许不同系统上的应用程序展现相同的行编辑行为。

    GPL许可协议[编辑]

    GNU Readline是一个著名的自由软件库,它是通过GNU通用公共许可协议(GPL)进行授权的。而其他的自由软件库通常是通过GNU宽公用许可协议(LGPL)进行授权,例如GNU C库GNU GettextFLTK[1]但其它软件在分发时,如果链接到像GNU Readline这种GPL协议的库,必须将与之相连的整个软件以GPL协议进行授权,以符合GPL第5章的规定。[2][3]自由软件基金会为GNU Readline选用了这个授权协议,以鼓励其它软件选用GPL协议。[4]

    示例代码[编辑]

    下面的代码是C语言的,必须通过向编译器传递-lreadline标志来链接到readline库:

    #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);
    
        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;
    }
    

    参考资料[编辑]

    1. ^ GNU Lesser General Public License. The GNU Lesser General Public License v3.0 - GNU Project. Free Software Foundation. 2007 [2011-09-03]. (原始内容存档于2018-04-04). 
    2. ^ GNU General Public License. The GNU General Public License v3.0 - GNU Project. Free Software Foundation. 2007 [2011-09-03]. (原始内容存档于2021-02-05). 
    3. ^ Frequently Asked Questions about the GNU licenses. Frequently Asked Questions about the GNU Licenses - GNU Project. Free Software Foundation. 2010 [2011-09-03]. (原始内容存档于2016-12-29). 
    4. ^ 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 [2019-10-15]. (原始内容存档于2020-12-09). 

    外部链接[编辑]