summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChet Ramey <chet.ramey@case.edu>2023-01-20 14:31:00 -0500
committerChet Ramey <chet.ramey@case.edu>2023-01-20 14:31:00 -0500
commita37b2af98533ace0ca90b3a2187481ee08e2615f (patch)
treeafa99a2c3e1a3dfc072d79203ab4e39c2a38a996
parent992bd861ab509f5a4783f90d40a590c8f7fd772a (diff)
downloadbash-a37b2af9.tar.gz
fix terminal pgrp issue with async jobs in non-interactive shells; history_expand change to first argument
-rw-r--r--CWRU/CWRU.chlog17
-rw-r--r--MANIFEST1
-rw-r--r--jobs.c6
-rw-r--r--lib/readline/doc/history.310
-rw-r--r--lib/readline/doc/history.texi2
-rw-r--r--lib/readline/doc/hstech.texi4
-rw-r--r--lib/readline/doc/version.texi8
-rw-r--r--lib/readline/histexpand.c4
-rw-r--r--lib/readline/history.h2
-rw-r--r--tests/alias.right14
-rw-r--r--tests/alias.tests1
-rw-r--r--tests/alias7.sub92
12 files changed, 144 insertions, 17 deletions
diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog
index b02adc8..ebf5eaf 100644
--- a/CWRU/CWRU.chlog
+++ b/CWRU/CWRU.chlog
@@ -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
diff --git a/MANIFEST b/MANIFEST
index 6e015e4..534429f 100644
--- 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 70b2fd4..d6552a3 100644
--- 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);
}
diff --git a/lib/readline/doc/history.3 b/lib/readline/doc/history.3
index 06419cf..082bf42 100644
--- a/lib/readline/doc/history.3
+++ b/lib/readline/doc/history.3
@@ -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
diff --git a/lib/readline/doc/history.texi b/lib/readline/doc/history.texi
index 721118b..c15e957 100644
--- a/lib/readline/doc/history.texi
+++ b/lib/readline/doc/history.texi
@@ -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
diff --git a/lib/readline/doc/hstech.texi b/lib/readline/doc/hstech.texi
index da6417b..7a6d762 100644
--- a/lib/readline/doc/hstech.texi
+++ b/lib/readline/doc/hstech.texi
@@ -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
diff --git a/lib/readline/doc/version.texi b/lib/readline/doc/version.texi
index d310273..0d4af12 100644
--- a/lib/readline/doc/version.texi
+++ b/lib/readline/doc/version.texi
@@ -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
diff --git a/lib/readline/histexpand.c b/lib/readline/histexpand.c
index 4e9d447..38a4953 100644
--- a/lib/readline/histexpand.c
+++ b/lib/readline/histexpand.c
@@ -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
diff --git a/lib/readline/history.h b/lib/readline/history.h
index 5208f9a..9c2b099 100644
--- a/lib/readline/history.h
+++ b/lib/readline/history.h
@@ -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
diff --git a/tests/alias.right b/tests/alias.right
index 76f3207..5dbc5d3 100644
--- a/tests/alias.right
+++ b/tests/alias.right
@@ -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=
diff --git a/tests/alias.tests b/tests/alias.tests
index 15eac5b..fd390c2 100644
--- a/tests/alias.tests
+++ b/tests/alias.tests
@@ -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
index 0000000..b2aeb15
--- /dev/null
+++ b/tests/alias7.sub
@@ -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