]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
commit bash-20190927 snapshot
authorChet Ramey <chet.ramey@case.edu>
Mon, 30 Sep 2019 17:51:13 +0000 (13:51 -0400)
committerChet Ramey <chet.ramey@case.edu>
Mon, 30 Sep 2019 17:51:13 +0000 (13:51 -0400)
14 files changed:
CWRU/CWRU.chlog
MANIFEST
builtins/shopt.def
doc/bash.1
doc/bashref.texi
doc/version.texi
general.c
jobs.c
nojobs.c
subst.c
tests/exec.right
tests/exec14.sub [new file with mode: 0644]
tests/execscript
tests/shopt.right

index d09e9ac9d9e1f3fab413decff97effdcd40bb3b0..2df28fc6473469cfa4c97e174d172cf7de01f5be 100644 (file)
@@ -6634,3 +6634,25 @@ doc/{bashref.texi,bash.1}
          the (a), not precede it. Report from hk <hkadeveloper@gmail.com>
        - some changes to the text describing regular expression matching for
          the =~ operator
+
+                                  9/25
+                                  ----
+general.c,builtins/shopt.def
+       - posix_glob_backslash: remove references to this variable and the
+         `posixglob' shell option
+
+doc/{bash.1,bashref.texi}
+       - remove references to the `posixglob' shell option
+
+                                  9/26
+                                  ----
+{jobs,nojobs}.c
+       - DEFAULT_MAX_CHILD: bump this up to 4096
+       - set_maxchild: set lmaxchild to MAX_CHILD_MAX if getmaxchild returns
+         -1 without changing errno (assume that sysconf returns -1 meaning
+         unlimited)
+       - initialize_job_control: call set_maxchild instead of inline code
+       - mark_dead_jobs_as_notified: call set_maxchild to set js.c_childmax
+         if it hasn't been set yet
+
+         
index 9180b5b4f448e3f539477dc7a9bce79a6cdc5f93..60c15381bb44ff40a917a7b3a27360393e284045 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -1045,6 +1045,7 @@ tests/exec10.sub  f
 tests/exec11.sub       f
 tests/exec12.sub       f
 tests/exec13.sub       f
+tests/exec14.sub       f
 tests/exp.tests                f
 tests/exp.right                f
 tests/exp1.sub         f
index 223642ed37040cf43c431ac8cdd246050d8560b6..7e3d4d085e11b16f4dc3511c8c5807ad5282d863 100644 (file)
@@ -1,7 +1,7 @@
 This file is shopt.def, from which is created shopt.c.
 It implements the Bash `shopt' builtin.
 
-Copyright (C) 1994-2018 Free Software Foundation, Inc.
+Copyright (C) 1994-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Bash, the Bourne Again SHell.
 
@@ -93,7 +93,6 @@ extern int lastpipe_opt;
 extern int inherit_errexit;
 extern int localvar_inherit;
 extern int localvar_unset;
-extern int posix_glob_backslash;
 
 #if defined (EXTENDED_GLOB)
 extern int extended_glob;
@@ -230,7 +229,6 @@ static struct {
   { "nocaseglob", &glob_ignore_case, (shopt_set_func_t *)NULL },
   { "nocasematch", &match_ignore_case, (shopt_set_func_t *)NULL },
   { "nullglob",        &allow_null_glob_expansion, (shopt_set_func_t *)NULL },
-  { "posixglob", &posix_glob_backslash, (shopt_set_func_t *)NULL },
 #if defined (PROGRAMMABLE_COMPLETION)
   { "progcomp", &prog_completion_enabled, (shopt_set_func_t *)NULL },
 #  if defined (ALIAS)
index 264d137a2648b881a31248da9dee729ca802cebb..c93f8a3945d2b21e0030bfe9fcd77290fed8202d 100644 (file)
@@ -5,12 +5,12 @@
 .\"    Case Western Reserve University
 .\"    chet.ramey@case.edu
 .\"
-.\"    Last Change: Fri Sep 20 15:30:19 EDT 2019
+.\"    Last Change: Wed Sep 25 16:28:22 EDT 2019
 .\"
 .\" bash_builtins, strip all but Built-Ins section
 .if \n(zZ=1 .ig zZ
 .if \n(zY=1 .ig zY
-.TH BASH 1 "2019 September 20" "GNU Bash 5.0"
+.TH BASH 1 "2019 September 25" "GNU Bash 5.0"
 .\"
 .\" There's some problem with having a `@'
 .\" in a tagged paragraph with the BSD man macros.
