]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
fix to RL_STATE_EOF in readline callback mode; fix to edge case for terminating signa...
authorChet Ramey <chet.ramey@case.edu>
Tue, 3 May 2022 14:43:44 +0000 (10:43 -0400)
committerChet Ramey <chet.ramey@case.edu>
Tue, 3 May 2022 14:43:44 +0000 (10:43 -0400)
15 files changed:
CWRU/CWRU.chlog
MANIFEST
Makefile.in
bashline.h
builtins/evalstring.c
configure
configure.ac
doc/bash.1
doc/bashref.texi
doc/version.texi
examples/loadables/Makefile.in
examples/loadables/Makefile.inc.in
examples/loadables/Makefile.sample.in [new file with mode: 0644]
examples/loadables/print.c
lib/readline/callback.c

index 6fbaa4355dc9f94c63863b4b4aa57d6fadc40711..eb1934e0a5ab86092954259bbbdedcd1ac48dea4 100644 (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>
index e907c78b6abc1ab9133a44e23ed4dad693d86e7e..86c3a104ec36901935fbda7e195cfa83653dc6ce 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -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
index ef26d7083ffa5d12177eea1629dda963d1247fa3..5fc3644cf9e549e38e09e919556be52f456bc817 100644 (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 \
index 48c9fecfb64bce51c202034673276c0937512cd8..d40228e29f1aebc1d1d8b47e1b18808fa5d26b0e 100644 (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));
index 5088151a698b4f6b5c852d8fd9791b40b719e660..7023eb320b96dd7bf90f85c31f1effd0059da22f 100644 (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
index 792e922abdae190aeffacf820e831c866be9e26b..4ae751c8293e50e30f383ba3e3a3f860f3e50db8 100755 (executable)
--- a/configure
+++ b/configure
@@ -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" ;;
index aee938a310b011785aa79f43c342d820be7409d9..0b41e64756e5a4f2497127a86be0c48b9462dd9a 100644 (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])
 
index e593be658c244785185314f93bcde26b62060009..900a17a243c003173082007813b6e107a620a6be 100644 (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
index 6d136d757d32813655a6fc7e75ce715778400055..5a110ece963afd277c7d185c568ebbbd3a096755 100644 (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}),
index c04e2a7294fb5484c3ffbb04e12428b5eb17355e..7454574cb6e9ad40e0aeb94fd3834963da22457c 100644 (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
index 60aef04cfa5a6ef7745dfb6ee3ba0660388f2203..a3cf372552b67a5a5643aae0ba949b9cdc5fbc55 100644 (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
index 8b419a78de2a3fd81c02e6a3172a2ceaaa227be1..ee3c30357770e46daebb8341c18197ee4161508c 100644 (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
diff --git a/examples/loadables/Makefile.sample.in b/examples/loadables/Makefile.sample.in
new file mode 100644 (file)
index 0000000..fe9b06a
--- /dev/null
@@ -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
index 0120dbf41bccd7a37b8e2838ca4a6956a1f21f3e..d6c590352bda8f2bfb7bbe840ccc146d8dd4aa31 100644 (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);
index 1a3235f1990eeec168bd82395ce30b31329e7ae5..69df77df709590dcbbec9f05c263d96826f0411a 100644 (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)
        {