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
+
+
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
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.
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;
{ "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)
.\" 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.
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
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.
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
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
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}).
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
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.
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
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
&source_uses_path,
&expand_aliases,
&inherit_errexit,
- &posix_glob_backslash,
&print_shift_error,
0
};
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. */
#endif
#if !DEFAULT_CHILD_MAX
-# define DEFAULT_CHILD_MAX 32
+# define DEFAULT_CHILD_MAX 4096
#endif
#if !MAX_CHILD_MAX
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;
}
#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. */
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;
/* 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.
#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))
/* 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);
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
--- /dev/null
+# 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'
$THIS_SH -c '/bin/echo c && /bin/echo d && echo e'
${THIS_SH} ./exec13.sub
+${THIS_SH} ./exec14.sub
shopt -u nocaseglob
shopt -u nocasematch
shopt -u nullglob
-shopt -s posixglob
shopt -s progcomp
shopt -u progcomp_alias
shopt -s promptvars
shopt -s globasciiranges
shopt -s hostcomplete
shopt -s interactive_comments
-shopt -s posixglob
shopt -s progcomp
shopt -s promptvars
shopt -s sourcepath