@@ -3565,12 +3565,9 @@ option has been set,
 scans each word for the characters
 .BR * ,
 .BR ? ,
-.BR [ ,
-and, under certain circumstances (e.g., when it appears in the expansion of
-an unquoted shell variable, depending on the setting of the \fBposixglob\fP
-shell option),
-.BR \e .
-If one of these characters appears, then the word is
+and
+.BR [ .
+If one of these characters appears, and is not quoted, then the word is
 regarded as a
 .IR pattern ,
 and replaced with an alphabetically sorted list of
@@ -10223,14 +10220,6 @@ files (see
 above)
 to expand to a null string, rather than themselves.
 .TP 8
-.B posixglob
-If set,
-.B bash
-makes words containing unquoted backslashes after expansion eligible for
-pathname expansion, even if they don't contain any other unquoted pattern
-characters. This option is enabled by default, and is enabled when
-\fIposix mode\fP is enabled.
-.TP 8
 .B progcomp
 If set, the programmable completion facilities (see
 \fBProgrammable Completion\fP above) are enabled.
index 231356e5c6e71fe8865959fe3935644a74b9a508..9de4b88b07839ae7c2130dafba423f8aadefd4d7 100644 (file)
@@ -1262,16 +1262,18 @@ use find's @option{-print0} option and parallel's @option{-0} option.
 You can use Parallel to move files from the current directory when the
 number of files is too large to process with one @code{mv} invocation:
 @example
-ls | parallel mv @{@} destdir
+printf '%s\n' * | parallel mv @{@} destdir
 @end example
 
 As you can see, the @{@} is replaced with each line read from standard input.
 While using @code{ls} will work in most instances, it is not sufficient to
-deal with all filenames.
+deal with all filenames. @code{printf} is a shell builtin, and therefore is
+not subject to the kernel's limit on the number of arguments to a program,
+so you can use @samp{*} (but see below about the @code{dotglob} shell option).
 If you need to accommodate special characters in filenames, you can use
 
 @example
-find . -depth 1 \! -name '.*' -print0 | parallel -0 mv @{@} destdir
+printf '%s\0' * | parallel -0 mv @{@} destdir
 @end example
 
 @noindent
@@ -1281,9 +1283,12 @@ This will run as many @code{mv} commands as there are files in the current
 directory.
 You can emulate a parallel @code{xargs} by adding the @option{-X} option:
 @example
-find . -depth 1 \! -name '.*' -print0 | parallel -0 -X mv @{@} destdir
+printf '%s\0' * | parallel -0 -X mv @{@} destdir
 @end example
 
+(You may have to modify the pattern if you have the @code{dotglob} option
+enabled.)
+
 GNU Parallel can replace certain common idioms that operate on lines read
 from a file (in this case, filenames listed one per line):
 @example
@@ -2500,11 +2505,8 @@ is performed.
 
 After word splitting, unless the @option{-f} option has been set
 (@pxref{The Set Builtin}), Bash scans each word for the characters
-@samp{*}, @samp{?}, @samp{[},
-and, under certain circumstances (e.g., when it appears in the expansion of
-an unquoted shell variable),
-@samp{\\}.
-If one of these characters appears, then the word is
+@samp{*}, @samp{?}, and @samp{[}.
+If one of these characters appears, and is not quoted, then the word is
 regarded as a @var{pattern},
 and replaced with an alphabetically sorted list of
 filenames matching the pattern (@pxref{Pattern Matching}).
@@ -3336,22 +3338,31 @@ are retained by the child.
 Most versions of Unix make this a part of the operating system's command
 execution mechanism.  If the first line of a script begins with
 the two characters @samp{#!}, the remainder of the line specifies
-an interpreter for the program.
+an interpreter for the program and, depending on the operating system, one
+or more optional arguments for that interpreter.
 Thus, you can specify Bash, @code{awk}, Perl, or some other
 interpreter and write the rest of the script file in that language.
 
 The arguments to the interpreter
-consist of a single optional argument following the interpreter
+consist of one or more optional arguments following the interpreter
 name on the first line of the script file, followed by the name of
-the script file, followed by the rest of the arguments.  Bash
-will perform this action on operating systems that do not handle it
-themselves.  Note that some older versions of Unix limit the interpreter
-name and argument to a maximum of 32 characters.
+the script file, followed by the rest of the arguments supplied to the
+script.
+The details of how the interpreter line is split into an interpreter name
+and a set of arguments vary across systems.
+Bash will perform this action on operating systems that do not handle it
+themselves.
+Note that some older versions of Unix limit the interpreter
+name and a single argument to a maximum of 32 characters, so it's not
+portable to assume that using more than one argument will work.
 
 Bash scripts often begin with @code{#! /bin/bash} (assuming that
 Bash has been installed in @file{/bin}), since this ensures that
 Bash will be used to interpret the script, even if it is executed
-under another shell.
+under another shell. It's a common idiom to use @code{env} to find
+@code{bash} even if it's been installed in another directory:
+@code{#!/usr/bin/env bash} will find the first occurrence of @code{bash}
+in @env{$PATH}.
 
 @node Shell Builtin Commands
 @chapter Shell Builtin Commands
@@ -5472,13 +5483,6 @@ or when filtering possible completions as part of programmable completion.
 If set, Bash allows filename patterns which match no
 files to expand to a null string, rather than themselves.
 
-@item posixglob
-If set, Bash
-makes words containing unquoted backslashes after expansion eligible for  
-filename expansion, even if they don't contain any other unquoted pattern
-characters. This option is enabled by default and is enabled when @sc{posix}
-mode is enabled.
-
 @item progcomp
 If set, the programmable completion facilities
 (@pxref{Programmable Completion}) are enabled.
@@ -7842,11 +7846,6 @@ Enabling @sc{posix} mode has the effect of setting the
 that exceed the number of positional parameters will result in an
 error message.
 
-@item
-Enabling @sc{posix} mode has the effect of setting the @code{posixglob}
-option, which affects how unquoted backslashes are treated during
-filename expansion (@pxref{Filename Expansion}).
-
 @item
 When the @code{alias} builtin displays alias definitions, it does not
 display them with a leading @samp{alias } unless the @option{-p} option
index b6f4d44052ba64aff54d3d1950706e948f5bc366..03ac36c506bfbf5686ca2e4f042caa71859eb86e 100644 (file)
@@ -2,10 +2,10 @@
 Copyright (C) 1988-2019 Free Software Foundation, Inc.
 @end ignore
 
-@set LASTCHANGE Fri Sep 20 15:29:59 EDT 2019
+@set LASTCHANGE Wed Sep 25 16:27:43 EDT 2019
 
 @set EDITION 5.0
 @set VERSION 5.0
 
-@set UPDATED 20 September 2019
+@set UPDATED 25 September 2019
 @set UPDATED-MONTH September 2019
index f8eae57c96a0edf138375c9c5e48804f9b53e47d..03fb9fd468b1b703ab1d3325018198245ed11192 100644 (file)
--- a/general.c
+++ b/general.c
@@ -93,7 +93,6 @@ static struct {
   &source_uses_path,
   &expand_aliases,
   &inherit_errexit,
-  &posix_glob_backslash,
   &print_shift_error,
   0
 };
@@ -109,7 +108,6 @@ posix_initialize (on)
       inherit_errexit = 1;
       source_searches_cwd = 0;
       print_shift_error = 1;
-      posix_glob_backslash = 1;
     }
 
   /* Things that should be turned on when posix mode is disabled. */
diff --git a/jobs.c b/jobs.c
index b6d6917039e7fa53b784c6174490ce127dee4130..3779e4ae67c21eeb9cb0d218c74347497c478a38 100644 (file)
--- a/jobs.c
+++ b/jobs.c
@@ -91,7 +91,7 @@ extern int killpg PARAMS((pid_t, int));
 #endif
 
 #if !DEFAULT_CHILD_MAX
-#  define DEFAULT_CHILD_MAX 32
+#  define DEFAULT_CHILD_MAX 4096
 #endif
 
 #if !MAX_CHILD_MAX
@@ -4527,15 +4527,7 @@ just_bail:
   if (interactive)
     get_tty_state ();
 
-  if (js.c_childmax < 0)
-    js.c_childmax = getmaxchild ();
-  if (js.c_childmax < 0)
-    js.c_childmax = DEFAULT_CHILD_MAX;
-
-#if 0
-  if (js.c_childmax > MAX_CHILD_MAX)
-    js.c_childmax = MAX_CHILD_MAX;
-#endif
+  set_maxchild (0);
 
   return job_control;
 }
@@ -4909,14 +4901,7 @@ mark_dead_jobs_as_notified (force)
 #endif
 
   if (js.c_childmax < 0)
-    js.c_childmax = getmaxchild ();
-  if (js.c_childmax < 0)
-    js.c_childmax = DEFAULT_CHILD_MAX;
-
-#if 0
-  if (js.c_childmax > MAX_CHILD_MAX)
-    js.c_childmax = MAX_CHILD_MAX;
-#endif
+    set_maxchild (0);
 
   /* Don't do anything if the number of dead processes is less than CHILD_MAX
      and we're not forcing a cleanup. */
@@ -5069,14 +5054,23 @@ restart_job_control ()
   initialize_job_control (0);
 }
 
+/* Set the maximum number of background children we keep track of to NCHILD.
+   If the caller passes NCHILD as 0 or -1, this ends up setting it to
+   LMAXCHILD, which is initialized the first time through. */
 void
 set_maxchild (nchild)
      int nchild;
 {
   static int lmaxchild = -1;
 
+  /* Initialize once. */
   if (lmaxchild < 0)
-    lmaxchild = getmaxchild ();
+    {
+      errno = 0;
+      lmaxchild = getmaxchild ();
+      if (lmaxchild < 0 && errno == 0)
+        lmaxchild = MAX_CHILD_MAX;             /* assume unlimited */
+    }
   if (lmaxchild < 0)
     lmaxchild = DEFAULT_CHILD_MAX;
 
index 3a631cdcaf15e6b6b0fb4ea0df2ead31c7ada2fc..d556ff3ccfe347b8faa25d189fd2cc5e71644e67 100644 (file)
--- a/nojobs.c
+++ b/nojobs.c
@@ -3,7 +3,7 @@
 /* This file works under BSD, System V, minix, and Posix systems.  It does
    not implement job control. */
 
-/* Copyright (C) 1987-2011 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2019 Free Software Foundation, Inc.
 
    This file is part of GNU Bash, the Bourne Again SHell.
 
@@ -51,7 +51,7 @@
 #include "builtins/builtext.h" /* for wait_builtin */
 #include "builtins/common.h"
 
-#define DEFAULT_CHILD_MAX 32
+#define DEFAULT_CHILD_MAX 4096
 
 #if defined (_POSIX_VERSION) || !defined (HAVE_KILLPG)
 #  define killpg(pg, sig)              kill(-(pg),(sig))
diff --git a/subst.c b/subst.c
index 6c4d56cd9f061c2d4ebf33653b957b015550f593..9a0c9cc09be4bb0adf83a3dd6786450edb7ee200 100644 (file)
--- a/subst.c
+++ b/subst.c
@@ -11249,7 +11249,7 @@ glob_expand_word_list (tlist, eflags)
       /* If the word isn't an assignment and contains an unquoted
         pattern matching character, then glob it. */
       if ((tlist->word->flags & W_NOGLOB) == 0 &&
-         (x = unquoted_glob_pattern_p (tlist->word->word)))
+         unquoted_glob_pattern_p (tlist->word->word))
        {
          glob_array = shell_glob_filename (tlist->word->word);
 
index 6075cc86ce2c9832d6882d35cb04cf5944c09ada..0a249ddadbd62a058d5e5f79d2c4c4b93bca8361 100644 (file)
@@ -105,3 +105,31 @@ x2b
 x3
 x3a
 x3b
+WORKS
+done
+WORKS
+WORKS
+a
+b
+c
+d
+a
+b
+c
+d
+e
+A
+B
+c
+d
+c
+d
+e
+x
+y
+z
+WORKS
+w
+x
+y
+z
diff --git a/tests/exec14.sub b/tests/exec14.sub
new file mode 100644 (file)
index 0000000..3402fb9
--- /dev/null
@@ -0,0 +1,47 @@
+#   This program is free software: you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation, either version 3 of the License, or
+#   (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+# test that optimizing command lists doesn't inappropriately short-cut commands
+
+# also includes optimizing last command in a list separated by `;'
+
+if [ -x /bin/echo ] ; then
+       binecho=/bin/echo
+elif [ -x /usr/bin/echo ]; then
+       binecho=/usr/bin/echo
+else
+       enable -n echo
+       binecho=echo
+fi
+
+export binecho
+
+: ${THIS_SH:=./bash} ${TMPDIR:=/var/tmp}
+
+${THIS_SH} -c 'trap "echo WORKS && rm $TMPDIR/x$$" EXIT && touch $TMPDIR/x$$' 
+${THIS_SH} -c 'trap "echo WORKS && rm $TMPDIR/x$$" EXIT && touch $TMPDIR/x$$ ; $binecho done' 
+
+( trap "echo WORKS && rm $TMPDIR/x$$" EXIT && touch $TMPDIR/x$$ )
+
+${THIS_SH} -c 'echo a && { $binecho b && $binecho c ; } && echo d'
+${THIS_SH} -c 'echo a && { $binecho b && $binecho c ; } && echo d ; $binecho e'
+
+${THIS_SH} -c 'echo A && $binecho B'
+${THIS_SH} -c '$binecho c && echo d'
+
+$THIS_SH -c '$binecho c && $binecho d && echo e'
+
+$THIS_SH -c 'trap "echo WORKS" EXIT ; $binecho x ; $binecho y ; $binecho z'
+
+${THIS_SH} -c 'echo w ; { echo x ; $binecho y; }; $binecho z'
index c1819de799968d7ed2c3174509f3810c1515b48d..28096769f003ab10c5ff39cff2a231132aa4c244 100644 (file)
@@ -157,3 +157,4 @@ $THIS_SH -c '/bin/echo c && echo d'
 $THIS_SH -c '/bin/echo c && /bin/echo d && echo e'
 
 ${THIS_SH} ./exec13.sub
+${THIS_SH} ./exec14.sub
index e9e8872717a74b02e947e717a9e1b2cb5c0369d7..f1fb1862c61a90f283b5b53dfb675dc135d21da3 100644 (file)
@@ -47,7 +47,6 @@ shopt -u no_empty_cmd_completion
 shopt -u nocaseglob
 shopt -u nocasematch
 shopt -u nullglob
-shopt -s posixglob
 shopt -s progcomp
 shopt -u progcomp_alias
 shopt -s promptvars
@@ -69,7 +68,6 @@ shopt -s force_fignore
 shopt -s globasciiranges
 shopt -s hostcomplete
 shopt -s interactive_comments
-shopt -s posixglob
 shopt -s progcomp
 shopt -s promptvars
 shopt -s sourcepath