Ubuntu o sistema operacional não lê as linhas de comando. Alguns programas lêem linhas de comando. Por exemplo, bash
é um interpretador de comandos (também conhecido como a < em> shell ), que lê as linhas de comando. Quando o shell é interativo e lê as linhas de comando de um terminal, ele usa o GNU readline
biblioteca.
$ sudo apt-get -y install libreadline6-dev readline-doc
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libtinfo-dev
The following NEW packages will be installed:
libreadline6-dev libtinfo-dev readline-doc
0 upgraded, 3 newly installed, 0 to remove and 1 not upgraded.
Need to get 299 kB of archives.
After this operation, 1,233 kB of additional disk space will be used.
...
$ sudo dpkg-query -l '*readline*'
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==============-============-============-=================================
un libreadline-co <none> <none> (no description available)
un libreadline-gp <none> <none> (no description available)
un libreadline4 <none> <none> (no description available)
ii libreadline5:a 5.2+dfsg-3bu amd64 GNU readline and history librarie
un libreadline5-d <none> <none> (no description available)
ii libreadline6:a 6.3-8ubuntu2 amd64 GNU readline and history librarie
ii libreadline6-d 6.3-8ubuntu2 amd64 GNU readline and history librarie
un libterm-readli <none> <none> (no description available)
un libterm-readli <none> <none> (no description available)
un php-readline <none> <none> (no description available)
ii php7.0-readlin 7.0.13-0ubun amd64 readline module for PHP
ii readline-commo 6.3-8ubuntu2 all GNU readline and history librarie
ii readline-doc 6.3-8ubuntu2 all GNU readline and history librarie
un tcl-tclreadlin <none> <none> (no description available)
$ cat trl.c
#include <stdio.h>
#include <stdlib.h>
#include <readline/readline.h>
int main(void)
{
char * line = readline("Enter some text: ");
if (line) {
printf("You have entered \"%s\"\n", line);
}
return EXIT_SUCCESS;
}
$ gcc -Wall trl.c -o trl -lreadline
$ ./trl
Enter some text: Some text to be read by readline()
You have entered "Some text to be read by readline()"