]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
fix terminal pgrp issue with async jobs in non-interactive shells; history_expand...
authorChet Ramey <chet.ramey@case.edu>
Fri, 20 Jan 2023 19:31:00 +0000 (14:31 -0500)
committerChet Ramey <chet.ramey@case.edu>
Fri, 20 Jan 2023 19:31:00 +0000 (14:31 -0500)
12 files changed:
CWRU/CWRU.chlog
MANIFEST
jobs.c
lib/readline/doc/history.3
lib/readline/doc/history.texi
lib/readline/doc/hstech.texi
lib/readline/doc/version.texi
lib/readline/histexpand.c
lib/readline/history.h
tests/alias.right
tests/alias.tests
tests/alias7.sub [new file with mode: 0644]

index b02adc8481994765da1c115f3e6511854bb855a6..ebf5eafea42ba78509b154892e02cd4e0f6342e8 100644 (file)
@@ -5088,3 +5088,20 @@ parse.y
          prevents it from being enabled if an alias expansion of more than
          two aliases ends with a space. Fixes issue reported by
          <anonymous4feedback@outlook.com>
+
+                                  1/18
+                                  ----
+jobs.c
+       - wait_for: if we are reaping a background job, don't bother trying to
+         give the terminal back to shell_pgrp -- we never set the terminal's
+         pgrp to that job in the first place. Fixes issue reported by
+         Steffen Nurpmeso <steffen@sdaoden.eu>
+
+                                  1/19
+                                  ----
+lib/readline/{histexpand.c,history.h}
+       - history_expand: first argument is now `const char *'. Request from
+         Simon Marchi <simon.marchi@polymtl.ca>
+
+lib/readline/doc/{history.3,hstech.texi}
+       - history_expansion: change description to note new const first arg
index 6e015e4634e348f7347154c2f677d4c5e4fca0f8..534429fc6714370a2e4fd20ac57a35583f14175b 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -892,6 +892,7 @@ tests/alias3.sub    f
 tests/alias4.sub       f
 tests/alias5.sub       f
 tests/alias6.sub       f
+tests/alias7.sub       f
 tests/alias.right      f
 tests/appendop.tests   f
 tests/appendop1.sub    f
diff --git a/jobs.c b/jobs.c
index 70b2fd4bf5f828016230aadc9e22290c7a3b0bb0..d6552a3e2aee35d2773af5f195f31d8b78cad864 100644 (file)
--- a/jobs.c
+++ b/jobs.c
@@ -3016,9 +3016,11 @@ if (job == NO_JOB)
       /* Don't modify terminal pgrp if we are running in background or a
         subshell.  Make sure subst.c:command_substitute uses the same
         conditions to determine whether or not it should undo this and
-        give the terminal to pipeline_pgrp. */
-      
+        give the terminal to pipeline_pgrp. We don't give the terminal
+        back to shell_pgrp if an async job exits because we never gave it
+        to that job in the first place. */
       if ((flags & JWAIT_NOTERM) == 0 && running_in_background == 0 &&
+         (job == NO_JOB || IS_ASYNC (job) == 0) &&
          (subshell_environment & (SUBSHELL_ASYNC|SUBSHELL_PIPE)) == 0)
        give_terminal_to (shell_pgrp, 0);
     }
index 06419cff564359ef8b3f633a1de83ca148bedfc3..082bf42d6fe82c01d65605fb3593e07ea2353e9c 100644 (file)
@@ -6,9 +6,9 @@
 .\"    Case Western Reserve University
 .\"    chet.ramey@case.edu
 .\"
-.\"    Last Change: Fri Jul 17 09:43:01 EDT 2020
+.\"    Last Change: Thu Jan 19 17:20:59 EST 2023
 .\"
-.TH HISTORY 3 "2020 July 17" "GNU History 8.1"
+.TH HISTORY 3 "2023 January 19" "GNU History 8.2"
 .\"
 .\" File Name macro.  This used to be `.PN', for Path Name,
 .\" but Sun doesn't seem to like that very much.
@@ -40,8 +40,8 @@
 .SH NAME
 history \- GNU History Library
 .SH COPYRIGHT
