mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-08-09 03:30:48 +02:00
commit bash-20180628 snapshot
This commit is contained in:
@@ -403,7 +403,7 @@ to the ``normal'' terminating characters.
|
||||
Return an array of tokens parsed out of @var{string}, much as the
|
||||
shell might. The tokens are split on the characters in the
|
||||
@var{history_word_delimiters} variable,
|
||||
and shell quoting conventions are obeyed.
|
||||
and shell quoting conventions are obeyed as described below.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun {char *} history_arg_extract (int first, int last, const char *string)
|
||||
@@ -476,8 +476,24 @@ carriage return, and @samp{=}.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar int history_quotes_inhibit_expansion
|
||||
If non-zero, double-quoted words are not scanned for the history expansion
|
||||
character or the history comment character. The default value is 0.
|
||||
If non-zero, the history expansion code implements shell-like quoting:
|
||||
single-quoted words are not scanned for the history expansion
|
||||
character or the history comment character, and double-quoted words may
|
||||
have history expansion performed, since single quotes are not special
|
||||
within double quotes.
|
||||
The default value is 0.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar int history_quoting_state
|
||||
An application may set this variable to indicate that the current line
|
||||
being expanded is subject to existing quoting. If set to @samp{'}, the
|
||||
history expansion function will assume that the line is single-quoted and
|
||||
inhibit expansion until it reads an unquoted closing single quote; if set
|
||||
to @samp{"}, history expansion will assume the line is double quoted until
|
||||
it reads an unquoted closing double quote. If set to zero, the default,
|
||||
the history expansion function will assume the line is not quoted and
|
||||
treat quote characters within the line as described above.
|
||||
This is only effective if @var{history_quotes_inhibit_expansion} is set.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar {rl_linebuf_func_t *} history_inhibit_expansion_function
|
||||
|
||||
@@ -262,8 +262,8 @@ fix errors in previous commands quickly.
|
||||
@ifset BashFeatures
|
||||
History expansion is performed immediately after a complete line
|
||||
is read, before the shell breaks it into words, and is performed
|
||||
on each line individually without taking quoting on previous lines into
|
||||
account.
|
||||
on each line individually. Bash attempts to inform the history
|
||||
expansion functions about quoting still in effect from previous lines.
|
||||
@end ifset
|
||||
|
||||
History expansion takes place in two parts. The first is to determine
|
||||
@@ -277,9 +277,19 @@ 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.
|
||||
|
||||
History expansion implements shell-like quoting conventions:
|
||||
a backslash can be used to remove the special handling for the next character;
|
||||
single quotes enclose verbatim sequences of characters, and can be used to
|
||||
inhibit history expansion;
|
||||
and characters enclosed within double quotes may be subject to history
|
||||
expansion, since backslash can escape the history expansion character,
|
||||
but single quotes may not, since they are not treated specially within
|
||||
double quotes.
|
||||
|
||||
@ifset BashFeatures
|
||||
Only @samp{\} and @samp{'} may be used to escape the history expansion
|
||||
character, but the history expansion character is
|
||||
When using the shell, only @samp{\} and @samp{'} may be used to escape the
|
||||
history expansion character, but the history expansion character is
|
||||
also treated as quoted if it immediately precedes the closing double quote
|
||||
in a double-quoted string.
|
||||
@end ifset
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
@ignore
|
||||
Copyright (C) 1988-2017 Free Software Foundation, Inc.
|
||||
Copyright (C) 1988-2018 Free Software Foundation, Inc.
|
||||
@end ignore
|
||||
|
||||
@set EDITION 7.0
|
||||
@set VERSION 7.0
|
||||
@set UPDATED 28 December 2017
|
||||
@set UPDATED-MONTH December 2017
|
||||
@set EDITION 8.0
|
||||
@set VERSION 8.0
|
||||
@set UPDATED 6 July 2018
|
||||
@set UPDATED-MONTH July 2018
|
||||
|
||||
@set LASTCHANGE Thu Dec 28 14:44:16 EST 2017
|
||||
@set LASTCHANGE Fri Jul 6 16:25:22 MDT 2018
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* histexpand.c -- history expansion. */
|
||||
|
||||
/* Copyright (C) 1989-2017 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1989-2018 Free Software Foundation, Inc.
|
||||
|
||||
This file contains the GNU History Library (History), a set of
|
||||
routines for managing the text of previously typed lines.
|
||||
@@ -107,6 +107,8 @@ char *history_word_delimiters = HISTORY_WORD_DELIMITERS;
|
||||
particular history expansion should be performed. */
|
||||
rl_linebuf_func_t *history_inhibit_expansion_function;
|
||||
|
||||
int history_quoting_state = 0;
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* History Expansion */
|
||||
@@ -961,7 +963,22 @@ history_expand (char *hstring, char **output)
|
||||
|
||||
/* `!' followed by one of the characters in history_no_expand_chars
|
||||
is NOT an expansion. */
|
||||
for (i = dquote = squote = 0; string[i]; i++)
|
||||
dquote = history_quoting_state == '"';
|
||||
squote = history_quoting_state == '\'';
|
||||
|
||||
/* If the calling application tells us we are already reading a
|
||||
single-quoted string, consume the rest of the string right now
|
||||
and then go on. */
|
||||
i = 0;
|
||||
if (squote && history_quotes_inhibit_expansion)
|
||||
{
|
||||
hist_string_extract_single_quoted (string, &i, 0);
|
||||
squote = 0;
|
||||
if (string[i])
|
||||
i++;
|
||||
}
|
||||
|
||||
for ( ; string[i]; i++)
|
||||
{
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
@@ -1049,7 +1066,29 @@ history_expand (char *hstring, char **output)
|
||||
}
|
||||
|
||||
/* Extract and perform the substitution. */
|
||||
for (passc = dquote = squote = i = j = 0; i < l; i++)
|
||||
dquote = history_quoting_state == '"';
|
||||
squote = history_quoting_state == '\'';
|
||||
|
||||
/* If the calling application tells us we are already reading a
|
||||
single-quoted string, consume the rest of the string right now
|
||||
and then go on. */
|
||||
i = j = 0;
|
||||
if (squote && history_quotes_inhibit_expansion)
|
||||
{
|
||||
int c;
|
||||
|
||||
hist_string_extract_single_quoted (string, &i, 0);
|
||||
squote = 0;
|
||||
for (c = 0; c < i; c++)
|
||||
ADD_CHAR (string[c]);
|
||||
if (string[i])
|
||||
{
|
||||
ADD_CHAR (string[i]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
for (passc = 0; i < l; i++)
|
||||
{
|
||||
int qc, tchar = string[i];
|
||||
|
||||
|
||||
@@ -261,7 +261,9 @@ extern char *history_word_delimiters;
|
||||
extern char history_comment_char;
|
||||
extern char *history_no_expand_chars;
|
||||
extern char *history_search_delimiter_chars;
|
||||
|
||||
extern int history_quotes_inhibit_expansion;
|
||||
extern int history_quoting_state;
|
||||
|
||||
extern int history_write_timestamps;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user