mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-08-05 01:32:28 +02:00
Bash-5.3-alpha release
This commit is contained in:
@@ -12,7 +12,7 @@ This document describes the GNU History library
|
||||
a programming tool that provides a consistent user interface for
|
||||
recalling lines of previously typed input.
|
||||
|
||||
Copyright @copyright{} 1988--2022 Free Software Foundation, Inc.
|
||||
Copyright @copyright{} 1988--2023 Free Software Foundation, Inc.
|
||||
|
||||
@quotation
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
@ignore
|
||||
This file documents the user interface to the GNU History library.
|
||||
|
||||
Copyright (C) 1988-2022 Free Software Foundation, Inc.
|
||||
Copyright (C) 1988-2023 Free Software Foundation, Inc.
|
||||
Authored by Brian Fox and Chet Ramey.
|
||||
|
||||
Permission is granted to make and distribute verbatim copies of this manual
|
||||
@@ -369,7 +369,7 @@ Returns 0 on success, or @code{errno} on failure.
|
||||
|
||||
These functions implement history expansion.
|
||||
|
||||
@deftypefun int history_expand (char *string, char **output)
|
||||
@deftypefun int history_expand (const char *string, char **output)
|
||||
Expand @var{string}, placing the result into @var{output}, a pointer
|
||||
to a string (@pxref{History Interaction}). Returns:
|
||||
@table @code
|
||||
@@ -517,9 +517,8 @@ The following program demonstrates simple use of the @sc{gnu} History Library.
|
||||
#include <stdio.h>
|
||||
#include <readline/history.h>
|
||||
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
@{
|
||||
char line[1024], *t;
|
||||
int len, done = 0;
|
||||
|
||||
@@ -90,8 +90,8 @@ named by @env{$HISTFILE}.
|
||||
If the @code{histappend} shell option is set (@pxref{Bash Builtins}),
|
||||
the lines are appended to the history file,
|
||||
otherwise the history file is overwritten.
|
||||
If @env{HISTFILE}
|
||||
is unset, or if the history file is unwritable, the history is not saved.
|
||||
If @env{HISTFILE} is unset or null,
|
||||
or if the history file is unwritable, the history is not saved.
|
||||
After saving the history, the history file is truncated
|
||||
to contain no more than @env{$HISTFILESIZE} lines.
|
||||
If @env{HISTFILESIZE} is unset, or set to null, a non-numeric value, or
|
||||
@@ -104,7 +104,7 @@ When the history file is read, lines beginning with the history
|
||||
comment character followed immediately by a digit are interpreted
|
||||
as timestamps for the following history entry.
|
||||
|
||||
The builtin command @code{fc} may be used to list or edit and re-execute
|
||||
The @code{fc} builtin command may be used to list or edit and re-execute
|
||||
a portion of the history list.
|
||||
The @code{history} builtin may be used to display or modify the history
|
||||
list and manipulate the history file.
|
||||
@@ -113,8 +113,9 @@ are available in each editing mode that provide access to the
|
||||
history list (@pxref{Commands For History}).
|
||||
|
||||
The shell allows control over which commands are saved on the history
|
||||
list. The @env{HISTCONTROL} and @env{HISTIGNORE}
|
||||
variables may be set to cause the shell to save only a subset of the
|
||||
list.
|
||||
The @env{HISTCONTROL} and @env{HISTIGNORE}
|
||||
variables are used to cause the shell to save only a subset of the
|
||||
commands entered.
|
||||
The @code{cmdhist}
|
||||
shell option, if enabled, causes the shell to attempt to save each
|
||||
@@ -192,7 +193,7 @@ With no options, display the history list with line numbers.
|
||||
Lines prefixed with a @samp{*} have been modified.
|
||||
An argument of @var{n} lists only the last @var{n} lines.
|
||||
If the shell variable @env{HISTTIMEFORMAT} is set and not null,
|
||||
it is used as a format string for @var{strftime} to display
|
||||
it is used as a format string for @code{strftime}(3) to display
|
||||
the time stamp associated with each displayed history entry.
|
||||
No intervening blank is printed between the formatted time stamp
|
||||
and the history line.
|
||||
@@ -250,6 +251,7 @@ If a @var{filename} argument is supplied
|
||||
when any of the @option{-w}, @option{-r}, @option{-a}, or @option{-n} options
|
||||
is used, Bash uses @var{filename} as the history file.
|
||||
If not, then the value of the @env{HISTFILE} variable is used.
|
||||
If @env{HISTFILE} is unset or null, these options have no effect.
|
||||
|
||||
The return value is 0 unless an invalid option is encountered, an
|
||||
error occurs while reading or writing the history file, an invalid
|
||||
@@ -282,14 +284,21 @@ expansion functions about quoting still in effect from previous lines.
|
||||
History expansion takes place in two parts. The first is to determine
|
||||
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 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
|
||||
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}.
|
||||
The line is broken into words in the same fashion
|
||||
that Bash does, so that several words
|
||||
surrounded by quotes are considered one word.
|
||||
The @dfn{event designator} selects the event, the optional
|
||||
@dfn{word designator} selects words from the event, and
|
||||
various optional @dfn{modifiers} are available to manipulate the
|
||||
selected words.
|
||||
|
||||
History expansions are introduced by the appearance of the
|
||||
history expansion character, which is @samp{!} by default.
|
||||
History expansions may appear anywhere in the input, but do not nest.
|
||||
|
||||
History expansion implements shell-like quoting conventions:
|
||||
a backslash can be used to remove the special handling for the next character;
|
||||
@@ -307,6 +316,16 @@ also treated as quoted if it immediately precedes the closing double quote
|
||||
in a double-quoted string.
|
||||
@end ifset
|
||||
|
||||
There is a special abbreviation for substitution, active when the
|
||||
@var{quick substitution} character (default @samp{^})
|
||||
is the first character on the line.
|
||||
It selects the previous history list entry, using an event designator
|
||||
equivalent to @code{!!},
|
||||
and substitutes one string for another in that line.
|
||||
It is described below (@pxref{Event Designators}).
|
||||
This is the only history expansion that does not begin with the history
|
||||
expansion character.
|
||||
|
||||
@ifset BashFeatures
|
||||
Several shell options settable with the @code{shopt}
|
||||
builtin (@pxref{The Shopt Builtin}) may be used to tailor
|
||||
@@ -347,6 +366,9 @@ An event designator is a reference to a command line entry in the
|
||||
history list.
|
||||
Unless the reference is absolute, events are relative to the current
|
||||
position in the history list.
|
||||
The event designator consists of the portion of the word beginning
|
||||
with the history expansion character, and ending with the word designator
|
||||
if one is present, or the end of the word.
|
||||
@cindex history events
|
||||
|
||||
@table @asis
|
||||
@@ -354,8 +376,9 @@ position in the history list.
|
||||
@item @code{!}
|
||||
@ifset BashFeatures
|
||||
Start a history substitution, except when followed by a space, tab,
|
||||
the end of the line, @samp{=} or @samp{(} (when the
|
||||
@code{extglob} shell option is enabled using the @code{shopt} builtin).
|
||||
the end of the line, @samp{=},
|
||||
or the rest of the shell metacharacters defined above
|
||||
(@pxref{Definitions}).
|
||||
@end ifset
|
||||
@ifclear BashFeatures
|
||||
Start a history substitution, except when followed by a space, tab,
|
||||
@@ -400,6 +423,8 @@ The entire command line typed so far.
|
||||
@subsection Word Designators
|
||||
|
||||
Word designators are used to select desired words from the event.
|
||||
They are optional; if the word designator isn't supplied, the history
|
||||
expansion uses the entire event.
|
||||
A @samp{:} separates the event specification from the word designator. It
|
||||
may be omitted if the word designator begins with a @samp{^}, @samp{$},
|
||||
@samp{*}, @samp{-}, or @samp{%}. Words are numbered from the beginning
|
||||
|
||||
+104
-52
@@ -7,7 +7,7 @@ This document describes the GNU Readline Library, a utility for aiding
|
||||
in the consistency of user interface across discrete programs that need
|
||||
to provide a command line interface.
|
||||
|
||||
Copyright (C) 1988--2022 Free Software Foundation, Inc.
|
||||
Copyright (C) 1988--2023 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to make and distribute verbatim copies of
|
||||
this manual provided the copyright notice and this permission notice
|
||||
@@ -67,6 +67,9 @@ the simplest way possible, perhaps to replace calls in your code to
|
||||
|
||||
The function @code{readline()} prints a prompt @var{prompt}
|
||||
and then reads and returns a single line of text from the user.
|
||||
Since it's possible to enter characters into the line while quoting
|
||||
them to disable any Readline editing function they might normally have,
|
||||
this line may include embedded newlines and other special characters.
|
||||
If @var{prompt} is @code{NULL} or the empty string, no prompt is displayed.
|
||||
The line @code{readline} returns is allocated with @code{malloc()};
|
||||
the caller should @code{free()} the line when it has finished with it.
|
||||
@@ -476,6 +479,8 @@ The default hook checks @code{rl_instream}; if an application is using a
|
||||
different input source, it should set the hook appropriately.
|
||||
Readline queries for available input when implementing intra-key-sequence
|
||||
timeouts during input and incremental searches.
|
||||
This function must return zero if there is no input available, and non-zero
|
||||
if input is available.
|
||||
This may use an application-specific timeout before returning a value;
|
||||
Readline uses the value passed to @code{rl_set_keyboard_input_timeout()}
|
||||
or the value of the user-settable @var{keyseq-timeout} variable.
|
||||
@@ -513,6 +518,15 @@ By default, this is set to @code{rl_deprep_terminal}
|
||||
(@pxref{Terminal Management}).
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar {void} rl_macro_display_hook
|
||||
If set, this points to a function that @code{rl_macro_dumper} will call to
|
||||
display a key sequence bound to a macro.
|
||||
It is called with the key sequence, the "untranslated" macro value (i.e.,
|
||||
with backslash escapes included, as when passed to @code{rl_macro_bind}),
|
||||
the @code{readable} argument passed to @code{rl_macro_dumper}, and any
|
||||
prefix to display before the key sequence.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar {Keymap} rl_executing_keymap
|
||||
This variable is set to the keymap (@pxref{Keymaps}) in which the
|
||||
currently executing Readline function was found.
|
||||
@@ -915,9 +929,19 @@ Return an array of strings representing the key sequences used to
|
||||
invoke @var{function} in the keymap @var{map}.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun void rl_print_keybinding (const char *name, Keymap map, int readable)
|
||||
Print key sequences bound to Readline function name @var{name} in
|
||||
keymap @var{map}.
|
||||
If @var{map} is NULL, this uses the current keymap.
|
||||
If @var{readable} is non-zero,
|
||||
the list is formatted in such a way that it can be made part of an
|
||||
@code{inputrc} file and re-read.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun void rl_function_dumper (int readable)
|
||||
Print the Readline function names and the key sequences currently
|
||||
bound to them to @code{rl_outstream}. If @var{readable} is non-zero,
|
||||
bound to them to @code{rl_outstream}.
|
||||
If @var{readable} is non-zero,
|
||||
the list is formatted in such a way that it can be made part of an
|
||||
@code{inputrc} file and re-read.
|
||||
@end deftypefun
|
||||
@@ -1346,13 +1370,15 @@ If @var{c} is a number, return the value it represents.
|
||||
Bind the key sequence @var{keyseq} to invoke the macro @var{macro}.
|
||||
The binding is performed in @var{map}. When @var{keyseq} is invoked, the
|
||||
@var{macro} will be inserted into the line. This function is deprecated;
|
||||
use @code{rl_generic_bind()} instead.
|
||||
use @code{rl_generic_bind} instead.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun void rl_macro_dumper (int readable)
|
||||
Print the key sequences bound to macros and their values, using
|
||||
the current keymap, to @code{rl_outstream}.
|
||||
If @var{readable} is non-zero, the list is formatted in such a way
|
||||
If the application has assigned a value to @code{rl_macro_display_hook},
|
||||
@code{rl_macro_dumper} calls it instead of printing anything.
|
||||
If @var{readable} is greater than zero, the list is formatted in such a way
|
||||
that it can be made part of an @code{inputrc} file and re-read.
|
||||
@end deftypefun
|
||||
|
||||
@@ -1389,6 +1415,10 @@ use all of a terminal's capabilities, and this function will return
|
||||
values for only those capabilities Readline uses.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun {void} rl_reparse_colors (void)
|
||||
Read or re-read color definitions from @env{LS_COLORS}.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun {void} rl_clear_history (void)
|
||||
Clear the history list by deleting all of the entries, in the same manner
|
||||
as the History library's @code{clear_history()} function.
|
||||
@@ -2138,7 +2168,9 @@ The function should not modify the directory argument if it returns 0.
|
||||
@deftypevar {rl_dequote_func_t *} rl_filename_rewrite_hook
|
||||
If non-zero, this is the address of a function called when reading
|
||||
directory entries from the filesystem for completion and comparing
|
||||
them to the partial word to be completed. The function should
|
||||
them to the filename portion of the partial word to be completed
|
||||
(after its potential modification by @code{rl_completion_rewrite_hook}).
|
||||
The function should
|
||||
perform any necessary application or system-specific conversion on
|
||||
the filename, such as converting between character sets or converting
|
||||
from a filesystem format to a character input format.
|
||||
@@ -2151,6 +2183,24 @@ matches, is added to the list of matches. Readline will free the
|
||||
allocated string.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar {rl_dequote_func_t *} rl_completion_rewrite_hook
|
||||
If non-zero, this is the address of a function to call before
|
||||
comparing the filename portion of a word to be completed with directory
|
||||
entries from the filesystem.
|
||||
The function takes two arguments: @var{fname}, the filename to be converted,
|
||||
after any @code{rl_filename_dequoting_function} has been applied,
|
||||
and @var{fnlen}, its length in bytes.
|
||||
It must either return its first argument (if no conversion takes place)
|
||||
or the converted filename in newly-allocated memory.
|
||||
The function should perform any necessary application or system-specific
|
||||
conversion on the filename, such as converting between character sets or
|
||||
converting from a character input format to some other format.
|
||||
Readline compares the converted form against directory entries, after
|
||||
their potential modification by @code{rl_filename_rewrite_hook}, and adds
|
||||
any matches to the list of matches.
|
||||
Readline will free the allocated string.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar {rl_compdisp_func_t *} rl_completion_display_matches_hook
|
||||
If non-zero, then this is the address of a function to call when
|
||||
completing a word would normally display the list of possible matches.
|
||||
@@ -2298,6 +2348,17 @@ The quoting is effected via a call to the function pointed to
|
||||
by @code{rl_filename_quoting_function}.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar int rl_full_quoting_desired
|
||||
Non-zero means that Readline should apply filename-style quoting,
|
||||
including any application-specified quoting mechanism,
|
||||
to all completion matches even if we are not otherwise treating the
|
||||
matches as filenames.
|
||||
This is @emph{always} zero when completion is attempted, and can only
|
||||
be changed within an application-specific completion function.
|
||||
The quoting is effected via a call to the function pointed to
|
||||
by @code{rl_filename_quoting_function}.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar int rl_attempted_completion_over
|
||||
If an application-specific completion function assigned to
|
||||
@code{rl_attempted_completion_function} sets this variable to a non-zero
|
||||
@@ -2423,8 +2484,8 @@ COMMAND commands[] = @{
|
||||
@};
|
||||
|
||||
/* Forward declarations. */
|
||||
char *stripwhite ();
|
||||
COMMAND *find_command ();
|
||||
char *stripwhite (char *);
|
||||
COMMAND *find_command (char *);
|
||||
|
||||
/* The name of this program, as taken from argv[0]. */
|
||||
char *progname;
|
||||
@@ -2433,8 +2494,7 @@ char *progname;
|
||||
int done;
|
||||
|
||||
char *
|
||||
dupstr (s)
|
||||
char *s;
|
||||
dupstr (char *s)
|
||||
@{
|
||||
char *r;
|
||||
|
||||
@@ -2443,9 +2503,8 @@ dupstr (s)
|
||||
return (r);
|
||||
@}
|
||||
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
@{
|
||||
char *line, *s;
|
||||
|
||||
@@ -2481,8 +2540,7 @@ main (argc, argv)
|
||||
|
||||
/* Execute a command line. */
|
||||
int
|
||||
execute_line (line)
|
||||
char *line;
|
||||
execute_line (char *line)
|
||||
@{
|
||||
register int i;
|
||||
COMMAND *command;
|
||||
@@ -2521,8 +2579,7 @@ execute_line (line)
|
||||
/* Look up NAME as the name of a command, and return a pointer to that
|
||||
command. Return a NULL pointer if NAME isn't a command name. */
|
||||
COMMAND *
|
||||
find_command (name)
|
||||
char *name;
|
||||
find_command (char *name)
|
||||
@{
|
||||
register int i;
|
||||
|
||||
@@ -2536,8 +2593,7 @@ find_command (name)
|
||||
/* Strip whitespace from the start and end of STRING. Return a pointer
|
||||
into STRING. */
|
||||
char *
|
||||
stripwhite (string)
|
||||
char *string;
|
||||
stripwhite (char *string)
|
||||
@{
|
||||
register char *s, *t;
|
||||
|
||||
@@ -2561,13 +2617,14 @@ stripwhite (string)
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
char *command_generator PARAMS((const char *, int));
|
||||
char **fileman_completion PARAMS((const char *, int, int));
|
||||
char *command_generator (const char *, int);
|
||||
char **fileman_completion (const char *, int, int);
|
||||
|
||||
/* Tell the GNU Readline library how to complete. We want to try to complete
|
||||
on command names if this is the first word in the line, or on filenames
|
||||
if not. */
|
||||
initialize_readline ()
|
||||
void
|
||||
initialize_readline (void)
|
||||
@{
|
||||
/* Allow conditional parsing of the ~/.inputrc file. */
|
||||
rl_readline_name = "FileMan";
|
||||
@@ -2582,9 +2639,7 @@ initialize_readline ()
|
||||
in case we want to do some simple parsing. Return the array of matches,
|
||||
or NULL if there aren't any. */
|
||||
char **
|
||||
fileman_completion (text, start, end)
|
||||
const char *text;
|
||||
int start, end;
|
||||
fileman_completion (const char *text, int start, int end)
|
||||
@{
|
||||
char **matches;
|
||||
|
||||
@@ -2603,9 +2658,7 @@ fileman_completion (text, start, end)
|
||||
to start from scratch; without any state (i.e. STATE == 0), then we
|
||||
start at the top of the list. */
|
||||
char *
|
||||
command_generator (text, state)
|
||||
const char *text;
|
||||
int state;
|
||||
command_generator (const char *text, int state)
|
||||
@{
|
||||
static int list_index, len;
|
||||
char *name;
|
||||
@@ -2643,40 +2696,40 @@ command_generator (text, state)
|
||||
static char syscom[1024];
|
||||
|
||||
/* List the file(s) named in arg. */
|
||||
com_list (arg)
|
||||
char *arg;
|
||||
int
|
||||
com_list (char *arg)
|
||||
@{
|
||||
if (!arg)
|
||||
arg = "";
|
||||
|
||||
sprintf (syscom, "ls -FClg %s", arg);
|
||||
snprintf (syscom, sizeof (syscom), "ls -FClg %s", arg);
|
||||
return (system (syscom));
|
||||
@}
|
||||
|
||||
com_view (arg)
|
||||
char *arg;
|
||||
int
|
||||
com_view (char *arg)
|
||||
@{
|
||||
if (!valid_argument ("view", arg))
|
||||
return 1;
|
||||
|
||||
#if defined (__MSDOS__)
|
||||
/* more.com doesn't grok slashes in pathnames */
|
||||
sprintf (syscom, "less %s", arg);
|
||||
snprintf (syscom, sizeof (syscom), "less %s", arg);
|
||||
#else
|
||||
sprintf (syscom, "more %s", arg);
|
||||
snprintf (syscom, sizeof (syscom), "more %s", arg);
|
||||
#endif
|
||||
return (system (syscom));
|
||||
@}
|
||||
|
||||
com_rename (arg)
|
||||
char *arg;
|
||||
int
|
||||
com_rename (char *arg)
|
||||
@{
|
||||
too_dangerous ("rename");
|
||||
return (1);
|
||||
@}
|
||||
|
||||
com_stat (arg)
|
||||
char *arg;
|
||||
int
|
||||
com_stat (char *arg)
|
||||
@{
|
||||
struct stat finfo;
|
||||
|
||||
@@ -2703,8 +2756,8 @@ com_stat (arg)
|
||||
return (0);
|
||||
@}
|
||||
|
||||
com_delete (arg)
|
||||
char *arg;
|
||||
int
|
||||
com_delete (char *arg)
|
||||
@{
|
||||
too_dangerous ("delete");
|
||||
return (1);
|
||||
@@ -2712,8 +2765,8 @@ com_delete (arg)
|
||||
|
||||
/* Print out help for ARG, or for all of the commands if ARG is
|
||||
not present. */
|
||||
com_help (arg)
|
||||
char *arg;
|
||||
int
|
||||
com_help (char *arg)
|
||||
@{
|
||||
register int i;
|
||||
int printed = 0;
|
||||
@@ -2751,8 +2804,8 @@ com_help (arg)
|
||||
@}
|
||||
|
||||
/* Change to the directory ARG. */
|
||||
com_cd (arg)
|
||||
char *arg;
|
||||
int
|
||||
com_cd (char *arg)
|
||||
@{
|
||||
if (chdir (arg) == -1)
|
||||
@{
|
||||
@@ -2765,8 +2818,8 @@ com_cd (arg)
|
||||
@}
|
||||
|
||||
/* Print out the current working directory. */
|
||||
com_pwd (ignore)
|
||||
char *ignore;
|
||||
int
|
||||
com_pwd (char *ignore)
|
||||
@{
|
||||
char dir[1024], *s;
|
||||
|
||||
@@ -2782,16 +2835,16 @@ com_pwd (ignore)
|
||||
@}
|
||||
|
||||
/* The user wishes to quit using this program. Just set DONE non-zero. */
|
||||
com_quit (arg)
|
||||
char *arg;
|
||||
int
|
||||
com_quit (char *arg)
|
||||
@{
|
||||
done = 1;
|
||||
return (0);
|
||||
@}
|
||||
|
||||
/* Function which tells you that you can't do this. */
|
||||
too_dangerous (caller)
|
||||
char *caller;
|
||||
void
|
||||
too_dangerous (char *caller)
|
||||
@{
|
||||
fprintf (stderr,
|
||||
"%s: Too dangerous for me to distribute. Write it yourself.\n",
|
||||
@@ -2801,8 +2854,7 @@ too_dangerous (caller)
|
||||
/* Return non-zero if ARG is a valid argument for CALLER, else print
|
||||
an error message and return zero. */
|
||||
int
|
||||
valid_argument (caller, arg)
|
||||
char *caller, *arg;
|
||||
valid_argument (char *caller, char *arg)
|
||||
@{
|
||||
if (!arg || !*arg)
|
||||
@{
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
@comment %**start of header (This is for running Texinfo on a region.)
|
||||
@ifclear BashFeatures
|
||||
@setfilename rluser.info
|
||||
@end ifclear
|
||||
@comment %**end of header (This is for running Texinfo on a region.)
|
||||
|
||||
@ignore
|
||||
@@ -9,7 +11,7 @@ use these features. There is a document entitled "readline.texinfo"
|
||||
which contains both end-user and programmer documentation for the
|
||||
GNU Readline Library.
|
||||
|
||||
Copyright (C) 1988--2022 Free Software Foundation, Inc.
|
||||
Copyright (C) 1988--2023 Free Software Foundation, Inc.
|
||||
|
||||
Authored by Brian Fox and Chet Ramey.
|
||||
|
||||
@@ -323,13 +325,14 @@ the line, thereby executing the command from the history list.
|
||||
A movement command will terminate the search, make the last line found
|
||||
the current line, and begin editing.
|
||||
|
||||
Readline remembers the last incremental search string. If two
|
||||
@kbd{C-r}s are typed without any intervening characters defining a new
|
||||
search string, any remembered search string is used.
|
||||
Readline remembers the last incremental search string.
|
||||
If two @kbd{C-r}s are typed without any intervening characters defining
|
||||
a new search string, Readline uses any remembered search string.
|
||||
|
||||
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 be part of the contents of the current line.
|
||||
to search for matching history lines.
|
||||
The search string may be typed by the user or be part of the contents of
|
||||
the current line.
|
||||
|
||||
@node Readline Init File
|
||||
@section Readline Init File
|
||||
@@ -402,11 +405,12 @@ set editing-mode vi
|
||||
@end example
|
||||
|
||||
Variable names and values, where appropriate, are recognized without regard
|
||||
to case. Unrecognized variable names are ignored.
|
||||
to case.
|
||||
Unrecognized variable names are ignored.
|
||||
|
||||
Boolean variables (those that can be set to on or off) are set to on if
|
||||
the value is null or empty, @var{on} (case-insensitive), or 1. Any other
|
||||
value results in the variable being set to off.
|
||||
the value is null or empty, @var{on} (case-insensitive), or 1.
|
||||
Any other value results in the variable being set to off.
|
||||
|
||||
@ifset BashFeatures
|
||||
The @w{@code{bind -V}} command lists the current Readline variable names
|
||||
@@ -456,8 +460,12 @@ the terminal's bell.
|
||||
@item bind-tty-special-chars
|
||||
@vindex bind-tty-special-chars
|
||||
If set to @samp{on} (the default), Readline attempts to bind the control
|
||||
characters treated specially by the kernel's terminal driver to their
|
||||
characters that are
|
||||
treated specially by the kernel's terminal driver to their
|
||||
Readline equivalents.
|
||||
These override the default Readline bindings described here.
|
||||
Type @samp{stty -a} at a Bash prompt to see your current terminal settings,
|
||||
including the special control characters (usually @code{cchars}).
|
||||
|
||||
@item blink-matching-paren
|
||||
@vindex blink-matching-paren
|
||||
@@ -716,11 +724,11 @@ The default is @samp{off}.
|
||||
|
||||
@item match-hidden-files
|
||||
@vindex match-hidden-files
|
||||
This variable, when set to @samp{on}, causes Readline to match files whose
|
||||
This variable, when set to @samp{on}, forces Readline to match files whose
|
||||
names begin with a @samp{.} (hidden files) when performing filename
|
||||
completion.
|
||||
If set to @samp{off}, the leading @samp{.} must be
|
||||
supplied by the user in the filename to be completed.
|
||||
If set to @samp{off}, the user must include the leading @samp{.}
|
||||
in the filename to be completed.
|
||||
This variable is @samp{on} by default.
|
||||
|
||||
@item menu-complete-display-prefix
|
||||
@@ -757,6 +765,12 @@ before returning when @code{accept-line} is executed. By default,
|
||||
history lines may be modified and retain individual undo lists across
|
||||
calls to @code{readline()}. The default is @samp{off}.
|
||||
|
||||
@item search-ignore-case
|
||||
@vindex search-ignore-case
|
||||
If set to @samp{on}, Readline performs incremental and non-incremental
|
||||
history list searches in a case-insensitive fashion.
|
||||
The default value is @samp{off}.
|
||||
|
||||
@item show-all-if-ambiguous
|
||||
@vindex show-all-if-ambiguous
|
||||
This alters the default behavior of the completion functions. If
|
||||
@@ -1458,6 +1472,16 @@ moving point past that word as well.
|
||||
If the insertion point is at the end of the line, this transposes
|
||||
the last two words on the line.
|
||||
|
||||
@ifset BashFeatures
|
||||
@item shell-transpose-words (M-C-t)
|
||||
Drag the word before point past the word after point,
|
||||
moving point past that word as well.
|
||||
If the insertion point is at the end of the line, this transposes
|
||||
the last two words on the line.
|
||||
Word boundaries are the same as @code{shell-forward-word} and
|
||||
@code{shell-backward-word}.
|
||||
@end ifset
|
||||
|
||||
@item upcase-word (M-u)
|
||||
Uppercase the current (or following) word. With a negative argument,
|
||||
uppercase the previous word, but do not move the cursor.
|
||||
@@ -1528,14 +1552,6 @@ Kill the word behind point.
|
||||
Word boundaries are the same as @code{shell-backward-word}.
|
||||
@end ifset
|
||||
|
||||
@item shell-transpose-words (M-C-t)
|
||||
Drag the word before point past the word after point,
|
||||
moving point past that word as well.
|
||||
If the insertion point is at the end of the line, this transposes
|
||||
the last two words on the line.
|
||||
Word boundaries are the same as @code{shell-forward-word} and
|
||||
@code{shell-backward-word}.
|
||||
|
||||
@item unix-word-rubout (C-w)
|
||||
Kill the word behind point, using white space as a word boundary.
|
||||
The killed text is saved on the kill-ring.
|
||||
@@ -1858,9 +1874,13 @@ pathname expansion.
|
||||
Display version information about the current instance of Bash.
|
||||
|
||||
@item shell-expand-line (M-C-e)
|
||||
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}).
|
||||
Expand the line by performing shell word expansions.
|
||||
This performs alias and history expansion,
|
||||
$'@var{string}' and $"@var{string}" quoting,
|
||||
tilde expansion, parameter and variable expansion, arithmetic expansion,
|
||||
command and proces substitution,
|
||||
word splitting, and quote removal.
|
||||
An explicit argument suppresses command and process substitution.
|
||||
|
||||
@item history-expand-line (M-^)
|
||||
Perform history expansion on the current line.
|
||||
@@ -1898,6 +1918,13 @@ editing mode.
|
||||
|
||||
@end ifclear
|
||||
|
||||
@item execute-named-command (M-x)
|
||||
Read a bindable readline command name from the input and execute the
|
||||
function to which it's bound, as if the key sequence to which it was
|
||||
bound appeared in the input.
|
||||
If this function is supplied with a numeric argument, it passes that
|
||||
argument to the function it executes.
|
||||
|
||||
@end ftable
|
||||
|
||||
@node Readline vi Mode
|
||||
@@ -2098,14 +2125,25 @@ be completed, and two to modify the completion as it is happening.
|
||||
@item compgen
|
||||
@btindex compgen
|
||||
@example
|
||||
@code{compgen [@var{option}] [@var{word}]}
|
||||
@code{compgen [-V @var{varname}] [@var{option}] [@var{word}]}
|
||||
@end example
|
||||
|
||||
Generate possible completion matches for @var{word} according to
|
||||
the @var{option}s, which may be any option accepted by the
|
||||
@code{complete}
|
||||
builtin with the exception of @option{-p} and @option{-r}, and write
|
||||
the matches to the standard output.
|
||||
builtin with the exceptions of
|
||||
@option{-p},
|
||||
@option{-r},
|
||||
@option{-D},
|
||||
@option{-E},
|
||||
and
|
||||
@option{-I},
|
||||
and write the matches to the standard output.
|
||||
|
||||
If the @option{-V} option is supplied, @code{compgen} stores the generated
|
||||
completions into the indexed array variable @var{varname} instead of writing
|
||||
them to the standard output.
|
||||
|
||||
When using the @option{-F} or @option{-C} options, the various shell variables
|
||||
set by the programmable completion facilities, while available, will not
|
||||
have useful values.
|
||||
@@ -2122,14 +2160,15 @@ matches were generated.
|
||||
@item complete
|
||||
@btindex complete
|
||||
@example
|
||||
@code{complete [-abcdefgjksuv] [-o @var{comp-option}] [-DEI] [-A @var{action}] [-G @var{globpat}]
|
||||
[-W @var{wordlist}] [-F @var{function}] [-C @var{command}] [-X @var{filterpat}]
|
||||
[-P @var{prefix}] [-S @var{suffix}] @var{name} [@var{name} @dots{}]}
|
||||
@code{complete [-abcdefgjksuv] [-o @var{comp-option}] [-DEI] [-A @var{action}]
|
||||
[-G @var{globpat}] [-W @var{wordlist}] [-F @var{function}] [-C @var{command}]
|
||||
[-X @var{filterpat}] [-P @var{prefix}] [-S @var{suffix}] @var{name} [@var{name} @dots{}]}
|
||||
@code{complete -pr [-DEI] [@var{name} @dots{}]}
|
||||
@end example
|
||||
|
||||
Specify how arguments to each @var{name} should be completed.
|
||||
If the @option{-p} option is supplied, or if no options are supplied, existing
|
||||
If the @option{-p} option is supplied, or if no options or @var{name}s
|
||||
are supplied, existing
|
||||
completion specifications are printed in a way that allows them to be
|
||||
reused as input.
|
||||
The @option{-r} option removes a completion specification for
|
||||
@@ -2187,6 +2226,10 @@ quoting special characters, or suppressing trailing spaces).
|
||||
This option is intended to be used with shell functions specified
|
||||
with @option{-F}.
|
||||
|
||||
@item fullquote
|
||||
Tell Readline to quote all the completed words even if they are not
|
||||
filenames.
|
||||
|
||||
@item noquote
|
||||
Tell Readline not to quote the completed words if they are filenames
|
||||
(quoting filenames is the default).
|
||||
@@ -2330,7 +2373,14 @@ case, any completion not matching @var{filterpat} is removed.
|
||||
@end table
|
||||
|
||||
The return value is true unless an invalid option is supplied, an option
|
||||
other than @option{-p} or @option{-r} is supplied without a @var{name}
|
||||
other than
|
||||
@option{-p},
|
||||
@option{-r},
|
||||
@option{-D},
|
||||
@option{-E},
|
||||
or
|
||||
@option{-I}
|
||||
is supplied without a @var{name}
|
||||
argument, an attempt is made to remove a completion specification for
|
||||
a @var{name} for which no specification exists, or
|
||||
an error occurs adding a completion specification.
|
||||
@@ -2458,9 +2508,11 @@ complete -o filenames -o nospace -o bashdefault -F _comp_cd cd
|
||||
@noindent
|
||||
Since we'd like Bash and Readline to take care of some
|
||||
of the other details for us, we use several other options to tell Bash
|
||||
and Readline what to do. The @option{-o filenames} option tells Readline
|
||||
and Readline what to do.
|
||||
The @option{-o filenames} option tells Readline
|
||||
that the possible completions should be treated as filenames, and quoted
|
||||
appropriately. That option will also cause Readline to append a slash to
|
||||
appropriately.
|
||||
That option will also cause Readline to append a slash to
|
||||
filenames it can determine are directories (which is why we might want to
|
||||
extend @code{_comp_cd} to append a slash if we're using directories found
|
||||
via @var{CDPATH}: Readline can't tell those completions are directories).
|
||||
@@ -2468,9 +2520,10 @@ The @option{-o nospace} option tells Readline to not append a space
|
||||
character to the directory name, in case we want to append to it.
|
||||
The @option{-o bashdefault} option brings in the rest of the "Bash default"
|
||||
completions -- possible completions that Bash adds to the default Readline
|
||||
set. These include things like command name completion, variable completion
|
||||
for words beginning with @samp{$} or @samp{$@{}, completions containing pathname
|
||||
expansion patterns (@pxref{Filename Expansion}), and so on.
|
||||
set.
|
||||
These include things like command name completion, variable completion
|
||||
for words beginning with @samp{$} or @samp{$@{}, completions containing
|
||||
pathname expansion patterns (@pxref{Filename Expansion}), and so on.
|
||||
|
||||
Once installed using @code{complete}, @code{_comp_cd} will be called every
|
||||
time we attempt word completion for a @code{cd} command.
|
||||
@@ -2479,8 +2532,8 @@ Many more examples -- an extensive collection of completions for most of
|
||||
the common GNU, Unix, and Linux commands -- are available as part of the
|
||||
bash_completion project. This is installed by default on many GNU/Linux
|
||||
distributions. Originally written by Ian Macdonald, the project now lives
|
||||
at @url{https://github.com/scop/bash-completion/}. There are ports for
|
||||
other systems such as Solaris and Mac OS X.
|
||||
at @url{https://github.com/scop/bash-completion/}.
|
||||
There are ports for other systems such as Solaris and Mac OS X.
|
||||
|
||||
An older version of the bash_completion package is distributed with bash
|
||||
in the @file{examples/complete} subdirectory.
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
@ignore
|
||||
Copyright (C) 1988-2022 Free Software Foundation, Inc.
|
||||
Copyright (C) 1988-2024 Free Software Foundation, Inc.
|
||||
@end ignore
|
||||
|
||||
@set EDITION 8.2
|
||||
@set VERSION 8.2
|
||||
@set EDITION 8.3
|
||||
@set VERSION 8.3
|
||||
|
||||
@set UPDATED 19 September 2022
|
||||
@set UPDATED-MONTH September 2022
|
||||
@set UPDATED 19 January 2024
|
||||
@set UPDATED-MONTH January 2024
|
||||
|
||||
@set LASTCHANGE Mon Sep 19 11:15:16 EDT 2022
|
||||
@set LASTCHANGE Fri Jan 19 11:01:44 EST 2024
|
||||
|
||||
Reference in New Issue
Block a user