Update to bash-5.2

- Remove bash-infotags.patch as it's in upstream now.

Resolves: #2129927
This commit is contained in:
Siteshwar Vashisht 2022-10-04 10:27:14 +02:00
parent c38410696d
commit 068c9df7a0
27 changed files with 91 additions and 1115 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@ bash-4.1.tar.gz
/bash-4.4.tar.gz /bash-4.4.tar.gz
/bash-5.0.tar.gz /bash-5.0.tar.gz
/bash-5.1.tar.gz /bash-5.1.tar.gz
/bash-5.2.tar.gz

View File

@ -1,6 +1,7 @@
--- bash-3.0/config-top.h.paths 2003-08-05 15:36:12.000000000 +0100 diff --git a/config-top.h b/config-top.h
+++ bash-3.0/config-top.h 2004-07-28 09:36:27.117205637 +0100 --- a/config-top.h
@@ -66,7 +66,7 @@ +++ b/config-top.h
@@ -74,7 +74,7 @@
the Posix.2 confstr () function, or CS_PATH define are not present. */ the Posix.2 confstr () function, or CS_PATH define are not present. */
#ifndef STANDARD_UTILS_PATH #ifndef STANDARD_UTILS_PATH
#define STANDARD_UTILS_PATH \ #define STANDARD_UTILS_PATH \
@ -8,4 +9,4 @@
+ "/bin:/usr/bin:/usr/sbin:/sbin" + "/bin:/usr/bin:/usr/sbin:/sbin"
#endif #endif
/* Default primary and secondary prompt strings. */ /* The default path for enable -f */

View File

@ -1,11 +1,12 @@
--- bash-2.05b/aclocal.m4.pgrp_sync 2002-06-25 14:45:43.000000000 +0100 diff --git a/aclocal.m4 b/aclocal.m4
+++ bash-2.05b/aclocal.m4 2003-01-15 18:17:35.000000000 +0000 --- a/aclocal.m4
@@ -1255,7 +1255,7 @@ +++ b/aclocal.m4
@@ -1324,7 +1324,7 @@ main()
wait(&status); wait(&status);
exit(ok ? 0 : 5); exit(ok ? 0 : 5);
} }
-], bash_cv_pgrp_pipe=no,bash_cv_pgrp_pipe=yes, -]])], [bash_cv_pgrp_pipe=no], [bash_cv_pgrp_pipe=yes],
+], bash_cv_pgrp_pipe=yes,bash_cv_pgrp_pipe=yes, +]])], [bash_cv_pgrp_pipe=yes], [bash_cv_pgrp_pipe=yes],
[AC_MSG_WARN(cannot check pgrp synchronization if cross compiling -- defaulting to no) [AC_MSG_WARN(cannot check pgrp synchronization if cross compiling -- defaulting to no)
bash_cv_pgrp_pipe=no]) bash_cv_pgrp_pipe=no]
]) )])

View File

@ -1,18 +1,18 @@
diff -up bash-4.1/examples/loadables/Makefile.in.examples bash-4.1/examples/loadables/Makefile.in diff --git a/examples/loadables/Makefile.in b/examples/loadables/Makefile.in
--- bash-4.1/examples/loadables/Makefile.in.examples 2010-06-22 16:20:02.000000000 +0200 --- a/examples/loadables/Makefile.in
+++ bash-4.1/examples/loadables/Makefile.in 2010-06-22 16:20:41.000000000 +0200 +++ b/examples/loadables/Makefile.in
@@ -43,7 +43,7 @@ host_os = @host_os@ @@ -59,7 +59,7 @@ host_cpu = @host_cpu@
host_cpu = @host_cpu@
host_vendor = @host_vendor@ host_vendor = @host_vendor@
STYLE_CFLAGS = @STYLE_CFLAGS@
-CFLAGS = @CFLAGS@ -CFLAGS = @CFLAGS@
+CFLAGS = -O2 -g ++CFLAGS = -O2 -g
LOCAL_CFLAGS = @LOCAL_CFLAGS@ LOCAL_CFLAGS = @LOCAL_CFLAGS@
DEFS = @DEFS@ DEFS = @DEFS@
LOCAL_DEFS = @LOCAL_DEFS@ LOCAL_DEFS = @LOCAL_DEFS@
diff -up bash-4.1/examples/loadables/perl/Makefile.in.examples bash-4.1/examples/loadables/perl/Makefile.in diff --git a/examples/loadables/perl/Makefile.in b/examples/loadables/perl/Makefile.in
--- bash-4.1/examples/loadables/perl/Makefile.in.examples 2010-06-22 16:20:46.000000000 +0200 --- a/examples/loadables/perl/Makefile.in
+++ bash-4.1/examples/loadables/perl/Makefile.in 2010-06-22 16:21:04.000000000 +0200 +++ b/examples/loadables/perl/Makefile.in
@@ -42,7 +42,7 @@ SHELL = @MAKE_SHELL@ @@ -42,7 +42,7 @@ SHELL = @MAKE_SHELL@
PERL5 = perl5 PERL5 = perl5

View File

@ -1,21 +1,20 @@
diff --git a/parse.y b/parse.y diff --git a/parse.y b/parse.y
index df1231d..2449fa8 100644
--- a/parse.y --- a/parse.y
+++ b/parse.y +++ b/parse.y
@@ -4482,6 +4482,8 @@ xparse_dolparen (base, string, indp, flags) @@ -4255,7 +4255,8 @@ xparse_dolparen (base, string, indp, flags)
save_parser_state (&ps); save_parser_state (&ps);
save_input_line_state (&ls); save_input_line_state (&ls);
orig_eof_token = shell_eof_token; -
+ /* avoid echoing every substitution again */ + /* avoid echoing every substitution again */
+ echo_input_at_read = 0; + echo_input_at_read = 0;
#if defined (ALIAS) || defined (DPAREN_ARITHMETIC) #if defined (ALIAS) || defined (DPAREN_ARITHMETIC)
saved_pushed_strings = pushed_string_list; /* separate parsing context */
pushed_string_list = (STRING_SAVER *)NULL; pushed_string_list = (STRING_SAVER *)NULL;
#endif
diff --git a/subst.c b/subst.c diff --git a/subst.c b/subst.c
index 9ccbf33..8a9ee5c 100644
--- a/subst.c --- a/subst.c
+++ b/subst.c +++ b/subst.c
@@ -9453,6 +9453,7 @@ param_expand (string, sindex, quoted, expanded_something, @@ -10222,6 +10222,7 @@ param_expand (string, sindex, quoted, expanded_something,
WORD_LIST *list, *l; WORD_LIST *list, *l;
WORD_DESC *tdesc, *ret; WORD_DESC *tdesc, *ret;
int tflag, nullarg; int tflag, nullarg;
@ -23,7 +22,7 @@ index 9ccbf33..8a9ee5c 100644
/*itrace("param_expand: `%s' pflags = %d", string+*sindex, pflags);*/ /*itrace("param_expand: `%s' pflags = %d", string+*sindex, pflags);*/
zindex = *sindex; zindex = *sindex;
@@ -9843,6 +9844,9 @@ arithsub: @@ -10614,6 +10615,9 @@ arithsub:
} }
comsub: comsub:
@ -33,7 +32,7 @@ index 9ccbf33..8a9ee5c 100644
if (pflags & PF_NOCOMSUB) if (pflags & PF_NOCOMSUB)
/* we need zindex+1 because string[zindex] == RPAREN */ /* we need zindex+1 because string[zindex] == RPAREN */
temp1 = substring (string, *sindex, zindex+1); temp1 = substring (string, *sindex, zindex+1);
@@ -9855,6 +9859,7 @@ comsub: @@ -10626,6 +10630,7 @@ comsub:
} }
FREE (temp); FREE (temp);
temp = temp1; temp = temp1;

View File

@ -1,9 +1,9 @@
diff --git a/doc/bash.1 b/doc/bash.1 diff --git a/doc/bash.1 b/doc/bash.1
--- a/doc/bash.1 --- a/doc/bash.1
+++ b/doc/bash.1 +++ b/doc/bash.1
@@ -9889,6 +9889,9 @@ If set, the @@ -10726,6 +10726,9 @@ If set, the shell automatically closes file descriptors assigned using the
to find the directory containing the file supplied as an argument. .el above)
This option is enabled by default. instead of leaving them open when the command completes.
.TP 8 .TP 8
+.B syslog_history +.B syslog_history
+If set, command history is logged to syslog. +If set, command history is logged to syslog.

View File

