mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-06-29 08:29:54 +02:00
fix issue with failed history expansion changing the history list offset; fix some tests to avoid problems with error messages that differ between systems; fix issue with readline rl_abort not clearing any pending command to execute
This commit is contained in:
@@ -10772,3 +10772,21 @@ lib/readline/isearch.c
|
||||
-----
|
||||
CHANGES,NEWS
|
||||
- updated for bash-5.3-beta
|
||||
|
||||
12/15
|
||||
-----
|
||||
lib/readline/histexpand.c
|
||||
- get_history_event: make sure we don't change history_offset whether
|
||||
the search succeeds or fails, don't set it to history_length.
|
||||
Callers don't expect to have the history offset changed out from
|
||||
under them.
|
||||
Fixes bug reported by Grisha Levit <grishalevit@gmail.com>
|
||||
|
||||
12/16
|
||||
-----
|
||||
lib/readline/util.c
|
||||
- _rl_abort_internal: make sure to clear _rl_command_to_execute
|
||||
Report and patch from Grisha Levit <grishalevit@gmail.com>
|
||||
|
||||
tests/printf7.sub,tests/cond-regexp2.sub
|
||||
- accommodate different error messages across different systems
|
||||
|
||||
@@ -645,6 +645,8 @@ po/ru.po f
|
||||
po/sk.gmo f
|
||||
po/sk.po f
|
||||
po/sl.gmo f
|
||||
po/sq.po f
|
||||
po/sq.gmo f
|
||||
po/sr.po f
|
||||
po/sr.gmo f
|
||||
po/sl.po f
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ $END
|
||||
#define UNSETOPT 0
|
||||
#define SETOPT 1
|
||||
|
||||
#define OPTFMT "%-15s\t%s\n"
|
||||
#define OPTFMT "%-25s %s\n"
|
||||
|
||||
extern int allow_null_glob_expansion, fail_glob_expansion, glob_dot_filenames;
|
||||
extern int cdable_vars, mail_warning, source_uses_path;
|
||||
|
||||
@@ -1448,6 +1448,13 @@ array variables.
|
||||
Namerefs can be unset using the \fB\-n\fP option to the \fBunset\fP builtin.
|
||||
Otherwise, if \fBunset\fP is executed with the name of a nameref variable
|
||||
as an argument, the variable referenced by the nameref variable is unset.
|
||||
.PP
|
||||
When the shell starts, it reads its environment and creates a shell
|
||||
variable from each environment variable that has a valid name,
|
||||
as described below
|
||||
(see
|
||||
.SM
|
||||
.BR ENVIRONMENT ).
|
||||
.SS Positional Parameters
|
||||
A
|
||||
.I positional parameter
|
||||
|
||||
@@ -1852,6 +1852,10 @@ Namerefs can be unset using the @option{-n} option to the @code{unset} builtin
|
||||
Otherwise, if @code{unset} is executed with the name of a nameref variable
|
||||
as an argument, the variable referenced by the nameref variable is unset.
|
||||
|
||||
When the shell starts, it reads its environment and creates a shell
|
||||
variable from each environment variable that has a valid name,
|
||||
as described below (@pxref{Environment}).
|
||||
|
||||
@node Positional Parameters
|
||||
@subsection Positional Parameters
|
||||
@cindex parameters, positional
|
||||
|
||||
@@ -141,7 +141,7 @@ get_history_event (const char *string, int *caller_index, int delimiting_quote)
|
||||
register char c;
|
||||
HIST_ENTRY *entry;
|
||||
int which, sign, local_index, substring_okay;
|
||||
int search_flags;
|
||||
int search_flags, old_offset;
|
||||
char *temp;
|
||||
|
||||
/* The event can be specified in a number of ways.
|
||||
@@ -251,9 +251,10 @@ get_history_event (const char *string, int *caller_index, int delimiting_quote)
|
||||
|
||||
*caller_index = i;
|
||||
|
||||
old_offset = history_offset; /* XXX */
|
||||
#define FAIL_SEARCH() \
|
||||
do { \
|
||||
history_offset = history_length; xfree (temp) ; return (char *)NULL; \
|
||||
history_offset = old_offset; xfree (temp) ; return (char *)NULL; \
|
||||
} while (0)
|
||||
|
||||
/* If there is no search string, try to use the previous search string,
|
||||
@@ -282,7 +283,7 @@ get_history_event (const char *string, int *caller_index, int delimiting_quote)
|
||||
entry = current_history ();
|
||||
if (entry == 0)
|
||||
FAIL_SEARCH ();
|
||||
history_offset = history_length;
|
||||
history_offset = old_offset; /* XXX - was history_length */
|
||||
|
||||
/* If this was a substring search, then remember the
|
||||
string that we matched for word substitution. */
|
||||
|
||||
@@ -112,6 +112,7 @@ _rl_abort_internal (void)
|
||||
RL_UNSETSTATE (RL_STATE_MULTIKEY); /* XXX */
|
||||
|
||||
rl_last_func = (rl_command_func_t *)NULL;
|
||||
_rl_command_to_execute = 0;
|
||||
|
||||
_rl_longjmp (_rl_top_level, 1);
|
||||
return (0);
|
||||
|
||||
@@ -574,8 +574,9 @@ termsig_sighandler (int sig)
|
||||
/* Set the event hook so readline will call it after the signal handlers
|
||||
finish executing, so if this interrupted character input we can get
|
||||
quick response. If readline is active or has modified the terminal we
|
||||
need to set this no matter what the signal is, though the check for
|
||||
RL_STATE_TERMPREPPED is possibly redundant. */
|
||||
need to set this no matter what the signal is; the check for
|
||||
RL_STATE_TERMPREPPED is to handle the cases where we get a terminating
|
||||
signal that readline *doesn't* handle while readline is executing. */
|
||||
if (RL_ISSTATE (RL_STATE_SIGHANDLER) || RL_ISSTATE (RL_STATE_TERMPREPPED))
|
||||
bashline_set_event_hook ();
|
||||
else if (RL_ISSTATE (RL_STATE_COMPLETING|RL_STATE_DISPATCHING))
|
||||
|
||||
+9
-9
@@ -23,27 +23,27 @@ JOBaa bb cc ddCONTROL
|
||||
NOTFOUND
|
||||
./comsub2.tests: line 75: p: command not found
|
||||
./comsub2.tests: line 75: p: command not found
|
||||
expand_aliases off
|
||||
expand_aliases off
|
||||
expand_aliases off
|
||||
expand_aliases off
|
||||
outside:
|
||||
./comsub2.tests: line 79: alias: p: not found
|
||||
alias e='echo inside redefine'
|
||||
expand_aliases off
|
||||
expand_aliases off
|
||||
1
|
||||
expand_aliases on
|
||||
expand_aliases on
|
||||
2
|
||||
expand_aliases on
|
||||
expand_aliases on
|
||||
outside:
|
||||
./comsub2.tests: line 89: alias: p: not found
|
||||
expand_aliases on
|
||||
expand_aliases on
|
||||
1
|
||||
xx
|
||||
expand_aliases on
|
||||
expand_aliases on
|
||||
2
|
||||
xx
|
||||
expand_aliases on
|
||||
expand_aliases on
|
||||
outside:
|
||||
expand_aliases on
|
||||
expand_aliases on
|
||||
inside: 12 22 42
|
||||
outside: 42 2
|
||||
newlines
|
||||
|
||||
+25
-5
@@ -11,25 +11,45 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
: ${TMPDIR:=/tmp}
|
||||
TMPF=$TMPDIR/cond-invalid-$RANDOM
|
||||
|
||||
cond_invalid()
|
||||
{
|
||||
local r;
|
||||
rm -f "$TMPF"
|
||||
line=$1 ; shift
|
||||
lhs=$1 ; shift
|
||||
rhs=$1 ; shift
|
||||
|
||||
[[ $lhs =~ $rhs ]] 2>"$TMPF"
|
||||
r=$?
|
||||
if [ ! -s "$TMPF" ]; then
|
||||
echo "cond-regexp2.sub: $line: expected invalid regexp error output to stderr" >&2
|
||||
fi
|
||||
rm -f "$TMPF"
|
||||
return $r;
|
||||
}
|
||||
|
||||
[[ "\\" =~ ["."] ]] && echo bad 1
|
||||
|
||||
[[ "\\" =~ "[.]" ]] && echo bad 2
|
||||
|
||||
[[ "\\" =~ [\. ]] && echo bad 3
|
||||
cond_invalid $LINENO '\\' '[\.' && echo bad 3
|
||||
|
||||
[[ "\\" =~ [\.] ]] && echo bad 4
|
||||
|
||||
[[ "\\" =~ [\\] ]] || echo bad 5
|
||||
|
||||
[[ x =~ [z-a] ]] && echo bad 6
|
||||
cond_invalid $LINENO x '[z-a]' && echo bad 6
|
||||
|
||||
[[ x =~ [[:invalid:]abc] ]] && echo bad 7
|
||||
cond_invalid $LINENO x '[[:invalid:]abc]' && echo bad 7
|
||||
|
||||
exp='x\'
|
||||
[[ x =~ $exp ]] && echo bad 8
|
||||
cond_invalid $LINENO x "$exp" && echo bad 8
|
||||
|
||||
exp='a(xb'
|
||||
[[ x =~ $exp ]] && echo bad 9
|
||||
cond_invalid $LINENO x "$exp" && echo bad 9
|
||||
|
||||
[[ dog =~ [[=d=]].. ]] && echo ok 1
|
||||
[[ d.. =~ [[=d=]]\.\. ]] && echo ok 2
|
||||
|
||||
@@ -84,11 +84,6 @@ match control-a 2
|
||||
match control-a 3
|
||||
match control-a 4
|
||||
match control-a 5
|
||||
./cond-regexp2.sub: line 18: [[: invalid regular expression `[\.': brackets ([ ]) not balanced
|
||||
./cond-regexp2.sub: line 24: [[: invalid regular expression `[z-a]': invalid character range
|
||||
./cond-regexp2.sub: line 26: [[: invalid regular expression `[[:invalid:]abc]': invalid character class
|
||||
./cond-regexp2.sub: line 29: [[: invalid regular expression `x\': trailing backslash (\)
|
||||
./cond-regexp2.sub: line 32: [[: invalid regular expression `a(xb': parentheses not balanced
|
||||
ok 1
|
||||
ok 2
|
||||
ok 3
|
||||
|
||||
+1
-1
@@ -79,7 +79,7 @@ this is ohio-state
|
||||
1
|
||||
0
|
||||
testb
|
||||
expand_aliases on
|
||||
expand_aliases on
|
||||
1
|
||||
1
|
||||
1
|
||||
|
||||
+6
-6
@@ -182,10 +182,10 @@ no dotglob: .a .foo bar
|
||||
? . .. .a .foo
|
||||
*
|
||||
bar
|
||||
extglob off
|
||||
extglob off
|
||||
x
|
||||
extglob off
|
||||
extglob off
|
||||
extglob off
|
||||
extglob off
|
||||
extglob off
|
||||
extglob off
|
||||
extglob off
|
||||
extglob off
|
||||
extglob off
|
||||
extglob off
|
||||
|
||||
@@ -374,38 +374,21 @@ hello --
|
||||
0000000 340 262 207 040 040 040 055 055 055 012
|
||||
000000a
|
||||
[][]
|
||||
./printf7.sub: line 20: printf: 21474836470: Result too large
|
||||
[]
|
||||
./printf7.sub: line 21: printf: 21474836470: Result too large
|
||||
[X]
|
||||
./printf7.sub: line 23: printf: 21474836470: Result too large
|
||||
VAR=[]
|
||||
./printf7.sub: line 26: printf: 21474836470: Result too large
|
||||
VAR=[X]
|
||||
./printf7.sub: line 32: printf: 9223372036854775825: Result too large
|
||||
[]
|
||||
./printf7.sub: line 33: printf: 9223372036854775825: Result too large
|
||||
[X]
|
||||
./printf7.sub: line 35: printf: 9223372036854775825: Result too large
|
||||
VAR=[]
|
||||
./printf7.sub: line 38: printf: 9223372036854775825: Result too large
|
||||
VAR=[X]
|
||||
./printf7.sub: line 44: printf: 21474836470: Result too large
|
||||
[]
|
||||
./printf7.sub: line 45: printf: 21474836470: Result too large
|
||||
[X]
|
||||
./printf7.sub: line 47: printf: 21474836470: Result too large
|
||||
VAR=[]
|
||||
./printf7.sub: line 50: printf: 21474836470: Result too large
|
||||
VAR=[X]
|
||||
./printf7.sub: line 56: printf: 9223372036854775825: Result too large
|
||||
[]
|
||||
./printf7.sub: line 57: printf: 9223372036854775825: Result too large
|
||||
[X]
|
||||
./printf7.sub: line 59: printf: 9223372036854775825: Result too large
|
||||
VAR=[]
|
||||
./printf7.sub: line 62: printf: 9223372036854775825: Result too large
|
||||
VAR=[X]
|
||||
XY
|
||||
./printf7.sub: line 72: printf: 9223372036854775825: Result too large
|
||||
XY
|
||||
|
||||
+37
-18
@@ -12,54 +12,72 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
: ${TMPDIR:=/tmp}
|
||||
TMPF=$TMPDIR/printf-oflow-$RANDOM
|
||||
|
||||
printf_overflow ()
|
||||
{
|
||||
local r;
|
||||
|
||||
line=$1 ; shift
|
||||
rm -f "$TMPF"
|
||||
printf "$@" 2>$TMPF
|
||||
r=$?
|
||||
if [ ! -s "$TMPF" ]; then
|
||||
echo "printf7.sub: $line: expected overflow error output to stderr" >&2
|
||||
fi
|
||||
rm -f "$TMPF"
|
||||
return $r
|
||||
}
|
||||
|
||||
# tests of integer overflow for field width and precision arguments
|
||||
INT_MAX=$(getconf INT_MAX 2>/dev/null)
|
||||
[ -z "$INT_MAX" ] && INT_MAX=2147483647 # assume 32 bits
|
||||
TOOBIG=$(( $INT_MAX * 10 ))
|
||||
TOOBIG=${INT_MAX}0 # effectively multiply by 10
|
||||
|
||||
printf '[%*s]\n' "${TOOBIG}"
|
||||
printf '[%*s]\n' "${TOOBIG}" X
|
||||
printf_overflow $LINENO '[%*s]\n' "${TOOBIG}"
|
||||
printf_overflow $LINENO '[%*s]\n' "${TOOBIG}" X
|
||||
|
||||
printf -v VAR '[%*s]' "${TOOBIG}"
|
||||
printf_overflow $LINENO -v VAR '[%*s]' "${TOOBIG}"
|
||||
echo VAR="$VAR"
|
||||
unset -v VAR
|
||||
printf -v VAR '[%*s]' "${TOOBIG}" X
|
||||
printf_overflow $LINENO -v VAR '[%*s]' "${TOOBIG}" X
|
||||
echo VAR="$VAR"
|
||||
unset -v VAR
|
||||
|
||||
TOOBIG=9223372036854775825
|
||||
|
||||
printf '[%*s]\n' "${TOOBIG}"
|
||||
printf '[%*s]\n' "${TOOBIG}" X
|
||||
printf_overflow $LINENO '[%*s]\n' "${TOOBIG}"
|
||||
printf_overflow $LINENO '[%*s]\n' "${TOOBIG}" X
|
||||
|
||||
printf -v VAR '[%*s]' "${TOOBIG}"
|
||||
printf_overflow $LINENO -v VAR '[%*s]' "${TOOBIG}"
|
||||
echo VAR="$VAR"
|
||||
unset -v VAR
|
||||
printf -v VAR '[%*s]' "${TOOBIG}" X
|
||||
printf_overflow $LINENO -v VAR '[%*s]' "${TOOBIG}" X
|
||||
echo VAR="$VAR"
|
||||
unset -v VAR
|
||||
|
||||
TOOBIG=$(( $INT_MAX * 10 ))
|
||||
|
||||
printf '[%.*s]\n' "${TOOBIG}"
|
||||
printf '[%.*s]\n' "${TOOBIG}" X
|
||||
printf_overflow $LINENO '[%.*s]\n' "${TOOBIG}"
|
||||
printf_overflow $LINENO '[%.*s]\n' "${TOOBIG}" X
|
||||
|
||||
printf -v VAR '[%.*s]' "${TOOBIG}"
|
||||
printf_overflow $LINENO -v VAR '[%.*s]' "${TOOBIG}"
|
||||
echo VAR="$VAR"
|
||||
unset -v VAR
|
||||
printf -v VAR '[%.*s]' "${TOOBIG}" X
|
||||
printf_overflow $LINENO -v VAR '[%.*s]' "${TOOBIG}" X
|
||||
echo VAR="$VAR"
|
||||
unset -v VAR
|
||||
|
||||
TOOBIG=9223372036854775825
|
||||
|
||||
printf '[%.*s]\n' "${TOOBIG}"
|
||||
printf '[%.*s]\n' "${TOOBIG}" X
|
||||
printf_overflow $LINENO '[%.*s]\n' "${TOOBIG}"
|
||||
printf_overflow $LINENO '[%.*s]\n' "${TOOBIG}" X
|
||||
|
||||
printf -v VAR '[%.*s]' "${TOOBIG}"
|
||||
printf_overflow $LINENO -v VAR '[%.*s]' "${TOOBIG}"
|
||||
echo VAR="$VAR"
|
||||
unset -v VAR
|
||||
printf -v VAR '[%.*s]' "${TOOBIG}" X
|
||||
printf_overflow $LINENO -v VAR '[%.*s]' "${TOOBIG}" X
|
||||
echo VAR="$VAR"
|
||||
unset -v VAR
|
||||
|
||||
@@ -69,4 +87,5 @@ unset -v VAR
|
||||
#printf "%.${TOOBIG}s\n" XY
|
||||
printf -v VAR "%.${TOOBIG}s\n" XY
|
||||
echo $VAR
|
||||
printf "%.${TOOBIG}Q\n" XY
|
||||
unset -v VAR
|
||||
printf_overflow $LINENO "%.${TOOBIG}Q\n" XY
|
||||
|
||||
+47
-47
@@ -126,51 +126,51 @@ shopt -u shift_verbose
|
||||
shopt -u varredir_close
|
||||
shopt -u xpg_echo
|
||||
--
|
||||
array_expand_once off
|
||||
assoc_expand_once off
|
||||
autocd off
|
||||
bash_source_fullpath off
|
||||
cdable_vars off
|
||||
checkhash off
|
||||
checkjobs off
|
||||
checkwinsize off
|
||||
compat31 off
|
||||
compat32 off
|
||||
compat40 off
|
||||
compat41 off
|
||||
compat42 off
|
||||
compat43 off
|
||||
compat44 off
|
||||
direxpand off
|
||||
dirspell off
|
||||
dotglob off
|
||||
execfail off
|
||||
extdebug off
|
||||
extglob off
|
||||
failglob off
|
||||
globstar off
|
||||
gnu_errfmt off
|
||||
histappend off
|
||||
histreedit off
|
||||
histverify off
|
||||
huponexit off
|
||||
inherit_errexit off
|
||||
lastpipe off
|
||||
lithist off
|
||||
localvar_inherit off
|
||||
localvar_unset off
|
||||
login_shell off
|
||||
mailwarn off
|
||||
no_empty_cmd_completion off
|
||||
nocaseglob off
|
||||
nocasematch off
|
||||
noexpand_translation off
|
||||
nullglob off
|
||||
progcomp_alias off
|
||||
restricted_shell off
|
||||
shift_verbose off
|
||||
varredir_close off
|
||||
xpg_echo off
|
||||
array_expand_once off
|
||||
assoc_expand_once off
|
||||
autocd off
|
||||
bash_source_fullpath off
|
||||
cdable_vars off
|
||||
checkhash off
|
||||
checkjobs off
|
||||
checkwinsize off
|
||||
compat31 off
|
||||
compat32 off
|
||||
compat40 off
|
||||
compat41 off
|
||||
compat42 off
|
||||
compat43 off
|
||||
compat44 off
|
||||
direxpand off
|
||||
dirspell off
|
||||
dotglob off
|
||||
execfail off
|
||||
extdebug off
|
||||
extglob off
|
||||
failglob off
|
||||
globstar off
|
||||
gnu_errfmt off
|
||||
histappend off
|
||||
histreedit off
|
||||
histverify off
|
||||
huponexit off
|
||||
inherit_errexit off
|
||||
lastpipe off
|
||||
lithist off
|
||||
localvar_inherit off
|
||||
localvar_unset off
|
||||
login_shell off
|
||||
mailwarn off
|
||||
no_empty_cmd_completion off
|
||||
nocaseglob off
|
||||
nocasematch off
|
||||
noexpand_translation off
|
||||
nullglob off
|
||||
progcomp_alias off
|
||||
restricted_shell off
|
||||
shift_verbose off
|
||||
varredir_close off
|
||||
xpg_echo off
|
||||
--
|
||||
set +o allexport
|
||||
set -o braceexpand
|
||||
@@ -310,5 +310,5 @@ xtrace off
|
||||
--
|
||||
./shopt.tests: line 106: shopt: xyz1: invalid shell option name
|
||||
./shopt.tests: line 107: shopt: xyz1: invalid option name
|
||||
expand_aliases on
|
||||
expand_aliases on
|
||||
expand_aliases on
|
||||
expand_aliases on
|
||||
|
||||
+3
-3
@@ -270,9 +270,9 @@ declare -x v="x"
|
||||
declare -x v="t"
|
||||
declare -- v
|
||||
declare -x v
|
||||
ignoreeof on
|
||||
ignoreeof off
|
||||
ignoreeof on
|
||||
ignoreeof on
|
||||
ignoreeof off
|
||||
ignoreeof on
|
||||
10
|
||||
local -
|
||||
match 1
|
||||
|
||||
@@ -613,7 +613,11 @@ trap_handler (int sig)
|
||||
/* Set the event hook so readline will call it after the signal handlers
|
||||
finish executing, so if this interrupted character input we can get
|
||||
quick response. */
|
||||
#if 1
|
||||
if (RL_ISSTATE (RL_STATE_SIGHANDLER))
|
||||
#else
|
||||
if (RL_ISSTATE (RL_STATE_SIGHANDLER) || RL_ISSTATE (RL_STATE_TERMPREPPED))
|
||||
#endif
|
||||
bashline_set_event_hook ();
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user