sync patches from bash community

(cherry picked from commit 29e54f0dd4a637d33f40ffc8c73b3be719c5b926)
This commit is contained in:
wangyuhang 2023-12-15 10:14:59 +08:00 committed by openeuler-sync-bot
parent d7f5e5330c
commit d16be25dc1
6 changed files with 304 additions and 1 deletions

View File

@ -0,0 +1,54 @@
From 8418224f32f4dda85019cae063370c18bbd2d036 Mon Sep 17 00:00:00 2001
From: Chet Ramey <chet.ramey@case.edu>
Date: Tue, 25 Jul 2023 10:18:35 -0400
Subject: [PATCH] changes for quoting special and multibyte characters in glob
patterns; changes to filename unicode normalization on macOS for globbing and
filename completion; send SIGCONT unconditionally to just-restarted job in
fg/bg
Conflict:partial round, only added function bashline_set_filename_hooks for this round
Reference:https://git.savannah.gnu.org/cgit/bash.git/commit/?id=8418224f32f4dda85019cae063370c18bbd2d036
---
bashline.c | 13 +++++++++++++
bashline.h | 1 +
2 files changed, 14 insertions(+)
diff --git a/bashline.c b/bashline.c
index a0e9044..4799de2 100644
--- a/bashline.c
+++ b/bashline.c
@@ -3257,6 +3257,19 @@ restore_directory_hook (hookf)
rl_directory_rewrite_hook = hookf;
}
+/* Set the readline hooks that affect how directories and filenames are
+ converted. Extern so other parts of the shell can use. */
+void
+bashline_set_filename_hooks (void)
+{
+ /* Tell the completer that we might want to follow symbolic links or
+ do other expansion on directory names. */
+ set_directory_hook ();
+
+ rl_filename_rewrite_hook = bash_filename_rewrite_hook;
+ rl_filename_stat_hook = bash_filename_stat_hook;
+}
+
/* Check whether not DIRNAME, with any trailing slash removed, exists. If
SHOULD_DEQUOTE is non-zero, we dequote the directory name first. */
static int
diff --git a/bashline.h b/bashline.h
index 48c9fec..7dfa913 100644
--- a/bashline.h
+++ b/bashline.h
@@ -53,6 +53,7 @@ extern int unbind_unix_command PARAMS((char *));
extern char **bash_default_completion PARAMS((const char *, int, int, int, int));
+extern void bashline_set_filename_hooks (void);
void set_directory_hook PARAMS((void));
/* Used by programmable completion code. */
--
2.33.0

View File