@ -1,50 +0,0 @@
diff --git a/Makefile.in b/Makefile.in
--- a/Makefile.in
+++ b/Makefile.in
@@ -1315,6 +1315,7 @@ bashline.o: trap.h flags.h assoc.h $(BASHINCDIR)/ocache.h
bashline.o: $(DEFSRC)/common.h $(GLOB_LIBSRC)/glob.h alias.h
bashline.o: pcomplete.h ${BASHINCDIR}/chartypes.h input.h
bashline.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
+bashline.o: ${DEFDIR}/builtext.h
bracecomp.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
bracecomp.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h
bracecomp.o: command.h ${BASHINCDIR}/stdc.h error.h
@@ -1435,6 +1436,7 @@ builtins/evalstring.o: quit.h unwind_prot.h ${BASHINCDIR}/maxpath.h jobs.h built
builtins/evalstring.o: dispose_cmd.h make_cmd.h subst.h externs.h
builtins/evalstring.o: jobs.h builtins.h flags.h input.h execute_cmd.h
builtins/evalstring.o: bashhist.h $(DEFSRC)/common.h pathnames.h
+builtins/evalstring.o: ${DEFDIR}/builtext.h
builtins/getopt.o: config.h ${BASHINCDIR}/memalloc.h
builtins/getopt.o: shell.h syntax.h bashjmp.h command.h general.h xmalloc.h error.h
builtins/getopt.o: variables.h arrayfunc.h conftypes.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
diff --git a/builtins/Makefile.in b/builtins/Makefile.in
--- a/builtins/Makefile.in
+++ b/builtins/Makefile.in
@@ -361,7 +361,7 @@ evalstring.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
evalstring.o: $(topdir)/externs.h $(topdir)/jobs.h $(topdir)/builtins.h
evalstring.o: $(topdir)/flags.h $(topdir)/input.h $(topdir)/execute_cmd.h
evalstring.o: $(topdir)/bashhist.h $(srcdir)/common.h
-evalstring.o: $(topdir)/trap.h $(topdir)/redir.h ../pathnames.h
+evalstring.o: $(topdir)/trap.h $(topdir)/redir.h ../pathnames.h ./builtext.h
#evalstring.o: $(topdir)/y.tab.h
getopt.o: ../config.h $(BASHINCDIR)/memalloc.h
getopt.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/bashjmp.h $(topdir)/command.h
diff --git a/patchlevel.h b/patchlevel.h
--- a/patchlevel.h
+++ b/patchlevel.h
@@ -1,6 +1,6 @@
/* patchlevel.h -- current bash patch level */
-/* Copyright (C) 2001-2016 Free Software Foundation, Inc.
+/* Copyright (C) 2001-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -25,6 +25,6 @@
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
looks for to find the patch level (for the sccs version string). */
-#define PATCHLEVEL 0
+#define PATCHLEVEL 1
#endif /* _PATCHLEVEL_H_ */

View File

@ -1,49 +0,0 @@
From 910fcdc415abeb3d7d85fb46ee0d3e804a4c47a6 Mon Sep 17 00:00:00 2001
From: Chet Ramey <chet.ramey@case.edu>
Date: Wed, 17 Nov 2021 16:45:23 -0500
Subject: [PATCH] Bash-5.1 patch 10: fix for wait -n being interrupted by a
trapped signal
---
builtins/wait.def | 5 ++++-
patchlevel.h | 2 +-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/builtins/wait.def b/builtins/wait.def
index 824c83fe..e70a4d94 100644
--- a/builtins/wait.def
+++ b/builtins/wait.def
@@ -111,7 +111,8 @@ int
wait_builtin (list)
WORD_LIST *list;
{
- int status, code, opt, nflag, wflags;
+ int status, code, opt, nflag;
+ volatile int wflags;
char *vname;
SHELL_VAR *pidvar;
struct procstat pstat;
@@ -180,6 +181,8 @@ wait_builtin (list)
last_command_exit_signal = wait_signal_received;
status = 128 + wait_signal_received;
wait_sigint_cleanup ();
+ if (wflags & JWAIT_WAITING)
+ unset_waitlist ();
WAIT_RETURN (status);
}
diff --git a/patchlevel.h b/patchlevel.h
index 17586ff7..75246e44 100644
--- a/patchlevel.h
+++ b/patchlevel.h
@@ -25,6 +25,6 @@
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
looks for to find the patch level (for the sccs version string). */
-#define PATCHLEVEL 9
+#define PATCHLEVEL 10
#endif /* _PATCHLEVEL_H_ */
--
2.31.1

View File

@ -1,79 +0,0 @@
From c839339fbfd2bb7ee4a523b64c7f3734ba36b9bc Mon Sep 17 00:00:00 2001
From: Chet Ramey <chet.ramey@case.edu>
Date: Wed, 17 Nov 2021 16:46:40 -0500
Subject: [PATCH] Bash-5.1 patch 11: save and restore alias parsing when
performing compound array assignment
---
parse.y | 4 ----
patchlevel.h | 2 +-
y.tab.c | 4 ----
3 files changed, 1 insertion(+), 9 deletions(-)
diff --git a/parse.y b/parse.y
index df1231da..f25575b5 100644
--- a/parse.y
+++ b/parse.y
@@ -6493,10 +6493,8 @@ parse_string_to_word_list (s, flags, whom)
old_expand_aliases = expand_aliases;
push_stream (1);
-#if 0 /* TAG: bash-5.2 Alex fxmbsw7 Ratchev <fxmbsw7@gmail.com> 11/17/2020 */
if (ea = expanding_alias ())
parser_save_alias ();
-#endif
last_read_token = WORD; /* WORD to allow reserved words here */
current_command_line_count = 0;
echo_input_at_read = expand_aliases = 0;
@@ -6531,10 +6529,8 @@ parse_string_to_word_list (s, flags, whom)
last_read_token = '\n';
pop_stream ();
-#if 0 /* TAG: bash-5.2 */
if (ea)
parser_restore_alias ();
-#endif
#if defined (HISTORY)
remember_on_history = old_remember_on_history;
diff --git a/patchlevel.h b/patchlevel.h
index 75246e44..8b14f289 100644
--- a/patchlevel.h
+++ b/patchlevel.h
@@ -25,6 +25,6 @@
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
looks for to find the patch level (for the sccs version string). */
-#define PATCHLEVEL 10
+#define PATCHLEVEL 11
#endif /* _PATCHLEVEL_H_ */
diff --git a/y.tab.c b/y.tab.c
index dcc5b7f3..c11d7aaa 100644
--- a/y.tab.c
+++ b/y.tab.c
@@ -8787,10 +8787,8 @@ parse_string_to_word_list (s, flags, whom)
old_expand_aliases = expand_aliases;
push_stream (1);
-#if 0 /* TAG: bash-5.2 Alex fxmbsw7 Ratchev <fxmbsw7@gmail.com> 11/17/2020 */
if (ea = expanding_alias ())
parser_save_alias ();
-#endif
last_read_token = WORD; /* WORD to allow reserved words here */
current_command_line_count = 0;
echo_input_at_read = expand_aliases = 0;
@@ -8825,10 +8823,8 @@ parse_string_to_word_list (s, flags, whom)
last_read_token = '\n';
pop_stream ();
-#if 0 /* TAG: bash-5.2 */
if (ea)
parser_restore_alias ();
-#endif
#if defined (HISTORY)
remember_on_history = old_remember_on_history;
--
2.31.1

View File

