This is a major update to the latest version of bash.
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org --- bash/bash.nm | 2 +- bash/patches/bash-2.05b-xcc.patch | 19 --- bash/patches/bash-4.3-noecho.patch | 31 +++-- bash/patches/bash-5.0-patch-1.patch | 150 +++++++++++++++++++++ bash/patches/bash-5.0-patch-2.patch | 96 +++++++++++++ bash/patches/bash-5.0-patch-3.patch | 202 ++++++++++++++++++++++++++++ bash/patches/bash-5.0-patch-4.patch | 42 ++++++ bash/patches/bash-5.0-patch-5.patch | 102 ++++++++++++++ bash/patches/bash-5.0-patch-6.patch | 39 ++++++ bash/patches/bash-5.0-patch-7.patch | 51 +++++++ bash/patches/bash-requires.patch | 155 ++++++++++----------- bash/patches/bash-tty-tests.patch | 41 +++--- 12 files changed, 798 insertions(+), 132 deletions(-) delete mode 100644 bash/patches/bash-2.05b-xcc.patch create mode 100644 bash/patches/bash-5.0-patch-1.patch create mode 100644 bash/patches/bash-5.0-patch-2.patch create mode 100644 bash/patches/bash-5.0-patch-3.patch create mode 100644 bash/patches/bash-5.0-patch-4.patch create mode 100644 bash/patches/bash-5.0-patch-5.patch create mode 100644 bash/patches/bash-5.0-patch-6.patch create mode 100644 bash/patches/bash-5.0-patch-7.patch
diff --git a/bash/bash.nm b/bash/bash.nm index 0ca9d1560..4179d3add 100644 --- a/bash/bash.nm +++ b/bash/bash.nm @@ -4,7 +4,7 @@ ###############################################################################
name = bash -version = 4.4 +version = 5.0 release = 1
groups = System/Tools diff --git a/bash/patches/bash-2.05b-xcc.patch b/bash/patches/bash-2.05b-xcc.patch deleted file mode 100644 index ad4283260..000000000 --- a/bash/patches/bash-2.05b-xcc.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- bash-3.1/Makefile.in.xcc 2005-10-25 19:37:52.000000000 +0100 -+++ bash-3.1/Makefile.in 2005-12-23 16:11:09.000000000 +0000 -@@ -68,6 +68,7 @@ - ARFLAGS = @ARFLAGS@ - RANLIB = @RANLIB@ - SIZE = @SIZE@ -+STRIP = strip - - INSTALL = @INSTALL@ - INSTALL_PROGRAM = @INSTALL_PROGRAM@ -@@ -535,7 +536,7 @@ - @chmod a+rx bashbug - - strip: $(Program) .made -- strip $(Program) -+ $(STRIP) $(Program) - ls -l $(Program) - -$(SIZE) $(Program) - diff --git a/bash/patches/bash-4.3-noecho.patch b/bash/patches/bash-4.3-noecho.patch index 8a2842ac5..8adf36d93 100644 --- a/bash/patches/bash-4.3-noecho.patch +++ b/bash/patches/bash-4.3-noecho.patch @@ -1,25 +1,29 @@ ---- bash-4.3/parse.y 2014-05-29 14:46:09.545543384 +0200 -+++ bash-4.3/parse.y 2014-05-29 14:48:40.758626213 +0200 -@@ -3858,6 +3858,8 @@ xparse_dolparen (base, string, indp, fla +diff --git a/parse.y b/parse.y +index 07e6e3e..4cd373f 100644 +--- a/parse.y ++++ b/parse.y +@@ -4410,6 +4410,8 @@ xparse_dolparen (base, string, indp, flags) save_parser_state (&ps); save_input_line_state (&ls); orig_eof_token = shell_eof_token; + /* avoid echoing every substitution again */ + echo_input_at_read = 0; - - /*(*/ - parser_state |= PST_CMDSUBST|PST_EOFTOKEN; /* allow instant ')' */ /*(*/ ---- bash-4.3/subst.c 2014-05-29 16:04:35.802784549 +0200 -+++ bash-4.3/subst.c 2014-05-29 16:08:25.021942676 +0200 -@@ -7103,6 +7103,7 @@ param_expand (string, sindex, quoted, ex + #if defined (ALIAS) || defined (DPAREN_ARITHMETIC) + saved_pushed_strings = pushed_string_list; /* separate parsing context */ + pushed_string_list = (STRING_SAVER *)NULL; +diff --git a/subst.c b/subst.c +index 9559187..0c2caa6 100644 +--- a/subst.c ++++ b/subst.c +@@ -9145,6 +9145,7 @@ param_expand (string, sindex, quoted, expanded_something, WORD_LIST *list; WORD_DESC *tdesc, *ret; int tflag; + int old_echo_input;
+ /*itrace("param_expand: `%s' pflags = %d", string+*sindex, pflags);*/ zindex = *sindex; - c = string[++zindex]; -@@ -7401,6 +7402,9 @@ arithsub: +@@ -9514,6 +9515,9 @@ arithsub: }
comsub: @@ -29,7 +33,7 @@ if (pflags & PF_NOCOMSUB) /* we need zindex+1 because string[zindex] == RPAREN */ temp1 = substring (string, *sindex, zindex+1); -@@ -7413,6 +7417,7 @@ comsub: +@@ -9526,6 +9530,7 @@ comsub: } FREE (temp); temp = temp1; @@ -37,3 +41,6 @@ break;
/* Do POSIX.2d9-style arithmetic substitution. This will probably go +-- +2.17.2 + diff --git a/bash/patches/bash-5.0-patch-1.patch b/bash/patches/bash-5.0-patch-1.patch new file mode 100644 index 000000000..254fd9ee0 --- /dev/null +++ b/bash/patches/bash-5.0-patch-1.patch @@ -0,0 +1,150 @@ +From 4d2e315490b778707b3a3afdfc514d5083a97a11 Mon Sep 17 00:00:00 2001 +From: Chet Ramey chet.ramey@case.edu +Date: Fri, 18 Jan 2019 15:12:37 -0500 +Subject: [PATCH] Bash-5.0 patch 1: fix pathname expansion of directory names + containing backslashes + +--- + bashline.c | 62 +++++++++++++++++++++++++++++++++++++++++--- + lib/glob/glob_loop.c | 6 ----- + patchlevel.h | 2 +- + 3 files changed, 60 insertions(+), 10 deletions(-) + +diff --git a/bashline.c b/bashline.c +index 2846aabf..75e79f1a 100644 +--- a/bashline.c ++++ b/bashline.c +@@ -231,6 +231,7 @@ static int bash_possible_variable_completions __P((int, int)); + static int bash_complete_command __P((int, int)); + static int bash_possible_command_completions __P((int, int)); + ++static int completion_glob_pattern __P((char *)); + static char *glob_complete_word __P((const char *, int)); + static int bash_glob_completion_internal __P((int)); + static int bash_glob_complete_word __P((int, int)); +@@ -1741,7 +1742,7 @@ bash_default_completion (text, start, end, qc, compflags) + + /* This could be a globbing pattern, so try to expand it using pathname + expansion. */ +- if (!matches && glob_pattern_p (text)) ++ if (!matches && completion_glob_pattern ((char *)text)) + { + matches = rl_completion_matches (text, glob_complete_word); + /* A glob expression that matches more than one filename is problematic. +@@ -1850,7 +1851,7 @@ command_word_completion_function (hint_text, state) + glob_matches = (char **)NULL; + } + +- globpat = glob_pattern_p (hint_text); ++ globpat = completion_glob_pattern ((char *)hint_text); + + /* If this is an absolute program name, do not check it against + aliases, reserved words, functions or builtins. We must check +@@ -3713,6 +3714,61 @@ bash_complete_command_internal (what_to_do) + return bash_specific_completion (what_to_do, command_word_completion_function); + } + ++static int ++completion_glob_pattern (string) ++ char *string; ++{ ++ register int c; ++ char *send; ++ int open; ++ ++ DECLARE_MBSTATE; ++ ++ open = 0; ++ send = string + strlen (string); ++ ++ while (c = *string++) ++ { ++ switch (c) ++ { ++ case '?': ++ case '*': ++ return (1); ++ ++ case '[': ++ open++; ++ continue; ++ ++ case ']': ++ if (open) ++ return (1); ++ continue; ++ ++ case '+': ++ case '@': ++ case '!': ++ if (*string == '(') /*)*/ ++ return (1); ++ continue; ++ ++ case '\': ++ if (*string == 0) ++ return (0); ++ } ++ ++ /* Advance one fewer byte than an entire multibyte character to ++ account for the auto-increment in the loop above. */ ++#ifdef HANDLE_MULTIBYTE ++ string--; ++ ADVANCE_CHAR_P (string, send - string); ++ string++; ++#else ++ ADVANCE_CHAR_P (string, send - string); ++#endif ++ } ++ return (0); ++} ++ + static char *globtext; + static char *globorig; + +@@ -3877,7 +3933,7 @@ bash_vi_complete (count, key) + t = substring (rl_line_buffer, p, rl_point); + } + +- if (t && glob_pattern_p (t) == 0) ++ if (t && completion_glob_pattern (t) == 0) + rl_explicit_arg = 1; /* XXX - force glob_complete_word to append `*' */ + FREE (t); + +diff --git a/lib/glob/glob_loop.c b/lib/glob/glob_loop.c +index 5f319cc2..7d6ae211 100644 +--- a/lib/glob/glob_loop.c ++++ b/lib/glob/glob_loop.c +@@ -54,17 +54,11 @@ INTERNAL_GLOB_PATTERN_P (pattern) + continue; + + case L('\'): +-#if 0 + /* Don't let the pattern end in a backslash (GMATCH returns no match + if the pattern ends in a backslash anyway), but otherwise return 1, + since the matching engine uses backslash as an escape character + and it can be removed. */ + return (*p != L('\0')); +-#else +- /* The pattern may not end with a backslash. */ +- if (*p++ == L('\0')) +- return 0; +-#endif + } + + return 0; +diff --git a/patchlevel.h b/patchlevel.h +index 1cd7c96c..40db1a32 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 0 ++#define PATCHLEVEL 1 + + #endif /* _PATCHLEVEL_H_ */ +-- +2.17.2 + diff --git a/bash/patches/bash-5.0-patch-2.patch b/bash/patches/bash-5.0-patch-2.patch new file mode 100644 index 000000000..b9858ae18 --- /dev/null +++ b/bash/patches/bash-5.0-patch-2.patch @@ -0,0 +1,96 @@ +From ddf3f643cb9b9a2ca8e6d996c605e4332204874c Mon Sep 17 00:00:00 2001 +From: Chet Ramey chet.ramey@case.edu +Date: Fri, 18 Jan 2019 15:13:57 -0500 +Subject: [PATCH] Bash-5.0 patch 2: fix expansion of aliases whose value ends + with an unquoted tab + +--- + parse.y | 5 ++++- + parser.h | 1 + + patchlevel.h | 2 +- + y.tab.c | 5 ++++- + 4 files changed, 10 insertions(+), 3 deletions(-) + +diff --git a/parse.y b/parse.y +index 3ff87bcc..07e6e3e4 100644 +--- a/parse.y ++++ b/parse.y +@@ -2557,12 +2557,14 @@ next_alias_char: + if (uc == 0 && pushed_string_list && pushed_string_list->flags != PSH_SOURCE && + pushed_string_list->flags != PSH_DPAREN && + (parser_state & PST_COMMENT) == 0 && ++ (parser_state & PST_ENDALIAS) == 0 && /* only once */ + shell_input_line_index > 0 && +- shell_input_line[shell_input_line_index-1] != ' ' && ++ shellblank (shell_input_line[shell_input_line_index-1]) == 0 && + shell_input_line[shell_input_line_index-1] != '\n' && + shellmeta (shell_input_line[shell_input_line_index-1]) == 0 && + (current_delimiter (dstack) != ''' && current_delimiter (dstack) != '"')) + { ++ parser_state |= PST_ENDALIAS; + return ' '; /* END_ALIAS */ + } + #endif +@@ -2571,6 +2573,7 @@ pop_alias: + /* This case works for PSH_DPAREN as well */ + if (uc == 0 && pushed_string_list && pushed_string_list->flags != PSH_SOURCE) + { ++ parser_state &= ~PST_ENDALIAS; + pop_string (); + uc = shell_input_line[shell_input_line_index]; + if (uc) +diff --git a/parser.h b/parser.h +index 54dd2c88..6d08915d 100644 +--- a/parser.h ++++ b/parser.h +@@ -47,6 +47,7 @@ + #define PST_REPARSE 0x040000 /* re-parsing in parse_string_to_word_list */ + #define PST_REDIRLIST 0x080000 /* parsing a list of redirections preceding a simple command name */ + #define PST_COMMENT 0x100000 /* parsing a shell comment; used by aliases */ ++#define PST_ENDALIAS 0x200000 /* just finished expanding and consuming an alias */ + + /* Definition of the delimiter stack. Needed by parse.y and bashhist.c. */ + struct dstack { +diff --git a/patchlevel.h b/patchlevel.h +index 40db1a32..a988d852 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 1 ++#define PATCHLEVEL 2 + + #endif /* _PATCHLEVEL_H_ */ +diff --git a/y.tab.c b/y.tab.c +index 1abe2c50..7efce3c8 100644 +--- a/y.tab.c ++++ b/y.tab.c +@@ -4873,12 +4873,14 @@ next_alias_char: + if (uc == 0 && pushed_string_list && pushed_string_list->flags != PSH_SOURCE && + pushed_string_list->flags != PSH_DPAREN && + (parser_state & PST_COMMENT) == 0 && ++ (parser_state & PST_ENDALIAS) == 0 && /* only once */ + shell_input_line_index > 0 && +- shell_input_line[shell_input_line_index-1] != ' ' && ++ shellblank (shell_input_line[shell_input_line_index-1]) == 0 && + shell_input_line[shell_input_line_index-1] != '\n' && + shellmeta (shell_input_line[shell_input_line_index-1]) == 0 && + (current_delimiter (dstack) != ''' && current_delimiter (dstack) != '"')) + { ++ parser_state |= PST_ENDALIAS; + return ' '; /* END_ALIAS */ + } + #endif +@@ -4887,6 +4889,7 @@ pop_alias: + /* This case works for PSH_DPAREN as well */ + if (uc == 0 && pushed_string_list && pushed_string_list->flags != PSH_SOURCE) + { ++ parser_state &= ~PST_ENDALIAS; + pop_string (); + uc = shell_input_line[shell_input_line_index]; + if (uc) +-- +2.17.2 + diff --git a/bash/patches/bash-5.0-patch-3.patch b/bash/patches/bash-5.0-patch-3.patch new file mode 100644 index 000000000..509f52efb --- /dev/null +++ b/bash/patches/bash-5.0-patch-3.patch @@ -0,0 +1,202 @@ +From fcf6ae7d069a64741e9484cf219d7fe95de9e796 Mon Sep 17 00:00:00 2001 +From: Chet Ramey chet.ramey@case.edu +Date: Tue, 19 Mar 2019 10:05:39 -0400 +Subject: [PATCH] Bash-5.0 patch 3: improvements when globbing directory names + containing backslashes + +--- + bashline.c | 2 +- + lib/glob/glob.c | 25 +++++++++++++++++++++---- + lib/glob/glob.h | 1 + + lib/glob/glob_loop.c | 23 ++++++++++++++++------- + patchlevel.h | 2 +- + pathexp.c | 16 ++++++++++++---- + 6 files changed, 52 insertions(+), 17 deletions(-) + +diff --git a/bashline.c b/bashline.c +index 75e79f1a..824ea9d9 100644 +--- a/bashline.c ++++ b/bashline.c +@@ -3752,7 +3752,7 @@ completion_glob_pattern (string) + continue; + + case '\': +- if (*string == 0) ++ if (*string++ == 0) + return (0); + } + +diff --git a/lib/glob/glob.c b/lib/glob/glob.c +index 22d90a5c..398253b5 100644 +--- a/lib/glob/glob.c ++++ b/lib/glob/glob.c +@@ -1061,7 +1061,7 @@ glob_filename (pathname, flags) + char *directory_name, *filename, *dname, *fn; + unsigned int directory_len; + int free_dirname; /* flag */ +- int dflags; ++ int dflags, hasglob; + + result = (char **) malloc (sizeof (char *)); + result_size = 1; +@@ -1110,9 +1110,12 @@ glob_filename (pathname, flags) + free_dirname = 1; + } + ++ hasglob = 0; + /* If directory_name contains globbing characters, then we +- have to expand the previous levels. Just recurse. */ +- if (directory_len > 0 && glob_pattern_p (directory_name)) ++ have to expand the previous levels. Just recurse. ++ If glob_pattern_p returns != [0,1] we have a pattern that has backslash ++ quotes but no unquoted glob pattern characters. We dequote it below. */ ++ if (directory_len > 0 && (hasglob = glob_pattern_p (directory_name)) == 1) + { + char **directories, *d, *p; + register unsigned int i; +@@ -1175,7 +1178,7 @@ glob_filename (pathname, flags) + if (d[directory_len - 1] == '/') + d[directory_len - 1] = '\0'; + +- directories = glob_filename (d, dflags); ++ directories = glob_filename (d, dflags|GX_RECURSE); + + if (free_dirname) + { +@@ -1332,6 +1335,20 @@ only_filename: + free (directory_name); + return (NULL); + } ++ /* If we have a directory name with quoted characters, and we are ++ being called recursively to glob the directory portion of a pathname, ++ we need to dequote the directory name before returning it so the ++ caller can read the directory */ ++ if (directory_len > 0 && hasglob == 2 && (flags & GX_RECURSE) != 0) ++ { ++ dequote_pathname (directory_name); ++ directory_len = strlen (directory_name); ++ } ++ ++ /* We could check whether or not the dequoted directory_name is a ++ directory and return it here, returning the original directory_name ++ if not, but we don't do that yet. I'm not sure it matters. */ ++ + /* Handle GX_MARKDIRS here. */ + result[0] = (char *) malloc (directory_len + 1); + if (result[0] == NULL) +diff --git a/lib/glob/glob.h b/lib/glob/glob.h +index b9462333..56ac08ba 100644 +--- a/lib/glob/glob.h ++++ b/lib/glob/glob.h +@@ -30,6 +30,7 @@ + #define GX_NULLDIR 0x100 /* internal -- no directory preceding pattern */ + #define GX_ADDCURDIR 0x200 /* internal -- add passed directory name */ + #define GX_GLOBSTAR 0x400 /* turn on special handling of ** */ ++#define GX_RECURSE 0x800 /* internal -- glob_filename called recursively */ + + extern int glob_pattern_p __P((const char *)); + extern char **glob_vector __P((char *, char *, int)); +diff --git a/lib/glob/glob_loop.c b/lib/glob/glob_loop.c +index 7d6ae211..3a4f4f1e 100644 +--- a/lib/glob/glob_loop.c ++++ b/lib/glob/glob_loop.c +@@ -26,10 +26,10 @@ INTERNAL_GLOB_PATTERN_P (pattern) + { + register const GCHAR *p; + register GCHAR c; +- int bopen; ++ int bopen, bsquote; + + p = pattern; +- bopen = 0; ++ bopen = bsquote = 0; + + while ((c = *p++) != L('\0')) + switch (c) +@@ -55,13 +55,22 @@ INTERNAL_GLOB_PATTERN_P (pattern) + + case L('\'): + /* Don't let the pattern end in a backslash (GMATCH returns no match +- if the pattern ends in a backslash anyway), but otherwise return 1, +- since the matching engine uses backslash as an escape character +- and it can be removed. */ +- return (*p != L('\0')); ++ if the pattern ends in a backslash anyway), but otherwise note that ++ we have seen this, since the matching engine uses backslash as an ++ escape character and it can be removed. We return 2 later if we ++ have seen only backslash-escaped characters, so interested callers ++ know they can shortcut and just dequote the pathname. */ ++ if (*p != L('\0')) ++ { ++ p++; ++ bsquote = 1; ++ continue; ++ } ++ else /* (*p == L('\0')) */ ++ return 0; + } + +- return 0; ++ return bsquote ? 2 : 0; + } + + #undef INTERNAL_GLOB_PATTERN_P +diff --git a/patchlevel.h b/patchlevel.h +index a988d852..e7e960c1 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 2 ++#define PATCHLEVEL 3 + + #endif /* _PATCHLEVEL_H_ */ +diff --git a/pathexp.c b/pathexp.c +index b51729a7..c1bf2d89 100644 +--- a/pathexp.c ++++ b/pathexp.c +@@ -65,11 +65,11 @@ unquoted_glob_pattern_p (string) + { + register int c; + char *send; +- int open; ++ int open, bsquote; + + DECLARE_MBSTATE; + +- open = 0; ++ open = bsquote = 0; + send = string + strlen (string); + + while (c = *string++) +@@ -100,7 +100,14 @@ unquoted_glob_pattern_p (string) + can be removed by the matching engine, so we have to run it through + globbing. */ + case '\': +- return (*string != 0); ++ if (*string != '\0' && *string != '/') ++ { ++ bsquote = 1; ++ string++; ++ continue; ++ } ++ else if (*string == 0) ++ return (0); + + case CTLESC: + if (*string++ == '\0') +@@ -117,7 +124,8 @@ unquoted_glob_pattern_p (string) + ADVANCE_CHAR_P (string, send - string); + #endif + } +- return (0); ++ ++ return (bsquote ? 2 : 0); + } + + /* Return 1 if C is a character that is `special' in a POSIX ERE and needs to +-- +2.17.2 + diff --git a/bash/patches/bash-5.0-patch-4.patch b/bash/patches/bash-5.0-patch-4.patch new file mode 100644 index 000000000..899383312 --- /dev/null +++ b/bash/patches/bash-5.0-patch-4.patch @@ -0,0 +1,42 @@ +From 16c907aa3bb427618733e5a6f2f4e2fc5a3488d3 Mon Sep 17 00:00:00 2001 +From: Chet Ramey chet.ramey@case.edu +Date: Sat, 20 Apr 2019 14:24:28 -0400 +Subject: [PATCH] Bash-5.0 patch 4: the wait builtin without arguments only + waits for known children the shell started + +--- + jobs.c | 4 +--- + patchlevel.h | 2 +- + 2 files changed, 2 insertions(+), 4 deletions(-) + +diff --git a/jobs.c b/jobs.c +index ce2bdf24..ae3c54c6 100644 +--- a/jobs.c ++++ b/jobs.c +@@ -2488,10 +2488,8 @@ wait_for_background_pids () + r = wait_for (last_procsub_child->pid); + wait_procsubs (); + reap_procsubs (); +-#if 1 ++#if 0 + /* We don't want to wait indefinitely if we have stopped children. */ +- /* XXX - should add a loop that goes through the list of process +- substitutions and waits for each proc in turn before this code. */ + if (any_stopped == 0) + { + /* Check whether or not we have any unreaped children. */ +diff --git a/patchlevel.h b/patchlevel.h +index e7e960c1..c059f0bd 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 3 ++#define PATCHLEVEL 4 + + #endif /* _PATCHLEVEL_H_ */ +-- +2.17.2 + diff --git a/bash/patches/bash-5.0-patch-5.patch b/bash/patches/bash-5.0-patch-5.patch new file mode 100644 index 000000000..1fb4fafaf --- /dev/null +++ b/bash/patches/bash-5.0-patch-5.patch @@ -0,0 +1,102 @@ +From 41f5420db7a911fb0833be693205f4db41f05434 Mon Sep 17 00:00:00 2001 +From: Chet Ramey chet.ramey@case.edu +Date: Sat, 20 Apr 2019 14:25:52 -0400 +Subject: [PATCH] Bash-5.0 patch 5: prevent optimizing forks away too + aggressively + +--- + builtins/evalstring.c | 26 +++++++++++++++++++++++--- + command.h | 1 + + execute_cmd.c | 2 ++ + patchlevel.h | 2 +- + 4 files changed, 27 insertions(+), 4 deletions(-) + +diff --git a/builtins/evalstring.c b/builtins/evalstring.c +index 1496eeec..cadc9bc0 100644 +--- a/builtins/evalstring.c ++++ b/builtins/evalstring.c +@@ -100,12 +100,22 @@ should_suppress_fork (command) + ((command->flags & CMD_INVERT_RETURN) == 0)); + } + ++int ++can_optimize_connection (command) ++ COMMAND *command; ++{ ++ return (*bash_input.location.string == '\0' && ++ (command->value.Connection->connector == AND_AND || command->value.Connection->connector == OR_OR || command->value.Connection->connector == ';') && ++ command->value.Connection->second->type == cm_simple); ++} ++ + void + optimize_fork (command) + COMMAND *command; + { + if (command->type == cm_connection && +- (command->value.Connection->connector == AND_AND || command->value.Connection->connector == OR_OR) && ++ (command->value.Connection->connector == AND_AND || command->value.Connection->connector == OR_OR || command->value.Connection->connector == ';') && ++ (command->value.Connection->second->flags & CMD_TRY_OPTIMIZING) && + should_suppress_fork (command->value.Connection->second)) + { + command->value.Connection->second->flags |= CMD_NO_FORK; +@@ -412,8 +422,18 @@ parse_and_execute (string, from_file, flags) + command->flags |= CMD_NO_FORK; + command->value.Simple->flags |= CMD_NO_FORK; + } +- else if (command->type == cm_connection) +- optimize_fork (command); ++ ++ /* Can't optimize forks out here execept for simple commands. ++ This knows that the parser sets up commands as left-side heavy ++ (&& and || are left-associative) and after the single parse, ++ if we are at the end of the command string, the last in a ++ series of connection commands is ++ command->value.Connection->second. */ ++ else if (command->type == cm_connection && can_optimize_connection (command)) ++ { ++ command->value.Connection->second->flags |= CMD_TRY_OPTIMIZING; ++ command->value.Connection->second->value.Simple->flags |= CMD_TRY_OPTIMIZING; ++ } + #endif /* ONESHOT */ + + /* See if this is a candidate for $( <file ). */ +diff --git a/command.h b/command.h +index 32495162..b9e9b669 100644 +--- a/command.h ++++ b/command.h +@@ -186,6 +186,7 @@ typedef struct element { + #define CMD_COPROC_SUBSHELL 0x1000 + #define CMD_LASTPIPE 0x2000 + #define CMD_STDPATH 0x4000 /* use standard path for command lookup */ ++#define CMD_TRY_OPTIMIZING 0x8000 /* try to optimize this simple command */ + + /* What a command looks like. */ + typedef struct command { +diff --git a/execute_cmd.c b/execute_cmd.c +index 8b3c83aa..f1d74bfe 100644 +--- a/execute_cmd.c ++++ b/execute_cmd.c +@@ -2767,6 +2767,8 @@ execute_connection (command, asynchronous, pipe_in, pipe_out, fds_to_close) + ((command->value.Connection->connector == OR_OR) && + (exec_result != EXECUTION_SUCCESS))) + { ++ optimize_fork (command); ++ + second = command->value.Connection->second; + if (ignore_return && second) + second->flags |= CMD_IGNORE_RETURN; +diff --git a/patchlevel.h b/patchlevel.h +index c059f0bd..1bc098b8 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_ */ +-- +2.17.2 + diff --git a/bash/patches/bash-5.0-patch-6.patch b/bash/patches/bash-5.0-patch-6.patch new file mode 100644 index 000000000..bfd84603b --- /dev/null +++ b/bash/patches/bash-5.0-patch-6.patch @@ -0,0 +1,39 @@ +From dfd2cc6ac5558e252af0a7cb829a9629bf782e17 Mon Sep 17 00:00:00 2001 +From: Chet Ramey chet.ramey@case.edu +Date: Sat, 20 Apr 2019 14:27:00 -0400 +Subject: [PATCH] Bash-5.0 patch 6: allow building with SYSLOG_HISTORY defined + without defining SYSLOG_SHOPT + +--- + builtins/shopt.def | 2 +- + patchlevel.h | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/builtins/shopt.def b/builtins/shopt.def +index f6dc6f97..1c485361 100644 +--- a/builtins/shopt.def ++++ b/builtins/shopt.def +@@ -122,7 +122,7 @@ extern int assoc_expand_once; + extern int array_expand_once; + #endif + +-#if defined (SYSLOG_HISTORY) && defined (SYSLOG_SHOPT) ++#if defined (SYSLOG_HISTORY) + extern int syslog_history; + #endif + +diff --git a/patchlevel.h b/patchlevel.h +index 1bc098b8..14bff9fc 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_ */ +-- +2.17.2 + diff --git a/bash/patches/bash-5.0-patch-7.patch b/bash/patches/bash-5.0-patch-7.patch new file mode 100644 index 000000000..2a4315e71 --- /dev/null +++ b/bash/patches/bash-5.0-patch-7.patch @@ -0,0 +1,51 @@ +From 3ba697465bc74fab513a26dea700cc82e9f4724e Mon Sep 17 00:00:00 2001 +From: Chet Ramey chet.ramey@case.edu +Date: Sat, 20 Apr 2019 14:27:56 -0400 +Subject: [PATCH] Bash-5.0 patch 7: fix exec builtin leaving the terminal in + the wrong process group + +--- + jobs.c | 12 +++++------- + patchlevel.h | 2 +- + 2 files changed, 6 insertions(+), 8 deletions(-) + +diff --git a/jobs.c b/jobs.c +index ae3c54c6..6bc31dca 100644 +--- a/jobs.c ++++ b/jobs.c +@@ -4837,15 +4837,13 @@ void + end_job_control () + { + if (job_control) +- { +- terminate_stopped_jobs (); ++ terminate_stopped_jobs (); + +- if (original_pgrp >= 0) +- give_terminal_to (original_pgrp, 1); +- } ++ if (original_pgrp >= 0 && terminal_pgrp != original_pgrp) ++ give_terminal_to (original_pgrp, 1); + +- if (original_pgrp >= 0) +- setpgid (0, original_pgrp); ++ if (original_pgrp >= 0 && setpgid (0, original_pgrp) == 0) ++ shell_pgrp = original_pgrp; + } + + /* Restart job control by closing shell tty and reinitializing. This is +diff --git a/patchlevel.h b/patchlevel.h +index 14bff9fc..deb9c5b7 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.17.2 + diff --git a/bash/patches/bash-requires.patch b/bash/patches/bash-requires.patch index 888de173c..35670bd55 100644 --- a/bash/patches/bash-requires.patch +++ b/bash/patches/bash-requires.patch @@ -1,40 +1,32 @@ -commit efb0da0c0fee3e3ca21b21cd72f63cdfd7766d45 -Author: Michael Tremer michael.tremer@ipfire.org -Date: Sun Sep 18 14:12:44 2016 +0100 - - Implement --rpm-requires - - Signed-off-by: Michael Tremer michael.tremer@ipfire.org - diff --git a/builtins.h b/builtins.h -index 0cfea18..c0c6acc 100644 +index dac95fd..5b7e811 100644 --- a/builtins.h +++ b/builtins.h -@@ -42,6 +42,7 @@ +@@ -45,6 +45,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 LOCALVAR_BUILTIN 0x40 /* This builtin creates local variables */ -+#define REQUIRES_BUILTIN 0x80 /* This builtin requires other files. */ ++#define REQUIRES_BUILTIN 0x80 /* This builtin requires other files. */
#define BASE_INDENT 4
diff --git a/builtins/mkbuiltins.c b/builtins/mkbuiltins.c -index 4f51201..69707ec 100644 +index 4f51201..91c25db 100644 --- a/builtins/mkbuiltins.c +++ b/builtins/mkbuiltins.c @@ -69,10 +69,15 @@ extern char *strcpy (); #define whitespace(c) (((c) == ' ') || ((c) == '\t'))
/* Flag values that builtins can have. */ -+/* These flags are for the C code generator, ++/* These flags are for the C code generator, + the C which is produced (./builtin.c) -+ includes the flags definitions found ++ includes the flags definitions found + in ../builtins.h */ #define BUILTIN_FLAG_SPECIAL 0x01 #define BUILTIN_FLAG_ASSIGNMENT 0x02 #define BUILTIN_FLAG_LOCALVAR 0x04 #define BUILTIN_FLAG_POSIX_BUILTIN 0x08 -+#define BUILTIN_FLAG_REQUIRES 0x16 ++#define BUILTIN_FLAG_REQUIRES 0x10
#define BASE_INDENT 4
@@ -58,17 +50,16 @@ index 4f51201..69707ec 100644
#if !defined (HAVE_RENAME) static int rename (); -@@ -831,6 +844,9 @@ builtin_handler (self, defs, arg) +@@ -831,6 +844,8 @@ builtin_handler (self, defs, arg) new->flags |= BUILTIN_FLAG_LOCALVAR; if (is_posix_builtin (name)) new->flags |= BUILTIN_FLAG_POSIX_BUILTIN; + if (is_requires_builtin (name)) + new->flags |= BUILTIN_FLAG_REQUIRES; -+
array_add ((char *)new, defs->builtins); building_builtin = 1; -@@ -1250,12 +1266,13 @@ write_builtins (defs, structfile, externfile) +@@ -1250,12 +1265,13 @@ write_builtins (defs, structfile, externfile) else fprintf (structfile, "(sh_builtin_func_t *)0x0, ");
@@ -83,7 +74,7 @@ index 4f51201..69707ec 100644 document_name (builtin));
/* Don't translate short document summaries that are identical -@@ -1645,6 +1662,13 @@ is_posix_builtin (name) +@@ -1645,6 +1661,13 @@ is_posix_builtin (name) return (_find_in_table (name, posix_builtins)); }
@@ -98,15 +89,15 @@ index 4f51201..69707ec 100644 static int rename (from, to) diff --git a/doc/bash.1 b/doc/bash.1 -index 9a7a384..1c738bb 100644 +index d91f1fd..111a66d 100644 --- a/doc/bash.1 +++ b/doc/bash.1 -@@ -238,6 +238,14 @@ The shell becomes restricted (see +@@ -239,6 +239,14 @@ The shell becomes restricted (see .B "RESTRICTED SHELL" below). .TP +.B --rpm-requires -+Produce the list of files that are required for the ++Produce the list of files that are required for the +shell script to run. This implies '-n' and is subject +to the same limitations as compile time error checking checking; +Command substitutions, Conditional expressions and @@ -117,15 +108,15 @@ index 9a7a384..1c738bb 100644 Equivalent to \fB-v\fP. .TP diff --git a/doc/bashref.texi b/doc/bashref.texi -index c0f4a2f..8e30d4f 100644 +index d33cd57..6fc4d18 100644 --- a/doc/bashref.texi +++ b/doc/bashref.texi -@@ -6243,6 +6243,13 @@ standard. @xref{Bash POSIX Mode}, for a description of the Bash +@@ -6453,6 +6453,13 @@ standard. @xref{Bash POSIX Mode}, for a description of the Bash @item --restricted Make the shell a restricted shell (@pxref{The Restricted Shell}).
+@item --rpm-requires -+Produce the list of files that are required for the ++Produce the list of files that are required for the +shell script to run. This implies '-n' and is subject +to the same limitations as compile time error checking checking; +Command substitutions, Conditional expressions and @command{eval} @@ -135,31 +126,24 @@ index c0f4a2f..8e30d4f 100644 Equivalent to @option{-v}. Print shell input lines as they're read.
diff --git a/eval.c b/eval.c -index db863e7..5a5af32 100644 +index f02d6e4..76c1e8d 100644 --- a/eval.c +++ b/eval.c -@@ -56,6 +56,7 @@ extern int need_here_doc; - extern int current_command_number, current_command_line_count, line_number; - extern int expand_aliases; - extern char *ps0_prompt; -+extern int rpm_requires; - - #if defined (HAVE_POSIX_SIGNALS) - extern sigset_t top_level_mask; -@@ -148,7 +149,7 @@ reader_loop () +@@ -142,7 +142,8 @@ reader_loop ()
if (read_command () == 0) { - if (interactive_shell == 0 && read_but_dont_execute) ++ + if (interactive_shell == 0 && (read_but_dont_execute && !rpm_requires)) { last_command_exit_value = EXECUTION_SUCCESS; dispose_command (global_command); diff --git a/execute_cmd.c b/execute_cmd.c -index 2a3df6d..2e3fb0c 100644 +index 8b3c83a..4eae19c 100644 --- a/execute_cmd.c +++ b/execute_cmd.c -@@ -529,6 +529,8 @@ async_redirect_stdin () +@@ -538,6 +538,8 @@ async_redirect_stdin ()
#define DESCRIBE_PID(pid) do { if (interactive) describe_pid (pid); } while (0)
@@ -168,7 +152,7 @@ index 2a3df6d..2e3fb0c 100644 /* Execute the command passed in COMMAND, perhaps doing it asynchronously. COMMAND is exactly what read_command () places into GLOBAL_COMMAND. ASYNCHROUNOUS, if non-zero, says to do this command in the background. -@@ -561,7 +563,13 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out, +@@ -569,7 +571,13 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
if (breaking || continuing) return (last_command_exit_value); @@ -178,14 +162,14 @@ index 2a3df6d..2e3fb0c 100644 + if (rpm_requires && command->type == cm_function_def) + return last_command_exit_value = + execute_intern_function (command->value.Function_def->name, -+ command->value.Function_def->command); ++ command->value.Function_def); + if (read_but_dont_execute) return (EXECUTION_SUCCESS);
QUIT; -@@ -5609,7 +5617,7 @@ execute_intern_function (name, funcdef) - - if (check_identifier (name, posixly_correct) == 0) +@@ -2813,7 +2821,7 @@ execute_for_command (for_command) + save_line_number = line_number; + if (check_identifier (for_command->name, 1) == 0) { - if (posixly_correct && interactive_shell == 0) + if (posixly_correct && interactive_shell == 0 && rpm_requires == 0) @@ -193,53 +177,24 @@ index 2a3df6d..2e3fb0c 100644 last_command_exit_value = EX_BADUSAGE; jump_to_top_level (ERREXIT); diff --git a/execute_cmd.h b/execute_cmd.h -index 62bec82..d42dc85 100644 +index dc2f15e..506fff4 100644 --- a/execute_cmd.h +++ b/execute_cmd.h -@@ -22,6 +22,8 @@ +@@ -22,6 +22,9 @@ #define _EXECUTE_CMD_H_
#include "stdc.h" +#include "variables.h" +#include "command.h" ++
#if defined (ARRAY_VARS) struct func_array_state diff --git a/make_cmd.c b/make_cmd.c -index b42e9ff..95ec723 100644 +index ecbbfd6..3d8bfa4 100644 --- a/make_cmd.c +++ b/make_cmd.c -@@ -42,11 +42,15 @@ - #include "flags.h" - #include "make_cmd.h" - #include "dispose_cmd.h" -+#include "execute_cmd.h" - #include "variables.h" - #include "subst.h" - #include "input.h" - #include "ocache.h" - #include "externs.h" -+#include "builtins.h" -+ -+#include "builtins/common.h" - - #if defined (JOB_CONTROL) - #include "jobs.h" -@@ -57,9 +61,13 @@ - extern int line_number, current_command_line_count, parser_state; - extern int last_command_exit_value; - extern int shell_initialized; -+extern int rpm_requires; - - int here_doc_first_line = 0; - -+static char *alphabet_set = "abcdefghijklmnopqrstuvwxyz" -+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; -+ - /* Object caching */ - sh_obj_cache_t wdcache = {0, 0, 0}; - sh_obj_cache_t wlcache = {0, 0, 0}; -@@ -839,6 +847,27 @@ make_coproc_command (name, command) +@@ -828,6 +828,27 @@ make_coproc_command (name, command) return (make_command (cm_coproc, (SIMPLE_COM *)temp)); }
@@ -251,9 +206,9 @@ index b42e9ff..95ec723 100644 + if (strchr(filename, '$') || (filename[0] != '/' && strchr(filename, '/'))) + return; + -+ /* ++ /* + if the executable is called via variable substitution we can -+ not dermine what it is at compile time. ++ not dermine what it is at compile time. + + if the executable consists only of characters not in the + alphabet we do not consider it a dependency just an artifact @@ -267,7 +222,7 @@ index b42e9ff..95ec723 100644 /* Reverse the word list and redirection list in the simple command has just been parsed. It seems simpler to do this here the one time then by any other method that I can think of. */ -@@ -856,6 +885,27 @@ clean_simple_command (command) +@@ -845,6 +866,28 @@ clean_simple_command (command) REVERSE_LIST (command->value.Simple->redirects, REDIRECT *); }
@@ -291,15 +246,16 @@ index b42e9ff..95ec723 100644 + output_requirement (find_function(cmd0) ? "function" : "executable", cmd0); + } + } /*rpm_requires*/ ++ + parser_state &= ~PST_REDIRLIST; return (command); } diff --git a/shell.c b/shell.c -index 45b77f9..b43de50 100644 +index a2b2a55..c5d99b3 100644 --- a/shell.c +++ b/shell.c -@@ -201,6 +201,9 @@ int have_devfd = 0; +@@ -193,6 +193,9 @@ int have_devfd = 0; /* The name of the .(shell)rc file. */ static char *bashrc_file = DEFAULT_BASHRC;
@@ -309,7 +265,7 @@ index 45b77f9..b43de50 100644 /* Non-zero means to act more like the Bourne shell on startup. */ static int act_like_sh;
-@@ -264,6 +267,7 @@ static const struct { +@@ -259,6 +262,7 @@ static const struct { { "protected", Int, &protected_mode, (char **)0x0 }, #endif { "rcfile", Charp, (int *)0x0, &bashrc_file }, @@ -317,7 +273,7 @@ index 45b77f9..b43de50 100644 #if defined (RESTRICTED_SHELL) { "restricted", Int, &restricted, (char **)0x0 }, #endif -@@ -500,6 +504,12 @@ main (argc, argv, env) +@@ -496,6 +500,12 @@ main (argc, argv, env) if (dump_translatable_strings) read_but_dont_execute = 1;
@@ -330,3 +286,36 @@ index 45b77f9..b43de50 100644 if (running_setuid && privileged_mode == 0) disable_priv_mode ();
+diff --git a/shell.h b/shell.h +index 8072605..6c4149d 100644 +--- a/shell.h ++++ b/shell.h +@@ -34,12 +34,15 @@ + #include "maxpath.h" + #include "unwind_prot.h" + #include "dispose_cmd.h" ++#include "execute_cmd.h" + #include "make_cmd.h" + #include "ocache.h" + #include "subst.h" + #include "sig.h" + #include "pathnames.h" + #include "externs.h" ++#include "builtins.h" ++#include "builtins/common.h" + + extern int EOF_Reached; + +@@ -99,6 +102,9 @@ extern int interactive, interactive_shell; + extern int startup_state; + extern int reading_shell_script; + extern int shell_initialized; ++extern int rpm_requires; ++static char *alphabet_set = "abcdefghijklmnopqrstuvwxyz" ++ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + extern int bash_argv_initialized; + extern int subshell_environment; + extern int current_command_number; +-- +2.17.2 + diff --git a/bash/patches/bash-tty-tests.patch b/bash/patches/bash-tty-tests.patch index 984f1b40d..f9b653245 100644 --- a/bash/patches/bash-tty-tests.patch +++ b/bash/patches/bash-tty-tests.patch @@ -1,7 +1,8 @@ -diff -up bash-4.2-rc2/tests/exec.right.tty_tests bash-4.2-rc2/tests/exec.right ---- bash-4.2-rc2/tests/exec.right.tty_tests 2011-02-09 10:42:48.000000000 +0100 -+++ bash-4.2-rc2/tests/exec.right 2011-02-09 10:42:59.000000000 +0100 -@@ -50,7 +50,6 @@ this is ohio-state +diff --git a/tests/exec.right b/tests/exec.right +index 6075cc8..0b3f02c 100644 +--- a/tests/exec.right ++++ b/tests/exec.right +@@ -51,7 +51,6 @@ this is ohio-state 0 1 testb @@ -9,21 +10,23 @@ diff -up bash-4.2-rc2/tests/exec.right.tty_tests bash-4.2-rc2/tests/exec.right 1 1 1 -diff -up bash-4.2-rc2/tests/execscript.tty_tests bash-4.2-rc2/tests/execscript ---- bash-4.2-rc2/tests/execscript.tty_tests 2010-12-27 22:01:02.000000000 +0100 -+++ bash-4.2-rc2/tests/execscript 2011-02-09 10:42:34.000000000 +0100 -@@ -107,8 +107,6 @@ ${THIS_SH} ./exec6.sub +diff --git a/tests/execscript b/tests/execscript +index c1819de..9227a4a 100644 +--- a/tests/execscript ++++ b/tests/execscript +@@ -108,8 +108,6 @@ ${THIS_SH} ./exec6.sub # checks for properly deciding what constitutes an executable file ${THIS_SH} ./exec7.sub
--${THIS_SH} -i ./exec8.sub +-${THIS_SH} -i ${PWD}/exec8.sub - ${THIS_SH} ./exec9.sub
- true | `echo true` & -diff -up bash-4.2-rc2/tests/read.right.tty_tests bash-4.2-rc2/tests/read.right ---- bash-4.2-rc2/tests/read.right.tty_tests 2010-12-21 16:49:00.000000000 +0100 -+++ bash-4.2-rc2/tests/read.right 2011-02-09 10:42:34.000000000 +0100 + ${THIS_SH} ./exec10.sub +diff --git a/tests/read.right b/tests/read.right +index 73cb704..a92fe7f 100644 +--- a/tests/read.right ++++ b/tests/read.right @@ -33,14 +33,6 @@ a = abcdefg a = xyz a = -xyz 123- @@ -39,10 +42,11 @@ diff -up bash-4.2-rc2/tests/read.right.tty_tests bash-4.2-rc2/tests/read.right ./read3.sub: line 4: read: -1: invalid number abc ab -diff -up bash-4.2-rc2/tests/read.tests.tty_tests bash-4.2-rc2/tests/read.tests ---- bash-4.2-rc2/tests/read.tests.tty_tests 2008-09-06 19:09:11.000000000 +0200 -+++ bash-4.2-rc2/tests/read.tests 2011-02-09 10:42:34.000000000 +0100 -@@ -82,9 +82,6 @@ echo " foo" | { IFS=$':' ; read line; re +diff --git a/tests/read.tests b/tests/read.tests +index f67cd00..083f4a4 100644 +--- a/tests/read.tests ++++ b/tests/read.tests +@@ -82,9 +82,6 @@ echo " foo" | { IFS=$':' ; read line; recho "$line"; } # test read -d delim behavior ${THIS_SH} ./read1.sub
@@ -52,3 +56,6 @@ diff -up bash-4.2-rc2/tests/read.tests.tty_tests bash-4.2-rc2/tests/read.tests # test read -n nchars behavior ${THIS_SH} ./read3.sub
+-- +2.17.2 +