@ -0,0 +1,86 @@
From fe24a6a55e8850298b496c5b9d82f1866eba190e Mon Sep 17 00:00:00 2001
From: Chet Ramey <chet.ramey@case.edu>
Date: Mon, 30 Oct 2023 12:16:07 -0400
Subject: [PATCH] changes to SIGINT handler while waiting for a child; skip
vertical whitespace after translating an integer
Conflict:partial round, only the modified content of jobs.c is rounded.
Reference:https://git.savannah.gnu.org/cgit/bash.git/commit/?id=fe24a6a55e8850298b496c5b9d82f1866eba190e
---
jobs.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/jobs.c b/jobs.c
index 7c3b6e8..c22ac9f 100644
--- a/jobs.c
+++ b/jobs.c
@@ -2727,6 +2727,10 @@ wait_for_background_pids (ps)
#define INVALID_SIGNAL_HANDLER (SigHandler *)wait_for_background_pids
static SigHandler *old_sigint_handler = INVALID_SIGNAL_HANDLER;
+/* The current SIGINT handler as set by restore_sigint_handler. Only valid
+ immediately after restore_sigint_handler, used for continuations. */
+static SigHandler *cur_sigint_handler = INVALID_SIGNAL_HANDLER;
+
static int wait_sigint_received;
static int child_caught_sigint;
@@ -2743,6 +2747,7 @@ wait_sigint_cleanup ()
static void
restore_sigint_handler ()
{
+ cur_sigint_handler = old_sigint_handler;
if (old_sigint_handler != INVALID_SIGNAL_HANDLER)
{
set_signal_handler (SIGINT, old_sigint_handler);
@@ -2766,8 +2771,7 @@ wait_sigint_handler (sig)
restore_sigint_handler ();
/* If we got a SIGINT while in `wait', and SIGINT is trapped, do
what POSIX.2 says (see builtins/wait.def for more info). */
- if (this_shell_builtin && this_shell_builtin == wait_builtin &&
- signal_is_trapped (SIGINT) &&
+ if (signal_is_trapped (SIGINT) &&
((sigint_handler = trap_to_sighandler (SIGINT)) == trap_handler))
{
trap_handler (SIGINT); /* set pending_traps[SIGINT] */
@@ -2790,6 +2794,8 @@ wait_sigint_handler (sig)
{
set_exit_status (128+SIGINT);
restore_sigint_handler ();
+ if (cur_sigint_handler == INVALID_SIGNAL_HANDLER)
+ set_sigint_handler (); /* XXX - only do this in one place */
kill (getpid (), SIGINT);
}
@@ -2934,15 +2940,15 @@ wait_for (pid, flags)
{
SigHandler *temp_sigint_handler;
- temp_sigint_handler = set_signal_handler (SIGINT, wait_sigint_handler);
- if (temp_sigint_handler == wait_sigint_handler)
+ temp_sigint_handler = old_sigint_handler;
+ old_sigint_handler = set_signal_handler (SIGINT, wait_sigint_handler);
+ if (old_sigint_handler == wait_sigint_handler)
{
#if defined (DEBUG)
internal_warning ("wait_for: recursively setting old_sigint_handler to wait_sigint_handler: running_trap = %d", running_trap);
#endif
+ old_sigint_handler = temp_sigint_handler;
}
- else
- old_sigint_handler = temp_sigint_handler;
waiting_for_child = 0;
if (old_sigint_handler == SIG_IGN)
set_signal_handler (SIGINT, old_sigint_handler);
@@ -4148,7 +4154,7 @@ set_job_status_and_cleanup (job)
SIGINT (if we reset the sighandler to the default).
In this case, we have to fix things up. What a crock. */
if (temp_handler == trap_handler && signal_is_trapped (SIGINT) == 0)
- temp_handler = trap_to_sighandler (SIGINT);
+ temp_handler = trap_to_sighandler (SIGINT);
restore_sigint_handler ();
if (temp_handler == SIG_DFL)
termsig_handler (SIGINT); /* XXX */
--
2.33.0

View File

@ -0,0 +1,88 @@
From 09c32bc946baad7364b30abb491f72f7728b56d9 Mon Sep 17 00:00:00 2001
From: Chet Ramey <chet.ramey@case.edu>
Date: Tue, 10 Oct 2023 12:00:19 -0400
Subject: [PATCH] fix for @E transformation; fixes for failures in arith for
and for commands; style changes to man page; fix for bug in read builtin if
it assigns to IFS
Conflict:partial round, only the modified content of execute_cmd.c is rounded.
Reference:https://git.savannah.gnu.org/cgit/bash.git/commit/?id=09c32bc946baad7364b30abb491f72f7728b56d9
---
execute_cmd.c | 25 +++++++------------------
1 file changed, 7 insertions(+), 18 deletions(-)
diff --git a/execute_cmd.c b/execute_cmd.c
index a855376..71d147c 100644
--- a/execute_cmd.c
+++ b/execute_cmd.c
@@ -2837,8 +2837,11 @@ execute_for_command (for_command)
#endif
save_line_number = line_number;
+ line_number = for_command->line; /* for expansion error messages */
+
if (check_identifier (for_command->name, 1) == 0)
{
+ line_number = save_line_number;
if (posixly_correct && interactive_shell == 0)
{
last_command_exit_value = EX_BADUSAGE;
@@ -2850,7 +2853,6 @@ execute_for_command (for_command)
loop_level++;
identifier = for_command->name->word;
- line_number = for_command->line; /* for expansion error messages */
list = releaser = expand_words_no_vars (for_command->map_list);
begin_unwind_frame ("for");
@@ -3075,13 +3077,8 @@ execute_arith_for_command (arith_for_command)
/* Evaluate the initialization expression. */
expresult = eval_arith_for_expr (arith_for_command->init, &expok);
- if (expok == 0)
- {
- line_number = save_lineno;
- return (EXECUTION_FAILURE);
- }
- while (1)
+ while (expok)
{
/* Evaluate the test expression. */
line_number = arith_lineno;
@@ -3089,10 +3086,8 @@ execute_arith_for_command (arith_for_command)
line_number = save_lineno;
if (expok == 0)
- {
- body_status = EXECUTION_FAILURE;
- break;
- }
+ break;
+
REAP ();
if (expresult == 0)
break;
@@ -3120,18 +3115,12 @@ execute_arith_for_command (arith_for_command)
line_number = arith_lineno;
expresult = eval_arith_for_expr (arith_for_command->step, &expok);
line_number = save_lineno;
-
- if (expok == 0)
- {
- body_status = EXECUTION_FAILURE;
- break;
- }
}
loop_level--;
line_number = save_lineno;
- return (body_status);
+ return (expok ? body_status : EXECUTION_FAILURE);
}
#endif
--
2.33.0

View File

@ -0,0 +1,28 @@
From f6a78e24d8928574fb239978c10d3509619271a2 Mon Sep 17 00:00:00 2001
From: Chet Ramey <chet.ramey@case.edu>
Date: Fri, 28 Jul 2023 11:35:44 -0400
Subject: [PATCH] fixes for $LINENO in multi-line simple commands; printf
out-of-range values now cause a non-zero return status
Conflict:partial round, only the modified content of builtins/complete.def is rounded.
Reference:https://git.savannah.gnu.org/cgit/bash.git/commit/?id=f6a78e24d8928574fb239978c10d3509619271a2
---
builtins/complete.def | 2 +
1 files changed, 2 insertions(+)
diff --git a/builtins/complete.def b/builtins/complete.def
index 74d966d5..aeae2438 100644
--- a/builtins/complete.def
+++ b/builtins/complete.def
@@ -724,6 +724,8 @@ compgen_builtin (WORD_LIST *list)
rval = EXECUTION_FAILURE;
+ bashline_set_filename_hooks ();
+
/* probably don't have to save these, just being safe */
old_line = pcomp_line;
old_ind = pcomp_ind;
--
2.33.0

View File

@ -0,0 +1,32 @@
From b30389070ab27e0429a7c16bae492afd1a8b0f6c Mon Sep 17 00:00:00 2001
From: Chet Ramey <chet.ramey@case.edu>
Date: Mon, 6 Nov 2023 09:26:02 -0500
Subject: [PATCH] renamed several functions beginning with legal_; changed all
callers
Conflict:partial round, only the modified content of brace_expand_word_list is rounded.
Reference:https://git.savannah.gnu.org/cgit/bash.git/commit/?id=b30389070ab27e0429a7c16bae492afd1a8b0f6c
---
subst.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/subst.c b/subst.c
index 779bed3..a5429f4 100644
--- a/subst.c
+++ b/subst.c
@@ -11526,6 +11526,12 @@ brace_expand_word_list (tlist, eflags)
if (mbschr (tlist->word->word, LBRACE))
{
expansions = brace_expand (tlist->word->word);
+ if (expansions == 0)
+ {
+ expansions = strvec_create (2);
+ expansions[0] = savestring (tlist->word->word);
+ expansions[1] = NULL;
+ }
for (eindex = 0; temp_string = expansions[eindex]; eindex++)
{
--
2.33.0

View File

@ -8,7 +8,7 @@
Name: bash
Version: 5.1.8
Release: 11
Release: 12
Summary: It is the Bourne Again Shell
License: GPLv3
URL: https://www.gnu.org/software/bash
@ -47,6 +47,11 @@ Patch6008: backport-fixes-for-array-subscripts-and-values-containing-0x0.patch
Patch6009: backport-fix-for-nofork-comsub-command-printing-fix-for-crash.patch
Patch6010: backport-fix-small-memleak-in-globbing.patch
Patch6011: backport-fix-for-leak-when-completing-command-word-with-glob-.patch
Patch6012: backport-fix-for-E-transformation-fixes-for-failures-in-arith.patch
Patch6013: backport-changes-for-quoting-special-and-multibyte-characters.patch
Patch6014: backport-fixes-for-LINENO-in-multi-line-simple-commands-print.patch
Patch6015: backport-changes-to-SIGINT-handler-while-waiting-for-a-child-.patch
Patch6016: backport-renamed-several-functions-beginning-with-legal_-chan.patch
BuildRequires: gcc bison texinfo autoconf ncurses-devel
# Required for bash tests
@ -166,6 +171,16 @@ make check
%exclude %{_infodir}/dir
%changelog
* Fri Dec 15 2023 wangyuhang <wangyuhang27@huawei.com> -5.1.8-12
- Type:bugfix
- ID:NA
- SUG:NA
- DESC: add backport-fix-for-E-transformation-fixes-for-failures-in-arith.patch
backport-changes-for-quoting-special-and-multibyte-characters.patch
backport-fixes-for-LINENO-in-multi-line-simple-commands-print.patch
backport-changes-to-SIGINT-handler-while-waiting-for-a-child-.patch
backport-renamed-several-functions-beginning-with-legal_-chan.patch
* Tue Oct 17 2023 wangyuhang <wangyuhang27@huawei.com> -5.1.8-11
- Type:bugfix
- ID:NA