@ -1,195 +0,0 @@
From 15409324f1974d41c183904ad575da7188058c1c Mon Sep 17 00:00:00 2001
From: Chet Ramey <chet.ramey@case.edu>
Date: Wed, 17 Nov 2021 16:47:24 -0500
Subject: [PATCH] Bash-5.1 patch 12: fix race condition with child processes
and resetting trapped signals
---
command.h | 1 +
execute_cmd.c | 8 +++++++-
jobs.c | 2 ++
nojobs.c | 2 ++
patchlevel.h | 2 +-
sig.c | 10 +++++++++-
subst.c | 2 ++
trap.c | 26 ++++++++++++++++++++++++++
8 files changed, 50 insertions(+), 3 deletions(-)
diff --git a/command.h b/command.h
index 914198f9..b8477528 100644
--- a/command.h
+++ b/command.h
@@ -124,6 +124,7 @@ enum command_type { cm_for, cm_case, cm_while, cm_if, cm_simple, cm_select,
#define SUBSHELL_PROCSUB 0x20 /* subshell caused by <(command) or >(command) */
#define SUBSHELL_COPROC 0x40 /* subshell from a coproc pipeline */
#define SUBSHELL_RESETTRAP 0x80 /* subshell needs to reset trap strings on first call to trap */
+#define SUBSHELL_IGNTRAP 0x100 /* subshell should reset trapped signals from trap_handler */
/* A structure which represents a word. */
typedef struct word_desc {
diff --git a/execute_cmd.c b/execute_cmd.c
index 90129e06..425679a2 100644
--- a/execute_cmd.c
+++ b/execute_cmd.c
@@ -1547,6 +1547,9 @@ execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close)
clear_pending_traps ();
reset_signal_handlers ();
subshell_environment |= SUBSHELL_RESETTRAP;
+ /* Note that signal handlers have been reset, so we should no longer
+ reset the handler and resend trapped signals to ourselves. */
+ subshell_environment &= ~SUBSHELL_IGNTRAP;
/* We are in a subshell, so forget that we are running a trap handler or
that the signal handler has changed (we haven't changed it!) */
@@ -4320,7 +4323,8 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close)
already_forked = 1;
cmdflags |= CMD_NO_FORK;
- subshell_environment = SUBSHELL_FORK; /* XXX */
+ /* We redo some of what make_child() does with SUBSHELL_IGNTRAP */
+ subshell_environment = SUBSHELL_FORK|SUBSHELL_IGNTRAP; /* XXX */
if (pipe_in != NO_PIPE || pipe_out != NO_PIPE)
subshell_environment |= SUBSHELL_PIPE;
if (async)
@@ -4574,6 +4578,7 @@ run_builtin:
trap strings if we run trap to change a signal disposition. */
reset_signal_handlers ();
subshell_environment |= SUBSHELL_RESETTRAP;
+ subshell_environment &= ~SUBSHELL_IGNTRAP;
if (async)
{
@@ -5514,6 +5519,7 @@ execute_disk_command (words, redirects, command_line, pipe_in, pipe_out,
reset_terminating_signals (); /* XXX */
/* Cancel traps, in trap.c. */
restore_original_signals ();
+ subshell_environment &= ~SUBSHELL_IGNTRAP;
#if defined (JOB_CONTROL)
FREE (p);
diff --git a/jobs.c b/jobs.c
index a581f305..7c3b6e83 100644
--- a/jobs.c
+++ b/jobs.c
@@ -2217,6 +2217,8 @@ make_child (command, flags)
signals to the default state for a new process. */
pid_t mypid;
+ subshell_environment |= SUBSHELL_IGNTRAP;
+
/* If this ends up being changed to modify or use `command' in the
child process, go back and change callers who free `command' in
the child process when this returns. */
diff --git a/nojobs.c b/nojobs.c
index c5fc83d9..f2563ca0 100644
--- a/nojobs.c
+++ b/nojobs.c
@@ -575,6 +575,8 @@ make_child (command, flags)
last_asynchronous_pid = getpid ();
#endif
+ subshell_environment |= SUBSHELL_IGNTRAP;
+
default_tty_job_signals ();
}
else
diff --git a/patchlevel.h b/patchlevel.h
index 8b14f289..eb2aca52 100644
--- a/patchlevel.h
+++ b/patchlevel.h
@@ -25,6 +25,6 @@
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
looks for to find the patch level (for the sccs version string). */
-#define PATCHLEVEL 11
+#define PATCHLEVEL 12
#endif /* _PATCHLEVEL_H_ */
diff --git a/sig.c b/sig.c
index 6964d862..e6537d26 100644
--- a/sig.c
+++ b/sig.c
@@ -55,7 +55,8 @@
# include "bashhist.h"
#endif
-extern void initialize_siglist ();
+extern void initialize_siglist PARAMS((void));
+extern void set_original_signal PARAMS((int, SigHandler *));
#if !defined (JOB_CONTROL)
extern void initialize_job_signals PARAMS((void));
@@ -255,6 +256,13 @@ initialize_terminating_signals ()
sigaction (XSIG (i), &act, &oact);
XHANDLER(i) = oact.sa_handler;
XSAFLAGS(i) = oact.sa_flags;
+
+#if 0
+ set_original_signal (XSIG(i), XHANDLER(i)); /* optimization */
+#else
+ set_original_signal (XSIG(i), act.sa_handler); /* optimization */
+#endif
+
/* Don't do anything with signals that are ignored at shell entry
if the shell is not interactive. */
/* XXX - should we do this for interactive shells, too? */
diff --git a/subst.c b/subst.c
index 462752de..327de083 100644
--- a/subst.c
+++ b/subst.c
@@ -5951,6 +5951,7 @@ process_substitute (string, open_for_read_in_child)
free_pushed_string_input ();
/* Cancel traps, in trap.c. */
restore_original_signals (); /* XXX - what about special builtins? bash-4.2 */
+ subshell_environment &= ~SUBSHELL_IGNTRAP;
QUIT; /* catch any interrupts we got post-fork */
setup_async_signals ();
#if 0
@@ -6382,6 +6383,7 @@ command_substitute (string, quoted, flags)
}
QUIT; /* catch any interrupts we got post-fork */
subshell_environment |= SUBSHELL_RESETTRAP;
+ subshell_environment &= ~SUBSHELL_IGNTRAP;
}
#if defined (JOB_CONTROL)
diff --git a/trap.c b/trap.c
index c7f8ded5..1b27fb3a 100644
--- a/trap.c
+++ b/trap.c
@@ -481,6 +481,32 @@ trap_handler (sig)
SIGRETURN (0);
}
+ /* This means we're in a subshell, but have not yet reset the handler for
+ trapped signals. We're not supposed to execute the trap in this situation;
+ we should restore the original signal and resend the signal to ourselves
+ to preserve the Posix "signal traps that are not being ignored shall be
+ set to the default action" semantics. */
+ if ((subshell_environment & SUBSHELL_IGNTRAP) && trap_list[sig] != (char *)IGNORE_SIG)
+ {
+ sigset_t mask;
+
+ /* Paranoia */
+ if (original_signals[sig] == IMPOSSIBLE_TRAP_HANDLER)
+ original_signals[sig] = SIG_DFL;
+
+ restore_signal (sig);
+
+ /* Make sure we let the signal we just caught through */
+ sigemptyset (&mask);
+ sigprocmask (SIG_SETMASK, (sigset_t *)NULL, &mask);
+ sigdelset (&mask, sig);
+ sigprocmask (SIG_SETMASK, &mask, (sigset_t *)NULL);
+
+ kill (getpid (), sig);
+
+ SIGRETURN (0);
+ }
+
if ((sig >= NSIG) ||
(trap_list[sig] == (char *)DEFAULT_SIG) ||
(trap_list[sig] == (char *)IGNORE_SIG))
--
2.31.1

View File

@ -1,38 +0,0 @@
From 6b9422dbe3917a0affb4898e38156d22cbec64e8 Mon Sep 17 00:00:00 2001
From: Chet Ramey <chet.ramey@case.edu>
Date: Tue, 4 Jan 2022 16:58:20 -0500
Subject: [PATCH] Bash-5.1 patch 13: fix tilde expansion after unquoted colons
in posix mode
---
patchlevel.h | 2 +-
subst.c | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/patchlevel.h b/patchlevel.h
index eb2aca52..d8a1b2a9 100644
--- a/patchlevel.h
+++ b/patchlevel.h
@@ -25,6 +25,6 @@
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
looks for to find the patch level (for the sccs version string). */
-#define PATCHLEVEL 12
+#define PATCHLEVEL 13
#endif /* _PATCHLEVEL_H_ */
diff --git a/subst.c b/subst.c
index 327de083..dda1d55c 100644
--- a/subst.c
+++ b/subst.c
@@ -3825,6 +3825,7 @@ expand_string_assignment (string, quoted)
#else
td.flags = W_ASSIGNRHS;
#endif
+ td.flags |= (W_NOGLOB|W_TILDEEXP);
td.word = savestring (string);
value = call_expand_word_internal (&td, quoted, 0, (int *)NULL, (int *)NULL);
FREE (td.word);
--
2.31.1

View File

@ -1,39 +0,0 @@
From 72912fb8209105af961c851260a173115efe60be Mon Sep 17 00:00:00 2001
From: Chet Ramey <chet.ramey@case.edu>
Date: Tue, 4 Jan 2022 16:59:40 -0500
Subject: [PATCH] Bash-5.1 patch 14: fix off-by-one error when reading
multibyte characters from command substitution output
---
patchlevel.h | 2 +-
subst.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/patchlevel.h b/patchlevel.h
index d8a1b2a9..f2e80d19 100644
--- a/patchlevel.h
+++ b/patchlevel.h
@@ -25,6 +25,6 @@
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
looks for to find the patch level (for the sccs version string). */
-#define PATCHLEVEL 13
+#define PATCHLEVEL 14
#endif /* _PATCHLEVEL_H_ */
diff --git a/subst.c b/subst.c
index dda1d55c..2b76256c 100644
--- a/subst.c
+++ b/subst.c
@@ -6242,7 +6242,7 @@ read_comsub (fd, quoted, flags, rflag)
/* read a multibyte character from buf */
/* punt on the hard case for now */
memset (&ps, '\0', sizeof (mbstate_t));
- mblen = mbrtowc (&wc, bufp-1, bufn+1, &ps);
+ mblen = mbrtowc (&wc, bufp-1, bufn, &ps);
if (MB_INVALIDCH (mblen) || mblen == 0 || mblen == 1)
istring[istring_index++] = c;
else
--
2.31.1

View File

