GNU readline

GNU readline is a library created and maintained by the GNU project with features for editing rows. It is under the GPL, which is used in projects such as bash. The current version is 6.1, which now includes, among other things, support for multi-byte characters ( Unicode).

Supports a program readline, so for example, moves the pressure on Ctrl b move the cursor back one character, Ctrl f moves the cursor forward one character Ctrl r searches the command buffer. This default shortcut keys come from one of the first GNU projects, the Emacs text editor. Readline support a variety of basic functions, such as a so-called "kill ring" ( a more flexible variant of a clipboard) and tab-completion. Since it is a platform- independent library that allows users to readline same line editing behavior on different operating systems.

Readline can be customized using a configuration file that applies to the user ( ~ /. Inputrc ) or may be program specific. In this file it is possible to define your own keyboard shortcuts, and changing various other settings.

The GNU GPL license

While other free libraries are often licensed under the LGPL ( Library / Lesser GPL ), is readline under the GPL. A programmer of a proprietary ( non-free ) software may not be a standing under the LGPL library dynamically to its program left, a GPL library, however.

The reason that the GNU Project proprietary applications prohibits the use of the Readline library, is due to the GPL LGPL strategy. Because it is (for example) quite a few C libraries (libc ) out there, it would not make sense, linking proprietary applications with the GNU libc (glibc ) to prohibit because this would limit the spread of glibc more. However, Readline is the only library of its kind to the fact that it is under the GPL, get free programs an advantage over their proprietary counterparts, since they can use ReadLine. In the case of libc would, however, raise anyone an advantage when only free programs are expected to use them. Proprietary software could simply use a different C library. When Readline is this, as mentioned, not possible.

Example in C

# include # include # include # include # include   int main () {      char * input, shell_prompt;        for (; ;) { / / Configure readline to auto-complete paths When the tab key is hit.          rl_bind_key ('\ t', rl_complete );            / / Create prompt string from user name and current working directory.          snprintf ( shell_prompt, sizeof ( shell_prompt ), "% s :% s $", getenv ( "USER" ), getcwd (NULL, 1024) );            / / Display prompt and read input ( nb input must be freed after use) ...          input = readline ( shell_prompt );            / / Check for EOF.          if (! input)              break;            / / Add input to history.          add_history ( input);            / / Do stuff ...            / / Free input.          free ( input);      } } Web Links

  • GNU readline Homepage
  • The Tecla command- line editing library - readline replacement with an MIT license
  • Editline library ( libedit ) - readline replacement with a BSD license
  • Rlwrap - tools which enhance ongoing programs to readline functionality
270251
de