GNU Readline

  • git.savannah.gnu.org/cgit/readline.git
編輯維基數據鏈接编程语言C类型许可协议GNU通用公共许可证网站tiswww.case.edu/php/chet/readline/rltop.html

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

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

GPL许可协议

GNU Readline是一个著名的自由软件库,它是通过GNU通用公共许可协议(GPL)进行授权的。而其他的自由软件库通常是通过GNU宽公用许可协议(LGPL)进行授权,例如GNU C库,GNU Gettext和FLTK[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;
}

外部链接

  • 自由软件主题
  • GNU readline主页
  • 关于GNU Readline你不知道的事情 (页面存档备份,存于互联网档案馆
历史
GNU's not UNIX
许可证
软件
公众发言人
其它议题
  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).