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). 

    外部連結[編輯]