@ -1,39 +0,0 @@
From 18ad612ea80ba978ae8271800814737e224a4baf Mon Sep 17 00:00:00 2001
From: Chet Ramey <chet.ramey@case.edu>
Date: Tue, 4 Jan 2022 17:01:33 -0500
Subject: [PATCH] Bash-5.1 patch 15: fix readline display of some characters >
128 in certain single-byte encodings
---
lib/readline/display.c | 2 +-
patchlevel.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/readline/display.c b/lib/readline/display.c
index 38b3d0e7..f5d32945 100644
--- a/lib/readline/display.c
+++ b/lib/readline/display.c
@@ -1598,7 +1598,7 @@ puts_face (const char *str, const char *face, int n)
char cur_face;
for (cur_face = FACE_NORMAL, i = 0; i < n; i++)
- putc_face (str[i], face[i], &cur_face);
+ putc_face ((unsigned char) str[i], face[i], &cur_face);
putc_face (EOF, FACE_NORMAL, &cur_face);
}
diff --git a/patchlevel.h b/patchlevel.h
index f2e80d19..252e0819 100644
--- a/patchlevel.h
+++ b/patchlevel.h
@@ -25,6 +25,6 @@
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
looks for to find the patch level (for the sccs version string). */
-#define PATCHLEVEL 14
+#define PATCHLEVEL 15
#endif /* _PATCHLEVEL_H_ */
--
2.31.1

View File

