fix to RL_STATE_EOF in readline callback mode; fix to edge case for terminating signal handling and exit traps in -c command

This commit is contained in:
Chet Ramey
2022-05-03 10:43:44 -04:00
parent d0cd67ee13
commit f9ed510acb
15 changed files with 103 additions and 30 deletions
+24 -1
View File
@@ -3590,4 +3590,27 @@ parse.y
4/27
----
lib/sh/strvis.c
- strivs: changes to handle being compiled without multibyte support
- sh_charvis: changes to handle being compiled without multibyte support
4/29
----
lib/readline/callback.c
- rl_callback_read_char: don't set rl_eof_found unless eof is > 0,
since it can be -3 if we need to read more input in a multi-key
sequence. Report from Andrew Burgess <aburgess@redhat.com>
examples/loadables/Makefile.sample.in
- new file, containing the rules to build the example shared object
- includes Makefile.inc from wherever it's installed. Suggested by
Robert E. Griffith <bobg@junga.com>
examples/loadables/Makefile.inc.in
- remove rules that create the example shared object
4/30
----
builtins/evalstring.c
- parse_and_execute: check for terminating signals before returning,
after any longjmp, to improve responsiveness and fix the -c code
path before running any exit trap. Report from
Emanuele Torre <torreemanuele6@gmail.com>
+1
View File
@@ -717,6 +717,7 @@ examples/loadables/template.c f
examples/loadables/loadables.h f
examples/loadables/Makefile.in f
examples/loadables/Makefile.inc.in f
examples/loadables/Makefile.sample.in f
examples/loadables/necho.c f
examples/loadables/hello.c f
examples/loadables/asort.c f
+3 -2
View File
@@ -468,7 +468,8 @@ INSTALLED_HEADERS = shell.h bashjmp.h command.h syntax.h general.h error.h \
make_cmd.h subst.h sig.h externs.h builtins.h \
bashtypes.h xmalloc.h config-top.h config-bot.h \
bashintl.h bashansi.h bashjmp.h alias.h hashlib.h \
conftypes.h unwind_prot.h jobs.h siglist.h
conftypes.h unwind_prot.h jobs.h siglist.h \
execute_cmd.h
INSTALLED_BUILTINS_HEADERS = bashgetopt.h common.h getopt.h
INSTALLED_INCFILES = posixstat.h ansi_stdlib.h filecntl.h posixdir.h \
memalloc.h stdc.h posixjmp.h posixwait.h posixtime.h systimes.h \
@@ -570,7 +571,7 @@ CREATED_MAKEFILES = Makefile builtins/Makefile doc/Makefile \
lib/readline/Makefile lib/glob/Makefile \
lib/sh/Makefile lib/tilde/Makefile lib/malloc/Makefile \
lib/termcap/Makefile examples/loadables/Makefile \
examples/loadables/Makefile.inc \
examples/loadables/Makefile.inc examples/loadables/Makefile.sample \
examples/loadables/perl/Makefile support/Makefile \
lib/intl/Makefile po/Makefile po/Makefile.in
CREATED_HEADERS = signames.h config.h pathnames.h version.h y.tab.h \
+1 -1
View File
@@ -53,7 +53,7 @@ extern int unbind_unix_command PARAMS((char *));
extern char **bash_default_completion PARAMS((const char *, int, int, int, int));
void set_directory_hook PARAMS((void));
extern void set_directory_hook PARAMS((void));
/* Used by programmable completion code. */
extern char *command_word_completion_function PARAMS((const char *, int));
+3 -2
View File
@@ -426,7 +426,7 @@ parse_and_execute (string, from_file, flags)
break;
}
}
if (parse_command () == 0)
{
if ((flags & SEVAL_PARSEONLY) || (interactive_shell == 0 && read_but_dont_execute))
@@ -561,6 +561,8 @@ parse_and_execute (string, from_file, flags)
throw_to_top_level ();
}
CHECK_TERMSIG;
if (should_jump_to_top_level)
jump_to_top_level (code);
@@ -594,7 +596,6 @@ parse_string (string, from_file, flags, cmdp, endp)
sigprocmask (SIG_BLOCK, (sigset_t *)NULL, (sigset_t *)&ps_sigmask);
#endif
/*itrace("parse_string: `%s'", string);*/
/* Reset the line number if the caller wants us to. If we don't reset the
line number, we have to subtract one, because we will add one just
before executing the next command (resetting the line number sets it to
Vendored
+3 -2
View File
@@ -1,5 +1,5 @@
#! /bin/sh
# From configure.ac for Bash 5.2, version 5.040.
# From configure.ac for Bash 5.2, version 5.041.
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.71 for bash 5.2-beta.
#
@@ -21863,7 +21863,7 @@ fi
#AC_SUBST(ALLOCA_SOURCE)
#AC_SUBST(ALLOCA_OBJECT)
ac_config_files="$ac_config_files Makefile builtins/Makefile lib/readline/Makefile lib/glob/Makefile lib/intl/Makefile lib/malloc/Makefile lib/sh/Makefile lib/termcap/Makefile lib/tilde/Makefile doc/Makefile support/Makefile po/Makefile.in examples/loadables/Makefile examples/loadables/Makefile.inc examples/loadables/perl/Makefile support/bash.pc support/bashbug.sh"
ac_config_files="$ac_config_files Makefile builtins/Makefile lib/readline/Makefile lib/glob/Makefile lib/intl/Makefile lib/malloc/Makefile lib/sh/Makefile lib/termcap/Makefile lib/tilde/Makefile doc/Makefile support/Makefile po/Makefile.in examples/loadables/Makefile examples/loadables/Makefile.inc examples/loadables/Makefile.sample examples/loadables/perl/Makefile support/bash.pc support/bashbug.sh"
ac_config_commands="$ac_config_commands stamp-h"
@@ -22586,6 +22586,7 @@ do
"po/Makefile.in") CONFIG_FILES="$CONFIG_FILES po/Makefile.in" ;;
"examples/loadables/Makefile") CONFIG_FILES="$CONFIG_FILES examples/loadables/Makefile" ;;
"examples/loadables/Makefile.inc") CONFIG_FILES="$CONFIG_FILES examples/loadables/Makefile.inc" ;;
"examples/loadables/Makefile.sample") CONFIG_FILES="$CONFIG_FILES examples/loadables/Makefile.sample" ;;
"examples/loadables/perl/Makefile") CONFIG_FILES="$CONFIG_FILES examples/loadables/perl/Makefile" ;;
"support/bash.pc") CONFIG_FILES="$CONFIG_FILES support/bash.pc" ;;
"support/bashbug.sh") CONFIG_FILES="$CONFIG_FILES support/bashbug.sh" ;;
+2 -1
View File
@@ -21,7 +21,7 @@ dnl Process this file with autoconf to produce a configure script.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
AC_REVISION([for Bash 5.2, version 5.040])dnl
AC_REVISION([for Bash 5.2, version 5.041])dnl
define(bashvers, 5.2)
define(relstatus, beta)
@@ -1316,6 +1316,7 @@ AC_CONFIG_FILES([Makefile builtins/Makefile lib/readline/Makefile \
lib/tilde/Makefile doc/Makefile support/Makefile \
po/Makefile.in examples/loadables/Makefile \
examples/loadables/Makefile.inc \
examples/loadables/Makefile.sample \
examples/loadables/perl/Makefile \
support/bash.pc support/bashbug.sh])
+4 -3
View File
@@ -5,12 +5,12 @@
.\" Case Western Reserve University
.\" chet.ramey@case.edu
.\"
.\" Last Change: Fri Mar 11 10:16:50 EST 2022
.\" Last Change: Mon May 2 09:00:07 EDT 2022
.\"
.\" bash_builtins, strip all but Built-Ins section
.if \n(zZ=1 .ig zZ
.if \n(zY=1 .ig zY
.TH BASH 1 "2022 March 11" "GNU Bash 5.2"
.TH BASH 1 "2022 May 2" "GNU Bash 5.2"
.\"
.\" There's some problem with having a `@'
.\" in a tagged paragraph with the BSD man macros.
@@ -589,7 +589,8 @@ The
variable may be used to specify the format of
the time information.
.PP
Each command in a pipeline is executed in a \fIsubshell\fP, which is a
Each command in a multi-command
pipeline is executed in a \fIsubshell\fP, which is a
separate process.
See
.SM
+2 -1
View File
@@ -801,7 +801,8 @@ the time information.
If the pipeline is not executed asynchronously (@pxref{Lists}), the
shell waits for all commands in the pipeline to complete.
Each command in a pipeline is executed in its own @dfn{subshell}, which is a
Each command in a multi-command
pipeline is executed in its own @dfn{subshell}, which is a
separate process (@pxref{Command Execution Environment}).
If the @code{lastpipe} option is enabled using the @code{shopt} builtin
(@pxref{The Shopt Builtin}),
+3 -3
View File
@@ -2,10 +2,10 @@
Copyright (C) 1988-2022 Free Software Foundation, Inc.
@end ignore
@set LASTCHANGE Mon Apr 11 17:04:12 EDT 2022
@set LASTCHANGE Mon May 2 08:59:39 EDT 2022
@set EDITION 5.2
@set VERSION 5.2
@set UPDATED 11 April 2022
@set UPDATED-MONTH April 2022
@set UPDATED 2 May 2022
@set UPDATED-MONTH May 2022
+5 -3
View File
@@ -249,7 +249,7 @@ pushd.c: ${topdir}/builtins/pushd.def
pushd.o: pushd.c
$(RM) $@
$(SHOBJ_CC) -DHAVE_CONFIG_H -DPUSHD_AND_POPD -DLOADABLE_BUILTIN $(SHOBJ_CFLAGS) $(CFLAGS) $(CPPFLAGS) $(INC) -c -o $@ $<
$(SHOBJ_CC) -Wno-format-security -DHAVE_CONFIG_H -DPUSHD_AND_POPD -DLOADABLE_BUILTIN $(SHOBJ_CFLAGS) $(CFLAGS) $(CPPFLAGS) $(INC) -c -o $@ $<
pushd: pushd.o
$(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ pushd.o $(SHOBJ_LIBS)
@@ -262,7 +262,7 @@ mostlyclean: clean
-( cd perl && ${MAKE} ${MFLAGS} $@ )
distclean maintainer-clean: clean
$(RM) Makefile Makefile.inc pushd.c
$(RM) Makefile Makefile.inc Makefile.sample pushd.c
-( cd perl && ${MAKE} ${MFLAGS} $@ )
installdirs:
@@ -270,6 +270,7 @@ installdirs:
install-dev: installdirs
@$(INSTALL_DATA) Makefile.inc $(DESTDIR)$(loadablesdir)/Makefile.inc
@$(INSTALL_DATA) Makefile.sample $(DESTDIR)$(loadablesdir)/Makefile.sample
@$(INSTALL_DATA) $(srcdir)/loadables.h $(DESTDIR)$(loadablesdir)/loadables.h
@( cd $(BUILD_DIR) && ${MAKE} ${MFLAGS} DESTDIR="$(DESTDIR)" install-headers)
@@ -281,7 +282,8 @@ install-supported: all installdirs install-dev
done
uninstall-dev:
-$(RM) $(DESTDIR)$(loadablesdir)/Makefile.inc $(DESTDIR)$(loadablesdir)/loadables.h
-$(RM) $(DESTDIR)$(loadablesdir)/Makefile.inc $(DESTDIR)$(loadablesdir)/Makefile.sample
-$(RM) $(DESTDIR)$(loadablesdir)/loadables.h
-( cd $(BUILD_DIR) && ${MAKE} ${MFLAGS} DESTDIR="$(DESTDIR)" uninstall-headers)
uninstall-supported: uninstall-dev
+1 -8
View File
@@ -1,7 +1,7 @@
#
# Sample makefile for bash loadable builtin development
#
# Copyright (C) 2015 Free Software Foundation, Inc.
# Copyright (C) 2015-2022 Free Software Foundation, Inc.
# 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
@@ -99,10 +99,3 @@ INC = -I$(headersdir) -I$(headersdir)/include -I$(headersdir)/builtins
.c.o:
$(SHOBJ_CC) $(SHOBJ_CFLAGS) $(CCFLAGS) $(INC) -c -o $@ $<
all: example
example: example.o
$(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ example.o $(SHOBJ_LIBS)
example.o: example.c
+44
View File
@@ -0,0 +1,44 @@
#
# Sample makefile for bash loadable builtin development
#
# Copyright (C) 2022 Free Software Foundation, Inc.
# 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/>.
#
# these should match the ones in Makefile.in (for the make install target)
prefix = @prefix@
exec_prefix = @exec_prefix@
libdir = @libdir@
# ${loadablesdir} is where the example loadable builtins and data files
# are installed (make install target in Makefile.in)
loadablesdir = @loadablesdir@
DESTDIR =
# include Makefile.inc for all boilerplate definitions
include $(DESTDIR)$(loadablesdir)/Makefile.inc
# here, `example' is the name of the shared object
# replace `example' with the appropriate filename
all: example
example: example.o
$(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ example.o $(SHOBJ_LIBS)
example.o: example.c
+2 -1
View File
@@ -181,7 +181,8 @@ printargs (list, ofp)
for (sawc = 0, l = list; l; l = l->next)
{
ostr = ansicstr (l->word->word, strlen (l->word->word), 0, &sawc, (int *)0);
fprintf (ofp, "%s", ostr);
if (ostr)
fprintf (ofp, "%s", ostr);
free (ostr);
if (sawc)
return (0);
+5 -2
View File
@@ -279,8 +279,11 @@ rl_callback_read_char (void)
}
/* Make sure application hooks can see whether we saw EOF. */
if (rl_eof_found = eof)
RL_SETSTATE(RL_STATE_EOF);
if (eof > 0)
{
rl_eof_found = eof;
RL_SETSTATE(RL_STATE_EOF);
}
if (rl_done)
{