From: Chet Ramey Date: Wed, 19 Nov 2025 15:18:54 +0000 (-0500) Subject: fix export environment if a local variable inherits the export attribute from a varia... X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bcac47f08a6e8f04893f3f282bb841ddc07fc2e8;p=thirdparty%2Fbash.git fix export environment if a local variable inherits the export attribute from a variable with the same name at a previous scope; changes to help builtin and glob pattern arguments; fix for fpurge declaration in a source file; man page typesetting updates --- diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index fab80135..6698b837 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -12228,3 +12228,28 @@ execute_cmd.c - time_command: make usage of the various preprocessor defines that determine how we measure the command's duration consistent From andrew@andrewoates.com + +variables.c + - make_local_variable: if we inherit the export attribute from an + existing variable at a previous scope, set array_needs_making + Report from Grisha Levit + +builtins/help.def + - help_builtin: treat each pattern individually; print one message per + glob pattern instead of printing a comma-separated list of all + patterns and print a potential error message once per failing + pattern + - help_builtin: suggest using man or info only if the pattern is not + a glob pattern + Suggestion from Martin D Kealey + + 11/17 + ----- +sig.c + - NEED_FPURGE_DECL: add before including externs.h, since we now call + fpurge + Report by Emanuele Torre + +doc/bash.1,doc/bashref.texi + - fix some options typeset in the wrong font + Report and patch from Grisha Levit diff --git a/builtins/help.def b/builtins/help.def index e7e9789d..f6db8a95 100644 --- a/builtins/help.def +++ b/builtins/help.def @@ -91,9 +91,9 @@ static void show_longdoc (int); int help_builtin (WORD_LIST *list) { - register int i; + int i; char *pattern, *name; - int match_found, sflag, dflag, mflag, m, pass, this_found; + int match_found, sflag, dflag, mflag, m, pass, this_found, globpat; size_t plen; dflag = sflag = mflag = 0; @@ -128,18 +128,15 @@ help_builtin (WORD_LIST *list) /* We should consider making `help bash' do something. */ - if (glob_pattern_p (list->word->word) == 1) - { - printf ("%s", ngettext ("Shell commands matching keyword `", "Shell commands matching keywords `", (list->next ? 2 : 1))); - print_word_list (list, ", "); - printf ("%s", _("'\n\n")); - } - for (match_found = 0, pattern = ""; list; list = list->next) { pattern = list->word->word; plen = strlen (pattern); + globpat = glob_pattern_p (pattern); + if (globpat) + printf (_("Shell commands matching pattern '%s':\n\n"), pattern); + for (pass = 1, this_found = 0; pass < 3; pass++) { for (i = 0; name = shell_builtins[i].name; i++) @@ -178,15 +175,16 @@ help_builtin (WORD_LIST *list) if (pass == 1 && this_found == 1) break; } + if (this_found == 0) + { + if (globpat) + builtin_error (_("no help topics match '%s'."), pattern); + else + builtin_error (_("no help topics match '%s'. Try 'help help', 'man -k %s', or 'info %s'."), pattern, pattern, pattern); + } } - if (match_found == 0) - { - builtin_error (_("no help topics match `%s'. Try `help help' or `man -k %s' or `info %s'."), pattern, pattern, pattern); - return (EXECUTION_FAILURE); - } - - return (sh_chkwrite (EXECUTION_SUCCESS)); + return (match_found ? sh_chkwrite (EXECUTION_SUCCESS) : sh_chkwrite (EXECUTION_FAILURE)); } void diff --git a/doc/bash.1 b/doc/bash.1 index 42c89441..afe320ee 100644 --- a/doc/bash.1 +++ b/doc/bash.1 @@ -5,7 +5,7 @@ .\" Case Western Reserve University .\" chet.ramey@case.edu .\" -.\" Last Change: Mon Oct 6 09:57:24 EDT 2025 +.\" Last Change: Mon Nov 17 11:37:04 EST 2025 .\" .\" For bash_builtins, strip all but "SHELL BUILTIN COMMANDS" section .\" For rbash, strip all but "RESTRICTED SHELL" section @@ -22,7 +22,7 @@ .ds zX \" empty .if \n(zZ=1 .ig zZ .if \n(zY=1 .ig zY -.TH BASH 1 "2025 October 6" "GNU Bash 5.3" +.TH BASH 1 "2025 November 17" "GNU Bash 5.3" .\" .ie \n(.g \{\ .ds ' \(aq @@ -8525,7 +8525,7 @@ programmable completion performs \fBreadline\fP's default completion. .PP The options supplied to \fBcomplete\fP and \fBcompopt\fP can control how \fBreadline\fP treats the completions. -For instance, the \fI\-o fullquote\fP option tells \fBreadline\fP +For instance, the \fB\-o fullquote\fP option tells \fBreadline\fP to quote the matches as if they were filenames. See the description of \fBcomplete\fP below for details. @@ -9080,8 +9080,8 @@ require \fB\-\-\fP to prevent this interpretation. .PP All builtins except \fB:\fP, \fBtrue\fP, \fBfalse\fP, \fBecho\fP, and \fBtest\fP/\fB[\fP -accept \fB--help\fP as a special option. -If \fB--help\fP is supplied, these builtins output +accept \fB\-\-help\fP as a special option. +If \fB\-\-help\fP is supplied, these builtins output a help message and exit with a status of 0. .PP .PD 0 @@ -10219,7 +10219,7 @@ to force a search of the current directory. The .B \-d option will delete a builtin previously loaded with \fB\-f\fP. -If \fI\-s\fP is used with \fI\-f\fP, the new builtin becomes a +If \fB\-s\fP is used with \fB\-f\fP, the new builtin becomes a .SM POSIX special builtin. .IP @@ -11057,8 +11057,9 @@ the next to last. .PD .RE .IP -If the top element of the directory stack is modified, and -the \fI\-n\fP option was not supplied, \fBpopd\fP uses the \fBcd\fP +If the top element of the directory stack is modified, +and the \fB\-n\fP option was not supplied, +\fBpopd\fP uses the \fBcd\fP builtin to change to the directory at the top of the stack. If the \fBcd\fP fails, \fBpopd\fP returns a non-zero value. .IP diff --git a/doc/bashref.texi b/doc/bashref.texi index f78bd7e5..7012cf6c 100644 --- a/doc/bashref.texi +++ b/doc/bashref.texi @@ -5338,7 +5338,7 @@ special builtins. The @option{-f} option means to load the new builtin command @var{name} from shared object @var{filename}, on systems that support dynamic loading. -If @var{filename} does not contain a slash. +If @var{filename} does not contain a slash, Bash will use the value of the @env{BASH_LOADABLES_PATH} variable as a colon-separated list of directories in which to search for @var{filename}. The default for @env{BASH_LOADABLES_PATH} is system-dependent, @@ -8941,8 +8941,9 @@ Remove the @var{N}th directory (counting from the right of the list printed by @code{dirs}), starting with zero, from the stack. @end table -If the top element of the directory stack is modified, and -the @option{-n} option was not supplied, @code{popd} uses the @code{cd} +If the top element of the directory stack is modified, +and the @option{-n} option was not supplied, +@code{popd} uses the @code{cd} builtin to change to the directory at the top of the stack. If the @code{cd} fails, @code{popd} returns a non-zero value. diff --git a/doc/version.texi b/doc/version.texi index 7bf929f5..e6d9f225 100644 --- a/doc/version.texi +++ b/doc/version.texi @@ -2,10 +2,10 @@ Copyright (C) 1988-2025 Free Software Foundation, Inc. @end ignore -@set LASTCHANGE Wed Sep 24 09:35:21 EDT 2025 +@set LASTCHANGE Mon Nov 17 11:37:24 EST 2025 @set EDITION 5.3 @set VERSION 5.3 -@set UPDATED 24 September 2025 -@set UPDATED-MONTH September 2025 +@set UPDATED 17 November 2025 +@set UPDATED-MONTH November 2025 diff --git a/examples/loadables/fltexpr.c b/examples/loadables/fltexpr.c index 5af6eeb8..76d13d3a 100644 --- a/examples/loadables/fltexpr.c +++ b/examples/loadables/fltexpr.c @@ -1607,6 +1607,10 @@ readtok (void) c = GEQ; else if ((c == LT) && (c1 == EQ)) c = LEQ; + else if ((c == '&') && (c1 == '&')) + c = LAND; + else if ((c == '|') && (c1 == '|')) + c = LOR; else if ((c == '*') && (c1 == '*')) c = POWER; else if ((c == '-' || c == '+') && c1 == c && curtok == STR) diff --git a/lib/sh/winsize.c b/lib/sh/winsize.c index ed991ad4..713d58a0 100644 --- a/lib/sh/winsize.c +++ b/lib/sh/winsize.c @@ -53,6 +53,7 @@ # endif /* HAVE_SYS_PTE_H */ #endif /* !STRUCT_WINSIZE_IN_TERMIOS && !STRUCT_WINSIZE_IN_SYS_IOCTL */ +#include #include /* Return the fd from which we are actually getting input. */ diff --git a/sig.c b/sig.c index 0662a249..6af1d5f0 100644 --- a/sig.c +++ b/sig.c @@ -34,6 +34,8 @@ #include "bashintl.h" +#define NEED_FPURGE_DECL + #include "shell.h" #include "execute_cmd.h" #if defined (JOB_CONTROL) diff --git a/tests/builtins.right b/tests/builtins.right index c0194b86..740dc47f 100644 --- a/tests/builtins.right +++ b/tests/builtins.right @@ -414,7 +414,7 @@ shift: shift [n] Returns success unless N is negative or greater than $#. builtin: builtin [shell-builtin [arg ...]] shift: shift [n] -Shell commands matching keyword `read*' +Shell commands matching pattern 'read*': read: read [-Eers] [-a array] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name ...] readarray: readarray [-d delim] [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array] @@ -495,7 +495,7 @@ A star (*) next to a name means that the command is disabled. getopts optstring name [arg ...] while COMMANDS; do COMMANDS-2; done hash [-lr] [-p pathname] [-dt] [name > { COMMANDS ; } help [-dms] [pattern ...] -./builtins10.sub: line 39: help: no help topics match `bash'. Try `help help' or `man -k bash' or `info bash'. +./builtins10.sub: line 39: help: no help topics match 'bash'. Try 'help help', 'man -k bash', or 'info bash'. builtins11.sub unlimited unlimited diff --git a/variables.c b/variables.c index 59423372..6a03175e 100644 --- a/variables.c +++ b/variables.c @@ -2724,6 +2724,9 @@ make_local_variable (const char *name, int flags) else /* We inherit the export attribute, but no others. */ new_var->attributes = exported_p (old_var) ? att_exported : 0; + + if (exported_p (new_var)) + array_needs_making = 1; } set_local_var_flags: