GNU Readline

出自Local Chinese Wikipedia
(重新導向自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). 

    外部鏈接[編輯]