sync patches from bash community
This commit is contained in:
parent
89dae67762
commit
931ec39889
@ -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);
|
||||||
|
extern void set_directory_hook PARAMS((void));
|
||||||
|
|
||||||
|
/* Used by programmable completion code. */
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
@ -0,0 +1,85 @@
|
|||||||
|
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 | 24 ++++++++++++++++--------
|
||||||
|
1 file changed, 16 insertions(+), 8 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/jobs.c b/jobs.c
|
||||||
|
index b8373cf5..59c46475 100644
|
||||||
|
--- a/jobs.c
|
||||||
|
+++ b/jobs.c
|
||||||
|
@@ -2664,6 +2664,10 @@ wait_for_background_pids (struct procstat *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;
|
||||||
|
|
||||||
|
@@ -2681,6 +2685,7 @@ wait_sigint_cleanup (void)
|
||||||
|
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);
|
||||||
|
@@ -2703,8 +2708,7 @@ wait_sigint_handler (int 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] */
|
||||||
|
@@ -2727,6 +2731,8 @@ wait_sigint_handler (int 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -2876,11 +2882,13 @@ wait_for (pid_t pid, int flags)
|
||||||
|
{
|
||||||
|
SigHandler *temp_sigint_handler;
|
||||||
|
|
||||||
|
- temp_sigint_handler = set_signal_handler (SIGINT, wait_sigint_handler);
|
||||||
|
- if (temp_sigint_handler == wait_sigint_handler)
|
||||||
|
- internal_debug ("wait_for: recursively setting old_sigint_handler to wait_sigint_handler: running_trap = %d", running_trap);
|
||||||
|
- else
|
||||||
|
- old_sigint_handler = temp_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)
|
||||||
|
+ {
|
||||||
|
+ internal_debug ("wait_for: recursively setting old_sigint_handler to wait_sigint_handler: running_trap = %d", running_trap);
|
||||||
|
+ old_sigint_handler = temp_sigint_handler;
|
||||||
|
+ }
|
||||||
|
waiting_for_child = 0;
|
||||||
|
if (old_sigint_handler == SIG_IGN)
|
||||||
|
set_signal_handler (SIGINT, old_sigint_handler);
|
||||||
|
@@ -4105,7 +4113,7 @@ set_job_status_and_cleanup (int 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
|
||||||
|
|
||||||
@ -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
|
||||||
|
|
||||||
@ -0,0 +1,237 @@
|
|||||||
|
From 35465406cdae9cd4a15e7f6699e657b5d09bf7bd Mon Sep 17 00:00:00 2001
|
||||||
|
From: Chet Ramey <chet.ramey@case.edu>
|
||||||
|
Date: Fri, 2 Feb 2024 14:39:50 -0500
|
||||||
|
Subject: [PATCH] fix for cd when curent directory doesn't exist; fix wait -n
|
||||||
|
in posix mode to delete any job that it returns; fix some variables where
|
||||||
|
readonly can be circumvented; fix some overflows in printf
|
||||||
|
|
||||||
|
Conflict:only the modified content of builtins/printf.def is rounded.
|
||||||
|
Reference:https://git.savannah.gnu.org/cgit/bash.git/commit/?id=35465406cdae9cd4a15e7f6699e657b5d09bf7bd
|
||||||
|
---
|
||||||
|
builtins/printf.def | 122 +++++++++++++++++++++++---------------------
|
||||||
|
1 file changed, 65 insertions(+), 57 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/builtins/printf.def b/builtins/printf.def
|
||||||
|
index 84658c3..96801e4 100644
|
||||||
|
--- a/builtins/printf.def
|
||||||
|
+++ b/builtins/printf.def
|
||||||
|
@@ -1,7 +1,7 @@
|
||||||
|
This file is printf.def, from which is created printf.c.
|
||||||
|
It implements the builtin "printf" in Bash.
|
||||||
|
|
||||||
|
-Copyright (C) 1997-2021 Free Software Foundation, Inc.
|
||||||
|
+Copyright (C) 1997-2024 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of GNU Bash, the Bourne Again SHell.
|
||||||
|
|
||||||
|
@@ -109,6 +109,50 @@ $END
|
||||||
|
extern int errno;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
+/* We free the buffer used by mklong() if it's `too big'. */
|
||||||
|
+#define PRETURN(value) \
|
||||||
|
+ do \
|
||||||
|
+ { \
|
||||||
|
+ QUIT; \
|
||||||
|
+ retval = value; \
|
||||||
|
+ if (conv_bufsize > 4096 ) \
|
||||||
|
+ { \
|
||||||
|
+ free (conv_buf); \
|
||||||
|
+ conv_bufsize = 0; \
|
||||||
|
+ conv_buf = 0; \
|
||||||
|
+ } \
|
||||||
|
+ if (vflag) \
|
||||||
|
+ { \
|
||||||
|
+ SHELL_VAR *v; \
|
||||||
|
+ v = builtin_bind_variable (vname, vbuf, 0); \
|
||||||
|
+ stupidly_hack_special_variables (vname); \
|
||||||
|
+ if (v == 0 || readonly_p (v) || noassign_p (v)) \
|
||||||
|
+ retval = EXECUTION_FAILURE; \
|
||||||
|
+ if (vbsize > 4096) \
|
||||||
|
+ { \
|
||||||
|
+ free (vbuf); \
|
||||||
|
+ vbsize = 0; \
|
||||||
|
+ vbuf = 0; \
|
||||||
|
+ } \
|
||||||
|
+ else if (vbuf) \
|
||||||
|
+ vbuf[0] = 0; \
|
||||||
|
+ } \
|
||||||
|
+ else \
|
||||||
|
+ { \
|
||||||
|
+ if (ferror (stdout) == 0) \
|
||||||
|
+ fflush (stdout); \
|
||||||
|
+ QUIT; \
|
||||||
|
+ if (ferror (stdout)) \
|
||||||
|
+ { \
|
||||||
|
+ sh_wrerror (); \
|
||||||
|
+ clearerr (stdout); \
|
||||||
|
+ retval = EXECUTION_FAILURE; \
|
||||||
|
+ } \
|
||||||
|
+ } \
|
||||||
|
+ return (retval); \
|
||||||
|
+ } \
|
||||||
|
+ while (0)
|
||||||
|
+
|
||||||
|
#define PC(c) \
|
||||||
|
do { \
|
||||||
|
char b[2]; \
|
||||||
|
@@ -124,7 +168,9 @@ extern int errno;
|
||||||
|
#define PF(f, func) \
|
||||||
|
do { \
|
||||||
|
int nw; \
|
||||||
|
- clearerr (stdout); \
|
||||||
|
+ if (vflag == 0) \
|
||||||
|
+ clearerr (stdout); \
|
||||||
|
+ errno = 0; \
|
||||||
|
if (have_fieldwidth && have_precision) \
|
||||||
|
nw = vflag ? vbprintf (f, fieldwidth, precision, func) : printf (f, fieldwidth, precision, func); \
|
||||||
|
else if (have_fieldwidth) \
|
||||||
|
@@ -133,56 +179,17 @@ extern int errno;
|
||||||
|
nw = vflag ? vbprintf (f, precision, func) : printf (f, precision, func); \
|
||||||
|
else \
|
||||||
|
nw = vflag ? vbprintf (f, func) : printf (f, func); \
|
||||||
|
- tw += nw; \
|
||||||
|
- QUIT; \
|
||||||
|
- if (ferror (stdout)) \
|
||||||
|
+ if (nw < 0 || ferror (stdout)) \
|
||||||
|
{ \
|
||||||
|
- sh_wrerror (); \
|
||||||
|
- clearerr (stdout); \
|
||||||
|
- return (EXECUTION_FAILURE); \
|
||||||
|
+ QUIT; \
|
||||||
|
+ if (vflag) \
|
||||||
|
+ builtin_error ("%s", strerror (errno)); \
|
||||||
|
+ PRETURN (EXECUTION_FAILURE); \
|
||||||
|
} \
|
||||||
|
+ tw += nw; \
|
||||||
|
+ QUIT; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
-/* We free the buffer used by mklong() if it's `too big'. */
|
||||||
|
-#define PRETURN(value) \
|
||||||
|
- do \
|
||||||
|
- { \
|
||||||
|
- QUIT; \
|
||||||
|
- if (vflag) \
|
||||||
|
- { \
|
||||||
|
- SHELL_VAR *v; \
|
||||||
|
- v = builtin_bind_variable (vname, vbuf, bindflags); \
|
||||||
|
- stupidly_hack_special_variables (vname); \
|
||||||
|
- if (v == 0 || readonly_p (v) || noassign_p (v)) \
|
||||||
|
- return (EXECUTION_FAILURE); \
|
||||||
|
- } \
|
||||||
|
- if (conv_bufsize > 4096 ) \
|
||||||
|
- { \
|
||||||
|
- free (conv_buf); \
|
||||||
|
- conv_bufsize = 0; \
|
||||||
|
- conv_buf = 0; \
|
||||||
|
- } \
|
||||||
|
- if (vbsize > 4096) \
|
||||||
|
- { \
|
||||||
|
- free (vbuf); \
|
||||||
|
- vbsize = 0; \
|
||||||
|
- vbuf = 0; \
|
||||||
|
- } \
|
||||||
|
- else if (vbuf) \
|
||||||
|
- vbuf[0] = 0; \
|
||||||
|
- if (ferror (stdout) == 0) \
|
||||||
|
- fflush (stdout); \
|
||||||
|
- QUIT; \
|
||||||
|
- if (ferror (stdout)) \
|
||||||
|
- { \
|
||||||
|
- sh_wrerror (); \
|
||||||
|
- clearerr (stdout); \
|
||||||
|
- return (EXECUTION_FAILURE); \
|
||||||
|
- } \
|
||||||
|
- return (value); \
|
||||||
|
- } \
|
||||||
|
- while (0)
|
||||||
|
-
|
||||||
|
#define SKIP1 "#'-+ 0"
|
||||||
|
#define LENMODS "hjlLtz"
|
||||||
|
|
||||||
|
@@ -238,7 +245,7 @@ static int vflag = 0;
|
||||||
|
static int bindflags = 0;
|
||||||
|
static char *vbuf, *vname;
|
||||||
|
static size_t vbsize;
|
||||||
|
-static int vblen;
|
||||||
|
+static size_t vblen;
|
||||||
|
|
||||||
|
static intmax_t tw;
|
||||||
|
|
||||||
|
@@ -315,6 +322,7 @@ printf_builtin (list)
|
||||||
|
return ((v == 0 || readonly_p (v) || noassign_p (v)) ? EXECUTION_FAILURE : EXECUTION_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ /* If the format string is empty after preprocessing, return immediately. */
|
||||||
|
if (list->word->word == 0 || list->word->word[0] == '\0')
|
||||||
|
return (EXECUTION_SUCCESS);
|
||||||
|
|
||||||
|
@@ -324,10 +332,6 @@ printf_builtin (list)
|
||||||
|
|
||||||
|
garglist = orig_arglist = list->next;
|
||||||
|
|
||||||
|
- /* If the format string is empty after preprocessing, return immediately. */
|
||||||
|
- if (format == 0 || *format == 0)
|
||||||
|
- return (EXECUTION_SUCCESS);
|
||||||
|
-
|
||||||
|
/* Basic algorithm is to scan the format string for conversion
|
||||||
|
specifications -- once one is found, find out if the field
|
||||||
|
width or precision is a '*'; if it is, gather up value. Note,
|
||||||
|
@@ -735,7 +739,7 @@ printf_builtin (list)
|
||||||
|
modstart[1] = nextch;
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (ferror (stdout))
|
||||||
|
+ if (vflag == 0 && ferror (stdout))
|
||||||
|
{
|
||||||
|
/* PRETURN will print error message. */
|
||||||
|
PRETURN (EXECUTION_FAILURE);
|
||||||
|
@@ -867,7 +871,7 @@ printstr (fmt, string, len, fieldwidth, precision)
|
||||||
|
for (; padlen < 0; padlen++)
|
||||||
|
PC (' ');
|
||||||
|
|
||||||
|
- return (ferror (stdout) ? -1 : 0);
|
||||||
|
+ return ((vflag == 0 && ferror (stdout)) ? -1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Convert STRING by expanding the escape sequences specified by the
|
||||||
|
@@ -1085,7 +1089,7 @@ vbadd (buf, blen)
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
if (strlen (vbuf) != vblen)
|
||||||
|
- internal_error ("printf:vbadd: vblen (%d) != strlen (vbuf) (%d)", vblen, (int)strlen (vbuf));
|
||||||
|
+ internal_error ("printf:vbadd: vblen (%zu) != strlen (vbuf) (%zu)", vblen, strlen (vbuf));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return vbuf;
|
||||||
|
@@ -1107,6 +1111,8 @@ vbprintf (format, va_alist)
|
||||||
|
SH_VA_START (args, format);
|
||||||
|
blen = vsnprintf (vbuf + vblen, vbsize - vblen, format, args);
|
||||||
|
va_end (args);
|
||||||
|
+ if (blen < 0)
|
||||||
|
+ return (blen);
|
||||||
|
|
||||||
|
nlen = vblen + blen + 1;
|
||||||
|
if (nlen >= vbsize)
|
||||||
|
@@ -1116,6 +1122,8 @@ vbprintf (format, va_alist)
|
||||||
|
SH_VA_START (args, format);
|
||||||
|
blen = vsnprintf (vbuf + vblen, vbsize - vblen, format, args);
|
||||||
|
va_end (args);
|
||||||
|
+ if (blen < 0)
|
||||||
|
+ return (blen);
|
||||||
|
}
|
||||||
|
|
||||||
|
vblen += blen;
|
||||||
|
@@ -1123,7 +1131,7 @@ vbprintf (format, va_alist)
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
if (strlen (vbuf) != vblen)
|
||||||
|
- internal_error ("printf:vbprintf: vblen (%d) != strlen (vbuf) (%d)", vblen, (int)strlen (vbuf));
|
||||||
|
+ internal_error ("printf:vbprintf: vblen (%zu) != strlen (vbuf) (%zu)", vblen, strlen (vbuf));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return (blen);
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
@ -1,78 +1,78 @@
|
|||||||
From 7f7ee0e9c6766ff5d3de542d03c59590c4a5a44a Mon Sep 17 00:00:00 2001
|
From 7f7ee0e9c6766ff5d3de542d03c59590c4a5a44a Mon Sep 17 00:00:00 2001
|
||||||
From: Chet Ramey <chet.ramey@case.edu>
|
From: Chet Ramey <chet.ramey@case.edu>
|
||||||
Date: Mon, 17 Jul 2023 17:35:59 -0400
|
Date: Mon, 17 Jul 2023 17:35:59 -0400
|
||||||
Subject: [PATCH] fix for leak when completing command word with glob pattern
|
Subject: [PATCH] fix for leak when completing command word with glob pattern
|
||||||
that matches multiple files; preserve export attribute when unsetting local
|
that matches multiple files; preserve export attribute when unsetting local
|
||||||
variable in case it is reset; fix for using nl_langinfo when performing
|
variable in case it is reset; fix for using nl_langinfo when performing
|
||||||
charset conversions
|
charset conversions
|
||||||
|
|
||||||
---
|
---
|
||||||
bashline.c | 6 +++++-
|
bashline.c | 6 +++++-
|
||||||
lib/sh/unicode.c | 6 +++++-
|
lib/sh/unicode.c | 6 +++++-
|
||||||
variables.c | 6 ++++++
|
variables.c | 6 ++++++
|
||||||
3 files changed, 16 insertions(+), 2 deletions(-)
|
3 files changed, 16 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
diff --git a/bashline.c b/bashline.c
|
diff --git a/bashline.c b/bashline.c
|
||||||
index c85b05b..2e0c0c7 100644
|
index c85b05b..2e0c0c7 100644
|
||||||
--- a/bashline.c
|
--- a/bashline.c
|
||||||
+++ b/bashline.c
|
+++ b/bashline.c
|
||||||
@@ -2203,7 +2203,11 @@ globword:
|
@@ -2203,7 +2203,11 @@ globword:
|
||||||
local_index = 0;
|
local_index = 0;
|
||||||
|
|
||||||
if (glob_matches[1] && rl_completion_type == TAB) /* multiple matches are bad */
|
if (glob_matches[1] && rl_completion_type == TAB) /* multiple matches are bad */
|
||||||
- return ((char *)NULL);
|
- return ((char *)NULL);
|
||||||
+ {
|
+ {
|
||||||
+ strvec_dispose (glob_matches);
|
+ strvec_dispose (glob_matches);
|
||||||
+ glob_matches = (char **)NULL;
|
+ glob_matches = (char **)NULL;
|
||||||
+ return ((char *)NULL);
|
+ return ((char *)NULL);
|
||||||
+ }
|
+ }
|
||||||
}
|
}
|
||||||
|
|
||||||
while (val = glob_matches[local_index++])
|
while (val = glob_matches[local_index++])
|
||||||
diff --git a/lib/sh/unicode.c b/lib/sh/unicode.c
|
diff --git a/lib/sh/unicode.c b/lib/sh/unicode.c
|
||||||
index d781353..9e3c9da 100644
|
index d781353..9e3c9da 100644
|
||||||
--- a/lib/sh/unicode.c
|
--- a/lib/sh/unicode.c
|
||||||
+++ b/lib/sh/unicode.c
|
+++ b/lib/sh/unicode.c
|
||||||
@@ -35,6 +35,10 @@
|
@@ -35,6 +35,10 @@
|
||||||
# include <iconv.h>
|
# include <iconv.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
+#if HAVE_LANGINFO_CODESET
|
+#if HAVE_LANGINFO_CODESET
|
||||||
+# include <langinfo.h>
|
+# include <langinfo.h>
|
||||||
+#endif
|
+#endif
|
||||||
+
|
+
|
||||||
#include <xmalloc.h>
|
#include <xmalloc.h>
|
||||||
|
|
||||||
#ifndef USHORT_MAX
|
#ifndef USHORT_MAX
|
||||||
@@ -277,7 +281,7 @@ u32cconv (c, s)
|
@@ -277,7 +281,7 @@ u32cconv (c, s)
|
||||||
{
|
{
|
||||||
#if HAVE_LOCALE_CHARSET
|
#if HAVE_LOCALE_CHARSET
|
||||||
charset = locale_charset ();
|
charset = locale_charset ();
|
||||||
-#elif HAVE_NL_LANGINFO
|
-#elif HAVE_NL_LANGINFO
|
||||||
+#elif HAVE_LANGINFO_CODESET
|
+#elif HAVE_LANGINFO_CODESET
|
||||||
charset = nl_langinfo (CODESET);
|
charset = nl_langinfo (CODESET);
|
||||||
#else
|
#else
|
||||||
charset = stub_charset ();
|
charset = stub_charset ();
|
||||||
diff --git a/variables.c b/variables.c
|
diff --git a/variables.c b/variables.c
|
||||||
index 1a0c2c4..f08575a 100644
|
index 1a0c2c4..f08575a 100644
|
||||||
--- a/variables.c
|
--- a/variables.c
|
||||||
+++ b/variables.c
|
+++ b/variables.c
|
||||||
@@ -4016,10 +4016,16 @@ makunbound (name, vc)
|
@@ -4016,10 +4016,16 @@ makunbound (name, vc)
|
||||||
FREE (nameref_cell (old_var));
|
FREE (nameref_cell (old_var));
|
||||||
else
|
else
|
||||||
FREE (value_cell (old_var));
|
FREE (value_cell (old_var));
|
||||||
+#if 0
|
+#if 0
|
||||||
/* Reset the attributes. Preserve the export attribute if the variable
|
/* Reset the attributes. Preserve the export attribute if the variable
|
||||||
came from a temporary environment. Make sure it stays local, and
|
came from a temporary environment. Make sure it stays local, and
|
||||||
make it invisible. */
|
make it invisible. */
|
||||||
old_var->attributes = (exported_p (old_var) && tempvar_p (old_var)) ? att_exported : 0;
|
old_var->attributes = (exported_p (old_var) && tempvar_p (old_var)) ? att_exported : 0;
|
||||||
+#else /* TAG:bash-5.3 look at this again */
|
+#else /* TAG:bash-5.3 look at this again */
|
||||||
+ /* Reset the attributes, but preserve the export attribute.
|
+ /* Reset the attributes, but preserve the export attribute.
|
||||||
+ Make sure it stays local, and make it invisible. */
|
+ Make sure it stays local, and make it invisible. */
|
||||||
+ old_var->attributes = exported_p (old_var) ? att_exported : 0;
|
+ old_var->attributes = exported_p (old_var) ? att_exported : 0;
|
||||||
+#endif
|
+#endif
|
||||||
VSETATTR (old_var, att_local);
|
VSETATTR (old_var, att_local);
|
||||||
VSETATTR (old_var, att_invisible);
|
VSETATTR (old_var, att_invisible);
|
||||||
var_setvalue (old_var, (char *)NULL);
|
var_setvalue (old_var, (char *)NULL);
|
||||||
--
|
--
|
||||||
2.33.0
|
2.33.0
|
||||||
|
|||||||
@ -1,28 +1,28 @@
|
|||||||
From 829aad36dbbeee462fa142fe2c571fd7ab735ba8 Mon Sep 17 00:00:00 2001
|
From 829aad36dbbeee462fa142fe2c571fd7ab735ba8 Mon Sep 17 00:00:00 2001
|
||||||
From: Chet Ramey <chet.ramey@case.edu>
|
From: Chet Ramey <chet.ramey@case.edu>
|
||||||
Date: Mon, 26 Jun 2023 17:09:08 -0400
|
Date: Mon, 26 Jun 2023 17:09:08 -0400
|
||||||
Subject: [PATCH] backport part of patch to fix small memleak in globbing
|
Subject: [PATCH] backport part of patch to fix small memleak in globbing
|
||||||
|
|
||||||
---
|
---
|
||||||
lib/glob/glob.c | 6 ++++++
|
lib/glob/glob.c | 6 ++++++
|
||||||
1 file changed, 6 insertions(+)
|
1 file changed, 6 insertions(+)
|
||||||
|
|
||||||
diff --git a/lib/glob/glob.c b/lib/glob/glob.c
|
diff --git a/lib/glob/glob.c b/lib/glob/glob.c
|
||||||
index b66af85..e4283bd 100644
|
index b66af85..e4283bd 100644
|
||||||
--- a/lib/glob/glob.c
|
--- a/lib/glob/glob.c
|
||||||
+++ b/lib/glob/glob.c
|
+++ b/lib/glob/glob.c
|
||||||
@@ -1446,6 +1446,12 @@ glob_filename (pathname, flags)
|
@@ -1446,6 +1446,12 @@ glob_filename (pathname, flags)
|
||||||
free ((char *) array);
|
free ((char *) array);
|
||||||
else if ((dflags & GX_ALLDIRS) && filename[0] == '*' && filename[1] == '*' && filename[2] == '\0')
|
else if ((dflags & GX_ALLDIRS) && filename[0] == '*' && filename[1] == '*' && filename[2] == '\0')
|
||||||
free (temp_results); /* expanding ** case above */
|
free (temp_results); /* expanding ** case above */
|
||||||
+ else if (array == temp_results)
|
+ else if (array == temp_results)
|
||||||
+ /* If array == temp_results, either we assigned it above or
|
+ /* If array == temp_results, either we assigned it above or
|
||||||
+ glob_dir_to_array returned temp_results because the dirname
|
+ glob_dir_to_array returned temp_results because the dirname
|
||||||
+ was the empty string. In any case, we assume temp_results
|
+ was the empty string. In any case, we assume temp_results
|
||||||
+ has not been freed, and free it here. */
|
+ has not been freed, and free it here. */
|
||||||
+ free (temp_results);
|
+ free (temp_results);
|
||||||
|
|
||||||
if (shouldbreak)
|
if (shouldbreak)
|
||||||
break;
|
break;
|
||||||
--
|
--
|
||||||
2.33.0
|
2.33.0
|
||||||
|
|||||||
@ -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
|
||||||
|
|
||||||
@ -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
|
||||||
|
|
||||||
11
bash.spec
11
bash.spec
@ -1,6 +1,6 @@
|
|||||||
Name: bash
|
Name: bash
|
||||||
Version: 5.2.15
|
Version: 5.2.15
|
||||||
Release: 7
|
Release: 8
|
||||||
Summary: It is the Bourne Again Shell
|
Summary: It is the Bourne Again Shell
|
||||||
License: GPLv3
|
License: GPLv3
|
||||||
URL: https://www.gnu.org/software/bash
|
URL: https://www.gnu.org/software/bash
|
||||||
@ -27,6 +27,12 @@ Patch140: bash-5.1-sw.patch
|
|||||||
Patch6000: backport-fix-for-nofork-comsub-command-printing-fix-for-crash.patch
|
Patch6000: backport-fix-for-nofork-comsub-command-printing-fix-for-crash.patch
|
||||||
Patch6001: backport-fix-small-memleak-in-globbing.patch
|
Patch6001: backport-fix-small-memleak-in-globbing.patch
|
||||||
Patch6002: backport-fix-for-leak-when-completing-command-word-with-glob-.patch
|
Patch6002: backport-fix-for-leak-when-completing-command-word-with-glob-.patch
|
||||||
|
Patch6003: backport-fix-for-E-transformation-fixes-for-failures-in-arith.patch
|
||||||
|
Patch6004: backport-changes-for-quoting-special-and-multibyte-characters.patch
|
||||||
|
Patch6005: backport-fixes-for-LINENO-in-multi-line-simple-commands-print.patch
|
||||||
|
Patch6006: backport-changes-to-SIGINT-handler-while-waiting-for-a-child-.patch
|
||||||
|
Patch6007: backport-renamed-several-functions-beginning-with-legal_-chan.patch
|
||||||
|
Patch6008: backport-fix-for-cd-when-curent-directory-doesn-t-exist-fix-w.patch
|
||||||
|
|
||||||
BuildRequires: gcc bison texinfo autoconf ncurses-devel
|
BuildRequires: gcc bison texinfo autoconf ncurses-devel
|
||||||
# Required for bash tests
|
# Required for bash tests
|
||||||
@ -155,6 +161,9 @@ make check
|
|||||||
%exclude %{_infodir}/dir
|
%exclude %{_infodir}/dir
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Fri Apr 26 2024 wangyuhang <wangyuhang27@huawei.com> -5.2.15-8
|
||||||
|
- sync patches from bash community
|
||||||
|
|
||||||
* Mon Apr 22 2024 wangyuhang <wangyuhang27@huawei.com> -5.2.15-7
|
* Mon Apr 22 2024 wangyuhang <wangyuhang27@huawei.com> -5.2.15-7
|
||||||
- relocations are no longer required.
|
- relocations are no longer required.
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user