Imported from ../bash-2.02.tar.gz.
This commit is contained in:
parent
e8ce775db8
commit
cce855bc5b
323 changed files with 33916 additions and 12321 deletions
|
|
@ -190,7 +190,7 @@ rltty.o: readline.h keymaps.h chardefs.h tilde.h
|
|||
search.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
|
||||
search.o: readline.h keymaps.h chardefs.h tilde.h
|
||||
search.o: ansi_stdlib.h history.h
|
||||
shell.o: ${BUILD_DIR}/config.h
|
||||
shell.o: ${BUILD_DIR}/config.h ansi_stdlib.h
|
||||
signals.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
|
||||
signals.o: readline.h keymaps.h chardefs.h tilde.h
|
||||
signals.o: history.h
|
||||
|
|
|
|||
|
|
@ -70,6 +70,8 @@ extern int _rl_convert_meta_chars_to_ascii;
|
|||
extern int _rl_output_meta_chars;
|
||||
extern int _rl_complete_show_all;
|
||||
extern int _rl_complete_mark_directories;
|
||||
extern int _rl_print_completions_horizontally;
|
||||
extern int _rl_completion_case_fold;
|
||||
extern int _rl_enable_keypad;
|
||||
#if defined (PAREN_MATCHING)
|
||||
extern int rl_blink_matching_paren;
|
||||
|
|
@ -105,6 +107,7 @@ Keymap rl_binding_keymap;
|
|||
/* Forward declarations */
|
||||
void rl_set_keymap_from_edit_mode ();
|
||||
|
||||
static int _rl_read_init_file ();
|
||||
static int glean_key_from_name ();
|
||||
static int substring_member_of_array ();
|
||||
|
||||
|
|
@ -198,6 +201,35 @@ rl_unbind_key_in_map (key, map)
|
|||
return (rl_bind_key_in_map (key, (Function *)NULL, map));
|
||||
}
|
||||
|
||||
/* Unbind all keys bound to FUNCTION in MAP. */
|
||||
int
|
||||
rl_unbind_function_in_map (func, map)
|
||||
Function *func;
|
||||
Keymap map;
|
||||
{
|
||||
register int i;
|
||||
|
||||
for (i = 0; i < KEYMAP_SIZE; i++)
|
||||
{
|
||||
if (map[i].type == ISFUNC && map[i].function == func)
|
||||
map[i].function = (Function *)NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
rl_unbind_command_in_map (command, map)
|
||||
char *command;
|
||||
Keymap map;
|
||||
{
|
||||
Function *func;
|
||||
register int i;
|
||||
|
||||
func = rl_named_function (command);
|
||||
if (func == 0)
|
||||
return 0;
|
||||
return (rl_unbind_function_in_map (func, map));
|
||||
}
|
||||
|
||||
/* Bind the key sequence represented by the string KEYSEQ to
|
||||
FUNCTION. This makes new keymaps as necessary. The initial
|
||||
place to do bindings is in MAP. */
|
||||
|
|
@ -313,7 +345,7 @@ rl_translate_keyseq (seq, array, len)
|
|||
char *seq, *array;
|
||||
int *len;
|
||||
{
|
||||
register int i, c, l;
|
||||
register int i, c, l, temp;
|
||||
|
||||
for (i = l = 0; c = seq[i]; i++)
|
||||
{
|
||||
|
|
@ -324,7 +356,8 @@ rl_translate_keyseq (seq, array, len)
|
|||
if (c == 0)
|
||||
break;
|
||||
|
||||
if (((c == 'C' || c == 'M') && seq[i + 1] == '-') || (c == 'e'))
|
||||
/* Handle \C- and \M- prefixes. */
|
||||
if ((c == 'C' || c == 'M') && seq[i + 1] == '-')
|
||||
{
|
||||
/* Handle special case of backwards define. */
|
||||
if (strncmp (&seq[i], "C-\\M-", 5) == 0)
|
||||
|
|
@ -332,31 +365,83 @@ rl_translate_keyseq (seq, array, len)
|
|||
array[l++] = ESC;
|
||||
i += 5;
|
||||
array[l++] = CTRL (_rl_to_upper (seq[i]));
|
||||
if (!seq[i])
|
||||
if (seq[i] == '\0')
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (c)
|
||||
else if (c == 'M')
|
||||
{
|
||||
case 'M':
|
||||
i++;
|
||||
array[l++] = ESC; /* XXX */
|
||||
break;
|
||||
|
||||
case 'C':
|
||||
}
|
||||
else if (c == 'C')
|
||||
{
|
||||
i += 2;
|
||||
/* Special hack for C-?... */
|
||||
array[l++] = (seq[i] == '?') ? RUBOUT : CTRL (_rl_to_upper (seq[i]));
|
||||
break;
|
||||
|
||||
case 'e':
|
||||
array[l++] = ESC;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Translate other backslash-escaped characters. These are the
|
||||
same escape sequences that bash's `echo' and `printf' builtins
|
||||
handle, with the addition of \d -> RUBOUT. A backslash
|
||||
preceding a character that is not special is stripped. */
|
||||
switch (c)
|
||||
{
|
||||
case 'a':
|
||||
array[l++] = '\007';
|
||||
break;
|
||||
case 'b':
|
||||
array[l++] = '\b';
|
||||
break;
|
||||
case 'd':
|
||||
array[l++] = RUBOUT; /* readline-specific */
|
||||
break;
|
||||
case 'e':
|
||||
array[l++] = ESC;
|
||||
break;
|
||||
case 'f':
|
||||
array[l++] = '\f';
|
||||
break;
|
||||
case 'n':
|
||||
array[l++] = NEWLINE;
|
||||
break;
|
||||
case 'r':
|
||||
array[l++] = RETURN;
|
||||
break;
|
||||
case 't':
|
||||
array[l++] = TAB;
|
||||
break;
|
||||
case 'v':
|
||||
array[l++] = 0x0B;
|
||||
break;
|
||||
case '\\':
|
||||
array[l++] = '\\';
|
||||
break;
|
||||
case '0': case '1': case '2': case '3':
|
||||
case '4': case '5': case '6': case '7':
|
||||
i++;
|
||||
for (temp = 2, c -= '0'; ISOCTAL (seq[i]) && temp--; i++)
|
||||
c = (c * 8) + OCTVALUE (seq[i]);
|
||||
i--; /* auto-increment in for loop */
|
||||
array[l++] = c % (largest_char + 1);
|
||||
break;
|
||||
case 'x':
|
||||
i++;
|
||||
for (temp = 3, c = 0; isxdigit (seq[i]) && temp--; i++)
|
||||
c = (c * 16) + HEXVALUE (seq[i]);
|
||||
if (temp == 3)
|
||||
c = 'x';
|
||||
i--; /* auto-increment in for loop */
|
||||
array[l++] = c % (largest_char + 1);
|
||||
break;
|
||||
default: /* backslashes before non-special chars just add the char */
|
||||
array[l++] = c;
|
||||
break; /* the backslash is stripped */
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
array[l++] = c;
|
||||
}
|
||||
|
||||
|
|
@ -541,8 +626,55 @@ static char *last_readline_init_file = (char *)NULL;
|
|||
|
||||
/* The file we're currently reading key bindings from. */
|
||||
static char *current_readline_init_file;
|
||||
static int current_readline_init_include_level;
|
||||
static int current_readline_init_lineno;
|
||||
|
||||
/* Read FILENAME into a locally-allocated buffer and return the buffer.
|
||||
The size of the buffer is returned in *SIZEP. Returns NULL if any
|
||||
errors were encountered. */
|
||||
static char *
|
||||
_rl_read_file (filename, sizep)
|
||||
char *filename;
|
||||
size_t *sizep;
|
||||
{
|
||||
struct stat finfo;
|
||||
size_t file_size;
|
||||
char *buffer;
|
||||
int i, file;
|
||||
|
||||
if ((stat (filename, &finfo) < 0) || (file = open (filename, O_RDONLY, 0666)) < 0)
|
||||
return ((char *)NULL);
|
||||
|
||||
file_size = (size_t)finfo.st_size;
|
||||
|
||||
/* check for overflow on very large files */
|
||||
if (file_size != finfo.st_size || file_size + 1 < file_size)
|
||||
{
|
||||
if (file >= 0)
|
||||
close (file);
|
||||
#if defined (EFBIG)
|
||||
errno = EFBIG;
|
||||
#endif
|
||||
return ((char *)NULL);
|
||||
}
|
||||
|
||||
/* Read the file into BUFFER. */
|
||||
buffer = (char *)xmalloc (file_size + 1);
|
||||
i = read (file, buffer, file_size);
|
||||
close (file);
|
||||
|
||||
if (i < file_size)
|
||||
{
|
||||
free (buffer);
|
||||
return ((char *)NULL);
|
||||
}
|
||||
|
||||
buffer[file_size] = '\0';
|
||||
if (sizep)
|
||||
*sizep = file_size;
|
||||
return (buffer);
|
||||
}
|
||||
|
||||
/* Re-read the current keybindings file. */
|
||||
int
|
||||
rl_re_read_init_file (count, ignore)
|
||||
|
|
@ -565,11 +697,6 @@ int
|
|||
rl_read_init_file (filename)
|
||||
char *filename;
|
||||
{
|
||||
register int i;
|
||||
char *buffer, *openname, *line, *end;
|
||||
struct stat finfo;
|
||||
int file;
|
||||
|
||||
/* Default the filename. */
|
||||
if (filename == 0)
|
||||
{
|
||||
|
|
@ -583,39 +710,37 @@ rl_read_init_file (filename)
|
|||
if (*filename == 0)
|
||||
filename = DEFAULT_INPUTRC;
|
||||
|
||||
return (_rl_read_init_file (filename, 0));
|
||||
}
|
||||
|
||||
static int
|
||||
_rl_read_init_file (filename, include_level)
|
||||
char *filename;
|
||||
int include_level;
|
||||
{
|
||||
register int i;
|
||||
char *buffer, *openname, *line, *end;
|
||||
size_t file_size;
|
||||
|
||||
current_readline_init_file = filename;
|
||||
current_readline_init_include_level = include_level;
|
||||
|
||||
openname = tilde_expand (filename);
|
||||
|
||||
if ((stat (openname, &finfo) < 0) ||
|
||||
(file = open (openname, O_RDONLY, 0666)) < 0)
|
||||
buffer = _rl_read_file (openname, &file_size);
|
||||
if (buffer == 0)
|
||||
return (errno);
|
||||
|
||||
if (include_level == 0 && filename != last_readline_init_file)
|
||||
{
|
||||
free (openname);
|
||||
return (errno);
|
||||
}
|
||||
else
|
||||
free (openname);
|
||||
|
||||
if (filename != last_readline_init_file)
|
||||
{
|
||||
if (last_readline_init_file)
|
||||
free (last_readline_init_file);
|
||||
|
||||
FREE (last_readline_init_file);
|
||||
last_readline_init_file = savestring (filename);
|
||||
}
|
||||
|
||||
/* Read the file into BUFFER. */
|
||||
buffer = (char *)xmalloc ((int)finfo.st_size + 1);
|
||||
i = read (file, buffer, finfo.st_size);
|
||||
close (file);
|
||||
|
||||
if (i != finfo.st_size)
|
||||
return (errno);
|
||||
|
||||
/* Loop over the lines in the file. Lines that start with `#' are
|
||||
comments; all other lines are commands for readline initialization. */
|
||||
current_readline_init_lineno = 1;
|
||||
line = buffer;
|
||||
end = buffer + finfo.st_size;
|
||||
end = buffer + file_size;
|
||||
while (line < end)
|
||||
{
|
||||
/* Find the end of this line. */
|
||||
|
|
@ -639,6 +764,7 @@ rl_read_init_file (filename)
|
|||
line += i + 1;
|
||||
current_readline_init_lineno++;
|
||||
}
|
||||
|
||||
free (buffer);
|
||||
return (0);
|
||||
}
|
||||
|
|
@ -697,7 +823,7 @@ parser_if (args)
|
|||
if (args[i])
|
||||
args[i++] = '\0';
|
||||
|
||||
/* Handle "if term=foo" and "if mode=emacs" constructs. If this
|
||||
/* Handle "$if term=foo" and "$if mode=emacs" constructs. If this
|
||||
isn't term=foo, or mode=emacs, then check to see if the first
|
||||
word in ARGS is the same as the value stored in rl_readline_name. */
|
||||
if (rl_terminal_name && _rl_strnicmp (args, "term=", 5) == 0)
|
||||
|
|
@ -749,9 +875,9 @@ parser_else (args)
|
|||
{
|
||||
register int i;
|
||||
|
||||
if (!if_stack_depth)
|
||||
if (if_stack_depth == 0)
|
||||
{
|
||||
/* Error message? */
|
||||
_rl_init_file_error ("$else found without matching $if");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -775,12 +901,36 @@ parser_endif (args)
|
|||
if (if_stack_depth)
|
||||
_rl_parsing_conditionalized_out = if_stack[--if_stack_depth];
|
||||
else
|
||||
{
|
||||
/* *** What, no error message? *** */
|
||||
}
|
||||
_rl_init_file_error ("$endif without matching $if");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
parser_include (args)
|
||||
char *args;
|
||||
{
|
||||
char *old_init_file, *e;
|
||||
int old_line_number, old_include_level, r;
|
||||
|
||||
if (_rl_parsing_conditionalized_out)
|
||||
return (0);
|
||||
|
||||
old_init_file = current_readline_init_file;
|
||||
old_line_number = current_readline_init_lineno;
|
||||
old_include_level = current_readline_init_include_level;
|
||||
|
||||
e = strchr (args, '\n');
|
||||
if (e)
|
||||
*e = '\0';
|
||||
r = _rl_read_init_file (args, old_include_level + 1);
|
||||
|
||||
current_readline_init_file = old_init_file;
|
||||
current_readline_init_lineno = old_line_number;
|
||||
current_readline_init_include_level = old_include_level;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Associate textual names with actual functions. */
|
||||
static struct {
|
||||
char *name;
|
||||
|
|
@ -789,6 +939,7 @@ static struct {
|
|||
{ "if", parser_if },
|
||||
{ "endif", parser_endif },
|
||||
{ "else", parser_else },
|
||||
{ "include", parser_include },
|
||||
{ (char *)0x0, (Function *)0x0 }
|
||||
};
|
||||
|
||||
|
|
@ -825,7 +976,8 @@ handle_parser_directive (statement)
|
|||
return (0);
|
||||
}
|
||||
|
||||
/* *** Should an error message be output? */
|
||||
/* display an error message about the unknown parser directive */
|
||||
_rl_init_file_error ("unknown parser directive");
|
||||
return (1);
|
||||
}
|
||||
|
||||
|
|
@ -940,10 +1092,9 @@ rl_parse_and_bind (string)
|
|||
the quoted string delimiter, like the shell. */
|
||||
if (*funname == '\'' || *funname == '"')
|
||||
{
|
||||
int delimiter = string[i++];
|
||||
int passc = 0;
|
||||
int delimiter = string[i++], passc;
|
||||
|
||||
for (; c = string[i]; i++)
|
||||
for (passc = 0; c = string[i]; i++)
|
||||
{
|
||||
if (passc)
|
||||
{
|
||||
|
|
@ -981,11 +1132,11 @@ rl_parse_and_bind (string)
|
|||
rl_set_key (). Otherwise, let the older code deal with it. */
|
||||
if (*string == '"')
|
||||
{
|
||||
char *seq = xmalloc (1 + strlen (string));
|
||||
register int j, k = 0;
|
||||
int passc = 0;
|
||||
char *seq;
|
||||
register int j, k, passc;
|
||||
|
||||
for (j = 1; string[j]; j++)
|
||||
seq = xmalloc (1 + strlen (string));
|
||||
for (j = 1, k = passc = 0; string[j]; j++)
|
||||
{
|
||||
/* Allow backslash to quote characters, but leave them in place.
|
||||
This allows a string to end with a backslash quoting another
|
||||
|
|
@ -1078,6 +1229,7 @@ static struct {
|
|||
#if defined (PAREN_MATCHING)
|
||||
{ "blink-matching-paren", &rl_blink_matching_paren },
|
||||
#endif
|
||||
{ "completion-ignore-case", &_rl_completion_case_fold },
|
||||
{ "convert-meta", &_rl_convert_meta_chars_to_ascii },
|
||||
{ "disable-completion", &rl_inhibit_completion },
|
||||
{ "enable-keypad", &_rl_enable_keypad },
|
||||
|
|
@ -1088,6 +1240,7 @@ static struct {
|
|||
{ "mark-modified-lines", &_rl_mark_modified_lines },
|
||||
{ "meta-flag", &_rl_meta_flag },
|
||||
{ "output-meta", &_rl_output_meta_chars },
|
||||
{ "print-completions-horizontally", &_rl_print_completions_horizontally },
|
||||
{ "show-all-if-ambiguous", &_rl_complete_show_all },
|
||||
#if defined (VISIBLE_STATS)
|
||||
{ "visible-stats", &rl_visible_stats },
|
||||
|
|
@ -1186,6 +1339,7 @@ rl_variable_bind (name, value)
|
|||
_rl_bell_preference = AUDIBLE_BELL;
|
||||
}
|
||||
|
||||
/* For the time being, unknown variable names are simply ignored. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1338,7 +1492,7 @@ _rl_get_keyname (key)
|
|||
int key;
|
||||
{
|
||||
char *keyname;
|
||||
int i, c;
|
||||
int i, c, v;
|
||||
|
||||
keyname = (char *)xmalloc (8);
|
||||
|
||||
|
|
@ -1383,6 +1537,18 @@ _rl_get_keyname (key)
|
|||
c = _rl_to_lower (UNCTRL (c));
|
||||
}
|
||||
|
||||
/* XXX experimental code. Turn the characters that are not ASCII or
|
||||
ISO Latin 1 (128 - 159) into octal escape sequences (\200 - \237).
|
||||
This changes C. */
|
||||
if (c >= 128 && c <= 159)
|
||||
{
|
||||
keyname[i++] = '\\';
|
||||
keyname[i++] = '2';
|
||||
c -= 128;
|
||||
keyname[i++] = (c / 8) + '0';
|
||||
c = (c % 8) + '0';
|
||||
}
|
||||
|
||||
/* Now, if the character needs to be quoted with a backslash, do that. */
|
||||
if (c == '\\' || c == '"')
|
||||
keyname[i++] = '\\';
|
||||
|
|
@ -1692,10 +1858,13 @@ rl_variable_dumper (print_readably)
|
|||
/* bell-style */
|
||||
switch (_rl_bell_preference)
|
||||
{
|
||||
case NO_BELL: kname = "none"; break;
|
||||
case VISIBLE_BELL: kname = "visible"; break;
|
||||
case NO_BELL:
|
||||
kname = "none"; break;
|
||||
case VISIBLE_BELL:
|
||||
kname = "visible"; break;
|
||||
case AUDIBLE_BELL:
|
||||
default: kname = "audible"; break;
|
||||
default:
|
||||
kname = "audible"; break;
|
||||
}
|
||||
if (print_readably)
|
||||
fprintf (rl_outstream, "set bell-style %s\n", kname);
|
||||
|
|
|
|||
|
|
@ -55,10 +55,10 @@ extern int rl_visible_prompt_length;
|
|||
things to handle at once, and dispatches them via select(). Call
|
||||
rl_callback_handler_install() with the prompt and a function to call
|
||||
whenever a complete line of input is ready. The user must then
|
||||
call readline_char() every time some input is available, and
|
||||
readline_char() will call the user's function with the complete text
|
||||
read in at each end of line. The terminal is kept prepped and signals
|
||||
handled all the time, except during calls to the user's function. */
|
||||
call rl_callback_read_char() every time some input is available, and
|
||||
rl_callback_read_char() will call the user's function with the complete
|
||||
text read in at each end of line. The terminal is kept prepped and
|
||||
signals handled all the time, except during calls to the user's function. */
|
||||
|
||||
VFunction *rl_linefunc; /* user callback function */
|
||||
static int in_handler; /* terminal_prepped and signals set? */
|
||||
|
|
|
|||
|
|
@ -121,7 +121,20 @@
|
|||
#ifdef ESC
|
||||
#undef ESC
|
||||
#endif
|
||||
|
||||
#define ESC CTRL('[')
|
||||
|
||||
#ifndef ISOCTAL
|
||||
#define ISOCTAL(c) ((c) >= '0' && (c) <= '7')
|
||||
#endif
|
||||
#define OCTVALUE(c) ((c) - '0')
|
||||
|
||||
#ifndef isxdigit
|
||||
# define isxdigit(c) (isdigit((c)) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F'))
|
||||
#endif
|
||||
|
||||
#define HEXVALUE(c) \
|
||||
(((c) >= 'a' && (c) <= 'f') \
|
||||
? (c)-'a'+10 \
|
||||
: (c) >= 'A' && (c) <= 'F' ? (c)-'A'+10 : (c)-'0')
|
||||
|
||||
#endif /* _CHARDEFS_H_ */
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -72,7 +72,11 @@ extern int _rl_prefer_visible_bell;
|
|||
|
||||
/* Variables and functions imported from terminal.c */
|
||||
extern void _rl_output_some_chars ();
|
||||
#ifdef _MINIX
|
||||
extern void _rl_output_character_function ();
|
||||
#else
|
||||
extern int _rl_output_character_function ();
|
||||
#endif
|
||||
extern int _rl_backspace ();
|
||||
|
||||
extern char *term_clreol, *term_clrpag;
|
||||
|
|
|
|||
|
|
@ -7,20 +7,25 @@
|
|||
@setchapternewpage odd
|
||||
|
||||
@ignore
|
||||
last change: Thu Mar 21 16:07:29 EST 1996
|
||||
last change: Thu Apr 2 14:38:22 EST 1998
|
||||
@end ignore
|
||||
|
||||
@set EDITION 2.1
|
||||
@set VERSION 2.1
|
||||
@set UPDATED 21 March 1996
|
||||
@set UPDATE-MONTH March 1996
|
||||
@set EDITION 2.2
|
||||
@set VERSION 2.2
|
||||
@set UPDATED 2 April 1998
|
||||
@set UPDATE-MONTH April 1998
|
||||
|
||||
@dircategory Libraries
|
||||
@direntry
|
||||
* History: (history). The GNU history library API
|
||||
@end direntry
|
||||
|
||||
@ifinfo
|
||||
This document describes the GNU History library, a programming tool that
|
||||
provides a consistent user interface for recalling lines of previously
|
||||
typed input.
|
||||
|
||||
Copyright (C) 1988, 1991, 1993, 1995, 1996 Free Software Foundation, Inc.
|
||||
Copyright (C) 1988, 1991, 1993, 1995, 1996, 1998 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to make and distribute verbatim copies of
|
||||
this manual provided the copyright notice and this permission notice
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ into another language, under the above conditions for modified versions.
|
|||
@ifset BashFeatures
|
||||
This chapter describes how to use the GNU History Library interactively,
|
||||
from a user's standpoint. It should be considered a user's guide. For
|
||||
information on using the GNU History Library in your own programs,
|
||||
information on using the GNU History Library in other programs,
|
||||
see the GNU Readline Library Manual.
|
||||
@end ifset
|
||||
@ifclear BashFeatures
|
||||
|
|
@ -43,6 +43,8 @@ information on using the GNU History Library in your own programs,
|
|||
@menu
|
||||
* Bash History Facilities:: How Bash lets you manipulate your command
|
||||
history.
|
||||
* Bash History Builtins:: The Bash builtin commands that manipulate
|
||||
the command history.
|
||||
* History Interaction:: What it feels like using History as a user.
|
||||
@end menu
|
||||
@end ifset
|
||||
|
|
@ -84,11 +86,10 @@ not saved. After saving the history, the history file is truncated
|
|||
to contain no more than @code{$HISTFILESIZE}
|
||||
lines. If @code{HISTFILESIZE} is not set, no truncation is performed.
|
||||
|
||||
The builtin command @code{fc} (@pxref{Korn Shell Builtins})
|
||||
may be used to list or edit and re-execute a portion of
|
||||
the history list. The @code{history} builtin (@pxref{C Shell Builtins})
|
||||
can be used to display or modify the history list and
|
||||
manipulate the history file.
|
||||
The builtin command @code{fc} may be used to list or edit and re-execute
|
||||
a portion of the history list.
|
||||
The @code{history} builtin can be used to display or modify the history
|
||||
list and manipulate the history file.
|
||||
When using the command-line editing, search commands
|
||||
are available in each editing mode that provide access to the
|
||||
history list.
|
||||
|
|
@ -104,11 +105,103 @@ semicolons where necessary to preserve syntactic correctness.
|
|||
The @code{lithist}
|
||||
shell option causes the shell to save the command with embedded newlines
|
||||
instead of semicolons.
|
||||
@xref{Bash Builtins} for a description of @code{shopt}.
|
||||
@xref{Bash Builtins}, for a description of @code{shopt}.
|
||||
|
||||
@node Bash History Builtins
|
||||
@section Bash History Builtins
|
||||
@cindex history builtins
|
||||
|
||||
Bash provides two builtin commands that allow you to manipulate the
|
||||
history list and history file.
|
||||
|
||||
@table @code
|
||||
|
||||
@item fc
|
||||
@btindex fc
|
||||
@example
|
||||
@code{fc [-e @var{ename}] [-nlr] [@var{first}] [@var{last}]}
|
||||
@code{fc -s [@var{pat}=@var{rep}] [@var{command}]}
|
||||
@end example
|
||||
|
||||
Fix Command. In the first form, a range of commands from @var{first} to
|
||||
@var{last} is selected from the history list. Both @var{first} and
|
||||
@var{last} may be specified as a string (to locate the most recent
|
||||
command beginning with that string) or as a number (an index into the
|
||||
history list, where a negative number is used as an offset from the
|
||||
current command number). If @var{last} is not specified it is set to
|
||||
@var{first}. If @var{first} is not specified it is set to the previous
|
||||
command for editing and @minus{}16 for listing. If the @samp{-l} flag is
|
||||
given, the commands are listed on standard output. The @samp{-n} flag
|
||||
suppresses the command numbers when listing. The @samp{-r} flag
|
||||
reverses the order of the listing. Otherwise, the editor given by
|
||||
@var{ename} is invoked on a file containing those commands. If
|
||||
@var{ename} is not given, the value of the following variable expansion
|
||||
is used: @code{$@{FCEDIT:-$@{EDITOR:-vi@}@}}. This says to use the
|
||||
value of the @code{FCEDIT} variable if set, or the value of the
|
||||
@code{EDITOR} variable if that is set, or @code{vi} if neither is set.
|
||||
When editing is complete, the edited commands are echoed and executed.
|
||||
|
||||
In the second form, @var{command} is re-executed after each instance
|
||||
of @var{pat} in the selected command is replaced by @var{rep}.
|
||||
|
||||
A useful alias to use with the @code{fc} command is @code{r='fc -s'}, so
|
||||
that typing @samp{r cc} runs the last command beginning with @code{cc}
|
||||
and typing @samp{r} re-executes the last command (@pxref{Aliases}).
|
||||
|
||||
@item history
|
||||
@btindex history
|
||||
@example
|
||||
history [-c] [@var{n}]
|
||||
history [-anrw] [@var{filename}]
|
||||
history -ps @var{arg}
|
||||
@end example
|
||||
|
||||
Display the history list with line numbers. Lines prefixed with
|
||||
with a @samp{*} have been modified. An argument of @var{n} says
|
||||
to list only the last @var{n} lines. Options, if supplied, have
|
||||
the following meanings:
|
||||
|
||||
@table @code
|
||||
@item -w
|
||||
Write out the current history to the history file.
|
||||
|
||||
@item -r
|
||||
Read the current history file and append its contents to
|
||||
the history list.
|
||||
|
||||
@item -a
|
||||
Append the new
|
||||
history lines (history lines entered since the beginning of the
|
||||
current Bash session) to the history file.
|
||||
|
||||
@item -n
|
||||
Append the history lines not already read from the history file
|
||||
to the current history list. These are lines appended to the history
|
||||
file since the beginning of the current Bash session.
|
||||
|
||||
@item -c
|
||||
Clear the history list. This may be combined
|
||||
with the other options to replace the history list completely.
|
||||
|
||||
@item -s
|
||||
The @var{arg}s are added to the end of
|
||||
the history list as a single entry.
|
||||
|
||||
@item -p
|
||||
Perform history substitution on the @var{arg}s and display the result
|
||||
on the standard output, without storing the results in the history list.
|
||||
@end table
|
||||
|
||||
When the @samp{-w}, @samp{-r}, @samp{-a}, or @samp{-n} option is
|
||||
used, if @var{filename}
|
||||
is given, then it is used as the history file. If not, then
|
||||
the value of the @code{HISTFILE} variable is used.
|
||||
|
||||
@end table
|
||||
@end ifset
|
||||
|
||||
@node History Interaction
|
||||
@section Interactive History Expansion
|
||||
@section History Expansion
|
||||
@cindex history expansion
|
||||
|
||||
The History library provides a history expansion feature that is similar
|
||||
|
|
@ -121,14 +214,14 @@ arguments to a previous command into the current input line, or
|
|||
fix errors in previous commands quickly.
|
||||
|
||||
History expansion takes place in two parts. The first is to determine
|
||||
which line from the previous history should be used during substitution.
|
||||
which line from the history list should be used during substitution.
|
||||
The second is to select portions of that line for inclusion into the
|
||||
current one. The line selected from the previous history is called the
|
||||
current one. The line selected from the history is called the
|
||||
@dfn{event}, and the portions of that line that are acted upon are
|
||||
called @dfn{words}. Various @dfn{modifiers} are available to manipulate
|
||||
the selected words. The line is broken into words in the same fashion
|
||||
that Bash does, so that several English (or Unix) words
|
||||
surrounded by quotes are considered as one word.
|
||||
that Bash does, so that several words
|
||||
surrounded by quotes are considered one word.
|
||||
History expansions are introduced by the appearance of the
|
||||
history expansion character, which is @samp{!} by default.
|
||||
@ifset BashFeatures
|
||||
|
|
@ -153,6 +246,7 @@ may be used to see what a history expansion will do before using it.
|
|||
The @samp{-s} option to the @code{history} builtin may be used to
|
||||
add commands to the end of the history list without actually executing
|
||||
them, so that they are available for subsequent recall.
|
||||
This is most useful in conjunction with Readline.
|
||||
|
||||
The shell allows control of the various characters used by the
|
||||
history expansion mechanism with the @code{histchars} variable.
|
||||
|
|
@ -176,7 +270,7 @@ history list.
|
|||
|
||||
@item @code{!}
|
||||
Start a history substitution, except when followed by a space, tab,
|
||||
the end of the line, @key{=} or @key{(}.
|
||||
the end of the line, @samp{=} or @samp{(}.
|
||||
|
||||
@item @code{!@var{n}}
|
||||
Refer to command line @var{n}.
|
||||
|
|
@ -210,7 +304,7 @@ The entire command line typed so far.
|
|||
|
||||
Word designators are used to select desired words from the event.
|
||||
A @samp{:} separates the event specification from the word designator. It
|
||||
can be omitted if the word designator begins with a @samp{^}, @samp{$},
|
||||
may be omitted if the word designator begins with a @samp{^}, @samp{$},
|
||||
@samp{*}, @samp{-}, or @samp{%}. Words are numbered from the beginning
|
||||
of the line, with the first word being denoted by 0 (zero). Words are
|
||||
inserted into the current line separated by single spaces.
|
||||
|
|
|
|||
|
|
@ -7,20 +7,25 @@
|
|||
@setchapternewpage odd
|
||||
|
||||
@ignore
|
||||
last change: Thu Mar 21 16:06:39 EST 1996
|
||||
last change: Thu Apr 2 14:39:03 EST 1998
|
||||
@end ignore
|
||||
|
||||
@set EDITION 2.1
|
||||
@set VERSION 2.1
|
||||
@set UPDATED 21 March 1996
|
||||
@set UPDATE-MONTH March 1996
|
||||
@set EDITION 2.2
|
||||
@set VERSION 2.2
|
||||
@set UPDATED 2 April 1998
|
||||
@set UPDATE-MONTH April 1998
|
||||
|
||||
@dircategory Libraries
|
||||
@direntry
|
||||
* Readline: (readline). The GNU readline library API
|
||||
@end direntry
|
||||
|
||||
@ifinfo
|
||||
This document describes the GNU Readline Library, a utility which aids
|
||||
in the consistency of user interface across discrete programs that need
|
||||
to provide a command line interface.
|
||||
|
||||
Copyright (C) 1988, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1988, 1991, 1993, 1996, 1998 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to make and distribute verbatim copies of
|
||||
this manual provided the copyright notice and this permission notice
|
||||
|
|
|
|||
|
|
@ -454,6 +454,14 @@ Bind @var{key} to the null function in @var{map}.
|
|||
Returns non-zero in case of error.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun int rl_unbind_function_in_map (Function *function, Keymap map)
|
||||
Unbind all keys that execute @var{function} in @var{map}.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun int rl_unbind_command_in_map (char *command, Keymap map)
|
||||
Unbind all keys that are bound to @var{command} in @var{map}.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun int rl_generic_bind (int type, char *keyseq, char *data, Keymap map)
|
||||
Bind the key sequence represented by the string @var{keyseq} to the arbitrary
|
||||
pointer @var{data}. @var{type} says what kind of data is pointed to by
|
||||
|
|
@ -1034,7 +1042,7 @@ unless they also appear within this list.
|
|||
|
||||
@deftypevar {char *} rl_filename_quote_characters
|
||||
A list of characters that cause a filename to be quoted by the completer
|
||||
when they appear in a completed filename. The default is empty.
|
||||
when they appear in a completed filename. The default is the null string.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar {char *} rl_special_prefixes
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ Delete the character underneath the cursor.
|
|||
@item @w{Printing characters}
|
||||
Insert the character into the line at the cursor.
|
||||
@item @key{C-_}
|
||||
Undo the last thing that you did. You can undo all the way back to an
|
||||
Undo the last editing command. You can undo all the way back to an
|
||||
empty line.
|
||||
@end table
|
||||
|
||||
|
|
@ -155,7 +155,7 @@ Move to the start of the line.
|
|||
@item C-e
|
||||
Move to the end of the line.
|
||||
@item M-f
|
||||
Move forward a word.
|
||||
Move forward a word, where a word is composed of letters and digits.
|
||||
@item M-b
|
||||
Move backward a word.
|
||||
@item C-l
|
||||
|
|
@ -207,7 +207,7 @@ Kill from the cursor to the previous whitespace. This is different than
|
|||
|
||||
@end table
|
||||
|
||||
And, here is how to @dfn{yank} the text back into the line. Yanking
|
||||
Here is how to @dfn{yank} the text back into the line. Yanking
|
||||
means to copy the most-recently-killed text from the kill buffer.
|
||||
|
||||
@table @key
|
||||
|
|
@ -227,10 +227,10 @@ argument acts as a repeat count, other times it is the @i{sign} of the
|
|||
argument that is significant. If you pass a negative argument to a
|
||||
command which normally acts in a forward direction, that command will
|
||||
act in a backward direction. For example, to kill text back to the
|
||||
start of the line, you might type @w{@kbd{M-- C-k}}.
|
||||
start of the line, you might type @samp{M-- C-k}.
|
||||
|
||||
The general way to pass numeric arguments to a command is to type meta
|
||||
digits before the command. If the first `digit' you type is a minus
|
||||
digits before the command. If the first `digit' typed is a minus
|
||||
sign (@key{-}), then the sign of the argument will be negative. Once
|
||||
you have typed one meta digit to get the argument started, you can type
|
||||
the remainder of the digits, and then the command. For example, to give
|
||||
|
|
@ -248,38 +248,38 @@ There are two search modes: @var{incremental} and @var{non-incremental}.
|
|||
|
||||
Incremental searches begin before the user has finished typing the
|
||||
search string.
|
||||
As each character of the search string is typed, readline displays
|
||||
As each character of the search string is typed, Readline displays
|
||||
the next entry from the history matching the string typed so far.
|
||||
An incremental search requires only as many characters as needed to
|
||||
find the desired history entry.
|
||||
The Escape character is used to terminate an incremental search.
|
||||
Control-J will also terminate the search.
|
||||
Control-G will abort an incremental search and restore the original
|
||||
line.
|
||||
The @key{ESC} character is used to terminate an incremental search.
|
||||
@key{C-j} will also terminate the search.
|
||||
@key{C-g} will abort an incremental search and restore the original line.
|
||||
When the search is terminated, the history entry containing the
|
||||
search string becomes the current line.
|
||||
To find other matching entries in the history list, type Control-S or
|
||||
Control-R as appropriate.
|
||||
To find other matching entries in the history list, type @key{C-s} or
|
||||
@key{C-r} as appropriate.
|
||||
This will search backward or forward in the history for the next
|
||||
entry matching the search string typed so far.
|
||||
Any other key sequence bound to a readline command will terminate
|
||||
Any other key sequence bound to a Readline command will terminate
|
||||
the search and execute that command.
|
||||
For instance, a @code{newline} will terminate the search and accept
|
||||
For instance, a @key{RET} will terminate the search and accept
|
||||
the line, thereby executing the command from the history list.
|
||||
|
||||
Non-incremental searches read the entire search string before starting
|
||||
to search for matching history lines. The search string may be
|
||||
typed by the user or part of the contents of the current line.
|
||||
typed by the user or be part of the contents of the current line.
|
||||
|
||||
@node Readline Init File
|
||||
@section Readline Init File
|
||||
@cindex initialization file, readline
|
||||
|
||||
Although the Readline library comes with a set of @code{emacs}-like
|
||||
keybindings installed by default,
|
||||
it is possible that you would like to use a different set
|
||||
of keybindings. You can customize programs that use Readline by putting
|
||||
commands in an @dfn{inputrc} file in your home directory. The name of this
|
||||
keybindings installed by default, it is possible to use a different set
|
||||
of keybindings.
|
||||
Any user can customize programs that use Readline by putting
|
||||
commands in an @dfn{inputrc} file in his home directory.
|
||||
The name of this
|
||||
@ifset BashFeatures
|
||||
file is taken from the value of the shell variable @code{INPUTRC}. If
|
||||
@end ifset
|
||||
|
|
@ -314,16 +314,18 @@ denote variable settings and key bindings.
|
|||
|
||||
@table @asis
|
||||
@item Variable Settings
|
||||
You can change the state of a few variables in Readline by
|
||||
using the @code{set} command within the init file. Here is how you
|
||||
would specify that you wish to use @code{vi} line editing commands:
|
||||
You can modify the run-time behavior of Readline by
|
||||
altering the values of variables in Readline
|
||||
using the @code{set} command within the init file. Here is how to
|
||||
change from the default Emacs-like key binding to use
|
||||
@code{vi} line editing commands:
|
||||
|
||||
@example
|
||||
set editing-mode vi
|
||||
@end example
|
||||
|
||||
Right now, there are only a few variables which can be set;
|
||||
so few, in fact, that we just list them here:
|
||||
A great deal of run-time behavior is changeable with the following
|
||||
variables.
|
||||
|
||||
@table @code
|
||||
|
||||
|
|
@ -341,6 +343,11 @@ The string to insert at the beginning of the line when the
|
|||
@code{insert-comment} command is executed. The default value
|
||||
is @code{"#"}.
|
||||
|
||||
@item completion-ignore-case
|
||||
If set to @samp{on}, Readline performs filename matching and completion
|
||||
in a case-insensitive fashion.
|
||||
The default value is @samp{off}.
|
||||
|
||||
@item completion-query-items
|
||||
@vindex completion-query-items
|
||||
The number of possible completions that determines when the user is
|
||||
|
|
@ -353,26 +360,26 @@ them; otherwise, they are simply listed. The default limit is
|
|||
@item convert-meta
|
||||
@vindex convert-meta
|
||||
If set to @samp{on}, Readline will convert characters with the
|
||||
eigth bit set to an ASCII key sequence by stripping the eigth
|
||||
eighth bit set to an ASCII key sequence by stripping the eighth
|
||||
bit and prepending an @key{ESC} character, converting them to a
|
||||
meta-prefixed key sequence. The default value is @samp{on}.
|
||||
|
||||
@item disable-completion
|
||||
@vindex disable-completion
|
||||
If set to @samp{On}, readline will inhibit word completion.
|
||||
If set to @samp{On}, Readline will inhibit word completion.
|
||||
Completion characters will be inserted into the line as if they had
|
||||
been mapped to @code{self-insert}. The default is @samp{off}.
|
||||
|
||||
@item editing-mode
|
||||
@vindex editing-mode
|
||||
The @code{editing-mode} variable controls which editing mode you are
|
||||
using. By default, Readline starts up in Emacs editing mode, where
|
||||
the keystrokes are most similar to Emacs. This variable can be
|
||||
The @code{editing-mode} variable controls which default set of
|
||||
key bindings is used. By default, Readline starts up in Emacs editing
|
||||
mode, where the keystrokes are most similar to Emacs. This variable can be
|
||||
set to either @samp{emacs} or @samp{vi}.
|
||||
|
||||
@item enable-keypad
|
||||
@vindex enable-keypad
|
||||
When set to @samp{on}, readline will try to enable the application
|
||||
When set to @samp{on}, Readline will try to enable the application
|
||||
keypad when it is called. Some systems need this to enable the
|
||||
arrow keys. The default is @samp{off}.
|
||||
|
||||
|
|
@ -384,7 +391,7 @@ attempts word completion. The default is @samp{off}.
|
|||
@item horizontal-scroll-mode
|
||||
@vindex horizontal-scroll-mode
|
||||
This variable can be set to either @samp{on} or @samp{off}. Setting it
|
||||
to @samp{on} means that the text of the lines that you edit will scroll
|
||||
to @samp{on} means that the text of the lines being edited will scroll
|
||||
horizontally on a single screen line when they are longer than the width
|
||||
of the screen, instead of wrapping onto a new screen line. By default,
|
||||
this variable is set to @samp{off}.
|
||||
|
|
@ -411,8 +418,8 @@ appended. The default is @samp{on}.
|
|||
|
||||
@item mark-modified-lines
|
||||
@vindex mark-modified-lines
|
||||
This variable, when set to @samp{on}, says to display an asterisk
|
||||
(@samp{*}) at the start of history lines which have been modified.
|
||||
This variable, when set to @samp{on}, causes Readline to display an
|
||||
asterisk (@samp{*}) at the start of history lines which have been modified.
|
||||
This variable is @samp{off} by default.
|
||||
|
||||
@item input-meta
|
||||
|
|
@ -430,6 +437,11 @@ If set to @samp{on}, Readline will display characters with the
|
|||
eighth bit set directly rather than as a meta-prefixed escape
|
||||
sequence. The default is @samp{off}.
|
||||
|
||||
@item print-completions-horizontally
|
||||
If set to @samp{on}, Readline will display completions with matches
|
||||
sorted horizontally in alphabetical order, rather than down the screen.
|
||||
The default is @samp{off}.
|
||||
|
||||
@item show-all-if-ambiguous
|
||||
@vindex show-all-if-ambiguous
|
||||
This alters the default behavior of the completion functions. If
|
||||
|
|
@ -449,9 +461,9 @@ completions. The default is @samp{off}.
|
|||
@item Key Bindings
|
||||
The syntax for controlling key bindings in the init file is
|
||||
simple. First you have to know the name of the command that you
|
||||
want to change. The following pages contain tables of the command name,
|
||||
the default keybinding, and a short description of what the command
|
||||
does.
|
||||
want to change. The following sections contain tables of the command
|
||||
name, the default keybinding, if any, and a short description of what
|
||||
the command does.
|
||||
|
||||
Once you know the name of the command, simply place the name of the key
|
||||
you wish to bind the command to, a colon, and then the name of the
|
||||
|
|
@ -468,8 +480,8 @@ Meta-Rubout: backward-kill-word
|
|||
Control-o: "> output"
|
||||
@end example
|
||||
|
||||
In the above example, @samp{C-u} is bound to the function
|
||||
@code{universal-argument}, and @samp{C-o} is bound to run the macro
|
||||
In the above example, @key{C-u} is bound to the function
|
||||
@code{universal-argument}, and @key{C-o} is bound to run the macro
|
||||
expressed on the right hand side (that is, to insert the text
|
||||
@samp{> output} into the line).
|
||||
|
||||
|
|
@ -486,12 +498,16 @@ special character names are not recognized.
|
|||
"\e[11~": "Function Key 1"
|
||||
@end example
|
||||
|
||||
In the above example, @samp{C-u} is bound to the function
|
||||
In the above example, @key{C-u} is bound to the function
|
||||
@code{universal-argument} (just as it was in the first example),
|
||||
@samp{C-x C-r} is bound to the function @code{re-read-init-file}, and
|
||||
@samp{ESC [ 1 1 ~} is bound to insert the text @samp{Function Key 1}.
|
||||
The following escape sequences are available when specifying key
|
||||
sequences:
|
||||
@samp{@key{C-x} @key{C-r}} is bound to the function @code{re-read-init-file},
|
||||
and @samp{@key{ESC} @key{[} @key{1} @key{1} @key{~}} is bound to insert
|
||||
the text @samp{Function Key 1}.
|
||||
|
||||
@end table
|
||||
|
||||
The following GNU Emacs style escape sequences are available when
|
||||
specifying key sequences:
|
||||
|
||||
@table @code
|
||||
@item @kbd{\C-}
|
||||
|
|
@ -508,18 +524,46 @@ backslash
|
|||
@key{'}
|
||||
@end table
|
||||
|
||||
When entering the text of a macro, single or double quotes should
|
||||
be used to indicate a macro definition. Unquoted text
|
||||
is assumed to be a function name. Backslash
|
||||
will quote any character in the macro text, including @samp{"}
|
||||
and @samp{'}.
|
||||
In addition to the GNU Emacs style escape sequences, a second
|
||||
set of backslash escapes is available:
|
||||
|
||||
@table @code
|
||||
@item \a
|
||||
alert (bell)
|
||||
@item \b
|
||||
backspace
|
||||
@item \d
|
||||
delete
|
||||
@item \f
|
||||
form feed
|
||||
@item \n
|
||||
newline
|
||||
@item \r
|
||||
carriage return
|
||||
@item \t
|
||||
horizontal tab
|
||||
@item \v
|
||||
vertical tab
|
||||
@item \@var{nnn}
|
||||
the character whose ASCII code is the octal value @var{nnn}
|
||||
(one to three digits)
|
||||
@item \x@var{nnn}
|
||||
the character whose ASCII code is the hexadecimal value @var{nnn}
|
||||
(one to three digits)
|
||||
@end table
|
||||
|
||||
When entering the text of a macro, single or double quotes must
|
||||
be used to indicate a macro definition.
|
||||
Unquoted text is assumed to be a function name.
|
||||
In the macro body, the backslash escapes described above are expanded.
|
||||
Backslash will quote any other character in the macro text,
|
||||
including @samp{"} and @samp{'}.
|
||||
For example, the following binding will make @samp{C-x \}
|
||||
insert a single @samp{\} into the line:
|
||||
@example
|
||||
"\C-x\\": "\\"
|
||||
@end example
|
||||
|
||||
@end table
|
||||
@end table
|
||||
|
||||
@node Conditional Init Constructs
|
||||
|
|
@ -528,7 +572,7 @@ insert a single @samp{\} into the line:
|
|||
Readline implements a facility similar in spirit to the conditional
|
||||
compilation features of the C preprocessor which allows key
|
||||
bindings and variable settings to be performed as the result
|
||||
of tests. There are three parser directives used.
|
||||
of tests. There are four parser directives used.
|
||||
|
||||
@table @code
|
||||
@item $if
|
||||
|
|
@ -550,8 +594,8 @@ Readline is starting out in @code{emacs} mode.
|
|||
The @code{term=} form may be used to include terminal-specific
|
||||
key bindings, perhaps to bind the key sequences output by the
|
||||
terminal's function keys. The word on the right side of the
|
||||
@samp{=} is tested against the full name of the terminal and the
|
||||
portion of the terminal name before the first @samp{-}. This
|
||||
@samp{=} is tested against both the full name of the terminal and
|
||||
the portion of the terminal name before the first @samp{-}. This
|
||||
allows @code{sun} to match both @code{sun} and @code{sun-cmd},
|
||||
for instance.
|
||||
|
||||
|
|
@ -571,12 +615,19 @@ $endif
|
|||
@end table
|
||||
|
||||
@item $endif
|
||||
This command, as you saw in the previous example, terminates an
|
||||
This command, as seen in the previous example, terminates an
|
||||
@code{$if} command.
|
||||
|
||||
@item $else
|
||||
Commands in this branch of the @code{$if} directive are executed if
|
||||
the test fails.
|
||||
|
||||
@item $include
|
||||
This directive takes a single filename as an argument and reads commands
|
||||
and bindings from that file.
|
||||
@example
|
||||
$include /etc/inputrc
|
||||
@end example
|
||||
@end table
|
||||
|
||||
@node Sample Init File
|
||||
|
|
@ -593,6 +644,11 @@ binding, variable assignment, and conditional syntax.
|
|||
#
|
||||
# You can re-read the inputrc file with C-x C-r.
|
||||
# Lines beginning with '#' are comments.
|
||||
#
|
||||
# First, include any systemwide bindings and variable assignments from
|
||||
# /etc/Inputrc
|
||||
$include /etc/Inputrc
|
||||
|
||||
#
|
||||
# Set various bindings for emacs mode.
|
||||
|
||||
|
|
@ -738,8 +794,9 @@ Refresh the current line. By default, this is unbound.
|
|||
@ifset BashFeatures
|
||||
Accept the line regardless of where the cursor is. If this line is
|
||||
non-empty, add it to the history list according to the setting of
|
||||
the @code{HISTCONTROL} variable. If this line was a history
|
||||
line, then restore the history line to its original state.
|
||||
the @code{HISTCONTROL} and @code{HISTIGNORE} variables.
|
||||
If this line was a history line, then restore the history line to its
|
||||
original state.
|
||||
@end ifset
|
||||
@ifclear BashFeatures
|
||||
Accept the line regardless of where the cursor is. If this line is
|
||||
|
|
@ -757,7 +814,8 @@ Move `down' through the history list.
|
|||
Move to the first line in the history.
|
||||
|
||||
@item end-of-history (M->)
|
||||
Move to the end of the input history, i.e., the line you are entering.
|
||||
Move to the end of the input history, i.e., the line currently
|
||||
being entered.
|
||||
|
||||
@item reverse-search-history (C-r)
|
||||
Search backward starting at the current line and moving `up' through
|
||||
|
|
@ -780,7 +838,7 @@ for a string supplied by the user.
|
|||
@item history-search-forward ()
|
||||
Search forward through the history for the string of characters
|
||||
between the start of the current line and the current cursor
|
||||
position (the `point'). This is a non-incremental search. By
|
||||
position (the @var{point}). This is a non-incremental search. By
|
||||
default, this command is unbound.
|
||||
|
||||
@item history-search-backward ()
|
||||
|
|
@ -799,6 +857,8 @@ inserts the @var{n}th word from the end of the previous command.
|
|||
Insert last argument to the previous command (the last word of the
|
||||
previous history entry). With an
|
||||
argument, behave exactly like @code{yank-nth-arg}.
|
||||
Successive calls to @code{yank-last-arg} move back through the history
|
||||
list, inserting the last argument of each line in turn.
|
||||
|
||||
@end ftable
|
||||
|
||||
|
|
@ -809,18 +869,21 @@ argument, behave exactly like @code{yank-nth-arg}.
|
|||
@item delete-char (C-d)
|
||||
Delete the character under the cursor. If the cursor is at the
|
||||
beginning of the line, there are no characters in the line, and
|
||||
the last character typed was not @kbd{C-d}, then return @code{EOF}.
|
||||
the last character typed was not bound to @code{delete-char}, then
|
||||
return @code{EOF}.
|
||||
|
||||
@item backward-delete-char (Rubout)
|
||||
Delete the character behind the cursor. A numeric arg says to kill
|
||||
the characters instead of deleting them.
|
||||
Delete the character behind the cursor. A numeric argument means
|
||||
to kill the characters instead of deleting them.
|
||||
|
||||
@item quoted-insert (C-q, C-v)
|
||||
Add the next character that you type to the line verbatim. This is
|
||||
Add the next character typed to the line verbatim. This is
|
||||
how to insert key sequences like @key{C-q}, for example.
|
||||
|
||||
@ifclear BashFeatures
|
||||
@item tab-insert (M-TAB)
|
||||
Insert a tab character.
|
||||
@end ifclear
|
||||
|
||||
@item self-insert (a, b, A, 1, !, ...)
|
||||
Insert yourself.
|
||||
|
|
@ -831,7 +894,7 @@ the character at the cursor, moving the
|
|||
cursor forward as well. If the insertion point
|
||||
is at the end of the line, then this
|
||||
transposes the last two characters of the line.
|
||||
Negative argumentss don't work.
|
||||
Negative arguments don't work.
|
||||
|
||||
@item transpose-words (M-t)
|
||||
Drag the word behind the cursor past the word in front of the cursor
|
||||
|
|
@ -839,15 +902,15 @@ moving the cursor over that word as well.
|
|||
|
||||
@item upcase-word (M-u)
|
||||
Uppercase the current (or following) word. With a negative argument,
|
||||
do the previous word, but do not move the cursor.
|
||||
uppercase the previous word, but do not move the cursor.
|
||||
|
||||
@item downcase-word (M-l)
|
||||
Lowercase the current (or following) word. With a negative argument,
|
||||
do the previous word, but do not move the cursor.
|
||||
lowercase the previous word, but do not move the cursor.
|
||||
|
||||
@item capitalize-word (M-c)
|
||||
Capitalize the current (or following) word. With a negative argument,
|
||||
do the previous word, but do not move the cursor.
|
||||
capitalize the previous word, but do not move the cursor.
|
||||
|
||||
@end ftable
|
||||
|
||||
|
|
@ -864,7 +927,7 @@ Kill backward to the beginning of the line.
|
|||
|
||||
@item unix-line-discard (C-u)
|
||||
Kill backward from the cursor to the beginning of the current line.
|
||||
Save the killed text on the kill-ring.
|
||||
The killed text is saved on the kill-ring.
|
||||
|
||||
@item kill-whole-line ()
|
||||
Kill all characters on the current line, no matter where the
|
||||
|
|
@ -888,19 +951,21 @@ Delete all spaces and tabs around point. By default, this is unbound.
|
|||
|
||||
@item kill-region ()
|
||||
Kill the text between the point and the @emph{mark} (saved
|
||||
cursor position. This text is referred to as the @var{region}.
|
||||
cursor position). This text is referred to as the @var{region}.
|
||||
By default, this command is unbound.
|
||||
|
||||
@item copy-region-as-kill ()
|
||||
Copy the text in the region to the kill buffer, so you can yank it
|
||||
Copy the text in the region to the kill buffer, so it can be yanked
|
||||
right away. By default, this command is unbound.
|
||||
|
||||
@item copy-backward-word ()
|
||||
Copy the word before point to the kill buffer.
|
||||
The word boundaries are the same as @code{backward-word}.
|
||||
By default, this command is unbound.
|
||||
|
||||
@item copy-forward-word ()
|
||||
Copy the word following point to the kill buffer.
|
||||
The word boundaries are the same as @code{forward-word}.
|
||||
By default, this command is unbound.
|
||||
|
||||
@item yank (C-y)
|
||||
|
|
@ -943,8 +1008,8 @@ By default, this is not bound to a key.
|
|||
Attempt to do completion on the text before the cursor. This is
|
||||
application-specific. Generally, if you are typing a filename
|
||||
argument, you can do filename completion; if you are typing a command,
|
||||
you can do command completion, if you are typing in a symbol to GDB, you
|
||||
can do symbol name completion, if you are typing in a variable to Bash,
|
||||
you can do command completion; if you are typing in a symbol to GDB, you
|
||||
can do symbol name completion; if you are typing in a variable to Bash,
|
||||
you can do variable name completion, and so on.
|
||||
@ifset BashFeatures
|
||||
Bash attempts completion treating the text as a variable (if the
|
||||
|
|
@ -961,6 +1026,19 @@ List the possible completions of the text before the cursor.
|
|||
Insert all completions of the text before point that would have
|
||||
been generated by @code{possible-completions}.
|
||||
|
||||
@item menu-complete ()
|
||||
Similar to @code{complete}, but replaces the word to be completed
|
||||
with a single match from the list of possible completions.
|
||||
Repeated execution of @code{menu-complete} steps through the list
|
||||
of possible completions, inserting each match in turn.
|
||||
At the end of the list of completions, the bell is rung and the
|
||||
original text is restored.
|
||||
An argument of @var{n} moves @var{n} positions forward in the list
|
||||
of matches; a negative argument may be used to move backward
|
||||
through the list.
|
||||
This command is intended to be bound to @code{TAB}, but is unbound
|
||||
by default.
|
||||
|
||||
@ifset BashFeatures
|
||||
@item complete-filename (M-/)
|
||||
Attempt filename completion on the text before point.
|
||||
|
|
@ -997,7 +1075,7 @@ treating it as a hostname.
|
|||
Attempt completion on the text before point, treating
|
||||
it as a command name. Command completion attempts to
|
||||
match the text against aliases, reserved words, shell
|
||||
functions, builtins, and finally executable filenames,
|
||||
functions, shell builtins, and finally executable filenames,
|
||||
in that order.
|
||||
|
||||
@item possible-command-completions (C-x !)
|
||||
|
|
@ -1052,7 +1130,7 @@ If the metafied character @var{x} is lowercase, run the command
|
|||
that is bound to the corresponding uppercase character.
|
||||
|
||||
@item prefix-meta (ESC)
|
||||
Make the next character that you type be metafied. This is for people
|
||||
Make the next character typed be metafied. This is for keyboards
|
||||
without a meta key. Typing @samp{ESC f} is equivalent to typing
|
||||
@samp{M-f}.
|
||||
|
||||
|
|
@ -1060,7 +1138,7 @@ without a meta key. Typing @samp{ESC f} is equivalent to typing
|
|||
Incremental undo, separately remembered for each line.
|
||||
|
||||
@item revert-line (M-r)
|
||||
Undo all changes made to this line. This is like typing the @code{undo}
|
||||
Undo all changes made to this line. This is like executing the @code{undo}
|
||||
command enough times to get back to the beginning.
|
||||
|
||||
@item tilde-expand (M-~)
|
||||
|
|
@ -1093,18 +1171,18 @@ This makes the current line a shell comment.
|
|||
|
||||
@item dump-functions ()
|
||||
Print all of the functions and their key bindings to the
|
||||
readline output stream. If a numeric argument is supplied,
|
||||
Readline output stream. If a numeric argument is supplied,
|
||||
the output is formatted in such a way that it can be made part
|
||||
of an @var{inputrc} file. This command is unbound by default.
|
||||
|
||||
@item dump-variables ()
|
||||
Print all of the settable variables and their values to the
|
||||
readline output stream. If a numeric argument is supplied,
|
||||
Readline output stream. If a numeric argument is supplied,
|
||||
the output is formatted in such a way that it can be made part
|
||||
of an @var{inputrc} file. This command is unbound by default.
|
||||
|
||||
@item dump-macros ()
|
||||
Print all of the readline key sequences bound to macros and the
|
||||
Print all of the Readline key sequences bound to macros and the
|
||||
strings they ouput. If a numeric argument is supplied,
|
||||
the output is formatted in such a way that it can be made part
|
||||
of an @var{inputrc} file. This command is unbound by default.
|
||||
|
|
@ -1116,24 +1194,27 @@ and the list of matching file names is inserted, replacing the word.
|
|||
|
||||
@item glob-list-expansions (C-x g)
|
||||
The list of expansions that would have been generated by
|
||||
@code{glob-expand-word}
|
||||
is inserted into the line, replacing the word before point.
|
||||
@code{glob-expand-word} is displayed, and the line is redrawn.
|
||||
|
||||
@item display-shell-version (C-x C-v)
|
||||
Display version information about the current instance of Bash.
|
||||
|
||||
@item shell-expand-line (M-C-e)
|
||||
Expand the line the way the shell does when it reads it. This
|
||||
performs alias and history expansion as well as all of the shell
|
||||
word expansions.
|
||||
Expand the line as the shell does.
|
||||
This performs alias and history expansion as well as all of the shell
|
||||
word expansions (@pxref{Shell Expansions}).
|
||||
|
||||
@item history-expand-line (M-^)
|
||||
Perform history expansion on the current line.
|
||||
|
||||
@item alias-expand-line
|
||||
@item magic-space ()
|
||||
Perform history expansion on the current line and insert a space
|
||||
(@pxref{History Interaction}).
|
||||
|
||||
@item alias-expand-line ()
|
||||
Perform alias expansion on the current line (@pxref{Aliases}).
|
||||
|
||||
@item history-and-alias-expand-line
|
||||
@item history-and-alias-expand-line ()
|
||||
Perform history and alias expansion on the current line.
|
||||
|
||||
@item insert-last-argument (M-., M-_)
|
||||
|
|
|
|||
|
|
@ -19,12 +19,16 @@
|
|||
#include "readline.h"
|
||||
#include "history.h"
|
||||
|
||||
extern HIST_ENTRY **history_list ();
|
||||
|
||||
main ()
|
||||
{
|
||||
HIST_ENTRY **history_list ();
|
||||
char *temp = (char *)NULL;
|
||||
char *prompt = "readline$ ";
|
||||
int done = 0;
|
||||
char *temp, *prompt;
|
||||
int done;
|
||||
|
||||
temp = (char *)NULL;
|
||||
prompt = "readline$ ";
|
||||
done = 0;
|
||||
|
||||
while (!done)
|
||||
{
|
||||
|
|
@ -47,18 +51,17 @@ main ()
|
|||
|
||||
if (strcmp (temp, "list") == 0)
|
||||
{
|
||||
HIST_ENTRY **list = history_list ();
|
||||
HIST_ENTRY **list;
|
||||
register int i;
|
||||
|
||||
list = history_list ();
|
||||
if (list)
|
||||
{
|
||||
for (i = 0; list[i]; i++)
|
||||
{
|
||||
fprintf (stderr, "%d: %s\r\n", i, list[i]->line);
|
||||
free (list[i]->line);
|
||||
}
|
||||
free (list);
|
||||
fprintf (stderr, "%d: %s\r\n", i, list[i]->line);
|
||||
}
|
||||
}
|
||||
free (temp);
|
||||
}
|
||||
exit (0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,11 +94,15 @@ static FUNMAP default_funmap[] = {
|
|||
{ "kill-line", rl_kill_line },
|
||||
{ "kill-region", rl_kill_region },
|
||||
{ "kill-word", rl_kill_word },
|
||||
{ "menu-complete", rl_menu_complete },
|
||||
{ "next-history", rl_get_next_history },
|
||||
{ "non-incremental-forward-search-history", rl_noninc_forward_search },
|
||||
{ "non-incremental-reverse-search-history", rl_noninc_reverse_search },
|
||||
{ "non-incremental-forward-search-history-again", rl_noninc_forward_search_again },
|
||||
{ "non-incremental-reverse-search-history-again", rl_noninc_reverse_search_again },
|
||||
#ifdef __CYGWIN32__
|
||||
{ "paste-from-clipboard", rl_paste_from_clipboard },
|
||||
#endif
|
||||
{ "possible-completions", rl_possible_completions },
|
||||
{ "previous-history", rl_get_previous_history },
|
||||
{ "quoted-insert", rl_quoted_insert },
|
||||
|
|
|
|||
|
|
@ -35,6 +35,9 @@
|
|||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# ifndef _MINIX
|
||||
# include <sys/types.h>
|
||||
# endif
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
|
|
@ -47,6 +50,9 @@
|
|||
#include "history.h"
|
||||
#include "histlib.h"
|
||||
|
||||
#define HISTORY_WORD_DELIMITERS " \t\n;&()|<>"
|
||||
#define HISTORY_QUOTE_CHARACTERS "\"'`"
|
||||
|
||||
static char error_pointer;
|
||||
|
||||
static char *subst_lhs;
|
||||
|
|
@ -823,8 +829,8 @@ history_expand (hstring, output)
|
|||
only_printing = modified = 0;
|
||||
l = strlen (hstring);
|
||||
|
||||
/* Grovel the string. Only backslash can quote the history escape
|
||||
character. We also handle arg specifiers. */
|
||||
/* Grovel the string. Only backslash and single quotes can quote the
|
||||
history escape character. We also handle arg specifiers. */
|
||||
|
||||
/* Before we grovel forever, see if the history_expansion_char appears
|
||||
anywhere within the text. */
|
||||
|
|
@ -852,7 +858,18 @@ history_expand (hstring, output)
|
|||
for (i = 0; string[i]; i++)
|
||||
{
|
||||
cc = string[i + 1];
|
||||
if (string[i] == history_expansion_char)
|
||||
/* The history_comment_char, if set, appearing that the beginning
|
||||
of a word signifies that the rest of the line should not have
|
||||
history expansion performed on it.
|
||||
Skip the rest of the line and break out of the loop. */
|
||||
if (history_comment_char && string[i] == history_comment_char &&
|
||||
(i == 0 || member (string[i - 1], HISTORY_WORD_DELIMITERS)))
|
||||
{
|
||||
while (string[i])
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
else if (string[i] == history_expansion_char)
|
||||
{
|
||||
if (!cc || member (cc, history_no_expand_chars))
|
||||
continue;
|
||||
|
|
@ -867,6 +884,8 @@ history_expand (hstring, output)
|
|||
else
|
||||
break;
|
||||
}
|
||||
/* XXX - at some point, might want to extend this to handle
|
||||
double quotes as well. */
|
||||
else if (history_quotes_inhibit_expansion && string[i] == '\'')
|
||||
{
|
||||
/* If this is bash, single quotes inhibit history expansion. */
|
||||
|
|
@ -904,6 +923,8 @@ history_expand (hstring, output)
|
|||
|
||||
if (tchar == history_expansion_char)
|
||||
tchar = -3;
|
||||
else if (tchar == history_comment_char)
|
||||
tchar = -2;
|
||||
|
||||
switch (tchar)
|
||||
{
|
||||
|
|
@ -939,6 +960,19 @@ history_expand (hstring, output)
|
|||
break;
|
||||
}
|
||||
|
||||
case -2: /* history_comment_char */
|
||||
if (i == 0 || member (string[i - 1], HISTORY_WORD_DELIMITERS))
|
||||
{
|
||||
temp = xmalloc (l - i + 1);
|
||||
strcpy (temp, string + i);
|
||||
ADD_STRING (temp);
|
||||
free (temp);
|
||||
i = l;
|
||||
}
|
||||
else
|
||||
ADD_CHAR (string[i]);
|
||||
break;
|
||||
|
||||
case -3: /* history_expansion_char */
|
||||
cc = string[i + 1];
|
||||
|
||||
|
|
@ -1238,7 +1272,7 @@ history_tokenize_internal (string, wind, indp)
|
|||
|
||||
/* Get word from string + i; */
|
||||
|
||||
if (member (string[i], "\"'`"))
|
||||
if (member (string[i], HISTORY_QUOTE_CHARACTERS))
|
||||
delimiter = string[i++];
|
||||
|
||||
for (; string[i]; i++)
|
||||
|
|
@ -1262,10 +1296,10 @@ history_tokenize_internal (string, wind, indp)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!delimiter && (member (string[i], " \t\n;&()|<>")))
|
||||
if (!delimiter && (member (string[i], HISTORY_WORD_DELIMITERS)))
|
||||
break;
|
||||
|
||||
if (!delimiter && member (string[i], "\"'`"))
|
||||
if (!delimiter && member (string[i], HISTORY_QUOTE_CHARACTERS))
|
||||
delimiter = string[i];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,9 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/file.h>
|
||||
#ifndef _MINIX
|
||||
# include <sys/file.h>
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
|
|
@ -129,19 +131,31 @@ read_history_range (filename, from, to)
|
|||
int from, to;
|
||||
{
|
||||
register int line_start, line_end;
|
||||
char *input, *buffer = (char *)NULL;
|
||||
char *input, *buffer;
|
||||
int file, current_line;
|
||||
struct stat finfo;
|
||||
size_t file_size;
|
||||
|
||||
buffer = (char *)NULL;
|
||||
input = history_filename (filename);
|
||||
file = open (input, O_RDONLY|O_BINARY, 0666);
|
||||
|
||||
if ((file < 0) || (fstat (file, &finfo) == -1))
|
||||
goto error_and_exit;
|
||||
|
||||
buffer = xmalloc ((int)finfo.st_size + 1);
|
||||
file_size = (size_t)finfo.st_size;
|
||||
|
||||
if (read (file, buffer, finfo.st_size) != finfo.st_size)
|
||||
/* check for overflow on very large files */
|
||||
if (file_size != finfo.st_size || file_size + 1 < file_size)
|
||||
{
|
||||
#if defined (EFBIG)
|
||||
errno = EFBIG;
|
||||
#endif
|
||||
goto error_and_exit;
|
||||
}
|
||||
|
||||
buffer = xmalloc (file_size + 1);
|
||||
if (read (file, buffer, file_size) != file_size)
|
||||
{
|
||||
error_and_exit:
|
||||
if (file >= 0)
|
||||
|
|
@ -157,15 +171,15 @@ read_history_range (filename, from, to)
|
|||
|
||||
/* Set TO to larger than end of file if negative. */
|
||||
if (to < 0)
|
||||
to = finfo.st_size;
|
||||
to = file_size;
|
||||
|
||||
/* Start at beginning of file, work to end. */
|
||||
line_start = line_end = current_line = 0;
|
||||
|
||||
/* Skip lines until we are at FROM. */
|
||||
while (line_start < finfo.st_size && current_line < from)
|
||||
while (line_start < file_size && current_line < from)
|
||||
{
|
||||
for (line_end = line_start; line_end < finfo.st_size; line_end++)
|
||||
for (line_end = line_start; line_end < file_size; line_end++)
|
||||
if (buffer[line_end] == '\n')
|
||||
{
|
||||
current_line++;
|
||||
|
|
@ -176,7 +190,7 @@ read_history_range (filename, from, to)
|
|||
}
|
||||
|
||||
/* If there are lines left to gobble, then gobble them now. */
|
||||
for (line_end = line_start; line_end < finfo.st_size; line_end++)
|
||||
for (line_end = line_start; line_end < file_size; line_end++)
|
||||
if (buffer[line_end] == '\n')
|
||||
{
|
||||
buffer[line_end] = '\0';
|
||||
|
|
@ -209,6 +223,7 @@ history_truncate_file (fname, lines)
|
|||
int file, chars_read;
|
||||
char *buffer, *filename;
|
||||
struct stat finfo;
|
||||
size_t file_size;
|
||||
|
||||
buffer = (char *)NULL;
|
||||
filename = history_filename (fname);
|
||||
|
|
@ -217,8 +232,20 @@ history_truncate_file (fname, lines)
|
|||
if (file == -1 || fstat (file, &finfo) == -1)
|
||||
goto truncate_exit;
|
||||
|
||||
buffer = xmalloc ((int)finfo.st_size + 1);
|
||||
chars_read = read (file, buffer, finfo.st_size);
|
||||
file_size = (size_t)finfo.st_size;
|
||||
|
||||
/* check for overflow on very large files */
|
||||
if (file_size != finfo.st_size || file_size + 1 < file_size)
|
||||
{
|
||||
close (file);
|
||||
#if defined (EFBIG)
|
||||
errno = EFBIG;
|
||||
#endif
|
||||
goto truncate_exit;
|
||||
}
|
||||
|
||||
buffer = xmalloc (file_size + 1);
|
||||
chars_read = read (file, buffer, file_size);
|
||||
close (file);
|
||||
|
||||
if (chars_read <= 0)
|
||||
|
|
@ -248,7 +275,7 @@ history_truncate_file (fname, lines)
|
|||
truncate to. */
|
||||
if (i && ((file = open (filename, O_WRONLY|O_TRUNC|O_BINARY, 0600)) != -1))
|
||||
{
|
||||
write (file, buffer + i, finfo.st_size - i);
|
||||
write (file, buffer + i, file_size - i);
|
||||
close (file);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,9 @@
|
|||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# ifdef _MINIX
|
||||
# include <sys/types.h>
|
||||
# endif
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,9 @@
|
|||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# ifdef _MINIX
|
||||
# include <sys/types.h>
|
||||
# endif
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#if defined (HAVE_STRING_H)
|
||||
|
|
|
|||
|
|
@ -262,7 +262,7 @@ rl_search_history (direction, invoking_key)
|
|||
break;
|
||||
}
|
||||
|
||||
if (c >= 0 && (CTRL_CHAR (c) || META_CHAR (c) || c == RUBOUT) && c != CTRL ('g'))
|
||||
if (c >= 0 && (CTRL_CHAR (c) || META_CHAR (c) || c == RUBOUT) && c != CTRL ('G'))
|
||||
{
|
||||
rl_execute_next (c);
|
||||
break;
|
||||
|
|
@ -298,6 +298,21 @@ rl_search_history (direction, invoking_key)
|
|||
free (lines);
|
||||
return 0;
|
||||
|
||||
#if 0
|
||||
/* delete character from search string. */
|
||||
case -3:
|
||||
if (search_string_index == 0)
|
||||
ding ();
|
||||
else
|
||||
{
|
||||
search_string[--search_string_index] = '\0';
|
||||
/* This is tricky. To do this right, we need to keep a
|
||||
stack of search positions for the current search, with
|
||||
sentinels marking the beginning and end. */
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
/* Add character to search string and continue search. */
|
||||
if (search_string_index + 2 >= search_string_size)
|
||||
|
|
|
|||
|
|
@ -39,9 +39,9 @@ typedef char **CPPFunction ();
|
|||
|
||||
/* A keymap contains one entry for each key in the ASCII set.
|
||||
Each entry consists of a type and a pointer.
|
||||
POINTER is the address of a function to run, or the
|
||||
FUNCTION is the address of a function to run, or the
|
||||
address of a keymap to indirect through.
|
||||
TYPE says which kind of thing POINTER is. */
|
||||
TYPE says which kind of thing FUNCTION is. */
|
||||
typedef struct _keymap_entry {
|
||||
char type;
|
||||
Function *function;
|
||||
|
|
|
|||
|
|
@ -495,17 +495,32 @@ rl_yank_pop (count, key)
|
|||
}
|
||||
}
|
||||
|
||||
/* Yank the COUNTth argument from the previous history line. */
|
||||
int
|
||||
rl_yank_nth_arg (count, ignore)
|
||||
int count, ignore;
|
||||
/* Yank the COUNTh argument from the previous history line, skipping
|
||||
HISTORY_SKIP lines before looking for the `previous line'. */
|
||||
static int
|
||||
rl_yank_nth_arg_internal (count, ignore, history_skip)
|
||||
int count, ignore, history_skip;
|
||||
{
|
||||
register HIST_ENTRY *entry;
|
||||
char *arg;
|
||||
int i;
|
||||
|
||||
if (history_skip)
|
||||
{
|
||||
for (i = 0; i < history_skip; i++)
|
||||
entry = previous_history ();
|
||||
}
|
||||
|
||||
entry = previous_history ();
|
||||
if (entry)
|
||||
next_history ();
|
||||
{
|
||||
if (history_skip)
|
||||
{
|
||||
for (i = 0; i < history_skip; i++)
|
||||
next_history ();
|
||||
}
|
||||
next_history ();
|
||||
}
|
||||
else
|
||||
{
|
||||
ding ();
|
||||
|
|
@ -538,6 +553,14 @@ rl_yank_nth_arg (count, ignore)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* Yank the COUNTth argument from the previous history line. */
|
||||
int
|
||||
rl_yank_nth_arg (count, ignore)
|
||||
int count, ignore;
|
||||
{
|
||||
return (rl_yank_nth_arg_internal (count, ignore, 0));
|
||||
}
|
||||
|
||||
/* Yank the last argument from the previous history line. This `knows'
|
||||
how rl_yank_nth_arg treats a count of `$'. With an argument, this
|
||||
behaves the same as rl_yank_nth_arg. */
|
||||
|
|
@ -545,8 +568,67 @@ int
|
|||
rl_yank_last_arg (count, key)
|
||||
int count, key;
|
||||
{
|
||||
if (rl_explicit_arg)
|
||||
return (rl_yank_nth_arg (count, key));
|
||||
static int history_skip = 0;
|
||||
static int explicit_arg_p = 0;
|
||||
static int count_passed = 1;
|
||||
static int direction = 1;
|
||||
|
||||
if (rl_last_func != rl_yank_last_arg)
|
||||
{
|
||||
history_skip = 0;
|
||||
explicit_arg_p = rl_explicit_arg;
|
||||
count_passed = count;
|
||||
direction = 1;
|
||||
}
|
||||
else
|
||||
return (rl_yank_nth_arg ('$', key));
|
||||
{
|
||||
rl_do_undo ();
|
||||
if (count < 1)
|
||||
direction = -direction;
|
||||
history_skip += direction;
|
||||
if (history_skip < 0)
|
||||
history_skip = 0;
|
||||
count_passed = count;
|
||||
}
|
||||
|
||||
if (explicit_arg_p)
|
||||
return (rl_yank_nth_arg_internal (count, key, history_skip));
|
||||
else
|
||||
return (rl_yank_nth_arg_internal ('$', key, history_skip));
|
||||
}
|
||||
|
||||
/* A special paste command for users of Cygnus's cygwin32. */
|
||||
#if defined (__CYGWIN32__)
|
||||
#include <windows.h>
|
||||
|
||||
int
|
||||
rl_paste_from_clipboard (count, key)
|
||||
int count, key;
|
||||
{
|
||||
char *data, *ptr;
|
||||
int len;
|
||||
|
||||
if (OpenClipboard (NULL) == 0)
|
||||
return (0);
|
||||
|
||||
data = (char *)GetClipboardData (CF_TEXT);
|
||||
if (data)
|
||||
{
|
||||
ptr = strchr (data, '\r');
|
||||
if (ptr)
|
||||
{
|
||||
len = ptr - data;
|
||||
ptr = xmalloc (len + 1);
|
||||
ptr[len] = '\0';
|
||||
strncpy (ptr, data, len);
|
||||
}
|
||||
else
|
||||
ptr = data;
|
||||
rl_insert_text (ptr);
|
||||
if (ptr != data)
|
||||
free (ptr);
|
||||
CloseClipboard ();
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
#endif /* __CYGWIN32__ */
|
||||
|
|
|
|||
|
|
@ -69,7 +69,8 @@ static char *legal_lang_values[] =
|
|||
"iso88598",
|
||||
"iso88599",
|
||||
"iso885910",
|
||||
"koi8r",
|
||||
"koi8r",
|
||||
"koi8-r",
|
||||
0
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ rl_insert_close (count, invoking_key)
|
|||
|
||||
FD_ZERO (&readfds);
|
||||
FD_SET (fileno (rl_instream), &readfds);
|
||||
timer.tv_sec = 1;
|
||||
timer.tv_sec = 0;
|
||||
timer.tv_usec = 500;
|
||||
|
||||
orig_point = rl_point;
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@
|
|||
#include "history.h"
|
||||
|
||||
#ifndef RL_LIBRARY_VERSION
|
||||
# define RL_LIBRARY_VERSION "2.1-bash"
|
||||
# define RL_LIBRARY_VERSION "2.2-bash"
|
||||
#endif
|
||||
|
||||
/* Evaluates its arguments multiple times. */
|
||||
|
|
@ -78,7 +78,11 @@
|
|||
/* Variables and functions imported from terminal.c */
|
||||
extern int _rl_init_terminal_io ();
|
||||
extern void _rl_enable_meta_key ();
|
||||
#ifdef _MINIX
|
||||
extern void _rl_output_character_function ();
|
||||
#else
|
||||
extern int _rl_output_character_function ();
|
||||
#endif
|
||||
extern void _rl_get_screen_size ();
|
||||
|
||||
extern int _rl_enable_meta;
|
||||
|
|
@ -1027,6 +1031,18 @@ _rl_fix_point (fix_mark_too)
|
|||
}
|
||||
#undef _RL_FIX_POINT
|
||||
|
||||
void
|
||||
_rl_replace_text (text, start, end)
|
||||
char *text;
|
||||
int start, end;
|
||||
{
|
||||
rl_begin_undo_group ();
|
||||
rl_delete_text (start, end + 1);
|
||||
rl_point = start;
|
||||
rl_insert_text (text);
|
||||
rl_end_undo_group ();
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Readline character functions */
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ extern int
|
|||
rl_forward_word (), rl_tab_insert (), rl_yank_pop (), rl_yank_nth_arg (),
|
||||
rl_backward_kill_word (), rl_backward_kill_line (), rl_transpose_words (),
|
||||
rl_complete (), rl_possible_completions (), rl_insert_completions (),
|
||||
rl_menu_complete (),
|
||||
rl_do_lowercase_version (), rl_kill_full_line (),
|
||||
rl_digit_argument (), rl_universal_argument (), rl_abort (),
|
||||
rl_undo_command (), rl_revert_line (), rl_beginning_of_history (),
|
||||
|
|
@ -93,13 +94,19 @@ extern void rl_callback_handler_install ();
|
|||
extern void rl_callback_read_char ();
|
||||
extern void rl_callback_handler_remove ();
|
||||
|
||||
/* Not available unless __CYGWIN32__ is defined. */
|
||||
#ifdef __CYGWIN32__
|
||||
extern int rl_paste_from_clipboard ();
|
||||
#endif
|
||||
|
||||
/* These are *both* defined even when VI_MODE is not. */
|
||||
extern int rl_vi_editing_mode (), rl_emacs_editing_mode ();
|
||||
|
||||
/* Non incremental history searching. */
|
||||
extern int
|
||||
rl_noninc_forward_search (), rl_noninc_reverse_search (),
|
||||
rl_noninc_forward_search_again (), rl_noninc_reverse_search_again ();
|
||||
extern int rl_noninc_forward_search ();
|
||||
extern int rl_noninc_reverse_search ();
|
||||
extern int rl_noninc_forward_search_again ();
|
||||
extern int rl_noninc_reverse_search_again ();
|
||||
|
||||
/* Things for vi mode. Not available unless readline is compiled -DVI_MODE. */
|
||||
extern int rl_vi_check ();
|
||||
|
|
@ -153,6 +160,7 @@ extern char *rl_get_keymap_name ();
|
|||
|
||||
extern int rl_bind_key (), rl_bind_key_in_map ();
|
||||
extern int rl_unbind_key (), rl_unbind_key_in_map ();
|
||||
extern int rl_unbind_function_in_map (), rl_unbind_command_in_map ();
|
||||
extern int rl_set_key ();
|
||||
extern int rl_generic_bind ();
|
||||
extern int rl_parse_and_bind ();
|
||||
|
|
|
|||
|
|
@ -42,17 +42,7 @@
|
|||
# include <sgtty.h>
|
||||
#endif
|
||||
|
||||
/* Stuff for `struct winsize' on various systems. */
|
||||
#if defined (HAVE_SYS_STREAM_H)
|
||||
# include <sys/stream.h>
|
||||
#endif /* HAVE_SYS_STREAM_H */
|
||||
#if defined (HAVE_SYS_PTEM_H)
|
||||
# include <sys/ptem.h>
|
||||
# define _IO_PTEM_H /* work around SVR4.2 1.1.4 bug */
|
||||
#endif /* HAVE_SYS_PTEM_H */
|
||||
#if defined (HAVE_SYS_PTE_H)
|
||||
# include <sys/pte.h>
|
||||
#endif /* HAVE_SYS_PTE_H */
|
||||
#include "rlwinsize.h"
|
||||
|
||||
/* Define _POSIX_VDISABLE if we are not using the `new' tty driver and
|
||||
it is not already defined. It is used both to determine if a
|
||||
|
|
|
|||
58
lib/readline/rlwinsize.h
Normal file
58
lib/readline/rlwinsize.h
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
/* rlwinsize.h -- an attempt to isolate some of the system-specific defines
|
||||
for `struct winsize' and TIOCGWINSZ. */
|
||||
|
||||
/* Copyright (C) 1997 Free Software Foundation, Inc.
|
||||
|
||||
This file contains the Readline Library (the Library), a set of
|
||||
routines for providing Emacs style line input to programs that ask
|
||||
for it.
|
||||
|
||||
The Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 1, or (at your option)
|
||||
any later version.
|
||||
|
||||
The Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
#if !defined (_RLWINSIZE_H_)
|
||||
#define _RLWINSIZE_H_
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
/* Try to find the definitions of `struct winsize' and TIOGCWINSZ */
|
||||
|
||||
#if defined (GWINSZ_IN_SYS_IOCTL) && !defined (TIOCGWINSZ)
|
||||
# include <sys/ioctl.h>
|
||||
#endif /* GWINSZ_IN_SYS_IOCTL && !TIOCGWINSZ */
|
||||
|
||||
#if defined (STRUCT_WINSIZE_IN_TERMIOS) && !defined (STRUCT_WINSIZE_IN_SYS_IOCTL)
|
||||
# include <termios.h>
|
||||
#endif /* STRUCT_WINSIZE_IN_TERMIOS && !STRUCT_WINSIZE_IN_SYS_IOCTL */
|
||||
|
||||
/* Not in either of the standard places, look around. */
|
||||
#if !defined (STRUCT_WINSIZE_IN_TERMIOS) && !defined (STRUCT_WINSIZE_IN_SYS_IOCTL)
|
||||
# if defined (HAVE_SYS_STREAM_H)
|
||||
# include <sys/stream.h>
|
||||
# endif /* HAVE_SYS_STREAM_H */
|
||||
# if defined (HAVE_SYS_PTEM_H) /* SVR4.2, at least, has it here */
|
||||
# include <sys/ptem.h>
|
||||
# define _IO_PTEM_H /* work around SVR4.2 1.1.4 bug */
|
||||
# endif /* HAVE_SYS_PTEM_H */
|
||||
# if defined (HAVE_SYS_PTE_H) /* ??? */
|
||||
# include <sys/pte.h>
|
||||
# endif /* HAVE_SYS_PTE_H */
|
||||
#endif /* !STRUCT_WINSIZE_IN_TERMIOS && !STRUCT_WINSIZE_IN_SYS_IOCTL */
|
||||
|
||||
#endif /* _RL_WINSIZE_H */
|
||||
|
||||
|
||||
|
|
@ -27,6 +27,9 @@
|
|||
#endif
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# ifdef _MINIX
|
||||
# include <sys/types.h>
|
||||
# endif
|
||||
# include <unistd.h>
|
||||
#endif /* HAVE_UNISTD_H */
|
||||
|
||||
|
|
@ -36,6 +39,12 @@
|
|||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
#if defined (HAVE_STRING_H)
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif /* !HAVE_STRING_H */
|
||||
|
||||
extern char *xmalloc (), *xrealloc ();
|
||||
|
||||
#if !defined (SHELL)
|
||||
|
|
|
|||
|
|
@ -434,13 +434,21 @@ rl_reset_terminal (terminal_name)
|
|||
}
|
||||
|
||||
/* A function for the use of tputs () */
|
||||
#ifdef _MINIX
|
||||
void
|
||||
_rl_output_character_function (c)
|
||||
int c;
|
||||
{
|
||||
putc (c, _rl_out_stream);
|
||||
}
|
||||
#else /* !_MINIX */
|
||||
int
|
||||
_rl_output_character_function (c)
|
||||
int c;
|
||||
{
|
||||
return putc (c, _rl_out_stream);
|
||||
}
|
||||
|
||||
#endif /* !_MINIX */
|
||||
/* Write COUNT characters from STRING to the output stream. */
|
||||
void
|
||||
_rl_output_some_chars (string, count)
|
||||
|
|
@ -519,18 +527,11 @@ ding ()
|
|||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
static int
|
||||
outchar (c)
|
||||
int c;
|
||||
{
|
||||
return putc (c, rl_outstream);
|
||||
}
|
||||
|
||||
void
|
||||
_rl_enable_meta_key ()
|
||||
{
|
||||
if (term_has_meta && term_mm)
|
||||
tputs (term_mm, 1, outchar);
|
||||
tputs (term_mm, 1, _rl_output_character_function);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -538,7 +539,7 @@ _rl_control_keypad (on)
|
|||
int on;
|
||||
{
|
||||
if (on && term_ks)
|
||||
tputs (term_ks, 1, outchar);
|
||||
tputs (term_ks, 1, _rl_output_character_function);
|
||||
else if (!on && term_ke)
|
||||
tputs (term_ke, 1, outchar);
|
||||
tputs (term_ke, 1, _rl_output_character_function);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,9 @@
|
|||
#endif
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# ifdef _MINIX
|
||||
# include <sys/types.h>
|
||||
# endif
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -166,6 +166,58 @@ rl_extend_line_buffer (len)
|
|||
_rl_set_the_line ();
|
||||
}
|
||||
|
||||
|
||||
/* A function for simple tilde expansion. */
|
||||
int
|
||||
rl_tilde_expand (ignore, key)
|
||||
int ignore, key;
|
||||
{
|
||||
register int start, end;
|
||||
char *homedir, *temp;
|
||||
int len;
|
||||
|
||||
end = rl_point;
|
||||
start = end - 1;
|
||||
|
||||
if (rl_point == rl_end && rl_line_buffer[rl_point] == '~')
|
||||
{
|
||||
homedir = tilde_expand ("~");
|
||||
_rl_replace_text (homedir, start, end);
|
||||
return (0);
|
||||
}
|
||||
else if (rl_line_buffer[start] != '~')
|
||||
{
|
||||
for (; !whitespace (rl_line_buffer[start]) && start >= 0; start--)
|
||||
;
|
||||
start++;
|
||||
}
|
||||
|
||||
end = start;
|
||||
do
|
||||
end++;
|
||||
while (whitespace (rl_line_buffer[end]) == 0 && end < rl_end);
|
||||
|
||||
if (whitespace (rl_line_buffer[end]) || end >= rl_end)
|
||||
end--;
|
||||
|
||||
/* If the first character of the current word is a tilde, perform
|
||||
tilde expansion and insert the result. If not a tilde, do
|
||||
nothing. */
|
||||
if (rl_line_buffer[start] == '~')
|
||||
{
|
||||
len = end - start + 1;
|
||||
temp = xmalloc (len + 1);
|
||||
strncpy (temp, rl_line_buffer + start, len);
|
||||
temp[len] = '\0';
|
||||
homedir = tilde_expand (temp);
|
||||
free (temp);
|
||||
|
||||
_rl_replace_text (homedir, start, end);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* String Utility Functions */
|
||||
|
|
@ -300,3 +352,13 @@ _rl_digit_value (c)
|
|||
{
|
||||
return (isdigit (c) ? c - '0' : c);
|
||||
}
|
||||
|
||||
/* Backwards compatibility, now that savestring has been removed from
|
||||
all `public' readline header files. */
|
||||
#undef _rl_savestring
|
||||
char *
|
||||
_rl_savestring (s)
|
||||
char *s;
|
||||
{
|
||||
return ((char *)strcpy (xmalloc (1 + (int)strlen (s)), (s)));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -615,6 +615,13 @@ _rl_vi_save_insert (up)
|
|||
{
|
||||
int len, start, end;
|
||||
|
||||
if (up == 0)
|
||||
{
|
||||
if (vi_insert_buffer_size >= 1)
|
||||
vi_insert_buffer[0] = '\0';
|
||||
return;
|
||||
}
|
||||
|
||||
start = up->start;
|
||||
end = up->end;
|
||||
len = end - start + 1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue