mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-08-08 03:02:40 +02:00
commit bash-20160429 snapshot
This commit is contained in:
@@ -1435,12 +1435,16 @@ It understands the EOF character or "exit" to exit the program.
|
||||
@example
|
||||
/* Standard include files. stdio.h is required. */
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <locale.h>
|
||||
|
||||
/* Used for select(2) */
|
||||
#include <sys/types.h>
|
||||
#include <sys/select.h>
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* Standard readline include files. */
|
||||
@@ -1448,10 +1452,20 @@ It understands the EOF character or "exit" to exit the program.
|
||||
#include <readline/history.h>
|
||||
|
||||
static void cb_linehandler (char *);
|
||||
static void sighandler (int);
|
||||
|
||||
int running;
|
||||
int sigwinch_received;
|
||||
const char *prompt = "rltest$ ";
|
||||
|
||||
/* Handle SIGWINCH and window size changes when readline is not active and
|
||||
reading a character. */
|
||||
static void
|
||||
sighandler (int sig)
|
||||
@{
|
||||
sigwinch_received = 1;
|
||||
@}
|
||||
|
||||
/* Callback function called for each line when accept-line executed, EOF
|
||||
seen, or EOF character read. This sets a flag and returns; it could
|
||||
also call exit(3). */
|
||||
@@ -1486,6 +1500,13 @@ main (int c, char **v)
|
||||
fd_set fds;
|
||||
int r;
|
||||
|
||||
/* Set the default locale values according to environment variables. */
|
||||
setlocale (LC_ALL, "");
|
||||
|
||||
/* Handle window size changes when readline is not active and reading
|
||||
characters. */
|
||||
signal (SIGWINCH, sighandler);
|
||||
|
||||
/* Install the line handler. */
|
||||
rl_callback_handler_install (prompt, cb_linehandler);
|
||||
|
||||
@@ -1500,12 +1521,19 @@ main (int c, char **v)
|
||||
FD_SET (fileno (rl_instream), &fds);
|
||||
|
||||
r = select (FD_SETSIZE, &fds, NULL, NULL, NULL);
|
||||
if (r < 0)
|
||||
if (r < 0 && errno != EINTR)
|
||||
@{
|
||||
perror ("rltest: select");
|
||||
rl_callback_handler_remove ();
|
||||
break;
|
||||
@}
|
||||
if (sigwinch_received)
|
||||
@{
|
||||
rl_resize_terminal ();
|
||||
sigwinch_received = 0;
|
||||
}@
|
||||
if (r < 0)
|
||||
continue;
|
||||
|
||||
if (FD_ISSET (fileno (rl_instream), &fds))
|
||||
rl_callback_read_char ();
|
||||
|
||||
+5
-1
@@ -236,7 +236,11 @@ tilde_expand (string)
|
||||
string += end;
|
||||
|
||||
expansion = tilde_expand_word (tilde_word);
|
||||
xfree (tilde_word);
|
||||
|
||||
if (expansion == 0)
|
||||
expansion = tilde_word;
|
||||
else
|
||||
xfree (tilde_word);
|
||||
|
||||
len = strlen (expansion);
|
||||
#ifdef __CYGWIN__
|
||||
|
||||
Reference in New Issue
Block a user