remove history position change to non-incremental search; fixes to $@ in some word expansions like :+

This commit is contained in:
Chet Ramey
2022-03-25 09:52:26 -04:00
parent 5bba60397c
commit 8f68f9f0ff
22 changed files with 990 additions and 976 deletions
+1 -4
View File
@@ -313,10 +313,7 @@ g. There is a new option: `enable-active-region'. This separates control of
h. rl_completer_word_break_characters is now `const char *' like
rl_basic_word_break_characters.
i. The non-incremental history searches now leave the current history offset
at the position of the last matching history entry, like incremental search.
j. Readline looks in $LS_COLORS for a custom filename extension
i. Readline looks in $LS_COLORS for a custom filename extension
(*.readline-colored-completion-prefix) and uses that as the default color
for the common prefix displayed when `colored-completion-prefix' is set.
+1 -5
View File
@@ -313,10 +313,6 @@ g. There is a new option: `enable-active-region'. This separates control of
h. rl_completer_word_break_characters is now `const char *' like
rl_basic_word_break_characters.
i. The non-incremental history searches now leave the current history offset
at the position of the last matching history entry, like incremental search.
j. Readline looks in $LS_COLORS for a custom filename extension
i. Readline looks in $LS_COLORS for a custom filename extension
(*.readline-colored-completion-prefix) and uses that as the default color
for the common prefix displayed when `colored-completion-prefix' is set.
+38
View File
@@ -3386,3 +3386,41 @@ lib/readline/search.c
move to the found history line instead of directly calling
history_set_pos. This makes the behavior more similar to incremental
search
- rl_history_search_internal: make sure to set rl_undo_list to the
current history undo list around the calls to rl_get_previous_history
or rl_get_next_history, in order to fool the call to
maybe_replace_line they make
lib/readline/readline.c
- _rl_executing_func: the currently-executing readline command function
lib/readline/rlprivate.h
- _rl_executing_func: extern declaration
lib/readline/search.c
- _rl_history_search_internal: removed (commented out) code that sets
the current history entry to the found history entry, too much
assumes that the current undo list should be applied to the current
history entry (where_history())
3/23
----
subst.c
- parameter_brace_expand_word: if we have double-quoted ${*} or ${@},
make sure we are setting W_HASQUOTEDNULL in the flags we return to the
caller if we are returning QUOTED_NULL(word)
- parameter_brace_expand_word: if we have a double-quoted associative array
reference using `*' or `@', make sure we are setting W_HASQUOTEDNULL in the flags
we return to the caller if we are returning QUOTED_NULL(word)
- parameter_brace_expand: if we're using the `[:]+' word expansion operator,
we need to note a quoted null string and pass the W_QUOTEDNULL flag
back to the caller
- expand_word_internal: make sure to return a QUOTED_NULL (word[0] == CTLNUL)
back to the caller if HAD_QUOTED_NULL is set, regardless of whether or
not we see a quoted dollar at. Fix for bug reported by
Andreas Luik <andreas.luik@innovative-navigation.de>
arrayfunc.c
- array_value_internal: fix typo and set estatep->type to ARRAY_INDEXED for
indexed arrays
+2
View File
@@ -1037,6 +1037,8 @@ tests/dollar-at-star6.sub f
tests/dollar-at-star7.sub f
tests/dollar-at-star8.sub f
tests/dollar-at-star9.sub f
tests/dollar-at-star10.sub f
tests/dollar-at-star11.sub f
tests/dollar-at1.sub f
tests/dollar-at2.sub f
tests/dollar-at3.sub f
+1 -4
View File
@@ -129,10 +129,7 @@ g. There is a new option: `enable-active-region'. This separates control of
h. rl_completer_word_break_characters is now `const char *' like
rl_basic_word_break_characters.
i. The non-incremental history searches now leave the current history offset
at the position of the last matching history entry, like incremental search.
j. Readline looks in $LS_COLORS for a custom filename extension
i. Readline looks in $LS_COLORS for a custom filename extension
(*.readline-colored-completion-prefix) and uses that as the default color
for the common prefix displayed when `colored-completion-prefix' is set.
+1 -4
View File
@@ -129,9 +129,6 @@ g. There is a new option: `enable-active-region'. This separates control of
h. rl_completer_word_break_characters is now `const char *' like
rl_basic_word_break_characters.
i. The non-incremental history searches now leave the current history offset
at the position of the last matching history entry, like incremental search.
j. Readline looks in $LS_COLORS for a custom filename extension
i. Readline looks in $LS_COLORS for a custom filename extension
(*.readline-colored-completion-prefix) and uses that as the default color
for the common prefix displayed when `colored-completion-prefix' is set.
+1 -1
View File
@@ -1538,7 +1538,7 @@ array_value_internal (s, quoted, flags, estatep)
else
{
if (estatep)
estatep->type = ARRAY_ASSOC;
estatep->type = ARRAY_INDEXED;
l = array_to_word_list (array_cell (var));
if (l == (WORD_LIST *)NULL)
return ((char *) NULL);
+1 -1
View File
@@ -2774,7 +2774,7 @@ interpreted as relative to one greater than the maximum index of
\fIname\fP, so negative indices count back from the end of the
array, and an index of \-1 references the last element.
.PP
The += operator will append to a array variable when assigning
The += operator will append to an array variable when assigning
using the compound assignment syntax; see
.SM
.B PARAMETERS
+1 -1
View File
@@ -7701,7 +7701,7 @@ interpreted as relative to one greater than the maximum index of
@var{name}, so negative indices count back from the end of the
array, and an index of -1 references the last element.
The @samp{+=} operator will append to a array variable when assigning
The @samp{+=} operator will append to an array variable when assigning
using the compound assignment syntax; see @ref{Shell Parameters} above.
Any element of an array may be referenced using
+10 -3
View File
@@ -240,6 +240,9 @@ char *_rl_comment_begin;
/* Keymap holding the function currently being executed. */
Keymap rl_executing_keymap;
/* The function currently being executed. */
rl_command_func_t *_rl_executing_func;
/* Keymap we're currently using to dispatch. */
Keymap _rl_dispatching_keymap;
@@ -489,10 +492,10 @@ readline_internal_teardown (int eof)
/* We don't want to do this if we executed functions that call
history_set_pos to set the history offset to the line containing the
non-incremental search string. */
#if 1 /* XXX */
if (entry && rl_undo_list)
#else
#if HISTORY_SEARCH_SETS_HISTPOS
if (entry && rl_undo_list && _rl_history_search_pos != where_history ())
#else
if (entry && rl_undo_list)
#endif
{
temp = savestring (the_line);
@@ -683,6 +686,8 @@ readline_internal_charloop (void)
rl_executing_keymap = _rl_command_to_execute->map;
rl_executing_key = _rl_command_to_execute->key;
_rl_executing_func = _rl_command_to_execute->func;
rl_dispatching = 1;
RL_SETSTATE(RL_STATE_DISPATCHING);
r = (*(_rl_command_to_execute->func)) (_rl_command_to_execute->count, _rl_command_to_execute->key);
@@ -904,6 +909,8 @@ _rl_dispatch_subseq (register int key, Keymap map, int got_subseq)
rl_executing_keymap = map;
rl_executing_key = key;
_rl_executing_func = func;
RESIZE_KEYSEQ_BUFFER();
rl_executing_keyseq[rl_key_sequence_length++] = key;
rl_executing_keyseq[rl_key_sequence_length] = '\0';
+2
View File
@@ -381,6 +381,8 @@ extern void _rl_end_executing_keyseq (void);
extern void _rl_add_executing_keyseq (int);
extern void _rl_del_executing_keyseq (void);
extern rl_command_func_t *_rl_executing_func;
/* rltty.c */
extern int _rl_disable_tty_signals (void);
extern int _rl_restore_tty_signals (void);
+11
View File
@@ -517,6 +517,7 @@ static int
rl_history_search_internal (int count, int dir)
{
HIST_ENTRY *temp;
UNDO_LIST *origlist;
int ret, oldpos, newcol, had_saved_line, origpos;
char *t;
@@ -584,13 +585,23 @@ rl_history_search_internal (int count, int dir)
if (had_saved_line == 0)
_rl_free_saved_history_line ();
#if HISTORY_SEARCH_SETS_HISTPOS
/* XXX - can't make this work the way I want it to yet. Too much assumes
that rl_undo_list corresponds to the current history entry's undo list,
especially the stuff in maybe_save_line and especially maybe_replace_line.
Leaving it commented out for now. */
/* Make sure we set the current history position to the last line found so
we can do things like operate-and-get-next from here. This is similar to
how incremental search behaves. */
origlist = rl_undo_list;
rl_undo_list = 0; /* XXX - was (UNDO_LIST *)temp->data */
if (_rl_history_search_pos < origpos)
rl_get_previous_history (origpos - _rl_history_search_pos, 0);
else
rl_get_next_history (_rl_history_search_pos - origpos, 0);
rl_undo_list = origlist;
#endif
/* decide where to put rl_point -- need to change this for pattern search */
if (_rl_history_search_flags & ANCHORED_SEARCH)
BIN
View File
Binary file not shown.
+653 -944
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+7 -7
View File
@@ -26,7 +26,7 @@ msgstr ""
"Project-Id-Version: bash 5.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-11-28 12:51-0500\n"
"PO-Revision-Date: 2022-03-15 23:15+0800\n"
"PO-Revision-Date: 2022-03-22 16:23+0800\n"
"Last-Translator: Wenbin Lv <wenbin816@gmail.com>\n"
"Language-Team: Chinese (simplified) <i18n-zh@googlegroups.com>\n"
"Language: zh_CN\n"
@@ -784,7 +784,7 @@ msgid ""
" \n"
" The `dirs' builtin displays the directory stack."
msgstr ""
"将目录添加到目录栈顶,或着旋转栈直到当前工作目录成为\n"
"将目录添加到目录栈顶,或者轮转栈直到当前工作目录成为\n"
" 新的栈顶。不带参数时,交换栈顶的两个目录。\n"
" \n"
" 选项:\n"
@@ -792,10 +792,10 @@ msgstr ""
" \t进行操作。\n"
" \n"
" 参数:\n"
" +N\t转栈,使得第 N 个目录(\"dirs\" 显示的列表中左起,\n"
" +N\t转栈,使得第 N 个目录(\"dirs\" 显示的列表中左起,\n"
" \t从零开始)移动到栈顶。\n"
" \n"
" -N\t转栈,使得第 N 个目录(\"dirs\" 显示的列表中右起,\n"
" -N\t转栈,使得第 N 个目录(\"dirs\" 显示的列表中右起,\n"
" \t从零开始)移动到栈顶。\n"
" \n"
" 目录\t将 <目录> 添加到栈顶,使其成为当前工作目录。\n"
@@ -5061,7 +5061,7 @@ msgid ""
msgstr ""
"将目录添加到栈中。\n"
" \n"
" 将目录添加到目录栈顶,或着旋转栈直到当前工作目录成为\n"
" 将目录添加到目录栈顶,或者轮转栈直到当前工作目录成为\n"
" 新的栈顶。不带参数时,交换栈顶的两个目录。\n"
" \n"
" 选项:\n"
@@ -5069,10 +5069,10 @@ msgstr ""
" \t\t进行操作。\n"
" \n"
" 参数:\n"
" +N\t转栈,使得第 N 个目录(\"dirs\" 显示的列表中左起,\n"
" +N\t转栈,使得第 N 个目录(\"dirs\" 显示的列表中左起,\n"
" \t\t从零开始)移动到栈顶。\n"
" \n"
" -N\t转栈,使得第 N 个目录(\"dirs\" 显示的列表中右起,\n"
" -N\t转栈,使得第 N 个目录(\"dirs\" 显示的列表中右起,\n"
" \t\t从零开始)移动到栈顶。\n"
" \n"
" 目录\t将 <目录> 添加到栈顶,使其成为当前工作目录。\n"
+27 -1
View File
@@ -7422,6 +7422,13 @@ parameter_brace_expand_word (name, var_is_special, quoted, pflags, estatep)
ret = param_expand (tt, &sindex, quoted, (int *)NULL, (int *)NULL,
(int *)NULL, (int *)NULL, pflags);
/* Make sure we note that we saw a quoted null string and pass the flag back
to the caller in addition to the value. */
if ((quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) && STR_DOLLAR_AT_STAR (name) &&
ret && ret->word && QUOTED_NULL (ret->word))
ret->flags |= W_HASQUOTEDNULL;
free (tt);
}
#if defined (ARRAY_VARS)
@@ -7475,8 +7482,13 @@ expand_arrayref:
if (estatep)
*estatep = es; /* structure copy */
}
/* Note that array[*] and array[@] expanded to a quoted null string by
returning the W_HASQUOTEDNULL flag to the caller in addition to TEMP. */
else if (es.subtype == 1 && temp && QUOTED_NULL (temp) && (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)))
rflags |= W_HASQUOTEDNULL;
else if (es.subtype == 2 && temp && QUOTED_NULL (temp) && (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)))
rflags |= W_HASQUOTEDNULL;
if (estatep == 0)
flush_eltstate (&es);
}
@@ -10123,6 +10135,14 @@ bad_substitution:
}
else /* VAR not set or VAR is NULL. */
{
/* If we're freeing a quoted null here, we need to remember we saw
it so we can restore it later if needed, or the caller can note it.
The check against `+' doesn't really matter, since the other cases
don't use or return TFLAG, but it's good for clarity. */
if (c == '+' && temp && QUOTED_NULL (temp) &&
(quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)))
tflag |= W_HASQUOTEDNULL;
FREE (temp);
temp = (char *)NULL;
if (c == '=' && var_is_special)
@@ -10947,7 +10967,9 @@ expand_word_internal (word, quoted, isexp, contains_dollar_at, expanded_somethin
DECLARE_MBSTATE;
/* OK, let's see if we can optimize a common idiom: "$@" */
/* OK, let's see if we can optimize a common idiom: "$@". This needs to make sure
that all of the flags callers care about (e.g., W_HASQUOTEDNULL) are set in
list->flags. */
if (STREQ (word->word, "\"$@\"") &&
(word->flags == (W_HASDOLLAR|W_QUOTED)) &&
dollar_vars[1]) /* XXX - check IFS here as well? */
@@ -11677,7 +11699,11 @@ finished_with_string:
if (*istring == '\0')
{
#if 0
if (quoted_dollar_at == 0 && (had_quoted_null || quoted_state == PARTIALLY_QUOTED))
#else
if (had_quoted_null || (quoted_dollar_at == 0 && quoted_state == PARTIALLY_QUOTED))
#endif
{
istring[0] = CTLNUL;
istring[1] = '\0';
+1 -1
View File
@@ -1,4 +1,4 @@
BUILD_DIR=/usr/local/build/chet/bash/bash-current
BUILD_DIR=/usr/local/build/bash/bash-current
THIS_SH=$BUILD_DIR/bash
PATH=$PATH:$BUILD_DIR
+19
View File
@@ -1,3 +1,17 @@
# This program 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 3 of the License, or
# (at your option) any later version.
#
# This program 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.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# first, let's start with the basics
recho "$@"
@@ -246,6 +260,11 @@ ${THIS_SH} ./dollar-at-star8.sub
# with different values for IFS
${THIS_SH} ./dollar-at-star9.sub
# tests for expansions of "$*" and "$@" and their array equivalents when $1 == ''
# and we're using the POSIX word expansions
${THIS_SH} ./dollar-at-star10.sub
${THIS_SH} ./dollar-at-star11.sub
# tests for special expansion of "$*" and "${array[*]}" when used with other
# expansions -- bugs through bash-2.05b
${THIS_SH} ./dollar-star1.sub
+66
View File
@@ -0,0 +1,66 @@
# checks for array variables and positional parameter expansions losing quoted
# null string expansions -- problem through bash-5.1
set -- ''
myvar[0]=
a="${myvar[*]}"
recho "$*"
recho "${*}"
recho "${a}"
recho "${myvar[*]}"
recho "${a:+nonnull}"
recho "${myvar[*]:+nonnull}"
a="${myvar[@]}"
recho "$@"
recho "${@}"
recho "${a}"
recho "${myvar[@]}"
recho "${a:+nonnull}"
recho "${myvar[@]:+nonnull}"
# check to make sure literal CTLNULs are handled correctly
set -- $'\x7f'
recho "$@"
recho "${@}"
recho "${@:+nonnull}"
recho "$*"
recho "${*}"
recho "${*:+nonnull}"
shift $#
# these should echo nothing
recho "${@}"
recho "${@:+nonnull}"
unset -v a
# make sure that other null expansions result in null strings where appropriate
set -- ''
a[0]=
recho "$*"$x
recho "${*}"$x
recho "$@"$x
recho "${@}"$x
recho "${a[*]}"$x
recho "${a[@]}"$x
recho "$@"$x
recho "${@}"$x
recho "${a[*]}"
recho "${a[@]}"
+80
View File
@@ -0,0 +1,80 @@
a[0]='/'
set -- /
# these should all result in the empty (null) string
recho "${a[0]%?}"
recho "${a[*]%?}"
recho "${a[@]%?}"
recho "${*%?}"
recho "${@%?}"
recho "${a[0]#?}"
recho "${a[*]#?}"
recho "${a[@]#?}"
recho "${*#?}"
recho "${@#?}"
recho "${a[0]/\//}"
recho "${a[*]/\//}"
recho "${a[@]/\//}"
recho "${*/\//}"
recho "${@/\//}"
recho "${a[0]:1:1}"
# these next four will all echo /
# arrays are zero-based
recho "${a[*]:0:1}"
recho "${a[@]:0:1}"
# but the positional parameters start at 1
recho "${*:1:1}"
recho "${@:1:1}"
a[0]=''
set -- ''
# arrays are zero-based
recho "${a[*]:0:1}"
recho "${a[@]:0:1}"
recho "${*:1:1}"
recho "${@:1:1}"
# these should all result in the empty (null) string, or quoted as such
recho "${a[0]@Q}"
recho "${a[*]@Q}"
recho "${a[@]@Q}"
recho "${*@Q}"
recho "${@@Q}"
recho "${a[0]@L}"
recho "${a[*]@L}"
recho "${a[@]@L}"
recho "${*@L}"
recho "${@@L}"
# examples from the bug report
unset -v a
a[0]='/'
for i in "${a[@]%/}"; do recho "$i"; done
a[0]=''
for i in "${a[@]}"; do recho "$i"; done
a[0]='/'
a[1]="//"
for i in "${a[@]%/}"; do recho "$i"; done
unset -v x y
x=('/')
y=("${x[@]%/}")
echo "${#x[@]}:${#y[@]}"
+67
View File
@@ -399,6 +399,73 @@ argv[1] = <^?>
argv[1] = <^?>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <^?>
argv[1] = <^?>
argv[1] = <nonnull>
argv[1] = <^?>
argv[1] = <^?>
argv[1] = <nonnull>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = </>
argv[1] = </>
argv[1] = </>
argv[1] = </>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <''>
argv[1] = <''>
argv[1] = <''>
argv[1] = <''>
argv[1] = <''>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = </>
1:1
xa|xb|xc
xa|xb|xc
a|b|c