GNU Readline - 维基百科,自由的百科全书
![]() | |
原作者 | 布萊恩·福克斯 |
---|---|
開發者 | Chet Ramey |
首次发布 | 1989年 |
当前版本 | 8.2(2022年9月26日 | )
源代码库 | |
编程语言 | C |
类型 | 库 |
许可协议 | GNU通用公共许可证 |
网站 | tiswww |
GNU Readline是一个软件库,可为具有命令行界面(例如Bash)的交互式程序提供行编辑器和历史记录功能。是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 Lesser General Public License. The GNU Lesser General Public License v3.0 - GNU Project. Free Software Foundation. 2007 [2011-09-03]. (原始内容存档于2018-04-04).
- ^ GNU General Public License. The GNU General Public License v3.0 - GNU Project. Free Software Foundation. 2007 [2011-09-03]. (原始内容存档于2021-02-05).
- ^ 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).
- ^ 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).