@ -1,53 +0,0 @@
From 9439ce094c9aa7557a9d53ac7b412a23aa66e36b Mon Sep 17 00:00:00 2001
From: Chet Ramey <chet.ramey@case.edu>
Date: Tue, 4 Jan 2022 17:03:45 -0500
Subject: [PATCH] Bash-5.1 patch 16: fix interpretation of multiple instances
of ! in [[ conditional commands
---
parse.y | 2 +-
patchlevel.h | 2 +-
y.tab.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/parse.y b/parse.y
index f25575b5..f4168c7c 100644
--- a/parse.y
+++ b/parse.y
@@ -4796,7 +4796,7 @@ cond_term ()
dispose_word (yylval.word); /* not needed */
term = cond_term ();
if (term)
- term->flags |= CMD_INVERT_RETURN;
+ term->flags ^= CMD_INVERT_RETURN;
}
else if (tok == WORD && yylval.word->word[0] == '-' && yylval.word->word[1] && yylval.word->word[2] == 0 && test_unop (yylval.word->word))
{
diff --git a/patchlevel.h b/patchlevel.h
index 252e0819..3c226949 100644
--- a/patchlevel.h
+++ b/patchlevel.h
@@ -25,6 +25,6 @@
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
looks for to find the patch level (for the sccs version string). */
-#define PATCHLEVEL 15
+#define PATCHLEVEL 16
#endif /* _PATCHLEVEL_H_ */
diff --git a/y.tab.c b/y.tab.c
index c11d7aaa..78b38250 100644
--- a/y.tab.c
+++ b/y.tab.c
@@ -7090,7 +7090,7 @@ cond_term ()
dispose_word (yylval.word); /* not needed */
term = cond_term ();
if (term)
- term->flags |= CMD_INVERT_RETURN;
+ term->flags ^= CMD_INVERT_RETURN;
}
else if (tok == WORD && yylval.word->word[0] == '-' && yylval.word->word[1] && yylval.word->word[2] == 0 && test_unop (yylval.word->word))
{
--
2.31.1

View File

@ -1,29 +0,0 @@
diff --git a/builtins/wait.def b/builtins/wait.def
--- a/builtins/wait.def
+++ b/builtins/wait.def
@@ -213,11 +213,11 @@ wait_builtin (list)
}
status = wait_for_any_job (wflags, &pstat);
- if (status < 0)
- status = 127;
-
if (vname && status >= 0)
bind_var_to_int (vname, pstat.pid);
+
+ if (status < 0)
+ status = 127;
if (list)
unset_waitlist ();
WAIT_RETURN (status);
diff --git a/patchlevel.h b/patchlevel.h
--- a/patchlevel.h
+++ b/patchlevel.h
@@ -25,6 +25,6 @@
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
looks for to find the patch level (for the sccs version string). */
-#define PATCHLEVEL 1
+#define PATCHLEVEL 2
#endif /* _PATCHLEVEL_H_ */

View File

@ -1,27 +0,0 @@
diff --git a/patchlevel.h b/patchlevel.h
--- a/patchlevel.h
+++ b/patchlevel.h
@@ -25,6 +25,6 @@
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
looks for to find the patch level (for the sccs version string). */
-#define PATCHLEVEL 2
+#define PATCHLEVEL 3
#endif /* _PATCHLEVEL_H_ */
diff --git a/subst.c b/subst.c
--- a/subst.c
+++ b/subst.c
@@ -6356,8 +6356,10 @@ command_substitute (string, quoted, flags)
#if defined (JOB_CONTROL)
old_pipeline_pgrp = pipeline_pgrp;
- /* Don't reset the pipeline pgrp if we're already a subshell in a pipeline. */
- if ((subshell_environment & SUBSHELL_PIPE) == 0)
+ /* Don't reset the pipeline pgrp if we're already a subshell in a pipeline or
+ we've already forked to run a disk command (and are expanding redirections,
+ for example). */
+ if ((subshell_environment & (SUBSHELL_FORK|SUBSHELL_PIPE)) == 0)
pipeline_pgrp = shell_pgrp;
cleanup_the_pipeline ();
#endif /* JOB_CONTROL */

View File

@ -1,97 +0,0 @@
diff --git a/arrayfunc.c b/arrayfunc.c
--- a/arrayfunc.c
+++ b/arrayfunc.c
@@ -597,6 +597,27 @@ assign_assoc_from_kvlist (var, nlist, h, flags)
free (aval);
}
}
+
+/* Return non-zero if L appears to be a key-value pair associative array
+ compound assignment. */
+int
+kvpair_assignment_p (l)
+ WORD_LIST *l;
+{
+ return (l && (l->word->flags & W_ASSIGNMENT) == 0 && l->word->word[0] != '['); /*]*/
+}
+
+char *
+expand_and_quote_kvpair_word (w)
+ char *w;
+{
+ char *t, *r;
+
+ t = w ? expand_assignment_string_to_string (w, 0) : 0;
+ r = sh_single_quote (t ? t : "");
+ free (t);
+ return r;
+}
#endif
/* Callers ensure that VAR is not NULL. Associative array assignments have not
@@ -640,7 +661,7 @@ assign_compound_array_list (var, nlist, flags)
last_ind = (a && (flags & ASS_APPEND)) ? array_max_index (a) + 1 : 0;
#if ASSOC_KVPAIR_ASSIGNMENT
- if (assoc_p (var) && nlist && (nlist->word->flags & W_ASSIGNMENT) == 0 && nlist->word->word[0] != '[') /*]*/
+ if (assoc_p (var) && kvpair_assignment_p (nlist))
{
iflags = flags & ~ASS_APPEND;
assign_assoc_from_kvlist (var, nlist, nhash, iflags);
diff --git a/arrayfunc.h b/arrayfunc.h
--- a/arrayfunc.h
+++ b/arrayfunc.h
@@ -67,6 +67,9 @@ extern SHELL_VAR *assign_array_var_from_string PARAMS((SHELL_VAR *, char *, int)
extern char *expand_and_quote_assoc_word PARAMS((char *, int));
extern void quote_compound_array_list PARAMS((WORD_LIST *, int));
+extern int kvpair_assignment_p PARAMS((WORD_LIST *));
+extern char *expand_and_quote_kvpair_word PARAMS((char *));
+
extern int unbind_array_element PARAMS((SHELL_VAR *, char *, int));
extern int skipsubscript PARAMS((const char *, int, int));
diff --git a/patchlevel.h b/patchlevel.h
--- a/patchlevel.h
+++ b/patchlevel.h
@@ -25,6 +25,6 @@
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
looks for to find the patch level (for the sccs version string). */
-#define PATCHLEVEL 3
+#define PATCHLEVEL 4
#endif /* _PATCHLEVEL_H_ */
diff --git a/subst.c b/subst.c
--- a/subst.c
+++ b/subst.c
@@ -11604,6 +11604,7 @@ expand_oneword (value, flags)
{
WORD_LIST *l, *nl;
char *t;
+ int kvpair;
if (flags == 0)
{
@@ -11618,11 +11619,21 @@ expand_oneword (value, flags)
{
/* Associative array */
l = parse_string_to_word_list (value, 1, "array assign");
+#if ASSOC_KVPAIR_ASSIGNMENT
+ kvpair = kvpair_assignment_p (l);
+#endif
+
/* For associative arrays, with their arbitrary subscripts, we have to
expand and quote in one step so we don't have to search for the
closing right bracket more than once. */
for (nl = l; nl; nl = nl->next)
{
+#if ASSOC_KVPAIR_ASSIGNMENT
+ if (kvpair)
+ /* keys and values undergo the same set of expansions */
+ t = expand_and_quote_kvpair_word (nl->word->word);
+ else
+#endif
if ((nl->word->flags & W_ASSIGNMENT) == 0)
t = sh_single_quote (nl->word->word ? nl->word->word : "");
else

View File

@ -1,85 +0,0 @@
From cc978a670597afc3251baca3a7db553f36946c22 Mon Sep 17 00:00:00 2001
From: Chet Ramey <chet.ramey@case.edu>
Date: Tue, 4 May 2021 14:29:06 -0400
Subject: [PATCH] Bash-5.1 patch 5: fix memory leaks in compound array
assignments
---
arrayfunc.c | 11 +++--------
patchlevel.h | 2 +-
subst.c | 2 ++
3 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/arrayfunc.c b/arrayfunc.c
index 8231ba1e..9338dfc7 100644
--- a/arrayfunc.c
+++ b/arrayfunc.c
@@ -564,12 +564,9 @@ assign_assoc_from_kvlist (var, nlist, h, flags)
{
WORD_LIST *list;
char *akey, *aval, *k, *v;
- int free_aval;
for (list = nlist; list; list = list->next)
{
- free_aval = 0;
-
k = list->word->word;
v = list->next ? list->next->word->word : 0;
@@ -577,24 +574,22 @@ assign_assoc_from_kvlist (var, nlist, h, flags)
list = list->next;
akey = expand_assignment_string_to_string (k, 0);
- aval = expand_assignment_string_to_string (v, 0);
-
if (akey == 0 || *akey == 0)
{
err_badarraysub (k);
FREE (akey);
continue;
}
+
+ aval = expand_assignment_string_to_string (v, 0);
if (aval == 0)
{
aval = (char *)xmalloc (1);
aval[0] = '\0'; /* like do_assignment_internal */
- free_aval = 1;
}
bind_assoc_var_internal (var, h, akey, aval, flags);
- if (free_aval)
- free (aval);
+ free (aval);
}
}
diff --git a/patchlevel.h b/patchlevel.h
index e1429c24..c7f39aec 100644
--- a/patchlevel.h
+++ b/patchlevel.h
@@ -25,6 +25,6 @@
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
looks for to find the patch level (for the sccs version string). */
-#define PATCHLEVEL 4
+#define PATCHLEVEL 5
#endif /* _PATCHLEVEL_H_ */
diff --git a/subst.c b/subst.c
index 6132316a..1d24188e 100644
--- a/subst.c
+++ b/subst.c
@@ -11673,6 +11673,8 @@ expand_compound_assignment_word (tlist, flags)
free (value);
value = string_list (l);
+ dispose_words (l);
+
wlen = STRLEN (value);
/* Now, let's rebuild the string */
--
2.29.2

View File

@ -1,44 +0,0 @@
From f3cd936b81006df41a1c8509891dea1edeaef8e6 Mon Sep 17 00:00:00 2001
From: Chet Ramey <chet.ramey@case.edu>
Date: Tue, 4 May 2021 14:30:17 -0400
Subject: [PATCH] Bash-5.1 patch 6: make sure child processes forked to execute
command substitutions are in the right process group
---
patchlevel.h | 2 +-
subst.c | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/patchlevel.h b/patchlevel.h
index c7f39aec..6257aeeb 100644
--- a/patchlevel.h
+++ b/patchlevel.h
@@ -25,6 +25,6 @@
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
looks for to find the patch level (for the sccs version string). */
-#define PATCHLEVEL 5
+#define PATCHLEVEL 6
#endif /* _PATCHLEVEL_H_ */
diff --git a/subst.c b/subst.c
index 1d24188e..462752de 100644
--- a/subst.c
+++ b/subst.c
@@ -6412,6 +6412,13 @@ command_substitute (string, quoted, flags)
/* The currently executing shell is not interactive. */
interactive = 0;
+#if defined (JOB_CONTROL)
+ /* Invariant: in child processes started to run command substitutions,
+ pipeline_pgrp == shell_pgrp. Other parts of the shell assume this. */
+ if (pipeline_pgrp > 0 && pipeline_pgrp != shell_pgrp)
+ shell_pgrp = pipeline_pgrp;
+#endif
+
set_sigint_handler (); /* XXX */
free_pushed_string_input ();
--
2.29.2

View File

@ -1,71 +0,0 @@
From b72f88db852104cf49cfb4762eda6e8f4fd20a70 Mon Sep 17 00:00:00 2001
From: Chet Ramey <chet.ramey@case.edu>
Date: Tue, 4 May 2021 14:31:05 -0400
Subject: [PATCH] Bash-5.1 patch 7: fix version comparisons in readline startup
files
---
lib/readline/bind.c | 15 ++++++++-------
patchlevel.h | 2 +-
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/lib/readline/bind.c b/lib/readline/bind.c
index 87596dce..76103786 100644
--- a/lib/readline/bind.c
+++ b/lib/readline/bind.c
@@ -1234,7 +1234,7 @@ parser_if (char *args)
#endif /* VI_MODE */
else if (_rl_strnicmp (args, "version", 7) == 0)
{
- int rlversion, versionarg, op, previ, major, minor;
+ int rlversion, versionarg, op, previ, major, minor, opresult;
_rl_parsing_conditionalized_out = 1;
rlversion = RL_VERSION_MAJOR*10 + RL_VERSION_MINOR;
@@ -1294,24 +1294,25 @@ parser_if (char *args)
switch (op)
{
case OP_EQ:
- _rl_parsing_conditionalized_out = rlversion == versionarg;
+ opresult = rlversion == versionarg;
break;
case OP_NE:
- _rl_parsing_conditionalized_out = rlversion != versionarg;
+ opresult = rlversion != versionarg;
break;
case OP_GT:
- _rl_parsing_conditionalized_out = rlversion > versionarg;
+ opresult = rlversion > versionarg;
break;
case OP_GE:
- _rl_parsing_conditionalized_out = rlversion >= versionarg;
+ opresult = rlversion >= versionarg;
break;
case OP_LT:
- _rl_parsing_conditionalized_out = rlversion < versionarg;
+ opresult = rlversion < versionarg;
break;
case OP_LE:
- _rl_parsing_conditionalized_out = rlversion <= versionarg;
+ opresult = rlversion <= versionarg;
break;
}
+ _rl_parsing_conditionalized_out = 1 - opresult;
}
/* Check to see if the first word in ARGS is the same as the
value stored in rl_readline_name. */
diff --git a/patchlevel.h b/patchlevel.h
index 6257aeeb..c5ed66ab 100644
--- a/patchlevel.h
+++ b/patchlevel.h
@@ -25,6 +25,6 @@
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
looks for to find the patch level (for the sccs version string). */
-#define PATCHLEVEL 6
+#define PATCHLEVEL 7
#endif /* _PATCHLEVEL_H_ */
--
2.29.2

View File

@ -1,49 +0,0 @@
From ce23728687ce9e584333367075c9deef413553fa Mon Sep 17 00:00:00 2001
From: Chet Ramey <chet.ramey@case.edu>
Date: Tue, 4 May 2021 14:31:53 -0400
Subject: [PATCH] Bash-5.1 patch 8: clean up FIFOs created by redirections in
child processes
---
execute_cmd.c | 8 +++++++-
patchlevel.h | 2 +-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/execute_cmd.c b/execute_cmd.c
index d2a0dd71..90129e06 100644
--- a/execute_cmd.c
+++ b/execute_cmd.c
@@ -5556,11 +5556,17 @@ execute_disk_command (words, redirects, command_line, pipe_in, pipe_out,
#if defined (PROCESS_SUBSTITUTION)
/* Try to remove named pipes that may have been created as the
result of redirections. */
- unlink_fifo_list ();
+ unlink_all_fifos ();
#endif /* PROCESS_SUBSTITUTION */
exit (EXECUTION_FAILURE);
}
+#if defined (PROCESS_SUBSTITUTION) && !defined (HAVE_DEV_FD)
+ /* This should only contain FIFOs created as part of redirection
+ expansion. */
+ unlink_all_fifos ();
+#endif
+
if (async)
interactive = old_interactive;
diff --git a/patchlevel.h b/patchlevel.h
index c5ed66ab..10fde2ee 100644
--- a/patchlevel.h
+++ b/patchlevel.h
@@ -25,6 +25,6 @@
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
looks for to find the patch level (for the sccs version string). */
-#define PATCHLEVEL 7
+#define PATCHLEVEL 8
#endif /* _PATCHLEVEL_H_ */
--
2.29.2

View File

@ -1,50 +0,0 @@
From fed42742e0b33b358610bf62c7474f55e6465205 Mon Sep 17 00:00:00 2001
From: Chet Ramey <chet.ramey@case.edu>
Date: Wed, 17 Nov 2021 16:44:19 -0500
Subject: [PATCH] Bash-5.1 patch 9: fix bash malloc implementation of
malloc_usable_size
---
lib/malloc/malloc.c | 13 ++++++-------
patchlevel.h | 2 +-
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/lib/malloc/malloc.c b/lib/malloc/malloc.c
index 439f8ef1..92e6efa5 100644
--- a/lib/malloc/malloc.c
+++ b/lib/malloc/malloc.c
@@ -1286,13 +1286,12 @@ malloc_usable_size (mem)
p = (union mhead *) ap - 1;
}
- /* XXX - should we return 0 if ISFREE? */
- maxbytes = binsize(p->mh_index);
-
- /* So the usable size is the maximum number of bytes in the bin less the
- malloc overhead */
- maxbytes -= MOVERHEAD + MSLOP;
- return (maxbytes);
+ /* return 0 if ISFREE */
+ if (p->mh_alloc == ISFREE)
+ return 0;
+
+ /* Since we use bounds checking, the usable size is the last requested size. */
+ return (p->mh_nbytes);
}
#if !defined (NO_VALLOC)
diff --git a/patchlevel.h b/patchlevel.h
index 10fde2ee..17586ff7 100644
--- a/patchlevel.h
+++ b/patchlevel.h
@@ -25,6 +25,6 @@
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
looks for to find the patch level (for the sccs version string). */
-#define PATCHLEVEL 8
+#define PATCHLEVEL 9
#endif /* _PATCHLEVEL_H_ */
--
2.31.1

View File

@ -1,26 +0,0 @@
diff --git a/doc/Makefile.in b/doc/Makefile.in
index 5f0756c..a5fa5a0 100644
--- a/doc/Makefile.in
+++ b/doc/Makefile.in
@@ -74,7 +74,6 @@ TEXI2DVI = ${SUPPORT_SRCDIR}/texi2dvi
TEXI2HTML = ${SUPPORT_SRCDIR}/texi2html
MAN2HTML = ${BUILD_DIR}/support/man2html
HTMLPOST = ${srcdir}/htmlpost.sh
-INFOPOST = ${srcdir}/infopost.sh
QUIETPS = #set this to -q to shut up dvips
PAPERSIZE = letter # change to a4 for A4-size paper
PSDPI = 600 # could be 300 if you like
@@ -188,8 +187,8 @@ bashref.pdf: $(BASHREF_FILES) $(HSUSER) $(RLUSER)
bashref.html: $(BASHREF_FILES) $(HSUSER) $(RLUSER)
$(MAKEINFO) --html --no-split -I$(TEXINPUTDIR) $(srcdir)/bashref.texi
-bash.info: bashref.info
- ${SHELL} ${INFOPOST} < $(srcdir)/bashref.info > $@ ; \
+bash.info: $(BASHREF_FILES) $(HSUSER) $(RLUSER)
+ $(MAKEINFO) --no-split -I$(TEXINPUTDIR) $(srcdir)/bashref.texi -o $@
bash.txt: bash.1
bash.ps: bash.1
--
2.9.3

View File

@ -1,20 +1,18 @@
diff --git a/builtins.h b/builtins.h diff --git a/builtins.h b/builtins.h
index dac95fd..5b7e811 100644
--- a/builtins.h --- a/builtins.h
+++ b/builtins.h +++ b/builtins.h
@@ -45,6 +45,7 @@ @@ -46,6 +46,7 @@
#define ASSIGNMENT_BUILTIN 0x10 /* This builtin takes assignment statements. */
#define POSIX_BUILTIN 0x20 /* This builtins is special in the Posix command search order. */ #define POSIX_BUILTIN 0x20 /* This builtins is special in the Posix command search order. */
#define LOCALVAR_BUILTIN 0x40 /* This builtin creates local variables */ #define LOCALVAR_BUILTIN 0x40 /* This builtin creates local variables */
+#define REQUIRES_BUILTIN 0x80 /* This builtin requires other files. */ #define ARRAYREF_BUILTIN 0x80 /* This builtin takes array references as arguments */
+#define REQUIRES_BUILTIN 0x100 /* This builtin requires other files. */
#define BASE_INDENT 4 #define BASE_INDENT 4
diff --git a/builtins/mkbuiltins.c b/builtins/mkbuiltins.c diff --git a/builtins/mkbuiltins.c b/builtins/mkbuiltins.c
index e243021..0a7a0e5 100644
--- a/builtins/mkbuiltins.c --- a/builtins/mkbuiltins.c
+++ b/builtins/mkbuiltins.c +++ b/builtins/mkbuiltins.c
@@ -69,10 +69,15 @@ extern char *strcpy (); @@ -69,11 +69,16 @@ extern char *strcpy ();
#define whitespace(c) (((c) == ' ') || ((c) == '\t')) #define whitespace(c) (((c) == ' ') || ((c) == '\t'))
/* Flag values that builtins can have. */ /* Flag values that builtins can have. */
@ -25,15 +23,18 @@ index e243021..0a7a0e5 100644
#define BUILTIN_FLAG_SPECIAL 0x01 #define BUILTIN_FLAG_SPECIAL 0x01
#define BUILTIN_FLAG_ASSIGNMENT 0x02 #define BUILTIN_FLAG_ASSIGNMENT 0x02
#define BUILTIN_FLAG_LOCALVAR 0x04 #define BUILTIN_FLAG_LOCALVAR 0x04
#define BUILTIN_FLAG_POSIX_BUILTIN 0x08 #define BUILTIN_FLAG_POSIX_BUILTIN 0x08
+#define BUILTIN_FLAG_REQUIRES 0x10 #define BUILTIN_FLAG_ARRAYREF_ARG 0x10
+#define BUILTIN_FLAG_REQUIRES 0x20
#define BASE_INDENT 4 #define BASE_INDENT 4
@@ -173,11 +178,19 @@ char *posix_builtins[] = @@ -189,13 +194,21 @@ char *arrayvar_builtins[] =
"typeset", "unset", "wait", /*]*/
(char *)NULL (char *)NULL
}; };
-
+
+/* The builtin commands that cause requirements on other files. */ +/* The builtin commands that cause requirements on other files. */
+static char *requires_builtins[] = +static char *requires_builtins[] =
+{ +{
@ -46,36 +47,38 @@ index e243021..0a7a0e5 100644
static int is_assignment_builtin (); static int is_assignment_builtin ();
static int is_localvar_builtin (); static int is_localvar_builtin ();
static int is_posix_builtin (); static int is_posix_builtin ();
static int is_arrayvar_builtin ();
+static int is_requires_builtin (); +static int is_requires_builtin ();
#if !defined (HAVE_RENAME) #if !defined (HAVE_RENAME)
static int rename (); static int rename ();
@@ -831,6 +844,8 @@ builtin_handler (self, defs, arg) @@ -856,6 +869,8 @@ builtin_handler (self, defs, arg)
new->flags |= BUILTIN_FLAG_LOCALVAR;
if (is_posix_builtin (name))
new->flags |= BUILTIN_FLAG_POSIX_BUILTIN; new->flags |= BUILTIN_FLAG_POSIX_BUILTIN;
if (is_arrayvar_builtin (name))
new->flags |= BUILTIN_FLAG_ARRAYREF_ARG;
+ if (is_requires_builtin (name)) + if (is_requires_builtin (name))
+ new->flags |= BUILTIN_FLAG_REQUIRES; + new->flags |= BUILTIN_FLAG_REQUIRES;
array_add ((char *)new, defs->builtins); array_add ((char *)new, defs->builtins);
building_builtin = 1; building_builtin = 1;
@@ -1250,12 +1265,13 @@ write_builtins (defs, structfile, externfile) @@ -1275,13 +1290,14 @@ write_builtins (defs, structfile, externfile)
else else
fprintf (structfile, "(sh_builtin_func_t *)0x0, "); fprintf (structfile, "(sh_builtin_func_t *)0x0, ");
- fprintf (structfile, "%s%s%s%s%s, %s_doc,\n", - fprintf (structfile, "%s%s%s%s%s%s, %s_doc,\n",
+ fprintf (structfile, "%s%s%s%s%s%s, %s_doc,\n", + fprintf (structfile, "%s%s%s%s%s%s%s, %s_doc,\n",
"BUILTIN_ENABLED | STATIC_BUILTIN", "BUILTIN_ENABLED | STATIC_BUILTIN",
(builtin->flags & BUILTIN_FLAG_SPECIAL) ? " | SPECIAL_BUILTIN" : "", (builtin->flags & BUILTIN_FLAG_SPECIAL) ? " | SPECIAL_BUILTIN" : "",
(builtin->flags & BUILTIN_FLAG_ASSIGNMENT) ? " | ASSIGNMENT_BUILTIN" : "", (builtin->flags & BUILTIN_FLAG_ASSIGNMENT) ? " | ASSIGNMENT_BUILTIN" : "",
(builtin->flags & BUILTIN_FLAG_LOCALVAR) ? " | LOCALVAR_BUILTIN" : "", (builtin->flags & BUILTIN_FLAG_LOCALVAR) ? " | LOCALVAR_BUILTIN" : "",
(builtin->flags & BUILTIN_FLAG_POSIX_BUILTIN) ? " | POSIX_BUILTIN" : "", (builtin->flags & BUILTIN_FLAG_POSIX_BUILTIN) ? " | POSIX_BUILTIN" : "",
(builtin->flags & BUILTIN_FLAG_ARRAYREF_ARG) ? " | ARRAYREF_BUILTIN" : "",
+ (builtin->flags & BUILTIN_FLAG_REQUIRES) ? " | REQUIRES_BUILTIN" : "", + (builtin->flags & BUILTIN_FLAG_REQUIRES) ? " | REQUIRES_BUILTIN" : "",
document_name (builtin)); document_name (builtin));
/* Don't translate short document summaries that are identical /* Don't translate short document summaries that are identical
@@ -1645,6 +1661,13 @@ is_posix_builtin (name) @@ -1678,6 +1694,13 @@ is_arrayvar_builtin (name)
return (_find_in_table (name, posix_builtins)); return (_find_in_table (name, arrayvar_builtins));
} }
+static int +static int
@ -89,7 +92,6 @@ index e243021..0a7a0e5 100644
static int static int
rename (from, to) rename (from, to)
diff --git a/doc/bash.1 b/doc/bash.1 diff --git a/doc/bash.1 b/doc/bash.1
index 5af7d42..7539368 100644
--- a/doc/bash.1 --- a/doc/bash.1
+++ b/doc/bash.1 +++ b/doc/bash.1
@@ -239,6 +239,14 @@ The shell becomes restricted (see @@ -239,6 +239,14 @@ The shell becomes restricted (see
@ -108,10 +110,9 @@ index 5af7d42..7539368 100644
Equivalent to \fB\-v\fP. Equivalent to \fB\-v\fP.
.TP .TP
diff --git a/doc/bashref.texi b/doc/bashref.texi diff --git a/doc/bashref.texi b/doc/bashref.texi
index 9e23f58..d02151e 100644
--- a/doc/bashref.texi --- a/doc/bashref.texi
+++ b/doc/bashref.texi +++ b/doc/bashref.texi
@@ -6554,6 +6554,13 @@ standard. @xref{Bash POSIX Mode}, for a description of the Bash @@ -6927,6 +6927,13 @@ standard. @xref{Bash POSIX Mode}, for a description of the Bash
@item --restricted @item --restricted
Make the shell a restricted shell (@pxref{The Restricted Shell}). Make the shell a restricted shell (@pxref{The Restricted Shell}).
@ -126,10 +127,9 @@ index 9e23f58..d02151e 100644
Equivalent to @option{-v}. Print shell input lines as they're read. Equivalent to @option{-v}. Print shell input lines as they're read.
diff --git a/eval.c b/eval.c diff --git a/eval.c b/eval.c
index 1d967da..f197033 100644
--- a/eval.c --- a/eval.c
+++ b/eval.c +++ b/eval.c
@@ -137,7 +137,8 @@ reader_loop () @@ -138,7 +138,8 @@ reader_loop ()
if (read_command () == 0) if (read_command () == 0)
{ {
@ -137,13 +137,12 @@ index 1d967da..f197033 100644
+ +
+ if (interactive_shell == 0 && (read_but_dont_execute && !rpm_requires)) + if (interactive_shell == 0 && (read_but_dont_execute && !rpm_requires))
{ {
set_exit_status (EXECUTION_SUCCESS); set_exit_status (last_command_exit_value);
dispose_command (global_command); dispose_command (global_command);
diff --git a/execute_cmd.c b/execute_cmd.c diff --git a/execute_cmd.c b/execute_cmd.c
index d2555ad..397e283 100644
--- a/execute_cmd.c --- a/execute_cmd.c
+++ b/execute_cmd.c +++ b/execute_cmd.c
@@ -543,6 +543,8 @@ async_redirect_stdin () @@ -561,6 +561,8 @@ async_redirect_stdin ()
#define DESCRIBE_PID(pid) do { if (interactive) describe_pid (pid); } while (0) #define DESCRIBE_PID(pid) do { if (interactive) describe_pid (pid); } while (0)
@ -152,22 +151,22 @@ index d2555ad..397e283 100644
/* Execute the command passed in COMMAND, perhaps doing it asynchronously. /* Execute the command passed in COMMAND, perhaps doing it asynchronously.
COMMAND is exactly what read_command () places into GLOBAL_COMMAND. COMMAND is exactly what read_command () places into GLOBAL_COMMAND.
ASYNCHRONOUS, if non-zero, says to do this command in the background. ASYNCHRONOUS, if non-zero, says to do this command in the background.
@@ -574,7 +576,13 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out, @@ -592,7 +594,13 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
if (breaking || continuing) if (breaking || continuing)
return (last_command_exit_value); return (last_command_exit_value);
- if (command == 0 || read_but_dont_execute) - if (read_but_dont_execute)
+ if (command == 0 || (read_but_dont_execute && !rpm_requires)) + if (command == 0 || (read_but_dont_execute && !rpm_requires))
+ return (EXECUTION_SUCCESS); + return (EXECUTION_SUCCESS);
+ if (rpm_requires && command->type == cm_function_def) + if (rpm_requires && command->type == cm_function_def)
+ return last_command_exit_value = + return last_command_exit_value =
+ execute_intern_function (command->value.Function_def->name, + execute_intern_function (command->value.Function_def->name,
+ command->value.Function_def); + command->value.Function_def);
+ if (read_but_dont_execute) + if (read_but_dont_execute)
return (last_command_exit_value);
if (command == 0)
return (EXECUTION_SUCCESS); return (EXECUTION_SUCCESS);
@@ -2883,7 +2891,7 @@ execute_for_command (for_command)
QUIT;
@@ -2836,7 +2844,7 @@ execute_for_command (for_command)
save_line_number = line_number; save_line_number = line_number;
if (check_identifier (for_command->name, 1) == 0) if (check_identifier (for_command->name, 1) == 0)
{ {
@ -177,7 +176,6 @@ index d2555ad..397e283 100644
last_command_exit_value = EX_BADUSAGE; last_command_exit_value = EX_BADUSAGE;
jump_to_top_level (ERREXIT); jump_to_top_level (ERREXIT);
diff --git a/execute_cmd.h b/execute_cmd.h diff --git a/execute_cmd.h b/execute_cmd.h
index 465030a..9c7fd1c 100644
--- a/execute_cmd.h --- a/execute_cmd.h
+++ b/execute_cmd.h +++ b/execute_cmd.h
@@ -22,6 +22,9 @@ @@ -22,6 +22,9 @@
@ -191,7 +189,6 @@ index 465030a..9c7fd1c 100644
#if defined (ARRAY_VARS) #if defined (ARRAY_VARS)
struct func_array_state struct func_array_state
diff --git a/make_cmd.c b/make_cmd.c diff --git a/make_cmd.c b/make_cmd.c
index 2d7ac96..ac53526 100644
--- a/make_cmd.c --- a/make_cmd.c
+++ b/make_cmd.c +++ b/make_cmd.c
@@ -35,6 +35,8 @@ @@ -35,6 +35,8 @@
@ -203,7 +200,7 @@ index 2d7ac96..ac53526 100644
#include "execute_cmd.h" #include "execute_cmd.h"
#include "parser.h" #include "parser.h"
#include "flags.h" #include "flags.h"
@@ -828,6 +830,30 @@ make_coproc_command (name, command) @@ -839,6 +841,30 @@ make_coproc_command (name, command)
return (make_command (cm_coproc, (SIMPLE_COM *)temp)); return (make_command (cm_coproc, (SIMPLE_COM *)temp));
} }
@ -234,7 +231,7 @@ index 2d7ac96..ac53526 100644
/* Reverse the word list and redirection list in the simple command /* Reverse the word list and redirection list in the simple command
has just been parsed. It seems simpler to do this here the one has just been parsed. It seems simpler to do this here the one
time then by any other method that I can think of. */ time then by any other method that I can think of. */
@@ -845,6 +871,28 @@ clean_simple_command (command) @@ -856,6 +882,28 @@ clean_simple_command (command)
REVERSE_LIST (command->value.Simple->redirects, REDIRECT *); REVERSE_LIST (command->value.Simple->redirects, REDIRECT *);
} }
@ -264,10 +261,9 @@ index 2d7ac96..ac53526 100644
return (command); return (command);
} }
diff --git a/shell.c b/shell.c diff --git a/shell.c b/shell.c
index ce8087f..7dcd000 100644
--- a/shell.c --- a/shell.c
+++ b/shell.c +++ b/shell.c
@@ -194,6 +194,9 @@ int have_devfd = 0; @@ -196,6 +196,9 @@ int have_devfd = 0;
/* The name of the .(shell)rc file. */ /* The name of the .(shell)rc file. */
static char *bashrc_file = DEFAULT_BASHRC; static char *bashrc_file = DEFAULT_BASHRC;
@ -277,7 +273,7 @@ index ce8087f..7dcd000 100644
/* Non-zero means to act more like the Bourne shell on startup. */ /* Non-zero means to act more like the Bourne shell on startup. */
static int act_like_sh; static int act_like_sh;
@@ -260,6 +263,7 @@ static const struct { @@ -266,6 +269,7 @@ static const struct {
{ "protected", Int, &protected_mode, (char **)0x0 }, { "protected", Int, &protected_mode, (char **)0x0 },
#endif #endif
{ "rcfile", Charp, (int *)0x0, &bashrc_file }, { "rcfile", Charp, (int *)0x0, &bashrc_file },
@ -285,9 +281,9 @@ index ce8087f..7dcd000 100644
#if defined (RESTRICTED_SHELL) #if defined (RESTRICTED_SHELL)
{ "restricted", Int, &restricted, (char **)0x0 }, { "restricted", Int, &restricted, (char **)0x0 },
#endif #endif
@@ -502,6 +506,12 @@ main (argc, argv, env) @@ -510,6 +514,12 @@ main (argc, argv, env)
if (dump_translatable_strings)
read_but_dont_execute = 1; read_but_dont_execute = 1;
#endif
+ if (rpm_requires) + if (rpm_requires)
+ { + {
@ -299,10 +295,9 @@ index ce8087f..7dcd000 100644
disable_priv_mode (); disable_priv_mode ();
diff --git a/shell.h b/shell.h diff --git a/shell.h b/shell.h
index 8b41792..29b0efb 100644
--- a/shell.h --- a/shell.h
+++ b/shell.h +++ b/shell.h
@@ -99,6 +99,7 @@ extern int interactive, interactive_shell; @@ -100,6 +100,7 @@ extern int interactive, interactive_shell;
extern int startup_state; extern int startup_state;
extern int reading_shell_script; extern int reading_shell_script;
extern int shell_initialized; extern int shell_initialized;

View File

@ -1,8 +1,7 @@
diff --git a/tests/exec.right b/tests/exec.right diff --git a/tests/exec.right b/tests/exec.right
index 0a249dd..fe8a127 100644
--- a/tests/exec.right --- a/tests/exec.right
+++ b/tests/exec.right +++ b/tests/exec.right
@@ -51,7 +51,6 @@ this is ohio-state @@ -60,7 +60,6 @@ this is ohio-state
0 0
1 1
testb testb
@ -11,7 +10,6 @@ index 0a249dd..fe8a127 100644
1 1
1 1
diff --git a/tests/execscript b/tests/execscript diff --git a/tests/execscript b/tests/execscript
index 2809676..1216828 100644
--- a/tests/execscript --- a/tests/execscript
+++ b/tests/execscript +++ b/tests/execscript
@@ -108,8 +108,6 @@ ${THIS_SH} ./exec6.sub @@ -108,8 +108,6 @@ ${THIS_SH} ./exec6.sub
@ -24,26 +22,27 @@ index 2809676..1216828 100644
${THIS_SH} ./exec10.sub ${THIS_SH} ./exec10.sub
diff --git a/tests/read.right b/tests/read.right diff --git a/tests/read.right b/tests/read.right
index 1144083..09cd422 100644
--- a/tests/read.right --- a/tests/read.right
+++ b/tests/read.right +++ b/tests/read.right
@@ -33,14 +33,6 @@ a = abcdefg @@ -34,17 +34,6 @@ xyz
a = xyz a = xyz
a = -xyz 123- a = -xyz 123-
a = abc a = abc
-timeout 1: ok -timeout 1: ok
- -unset or null 1
-timeout 2: ok -timeout 2: ok
- -unset or null 2
-./read2.sub: line 36: read: -3: invalid timeout specification -timeout 3: ok
-unset or null 3
-./read2.sub: line 45: read: -3: invalid timeout specification
-1 -1
- -
-abcde
-abcde -abcde
./read3.sub: line 17: read: -1: invalid number ./read3.sub: line 17: read: -1: invalid number
abc abc
ab defg
diff --git a/tests/read.tests b/tests/read.tests diff --git a/tests/read.tests b/tests/read.tests
index 7384f05..43fcf8d 100644
--- a/tests/read.tests --- a/tests/read.tests
+++ b/tests/read.tests +++ b/tests/read.tests
@@ -95,9 +95,6 @@ echo " foo" | { IFS=$':' ; read line; recho "$line"; } @@ -95,9 +95,6 @@ echo " foo" | { IFS=$':' ; read line; recho "$line"; }

View File

@ -1,12 +1,12 @@
#% define beta_tag rc2 #% define beta_tag rc2
%define patchleveltag .16 %define patchleveltag .0
%define baseversion 5.1 %define baseversion 5.2
%bcond_without tests %bcond_without tests
Version: %{baseversion}%{patchleveltag} Version: %{baseversion}%{patchleveltag}
Name: bash Name: bash
Summary: The GNU Bourne Again shell Summary: The GNU Bourne Again shell
Release: 4%{?dist} Release: 1%{?dist}
License: GPLv3+ License: GPLv3+
Url: https://www.gnu.org/software/bash Url: https://www.gnu.org/software/bash
Source0: https://ftp.gnu.org/gnu/bash/bash-%{baseversion}.tar.gz Source0: https://ftp.gnu.org/gnu/bash/bash-%{baseversion}.tar.gz
@ -20,7 +20,7 @@ Source3: dot-bash_logout
# Official upstream patches # Official upstream patches
# Patches are converted to apply with '-p1' # Patches are converted to apply with '-p1'
%{lua:for i=1,16 do print(string.format("Patch%u: bash-5.1-patch-%u.patch\n", i, i)) end} #{lua:for i=1,16 do print(string.format("Patch%u: bash-5.1-patch-%u.patch\n", i, i)) end}
# Other patches # Other patches
# We don't want to add '/etc:/usr/etc' in standard utils path. # We don't want to add '/etc:/usr/etc' in standard utils path.
@ -38,7 +38,7 @@ Patch106: bash-3.2-audit.patch
# Source bashrc file when bash is run under ssh. # Source bashrc file when bash is run under ssh.
Patch107: bash-3.2-ssh_source_bash.patch Patch107: bash-3.2-ssh_source_bash.patch
# Use makeinfo to generate .texi file # Use makeinfo to generate .texi file
Patch108: bash-infotags.patch # Patch108: bash-infotags.patch
# Try to pick up latest `--rpm-requires` patch from http://git.altlinux.org/gears/b/bash4.git # Try to pick up latest `--rpm-requires` patch from http://git.altlinux.org/gears/b/bash4.git
Patch109: bash-requires.patch Patch109: bash-requires.patch
Patch110: bash-setlocale.patch Patch110: bash-setlocale.patch
@ -55,7 +55,7 @@ Patch117: bash-4.1-examples.patch
# when output does not succeed due to EPIPE # when output does not succeed due to EPIPE
Patch118: bash-4.1-broken_pipe.patch Patch118: bash-4.1-broken_pipe.patch
# # Enable system-wide .bash_logout for login shells # Enable system-wide .bash_logout for login shells
Patch119: bash-4.2-rc2-logout.patch Patch119: bash-4.2-rc2-logout.patch
# Static analyzis shows some issues in bash-2.05a-interpreter.patch # Static analyzis shows some issues in bash-2.05a-interpreter.patch
@ -87,10 +87,6 @@ Patch127: bash-4.4-no-loadable-builtins.patch
# This option is undocumented in upstream and is documented by this patch # This option is undocumented in upstream and is documented by this patch
Patch128: bash-5.0-syslog-history.patch Patch128: bash-5.0-syslog-history.patch
# 2122331 - Heap-buffer-overflow in valid_parameter_transform
# This patch should be removed while rebasing to bash-5.2
Patch129: bash-5.2-check-xform.patch
BuildRequires: gcc BuildRequires: gcc
BuildRequires: texinfo bison BuildRequires: texinfo bison
BuildRequires: ncurses-devel BuildRequires: ncurses-devel
@ -322,6 +318,10 @@ end
%{_libdir}/pkgconfig/%{name}.pc %{_libdir}/pkgconfig/%{name}.pc
%changelog %changelog
* Tue Oct 04 2022 situ <svashisht@redhat.com> - 5.2.0-1
- Update to bash-5.2
Resolves: #2129927
* Mon Sep 26 2022 Siteshwar Vashisht <svashisht@redhat.com> - 5.1.16-4 * Mon Sep 26 2022 Siteshwar Vashisht <svashisht@redhat.com> - 5.1.16-4
- Add a null check in parameter_brace_transform() function - Add a null check in parameter_brace_transform() function
Resolves: #2122331 Resolves: #2122331

View File

@ -1 +1 @@
SHA512 (bash-5.1.tar.gz) = c44a0ce381469219548a3a27589af3fea4f22eda1ca4e9434b59fc16da81b471c29ce18e31590e0860a6a251a664b68c2b45e3a17d22cfc02799ffd9a208390c SHA512 (bash-5.2.tar.gz) = 5647636223ba336bf33e0c65e516d8ebcf6932de8b44f37bc468eedb87579c628ad44213f78534beb10f47aebb9c6fa670cb0bed3b4e7717e5faf7e9a1ef81ae