-.if t The GNU History Library is Copyright \(co 1989-2020 by the Free Software Foundation, Inc.
-.if n The GNU History Library is Copyright (C) 1989-2020 by the Free Software Foundation, Inc.
+.if t The GNU History Library is Copyright \(co 1989-2023 by the Free Software Foundation, Inc.
+.if n The GNU History Library is Copyright (C) 1989-2023 by the Free Software Foundation, Inc.
 .SH DESCRIPTION
 Many programs read input from the user a line at a time.  The GNU
 History library is able to keep track of those lines, associate arbitrary
@@ -530,7 +530,7 @@ Returns 0 on success, or \fBerrno\fP on failure.
 
 These functions implement history expansion.
 
-.Fn2 int history_expand "char *string" "char **output"
+.Fn2 int history_expand "const char *string" "char **output"
 Expand \fIstring\fP, placing the result into \fIoutput\fP, a pointer
 to a string.  Returns:
 .RS
index 721118bce1e8bfb9a9bbf75da627c22fb5ef458e..c15e95779a71a263ef409f87347e98b4e4eeb344 100644 (file)
@@ -12,7 +12,7 @@ This document describes the GNU History library
 a programming tool that provides a consistent user interface for
 recalling lines of previously typed input.
 
-Copyright @copyright{} 1988--2022 Free Software Foundation, Inc.
+Copyright @copyright{} 1988--2023 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
index da6417b48fda487e24853fab3d7176912ba89e10..7a6d7627be933248a24c0b86f1b46e7e1503d704 100644 (file)
@@ -1,7 +1,7 @@
 @ignore
 This file documents the user interface to the GNU History library.
 
-Copyright (C) 1988-2022 Free Software Foundation, Inc.
+Copyright (C) 1988-2023 Free Software Foundation, Inc.
 Authored by Brian Fox and Chet Ramey.
 
 Permission is granted to make and distribute verbatim copies of this manual
@@ -369,7 +369,7 @@ Returns 0 on success, or @code{errno} on failure.
 
 These functions implement history expansion.
 
-@deftypefun int history_expand (char *string, char **output)
+@deftypefun int history_expand (const char *string, char **output)
 Expand @var{string}, placing the result into @var{output}, a pointer
 to a string (@pxref{History Interaction}).  Returns:
 @table @code
index d310273405152877ce211fe53d644851f6fad667..0d4af12e68e394dbcba178cf847eb144dc10bef6 100644 (file)
@@ -1,11 +1,11 @@
 @ignore
-Copyright (C) 1988-2022 Free Software Foundation, Inc. 
+Copyright (C) 1988-2023 Free Software Foundation, Inc. 
 @end ignore
 
 @set EDITION 8.2
 @set VERSION 8.2
 
-@set UPDATED 19 September 2022
-@set UPDATED-MONTH September 2022
+@set UPDATED 19 January 2023
+@set UPDATED-MONTH January 2023
 
-@set LASTCHANGE Mon Sep 19 11:15:16 EDT 2022
+@set LASTCHANGE Thu Jan 19 17:22:06 EST 2023
index 4e9d4477be2a52d6baa43c0c3a36468a2384116d..38a4953137180aec3f7af22975857b273b7fa442 100644 (file)
@@ -904,7 +904,7 @@ history_expand_internal (const char *string, int start, int qc, int *end_index_p
        while (0)
 
 int
-history_expand (char *hstring, char **output)
+history_expand (const char *hstring, char **output)
 {
   int j;
   int i, r, passc, cc, modified, eindex, only_printing, dquote, squote, flag;
@@ -966,7 +966,7 @@ history_expand (char *hstring, char **output)
       memset (&ps, 0, sizeof (mbstate_t));
 #endif
 
-      string = hstring;
+      string = (char *)hstring;
       /* If not quick substitution, still maybe have to do expansion. */
 
       /* `!' followed by one of the characters in history_no_expand_chars
index 5208f9a463b2a18c5a6e9ee32d120980e989eaaf..9c2b099041de22e61b8404faae065f3aaa92a4d4 100644 (file)
@@ -232,7 +232,7 @@ extern int history_truncate_file (const char *, int);
 
   If an error occurred in expansion, then OUTPUT contains a descriptive
   error message. */
-extern int history_expand (char *, char **);
+extern int history_expand (const char *, char **);
 
 /* Extract a string segment consisting of the FIRST through LAST
    arguments present in STRING.  Arguments are broken up as in
index 76f32076fb5529fbaf736cc098cd0455c4acd258..5dbc5d3211bfe1e2f322f4c9fc799cc269ebecfa 100644 (file)
@@ -43,3 +43,17 @@ bar
 baz
 <áa>
 <aá>
+bar
+foo bar x
+foo
+x
+bar
+x
+bar
+x
+foo=v bar=
+foo
+foo in v
+bash: -c: line 7: syntax error near unexpected token `do'
+bash: -c: line 7: `do echo foo=$foo bar=$bar'
+foo=v bar=
index 15eac5b176b652b2564c1fd27647d81eff6ce1e8..fd390c20e77210d264814bff62bf09045606ffba 100644 (file)
@@ -63,3 +63,4 @@ ${THIS_SH} ./alias3.sub
 ${THIS_SH} ./alias4.sub
 ${THIS_SH} ./alias5.sub
 ${THIS_SH} ./alias6.sub
+${THIS_SH} ./alias7.sub
diff --git a/tests/alias7.sub b/tests/alias7.sub
new file mode 100644 (file)
index 0000000..b2aeb15
--- /dev/null
@@ -0,0 +1,92 @@
+#   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/>.
+#
+
+# Change bash to expand the next word following aliases ending with a space
+# that are more than one level deep. Change how bash handles the expand-next-word
+# flag when recognizing a reserved word.
+#
+# Bash never did this before post-bash-5.2
+
+: ${THIS_SH:=./bash}
+
+shopt -s expand_aliases 2>/dev/null
+
+alias a1='echo '
+alias a2=a1
+
+alias foo=bar
+alias x=xtra
+
+a2 foo
+unalias foo
+
+alias e='echo '
+alias f='foo '
+alias b=bar
+
+e f b x
+
+alias e=echo
+
+a2 foo;e x
+
+unalias e f b
+
+alias e=echo
+alias foo='bar '
+alias c=';'
+
+a2 foo c e x
+
+unalias foo e c
+
+alias file='/dev/null ;'
+alias e=echo
+alias foo='bar '
+alias c='< '
+alias x=xtra
+a2 foo c file e x
+
+unalias a1 a2 e foo c x file
+
+alias foo=bar
+
+alias al=' '
+alias foo=bar
+
+al for foo in v
+do echo foo=$foo bar=$bar
+done
+
+al case foo in foo) echo foo;; bar) echo bar;; esac
+
+# one difference between bash in default and posix modes is that default mode
+# bash allows reserved words to be aliased, which posix says is a no-no
+
+${THIS_SH} -c '
+shopt -s expand_aliases 2>/dev/null
+alias al=" "
+alias foo=bar
+alias for=echo
+al for foo in v
+do echo foo=$foo bar=$bar
+done' bash
+
+${THIS_SH} -o posix -c '
+alias al=" "
+alias foo=bar
+alias for=echo
+al for foo in v
+do echo foo=$foo bar=$bar
+done' bash