1
0
Fork 0
mirror of synced 2025-03-06 20:53:29 +01:00

Bash-4.4 distribution sources and documentation

This commit is contained in:
Chet Ramey 2016-09-15 16:59:08 -04:00
parent 30a978b7d8
commit a0c0a00fc4
588 changed files with 130746 additions and 80164 deletions

1035
CHANGES

File diff suppressed because it is too large Load diff

42
COMPAT
View file

@ -2,9 +2,9 @@ Compatibility with previous versions
====================================
This document details the incompatibilities between this version of bash,
bash-4.3, and the previous widely-available versions, bash-3.x (which is
still the `standard' version for Mac OS X), 4.0/4.1 (which are still
standard on a few Linux distributions), and bash-4.2, the current
bash-4.4, and the previous widely-available versions, bash-3.x (which is
still the `standard' version for Mac OS X), 4.1/4.2 (which are still
standard on a few Linux distributions), and bash-4.3, the current
widely-available version. These were discovered by users of bash-2.x
through 4.x, so this list is not comprehensive. Some of these
incompatibilities occur between the current version and versions 2.0 and
@ -372,6 +372,25 @@ above.
characters in the replacement string as special; if it treats them as
special, then quote removal should remove them.
54. Bash-4.4 no longer considers a reference to ${a[@]} or ${a[*]}, where `a'
is an array without any elements set, to be a reference to an unset
variable. This means that such a reference will not cause the shell to
exit when the `-u' option is enabled.
55. Bash-4.4 allows double quotes to quote the history expansion character (!)
when in Posix mode, since Posix specifies the effects of double quotes.
56. Bash-4.4 does not inherit $PS4 from the environment if running as root.
57. Bash-4.4 doesn't allow a `break' or `continue' in a function to affect
loop execution in the calling context.
58. Bash-4.4 no longer expands tildes in $PATH elements when in Posix mode.
59. Bash-4.4 does not attempt to perform a compound array assignment if an
argument to `declare' or a similar builtin expands to a word that looks
like a compound array assignment (e.g. declare w=$x where x='(foo)').
Shell Compatibility Level
=========================
@ -389,6 +408,9 @@ to this variable (a decimal version number like 4.2, or an integer
corresponding to the compatNN option, like 42) determines the compatibility
level.
Bash-4.4 has begun deprecating older compatibility levels. Eventually, the
options will be removed in favor of the BASH_COMPAT variable.
compat31 set
- the < and > operators to the [[ command do not consider the current
locale when comparing strings; they use ASCII ordering
@ -408,7 +430,7 @@ compat40 set
compat41 set
- interrupting a command list such as "a ; b ; c" causes the execution
of the entire list to be aborted (in versions before bash-4.1,
of the entire list to be aborted (in versions before bash-4.0,
interrupting one command in a list caused the next to be executed)
- when in posix mode, single quotes in the `word' portion of a
double-quoted parameter expansion define a new quoting context and
@ -417,6 +439,18 @@ compat41 set
compat42 set
- the replacement string in double-quoted pattern substitution is not
run through quote removal, as in previous versions
compat43 set
- the shell does not print a warning message if an attempt is made to
use a quoted compound assignment as an argument to declare
(declare -a foo='(1 2)')
- word expansion errors are considered non-fatal errors that cause the
current command to fail, even in Posix mode
- when executing a shell function, the loop state (while/until/etc.) is
not reset, so `break' or `continue' in a shell function will break or
continue loops in the calling context. Bash-4.4 and later reset the
loop state to prevent this.
-------------------------------------------------------------------------------
Copying and distribution of this file, with or without modification,

File diff suppressed because it is too large Load diff

442
INSTALL
View file

@ -5,37 +5,37 @@ These are installation instructions for Bash.
The simplest way to compile Bash is:
1. `cd' to the directory containing the source code and type
`./configure' to configure Bash for your system. If you're using
`csh' on an old version of System V, you might need to type `sh
./configure' instead to prevent `csh' from trying to execute
`configure' itself.
1. 'cd' to the directory containing the source code and type
'./configure' to configure Bash for your system. If you're using
'csh' on an old version of System V, you might need to type 'sh
./configure' instead to prevent 'csh' from trying to execute
'configure' itself.
Running `configure' takes some time. While running, it prints
Running 'configure' takes some time. While running, it prints
messages telling which features it is checking for.
2. Type `make' to compile Bash and build the `bashbug' bug reporting
2. Type 'make' to compile Bash and build the 'bashbug' bug reporting
script.
3. Optionally, type `make tests' to run the Bash test suite.
3. Optionally, type 'make tests' to run the Bash test suite.
4. Type `make install' to install `bash' and `bashbug'. This will
4. Type 'make install' to install 'bash' and 'bashbug'. This will
also install the manual pages and Info file.
The `configure' shell script attempts to guess correct values for
The 'configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package
(the top directory, the `builtins', `doc', and `support' directories,
each directory under `lib', and several others). It also creates a
`config.h' file containing system-dependent definitions. Finally, it
creates a shell script named `config.status' that you can run in the
future to recreate the current configuration, a file `config.cache'
that saves the results of its tests to speed up reconfiguring, and a
file `config.log' containing compiler output (useful mainly for
debugging `configure'). If at some point `config.cache' contains
results you don't want to keep, you may remove or edit it.
those values to create a 'Makefile' in each directory of the package
(the top directory, the 'builtins', 'doc', and 'support' directories,
each directory under 'lib', and several others). It also creates a
'config.h' file containing system-dependent definitions. Finally, it
creates a shell script named 'config.status' that you can run in the
future to recreate the current configuration, a file 'config.cache' that
saves the results of its tests to speed up reconfiguring, and a file
'config.log' containing compiler output (useful mainly for debugging
'configure'). If at some point 'config.cache' contains results you
don't want to keep, you may remove or edit it.
To find out more about the options and arguments that the `configure'
To find out more about the options and arguments that the 'configure'
script understands, type
bash-2.04$ ./configure --help
@ -43,379 +43,397 @@ script understands, type
at the Bash prompt in your Bash source directory.
If you need to do unusual things to compile Bash, please try to figure
out how `configure' could check whether or not to do them, and mail
out how 'configure' could check whether or not to do them, and mail
diffs or instructions to <bash-maintainers@gnu.org> so they can be
considered for the next release.
The file `configure.ac' is used to create `configure' by a program
called Autoconf. You only need `configure.ac' if you want to change it
or regenerate `configure' using a newer version of Autoconf. If you do
The file 'configure.ac' is used to create 'configure' by a program
called Autoconf. You only need 'configure.ac' if you want to change it
or regenerate 'configure' using a newer version of Autoconf. If you do
this, make sure you are using Autoconf version 2.50 or newer.
You can remove the program binaries and object files from the source
code directory by typing `make clean'. To also remove the files that
`configure' created (so you can compile Bash for a different kind of
computer), type `make distclean'.
code directory by typing 'make clean'. To also remove the files that
'configure' created (so you can compile Bash for a different kind of
computer), type 'make distclean'.
Next: Compiling For Multiple Architectures, Prev: Basic Installation, Up: Installing Bash
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. You can give `configure'
Some systems require unusual options for compilation or linking that the
'configure' script does not know about. You can give 'configure'
initial values for variables by setting them in the environment. Using
a Bourne-compatible shell, you can do that on the command line like
this:
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
On systems that have the `env' program, you can do it like this:
On systems that have the 'env' program, you can do it like this:
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
The configuration process uses GCC to build Bash if it is available.
Next: Installation Names, Prev: Compilers and Options, Up: Installing Bash
Compiling For Multiple Architectures
====================================
You can compile Bash for more than one kind of computer at the same
time, by placing the object files for each architecture in their own
directory. To do this, you must use a version of `make' that supports
the `VPATH' variable, such as GNU `make'. `cd' to the directory where
you want the object files and executables to go and run the `configure'
directory. To do this, you must use a version of 'make' that supports
the 'VPATH' variable, such as GNU 'make'. 'cd' to the directory where
you want the object files and executables to go and run the 'configure'
script from the source directory. You may need to supply the
`--srcdir=PATH' argument to tell `configure' where the source files
are. `configure' automatically checks for the source code in the
directory that `configure' is in and in `..'.
'--srcdir=PATH' argument to tell 'configure' where the source files are.
'configure' automatically checks for the source code in the directory
that 'configure' is in and in '..'.
If you have to use a `make' that does not supports the `VPATH'
variable, you can compile Bash for one architecture at a time in the
source code directory. After you have installed Bash for one
architecture, use `make distclean' before reconfiguring for another
architecture.
If you have to use a 'make' that does not supports the 'VPATH' variable,
you can compile Bash for one architecture at a time in the source code
directory. After you have installed Bash for one architecture, use
'make distclean' before reconfiguring for another architecture.
Alternatively, if your system supports symbolic links, you can use the
`support/mkclone' script to create a build tree which has symbolic
links back to each file in the source directory. Here's an example
that creates a build directory in the current directory from a source
directory `/usr/gnu/src/bash-2.0':
'support/mkclone' script to create a build tree which has symbolic links
back to each file in the source directory. Here's an example that
creates a build directory in the current directory from a source
directory '/usr/gnu/src/bash-2.0':
bash /usr/gnu/src/bash-2.0/support/mkclone -s /usr/gnu/src/bash-2.0 .
The `mkclone' script requires Bash, so you must have already built Bash
The 'mkclone' script requires Bash, so you must have already built Bash
for at least one architecture before you can create build directories
for other architectures.
Next: Specifying the System Type, Prev: Compiling For Multiple Architectures, Up: Installing Bash
Installation Names
==================
By default, `make install' will install into `/usr/local/bin',
`/usr/local/man', etc. You can specify an installation prefix other
than `/usr/local' by giving `configure' the option `--prefix=PATH', or
by specifying a value for the `DESTDIR' `make' variable when running
`make install'.
By default, 'make install' will install into '/usr/local/bin',
'/usr/local/man', etc. You can specify an installation prefix other
than '/usr/local' by giving 'configure' the option '--prefix=PATH', or
by specifying a value for the 'DESTDIR' 'make' variable when running
'make install'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
give `configure' the option `--exec-prefix=PATH', `make install' will
use PATH as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix.
You can specify separate installation prefixes for architecture-specific
files and architecture-independent files. If you give 'configure' the
option '--exec-prefix=PATH', 'make install' will use PATH as the prefix
for installing programs and libraries. Documentation and other data
files will still use the regular prefix.
Next: Sharing Defaults, Prev: Installation Names, Up: Installing Bash
Specifying the System Type
==========================
There may be some features `configure' can not figure out
automatically, but need to determine by the type of host Bash will run
on. Usually `configure' can figure that out, but if it prints a
message saying it can not guess the host type, give it the
`--host=TYPE' option. `TYPE' can either be a short name for the system
type, such as `sun4', or a canonical name with three fields:
`CPU-COMPANY-SYSTEM' (e.g., `i386-unknown-freebsd4.2').
There may be some features 'configure' can not figure out automatically,
but need to determine by the type of host Bash will run on. Usually
'configure' can figure that out, but if it prints a message saying it
can not guess the host type, give it the '--host=TYPE' option. 'TYPE'
can either be a short name for the system type, such as 'sun4', or a
canonical name with three fields: 'CPU-COMPANY-SYSTEM' (e.g.,
'i386-unknown-freebsd4.2').
See the file `support/config.sub' for the possible values of each field.
See the file 'support/config.sub' for the possible values of each field.
Next: Operation Controls, Prev: Specifying the System Type, Up: Installing Bash
Sharing Defaults
================
If you want to set default values for `configure' scripts to share, you
can create a site shell script called `config.site' that gives default
values for variables like `CC', `cache_file', and `prefix'. `configure'
looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: the Bash `configure' looks for a site script, but not all
`configure' scripts do.
If you want to set default values for 'configure' scripts to share, you
can create a site shell script called 'config.site' that gives default
values for variables like 'CC', 'cache_file', and 'prefix'. 'configure'
looks for 'PREFIX/share/config.site' if it exists, then
'PREFIX/etc/config.site' if it exists. Or, you can set the
'CONFIG_SITE' environment variable to the location of the site script.
A warning: the Bash 'configure' looks for a site script, but not all
'configure' scripts do.
Next: Optional Features, Prev: Sharing Defaults, Up: Installing Bash
Operation Controls
==================
`configure' recognizes the following options to control how it operates.
'configure' recognizes the following options to control how it operates.
`--cache-file=FILE'
'--cache-file=FILE'
Use and save the results of the tests in FILE instead of
`./config.cache'. Set FILE to `/dev/null' to disable caching, for
debugging `configure'.
'./config.cache'. Set FILE to '/dev/null' to disable caching, for
debugging 'configure'.
`--help'
Print a summary of the options to `configure', and exit.
'--help'
Print a summary of the options to 'configure', and exit.
`--quiet'
`--silent'
`-q'
'--quiet'
'--silent'
'-q'
Do not print messages saying which checks are being made.
`--srcdir=DIR'
'--srcdir=DIR'
Look for the Bash source code in directory DIR. Usually
`configure' can determine that directory automatically.
'configure' can determine that directory automatically.
`--version'
Print the version of Autoconf used to generate the `configure'
'--version'
Print the version of Autoconf used to generate the 'configure'
script, and exit.
`configure' also accepts some other, not widely used, boilerplate
options. `configure --help' prints the complete list.
'configure' also accepts some other, not widely used, boilerplate
options. 'configure --help' prints the complete list.
Prev: Operation Controls, Up: Installing Bash
Optional Features
=================
The Bash `configure' has a number of `--enable-FEATURE' options, where
The Bash 'configure' has a number of '--enable-FEATURE' options, where
FEATURE indicates an optional part of Bash. There are also several
`--with-PACKAGE' options, where PACKAGE is something like `bash-malloc'
or `purify'. To turn off the default use of a package, use
`--without-PACKAGE'. To configure Bash without a feature that is
enabled by default, use `--disable-FEATURE'.
'--with-PACKAGE' options, where PACKAGE is something like 'bash-malloc'
or 'purify'. To turn off the default use of a package, use
'--without-PACKAGE'. To configure Bash without a feature that is
enabled by default, use '--disable-FEATURE'.
Here is a complete list of the `--enable-' and `--with-' options that
the Bash `configure' recognizes.
Here is a complete list of the '--enable-' and '--with-' options that
the Bash 'configure' recognizes.
`--with-afs'
'--with-afs'
Define if you are using the Andrew File System from Transarc.
`--with-bash-malloc'
Use the Bash version of `malloc' in the directory `lib/malloc'.
This is not the same `malloc' that appears in GNU libc, but an
older version originally derived from the 4.2 BSD `malloc'. This
`malloc' is very fast, but wastes some space on each allocation.
This option is enabled by default. The `NOTES' file contains a
'--with-bash-malloc'
Use the Bash version of 'malloc' in the directory 'lib/malloc'.
This is not the same 'malloc' that appears in GNU libc, but an
older version originally derived from the 4.2 BSD 'malloc'. This
'malloc' is very fast, but wastes some space on each allocation.
This option is enabled by default. The 'NOTES' file contains a
list of systems for which this should be turned off, and
`configure' disables this option automatically for a number of
'configure' disables this option automatically for a number of
systems.
`--with-curses'
'--with-curses'
Use the curses library instead of the termcap library. This should
be supplied if your system has an inadequate or incomplete termcap
database.
`--with-gnu-malloc'
A synonym for `--with-bash-malloc'.
'--with-gnu-malloc'
A synonym for '--with-bash-malloc'.
`--with-installed-readline[=PREFIX]'
'--with-installed-readline[=PREFIX]'
Define this to make Bash link with a locally-installed version of
Readline rather than the version in `lib/readline'. This works
only with Readline 5.0 and later versions. If PREFIX is `yes' or
not supplied, `configure' uses the values of the make variables
`includedir' and `libdir', which are subdirectories of `prefix' by
Readline rather than the version in 'lib/readline'. This works
only with Readline 5.0 and later versions. If PREFIX is 'yes' or
not supplied, 'configure' uses the values of the make variables
'includedir' and 'libdir', which are subdirectories of 'prefix' by
default, to find the installed version of Readline if it is not in
the standard system include and library directories. If PREFIX is
`no', Bash links with the version in `lib/readline'. If PREFIX is
set to any other value, `configure' treats it as a directory
'no', Bash links with the version in 'lib/readline'. If PREFIX is
set to any other value, 'configure' treats it as a directory
pathname and looks for the installed version of Readline in
subdirectories of that directory (include files in
PREFIX/`include' and the library in PREFIX/`lib').
subdirectories of that directory (include files in PREFIX/'include'
and the library in PREFIX/'lib').
`--with-purify'
'--with-purify'
Define this to use the Purify memory allocation checker from
Rational Software.
`--enable-minimal-config'
'--enable-minimal-config'
This produces a shell with minimal features, close to the
historical Bourne shell.
There are several `--enable-' options that alter how Bash is compiled
There are several '--enable-' options that alter how Bash is compiled
and linked, rather than changing run-time features.
`--enable-largefile'
'--enable-largefile'
Enable support for large files
(http://www.sas.com/standards/large_file/x_open.20Mar96.html) if
the operating system requires special compiler options to build
programs which can access large files. This is enabled by
default, if the operating system provides large file support.
programs which can access large files. This is enabled by default,
if the operating system provides large file support.
`--enable-profiling'
'--enable-profiling'
This builds a Bash binary that produces profiling information to be
processed by `gprof' each time it is executed.
processed by 'gprof' each time it is executed.
`--enable-static-link'
This causes Bash to be linked statically, if `gcc' is being used.
'--enable-static-link'
This causes Bash to be linked statically, if 'gcc' is being used.
This could be used to build a version to use as root's shell.
The `minimal-config' option can be used to disable all of the following
options, but it is processed first, so individual options may be
enabled using `enable-FEATURE'.
The 'minimal-config' option can be used to disable all of the following
options, but it is processed first, so individual options may be enabled
using 'enable-FEATURE'.
All of the following options except for `disabled-builtins',
`directpand-default', and `xpg-echo-default' are enabled by default,
All of the following options except for 'disabled-builtins',
'direxpand-default', and 'xpg-echo-default' are enabled by default,
unless the operating system does not provide the necessary support.
`--enable-alias'
Allow alias expansion and include the `alias' and `unalias'
'--enable-alias'
Allow alias expansion and include the 'alias' and 'unalias'
builtins (*note Aliases::).
`--enable-arith-for-command'
Include support for the alternate form of the `for' command that
behaves like the C language `for' statement (*note Looping
'--enable-arith-for-command'
Include support for the alternate form of the 'for' command that
behaves like the C language 'for' statement (*note Looping
Constructs::).
`--enable-array-variables'
'--enable-array-variables'
Include support for one-dimensional array shell variables (*note
Arrays::).
`--enable-bang-history'
Include support for `csh'-like history substitution (*note History
'--enable-bang-history'
Include support for 'csh'-like history substitution (*note History
Interaction::).
`--enable-brace-expansion'
Include `csh'-like brace expansion ( `b{a,b}c' ==> `bac bbc' ).
'--enable-brace-expansion'
Include 'csh'-like brace expansion ( 'b{a,b}c' ==> 'bac bbc' ).
See *note Brace Expansion::, for a complete description.
`--enable-casemod-attributes'
Include support for case-modifying attributes in the `declare'
'--enable-casemod-attributes'
Include support for case-modifying attributes in the 'declare'
builtin and assignment statements. Variables with the UPPERCASE
attribute, for example, will have their values converted to
uppercase upon assignment.
`--enable-casemod-expansion'
'--enable-casemod-expansion'
Include support for case-modifying word expansions.
`--enable-command-timing'
Include support for recognizing `time' as a reserved word and for
displaying timing statistics for the pipeline following `time'
'--enable-command-timing'
Include support for recognizing 'time' as a reserved word and for
displaying timing statistics for the pipeline following 'time'
(*note Pipelines::). This allows pipelines as well as shell
builtins and functions to be timed.
`--enable-cond-command'
Include support for the `[[' conditional command. (*note
'--enable-cond-command'
Include support for the '[[' conditional command. (*note
Conditional Constructs::).
`--enable-cond-regexp'
'--enable-cond-regexp'
Include support for matching POSIX regular expressions using the
`=~' binary operator in the `[[' conditional command. (*note
'=~' binary operator in the '[[' conditional command. (*note
Conditional Constructs::).
`--enable-coprocesses'
Include support for coprocesses and the `coproc' reserved word
'--enable-coprocesses'
Include support for coprocesses and the 'coproc' reserved word
(*note Pipelines::).
`--enable-debugger'
'--enable-debugger'
Include support for the bash debugger (distributed separately).
`--enable-direxpand-default'
Cause the `direxpand' shell option (*note The Shopt Builtin::) to
'--enable-direxpand-default'
Cause the 'direxpand' shell option (*note The Shopt Builtin::) to
be enabled by default when the shell starts. It is normally
disabled by default.
`--enable-directory-stack'
Include support for a `csh'-like directory stack and the `pushd',
`popd', and `dirs' builtins (*note The Directory Stack::).
'--enable-directory-stack'
Include support for a 'csh'-like directory stack and the 'pushd',
'popd', and 'dirs' builtins (*note The Directory Stack::).
`--enable-disabled-builtins'
Allow builtin commands to be invoked via `builtin xxx' even after
`xxx' has been disabled using `enable -n xxx'. See *note Bash
Builtins::, for details of the `builtin' and `enable' builtin
'--enable-disabled-builtins'
Allow builtin commands to be invoked via 'builtin xxx' even after
'xxx' has been disabled using 'enable -n xxx'. See *note Bash
Builtins::, for details of the 'builtin' and 'enable' builtin
commands.
`--enable-dparen-arithmetic'
Include support for the `((...))' command (*note Conditional
'--enable-dparen-arithmetic'
Include support for the '((...))' command (*note Conditional
Constructs::).
`--enable-extended-glob'
'--enable-extended-glob'
Include support for the extended pattern matching features
described above under *note Pattern Matching::.
`--enable-extended-glob-default'
'--enable-extended-glob-default'
Set the default value of the EXTGLOB shell option described above
under *note The Shopt Builtin:: to be enabled.
`--enable-glob-asciirange-default'
Set the default value of the GLOBASCIIRANGES shell option described
above under *note The Shopt Builtin:: to be enabled. This
controls the behavior of character ranges when used in pattern
matching bracket expressions.
'--enable-function-import'
Include support for importing function definitions exported by
another instance of the shell from the environment. This option is
enabled by default.
`--enable-help-builtin'
Include the `help' builtin, which displays help on shell builtins
'--enable-glob-asciirange-default'
Set the default value of the GLOBASCIIRANGES shell option described
above under *note The Shopt Builtin:: to be enabled. This controls
the behavior of character ranges when used in pattern matching
bracket expressions.
'--enable-help-builtin'
Include the 'help' builtin, which displays help on shell builtins
and variables (*note Bash Builtins::).
`--enable-history'
Include command history and the `fc' and `history' builtin
commands (*note Bash History Facilities::).
'--enable-history'
Include command history and the 'fc' and 'history' builtin commands
(*note Bash History Facilities::).
`--enable-job-control'
This enables the job control features (*note Job Control::), if
the operating system supports them.
'--enable-job-control'
This enables the job control features (*note Job Control::), if the
operating system supports them.
`--enable-multibyte'
'--enable-multibyte'
This enables support for multibyte characters if the operating
system provides the necessary support.
`--enable-net-redirections'
'--enable-net-redirections'
This enables the special handling of filenames of the form
`/dev/tcp/HOST/PORT' and `/dev/udp/HOST/PORT' when used in
'/dev/tcp/HOST/PORT' and '/dev/udp/HOST/PORT' when used in
redirections (*note Redirections::).
`--enable-process-substitution'
'--enable-process-substitution'
This enables process substitution (*note Process Substitution::) if
the operating system provides the necessary support.
`--enable-progcomp'
'--enable-progcomp'
Enable the programmable completion facilities (*note Programmable
Completion::). If Readline is not enabled, this option has no
effect.
`--enable-prompt-string-decoding'
'--enable-prompt-string-decoding'
Turn on the interpretation of a number of backslash-escaped
characters in the `$PS1', `$PS2', `$PS3', and `$PS4' prompt
characters in the '$PS1', '$PS2', '$PS3', and '$PS4' prompt
strings. See *note Controlling the Prompt::, for a complete list
of prompt string escape sequences.
`--enable-readline'
'--enable-readline'
Include support for command-line editing and history with the Bash
version of the Readline library (*note Command Line Editing::).
`--enable-restricted'
'--enable-restricted'
Include support for a "restricted shell". If this is enabled,
Bash, when called as `rbash', enters a restricted mode. See *note
Bash, when called as 'rbash', enters a restricted mode. See *note
The Restricted Shell::, for a description of restricted mode.
`--enable-select'
Include the `select' compound command, which allows the generation
'--enable-select'
Include the 'select' compound command, which allows the generation
of simple menus (*note Conditional Constructs::).
`--enable-separate-helpfiles'
Use external files for the documentation displayed by the `help'
'--enable-separate-helpfiles'
Use external files for the documentation displayed by the 'help'
builtin instead of storing the text internally.
`--enable-single-help-strings'
Store the text displayed by the `help' builtin as a single string
'--enable-single-help-strings'
Store the text displayed by the 'help' builtin as a single string
for each help topic. This aids in translating the text to
different languages. You may need to disable this if your
compiler cannot handle very long string literals.
different languages. You may need to disable this if your compiler
cannot handle very long string literals.
`--enable-strict-posix-default'
'--enable-strict-posix-default'
Make Bash POSIX-conformant by default (*note Bash POSIX Mode::).
`--enable-usg-echo-default'
A synonym for `--enable-xpg-echo-default'.
'--enable-usg-echo-default'
A synonym for '--enable-xpg-echo-default'.
`--enable-xpg-echo-default'
Make the `echo' builtin expand backslash-escaped characters by
default, without requiring the `-e' option. This sets the default
value of the `xpg_echo' shell option to `on', which makes the Bash
`echo' behave more like the version specified in the Single Unix
Specification, version 3. *Note Bash Builtins::, for a
description of the escape sequences that `echo' recognizes.
'--enable-xpg-echo-default'
Make the 'echo' builtin expand backslash-escaped characters by
default, without requiring the '-e' option. This sets the default
value of the 'xpg_echo' shell option to 'on', which makes the Bash
'echo' behave more like the version specified in the Single Unix
Specification, version 3. *Note Bash Builtins::, for a description
of the escape sequences that 'echo' recognizes.
The file `config-top.h' contains C Preprocessor `#define' statements
for options which are not settable from `configure'. Some of these are
not meant to be changed; beware of the consequences if you do. Read
the comments associated with each definition for more information about
its effect.
The file 'config-top.h' contains C Preprocessor '#define' statements for
options which are not settable from 'configure'. Some of these are not
meant to be changed; beware of the consequences if you do. Read the
comments associated with each definition for more information about its
effect.

View file

@ -529,6 +529,8 @@ po/ja.po f
po/lt.gmo f
po/lt.po f
po/nl.gmo f
po/nb.po f
po/nb.gmo f
po/nl.po f
po/pl.gmo f
po/pl.po f
@ -581,6 +583,7 @@ doc/texinfo.tex f
doc/bashref.texi f
doc/version.texi f
doc/bashref.info f
doc/bash.info f
doc/article.ms f
doc/htmlpost.sh f 755
doc/infopost.sh f 755
@ -607,8 +610,10 @@ doc/bash.pdf f
doc/bashref.pdf f
doc/rose94.pdf f
doc/aosa-bash.pdf f
doc/aosa-bash-full.pdf f
#
support/Makefile.in f
support/bash.pc.in f
support/bashversion.c f
support/checkbashisms f 755
support/config.guess f
@ -654,11 +659,14 @@ examples/complete/complete-examples f
examples/complete/bashcc-1.0.1.tar.gz f
examples/loadables/README f
examples/loadables/template.c f
examples/loadables/loadables.h f
examples/loadables/Makefile.in f
examples/loadables/Makefile.inc.in f
examples/loadables/necho.c f
examples/loadables/hello.c f
examples/loadables/print.c f
examples/loadables/realpath.c f
examples/loadables/setpgid.c f
examples/loadables/sleep.c f
examples/loadables/strftime.c f
examples/loadables/truefalse.c f
@ -704,6 +712,7 @@ examples/functions/basename f
examples/functions/csh-compat f
#examples/functions/dirfuncs f
examples/functions/dirname f
examples/functions/dirstack f
#examples/functions/emptydir f
examples/functions/exitstat f
examples/functions/external f
@ -795,8 +804,10 @@ examples/misc/aliasconv.bash f
examples/misc/cshtobash f
tests/README f
tests/COPYRIGHT f
tests/test-glue-functions f
tests/alias.tests f
tests/alias1.sub f
tests/alias2.sub f
tests/alias.right f
tests/appendop.tests f
tests/appendop1.sub f
@ -812,6 +823,7 @@ tests/arith3.sub f
tests/arith4.sub f
tests/arith5.sub f
tests/arith6.sub f
tests/arith7.sub f
tests/array.tests f
tests/array.right f
tests/array1.sub f
@ -830,6 +842,11 @@ tests/array13.sub f
tests/array14.sub f
tests/array15.sub f
tests/array16.sub f
tests/array17.sub f
tests/array18.sub f
tests/array19.sub f
tests/array20.sub f
tests/array21.sub f
tests/array-at-star f
tests/array2.right f
tests/assoc.tests f
@ -841,6 +858,11 @@ tests/assoc4.sub f
tests/assoc5.sub f
tests/assoc6.sub f
tests/assoc7.sub f
tests/assoc8.sub f
tests/attr.tests f
tests/attr.right f
tests/attr1.sub f
tests/attr2.sub f
tests/braces.tests f
tests/braces.right f
tests/builtins.tests f
@ -849,6 +871,8 @@ tests/builtins1.sub f
tests/builtins2.sub f
tests/builtins3.sub f
tests/builtins4.sub f
tests/builtins5.sub f
tests/builtins6.sub f
tests/source1.sub f
tests/source2.sub f
tests/source3.sub f
@ -864,6 +888,8 @@ tests/casemod.right f
tests/comsub.tests f
tests/comsub.right f
tests/comsub1.sub f
tests/comsub2.sub f
tests/comsub3.sub f
tests/comsub-eof.tests f
tests/comsub-eof0.sub f
tests/comsub-eof1.sub f
@ -894,6 +920,13 @@ tests/dbg-support2.tests f
tests/dbg-support3.sub f
tests/dollar-at-star f
tests/dollar-at-star1.sub f
tests/dollar-at-star2.sub f
tests/dollar-at-star3.sub f
tests/dollar-at-star4.sub f
tests/dollar-at-star5.sub f
tests/dollar-at-star6.sub f
tests/dollar-at-star7.sub f
tests/dollar-at-star8.sub f
tests/dollar-at1.sub f
tests/dollar-at2.sub f
tests/dollar-at3.sub f
@ -917,6 +950,9 @@ tests/errors.right f
tests/errors1.sub f
tests/errors2.sub f
tests/errors3.sub f
tests/errors4.sub f
tests/errors5.sub f
tests/errors6.sub f
tests/execscript f
tests/exec.right f
tests/exec1.sub f 755
@ -928,6 +964,10 @@ tests/exec6.sub f
tests/exec7.sub f
tests/exec8.sub f
tests/exec9.sub f
tests/exec10.sub f
tests/exec11.sub f
tests/exec12.sub f
tests/exec13.sub f
tests/exp.tests f
tests/exp.right f
tests/exp1.sub f
@ -936,14 +976,25 @@ tests/exp3.sub f
tests/exp4.sub f
tests/exp5.sub f
tests/exp6.sub f
tests/exp7.sub f
tests/exp8.sub f
tests/exp9.sub f
tests/exportfunc.tests f
tests/exportfunc.right f
tests/exportfunc1.sub f
tests/exportfunc2.sub f
tests/exportfunc3.sub f
tests/extglob.tests f
tests/extglob.right f
tests/extglob1.sub f
tests/extglob1a.sub f
tests/extglob2.sub f
tests/extglob2.tests f
tests/extglob2.right f
tests/extglob3.sub f
tests/extglob3.tests f
tests/extglob3.right f
tests/extglob4.sub f
tests/func.tests f
tests/func.right f
tests/func1.sub f
@ -959,6 +1010,9 @@ tests/getopts4.sub f
tests/getopts5.sub f
tests/getopts6.sub f
tests/getopts7.sub f
tests/getopts8.sub f
tests/getopts9.sub f
tests/getopts10.sub f
tests/glob.tests f
tests/glob1.sub f
tests/glob.right f
@ -973,7 +1027,12 @@ tests/heredoc2.sub f
tests/heredoc3.sub f
tests/herestr.tests f
tests/herestr.right f
tests/herestr1.sub f
tests/histexp.tests f
tests/histexp1.sub f
tests/histexp2.sub f
tests/histexp3.sub f
tests/histexp4.sub f
tests/histexp.right f
tests/history.tests f
tests/history.right f
@ -990,6 +1049,7 @@ tests/input.right f
tests/intl.tests f
tests/intl1.sub f
tests/intl2.sub f
tests/intl3.sub f
tests/intl.right f
tests/iquote.tests f
tests/iquote.right f
@ -1006,10 +1066,12 @@ tests/jobs.right f
tests/lastpipe.right f
tests/lastpipe.tests f
tests/lastpipe1.sub f
tests/lastpipe2.sub f
tests/mapfile.data f
tests/mapfile.right f
tests/mapfile.tests f
tests/mapfile1.sub f
tests/mapfile2.sub f
tests/more-exp.tests f
tests/more-exp.right f
tests/nameref.tests f
@ -1021,6 +1083,16 @@ tests/nameref5.sub f
tests/nameref6.sub f
tests/nameref7.sub f
tests/nameref8.sub f
tests/nameref9.sub f
tests/nameref10.sub f
tests/nameref11.sub f
tests/nameref12.sub f
tests/nameref13.sub f
tests/nameref14.sub f
tests/nameref15.sub f
tests/nameref16.sub f
tests/nameref17.sub f
tests/nameref18.sub f
tests/nameref.right f
tests/new-exp.tests f
tests/new-exp1.sub f
@ -1032,11 +1104,13 @@ tests/new-exp6.sub f
tests/new-exp7.sub f
tests/new-exp8.sub f
tests/new-exp9.sub f
tests/new-exp10.sub f
tests/new-exp.right f
tests/nquote.tests f
tests/nquote.right f
tests/nquote1.sub f
tests/nquote2.sub f
tests/nquote3.sub f
tests/nquote1.tests f
tests/nquote1.right f
tests/nquote2.tests f
@ -1047,6 +1121,9 @@ tests/nquote4.tests f
tests/nquote4.right f
tests/nquote5.tests f
tests/nquote5.right f
tests/parser.tests f
tests/parser.right f
tests/parser1.sub f
tests/posix2.tests f
tests/posix2.right f
tests/posixexp.tests f
@ -1093,6 +1170,8 @@ tests/redir7.sub f
tests/redir8.sub f
tests/redir9.sub f
tests/redir10.sub f
tests/redir11.sub f
tests/redir12.sub f
tests/rhs-exp.tests f
tests/rhs-exp.right f
tests/rhs-exp1.sub f
@ -1107,6 +1186,7 @@ tests/run-arith f
tests/run-array f
tests/run-array2 f
tests/run-assoc f
tests/run-attr f
tests/run-braces f
tests/run-builtins f
tests/run-case f
@ -1124,6 +1204,7 @@ tests/run-dollars f
tests/run-errors f
tests/run-execscript f
tests/run-exp-tests f
tests/run-exportfunc f
tests/run-extglob f
tests/run-extglob2 f
tests/run-extglob3 f
@ -1153,6 +1234,7 @@ tests/run-nquote2 f
tests/run-nquote3 f
tests/run-nquote4 f
tests/run-nquote5 f
tests/run-parser f
tests/run-posix2 f
tests/run-posixexp f
tests/run-posixexp2 f
@ -1220,6 +1302,8 @@ tests/varenv3.sub f
tests/varenv4.sub f
tests/varenv5.sub f
tests/varenv6.sub f
tests/varenv7.sub f
tests/varenv8.sub f
tests/version f
tests/version.mini f
tests/vredir.tests f
@ -1230,6 +1314,7 @@ tests/vredir3.sub f
tests/vredir4.sub f
tests/vredir5.sub f
tests/vredir6.sub f
tests/vredir7.sub f
tests/misc/dev-tcp.tests f
tests/misc/perf-script f
tests/misc/perftest f

View file

@ -1,6 +1,6 @@
# Makefile for bash-4.3, version 4.11
# Makefile for bash-4.4, version 4.18
#
# Copyright (C) 1996-2012 Free Software Foundation, Inc.
# Copyright (C) 1996-2015 Free Software Foundation, Inc.
# 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
@ -42,6 +42,9 @@ includedir = @includedir@
datadir = @datadir@
localedir = @localedir@
loadablesdir = @loadablesdir@
headersdir = @headersdir@
docdir = @docdir@
mandir = @mandir@
@ -61,7 +64,7 @@ topdir = @top_srcdir@
BUILD_DIR = @BUILD_DIR@
top_builddir = @BUILD_DIR@
srcdir = @srcdir@
VPATH = .:@srcdir@
VPATH = @srcdir@
@SET_MAKE@
CC = @CC@
@ -86,10 +89,8 @@ TESTSCRIPT = @TESTSCRIPT@
DEBUGGER_START_FILE = @DEBUGGER_START_FILE@
#If you have purify, and want to use it, uncomment this definition or
# run the make as `make PURIFY=purify'
# or run configure with the --with-purify argument.
PURIFY = @PURIFY@
#If you have purify, and want to use it, run the make as `make PURIFY=purify'
#PURIFY = @PURIFY@
# Here is a rule for making .o files from .c files that does not
# force the type of the machine (like -M_MACHINE) into the flags.
@ -443,6 +444,19 @@ HSOURCES = shell.h flags.h trap.h hashcmd.h hashlib.h jobs.h builtins.h \
SOURCES = $(CSOURCES) $(HSOURCES) $(BUILTIN_DEFS)
# headers in top-level source directory that get installed by install-headers
INSTALLED_HEADERS = shell.h bashjmp.h command.h syntax.h general.h error.h \
variables.h array.h assoc.h arrayfunc.h quit.h dispose_cmd.h \
make_cmd.h subst.h sig.h externs.h builtins.h \
bashtypes.h xmalloc.h config-top.h config-bot.h \
bashintl.h bashansi.h bashjmp.h alias.h hashlib.h \
conftypes.h unwind_prot.h jobs.h siglist.h
INSTALLED_BUILTINS_HEADERS = bashgetopt.h common.h getopt.h
INSTALLED_INCFILES = posixstat.h ansi_stdlib.h filecntl.h posixdir.h \
memalloc.h stdc.h posixjmp.h posixwait.h posixtime.h systimes.h \
unionwait.h maxpath.h shtty.h typemax.h ocache.h chartypes.h gettext.h \
posixstat.h shmbchar.h shmbutil.h stat-time.h
# header files chosen based on running of configure
SIGNAMES_H = @SIGNAMES_H@
@ -521,7 +535,7 @@ PO_DIR = $(dot)/po/
SIGNAMES_SUPPORT = $(SUPPORT_SRC)mksignames.c
SUPPORT_SRC = $(srcdir)/support/
SDIR = $(dot)/support/
SDIR = $(dot)/support
TESTS_SUPPORT = recho$(EXEEXT) zecho$(EXEEXT) printenv$(EXEEXT) xcase$(EXEEXT)
CREATED_SUPPORT = signames.h recho$(EXEEXT) zecho$(EXEEXT) printenv$(EXEEXT) \
@ -536,17 +550,22 @@ CREATED_MAKEFILES = Makefile builtins/Makefile doc/Makefile \
lib/readline/Makefile lib/glob/Makefile \
lib/sh/Makefile lib/tilde/Makefile lib/malloc/Makefile \
lib/termcap/Makefile examples/loadables/Makefile \
examples/loadables/Makefile.inc \
examples/loadables/perl/Makefile support/Makefile \
lib/intl/Makefile po/Makefile po/Makefile.in
CREATED_HEADERS = signames.h config.h pathnames.h version.h y.tab.h \
${DEFDIR}/builtext.h
OTHER_DOCS = $(srcdir)/CHANGES $(srcdir)/COMPAT $(srcdir)/NEWS $(srcdir)/POSIX \
$(srcdir)/RBASH $(srcdir)/README
OTHER_INSTALLED_DOCS = CHANGES COMPAT NEWS POSIX RBASH README
LOADABLES_DIR = ${top_builddir}/examples/loadables
# Keep GNU Make from exporting the entire environment for small machines.
.NOEXPORT:
.made: $(Program) bashbug
.made: $(Program) bashbug $(SDIR)/man2html$(EXEEXT)
@echo "$(Program) last made for a $(Machine) running $(OS)" >.made
$(Program): .build $(OBJECTS) $(BUILTINS_DEP) $(LIBDEP)
@ -617,12 +636,12 @@ $(LIBDEP): .build
$(READLINE_LIBRARY): config.h $(READLINE_SOURCE)
@echo making $@ in ${RL_LIBDIR}
@( { test "${RL_LIBDIR}" = "${libdir}" && exit 0; } || \
cd ${RL_LIBDIR} && $(MAKE) $(MFLAGS) libreadline.a) || exit 1
cd ${RL_LIBDIR} && $(MAKE) $(MFLAGS) DEBUG=${DEBUG} libreadline.a) || exit 1
$(HISTORY_LIBRARY): config.h $(HISTORY_SOURCE) $(READLINE_DEP)
@echo making $@ in ${HIST_LIBDIR}
@( { test "${HIST_LIBDIR}" = "${libdir}" && exit 0; } || \
cd ${HIST_LIBDIR} && $(MAKE) $(MFLAGS) libhistory.a) || exit 1
cd ${HIST_LIBDIR} && $(MAKE) $(MFLAGS) DEBUG=${DEBUG} libhistory.a) || exit 1
$(GLOB_LIBRARY): config.h $(GLOB_SOURCE)
@echo making $@ in ${GLOB_LIBDIR}
@ -698,6 +717,9 @@ ${DEFDIR}/bashgetopt.o: $(BUILTIN_SRCDIR)/bashgetopt.c
${DEFDIR}/builtext.h: $(BUILTIN_DEFS)
@(cd $(DEFDIR) && $(MAKE) $(MFLAGS) builtext.h ) || exit 1
$(SDIR)/man2html$(EXEEXT): ${SUPPORT_SRC}/man2html.c
@(cd $(SDIR) && $(MAKE) $(MFLAGS) all ) || exit 1
# For the justification of the following Makefile rules, see node
# `Automatic Remaking' in GNU Autoconf documentation.
@ -734,6 +756,9 @@ $(srcdir)/configure: $(srcdir)/configure.ac $(srcdir)/aclocal.m4 $(srcdir)/confi
reconfig: force
sh $(srcdir)/configure -C
loadables:
cd $(LOADABLES_DIR) && $(MAKE) $(MFLAGS) all
#newversion: mkversion
# $(RM) .build
# ./mkversion -dir $(srcdir) -dist
@ -774,12 +799,41 @@ install: .made installdirs
infodir=$(infodir) htmldir=$(htmldir) DESTDIR=$(DESTDIR) $@ )
-( cd $(DEFDIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
-( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
-( cd $(LOADABLES_DIR) && $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
install-strip:
$(MAKE) $(MFLAGS) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' \
prefix=${prefix} exec_prefix=${exec_prefix} \
DESTDIR=$(DESTDIR) install
install-headers-dirs:
@${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(headersdir)
@${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(headersdir)/builtins
@${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(headersdir)/include
@${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(libdir)/pkgconfig
install-headers: install-headers-dirs
@for hf in $(INSTALLED_HEADERS) ; do \
${INSTALL_DATA} $(srcdir)/"$$hf" $(DESTDIR)$(headersdir)/$$hf; \
done
@for hf in $(INSTALLED_INCFILES) ; do \
${INSTALL_DATA} $(BASHINCDIR)/"$$hf" $(DESTDIR)$(headersdir)/include/$$hf; \
done
@for hf in $(INSTALLED_BUILTINS_HEADERS) ; do \
${INSTALL_DATA} $(BUILTIN_SRCDIR)/"$$hf" $(DESTDIR)$(headersdir)/builtins/$$hf; \
done
@for hf in $(CREATED_HEADERS) ; do \
${INSTALL_DATA} $(BUILD_DIR)/"$$hf" $(DESTDIR)$(headersdir)/$$hf; \
done
$(INSTALL_DATA) $(SDIR)/bash.pc $(DESTDIR)$(libdir)/pkgconfig/bash.pc
uninstall-headers:
-( cd $(DESTDIR)$(headersdir) && $(RM) $(INSTALLED_HEADERS) )
-( cd $(DESTDIR)$(headersdir)/include && $(RM) $(INSTALLED_INCFILES) )
-( cd $(DESTDIR)$(headersdir)/builtins && $(RM) $(INSTALLED_BUILTINS_HEADERS) )
-( cd $(DESTDIR)$(headersdir) && $(RM) $(CREATED_HEADERS) )
-( $(RM) $(DESTDIR)$(libdir)/pkgconfig/bash.pc )
uninstall: .made
$(RM) $(DESTDIR)$(bindir)/$(Program) $(DESTDIR)$(bindir)/bashbug
-( cd $(DESTDIR)$(docdir) && ${RM} ${OTHER_INSTALLED_DOCS} )
@ -788,6 +842,7 @@ uninstall: .made
man3dir=$(man3dir) man3ext=$(man3ext) \
infodir=$(infodir) htmldir=$(htmldir) DESTDIR=$(DESTDIR) $@ )
-( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
-( cd $(LOADABLES_DIR) && $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
.PHONY: basic-clean clean realclean maintainer-clean distclean mostlyclean maybe-clean
@ -806,6 +861,7 @@ clean: basic-clean
(cd $$libdir && test -f Makefile && $(MAKE) $(MFLAGS) $@) ;\
done
-( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
-( cd $(LOADABLES_DIR) && $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
$(RM) $(CREATED_SUPPORT)
mostlyclean: basic-clean
@ -816,6 +872,7 @@ mostlyclean: basic-clean
(cd $$libdir && test -f Makefile && $(MAKE) $(MFLAGS) $@) ;\
done
-( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
-( cd $(LOADABLES_DIR) && $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
distclean: basic-clean maybe-clean
( cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ )
@ -825,6 +882,7 @@ distclean: basic-clean maybe-clean
(cd $$libdir && test -f Makefile && $(MAKE) $(MFLAGS) $@) ;\
done
-( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
-( cd $(LOADABLES_DIR) && $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
$(RM) $(CREATED_CONFIGURE) tags TAGS
$(RM) $(CREATED_SUPPORT) Makefile $(CREATED_MAKEFILES) pathnames.h
@ -839,6 +897,7 @@ maintainer-clean: basic-clean
(cd $$libdir && test -f Makefile && $(MAKE) $(MFLAGS) $@) ;\
done
-( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
-( cd $(LOADABLES_DIR) && $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
$(RM) $(CREATED_CONFIGURE) $(CREATED_MAKEFILES)
$(RM) $(CREATED_SUPPORT) Makefile pathnames.h
@ -871,9 +930,11 @@ symlinks:
dist: force
@echo Bash distributions are created using $(srcdir)/support/mkdist.
@echo Here is a sample of the necessary commands:
@echo $(Program) $(srcdir)/support/mkdist -m $(srcdir)/MANIFEST -s $(srcdir) -r ${PACKAGE} $(PACKAGE_VERSION)
@echo tar cf $(PACKAGE)-${PACKAGE_VERSION}.tar ${PACKAGE}-$(PACKAGE_VERSION)
@echo gzip $(PACKAGE)-$(PACKAGE_VERSION).tar
@echo $(Program) $(srcdir)/support/mkdist -m $(srcdir)/MANIFEST -s $(srcdir) -r ${PACKAGE} -t $(PACKAGE_VERSION)
xdist: force
( cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ )
( cd po && $(MAKE) $(MFLAGS) $@ )
depend: depends
@ -882,7 +943,7 @@ depends: force
#### PRIVATE TARGETS ####
hashtest: hashlib.c
$(CC) -DTEST_HASHING $(CCFLAGS) -o $@ $(srcdir)/hashlib.c
$(CC) -DTEST_HASHING $(CCFLAGS) $(TEST_NBUCKETS) -o $@ $(srcdir)/hashlib.c xmalloc.o $(INTL_LIB)
############################ DEPENDENCIES ###############################
@ -937,6 +998,7 @@ execute_cmd.o: ${BASHINCDIR}/memalloc.h ${GRAM_H} flags.h builtins.h jobs.h quit
execute_cmd.o: execute_cmd.h findcmd.h redir.h trap.h test.h pathexp.h
execute_cmd.o: $(DEFSRC)/common.h ${DEFDIR}/builtext.h ${GLOB_LIBSRC}/strmatch.h
execute_cmd.o: ${BASHINCDIR}/posixtime.h ${BASHINCDIR}/chartypes.h
execute_cmd.o: $(DEFSRC)/getopt.h
expr.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
expr.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
expr.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
@ -965,6 +1027,7 @@ hashcmd.o: config.h ${BASHINCDIR}/posixstat.h bashtypes.h bashansi.h ${BASHINCDI
hashcmd.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
hashcmd.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashcmd.h
hashcmd.o: execute_cmd.h findcmd.h ${BASHINCDIR}/stdc.h pathnames.h hashlib.h
hashcmd.o: quit.h sig.h
hashlib.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
hashlib.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
hashlib.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
@ -993,7 +1056,7 @@ mailcheck.o: execute_cmd.h mailcheck.h
make_cmd.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h bashansi.h
make_cmd.o: command.h ${BASHINCDIR}/stdc.h general.h xmalloc.h error.h flags.h make_cmd.h
make_cmd.o: variables.h arrayfunc.h conftypes.h array.h hashlib.h subst.h input.h externs.h
make_cmd.o: jobs.h quit.h siglist.h syntax.h dispose_cmd.h parser.h
make_cmd.o: jobs.h quit.h sig.h siglist.h syntax.h dispose_cmd.h parser.h
make_cmd.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h ${BASHINCDIR}/ocache.h
y.tab.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/memalloc.h
y.tab.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
@ -1015,6 +1078,7 @@ print_cmd.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h comman
print_cmd.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
print_cmd.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
print_cmd.o: make_cmd.h subst.h sig.h pathnames.h externs.h
print_cmd.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
print_cmd.o: ${GRAM_H} $(DEFSRC)/common.h
redir.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/filecntl.h
redir.o: ${BASHINCDIR}/memalloc.h shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
@ -1143,6 +1207,7 @@ pcomplete.o: ${BASHINCDIR}/stdc.h hashlib.h pcomplete.h shell.h syntax.h
pcomplete.o: bashjmp.h command.h general.h xmalloc.h error.h variables.h arrayfunc.h conftypes.h quit.h
pcomplete.o: unwind_prot.h dispose_cmd.h make_cmd.h subst.h sig.h pathnames.h
pcomplete.o: externs.h ${BASHINCDIR}/maxpath.h execute_cmd.h
pcomplete.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
pcomplete.o: ${DEFDIR}/builtext.h
# library support files
@ -1171,6 +1236,7 @@ bracecomp.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h
bracecomp.o: array.h hashlib.h alias.h builtins.h
bracecomp.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
bracecomp.o: make_cmd.h subst.h sig.h pathnames.h externs.h
bracecomp.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
# library dependencies
@ -1302,7 +1368,7 @@ builtins/command.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/std
builtins/declare.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
builtins/declare.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
builtins/declare.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/declare.o: $(DEFSRC)/bashgetopt.h pathnames.h
builtins/declare.o: $(DEFSRC)/bashgetopt.h pathnames.h flags.h
builtins/echo.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
builtins/echo.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
builtins/echo.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
@ -1377,6 +1443,7 @@ builtins/printf.o: config.h ${BASHINCDIR}/memalloc.h bashjmp.h command.h error.h
builtins/printf.o: general.h xmalloc.h quit.h dispose_cmd.h make_cmd.h subst.h
builtins/printf.o: externs.h sig.h pathnames.h shell.h syntax.h unwind_prot.h
builtins/printf.o: variables.h arrayfunc.h conftypes.h ${BASHINCDIR}/stdc.h $(DEFSRC)/bashgetopt.h
builtins/printf.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
builtins/printf.o: ${BASHINCDIR}/chartypes.h
builtins/pushd.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
builtins/pushd.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
@ -1385,6 +1452,7 @@ builtins/pushd.o: $(DEFSRC)/common.h pathnames.h
builtins/read.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
builtins/read.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/read.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
builtins/read.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
builtins/read.o: pathnames.h
builtins/return.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
builtins/return.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
@ -1398,7 +1466,7 @@ builtins/setattr.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.
builtins/setattr.o: quit.h $(DEFSRC)/common.h $(DEFSRC)/bashgetopt.h
builtins/setattr.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
builtins/setattr.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/setattr.o: pathnames.h
builtins/setattr.o: pathnames.h flags.h
builtins/shift.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
builtins/shift.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/shift.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
@ -1452,7 +1520,8 @@ builtins/wait.o: ${BASHINCDIR}/chartypes.h pathnames.h
builtins/complete.o: config.h shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h
builtins/complete.o: unwind_prot.h variables.h arrayfunc.h conftypes.h
builtins/complete.o: bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
builtins/complete.o: builtins.h pathnames.h
builtins/complete.o: builtins.h pathnames.h general.h
builtins/complete.o: bashtypes.h ${BASHINCDIR}/chartypes.h xmalloc.h
builtins/complete.o: pcomplete.h
builtins/complete.o: ${DEFSRC}/common.h ${DEFSRC}/bashgetopt.h
builtins/mapfile.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h

224
NEWS
View file

@ -1,3 +1,227 @@
This is a terse description of the new features added to bash-4.4 since
the release of bash-4.3. As always, the manual page (doc/bash.1) is
the place to look for complete descriptions.
1. New Features in Bash
a. There is now a settable configuration #define that will cause the shell
to exit if the shell is running setuid without the -p option and setuid
to the real uid fails.
b. Command and process substitutions now turn off the `-v' option when
executing, as other shells seem to do.
c. The default value for the `checkhash' shell option may now be set at
compile time with a #define.
d. The `mapfile' builtin now has a -d option to use an arbitrary character
as the record delimiter, and a -t option to strip the delimiter as
supplied with -d.
e. The maximum number of nested recursive calls to `eval' is now settable in
config-top.h; the default is no limit.
f. The `-p' option to declare and similar builtins will display attributes for
named variables even when those variables have not been assigned values
(which are technically unset).
g. The maximum number of nested recursive calls to `source' is now settable
in config-top.h; the default is no limit.
h. All builtin commands recognize the `--help' option and print a usage
summary.
i. Bash does not allow function names containing `/' and `=' to be exported.
j. The `ulimit' builtin has new -k (kqueues) and -P (pseudoterminals) options.
k. The shell now allows `time ; othercommand' to time null commands.
l. There is a new `--enable-function-import' configuration option to allow
importing shell functions from the environment; import is enabled by
default.
m. `printf -v var ""' will now set `var' to the empty string, as if `var=""'
had been executed.
n. GLOBIGNORE, the pattern substitution word expansion, and programmable
completion match filtering now honor the value of the `nocasematch' option.
o. There is a new ${parameter@spec} family of operators to transform the
value of `parameter'.
p. Bash no longer attempts to perform compound assignment if a variable on the
rhs of an assignment statement argument to `declare' has the form of a
compound assignment (e.g., w='(word)' ; declare foo=$w); compound
assignments are accepted if the variable was already declared as an array,
but with a warning.
q. The declare builtin no longer displays array variables using the compound
assignment syntax with quotes; that will generate warnings when re-used as
input, and isn't necessary.
r. Executing the rhs of && and || will no longer cause the shell to fork if
it's not necessary.
s. The `local' builtin takes a new argument: `-', which will cause it to save
and the single-letter shell options and restore their previous values at
function return.
t. `complete' and `compgen' have a new `-o nosort' option, which forces
readline to not sort the completion matches.
u. Bash now allows waiting for the most recent process substitution, since it
appears as $!.
v. The `unset' builtin now unsets a scalar variable if it is subscripted with
a `0', analogous to the ${var[0]} expansion.
w. `set -i' is no longer valid, as in other shells.
x. BASH_SUBSHELL is now updated for process substitution and group commands
in pipelines, and is available with the same value when running any exit
trap.
y. Bash now checks $INSIDE_EMACS as well as $EMACS when deciding whether or
not bash is being run in a GNU Emacs shell window.
z. Bash now treats SIGINT received when running a non-builtin command in a
loop the way it has traditionally treated running a builtin command:
running any trap handler and breaking out of the loop.
aa. New variable: EXECIGNORE; a colon-separate list of patterns that will
cause matching filenames to be ignored when searching for commands.
bb. Aliases whose value ends in a shell metacharacter now expand in a way to
allow them to be `pasted' to the next token, which can potentially change
the meaning of a command (e.g., turning `&' into `&&').
cc. `make install' now installs the example loadable builtins and a set of
bash headers to use when developing new loadable builtins.
dd. `enable -f' now attempts to call functions named BUILTIN_builtin_load when
loading BUILTIN, and BUILTIN_builtin_unload when deleting it. This allows
loadable builtins to run initialization and cleanup code.
ee. There is a new BASH_LOADABLES_PATH variable containing a list of directories
where the `enable -f' command looks for shared objects containing loadable
builtins.
ff. The `complete_fullquote' option to `shopt' changes filename completion to
quote all shell metacharacters in filenames and directory names.
gg. The `kill' builtin now has a `-L' option, equivalent to `-l', for
compatibility with Linux standalone versions of kill.
hh. BASH_COMPAT and FUNCNEST can be inherited and set from the shell's initial
environment.
ii. inherit_errexit: a new `shopt' option that, when set, causes command
substitutions to inherit the -e option. By default, those subshells disable
-e. It's enabled as part of turning on posix mode.
jj. New prompt string: PS0. Expanded and displayed by interactive shells after
reading a complete command but before executing it.
kk. Interactive shells now behave as if SIGTSTP/SIGTTIN/SIGTTOU are set to
SIG_DFL when the shell is started, so they are set to SIG_DFL in child
processes.
ll. Posix-mode shells now allow double quotes to quote the history expansion
character.
mm. OLDPWD can be inherited from the environment if it names a directory.
nn. Shells running as root no longer inherit PS4 from the environment, closing
a security hole involving PS4 expansion performing command substitution.
oo. If executing an implicit `cd' when the `autocd' option is set, bash will
now invoke a function named `cd' if one exists before executing the `cd'
builtin.
pp. Value conversions (arithmetic expansions, case modification, etc.) now
happen when assigning elements of an array using compound assignment.
qq. There is a new option settable in config-top.h that makes multiple
directory arguments to `cd' a fatal error.
rr. Bash now uses mktemp() when creating internal temporary files; it produces
a warning at build time on many Linux systems.
2. New Features in Readline
a. The history truncation code now uses the same error recovery mechansim as
the history writing code, and restores the old version of the history file
on error. The error recovery mechanism handles symlinked history files.
b. There is a new bindable variable, `enable-bracketed-paste', which enables
support for a terminal's bracketed paste mode.
c. The editing mode indicators can now be strings and are user-settable
(new `emacs-mode-string', `vi-cmd-mode-string' and `vi-ins-mode-string'
variables). Mode strings can contain invisible character sequences.
Setting mode strings to null strings restores the defaults.
d. Prompt expansion adds the mode string to the last line of a multi-line
prompt (one with embedded newlines).
e. There is a new bindable variable, `colored-completion-prefix', which, if
set, causes the common prefix of a set of possible completions to be
displayed in color.
f. There is a new bindable command `vi-yank-pop', a vi-mode version of emacs-
mode yank-pop.
g. The redisplay code underwent several efficiency improvements for multibyte
locales.
h. The insert-char function attempts to batch-insert all pending typeahead
that maps to self-insert, as long as it is coming from the terminal.
i. rl_callback_sigcleanup: a new application function that can clean up and
unset any state set by readline's callback mode. Intended to be used
after a signal.
j. If an incremental search string has its last character removed with DEL, the
resulting empty search string no longer matches the previous line.
k. If readline reads a history file that begins with `#' (or the value of
the history comment character) and has enabled history timestamps, the
history entries are assumed to be delimited by timestamps. This allows
multi-line history entries.
l. Readline now throws an error if it parses a key binding without a
terminating `:' or whitespace.
m. The default binding for ^W in vi mode now uses word boundaries specified
by Posix (vi-unix-word-rubout is bindable command name).
n. rl_clear_visible_line: new application-callable function; clears all
screen lines occupied by the current visible readline line.
o. rl_tty_set_echoing: application-callable function that controls whether
or not readline thinks it is echoing terminal output.
p. Handle >| and strings of digits preceding and following redirection
specifications as single tokens when tokenizing the line for history
expansion.
q. Fixed a bug with displaying completions when the prefix display length
is greater than the length of the completions to be displayed.
r. The :p history modifier now applies to the entire line, so any expansion
specifying :p causes the line to be printed instead of expanded.
s. New application-callable function: rl_pending_signal(): returns the signal
number of any signal readline has caught but not yet handled.
t. New application-settable variable: rl_persistent_signal_handlers: if set
to a non-zero value, readline will enable the readline-6.2 signal handler
behavior in callback mode: handlers are installed when
rl_callback_handler_install is called and removed removed when a complete
line has been read.
-------------------------------------------------------------------------------
This is a terse description of the new features added to bash-4.3 since
the release of bash-4.2. As always, the manual page (doc/bash.1) is
the place to look for complete descriptions.

4
NOTES
View file

@ -1,5 +1,5 @@
Platform-Specific Configuration and Operation Notes
===================================================
Platform-Specific Configuration and Operation Notes [somewhat dated]
====================================================================
1. configure --without-gnu-malloc on:

230
POSIX
View file

@ -1,216 +1,228 @@
6.11 Bash POSIX Mode
====================
Starting Bash with the `--posix' command-line option or executing `set
Starting Bash with the '--posix' command-line option or executing 'set
-o posix' while Bash is running will cause Bash to conform more closely
to the POSIX standard by changing the behavior to match that specified
by POSIX in areas where the Bash default differs.
When invoked as `sh', Bash enters POSIX mode after reading the startup
When invoked as 'sh', Bash enters POSIX mode after reading the startup
files.
The following list is what's changed when `POSIX mode' is in effect:
The following list is what's changed when 'POSIX mode' is in effect:
1. When a command in the hash table no longer exists, Bash will
re-search `$PATH' to find the new location. This is also
available with `shopt -s checkhash'.
re-search '$PATH' to find the new location. This is also available
with 'shopt -s checkhash'.
2. The message printed by the job control code and builtins when a job
exits with a non-zero status is `Done(status)'.
exits with a non-zero status is 'Done(status)'.
3. The message printed by the job control code and builtins when a job
is stopped is `Stopped(SIGNAME)', where SIGNAME is, for example,
`SIGTSTP'.
is stopped is 'Stopped(SIGNAME)', where SIGNAME is, for example,
'SIGTSTP'.
4. The `bg' builtin uses the required format to describe each job
placed in the background, which does not include an indication of
whether the job is the current or previous job.
4. Alias expansion is always enabled, even in non-interactive shells.
5. Reserved words appearing in a context where reserved words are
recognized do not undergo alias expansion.
6. The POSIX `PS1' and `PS2' expansions of `!' to the history number
and `!!' to `!' are enabled, and parameter expansion is performed
on the values of `PS1' and `PS2' regardless of the setting of the
`promptvars' option.
6. The POSIX 'PS1' and 'PS2' expansions of '!' to the history number
and '!!' to '!' are enabled, and parameter expansion is performed
on the values of 'PS1' and 'PS2' regardless of the setting of the
'promptvars' option.
7. The POSIX startup files are executed (`$ENV') rather than the
7. The POSIX startup files are executed ('$ENV') rather than the
normal Bash files.
8. Tilde expansion is only performed on assignments preceding a
command name, rather than on all assignment statements on the line.
9. The `command' builtin does not prevent builtins that take
assignment statements as arguments from expanding them as
assignment statements; when not in POSIX mode, assignment builtins
lose their assignment statement expansion properties when preceded
by `command'.
9. The default history file is '~/.sh_history' (this is the default
value of '$HISTFILE').
10. The default history file is `~/.sh_history' (this is the default
value of `$HISTFILE').
10. Redirection operators do not perform filename expansion on the
word in the redirection unless the shell is interactive.
11. The output of `kill -l' prints all the signal names on a single
line, separated by spaces, without the `SIG' prefix.
12. The `kill' builtin does not accept signal names with a `SIG'
prefix.
13. Non-interactive shells exit if FILENAME in `.' FILENAME is not
found.
14. Non-interactive shells exit if a syntax error in an arithmetic
expansion results in an invalid expression.
15. Non-interactive shells exit if there is a syntax error in a script
read with the `.' or `source' builtins, or in a string processed by
the `eval' builtin.
16. Redirection operators do not perform filename expansion on the word
in the redirection unless the shell is interactive.
17. Redirection operators do not perform word splitting on the word in
11. Redirection operators do not perform word splitting on the word in
the redirection.
18. Function names must be valid shell `name's. That is, they may not
12. Function names must be valid shell 'name's. That is, they may not
contain characters other than letters, digits, and underscores, and
may not start with a digit. Declaring a function with an invalid
name causes a fatal syntax error in non-interactive shells.
19. Function names may not be the same as one of the POSIX special
13. Function names may not be the same as one of the POSIX special
builtins.
20. POSIX special builtins are found before shell functions during
14. POSIX special builtins are found before shell functions during
command lookup.
21. The `time' reserved word may be used by itself as a command. When
15. Literal tildes that appear as the first character in elements of
the 'PATH' variable are not expanded as described above under *note
Tilde Expansion::.
16. The 'time' reserved word may be used by itself as a command. When
used in this way, it displays timing statistics for the shell and
its completed children. The `TIMEFORMAT' variable controls the
its completed children. The 'TIMEFORMAT' variable controls the
format of the timing information.
22. When parsing and expanding a ${...} expansion that appears within
17. When parsing and expanding a ${...} expansion that appears within
double quotes, single quotes are no longer special and cannot be
used to quote a closing brace or other special character, unless
the operator is one of those defined to perform pattern removal.
In this case, they do not have to appear as matched pairs.
23. The parser does not recognize `time' as a reserved word if the next
token begins with a `-'.
18. The parser does not recognize 'time' as a reserved word if the
next token begins with a '-'.
24. If a POSIX special builtin returns an error status, a
19. The '!' character does not introduce history expansion within a
double-quoted string, even if the 'histexpand' option is enabled.
20. If a POSIX special builtin returns an error status, a
non-interactive shell exits. The fatal errors are those listed in
the POSIX standard, and include things like passing incorrect
options, redirection errors, variable assignment errors for
assignments preceding the command name, and so on.
25. A non-interactive shell exits with an error status if a variable
21. A non-interactive shell exits with an error status if a variable
assignment error occurs when no command name follows the assignment
statements. A variable assignment error occurs, for example, when
trying to assign a value to a readonly variable.
26. A non-interactive shell exits with an error status if a variable
22. A non-interactive shell exits with an error status if a variable
assignment error occurs in an assignment statement preceding a
special builtin, but not with any other simple command.
27. A non-interactive shell exits with an error status if the iteration
variable in a `for' statement or the selection variable in a
`select' statement is a readonly variable.
23. A non-interactive shell exits with an error status if the
iteration variable in a 'for' statement or the selection variable
in a 'select' statement is a readonly variable.
28. Process substitution is not available.
24. Non-interactive shells exit if FILENAME in '.' FILENAME is not
found.
29. While variable indirection is available, it may not be applied to
the `#' and `?' special parameters.
25. Non-interactive shells exit if a syntax error in an arithmetic
expansion results in an invalid expression.
30. Assignment statements preceding POSIX special builtins persist in
26. Non-interactive shells exit on word expansion errors.
27. Non-interactive shells exit if there is a syntax error in a script
read with the '.' or 'source' builtins, or in a string processed by
the 'eval' builtin.
28. Process substitution is not available.
29. While variable indirection is available, it may not be applied to
the '#' and '?' special parameters.
30. Assignment statements preceding POSIX special builtins persist in
the shell environment after the builtin completes.
31. Assignment statements preceding shell function calls persist in the
shell environment after the function returns, as if a POSIX
31. Assignment statements preceding shell function calls persist in
the shell environment after the function returns, as if a POSIX
special builtin command had been executed.
32. The `export' and `readonly' builtin commands display their output
32. The 'command' builtin does not prevent builtins that take
assignment statements as arguments from expanding them as
assignment statements; when not in POSIX mode, assignment builtins
lose their assignment statement expansion properties when preceded
by 'command'.
33. The 'bg' builtin uses the required format to describe each job
placed in the background, which does not include an indication of
whether the job is the current or previous job.
34. The output of 'kill -l' prints all the signal names on a single
line, separated by spaces, without the 'SIG' prefix.
35. The 'kill' builtin does not accept signal names with a 'SIG'
prefix.
36. The 'export' and 'readonly' builtin commands display their output
in the format required by POSIX.
33. The `trap' builtin displays signal names without the leading `SIG'.
37. The 'trap' builtin displays signal names without the leading
'SIG'.
34. The `trap' builtin doesn't check the first argument for a possible
38. The 'trap' builtin doesn't check the first argument for a possible
signal specification and revert the signal handling to the original
disposition if it is, unless that argument consists solely of
digits and is a valid signal number. If users want to reset the
handler for a given signal to the original disposition, they
should use `-' as the first argument.
handler for a given signal to the original disposition, they should
use '-' as the first argument.
35. The `.' and `source' builtins do not search the current directory
for the filename argument if it is not found by searching `PATH'.
39. The '.' and 'source' builtins do not search the current directory
for the filename argument if it is not found by searching 'PATH'.
36. Subshells spawned to execute command substitutions inherit the
value of the `-e' option from the parent shell. When not in POSIX
mode, Bash clears the `-e' option in such subshells.
40. Enabling POSIX mode has the effect of setting the
'inherit_errexit' option, so subshells spawned to execute command
substitutions inherit the value of the '-e' option from the parent
shell. When the 'inherit_errexit' option is not enabled, Bash
clears the '-e' option in such subshells.
37. Alias expansion is always enabled, even in non-interactive shells.
38. When the `alias' builtin displays alias definitions, it does not
display them with a leading `alias ' unless the `-p' option is
41. When the 'alias' builtin displays alias definitions, it does not
display them with a leading 'alias ' unless the '-p' option is
supplied.
39. When the `set' builtin is invoked without options, it does not
42. When the 'set' builtin is invoked without options, it does not
display shell function names and definitions.
40. When the `set' builtin is invoked without options, it displays
43. When the 'set' builtin is invoked without options, it displays
variable values without quotes, unless they contain shell
metacharacters, even if the result contains nonprinting characters.
41. When the `cd' builtin is invoked in LOGICAL mode, and the pathname
constructed from `$PWD' and the directory name supplied as an
argument does not refer to an existing directory, `cd' will fail
44. When the 'cd' builtin is invoked in LOGICAL mode, and the pathname
constructed from '$PWD' and the directory name supplied as an
argument does not refer to an existing directory, 'cd' will fail
instead of falling back to PHYSICAL mode.
42. The `pwd' builtin verifies that the value it prints is the same as
45. The 'pwd' builtin verifies that the value it prints is the same as
the current directory, even if it is not asked to check the file
system with the `-P' option.
system with the '-P' option.
43. When listing the history, the `fc' builtin does not include an
46. When listing the history, the 'fc' builtin does not include an
indication of whether or not a history entry has been modified.
44. The default editor used by `fc' is `ed'.
47. The default editor used by 'fc' is 'ed'.
45. The `type' and `command' builtins will not report a non-executable
file as having been found, though the shell will attempt to
execute such a file if it is the only so-named file found in
`$PATH'.
48. The 'type' and 'command' builtins will not report a non-executable
file as having been found, though the shell will attempt to execute
such a file if it is the only so-named file found in '$PATH'.
46. The `vi' editing mode will invoke the `vi' editor directly when
the `v' command is run, instead of checking `$VISUAL' and
`$EDITOR'.
49. The 'vi' editing mode will invoke the 'vi' editor directly when
the 'v' command is run, instead of checking '$VISUAL' and
'$EDITOR'.
47. When the `xpg_echo' option is enabled, Bash does not attempt to
interpret any arguments to `echo' as options. Each argument is
50. When the 'xpg_echo' option is enabled, Bash does not attempt to
interpret any arguments to 'echo' as options. Each argument is
displayed, after escape characters are converted.
48. The `ulimit' builtin uses a block size of 512 bytes for the `-c'
and `-f' options.
51. The 'ulimit' builtin uses a block size of 512 bytes for the '-c'
and '-f' options.
49. The arrival of `SIGCHLD' when a trap is set on `SIGCHLD' does not
interrupt the `wait' builtin and cause it to return immediately.
52. The arrival of 'SIGCHLD' when a trap is set on 'SIGCHLD' does not
interrupt the 'wait' builtin and cause it to return immediately.
The trap command is run once for each child that exits.
50. The `read' builtin may be interrupted by a signal for which a trap
53. The 'read' builtin may be interrupted by a signal for which a trap
has been set. If Bash receives a trapped signal while executing
`read', the trap handler executes and `read' returns an exit
status greater than 128.
'read', the trap handler executes and 'read' returns an exit status
greater than 128.
54. Bash removes an exited background process's status from the list
of such statuses after the 'wait' builtin is used to obtain it.
There is other POSIX behavior that Bash does not implement by default
even when in POSIX mode. Specifically:
1. The `fc' builtin checks `$EDITOR' as a program to edit history
entries if `FCEDIT' is unset, rather than defaulting directly to
`ed'. `fc' uses `ed' if `EDITOR' is unset.
2. As noted above, Bash requires the `xpg_echo' option to be enabled
for the `echo' builtin to be fully conformant.
1. The 'fc' builtin checks '$EDITOR' as a program to edit history
entries if 'FCEDIT' is unset, rather than defaulting directly to
'ed'. 'fc' uses 'ed' if 'EDITOR' is unset.
2. As noted above, Bash requires the 'xpg_echo' option to be enabled
for the 'echo' builtin to be fully conformant.
Bash can be configured to be POSIX-conformant by default, by specifying
the `--enable-strict-posix-default' to `configure' when building (*note
the '--enable-strict-posix-default' to 'configure' when building (*note
Optional Features::).

46
RBASH
View file

@ -1,49 +1,37 @@
6.10 The Restricted Shell
=========================
If Bash is started with the name `rbash', or the `--restricted' or `-r'
If Bash is started with the name 'rbash', or the '--restricted' or '-r'
option is supplied at invocation, the shell becomes restricted. A
restricted shell is used to set up an environment more controlled than
the standard shell. A restricted shell behaves identically to `bash'
the standard shell. A restricted shell behaves identically to 'bash'
with the exception that the following are disallowed or not performed:
* Changing directories with the `cd' builtin.
* Setting or unsetting the values of the `SHELL', `PATH', `ENV', or
`BASH_ENV' variables.
* Changing directories with the 'cd' builtin.
* Setting or unsetting the values of the 'SHELL', 'PATH', 'ENV', or
'BASH_ENV' variables.
* Specifying command names containing slashes.
* Specifying a filename containing a slash as an argument to the `.'
* Specifying a filename containing a slash as an argument to the '.'
builtin command.
* Specifying a filename containing a slash as an argument to the `-p'
option to the `hash' builtin command.
* Specifying a filename containing a slash as an argument to the '-p'
option to the 'hash' builtin command.
* Importing function definitions from the shell environment at
startup.
* Parsing the value of `SHELLOPTS' from the shell environment at
* Parsing the value of 'SHELLOPTS' from the shell environment at
startup.
* Redirecting output using the `>', `>|', `<>', `>&', `&>', and `>>'
* Redirecting output using the '>', '>|', '<>', '>&', '&>', and '>>'
redirection operators.
* Using the `exec' builtin to replace the shell with another command.
* Adding or deleting builtin commands with the `-f' and `-d' options
to the `enable' builtin.
* Using the `enable' builtin command to enable disabled shell
* Using the 'exec' builtin to replace the shell with another command.
* Adding or deleting builtin commands with the '-f' and '-d' options
to the 'enable' builtin.
* Using the 'enable' builtin command to enable disabled shell
builtins.
* Specifying the `-p' option to the `command' builtin.
* Turning off restricted mode with `set +r' or `set +o restricted'.
* Specifying the '-p' option to the 'command' builtin.
* Turning off restricted mode with 'set +r' or 'set +o restricted'.
These restrictions are enforced after any startup files are read.
When a command that is found to be a shell script is executed (*note
Shell Scripts::), `rbash' turns off any restrictions in the shell
Shell Scripts::), 'rbash' turns off any restrictions in the shell
spawned to execute the script.

6
README
View file

@ -1,7 +1,7 @@
Introduction
============
This is GNU Bash, version 4.3. Bash is the GNU Project's Bourne
This is GNU Bash, version 4.4. Bash is the GNU Project's Bourne
Again SHell, a complete implementation of the POSIX shell spec,
but also with interactive command line editing, job control on
architectures that support it, csh-like features such as history
@ -15,8 +15,8 @@ See the file POSIX for a discussion of how the Bash defaults differ
from the POSIX spec and a description of the Bash `posix mode'.
There are some user-visible incompatibilities between this version
of Bash and previous widely-distributed versions, bash-4.1 and
bash-4.2. For details, see the file COMPAT. The NEWS file tersely
of Bash and previous widely-distributed versions, bash-4.2 and
bash-4.3. For details, see the file COMPAT. The NEWS file tersely
lists features that are new in this release.
Bash is free software, distributed under the terms of the [GNU] General

8
aclocal.m4 vendored
View file

@ -1692,6 +1692,8 @@ AC_CHECK_HEADERS(wctype.h)
AC_CHECK_HEADERS(wchar.h)
AC_CHECK_HEADERS(langinfo.h)
AC_CHECK_HEADERS(mbstr.h)
AC_CHECK_FUNC(mbrlen, AC_DEFINE(HAVE_MBRLEN))
AC_CHECK_FUNC(mbscasecmp, AC_DEFINE(HAVE_MBSCMP))
AC_CHECK_FUNC(mbscmp, AC_DEFINE(HAVE_MBSCMP))
@ -1784,14 +1786,14 @@ char **v;
exit (w == 0); /* exit 0 if wcwidth broken */
}
],
bash_cv_wcwidth_broken=yes, bash_cv_wcwdith_broken=no, bash_cv_wcwidth_broken=no)])
bash_cv_wcwidth_broken=yes, bash_cv_wcwidth_broken=no, bash_cv_wcwidth_broken=no)])
if test "$bash_cv_wcwidth_broken" = yes; then
AC_DEFINE(WCWIDTH_BROKEN, 1, [wcwidth is usually not broken])
fi
if test "$am_cv_func_iconv" = yes; then
OLDLIBS="$LIBS"
LIBS="$LIBS $LIBICONV"
LIBS="$LIBS $LIBINTL $LIBICONV"
AC_CHECK_FUNCS(locale_charset)
LIBS="$OLDLIBS"
fi
@ -1854,7 +1856,7 @@ main()
],
ac_cv_rl_version=`cat conftest.rlv`,
ac_cv_rl_version='0.0',
ac_cv_rl_version='4.2')])
ac_cv_rl_version='6.3')])
CFLAGS="$_save_CFLAGS"
LDFLAGS="$_save_LDFLAGS"

View file

@ -1,7 +1,7 @@
/* alias.c -- Not a full alias, but just the kind that we use in the
shell. Csh style alias is somewhere else (`over there, in a box'). */
/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
/* Copyright (C) 1987-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -42,7 +42,11 @@
# include "pcomplete.h"
#endif
#define ALIAS_HASH_BUCKETS 16 /* must be power of two */
#if defined (HAVE_MBSTR_H) && defined (HAVE_MBSCHR)
# include <mbstr.h> /* mbschr */
#endif
#define ALIAS_HASH_BUCKETS 64 /* must be power of two */
typedef int sh_alias_map_func_t __P((alias_t *));

12
array.c
View file

@ -55,6 +55,9 @@
static char *array_to_string_internal __P((ARRAY_ELEMENT *, ARRAY_ELEMENT *, char *, int));
/* lastref should be moved into the array structure so each array can be
optimized separately */
static ARRAY *lastarray = 0;
static ARRAY_ELEMENT *lastref = 0;
@ -719,7 +722,7 @@ arrayind_t i;
SET_LASTREF(a, ae);
return(element_value(ae));
}
UNSET_LASTREF();
UNSET_LASTREF(); /* XXX SET_LASTREF(a, start) ? */
return((char *) NULL);
}
@ -834,7 +837,7 @@ int quoted;
rsize, rsize);
strcpy(result + rlen, t);
rlen += reg;
if (quoted && t)
if (quoted)
free(t);
/*
* Add a separator only after non-null elements.
@ -869,7 +872,10 @@ int quoted;
for (ae = element_forw(a->head); ae != a->head; ae = element_forw(ae)) {
is = inttostr (element_index(ae), indstr, sizeof(indstr));
valstr = element_value (ae) ? sh_double_quote (element_value(ae))
valstr = element_value (ae) ?
(ansic_shouldquote (element_value (ae)) ?
ansic_quote (element_value(ae), 0, (int *)0) :
sh_double_quote (element_value (ae)))
: (char *)NULL;
elen = STRLEN (is) + 8 + STRLEN (valstr);
RESIZE_MALLOCED_BUFFER (result, rlen, (elen + 1), rsize, rsize);

View file

@ -1,6 +1,6 @@
/* arrayfunc.c -- High-level array functions used by other parts of the shell. */
/* Copyright (C) 2001-2011 Free Software Foundation, Inc.
/* Copyright (C) 2001-2016 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -33,6 +33,9 @@
#include "pathexp.h"
#include "shmbutil.h"
#if defined (HAVE_MBSTR_H) && defined (HAVE_MBSCHR)
# include <mbstr.h> /* mbschr */
#endif
#include "builtins/common.h"
@ -45,7 +48,7 @@ static SHELL_VAR *assign_array_element_internal __P((SHELL_VAR *, char *, char *
static char *quote_assign __P((const char *));
static void quote_array_assignment_chars __P((WORD_LIST *));
static char *array_value_internal __P((char *, int, int, int *, arrayind_t *));
static char *array_value_internal __P((const char *, int, int, int *, arrayind_t *));
/* Standard error message to use when encountering an invalid array subscript */
const char * const bash_badsub_errmsg = N_("bad array subscript");
@ -84,6 +87,12 @@ convert_var_to_array (var)
VSETATTR (var, att_array);
VUNSETATTR (var, att_invisible);
/* Make sure it's not marked as an associative array any more */
VUNSETATTR (var, att_assoc);
/* Since namerefs can't be array variables, turn off nameref attribute */
VUNSETATTR (var, att_nameref);
return var;
}
@ -115,6 +124,12 @@ convert_var_to_assoc (var)
VSETATTR (var, att_assoc);
VUNSETATTR (var, att_invisible);
/* Make sure it's not marked as an indexed array any more */
VUNSETATTR (var, att_array);
/* Since namerefs can't be array variables, turn off nameref attribute */
VUNSETATTR (var, att_nameref);
return var;
}
@ -201,9 +216,18 @@ bind_array_variable (name, ind, value, flags)
entry = find_shell_variable (name);
if (entry == (SHELL_VAR *) 0)
{
/* Is NAME a nameref variable that points to an unset variable? */
entry = find_variable_nameref_for_create (name, 0);
if (entry == INVALID_NAMEREF_VALUE)
return ((SHELL_VAR *)0);
if (entry && nameref_p (entry))
entry = make_new_array_variable (nameref_cell (entry));
}
if (entry == (SHELL_VAR *) 0)
entry = make_new_array_variable (name);
else if (readonly_p (entry) || noassign_p (entry))
else if ((readonly_p (entry) && (flags&ASS_FORCE) == 0) || noassign_p (entry))
{
if (readonly_p (entry))
err_readonly (name);
@ -237,7 +261,7 @@ bind_assoc_variable (entry, name, key, value, flags)
SHELL_VAR *dentry;
char *newval;
if (readonly_p (entry) || noassign_p (entry))
if ((readonly_p (entry) && (flags&ASS_FORCE) == 0) || noassign_p (entry))
{
if (readonly_p (entry))
err_readonly (name);
@ -256,7 +280,7 @@ assign_array_element (name, value, flags)
{
char *sub, *vname;
int sublen;
SHELL_VAR *entry;
SHELL_VAR *entry, *nv;
vname = array_variable_name (name, &sub, &sublen);
@ -338,9 +362,21 @@ find_or_make_array_variable (name, flags)
{
/* See if we have a nameref pointing to a variable that hasn't been
created yet. */
var = find_variable_last_nameref (name);
var = find_variable_last_nameref (name, 1);
if (var && nameref_p (var) && invisible_p (var))
{
internal_warning (_("%s: removing nameref attribute"), name);
VUNSETATTR (var, att_nameref);
}
if (var && nameref_p (var))
var = (flags & 2) ? make_new_assoc_variable (nameref_cell (var)) : make_new_array_variable (nameref_cell (var));
{
if (valid_nameref_value (nameref_cell (var), 2) == 0)
{
sh_invalidid (nameref_cell (var));
return ((SHELL_VAR *)NULL);
}
var = (flags & 2) ? make_new_assoc_variable (nameref_cell (var)) : make_new_array_variable (nameref_cell (var));
}
}
if (var == 0)
@ -400,10 +436,7 @@ assign_array_var_from_word_list (var, list, flags)
i = (flags & ASS_APPEND) ? array_max_index (a) + 1 : 0;
for (l = list; l; l = l->next, i++)
if (var->assign_func)
(*var->assign_func) (var, l->word->word, i, 0);
else
array_insert (a, i, l->word->word);
bind_array_var_internal (var, i, 0, l->word->word, flags & ~ASS_APPEND);
VUNSETATTR (var, att_invisible); /* no longer invisible */
@ -476,7 +509,7 @@ assign_compound_array_list (var, nlist, flags)
ARRAY *a;
HASH_TABLE *h;
WORD_LIST *list;
char *w, *val, *nval;
char *w, *val, *nval, *savecmd;
int len, iflags, free_val;
arrayind_t ind, last_ind;
char *akey;
@ -501,7 +534,9 @@ assign_compound_array_list (var, nlist, flags)
for (list = nlist; list; list = list->next)
{
iflags = flags;
/* Don't allow var+=(values) to make assignments in VALUES append to
existing values by default. */
iflags = flags & ~ASS_APPEND;
w = list->word->word;
/* We have a word of the form [ind]=value */
@ -609,10 +644,12 @@ assign_compound_array_list (var, nlist, flags)
free_val = 1;
}
savecmd = this_command_name;
if (integer_p (var))
this_command_name = (char *)NULL; /* no command name for errors */
bind_array_var_internal (var, ind, akey, val, iflags);
last_ind++;
this_command_name = savecmd;
if (free_val)
free (val);
@ -732,7 +769,7 @@ unbind_array_element (var, sub)
char *akey;
ARRAY_ELEMENT *ae;
len = skipsubscript (sub, 0, 0);
len = skipsubscript (sub, 0, (var && assoc_p(var)));
if (sub[len] != ']' || len == 0)
{
builtin_error ("%s[%s: %s", var->name, sub, _(bash_badsub_errmsg));
@ -742,8 +779,13 @@ unbind_array_element (var, sub)
if (ALL_ELEMENT_SUB (sub[0]) && sub[1] == 0)
{
unbind_variable (var->name);
return (0);
if (array_p (var) || assoc_p (var))
{
unbind_variable (var->name); /* XXX -- {array,assoc}_flush ? */
return (0);
}
else
return -2; /* don't allow this to unset scalar variables */
}
if (assoc_p (var))
@ -758,7 +800,7 @@ unbind_array_element (var, sub)
assoc_remove (assoc_cell (var), akey);
free (akey);
}
else
else if (array_p (var))
{
ind = array_expand_index (var, sub, len+1);
/* negative subscripts to indexed arrays count back from end */
@ -773,6 +815,19 @@ unbind_array_element (var, sub)
if (ae)
array_dispose_element (ae);
}
else /* array_p (var) == 0 && assoc_p (var) == 0 */
{
akey = this_command_name;
ind = array_expand_index (var, sub, len+1);
this_command_name = akey;
if (ind == 0)
{
unbind_variable (var->name);
return (0);
}
else
return -2; /* any subscript other than 0 is invalid with scalar variables */
}
return 0;
}
@ -825,8 +880,9 @@ print_assoc_assignment (var, quoted)
/* Return 1 if NAME is a properly-formed array reference v[sub]. */
int
valid_array_reference (name)
char *name;
valid_array_reference (name, flags)
const char *name;
int flags;
{
char *t;
int r, len;
@ -843,6 +899,8 @@ valid_array_reference (name)
len = skipsubscript (t, 0, 0);
if (t[len] != ']' || len == 1)
return 0;
if (t[len+1] != '\0')
return 0;
for (r = 1; r < len; r++)
if (whitespace (t[r]) == 0)
return 1;
@ -858,22 +916,26 @@ array_expand_index (var, s, len)
char *s;
int len;
{
char *exp, *t;
char *exp, *t, *savecmd;
int expok;
arrayind_t val;
exp = (char *)xmalloc (len);
strncpy (exp, s, len - 1);
exp[len - 1] = '\0';
t = expand_arith_string (exp, 0);
t = expand_arith_string (exp, Q_DOUBLE_QUOTES|Q_ARITH|Q_ARRAYSUB); /* XXX - Q_ARRAYSUB for future use */
savecmd = this_command_name;
this_command_name = (char *)NULL;
val = evalexp (t, &expok);
this_command_name = savecmd;
free (t);
free (exp);
if (expok == 0)
{
last_command_exit_value = EXECUTION_FAILURE;
if (no_longjmp_on_fatal_error)
return 0;
top_level_cleanup ();
jump_to_top_level (DISCARD);
}
@ -886,7 +948,8 @@ array_expand_index (var, s, len)
in *LENP. This returns newly-allocated memory. */
char *
array_variable_name (s, subp, lenp)
char *s, **subp;
const char *s;
char **subp;
int *lenp;
{
char *t, *ret;
@ -930,7 +993,8 @@ array_variable_name (s, subp, lenp)
If LENP is non-null, the length of the subscript is returned in *LENP. */
SHELL_VAR *
array_variable_part (s, subp, lenp)
char *s, **subp;
const char *s;
char **subp;
int *lenp;
{
char *t;
@ -939,14 +1003,10 @@ array_variable_part (s, subp, lenp)
t = array_variable_name (s, subp, lenp);
if (t == 0)
return ((SHELL_VAR *)NULL);
var = find_variable (t);
var = find_variable (t); /* XXX - handle namerefs here? */
free (t);
#if 0
return (var == 0 || invisible_p (var)) ? (SHELL_VAR *)0 : var;
#else
return var; /* now return invisible variables; caller must handle */
#endif
}
#define INDEX_ERROR() \
@ -971,7 +1031,7 @@ array_variable_part (s, subp, lenp)
reference is name[@], and 0 otherwise. */
static char *
array_value_internal (s, quoted, flags, rtype, indp)
char *s;
const char *s;
int quoted, flags, *rtype;
arrayind_t *indp;
{
@ -1029,7 +1089,8 @@ array_value_internal (s, quoted, flags, rtype, indp)
free (temp);
}
else /* ${name[@]} or unquoted ${name[*]} */
retval = string_list_dollar_at (l, quoted); /* XXX - leak here */
/* XXX - bash-4.4/bash-5.0 test AV_ASSIGNRHS and pass PF_ASSIGNRHS */
retval = string_list_dollar_at (l, quoted, (flags & AV_ASSIGNRHS) ? PF_ASSIGNRHS : 0); /* XXX - leak here */
dispose_words (l);
}
@ -1091,7 +1152,7 @@ array_value_internal (s, quoted, flags, rtype, indp)
subscript contained in S, obeying quoting for subscripts * and @. */
char *
array_value (s, quoted, flags, rtype, indp)
char *s;
const char *s;
int quoted, flags, *rtype;
arrayind_t *indp;
{
@ -1104,7 +1165,7 @@ array_value (s, quoted, flags, rtype, indp)
evaluator in expr.c. */
char *
get_array_value (s, flags, rtype, indp)
char *s;
const char *s;
int flags, *rtype;
arrayind_t *indp;
{
@ -1146,7 +1207,7 @@ array_keys (s, quoted)
free (temp);
}
else /* ${!name[@]} or unquoted ${!name[*]} */
retval = string_list_dollar_at (l, quoted);
retval = string_list_dollar_at (l, quoted, 0);
dispose_words (l);
return retval;

View file

@ -29,6 +29,8 @@
#define AV_ALLOWALL 0x001
#define AV_QUOTED 0x002
#define AV_USEIND 0x004
#define AV_USEVAL 0x008 /* XXX - should move this */
#define AV_ASSIGNRHS 0x010 /* no splitting, special case ${a[@]} */
extern SHELL_VAR *convert_var_to_array __P((SHELL_VAR *));
extern SHELL_VAR *convert_var_to_assoc __P((SHELL_VAR *));
@ -57,20 +59,21 @@ extern void print_array_assignment __P((SHELL_VAR *, int));
extern void print_assoc_assignment __P((SHELL_VAR *, int));
extern arrayind_t array_expand_index __P((SHELL_VAR *, char *, int));
extern int valid_array_reference __P((char *));
extern char *array_value __P((char *, int, int, int *, arrayind_t *));
extern char *get_array_value __P((char *, int, int *, arrayind_t *));
extern int valid_array_reference __P((const char *, int));
extern char *array_value __P((const char *, int, int, int *, arrayind_t *));
extern char *get_array_value __P((const char *, int, int *, arrayind_t *));
extern char *array_keys __P((char *, int));
extern char *array_variable_name __P((char *, char **, int *));
extern SHELL_VAR *array_variable_part __P((char *, char **, int *));
extern char *array_variable_name __P((const char *, char **, int *));
extern SHELL_VAR *array_variable_part __P((const char *, char **, int *));
#else
#define AV_ALLOWALL 0
#define AV_QUOTED 0
#define AV_USEIND 0
#define AV_ASSIGNRHS 0
#endif

19
assoc.c
View file

@ -277,7 +277,10 @@ int starsub, quoted;
for (i = 1; l && i < start; i++)
l = l->next;
if (l == 0)
return ((char *)NULL);
{
dispose_words (save);
return ((char *)NULL);
}
for (j = 0,h = t = l; l && j < nelem; j++)
{
t = l;
@ -433,17 +436,19 @@ assoc_to_assign (hash, quoted)
for (i = 0; i < hash->nbuckets; i++)
for (tlist = hash_items (i, hash); tlist; tlist = tlist->next)
{
#if 1
if (sh_contains_shell_metas (tlist->key))
if (ansic_shouldquote (tlist->key))
istr = ansic_quote (tlist->key, 0, (int *)0);
else if (sh_contains_shell_metas (tlist->key))
istr = sh_double_quote (tlist->key);
else if (ALL_ELEMENT_SUB (tlist->key[0]) && tlist->key[1] == '\0')
istr = sh_double_quote (tlist->key);
else
istr = tlist->key;
#else
istr = tlist->key;
#endif
vstr = tlist->data ? sh_double_quote ((char *)tlist->data) : (char *)0;
vstr = tlist->data ? (ansic_shouldquote ((char *)tlist->data) ?
ansic_quote ((char *)tlist->data, 0, (int *)0) :
sh_double_quote ((char *)tlist->data))
: (char *)0;
elen = STRLEN (istr) + 8 + STRLEN (vstr);
RESIZE_MALLOCED_BUFFER (ret, rlen, (elen+1), rsize, rsize);

View file

@ -1,6 +1,6 @@
/* bashhist.c -- bash interface to the GNU history library. */
/* Copyright (C) 1993-2012 Free Software Foundation, Inc.
/* Copyright (C) 1993-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -83,8 +83,8 @@ static struct ignorevar histignore =
/* Non-zero means to remember lines typed to the shell on the history
list. This is different than the user-controlled behaviour; this
becomes zero when we read lines from a file, for example. */
int remember_on_history = 1;
int enable_history_list = 1; /* value for `set -o history' */
int remember_on_history = 0;
int enable_history_list = 0; /* value for `set -o history' */
/* The number of lines that Bash has added to this history session. The
difference between the number of the top element in the history list
@ -99,6 +99,8 @@ int history_lines_in_file;
/* Non-zero means do no history expansion on this line, regardless
of what history_expansion says. */
int history_expansion_inhibited;
/* If non-zero, double quotes can quote the history expansion character. */
int double_quotes_inhibit_history_expansion = 0;
#endif
/* With the old default, every line was saved in the history individually.
@ -186,7 +188,9 @@ extern int current_command_line_count;
extern struct dstack dstack;
extern int parser_state;
#if defined (BANG_HISTORY)
static int bash_history_inhibit_expansion __P((char *, int));
#endif
#if defined (READLINE)
static void re_edit __P((char *));
#endif
@ -197,6 +201,7 @@ static HIST_ENTRY *last_history_entry __P((void));
static char *expand_histignore_pattern __P((char *));
static int history_should_ignore __P((char *));
#if defined (BANG_HISTORY)
/* Is the history expansion starting at string[i] one that should not
be expanded? */
static int
@ -204,6 +209,12 @@ bash_history_inhibit_expansion (string, i)
char *string;
int i;
{
int t;
char hx[2];
hx[0] = history_expansion_char;
hx[1] = '\0';
/* The shell uses ! as a pattern negation character in globbing [...]
expressions, so let those pass without expansion. */
if (i > 0 && (string[i - 1] == '[') && member (']', string + i + 1))
@ -220,17 +231,33 @@ bash_history_inhibit_expansion (string, i)
else if (extended_glob && i > 1 && string[i+1] == '(' && member (')', string + i + 2))
return (1);
#endif
/* Make sure the history expansion should not be skipped by quoting or
command/process substitution. */
else if ((t = skip_to_histexp (string, 0, hx, SD_NOJMP|SD_HISTEXP)) > 0)
{
/* Skip instances of history expansion appearing on the line before
this one. */
while (t < i)
{
t = skip_to_histexp (string, t+1, hx, SD_NOJMP|SD_HISTEXP);
if (t <= 0)
return 0;
}
return (t > i);
}
else
return (0);
}
#endif
void
bash_initialize_history ()
{
history_quotes_inhibit_expansion = 1;
history_search_delimiter_chars = ";&()|<>";
history_inhibit_expansion_function = bash_history_inhibit_expansion;
#if defined (BANG_HISTORY)
history_inhibit_expansion_function = bash_history_inhibit_expansion;
sv_histchars ("histchars");
#endif
}
@ -241,10 +268,10 @@ bash_history_reinit (interact)
{
#if defined (BANG_HISTORY)
history_expansion = interact != 0;
history_expansion_inhibited = 1;
#endif
remember_on_history = enable_history_list = interact != 0;
history_expansion_inhibited = 1; /* XXX */
history_inhibit_expansion_function = bash_history_inhibit_expansion;
#endif
remember_on_history = enable_history_list;
}
void
@ -259,11 +286,11 @@ bash_history_disable ()
void
bash_history_enable ()
{
remember_on_history = 1;
remember_on_history = enable_history_list = 1;
#if defined (BANG_HISTORY)
history_expansion_inhibited = 0;
#endif
history_inhibit_expansion_function = bash_history_inhibit_expansion;
#endif
sv_history_control ("HISTCONTROL");
sv_histignore ("HISTIGNORE");
}
@ -290,8 +317,13 @@ load_history ()
if (hf && *hf && file_exists (hf))
{
read_history (hf);
/* We have read all of the lines from the history file, even if we
read more lines than $HISTSIZE. Remember the total number of lines
we read so we don't count the last N lines as new over and over
again. */
history_lines_in_file = history_lines_read_from_file;
using_history ();
history_lines_in_file = where_history ();
/* history_lines_in_file = where_history () + history_base - 1; */
}
}
@ -300,6 +332,7 @@ bash_clear_history ()
{
clear_history ();
history_lines_this_session = 0;
/* XXX - reset history_lines_read_from_file? */
}
/* Delete and free the history list entry at offset I. */
@ -377,7 +410,7 @@ maybe_append_history (filename)
struct stat buf;
result = EXECUTION_SUCCESS;
if (history_lines_this_session && (history_lines_this_session <= where_history ()))
if (history_lines_this_session > 0 && (history_lines_this_session <= where_history ()))
{
/* If the filename was supplied, then create it if necessary. */
if (stat (filename, &buf) == -1 && errno == ENOENT)
@ -391,9 +424,14 @@ maybe_append_history (filename)
close (fd);
}
result = append_history (history_lines_this_session, filename);
/* Pretend we already read these lines from the file because we just
added them */
history_lines_in_file += history_lines_this_session;
history_lines_this_session = 0;
}
else
history_lines_this_session = 0; /* reset if > where_history() */
return (result);
}
@ -406,7 +444,7 @@ maybe_save_shell_history ()
char *hf;
result = 0;
if (history_lines_this_session)
if (history_lines_this_session > 0)
{
hf = get_string_value ("HISTFILE");
@ -433,7 +471,8 @@ maybe_save_shell_history ()
else
{
result = write_history (hf);
history_lines_in_file = history_lines_this_session;
history_lines_in_file = history_lines_written_to_file;
/* history_lines_in_file = where_history () + history_base - 1; */
}
history_lines_this_session = 0;
@ -532,6 +571,7 @@ pre_process_line (line, print_changes, addit)
if (hist_verify && expanded == 1)
{
re_edit (history_value);
free (history_value);
return ((char *)NULL);
}
# endif
@ -634,7 +674,9 @@ hc_erasedups (line)
if (STREQ (temp->line, line))
{
r = where_history ();
remove_history (r);
temp = remove_history (r);
if (temp)
free_history_entry (temp);
}
}
using_history ();
@ -706,11 +748,24 @@ check_add_history (line, force)
#if defined (SYSLOG_HISTORY)
#define SYSLOG_MAXLEN 600
extern char *shell_name;
#ifndef OPENLOG_OPTS
#define OPENLOG_OPTS 0
#endif
void
bash_syslog_history (line)
const char *line;
{
char trunc[SYSLOG_MAXLEN];
static int first = 1;
if (first)
{
openlog (shell_name, OPENLOG_OPTS, SYSLOG_FACILITY);
first = 0;
}
if (strlen(line) < SYSLOG_MAXLEN)
syslog (SYSLOG_FACILITY|SYSLOG_LEVEL, "HISTORY: PID=%d UID=%d %s", getpid(), current_user.uid, line);

View file

@ -27,7 +27,9 @@ extern procenv_t top_level;
extern procenv_t subshell_top_level;
extern procenv_t return_catch; /* used by `return' builtin */
#define SHFUNC_RETURN() longjmp (return_catch, 1)
extern int no_longjmp_on_fatal_error;
#define SHFUNC_RETURN() sh_longjmp (return_catch, 1)
#define COPY_PROCENV(old, save) \
xbcopy ((char *)old, (char *)save, sizeof (procenv_t));

View file

@ -1,6 +1,6 @@
/* bashline.c -- Bash's interface to the readline library. */
/* Copyright (C) 1987-2013 Free Software Foundation, Inc.
/* Copyright (C) 1987-2016 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -54,6 +54,11 @@
#include "pathexp.h"
#include "shmbutil.h"
#include "trap.h"
#include "flags.h"
#if defined (HAVE_MBSTR_H) && defined (HAVE_MBSCHR)
# include <mbstr.h> /* mbschr */
#endif
#include "builtins/common.h"
@ -137,6 +142,8 @@ static int executable_completion __P((const char *, int));
static rl_icppfunc_t *save_directory_hook __P((void));
static void restore_directory_hook __P((rl_icppfunc_t));
static int directory_exists __P((const char *));
static void cleanup_expansion_error __P((void));
static void maybe_make_readline_line __P((char *));
static void set_up_new_line __P((char *));
@ -631,6 +638,8 @@ bashline_reset ()
rl_filename_stat_hook = bash_filename_stat_hook;
bashline_reset_event_hook ();
rl_sort_completion_matches = 1;
}
/* Contains the line to push into readline. */
@ -972,9 +981,6 @@ edit_and_execute_command (count, c, editing_mode, edit_command)
metaval = rl_variable_value ("input-meta");
metaflag = RL_BOOLEAN_VARIABLE_VALUE (metaval);
/* Now, POSIX.1-2001 and SUSv3 say that the commands executed from the
temporary file should be placed into the history. We don't do that
yet. */
if (rl_deprep_term_function)
(*rl_deprep_term_function) ();
save_parser_state (&ps);
@ -1273,7 +1279,7 @@ check_redir (ti)
/* Handle the two character tokens `>&', `<&', and `>|'.
We are not in a command position after one of these. */
this_char = rl_line_buffer[ti];
prev_char = rl_line_buffer[ti - 1];
prev_char = (ti > 0) ? rl_line_buffer[ti - 1] : 0;
if ((this_char == '&' && (prev_char == '<' || prev_char == '>')) ||
(this_char == '|' && prev_char == '>'))
@ -1305,15 +1311,26 @@ static int
find_cmd_start (start)
int start;
{
register int s, os;
register int s, os, ns;
os = 0;
/* Flags == SD_NOJMP only because we want to skip over command substitutions
in assignment statements. Have to test whether this affects `standalone'
command substitutions as individual words. */
while (((s = skip_to_delim (rl_line_buffer, os, COMMAND_SEPARATORS, SD_NOJMP/*|SD_NOSKIPCMD*/)) <= start) &&
while (((s = skip_to_delim (rl_line_buffer, os, COMMAND_SEPARATORS, SD_NOJMP|SD_COMPLETE/*|SD_NOSKIPCMD*/)) <= start) &&
rl_line_buffer[s])
os = s+1;
{
/* Handle >| token crudely; treat as > not | */
if (rl_line_buffer[s] == '|' && rl_line_buffer[s-1] == '>')
{
ns = skip_to_delim (rl_line_buffer, s+1, COMMAND_SEPARATORS, SD_NOJMP|SD_COMPLETE/*|SD_NOSKIPCMD*/);
if (ns > start || rl_line_buffer[ns] == 0)
return os;
os = ns+1;
continue;
}
os = s+1;
}
return os;
}
@ -1323,7 +1340,7 @@ find_cmd_end (end)
{
register int e;
e = skip_to_delim (rl_line_buffer, end, COMMAND_SEPARATORS, SD_NOJMP);
e = skip_to_delim (rl_line_buffer, end, COMMAND_SEPARATORS, SD_NOJMP|SD_COMPLETE);
return e;
}
@ -1339,7 +1356,7 @@ find_cmd_name (start, sp, ep)
;
/* skip until a shell break character */
e = skip_to_delim (rl_line_buffer, s, "()<>;&| \t\n", SD_NOJMP);
e = skip_to_delim (rl_line_buffer, s, "()<>;&| \t\n", SD_NOJMP|SD_COMPLETE);
name = substring (rl_line_buffer, s, e);
@ -1368,6 +1385,34 @@ prog_complete_return (text, matchnum)
#endif /* PROGRAMMABLE_COMPLETION */
/* Try and catch completion attempts that are syntax errors or otherwise
invalid. */
static int
invalid_completion (text, ind)
const char *text;
int ind;
{
int pind;
/* If we don't catch these here, the next clause will */
if (ind > 0 && rl_line_buffer[ind] == '(' && /*)*/
member (rl_line_buffer[ind-1], "$<>"))
return 0;
pind = ind - 1;
while (pind > 0 && whitespace (rl_line_buffer[pind]))
pind--;
/* If we have only whitespace preceding a paren, it's valid */
if (ind >= 0 && pind <= 0 && rl_line_buffer[ind] == '(') /*)*/
return 0;
/* Flag the invalid completions, which are mostly syntax errors */
if (ind > 0 && rl_line_buffer[ind] == '(' && /*)*/
member (rl_line_buffer[pind], COMMAND_SEPARATORS) == 0)
return 1;
return 0;
}
/* Do some completion on TEXT. The indices of TEXT in RL_LINE_BUFFER are
at START and END. Return an array of matches, or NULL if none. */
static char **
@ -1390,6 +1435,8 @@ attempt_shell_completion (text, start, end)
set_directory_hook ();
rl_filename_stat_hook = bash_filename_stat_hook;
rl_sort_completion_matches = 1; /* sort by default */
/* Determine if this could be a command word. It is if it appears at
the start of the line (ignoring preceding whitespace), or if it
appears after a character that separates commands. It cannot be a
@ -1436,6 +1483,12 @@ attempt_shell_completion (text, start, end)
assignments. */
}
if (in_command_position && invalid_completion (text, ti))
{
rl_attempted_completion_over = 1;
return ((char **)NULL);
}
/* Check that we haven't incorrectly flagged a closed command substitution
as indicating we're in a command position. */
if (in_command_position && ti >= 0 && rl_line_buffer[ti] == '`' &&
@ -1525,6 +1578,13 @@ attempt_shell_completion (text, start, end)
/* command completion if programmable completion fails */
in_command_position = s == start && STREQ (n, text); /* XXX */
}
/* empty command name following command separator */
else if (s >= e && n[0] == '\0' && text[0] == '\0' && start > 0 &&
was_assignment == 0 && member (rl_line_buffer[start-1], COMMAND_SEPARATORS))
{
foundcs = 0;
in_command_position = 1;
}
else if (s >= e && n[0] == '\0' && text[0] == '\0' && start > 0)
{
foundcs = 0; /* empty command name following assignments */
@ -1586,6 +1646,11 @@ bash_default_completion (text, start, end, qc, compflags)
else
{
matches = rl_completion_matches (text, variable_completion_function);
/* If a single match, see if it expands to a directory name and append
a slash if it does. This requires us to expand the variable name,
so we don't want to display errors if the variable is unset. This
can happen with dynamic variables whose value has never been
requested. */
if (matches && matches[0] && matches[1] == 0)
{
t = savestring (matches[0]);
@ -1780,7 +1845,9 @@ command_word_completion_function (hint_text, state)
if (globpat || absolute_program (hint_text))
{
/* Perform tilde expansion on what's passed, so we don't end up
passing filenames with tildes directly to stat(). */
passing filenames with tildes directly to stat(). The rest of
the shell doesn't do variable expansion on the word following
the tilde, so we don't do it here even if direxpand is set. */
if (*hint_text == '~')
{
hint = bash_tilde_expand (hint_text, 0);
@ -1794,6 +1861,11 @@ command_word_completion_function (hint_text, state)
directory_part = (char *)NULL;
}
}
else if (dircomplete_expand)
{
hint = savestring (hint_text);
bash_directory_completion_hook (&hint);
}
else
hint = savestring (hint_text);
@ -3030,6 +3102,30 @@ restore_directory_hook (hookf)
rl_directory_rewrite_hook = hookf;
}
/* Check whether not the (dequoted) version of DIRNAME, with any trailing slash
removed, exists. */
static int
directory_exists (dirname)
const char *dirname;
{
char *new_dirname;
int dirlen, r;
struct stat sb;
/* First, dequote the directory name */
new_dirname = bash_dequote_filename ((char *)dirname, rl_completion_quote_character);
dirlen = STRLEN (new_dirname);
if (new_dirname[dirlen - 1] == '/')
new_dirname[dirlen - 1] = '\0';
#if defined (HAVE_LSTAT)
r = lstat (new_dirname, &sb) == 0;
#else
r = stat (new_dirname, &sb) == 0;
#endif
free (new_dirname);
return (r);
}
/* Expand a filename before the readline completion code passes it to stat(2).
The filename will already have had tilde expansion performed. */
static int
@ -3038,6 +3134,7 @@ bash_filename_stat_hook (dirname)
{
char *local_dirname, *new_dirname, *t;
int should_expand_dirname, return_value;
int global_nounset;
WORD_LIST *wl;
struct stat sb;
@ -3048,17 +3145,18 @@ bash_filename_stat_hook (dirname)
else if (t = mbschr (local_dirname, '`')) /* XXX */
should_expand_dirname = '`';
#if defined (HAVE_LSTAT)
if (should_expand_dirname && lstat (local_dirname, &sb) == 0)
#else
if (should_expand_dirname && stat (local_dirname, &sb) == 0)
#endif
if (should_expand_dirname && directory_exists (local_dirname))
should_expand_dirname = 0;
if (should_expand_dirname)
{
new_dirname = savestring (local_dirname);
wl = expand_prompt_string (new_dirname, 0, W_NOCOMSUB); /* does the right thing */
/* no error messages, and expand_prompt_string doesn't longjmp so we don't
have to worry about restoring this setting. */
global_nounset = unbound_vars_is_error;
unbound_vars_is_error = 0;
wl = expand_prompt_string (new_dirname, 0, W_NOCOMSUB|W_COMPLETE); /* does the right thing */
unbound_vars_is_error = global_nounset;
if (wl)
{
free (new_dirname);
@ -3116,7 +3214,8 @@ bash_directory_completion_hook (dirname)
char **dirname;
{
char *local_dirname, *new_dirname, *t;
int return_value, should_expand_dirname, nextch, closer;
int return_value, should_expand_dirname, nextch, closer, changed;
size_t local_dirlen;
WORD_LIST *wl;
struct stat sb;
@ -3145,17 +3244,13 @@ bash_directory_completion_hook (dirname)
should_expand_dirname = '`';
}
#if defined (HAVE_LSTAT)
if (should_expand_dirname && lstat (local_dirname, &sb) == 0)
#else
if (should_expand_dirname && stat (local_dirname, &sb) == 0)
#endif
if (should_expand_dirname && directory_exists (local_dirname))
should_expand_dirname = 0;
if (should_expand_dirname)
{
new_dirname = savestring (local_dirname);
wl = expand_prompt_string (new_dirname, 0, W_NOCOMSUB); /* does the right thing */
wl = expand_prompt_string (new_dirname, 0, W_NOCOMSUB|W_COMPLETE); /* does the right thing */
if (wl)
{
*dirname = string_list (wl);
@ -4001,8 +4096,12 @@ bash_execute_unix_command (count, key)
ce = rl_get_termcap ("ce");
if (ce) /* clear current line */
{
#if 0
fprintf (rl_outstream, "\r");
tputs (ce, 1, putx);
#else
rl_clear_visible_line ();
#endif
fflush (rl_outstream);
}
else
@ -4040,12 +4139,19 @@ bash_execute_unix_command (count, key)
}
}
unbind_variable ("READLINE_LINE");
unbind_variable ("READLINE_POINT");
check_unbind_variable ("READLINE_LINE");
check_unbind_variable ("READLINE_POINT");
array_needs_making = 1;
/* and restore the readline buffer and display after command execution. */
rl_forced_update_display ();
/* If we clear the last line of the prompt above, redraw only that last
line. If the command returns 124, we redraw unconditionally as in
previous versions. */
if (ce && r != 124)
rl_redraw_prompt_last_line ();
else
rl_forced_update_display ();
return 0;
}

View file

@ -38,6 +38,12 @@
#if defined (SHELL)
# include "shell.h"
#else
# if defined (TEST)
typedef char *WORD_DESC;
typedef char **WORD_LIST;
#define _(X) X
# endif /* TEST */
#endif /* SHELL */
#include "typemax.h" /* INTMAX_MIN, INTMAX_MAX */
@ -287,7 +293,9 @@ expand_amble (text, tlen, flags)
char *tem;
int start, i, c;
#if defined (SHELL)
DECLARE_MBSTATE;
#endif
result = (char **)NULL;
@ -301,7 +309,7 @@ expand_amble (text, tlen, flags)
#else
tem = (char *)xmalloc (1 + (i - start));
strncpy (tem, &text[start], (i - start));
tem[i- start] = '\0';
tem[i - start] = '\0';
#endif
partial = brace_expand (tem);
@ -319,6 +327,8 @@ expand_amble (text, tlen, flags)
if (tresult == 0)
{
internal_error (_("brace expansion: cannot allocate memory for %s"), tem);
free (tem);
strvec_dispose (partial);
strvec_dispose (result);
result = (char **)NULL;
return result;
@ -333,7 +343,11 @@ expand_amble (text, tlen, flags)
free (partial);
}
free (tem);
#if defined (SHELL)
ADVANCE_CHAR (text, tlen, i);
#else
i++;
#endif
start = i;
}
return (result);
@ -420,7 +434,12 @@ mkseq (start, end, incr, type, width)
do
{
#if defined (SHELL)
QUIT; /* XXX - memory leak here */
if (ISINTERRUPT)
{
strvec_dispose (result);
result = (char **)NULL;
}
QUIT;
#endif
if (type == ST_INT)
result[i++] = t = itos (n);
@ -618,7 +637,11 @@ brace_gobbler (text, tlen, indx, satisfy)
if (pass_next)
{
pass_next = 0;
#if defined (SHELL)
ADVANCE_CHAR (text, tlen, i);
#else
i++;
#endif
continue;
}
@ -652,7 +675,11 @@ brace_gobbler (text, tlen, indx, satisfy)
if (quoted == '"' && c == '$' && text[i+1] == '(') /*)*/
goto comsub;
#endif
#if defined (SHELL)
ADVANCE_CHAR (text, tlen, i);
#else
i++;
#endif
continue;
}
@ -705,7 +732,11 @@ comsub:
commas++;
#endif
#if defined (SHELL)
ADVANCE_CHAR (text, tlen, i);
#else
i++;
#endif
}
*indx = i;
@ -784,20 +815,29 @@ array_concat (arr1, arr2)
#if defined (TEST)
#include <stdio.h>
fatal_error (format, arg1, arg2)
char *format, *arg1, *arg2;
void *
xmalloc(n)
size_t n;
{
report_error (format, arg1, arg2);
exit (1);
return (malloc (n));
}
report_error (format, arg1, arg2)
void *
xrealloc(p, n)
void *p;
size_t n;
{
return (realloc (p, n));
}
int
internal_error (format, arg1, arg2)
char *format, *arg1, *arg2;
{
fprintf (stderr, format, arg1, arg2);
fprintf (stderr, "\n");
}
main ()
{
char example[256];
@ -821,7 +861,7 @@ main ()
for (i = 0; result[i]; i++)
printf ("%s\n", result[i]);
free_array (result);
strvec_dispose (result);
}
}

View file

@ -41,6 +41,7 @@
#define SPECIAL_BUILTIN 0x08 /* This is a Posix `special' builtin. */
#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 BASE_INDENT 4

View file

@ -1,6 +1,6 @@
# This Makefile for building libbuiltins.a is in -*- text -*- for Emacs.
#
# Copyright (C) 1996-2009 Free Software Foundation, Inc.
# Copyright (C) 1996-2015 Free Software Foundation, Inc.
# 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
@ -36,7 +36,7 @@ EXEEXT = @EXEEXT@
prefix = @prefix@
srcdir = @srcdir@
VPATH = .:@srcdir@
VPATH = @srcdir@
topdir = @top_srcdir@
datarootdir = @datarootdir@
@ -45,6 +45,8 @@ includedir = @includedir@
datadir = @datadir@
localedir = @localedir@
loadablesdir = @loadablesdir@
# Support an alternate destination root directory for package building
DESTDIR =
@ -375,31 +377,31 @@ mkbuiltins.o: $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h
# def files
alias.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
alias.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h $(BASHINCDIR)/maxpath.h
alias.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
alias.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
alias.o: $(topdir)/subst.h $(topdir)/externs.h $(srcdir)/common.h
alias.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
alias.o: ../pathnames.h
bind.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
bind.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
bind.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
bind.o: $(topdir)/subst.h $(topdir)/externs.h $(srcdir)/bashgetopt.h
bind.o: $(topdir)/general.h $(topdir)/xmalloc.h $(BASHINCDIR)/maxpath.h $(topdir)/bashline.h
bind.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
bind.o: ../pathnames.h
break.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
break.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
break.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
break.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
break.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
break.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
break.o: ../pathnames.h
builtin.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
builtin.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/externs.h
builtin.o: $(topdir)/quit.h $(srcdir)/common.h $(BASHINCDIR)/maxpath.h
builtin.o: $(topdir)/quit.h $(srcdir)/common.h $(BASHINCDIR)/maxpath.h $(topdir)/sig.h
builtin.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
builtin.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
builtin.o: $(srcdir)/bashgetopt.h ../pathnames.h
caller.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
caller.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/quit.h $(topdir)/dispose_cmd.h
caller.o: $(topdir)/make_cmd.h $(topdir)/subst.h $(topdir)/externs.h
caller.o: $(topdir)/make_cmd.h $(topdir)/subst.h $(topdir)/externs.h $(topdir)/sig.h
caller.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
caller.o: $(srcdir)/common.h $(BASHINCDIR)/maxpath.h ./builtext.h
caller.o: ${BASHINCDIR}/chartypes.h $(topdir)/bashtypes.h ../pathnames.h
@ -408,41 +410,43 @@ cd.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/quit.h $(topdir)/dispose
cd.o: $(topdir)/make_cmd.h $(topdir)/subst.h $(topdir)/externs.h
cd.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
cd.o: $(srcdir)/common.h $(BASHINCDIR)/maxpath.h ../pathnames.h
cd.o: $(topdir)/sig.h
command.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
command.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/externs.h
command.o: $(topdir)/quit.h $(srcdir)/bashgetopt.h $(BASHINCDIR)/maxpath.h
command.o: $(topdir)/sig.h
command.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
command.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
command.o: ../pathnames.h
declare.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
declare.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
declare.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
declare.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
declare.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
declare.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
declare.o: $(topdir)/arrayfunc.h $(srcdir)/bashgetopt.h
declare.o: $(topdir)/arrayfunc.h $(srcdir)/bashgetopt.h $(topdir)/flags.h
declare.o: ./builtext.h ../pathnames.h
echo.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
echo.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/subst.h $(topdir)/externs.h
echo.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
echo.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
echo.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
echo.o: $(BASHINCDIR)/maxpath.h ../pathnames.h
enable.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
enable.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
enable.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
enable.o: $(topdir)/subst.h $(topdir)/externs.h
enable.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/sig.h
enable.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
enable.o: $(BASHINCDIR)/maxpath.h ../pathnames.h
enable.o: $(topdir)/pcomplete.h
eval.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
eval.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
eval.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
eval.o: $(topdir)/subst.h $(topdir)/externs.h
eval.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/sig.h
eval.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
eval.o: $(BASHINCDIR)/maxpath.h ../pathnames.h
exec.o: $(topdir)/bashtypes.h
exec.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
exec.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
exec.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
exec.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
exec.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/flags.h
exec.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
exec.o: $(srcdir)/common.h $(topdir)/execute_cmd.h $(BASHINCDIR)/maxpath.h
@ -450,7 +454,7 @@ exec.o: $(topdir)/findcmd.h $(topdir)/jobs.h ../pathnames.h
exit.o: $(topdir)/bashtypes.h
exit.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
exit.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
exit.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
exit.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
exit.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/jobs.h
exit.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
exit.o: $(BASHINCDIR)/maxpath.h ./builtext.h ../pathnames.h
@ -459,7 +463,7 @@ fc.o: $(topdir)/builtins.h $(topdir)/command.h $(srcdir)/bashgetopt.h
fc.o: $(topdir)/bashhist.h
fc.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
fc.o: $(topdir)/general.h $(topdir)/xmalloc.h $(BASHINCDIR)/maxpath.h
fc.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
fc.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
fc.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/shell.h $(topdir)/syntax.h
fc.o: $(topdir)/flags.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
fc.o: $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h $(BASHINCDIR)/chartypes.h
@ -467,18 +471,18 @@ fc.o: ../pathnames.h
fg_bg.o: $(topdir)/bashtypes.h $(srcdir)/bashgetopt.h
fg_bg.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
fg_bg.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
fg_bg.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
fg_bg.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
fg_bg.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
fg_bg.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
fg_bg.o: $(topdir)/jobs.h ../pathnames.h
getopts.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
getopts.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
getopts.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
getopts.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
getopts.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
getopts.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
getopts.o: ../pathnames.h
hash.o: $(topdir)/builtins.h $(topdir)/command.h $(topdir)/quit.h
hash.o: $(topdir)/findcmd.h $(topdir)/hashlib.h
hash.o: $(topdir)/findcmd.h $(topdir)/hashlib.h $(topdir)/sig.h
hash.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
hash.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
hash.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
@ -488,12 +492,12 @@ help.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
help.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
help.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
help.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
help.o: ${srcdir}/common.h ../pathnames.h
help.o: ${srcdir}/common.h $(topdir)/sig.h ../pathnames.h
history.o: $(topdir)/bashtypes.h
history.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
history.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
history.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
history.o: $(topdir)/subst.h $(topdir)/externs.h
history.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/sig.h
history.o: ${BASHINCDIR}/filecntl.h $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h
history.o: $(topdir)/variables.h $(topdir)/conftypes.h $(topdir)/bashhist.h $(BASHINCDIR)/maxpath.h
history.o: ../pathnames.h
@ -507,16 +511,16 @@ jobs.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/quit.h $(srcdir)/bashg
jobs.o: $(BASHINCDIR)/maxpath.h $(topdir)/externs.h $(topdir)/jobs.h
jobs.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
jobs.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
jobs.o: ../pathnames.h
jobs.o: $(topdir)/sig.h ../pathnames.h
kill.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
kill.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/subst.h $(topdir)/externs.h
kill.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
kill.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
kill.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/trap.h $(topdir)/unwind_prot.h
kill.o: $(topdir)/variables.h $(topdir)/conftypes.h $(BASHINCDIR)/maxpath.h
kill.o: $(topdir)/jobs.h ../pathnames.h
let.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
let.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
let.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
let.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
let.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
let.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
let.o: ../pathnames.h
@ -527,11 +531,12 @@ printf.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/sig.h
printf.o: ../pathnames.h $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h
printf.o: $(topdir)/variables.h $(topdir)/conftypes.h $(BASHINCDIR)/stdc.h $(srcdir)/bashgetopt.h
printf.o: $(topdir)/bashtypes.h ${srcdir}/common.h $(BASHINCDIR)/chartypes.h
printf.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
printf.o: ../pathnames.h
pushd.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
pushd.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
pushd.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
pushd.o: $(topdir)/subst.h $(topdir)/externs.h
pushd.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/sig.h
pushd.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
pushd.o: $(BASHINCDIR)/maxpath.h $(srcdir)/common.h ./builtext.h
pushd.o: ../pathnames.h
@ -540,11 +545,12 @@ read.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
read.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
read.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
read.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
read.o: $(BASHINCDIR)/shtty.h
read.o: $(BASHINCDIR)/shtty.h $(topdir)/sig.h
read.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
read.o: $(topdir)/arrayfunc.h ../pathnames.h
return.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
return.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
return.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
return.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
return.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
return.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
return.o: ../pathnames.h
@ -552,18 +558,18 @@ set.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
set.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/subst.h $(topdir)/externs.h
set.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
set.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
set.o: $(BASHINCDIR)/maxpath.h $(topdir)/error.h
set.o: $(BASHINCDIR)/maxpath.h $(topdir)/error.h $(topdir)/sig.h
set.o: $(topdir)/arrayfunc.h ../pathnames.h
setattr.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
setattr.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h $(BASHINCDIR)/maxpath.h
setattr.o: $(topdir)/quit.h $(srcdir)/common.h $(srcdir)/bashgetopt.h
setattr.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
setattr.o: $(topdir)/externs.h
setattr.o: $(topdir)/externs.h $(topdir)/flags.h $(topdir)/sig.h
setattr.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
setattr.o: $(topdir)/arrayfunc.h ../pathnames.h
shift.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
shift.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
shift.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
shift.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
shift.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
shift.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
shift.o: ../pathnames.h
@ -573,53 +579,53 @@ shopt.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
shopt.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
shopt.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
shopt.o: $(srcdir)/common.h $(srcdir)/bashgetopt.h ../pathnames.h
shopt.o: $(topdir)/bashhist.h $(topdir)/bashline.h
shopt.o: $(topdir)/bashhist.h $(topdir)/bashline.h $(topdir)/sig.h
source.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
source.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/findcmd.h
source.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
source.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
source.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
source.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
source.o: $(srcdir)/bashgetopt.h $(topdir)/flags.h $(topdir)/trap.h
source.o: ../pathnames.h
suspend.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
suspend.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
suspend.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
suspend.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
suspend.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
suspend.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
suspend.o: $(topdir)/jobs.h ../pathnames.h
test.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
test.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
test.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
test.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
test.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
test.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
test.o: $(topdir)/test.h ../pathnames.h
times.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
times.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
times.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
times.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
times.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
times.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
times.o: $(BASHINCDIR)/posixtime.h ../pathnames.h
trap.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
trap.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/externs.h
trap.o: $(topdir)/quit.h $(srcdir)/common.h $(BASHINCDIR)/maxpath.h
trap.o: $(topdir)/quit.h $(srcdir)/common.h $(BASHINCDIR)/maxpath.h $(topdir)/sig.h
trap.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
trap.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
trap.o: $(topdir)/findcmd.h ../pathnames.h
type.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
type.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
type.o: $(topdir)/quit.h $(srcdir)/common.h $(BASHINCDIR)/maxpath.h
type.o: $(topdir)/quit.h $(srcdir)/common.h $(BASHINCDIR)/maxpath.h $(topdir)/sig.h
type.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
type.o: $(topdir)/externs.h $(topdir)/hashcmd.h ../pathnames.h
type.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
ulimit.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
ulimit.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
ulimit.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
ulimit.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
ulimit.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
ulimit.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
ulimit.o: ../pathnames.h
umask.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
umask.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
umask.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
umask.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
umask.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
umask.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
umask.o: $(BASHINCDIR)/chartypes.h ../pathnames.h
@ -628,19 +634,21 @@ wait.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
wait.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
wait.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
wait.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
wait.o: $(topdir)/jobs.h
wait.o: $(topdir)/jobs.h $(topdir)/sig.h
wait.o: $(BASHINCDIR)/chartypes.h ../pathnames.h
complete.o: ../config.h ../pathnames.h
complete.o: ${topdir}/shell.h $(topdir)/syntax.h ${topdir}/bashjmp.h ${BASHINCDIR}/posixjmp.h ${topdir}/sig.h
complete.o: ${topdir}/unwind_prot.h ${topdir}/variables.h
complete.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
complete.o: ${topdir}/bashtypes.h ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
complete.o: ${topdir}/builtins.h
complete.o: ${topdir}/builtins.h ${topdir}/general.h
complete.o: ${topdir}/bashtypes.h ${BASHINCDIR}/chartypes.h ${topdir}/xmalloc.h
complete.o: ${topdir}/pcomplete.h
complete.o: ${srcdir}/common.h ${srcdir}/bashgetopt.h
mapfile.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
mapfile.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
mapfile.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
mapfile.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
mapfile.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
mapfile.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/variables.h $(topdir)/conftypes.h
mapfile.o: $(topdir)/arrayfunc.h ../pathnames.h

View file

@ -1,7 +1,7 @@
This file is alias.def, from which is created alias.c
It implements the builtins "alias" and "unalias" in Bash.
Copyright (C) 1987-2009 Free Software Foundation, Inc.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -33,7 +33,7 @@ A trailing space in VALUE causes the next word to be checked for
alias substitution when the alias is expanded.
Options:
-p Print all defined aliases in a reusable format
-p print all defined aliases in a reusable format
Exit Status:
alias returns true unless a NAME is supplied for which no alias has been
@ -87,6 +87,7 @@ alias_builtin (list)
pflag = 1;
dflags |= AL_REUSABLE;
break;
CASE_HELPOPT;
default:
builtin_usage ();
return (EX_USAGE);
@ -160,7 +161,7 @@ $SHORT_DOC unalias [-a] name [name ...]
Remove each NAME from the list of defined aliases.
Options:
-a remove all alias definitions.
-a remove all alias definitions
Return success unless a NAME is not an existing alias.
$END
@ -183,6 +184,7 @@ unalias_builtin (list)
case 'a':
aflag = 1;
break;
CASE_HELPOPT;
default:
builtin_usage ();
return (EX_USAGE);
@ -232,7 +234,7 @@ print_alias (alias, flags)
value = sh_single_quote (alias->value);
if (flags & AL_REUSABLE)
printf ("alias ");
printf ("alias %s", (alias->name && alias->name[0] == '-') ? "-- " : "");
printf ("%s=%s\n", alias->name, value);
free (value);

View file

@ -31,6 +31,8 @@
#include "../shell.h"
#include "common.h"
#include "bashgetopt.h"
#define ISOPT(s) (((*(s) == '-') || (plus && *(s) == '+')) && (s)[1])
#define NOTOPT(s) (((*(s) != '-') && (!plus || *(s) != '+')) || (s)[1] == '\0')
@ -76,6 +78,10 @@ char *opts;
lhead = (WORD_LIST *)NULL;
loptend = lcurrent;
return(-1);
} else if (ISHELP (lcurrent->word->word)) {
lhead = (WORD_LIST *)NULL;
loptend = lcurrent;
return (GETOPT_HELP);
} else if (lcurrent->word->word[0] == '-' &&
lcurrent->word->word[1] == '-' &&
lcurrent->word->word[2] == 0) {

View file

@ -25,6 +25,9 @@
#include <stdc.h>
#define GETOPT_EOF -1
#define GETOPT_HELP -99
extern char *list_optarg;
extern int list_optopt;

View file

@ -1,7 +1,7 @@
This file is bind.def, from which is created bind.c.
It implements the builtin "bind" in Bash.
Copyright (C) 1987-2009 Free Software Foundation, Inc.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -54,7 +54,7 @@ Options:
-f filename Read key bindings from FILENAME.
-x keyseq:shell-command Cause SHELL-COMMAND to be executed when
KEYSEQ is entered.
-X List key sequences bound with -x and associated commands
-X List key sequences bound with -x and associated commands
in a form that can be reused as input.
Exit Status:
@ -115,7 +115,7 @@ bind_builtin (list)
int return_code;
Keymap kmap, saved_keymap;
int flags, opt;
char *initfile, *map_name, *fun_name, *unbind_name, *remove_seq, *cmd_seq;
char *initfile, *map_name, *fun_name, *unbind_name, *remove_seq, *cmd_seq, *t;
if (no_line_editing)
{
@ -129,7 +129,7 @@ bind_builtin (list)
kmap = saved_keymap = (Keymap) NULL;
flags = 0;
initfile = map_name = fun_name = unbind_name = remove_seq = (char *)NULL;
initfile = map_name = fun_name = unbind_name = remove_seq = cmd_seq = (char *)NULL;
return_code = EXECUTION_SUCCESS;
if (bash_readline_initialized == 0)
@ -141,7 +141,7 @@ bind_builtin (list)
rl_outstream = stdout;
reset_internal_getopt ();
while ((opt = internal_getopt (list, "lvpVPsSXf:q:u:m:r:x:")) != EOF)
while ((opt = internal_getopt (list, "lvpVPsSXf:q:u:m:r:x:")) != -1)
{
switch (opt)
{
@ -193,6 +193,7 @@ bind_builtin (list)
case 'X':
flags |= XXFLAG;
break;
CASE_HELPOPT;
default:
builtin_usage ();
BIND_RETURN (EX_USAGE);
@ -248,7 +249,10 @@ bind_builtin (list)
{
if (rl_read_init_file (initfile) != 0)
{
builtin_error (_("%s: cannot read: %s"), initfile, strerror (errno));
t = printable_filename (initfile, 0);
builtin_error (_("%s: cannot read: %s"), t, strerror (errno));
if (t != initfile)
free (t);
BIND_RETURN (EXECUTION_FAILURE);
}
}

View file

@ -67,6 +67,8 @@ break_builtin (list)
{
intmax_t newbreak;
CHECK_HELPOPT (list);
if (check_loop_level () == 0)
return (EXECUTION_SUCCESS);
@ -107,6 +109,8 @@ continue_builtin (list)
{
intmax_t newcont;
CHECK_HELPOPT (list);
if (check_loop_level () == 0)
return (EXECUTION_SUCCESS);

View file

@ -81,6 +81,8 @@ caller_builtin (list)
char *funcname_s, *source_s, *lineno_s;
intmax_t num;
CHECK_HELPOPT (list);
GET_ARRAY_FROM_VAR ("FUNCNAME", funcname_v, funcname_a);
GET_ARRAY_FROM_VAR ("BASH_SOURCE", bash_source_v, bash_source_a);
GET_ARRAY_FROM_VAR ("BASH_LINENO", bash_lineno_v, bash_lineno_a);

View file

@ -1,7 +1,7 @@
This file is cd.def, from which is created cd.c. It implements the
builtins "cd" and "pwd" in Bash.
Copyright (C) 1987-2013 Free Software Foundation, Inc.
Copyright (C) 1987-2016 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -93,16 +93,17 @@ the word is assumed to be a variable name. If that variable has a value,
its value is used for DIR.
Options:
-L force symbolic links to be followed: resolve symbolic links in
DIR after processing instances of `..'
-P use the physical directory structure without following symbolic
links: resolve symbolic links in DIR before processing instances
of `..'
-e if the -P option is supplied, and the current working directory
cannot be determined successfully, exit with a non-zero status
-L force symbolic links to be followed: resolve symbolic
links in DIR after processing instances of `..'
-P use the physical directory structure without following
symbolic links: resolve symbolic links in DIR before
processing instances of `..'
-e if the -P option is supplied, and the current working
directory cannot be determined successfully, exit with
a non-zero status
#if defined (O_XATTR)
-@ on systems that support it, present a file with extended attributes
as a directory containing the file attributes
-@ on systems that support it, present a file with extended
attributes as a directory containing the file attributes
#endif
The default is to follow symbolic links, as if `-L' were specified.
@ -261,7 +262,7 @@ cd_builtin (list)
WORD_LIST *list;
{
char *dirname, *cdpath, *path, *temp;
int path_index, no_symlinks, opt, lflag;
int path_index, no_symlinks, opt, lflag, e;
#if defined (RESTRICTED_SHELL)
if (restricted)
@ -297,6 +298,7 @@ cd_builtin (list)
xattrflag = 1;
break;
#endif
CASE_HELPOPT;
default:
builtin_usage ();
return (EX_USAGE);
@ -327,6 +329,13 @@ cd_builtin (list)
builtin_error (_("too many arguments"));
return (EXECUTION_FAILURE);
}
#endif
#if 0
else if (list->word->word[0] == '\0')
{
builtin_error (_("null directory"));
return (EXECUTION_FAILURE);
}
#endif
else if (list->word->word[0] == '-' && list->word->word[1] == '\0')
{
@ -436,7 +445,11 @@ cd_builtin (list)
FREE (temp);
}
builtin_error ("%s: %s", dirname, strerror (errno));
e = errno;
temp = printable_filename (dirname, 0);
builtin_error ("%s: %s", temp, strerror (e));
if (temp != dirname)
free (temp);
return (EXECUTION_FAILURE);
}
@ -447,7 +460,7 @@ Print the name of the current working directory.
Options:
-L print the value of $PWD if it names the current working
directory
directory
-P print the physical directory, without any symbolic links
By default, `pwd' behaves as if `-L' were specified.
@ -482,6 +495,7 @@ pwd_builtin (list)
case 'L':
verbatim_pwd = 0;
break;
CASE_HELPOPT;
default:
builtin_usage ();
return (EX_USAGE);

View file

@ -1,7 +1,7 @@
This file is command.def, from which is created command.c.
It implements the builtin "command" in Bash.
Copyright (C) 1987-2009 Free Software Foundation, Inc.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -30,10 +30,10 @@ information about the specified COMMANDs. Can be used to invoke commands
on disk when a function with the same name exists.
Options:
-p use a default value for PATH that is guaranteed to find all of
the standard utilities
-v print a description of COMMAND similar to the `type' builtin
-V print a more verbose description of each COMMAND
-p use a default value for PATH that is guaranteed to find all of
the standard utilities
-v print a description of COMMAND similar to the `type' builtin
-V print a more verbose description of each COMMAND
Exit Status:
Returns exit status of COMMAND, or failure if COMMAND is not found.
@ -63,7 +63,6 @@ extern size_t confstr __P((int, char *, size_t));
extern int subshell_environment;
static void restore_path __P((char *));
static char *get_standard_path __P((void));
/* Run the commands mentioned in LIST without paying attention to shell
functions. */
@ -82,7 +81,7 @@ command_builtin (list)
switch (opt)
{
case 'p':
use_standard_path = 1;
use_standard_path = CDESC_STDPATH;
break;
case 'V':
verbose = CDESC_SHORTDESC|CDESC_ABSPATH; /* look in common.h for constants */
@ -90,6 +89,7 @@ command_builtin (list)
case 'v':
verbose = CDESC_REUSABLE; /* ditto */
break;
CASE_HELPOPT;
default:
builtin_usage ();
return (EX_USAGE);
@ -108,30 +108,13 @@ command_builtin (list)
}
#endif
begin_unwind_frame ("command_builtin");
if (use_standard_path)
{
old_path = get_string_value ("PATH");
/* If old_path is NULL, $PATH is unset. If so, we want to make sure
it's unset after this command completes. */
if (old_path)
old_path = savestring (old_path);
add_unwind_protect ((Function *)restore_path, old_path);
standard_path = get_standard_path ();
bind_variable ("PATH", standard_path ? standard_path : "", 0);
stupidly_hack_special_variables ("PATH");
FREE (standard_path);
}
if (verbose)
{
int found, any_found;
for (any_found = 0; list; list = list->next)
{
found = describe_command (list->word->word, verbose);
found = describe_command (list->word->word, verbose|use_standard_path);
if (found == 0 && verbose != CDESC_REUSABLE)
sh_notfound (list->word->word);
@ -139,11 +122,12 @@ command_builtin (list)
any_found += found;
}
run_unwind_frame ("command_builtin");
return (any_found ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
}
#define COMMAND_BUILTIN_FLAGS (CMD_NO_FUNCTIONS | CMD_INHIBIT_EXPANSION | CMD_COMMAND_BUILTIN)
begin_unwind_frame ("command_builtin");
#define COMMAND_BUILTIN_FLAGS (CMD_NO_FUNCTIONS | CMD_INHIBIT_EXPANSION | CMD_COMMAND_BUILTIN | (use_standard_path ? CMD_STDPATH : 0))
/* We don't want this to be reparsed (consider command echo 'foo &'), so
just make a simple_command structure and call execute_command with it. */
@ -152,18 +136,7 @@ command_builtin (list)
command->value.Simple->redirects = (REDIRECT *)NULL;
command->flags |= COMMAND_BUILTIN_FLAGS;
command->value.Simple->flags |= COMMAND_BUILTIN_FLAGS;
#if 0
/* This breaks for things like ( cd /tmp ; command z ababa ; echo next )
or $(command echo a ; command echo b;) or even
{ command echo a; command echo b; } & */
/* If we're in a subshell, see if we can get away without forking
again, since we've already forked to run this builtin. */
if (subshell_environment)
{
command->flags |= CMD_NO_FORK;
command->value.Simple->flags |= CMD_NO_FORK;
}
#endif
add_unwind_protect ((char *)dispose_command, command);
result = execute_command (command);
@ -188,32 +161,3 @@ restore_path (var)
stupidly_hack_special_variables ("PATH");
}
/* Return a value for PATH that is guaranteed to find all of the standard
utilities. This uses Posix.2 configuration variables, if present. It
uses a value defined in config.h as a last resort. */
static char *
get_standard_path ()
{
#if defined (_CS_PATH) && defined (HAVE_CONFSTR)
char *p;
size_t len;
len = (size_t)confstr (_CS_PATH, (char *)NULL, (size_t)0);
if (len > 0)
{
p = (char *)xmalloc (len + 2);
*p = '\0';
confstr (_CS_PATH, p, len);
return (p);
}
else
return (savestring (STANDARD_UTILS_PATH));
#else /* !_CS_PATH || !HAVE_CONFSTR */
# if defined (CS_PATH)
return (savestring (CS_PATH));
# else
return (savestring (STANDARD_UTILS_PATH));
# endif /* !CS_PATH */
#endif /* !_CS_PATH || !HAVE_CONFSTR */
}

View file

@ -1,6 +1,6 @@
/* common.c - utility functions for all builtins */
/* Copyright (C) 1987-2010 Free Software Foundation, Inc.
/* Copyright (C) 1987-2016 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -70,6 +70,7 @@ extern int errno;
extern int indirection_level, subshell_environment;
extern int line_number;
extern int last_command_exit_value;
extern int trap_saved_exit_value;
extern int running_trap;
extern int posixly_correct;
extern char *this_command_name, *shell_name;
@ -175,9 +176,16 @@ int
no_options (list)
WORD_LIST *list;
{
int opt;
reset_internal_getopt ();
if (internal_getopt (list, "") != -1)
if ((opt = internal_getopt (list, "")) != -1)
{
if (opt == GETOPT_HELP)
{
builtin_help ();
return (2);
}
builtin_usage ();
return (1);
}
@ -234,7 +242,7 @@ sh_invalidnum (s)
{
char *msg;
if (*s == '0' && isdigit (s[1]))
if (*s == '0' && isdigit ((unsigned char)s[1]))
msg = _("invalid octal number");
else if (*s == '0' && s[1] == 'x')
msg = _("invalid hex number");
@ -335,7 +343,9 @@ int
sh_chkwrite (s)
int s;
{
QUIT;
fflush (stdout);
QUIT;
if (ferror (stdout))
{
sh_wrerror ();
@ -403,6 +413,8 @@ remember_args (list, destructive)
if (destructive)
set_dollar_vars_changed ();
invalidate_cached_quoted_dollar_at ();
}
static int changed_dollar_vars;
@ -494,7 +506,17 @@ get_exitstat (list)
list = list->next;
if (list == 0)
return (last_command_exit_value);
{
/* If we're not running the DEBUG trap, the return builtin, when not
given any arguments, uses the value of $? before the trap ran. If
given an argument, return uses it. This means that the trap can't
change $?. The DEBUG trap gets to change $?, though, since that is
part of its reason for existing, and because the extended debug mode
does things with the return value. */
if (this_shell_builtin == return_builtin && running_trap > 0 && running_trap != DEBUG_TRAP+1)
return (trap_saved_exit_value);
return (last_command_exit_value);
}
arg = list->word->word;
if (arg == 0 || legal_number (arg, &sval) == 0)
@ -888,3 +910,11 @@ initialize_shell_builtins ()
qsort (shell_builtins, num_shell_builtins, sizeof (struct builtin),
(QSFUNC *)shell_builtin_compare);
}
#if !defined (HELP_BUILTIN)
void
builtin_help ()
{
printf ("%s: %s\n", this_command_name, _("help not available in this version"));
}
#endif

View file

@ -1,6 +1,6 @@
/* common.h -- extern declarations for functions defined in common.c. */
/* Copyright (C) 1993-2010 Free Software Foundation, Inc.
/* Copyright (C) 1993-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -24,6 +24,21 @@
#include "stdc.h"
#define ISOPTION(s, c) (s[0] == '-' && !s[2] && s[1] == c)
#define ISHELP(s) (STREQ ((s), "--help"))
#define CHECK_HELPOPT(l) \
do { \
if ((l) && (l)->word && ISHELP((l)->word->word)) \
{ \
builtin_help (); \
return (EX_USAGE); \
} \
} while (0)
#define CASE_HELPOPT \
case GETOPT_HELP: \
builtin_help (); \
return (EX_USAGE)
/* Flag values for parse_and_execute () */
#define SEVAL_NONINT 0x001
@ -35,6 +50,7 @@
#define SEVAL_NOLONGJMP 0x040
#define SEVAL_FUNCDEF 0x080 /* only allow function definitions */
#define SEVAL_ONECMD 0x100 /* only allow a single command */
#define SEVAL_NOHISTEXP 0x200 /* inhibit history expansion */
/* Flags for describe_command, shared between type.def and command.def */
#define CDESC_ALL 0x001 /* type -a */
@ -45,6 +61,7 @@
#define CDESC_FORCE_PATH 0x020 /* type -ap or type -P */
#define CDESC_NOFUNCS 0x040 /* type -f */
#define CDESC_ABSPATH 0x080 /* convert to absolute path, no ./ */
#define CDESC_STDPATH 0x100 /* command -p */
/* Flags for get_job_by_name */
#define JM_PREFIX 0x01 /* prefix of job name */
@ -59,6 +76,9 @@
#define ARGS_FUNC 0x02
#define ARGS_SETBLTIN 0x04
/* Maximum number of attribute letters */
#define MAX_ATTRIBUTES 16
/* Functions from common.c */
extern void builtin_error __P((const char *, ...)) __attribute__((__format__ (printf, 1, 2)));
extern void builtin_warning __P((const char *, ...)) __attribute__((__format__ (printf, 1, 2)));
@ -122,6 +142,9 @@ extern void bash_logout __P((void));
/* Functions from getopts.def */
extern void getopts_reset __P((int));
/* Functions from help.def */
extern void builtin_help __P((void));
/* Functions from read.def */
extern void read_tty_cleanup __P((void));
extern int read_tty_modified __P((void));
@ -138,6 +161,9 @@ extern void initialize_shell_options __P((int));
extern void reset_shell_options __P((void));
extern char *get_current_options __P((void));
extern void set_current_options __P((const char *));
/* Functions from shopt.def */
extern void reset_shopt_options __P((void));
extern char **get_shopt_options __P((void));
@ -163,6 +189,7 @@ extern int show_var_attributes __P((SHELL_VAR *, int, int));
extern int show_name_attributes __P((char *, int));
extern int show_func_attributes __P((char *, int));
extern void set_var_attribute __P((char *, int, int));
extern int var_attribute_string __P((SHELL_VAR *, int, char *));
/* Functions from pushd.def */
extern char *get_dirstack_from_string __P((char *));
@ -175,9 +202,12 @@ extern int parse_and_execute __P((char *, const char *, int));
extern int evalstring __P((char *, const char *, int));
extern void parse_and_execute_cleanup __P((void));
extern int parse_string __P((char *, const char *, int, char **));
extern int should_suppress_fork __P((COMMAND *));
extern void optimize_fork __P((COMMAND *));
/* Functions from evalfile.c */
extern int maybe_execute_file __P((const char *, int));
extern int force_execute_file __P((const char *, int));
extern int source_file __P((const char *, int));
extern int fc_execute_file __P((const char *));

View file

@ -1,7 +1,7 @@
This file is complete.def, from which is created complete.c.
It implements the builtins "complete", "compgen", and "compopt" in Bash.
Copyright (C) 1999-2011 Free Software Foundation, Inc.
Copyright (C) 1999-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -33,11 +33,11 @@ allows them to be reused as input.
Options:
-p print existing completion specifications in a reusable format
-r remove a completion specification for each NAME, or, if no
NAMEs are supplied, all completion specifications
NAMEs are supplied, all completion specifications
-D apply the completions and actions as the default for commands
without any specific completion defined
without any specific completion defined
-E apply the completions and actions to "empty" commands --
completion attempted on a blank line
completion attempted on a blank line
When completion is attempted, the actions are applied in the order the
uppercase-letter options are listed above. The -D option takes
@ -138,6 +138,7 @@ static const struct _compopt {
{ "dirnames", COPT_DIRNAMES },
{ "filenames",COPT_FILENAMES},
{ "noquote", COPT_NOQUOTE },
{ "nosort", COPT_NOSORT },
{ "nospace", COPT_NOSPACE },
{ "plusdirs", COPT_PLUSDIRS },
{ (char *)NULL, 0 },
@ -170,7 +171,7 @@ find_compopt (name)
/* Build the actions and compspec options from the options specified in LIST.
ACTP is a pointer to an unsigned long in which to place the bitmap of
actions. OPTP is a pointer to an unsigned long in which to place the
btmap of compspec options (arguments to `-o'). PP, if non-null, gets 1
bitmap of compspec options (arguments to `-o'). PP, if non-null, gets 1
if -p is supplied; RP, if non-null, gets 1 if -r is supplied.
If either is null, the corresponding option generates an error.
This also sets variables corresponding to options that take arguments as
@ -324,6 +325,7 @@ build_actions (list, flagp, actp, optp)
case 'X':
Xarg = list_optarg;
break;
CASE_HELPOPT;
default:
builtin_usage ();
return (EX_USAGE);
@ -653,7 +655,7 @@ print_cmd_completions (list)
$BUILTIN compgen
$DEPENDS_ON PROGRAMMABLE_COMPLETION
$FUNCTION compgen_builtin
$SHORT_DOC compgen [-abcdefgjksuv] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [word]
$SHORT_DOC compgen [-abcdefgjksuv] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [word]
Display possible completions depending on the options.
Intended to be used from within a shell function generating possible
@ -790,7 +792,7 @@ compopt_builtin (list)
ret = EXECUTION_SUCCESS;
reset_internal_getopt ();
while ((opt = internal_getopt (list, "+o:DE")) != EOF)
while ((opt = internal_getopt (list, "+o:DE")) != -1)
{
opts = (list_opttype == '-') ? &opts_on : &opts_off;
@ -811,6 +813,7 @@ compopt_builtin (list)
case 'E':
Eflag = 1;
break;
CASE_HELPOPT;
default:
builtin_usage ();
return (EX_USAGE);
@ -867,5 +870,8 @@ compopt_builtin (list)
pcomp_set_compspec_options (cs, opts_off, 0);
}
if (wl)
dispose_words (wl);
return (ret);
}

View file

@ -1,7 +1,7 @@
This file is declare.def, from which is created declare.c.
It implements the builtins "declare" and "local" in Bash.
Copyright (C) 1987-2012 Free Software Foundation, Inc.
Copyright (C) 1987-2016 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -31,9 +31,9 @@ display the attributes and values of all variables.
Options:
-f restrict action or display to function names and definitions
-F restrict display to function names only (plus line number and
source file when debugging)
source file when debugging)
-g create global variables when used in a shell function; otherwise
ignored
ignored
-p display the attributes and value of each NAME
Options which set attributes:
@ -62,10 +62,10 @@ $END
$BUILTIN typeset
$FUNCTION declare_builtin
$SHORT_DOC typeset [-aAfFgilrtux] [-p] name[=value] ...
$SHORT_DOC typeset [-aAfFgilnrtux] [-p] name[=value] ...
Set variable values and attributes.
Obsolete. See `help declare'.
A synonym for `declare'. See `help declare'.
$END
#include <config.h>
@ -83,6 +83,7 @@ $END
#include "../bashintl.h"
#include "../shell.h"
#include "../flags.h"
#include "common.h"
#include "builtext.h"
#include "bashgetopt.h"
@ -149,10 +150,12 @@ declare_internal (list, local_var)
flags_on = flags_off = any_failed = assign_error = pflag = nodefs = mkglobal = 0;
refvar = (SHELL_VAR *)NULL;
reset_internal_getopt ();
while ((opt = internal_getopt (list, DECLARE_OPTS)) != EOF)
while ((opt = internal_getopt (list, DECLARE_OPTS)) != -1)
{
flags = list_opttype == '+' ? &flags_off : &flags_on;
/* If you add options here, see whether or not they need to be added to
the loop in subst.c:shell_expand_word_list() */
switch (opt)
{
case 'a':
@ -221,6 +224,7 @@ declare_internal (list, local_var)
flags_off |= att_capcase|att_lowercase;
break;
#endif /* CASEMOD_ATTRS */
CASE_HELPOPT;
default:
builtin_usage ();
return (EX_USAGE);
@ -282,15 +286,28 @@ declare_internal (list, local_var)
/* There are arguments left, so we are making variables. */
while (list) /* declare [-aAfFirx] name [name ...] */
{
char *value, *name;
int offset, aflags;
char *value, *name, *oldname;
int offset, aflags, wflags, created_var, namelen;
#if defined (ARRAY_VARS)
int making_array_special, compound_array_assign, simple_array_assign;
int var_exists, array_exists, creating_array, array_subscript_assignment;
#endif
name = savestring (list->word->word);
wflags = list->word->flags;
offset = assignment (name, 0);
aflags = 0;
created_var = 0;
if (local_var && variable_context && STREQ (name, "-"))
{
var = make_local_variable ("-");
FREE (value_cell (var)); /* just in case */
value = get_current_options ();
var_setvalue (var, value);
VSETATTR (var, att_invisible);
NEXT_VARIABLE ();
}
if (offset) /* declare [-aAfFirx] name=value */
{
@ -309,8 +326,8 @@ declare_internal (list, local_var)
that is specific to nameref variables. */
if (flags_on & att_nameref)
{
#if defined (ARRAY_VARIABLES)
if (valid_array_reference (name))
#if defined (ARRAY_VARS)
if (valid_array_reference (name, 0))
{
builtin_error (_("%s: reference variable cannot be an array"), name);
assign_error++;
@ -318,22 +335,39 @@ declare_internal (list, local_var)
}
else
#endif
/* disallow self references at global scope */
if (STREQ (name, value) && variable_context == 0)
/* disallow self references at global scope, warn at function scope */
if (check_selfref (name, value, 0))
{
builtin_error (_("%s: nameref variable self references not allowed"), name);
if (variable_context == 0)
{
builtin_error (_("%s: nameref variable self references not allowed"), name);
assign_error++;
NEXT_VARIABLE ();
}
else
builtin_warning (_("%s: circular name reference"), name);
}
#if 1
if (value && *value && (aflags & ASS_APPEND) == 0 && valid_nameref_value (value, 1) == 0)
{
builtin_error (_("`%s': invalid variable name for name reference"), value);
assign_error++;
NEXT_VARIABLE ();
}
#endif
}
restart_new_var_name:
#if defined (ARRAY_VARS)
var_exists = array_exists = creating_array = 0;
compound_array_assign = simple_array_assign = 0;
array_subscript_assignment = 0;
subscript_start = (char *)NULL;
if (t = strchr (name, '[')) /* ] */
{
/* If offset != 0 we have already validated any array reference */
if (offset == 0 && valid_array_reference (name) == 0)
/* If offset != 0 we have already validated any array reference
because assignment() calls skipsubscript() */
if (offset == 0 && valid_array_reference (name, 0) == 0)
{
sh_invalidid (name);
assign_error++;
@ -341,7 +375,8 @@ declare_internal (list, local_var)
}
subscript_start = t;
*t = '\0';
making_array_special = 1;
making_array_special = 1; /* XXX - should this check offset? */
array_subscript_assignment = offset != 0;
}
else
making_array_special = 0;
@ -368,6 +403,7 @@ declare_internal (list, local_var)
refvar = (SHELL_VAR *)NULL;
if (variable_context && mkglobal == 0 && ((flags_on & att_function) == 0))
{
/* check name for validity here? */
#if defined (ARRAY_VARS)
if (flags_on & att_assoc)
var = make_local_assoc_variable (name);
@ -375,12 +411,41 @@ declare_internal (list, local_var)
var = make_local_array_variable (name, making_array_special);
else
#endif
if (offset == 0 && (flags_on & att_nameref))
{
/* First look for refvar at current scope */
refvar = find_variable_last_nameref (name, 1);
var = find_variable (name);
/* VARIABLE_CONTEXT != 0, so we are attempting to create or modify
the attributes for a local variable at the same scope. If we've
used a reference from a previous context to resolve VAR, we
want to throw REFVAR and VAR away and create a new local var. */
if (refvar && refvar->context != variable_context)
{
refvar = 0;
var = make_local_variable (name);
}
else if (refvar && refvar->context == variable_context)
var = refvar;
/* Maybe we just want to create a new local variable */
else if (var == 0 || var->context != variable_context)
var = make_local_variable (name);
/* otherwise we have a var at the right context */
}
else
/* XXX - check name for validity here with valid_nameref_value */
var = make_local_variable (name); /* sets att_invisible for new vars */
if (var == 0)
{
any_failed++;
NEXT_VARIABLE ();
}
if (var && nameref_p (var) && readonly_p (var) && nameref_cell (var) && (flags_off & att_nameref))
{
sh_readonly (name);
any_failed++;
NEXT_VARIABLE ();
}
}
else
var = (SHELL_VAR *)NULL;
@ -444,18 +509,33 @@ declare_internal (list, local_var)
NEXT_VARIABLE ();
}
}
else /* declare -[aAirx] name [name...] */
else /* declare -[aAinrx] name [name...] */
{
/* Non-null if we just created or fetched a local variable. */
#if 0
/* This is bash-4.3 code. */
/* Here's what ksh93 seems to do. If we are modifying an existing
nameref variable, we don't follow the nameref chain past the last
nameref, and we set the nameref variable's value so future
references to that variable will return the value of the variable
we're assigning right now. */
#else
/* Here's what ksh93 seems to do as of the 2012 version: if we are
using declare -n to modify the value of an existing nameref
variable, don't follow the nameref chain at all and just search
for a nameref at the current context. If we have a nameref,
modify its value (changing which variable it references). */
#endif
if (var == 0 && (flags_on & att_nameref))
{
#if 0
/* See if we are trying to modify an existing nameref variable */
var = mkglobal ? find_global_variable_last_nameref (name) : find_variable_last_nameref (name);
var = mkglobal ? find_global_variable_last_nameref (name, 1) : find_variable_last_nameref (name, 1);
#else
/* See if we are trying to modify an existing nameref variable,
but don't follow the nameref chain. */
var = mkglobal ? find_global_variable_noref (name) : find_variable_noref (name);
#endif
if (var && nameref_p (var) == 0)
var = 0;
}
@ -467,41 +547,137 @@ declare_internal (list, local_var)
else if (var == 0 && (flags_off & att_nameref))
{
/* See if we are trying to modify an existing nameref variable */
refvar = mkglobal ? find_global_variable_last_nameref (name) : find_variable_last_nameref (name);
refvar = mkglobal ? find_global_variable_last_nameref (name, 0) : find_variable_last_nameref (name, 0);
if (refvar && nameref_p (refvar) == 0)
refvar = 0;
/* If the nameref is readonly but doesn't have a value, ksh93
allows the nameref attribute to be removed. If it's readonly
and has a value, even if the value doesn't reference an
existing variable, we disallow the modification */
if (refvar && nameref_cell (refvar) && readonly_p (refvar))
{
sh_readonly (name);
any_failed++;
NEXT_VARIABLE ();
}
if (refvar)
var = mkglobal ? find_global_variable (nameref_cell (refvar)) : find_variable (nameref_cell (refvar));
}
#if defined (ARRAY_VARS)
/* If we have an array assignment to a nameref, remove the nameref
attribute and go on. */
else if (var == 0 && offset && array_subscript_assignment)
{
var = mkglobal ? find_global_variable_noref (name) : find_variable_noref (name);
if (var && nameref_p (var))
{
internal_warning (_("%s: removing nameref attribute"), name);
FREE (value_cell (var)); /* XXX - bash-4.3 compat */
var_setvalue (var, (char *)NULL);
VUNSETATTR (var, att_nameref);
}
}
#endif
/* See if we are trying to set flags or value for an existing nameref
that points to a non-existent variable: e.g.,
declare -n foo=bar
unset foo # unsets bar
declare -i foo
foo=4+4
declare -p foo */
if (var == 0 && (flags_on || flags_off || offset))
{
refvar = mkglobal ? find_global_variable_last_nameref (name, 0) : find_variable_last_nameref (name, 0);
if (refvar && nameref_p (refvar) == 0)
refvar = 0;
if (refvar)
var = mkglobal ? find_global_variable (nameref_cell (refvar)) : find_variable (nameref_cell (refvar));
if (refvar && var == 0)
{
oldname = name; /* need to free this */
namelen = strlen (nameref_cell (refvar));
#if defined (ARRAY_VARS)
if (subscript_start)
{
*subscript_start = '['; /*]*/
namelen += strlen (subscript_start);
}
#endif
name = xmalloc (namelen + 2 + strlen (value) + 1);
strcpy (name, nameref_cell (refvar));
#if defined (ARRAY_VARS)
if (subscript_start)
strcpy (name + strlen (nameref_cell (refvar)), subscript_start);
#endif
/* We are committed to using the new name, so reset */
if (offset)
{
/* Rebuild assignment and restore offset and value */
if (aflags & ASS_APPEND)
name[namelen++] = '+';
name[namelen++] = '=';
if (value && *value)
strcpy (name + namelen, value);
else
name[namelen] = '\0';
offset = assignment (name, 0);
/* if offset was valid previously, but the substituting
of the nameref value results in an invalid assignment,
throw an invalid identifier error */
if (offset == 0)
{
free (oldname);
sh_invalidid (name);
assign_error++;
NEXT_VARIABLE ();
}
name[offset] = '\0';
value = name + namelen;
}
free (oldname);
goto restart_new_var_name;
/* NOTREACHED */
}
}
if (var == 0)
var = mkglobal ? find_global_variable (name) : find_variable (name);
#if defined (ARRAY_VARS)
var_exists = var != 0;
array_exists = var && (array_p (var) || assoc_p (var));
creating_array = flags_on & (att_array|att_assoc);
#endif
if (var == 0)
{
#if defined (ARRAY_VARS)
if (flags_on & att_assoc)
{
var = make_new_assoc_variable (name);
if (offset == 0)
if (var && offset == 0 && no_invisible_vars == 0)
VSETATTR (var, att_invisible);
}
else if ((flags_on & att_array) || making_array_special)
{
var = make_new_array_variable (name);
if (offset == 0)
if (var && offset == 0 && no_invisible_vars == 0)
VSETATTR (var, att_invisible);
}
else
#endif
if (offset)
var = mkglobal ? bind_global_variable (name, "", 0) : bind_variable (name, "", 0);
else
{
var = mkglobal ? bind_global_variable (name, (char *)NULL, 0) : bind_variable (name, (char *)NULL, 0);
VSETATTR (var, att_invisible);
var = mkglobal ? bind_global_variable (name, (char *)NULL, ASS_FORCE) : bind_variable (name, (char *)NULL, ASS_FORCE);
if (var && offset == 0 && no_invisible_vars == 0)
VSETATTR (var, att_invisible);
}
if (var == 0)
{
/* Has to appear in brackets */
NEXT_VARIABLE ();
}
created_var = 1;
}
/* Can't take an existing array variable and make it a nameref */
else if ((array_p (var) || assoc_p (var)) && (flags_on & att_nameref))
@ -510,8 +686,30 @@ declare_internal (list, local_var)
assign_error++;
NEXT_VARIABLE ();
}
else if (nameref_p (var) && (flags_on & att_nameref) == 0 && (flags_off & att_nameref) == 0 && offset && valid_nameref_value (value, 1) == 0)
{
builtin_error (_("`%s': invalid variable name for name reference"), value);
any_failed++;
NEXT_VARIABLE ();
}
else if (flags_on & att_nameref)
{
#if 1
/* Check of offset is to allow an assignment to a nameref var as
part of the declare word to override existing value */
if (nameref_p (var) == 0 && var_isset (var) && offset == 0 && valid_nameref_value (value_cell (var), 0) == 0)
{
builtin_error (_("`%s': invalid variable name for name reference"), value_cell (var));
any_failed++;
NEXT_VARIABLE ();
}
#endif
if (readonly_p (var))
{
sh_readonly (name);
any_failed++;
NEXT_VARIABLE ();
}
/* ksh93 compat: turning on nameref attribute turns off -ilu */
VUNSETATTR (var, att_integer|att_uppercase|att_lowercase|att_capcase);
}
@ -519,7 +717,7 @@ declare_internal (list, local_var)
/* Cannot use declare +r to turn off readonly attribute. */
if (readonly_p (var) && (flags_off & att_readonly))
{
sh_readonly (name);
sh_readonly (name_cell (var));
any_failed++;
NEXT_VARIABLE ();
}
@ -535,12 +733,28 @@ declare_internal (list, local_var)
}
#if defined (ARRAY_VARS)
if ((making_array_special || (flags_on & (att_array|att_assoc)) || array_p (var) || assoc_p (var)) && offset)
/* make declare a[2]=foo as similar to a[2]=foo as possible if
a is already an array or assoc variable. */
if (array_subscript_assignment && array_exists && creating_array == 0)
simple_array_assign = 1;
else if ((making_array_special || creating_array || array_exists) && offset)
{
int vlen;
vlen = STRLEN (value);
if (value[0] == '(' && value[vlen-1] == ')')
/*itrace("declare_builtin: name = %s value = %s flags = %d", name, value, wflags);*/
if (shell_compatibility_level > 43 && (wflags & W_COMPASSIGN) == 0 &&
value[0] == '(' && value[vlen-1] == ')')
{
/* The warning is only printed when using compound assignment
to an array variable that doesn't already exist. We use
creating_array to allow things like
declare -a foo$bar='(abc)' to work. */
if (array_exists == 0 && creating_array == 0)
internal_warning (_("%s: quoted compound array assignment deprecated"), list->word->word);
compound_array_assign = array_exists || creating_array;
simple_array_assign = making_array_special;
}
else if (value[0] == '(' && value[vlen-1] == ')' && (shell_compatibility_level < 44 || (wflags & W_COMPASSIGN)))
compound_array_assign = 1;
else
simple_array_assign = 1;
@ -604,12 +818,13 @@ declare_internal (list, local_var)
#if defined (ARRAY_VARS)
if (offset && compound_array_assign)
assign_array_var_from_string (var, value, aflags);
assign_array_var_from_string (var, value, aflags|ASS_FORCE);
else if (simple_array_assign && subscript_start)
{
/* declare [-aA] name[N]=value */
*subscript_start = '['; /* ] */
var = assign_array_element (name, value, 0); /* XXX - not aflags */
/* XXX - problem here with appending */
var = assign_array_element (name, value, aflags&ASS_APPEND); /* XXX - not aflags */
*subscript_start = '\0';
if (var == 0) /* some kind of assignment error */
{
@ -623,25 +838,30 @@ declare_internal (list, local_var)
{
/* let bind_{array,assoc}_variable take care of this. */
if (assoc_p (var))
bind_assoc_variable (var, name, savestring ("0"), value, aflags);
bind_assoc_variable (var, name, savestring ("0"), value, aflags|ASS_FORCE);
else
bind_array_variable (name, 0, value, aflags);
bind_array_variable (name, 0, value, aflags|ASS_FORCE);
}
else
#endif
/* XXX - no ASS_FORCE here */
/* bind_variable_value duplicates the essential internals of
bind_variable() */
if (offset)
{
if (onref)
if (onref || nameref_p (var))
aflags |= ASS_NAMEREF;
v = bind_variable_value (var, value, aflags);
if (v == 0 && onref)
if (v == 0 && (onref || nameref_p (var)))
{
sh_invalidid (value);
if (valid_nameref_value (value, 1) == 0)
sh_invalidid (value);
assign_error++;
/* XXX - unset this variable? or leave it as normal var? */
delete_var (var->name, mkglobal ? global_variables : shell_variables);
if (created_var)
delete_var (var->name, mkglobal ? global_variables : shell_variables);
flags_on |= onref; /* undo change from above */
flags_off |= offref;
NEXT_VARIABLE ();
}
}
@ -681,9 +901,16 @@ declare_internal (list, local_var)
flags_on |= onref;
VUNSETATTR (var, offref);
flags_off |= offref;
/* Yuck. ksh93 compatibility */
/* Yuck. ksh93 compatibility. XXX - need to investigate more but
definitely happens when turning off nameref attribute on nameref
(see comments above). Under no circumstances allow this to turn
off readonly attribute on readonly nameref variable. */
if (refvar)
VUNSETATTR (refvar, flags_off);
{
if (flags_off & att_readonly)
flags_off &= ~att_readonly;
VUNSETATTR (refvar, flags_off);
}
stupidly_hack_special_variables (name);

View file

@ -1,7 +1,7 @@
This file is echo.def, from which is created echo.c.
It implements the builtin "echo" in Bash.
Copyright (C) 1987-2009 Free Software Foundation, Inc.
Copyright (C) 1987-2016 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -59,9 +59,9 @@ Options:
\v vertical tab
\\ backslash
\0nnn the character whose ASCII code is NNN (octal). NNN can be
0 to 3 octal digits
0 to 3 octal digits
\xHH the eight-bit character whose value is HH (hexadecimal). HH
can be one or two hex digits
can be one or two hex digits
Exit Status:
Returns success unless a write error occurs.
@ -161,7 +161,6 @@ just_echo:
clearerr (stdout); /* clear error before writing and testing success */
terminate_immediately++;
while (list)
{
i = len = 0;
@ -180,6 +179,7 @@ just_echo:
fflush (stdout); /* Fix for bug in SunOS 5.5 printf(3) */
#endif
}
QUIT;
if (do_v9 && temp)
free (temp);
list = list->next;
@ -190,11 +190,11 @@ just_echo:
}
if (list)
putchar(' ');
QUIT;
}
if (display_return)
putchar ('\n');
terminate_immediately--;
return (sh_chkwrite (EXECUTION_SUCCESS));
}

View file

@ -1,7 +1,7 @@
This file is enable.def, from which is created enable.c.
It implements the builtin "enable" in Bash.
Copyright (C) 1987-2009 Free Software Foundation, Inc.
Copyright (C) 1987-2016 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -66,6 +66,7 @@ $END
#include "../flags.h"
#include "common.h"
#include "bashgetopt.h"
#include "findcmd.h"
#if defined (PROGRAMMABLE_COMPLETION)
# include "../pcomplete.h"
@ -92,6 +93,11 @@ static void delete_builtin __P((struct builtin *));
static int local_dlclose __P((void *));
#endif
#define STRUCT_SUFFIX "_struct"
/* for now */
#define LOAD_SUFFIX "_builtin_load"
#define UNLOAD_SUFFIX "_builtin_unload"
static void list_some_builtins __P((int));
static int enable_shell_command __P((char *, int));
@ -145,6 +151,7 @@ enable_builtin (list)
builtin_error (_("dynamic loading not available"));
return (EX_USAGE);
#endif /* HAVE_DLCLOSE */
CASE_HELPOPT;
default:
builtin_usage ();
return (EX_USAGE);
@ -290,9 +297,11 @@ dyn_load_builtin (list, flags, filename)
WORD_LIST *l;
void *handle;
int total, size, new, replaced;
char *struct_name, *name;
int total, size, new, replaced, r;
char *struct_name, *name, *funcname;
sh_load_func_t *loadfunc;
struct builtin **new_builtins, *b, *new_shell_builtins, *old_builtin;
char *loadables_path, *load_path;
if (list == 0)
return (EXECUTION_FAILURE);
@ -301,15 +310,39 @@ dyn_load_builtin (list, flags, filename)
#define RTLD_LAZY 1
#endif
handle = 0;
if (absolute_program (filename) == 0)
{
loadables_path = get_string_value ("BASH_LOADABLES_PATH");
if (loadables_path)
{
load_path = find_in_path (filename, loadables_path, FS_NODIRS|FS_EXEC_PREFERRED);
if (load_path)
{
#if defined (_AIX)
handle = dlopen (filename, RTLD_NOW|RTLD_GLOBAL);
handle = dlopen (load_path, RTLD_NOW|RTLD_GLOBAL);
#else
handle = dlopen (filename, RTLD_LAZY);
handle = dlopen (load_path, RTLD_LAZY);
#endif /* !_AIX */
free (load_path);
}
}
}
/* Fall back to current directory for now */
if (handle == 0)
#if defined (_AIX)
handle = dlopen (filename, RTLD_NOW|RTLD_GLOBAL);
#else
handle = dlopen (filename, RTLD_LAZY);
#endif /* !_AIX */
if (handle == 0)
{
builtin_error (_("cannot open shared object %s: %s"), filename, dlerror ());
name = printable_filename (filename, 0);
builtin_error (_("cannot open shared object %s: %s"), name, dlerror ());
if (name != filename)
free (name);
return (EXECUTION_FAILURE);
}
@ -327,18 +360,36 @@ dyn_load_builtin (list, flags, filename)
size = strlen (name);
struct_name = (char *)xmalloc (size + 8);
strcpy (struct_name, name);
strcpy (struct_name + size, "_struct");
strcpy (struct_name + size, STRUCT_SUFFIX);
b = (struct builtin *)dlsym (handle, struct_name);
if (b == 0)
{
name = printable_filename (filename, 0);
builtin_error (_("cannot find %s in shared object %s: %s"),
struct_name, filename, dlerror ());
struct_name, name, dlerror ());
if (name != filename)
free (name);
free (struct_name);
continue;
}
free (struct_name);
funcname = xrealloc (struct_name, size + sizeof (LOAD_SUFFIX) + 1);
strcpy (funcname, name);
strcpy (funcname + size, LOAD_SUFFIX);
loadfunc = (sh_load_func_t *)dlsym (handle, funcname);
if (loadfunc)
{
r = (*loadfunc) (name);
if (r == 0)
{
builtin_error (_("load function for %s returns failure (%d): not loaded"), name, r);
free (funcname);
continue;
}
}
free (funcname);
b->flags &= ~STATIC_BUILTIN;
if (flags & SPECIAL)
@ -446,7 +497,9 @@ dyn_unload_builtin (name)
{
struct builtin *b;
void *handle;
int ref, i;
char *funcname;
sh_unload_func_t *unloadfunc;
int ref, i, size;
b = builtin_address_internal (name, 1);
if (b == 0)
@ -467,6 +520,17 @@ dyn_unload_builtin (name)
ref++;
}
/* Call any unload function */
size = strlen (name);
funcname = xmalloc (size + sizeof (UNLOAD_SUFFIX) + 1);
strcpy (funcname, name);
strcpy (funcname + size, UNLOAD_SUFFIX);
unloadfunc = (sh_unload_func_t *)dlsym (handle, funcname);
if (unloadfunc)
(*unloadfunc) (name); /* void function */
free (funcname);
/* Don't remove the shared object unless the reference count of builtins
using it drops to zero. */
if (ref == 1 && local_dlclose (handle) != 0)

View file

@ -1,7 +1,7 @@
This file is eval.def, from which is created eval.c.
It implements the builtin "eval" in Bash.
Copyright (C) 1987-2009 Free Software Foundation, Inc.
Copyright (C) 1987-2016 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.

View file

@ -1,6 +1,6 @@
/* evalfile.c - read and evaluate commands from a file or file descriptor */
/* Copyright (C) 1996-2009 Free Software Foundation, Inc.
/* Copyright (C) 1996-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -43,6 +43,8 @@
#include "../execute_cmd.h"
#include "../trap.h"
#include <y.tab.h>
#if defined (HISTORY)
# include "../bashhist.h"
#endif
@ -71,6 +73,7 @@ extern int indirection_level, subshell_environment;
extern int return_catch_flag, return_catch_value;
extern int last_command_exit_value;
extern int executing_command_builtin;
extern int current_token; /* parse.y */
/* How many `levels' of sourced files we have. */
int sourcelevel = 0;
@ -91,6 +94,7 @@ _evalfile (filename, flags)
#if defined (ARRAY_VARS)
SHELL_VAR *funcname_v, *nfv, *bash_source_v, *bash_lineno_v;
ARRAY *funcname_a, *bash_source_a, *bash_lineno_a;
struct func_array_state *fa;
# if defined (DEBUGGER)
SHELL_VAR *bash_argv_v, *bash_argc_v;
ARRAY *bash_argv_a, *bash_argc_a;
@ -130,7 +134,7 @@ file_error_and_exit:
}
return ((flags & FEVAL_BUILTIN) ? EXECUTION_FAILURE
: ((errno == ENOENT) ? 0 : -1));
: ((errno == ENOENT && (flags & FEVAL_ENOENTOK) != 0) ? 0 : -1));
}
errfunc = ((flags & FEVAL_BUILTIN) ? builtin_error : internal_error);
@ -240,6 +244,17 @@ file_error_and_exit:
array_push (bash_lineno_a, t);
free (t);
array_push (funcname_a, "source"); /* not exactly right */
fa = (struct func_array_state *)xmalloc (sizeof (struct func_array_state));
fa->source_a = bash_source_a;
fa->source_v = bash_source_v;
fa->lineno_a = bash_lineno_a;
fa->lineno_v = bash_lineno_v;
fa->funcname_a = funcname_a;
fa->funcname_v = funcname_v;
if (flags & FEVAL_UNWINDPROT)
add_unwind_protect (restore_funcarray_state, fa);
# if defined (DEBUGGER)
/* Have to figure out a better way to do this when `source' is supplied
arguments */
@ -248,6 +263,8 @@ file_error_and_exit:
array_push (bash_argv_a, (char *)filename);
tt[0] = '1'; tt[1] = '\0';
array_push (bash_argc_a, tt);
if (flags & FEVAL_UNWINDPROT)
add_unwind_protect (pop_args, 0);
}
# endif
#endif
@ -277,30 +294,27 @@ file_error_and_exit:
{
if (flags & FEVAL_NONINT)
interactive = old_interactive;
#if defined (ARRAY_VARS)
restore_funcarray_state (fa);
# if defined (DEBUGGER)
if ((flags & FEVAL_NOPUSHARGS) == 0)
{
/* Don't need to call pop_args here until we do something better
when source is passed arguments (see above). */
array_pop (bash_argc_a);
array_pop (bash_argv_a);
}
# endif
#endif
return_catch_flag--;
sourcelevel--;
COPY_PROCENV (old_return_catch, return_catch);
}
#if defined (ARRAY_VARS)
/* These two variables cannot be unset, and cannot be affected by the
sourced file. */
array_pop (bash_source_a);
array_pop (bash_lineno_a);
/* FUNCNAME can be unset, and so can potentially be changed by the
sourced file. */
GET_ARRAY_FROM_VAR ("FUNCNAME", nfv, funcname_a);
if (nfv == funcname_v)
array_pop (funcname_a);
# if defined (DEBUGGER)
if ((flags & FEVAL_NOPUSHARGS) == 0)
{
array_pop (bash_argc_a);
array_pop (bash_argv_a);
}
# endif
#endif
/* If we end up with EOF after sourcing a file, which can happen when the file
doesn't end with a newline, pretend that it did. */
if (current_token == yacc_EOF)
push_token ('\n'); /* XXX */
return ((flags & FEVAL_BUILTIN) ? result : 1);
}
@ -322,6 +336,23 @@ maybe_execute_file (fname, force_noninteractive)
return result;
}
int
force_execute_file (fname, force_noninteractive)
const char *fname;
int force_noninteractive;
{
char *filename;
int result, flags;
filename = bash_tilde_expand (fname, 0);
flags = 0;
if (force_noninteractive)
flags |= FEVAL_NONINT;
result = _evalfile (filename, flags);
free (filename);
return result;
}
#if defined (HISTORY)
int
fc_execute_file (filename)
@ -330,8 +361,9 @@ fc_execute_file (filename)
int flags;
/* We want these commands to show up in the history list if
remember_on_history is set. */
flags = FEVAL_ENOENTOK|FEVAL_HISTORY|FEVAL_REGFILE;
remember_on_history is set. We use FEVAL_BUILTIN to return
the result of parse_and_execute. */
flags = FEVAL_ENOENTOK|FEVAL_HISTORY|FEVAL_REGFILE|FEVAL_BUILTIN;
return (_evalfile (filename, flags));
}
#endif /* HISTORY */

View file

@ -1,6 +1,6 @@
/* evalstring.c - evaluate a string as one or more shell commands. */
/* Copyright (C) 1996-2012 Free Software Foundation, Inc.
/* Copyright (C) 1996-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -96,6 +96,38 @@ restore_lastcom (x)
the_printed_command_except_trap = x;
}
int
should_suppress_fork (command)
COMMAND *command;
{
return (startup_state == 2 && parse_and_execute_level == 1 &&
running_trap == 0 &&
*bash_input.location.string == '\0' &&
command->type == cm_simple &&
#if 0
signal_is_trapped (EXIT_TRAP) == 0 &&
signal_is_trapped (ERROR_TRAP) == 0 &&
#else
any_signals_trapped () < 0 &&
#endif
command->redirects == 0 && command->value.Simple->redirects == 0 &&
((command->flags & CMD_TIME_PIPELINE) == 0) &&
((command->flags & CMD_INVERT_RETURN) == 0));
}
void
optimize_fork (command)
COMMAND *command;
{
if (command->type == cm_connection &&
(command->value.Connection->connector == AND_AND || command->value.Connection->connector == OR_OR) &&
should_suppress_fork (command->value.Connection->second))
{
command->value.Connection->second->flags |= CMD_NO_FORK;
command->value.Connection->second->value.Simple->flags |= CMD_NO_FORK;
}
}
/* How to force parse_and_execute () to clean up after itself. */
void
parse_and_execute_cleanup ()
@ -141,8 +173,7 @@ parse_prologue (string, flags, tag)
else
unwind_protect_int (remember_on_history); /* can be used in scripts */
# if defined (BANG_HISTORY)
if (interactive_shell)
unwind_protect_int (history_expansion_inhibited);
unwind_protect_int (history_expansion_inhibited);
# endif /* BANG_HISTORY */
#endif /* HISTORY */
@ -172,6 +203,10 @@ parse_prologue (string, flags, tag)
#if defined (HISTORY)
if (flags & SEVAL_NOHIST)
bash_history_disable ();
# if defined (BANG_HISTORY)
if (flags & SEVAL_NOHISTEXP)
history_expansion_inhibited = 1;
# endif /* BANG_HISTORY */
#endif /* HISTORY */
}
@ -184,6 +219,7 @@ parse_prologue (string, flags, tag)
(flags & SEVAL_NOHIST) -> call bash_history_disable ()
(flags & SEVAL_NOFREE) -> don't free STRING when finished
(flags & SEVAL_RESETLINE) -> reset line_number to 1
(flags & SEVAL_NOHISTEXP) -> history_expansion_inhibited -> 1
*/
int
@ -205,8 +241,8 @@ parse_and_execute (string, from_file, flags)
#if defined (HAVE_POSIX_SIGNALS)
/* If we longjmp and are going to go on, use this to restore signal mask */
sigemptyset (&pe_sigmask);
sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &pe_sigmask);
sigemptyset ((sigset_t *)&pe_sigmask);
sigprocmask (SIG_BLOCK, (sigset_t *)NULL, (sigset_t *)&pe_sigmask);
#endif
/* Reset the line number if the caller wants us to. If we don't reset the
@ -226,7 +262,12 @@ parse_and_execute (string, from_file, flags)
code = should_jump_to_top_level = 0;
last_result = EXECUTION_SUCCESS;
/* We need to reset enough of the token state so we can start fresh. */
if (current_token == yacc_EOF)
current_token = '\n'; /* reset_parser() ? */
with_input_from_string (string, from_file);
clear_shell_input_line ();
while (*(bash_input.location.string))
{
command = (COMMAND *)NULL;
@ -285,7 +326,7 @@ parse_and_execute (string, from_file, flags)
dispose_command (command); /* pe_dispose does this */
#endif
#if defined (HAVE_POSIX_SIGNALS)
sigprocmask (SIG_SETMASK, &pe_sigmask, (sigset_t *)NULL);
sigprocmask (SIG_SETMASK, (sigset_t *)&pe_sigmask, (sigset_t *)NULL);
#endif
continue;
}
@ -349,22 +390,18 @@ parse_and_execute (string, from_file, flags)
* we're not going to run the exit trap AND
* we have a simple command without redirections AND
* the command is not being timed AND
* the command's return status is not being inverted
* the command's return status is not being inverted AND
* there aren't any traps in effect
* THEN
* tell the execution code that we don't need to fork
*/
if (startup_state == 2 && parse_and_execute_level == 1 &&
running_trap == 0 &&
*bash_input.location.string == '\0' &&
command->type == cm_simple &&
signal_is_trapped (EXIT_TRAP) == 0 &&
command->redirects == 0 && command->value.Simple->redirects == 0 &&
((command->flags & CMD_TIME_PIPELINE) == 0) &&
((command->flags & CMD_INVERT_RETURN) == 0))
if (should_suppress_fork (command))
{
command->flags |= CMD_NO_FORK;
command->value.Simple->flags |= CMD_NO_FORK;
}
else if (command->type == cm_connection)
optimize_fork (command);
#endif /* ONESHOT */
/* See if this is a candidate for $( <file ). */
@ -457,11 +494,11 @@ parse_string (string, from_file, flags, endp)
#if defined (HAVE_POSIX_SIGNALS)
/* If we longjmp and are going to go on, use this to restore signal mask */
sigemptyset (&ps_sigmask);
sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &ps_sigmask);
sigemptyset ((sigset_t *)&ps_sigmask);
sigprocmask (SIG_BLOCK, (sigset_t *)NULL, (sigset_t *)&ps_sigmask);
#endif
/* itrace("parse_string: `%s'", string); */
/*itrace("parse_string: `%s'", string);*/
/* Reset the line number if the caller wants us to. If we don't reset the
line number, we have to subtract one, because we will add one just
before executing the next command (resetting the line number sets it to
@ -510,7 +547,7 @@ itrace("parse_string: longjmp executed: code = %d", code);
default:
#if defined (HAVE_POSIX_SIGNALS)
sigprocmask (SIG_SETMASK, &ps_sigmask, (sigset_t *)NULL);
sigprocmask (SIG_SETMASK, (sigset_t *)&ps_sigmask, (sigset_t *)NULL);
#endif
command_error ("parse_string", CMDERR_BADJUMP, code, 0);
break;
@ -547,8 +584,16 @@ itrace("parse_string: longjmp executed: code = %d", code);
run_unwind_frame (PS_TAG);
/* If we return < 0, the caller (xparse_dolparen) will jump_to_top_level for
us, after doing cleanup */
if (should_jump_to_top_level)
jump_to_top_level (code);
{
if (parse_and_execute_level == 0)
top_level_cleanup ();
if (code == DISCARD)
return -DISCARD;
jump_to_top_level (code);
}
return (nc);
}
@ -634,7 +679,7 @@ evalstring (string, from_file, flags)
if (rcatch && return_catch_flag)
{
return_catch_value = r;
longjmp (return_catch, 1);
sh_longjmp (return_catch, 1);
}
}

View file

@ -1,7 +1,7 @@
This file is exec.def, from which is created exec.c.
It implements the builtin "exec" in Bash.
Copyright (C) 1987-2012 Free Software Foundation, Inc.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -31,8 +31,8 @@ any redirections take effect in the current shell.
Options:
-a name pass NAME as the zeroth argument to COMMAND
-c execute COMMAND with an empty environment
-l place a dash in the zeroth argument to COMMAND
-c execute COMMAND with an empty environment
-l place a dash in the zeroth argument to COMMAND
If the command cannot be executed, a non-interactive shell exits, unless
the shell option `execfail' is set.
@ -119,6 +119,7 @@ exec_builtin (list)
case 'a':
argv0 = list_optarg;
break;
CASE_HELPOPT;
default:
builtin_usage ();
return (EX_USAGE);
@ -142,6 +143,7 @@ exec_builtin (list)
#endif /* RESTRICTED_SHELL */
args = strvec_from_word_list (list, 1, 0, (int *)NULL);
env = (char **)0;
/* A command with a slash anywhere in its name is not looked up in $PATH. */
command = absolute_program (args[0]) ? args[0] : search_for_command (args[0], 1);
@ -193,7 +195,10 @@ exec_builtin (list)
adjust_shell_level (-1);
if (cleanenv)
env = (char **)NULL;
{
env = strvec_create (1);
env[0] = (char *)0;
}
else
{
maybe_make_export_env ();
@ -210,6 +215,8 @@ exec_builtin (list)
#if defined (JOB_CONTROL)
if (subshell_environment == 0)
end_job_control ();
if (interactive || job_control)
default_tty_job_signals (); /* undo initialize_job_signals */
#endif /* JOB_CONTROL */
exit_value = shell_execve (command, args, env);
@ -240,6 +247,9 @@ failed_exec:
if (args)
strvec_dispose (args);
if (env && env != export_env)
strvec_dispose (env);
initialize_traps ();
initialize_signals (1);

View file

@ -60,6 +60,8 @@ int
exit_builtin (list)
WORD_LIST *list;
{
CHECK_HELPOPT (list);
if (interactive)
{
fprintf (stderr, login_shell ? _("logout\n") : "exit\n");
@ -83,6 +85,8 @@ int
logout_builtin (list)
WORD_LIST *list;
{
CHECK_HELPOPT (list);
if (login_shell == 0 /* && interactive */)
{
builtin_error (_("not login shell: use `exit'"));

View file

@ -1,7 +1,7 @@
This file is fc.def, from which is created fc.c.
It implements the builtin "fc" in Bash.
Copyright (C) 1987-2011 Free Software Foundation, Inc.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -158,6 +158,12 @@ static char *fc_readline __P((FILE *));
static void fc_addhist __P((char *));
#endif
static void
set_verbose_flag ()
{
echo_input_at_read = verbose_flag;
}
/* String to execute on a file that we want to edit. */
#define FC_EDIT_COMMAND "${FCEDIT:-${EDITOR:-vi}}"
#if defined (STRICT_POSIX)
@ -212,6 +218,7 @@ fc_builtin (list)
ename = list_optarg;
break;
CASE_HELPOPT;
default:
builtin_usage ();
return (EX_USAGE);
@ -440,6 +447,13 @@ fc_builtin (list)
return (EXECUTION_FAILURE);
}
#if defined (READLINE)
/* If we're executing as part of a dispatched readline commnand like
{emacs,vi}_edit_and_execute_command, the readline state will indicate it.
We could remove the partial command from the history, but ksh93 doesn't
so we stay compatible. */
#endif
/* Make sure parse_and_execute doesn't turn this off, even though a
call to parse_and_execute farther up the function call stack (e.g.,
if this is called by vi_edit_and_execute_command) may have already
@ -451,11 +465,10 @@ fc_builtin (list)
begin_unwind_frame ("fc builtin");
add_unwind_protect ((Function *)xfree, fn);
add_unwind_protect (unlink, fn);
unwind_protect_int (echo_input_at_read);
add_unwind_protect (set_verbose_flag, (char *)NULL);
echo_input_at_read = 1;
retval = fc_execute_file (fn);
retval = fc_execute_file (fn);
run_unwind_frame ("fc builtin");
return (retval);

View file

@ -63,6 +63,8 @@ fg_builtin (list)
int fg_bit;
register WORD_LIST *t;
CHECK_HELPOPT (list);
if (job_control == 0)
{
sh_nojobs ((char *)NULL);
@ -105,6 +107,8 @@ bg_builtin (list)
{
int r;
CHECK_HELPOPT (list);
if (job_control == 0)
{
sh_nojobs ((char *)NULL);

View file

@ -223,6 +223,52 @@ sh_getopt_restore_state (argv)
nextchar = argv[sh_curopt] + sh_charindex;
}
sh_getopt_state_t *
sh_getopt_alloc_istate ()
{
sh_getopt_state_t *ret;
ret = (sh_getopt_state_t *)xmalloc (sizeof (sh_getopt_state_t));
return ret;
}
void
sh_getopt_dispose_istate (gs)
sh_getopt_state_t *gs;
{
free (gs);
}
sh_getopt_state_t *
sh_getopt_save_istate ()
{
sh_getopt_state_t *ret;
ret = sh_getopt_alloc_istate ();
ret->gs_optarg = sh_optarg;
ret->gs_optind = sh_optind;
ret->gs_curopt = sh_curopt;
ret->gs_nextchar = nextchar; /* XXX */
ret->gs_charindex = sh_charindex;
ret->gs_flags = 0; /* XXX for later use */
return ret;
}
void
sh_getopt_restore_istate (state)
sh_getopt_state_t *state;
{
sh_optarg = state->gs_optarg;
sh_optind = state->gs_optind;
sh_curopt = state->gs_curopt;
nextchar = state->gs_nextchar; /* XXX - probably not usable */
sh_charindex = state->gs_charindex;
sh_getopt_dispose_istate (state);
}
#if 0
void
sh_getopt_debug_restore_state (argv)

View file

@ -60,6 +60,23 @@ extern int sh_optopt;
extern int sh_badopt;
extern int sh_getopt __P((int, char *const *, const char *));
typedef struct sh_getopt_state
{
char *gs_optarg;
int gs_optind;
int gs_curopt;
char *gs_nextchar;
int gs_charindex;
int gs_flags;
} sh_getopt_state_t;
extern void sh_getopt_restore_state __P((char **));
extern sh_getopt_state_t *sh_getopt_alloc_istate __P((void));
extern void sh_getopt_dispose_istate __P((sh_getopt_state_t *));
extern sh_getopt_state_t *sh_getopt_save_istate __P((void));
extern void sh_getopt_restore_istate __P((sh_getopt_state_t *));
#endif /* _SH_GETOPT_H */

View file

@ -1,7 +1,7 @@
This file is getopts.def, from which is created getopts.c.
It implements the builtin "getopts" in Bash.
Copyright (C) 1987-2004 Free Software Foundation, Inc.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -74,6 +74,7 @@ $END
#endif
#include "../bashansi.h"
#include "../bashintl.h"
#include "../shell.h"
#include "common.h"
@ -86,6 +87,7 @@ $END
extern char *this_command_name;
static int getopts_unbind_variable __P((char *));
static int getopts_bind_variable __P((char *, char *));
static int dogetopts __P((int, char **));
@ -99,6 +101,17 @@ getopts_reset (newind)
sh_badopt = 0;
}
static int
getopts_unbind_variable (name)
char *name;
{
#if 0
return (unbind_variable (name));
#else
return (unbind_variable_noref (name));
#endif
}
static int
getopts_bind_variable (name, value)
char *name, *value;
@ -253,7 +266,7 @@ dogetopts (argc, argv)
if (ret == G_EOF)
{
unbind_variable ("OPTARG");
getopts_unbind_variable ("OPTARG");
getopts_bind_variable (name, "?");
return (EXECUTION_FAILURE);
}
@ -270,7 +283,7 @@ dogetopts (argc, argv)
bind_variable ("OPTARG", strval, 0);
}
else
unbind_variable ("OPTARG");
getopts_unbind_variable ("OPTARG");
return (ret);
}
@ -289,7 +302,7 @@ dogetopts (argc, argv)
else
{
ret = getopts_bind_variable (name, "?");
unbind_variable ("OPTARG");
getopts_unbind_variable ("OPTARG");
}
return (ret);
}
@ -316,9 +329,12 @@ getopts_builtin (list)
}
reset_internal_getopt ();
if (internal_getopt (list, "") != -1)
if ((ret = internal_getopt (list, "")) != -1)
{
builtin_usage ();
if (ret == GETOPT_HELP)
builtin_help ();
else
builtin_usage ();
return (EX_USAGE);
}
list = loptend;

View file

@ -1,7 +1,7 @@
This file is hash.def, from which is created hash.c.
It implements the builtin "hash" in Bash.
Copyright (C) 1987-2013 Free Software Foundation, Inc.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -29,15 +29,15 @@ Determine and remember the full pathname of each command NAME. If
no arguments are given, information about remembered commands is displayed.
Options:
-d forget the remembered location of each NAME
-l display in a format that may be reused as input
-d forget the remembered location of each NAME
-l display in a format that may be reused as input
-p pathname use PATHNAME as the full pathname of NAME
-r forget all remembered locations
-t print the remembered location of each NAME, preceding
-r forget all remembered locations
-t print the remembered location of each NAME, preceding
each location with the corresponding NAME if multiple
NAMEs are given
Arguments:
NAME Each NAME is searched for in $PATH and added to the list
NAME Each NAME is searched for in $PATH and added to the list
of remembered commands.
Exit Status:
@ -115,6 +115,7 @@ hash_builtin (list)
case 't':
list_targets = 1;
break;
CASE_HELPOPT;
default:
builtin_usage ();
return (EX_USAGE);
@ -230,7 +231,15 @@ static int
print_portable_hash_info (item)
BUCKET_CONTENTS *item;
{
printf ("builtin hash -p %s %s\n", pathdata(item)->path, item->key);
char *fp, *fn;
fp = printable_filename (pathdata(item)->path, 1);
fn = printable_filename (item->key, 1);
printf ("builtin hash -p %s %s\n", fp, fn);
if (fp != pathdata(item)->path)
free (fp);
if (fn != item->key)
free (fn);
return 0;
}

View file

@ -1,7 +1,7 @@
This file is help.def, from which is created help.c.
It implements the builtin "help" in Bash.
Copyright (C) 1987-2013 Free Software Foundation, Inc.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -34,7 +34,7 @@ Options:
-d output short description for each topic
-m display usage in pseudo-manpage format
-s output only a short usage synopsis for each topic matching
PATTERN
PATTERN
Arguments:
PATTERN Pattern specifiying a help topic
@ -58,6 +58,7 @@ $END
#include <errno.h>
#include <filecntl.h>
#include <stddef.h>
#include "../bashintl.h"
@ -77,6 +78,9 @@ extern int errno;
extern const char * const bash_copyright;
extern const char * const bash_license;
extern char *this_command_name;
extern struct builtin *current_builtin;
static void show_builtin_command_help __P((void));
static int open_helpfile __P((char *));
static void show_desc __P((char *, int));
@ -109,6 +113,7 @@ help_builtin (list)
case 's':
sflag = 1;
break;
CASE_HELPOPT;
default:
builtin_usage ();
return (EX_USAGE);
@ -187,6 +192,28 @@ help_builtin (list)
return (EXECUTION_SUCCESS);
}
void
builtin_help ()
{
int ind;
ptrdiff_t d;
current_builtin = builtin_address_internal (this_command_name, 0);
if (current_builtin == 0)
return;
d = current_builtin - shell_builtins;
#if defined (__STDC__)
ind = (int)d;
#else
ind = (int)d / sizeof (struct builtin);
#endif
printf ("%s: %s\n", this_command_name, _(shell_builtins[ind].short_doc));
show_longdoc (ind);
}
static int
open_helpfile (name)
char *name;
@ -348,7 +375,7 @@ dispcolumn (i, buf, bufsize, width, height)
int width, height;
{
int j;
int displen;
int dispcols;
char *helpdoc;
/* first column */
@ -365,9 +392,9 @@ dispcolumn (i, buf, bufsize, width, height)
return;
}
displen = strlen (buf);
dispcols = strlen (buf);
/* two spaces */
for (j = displen; j < width; j++)
for (j = dispcols; j < width; j++)
putc (' ', stdout);
/* second column */
@ -390,7 +417,7 @@ wdispcolumn (i, buf, bufsize, width, height)
int width, height;
{
int j;
int displen;
int dispcols, dispchars;
char *helpdoc;
wchar_t *wcstr;
size_t slen, n;
@ -420,23 +447,29 @@ wdispcolumn (i, buf, bufsize, width, height)
if (wcstr[j] == L'\n' || wcstr[j] == L'\t')
wcstr[j] = L' ';
displen = wcsnwidth (wcstr+1, slen, width - 2) + 1; /* +1 for ' ' or '*' */
/* dispchars == number of characters that will be displayed */
dispchars = wcsnwidth (wcstr+1, slen, width - 2);
/* dispcols == number of columns required to display DISPCHARS */
dispcols = wcswidth (wcstr+1, dispchars) + 1; /* +1 for ' ' or '*' */
wcstr[0] = (shell_builtins[i].flags & BUILTIN_ENABLED) ? L' ' : L'*';
/* This assumes each wide char takes up one column position when displayed */
wcstr[width - 2] = L'>'; /* indicate truncation */
wcstr[width - 1] = L'\0';
if (dispcols >= width-2)
{
wcstr[dispchars] = L'>'; /* indicate truncation */
wcstr[dispchars+1] = L'\0';
}
printf ("%ls", wcstr);
if (((i << 1) >= num_shell_builtins) || (i+height >= num_shell_builtins))
{
printf ("\n");
free (wcstr);
return;
}
/* at least one space */
for (j = displen; j < width; j++)
for (j = dispcols; j < width; j++)
putc (' ', stdout);
/* second column */
@ -446,6 +479,7 @@ wdispcolumn (i, buf, bufsize, width, height)
{
/* for now */
printf ("%c%s\n", (shell_builtins[i+height].flags & BUILTIN_ENABLED) ? ' ' : '*', helpdoc);
free (wcstr);
return;
}
@ -460,13 +494,20 @@ wdispcolumn (i, buf, bufsize, width, height)
if (wcstr[j] == L'\n' || wcstr[j] == L'\t')
wcstr[j] = L' ';
displen = wcsnwidth (wcstr+1, slen, width - 2);
/* dispchars == number of characters that will be displayed */
dispchars = wcsnwidth (wcstr+1, slen, width - 2);
dispcols = wcswidth (wcstr+1, dispchars) + 1; /* +1 for ' ' or '*' */
wcstr[0] = (shell_builtins[i+height].flags & BUILTIN_ENABLED) ? L' ' : L'*';
/* This assumes each wide char takes up one column position when displayed */
wcstr[width - 3] = L'>'; /* indicate truncation */
wcstr[width - 2] = L'\0';
/* The dispchars-1 is there for terminals that behave strangely when you
have \n in the nth column for terminal width n; this is what bash-4.3
did. */
if (dispcols >= width - 2)
{
wcstr[dispchars-1] = L'>'; /* indicate truncation */
wcstr[dispchars] = L'\0';
}
printf ("%ls\n", wcstr);

View file

@ -1,7 +1,7 @@
This file is history.def, from which is created history.c.
It implements the builtin "history" in Bash.
Copyright (C) 1987-2009 Free Software Foundation, Inc.
Copyright (C) 1987-2016 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -31,23 +31,23 @@ entry with a `*'. An argument of N lists only the last N entries.
Options:
-c clear the history list by deleting all of the entries
-d offset delete the history entry at offset OFFSET.
-d offset delete the history entry at position OFFSET.
-a append history lines from this session to the history file
-n read all history lines not already read from the history file
and append them to the history list
-r read the history file and append the contents to the history
list
list
-w write the current history to the history file
and append them to the history list
-p perform history expansion on each ARG and display the result
without storing it in the history list
without storing it in the history list
-s append the ARGs to the history list as a single entry
If FILENAME is given, it is used as the history file. Otherwise,
if $HISTFILE has a value, that is used, else ~/.bash_history.
if HISTFILE has a value, that is used, else ~/.bash_history.
If the $HISTTIMEFORMAT variable is set and not null, its value is used
If the HISTTIMEFORMAT variable is set and not null, its value is used
as a format string for strftime(3) to print the time stamp associated
with each displayed history entry. No time stamps are printed otherwise.
@ -141,6 +141,7 @@ history_builtin (list)
flags |= PFLAG;
#endif
break;
CASE_HELPOPT;
default:
builtin_usage ();
return (EX_USAGE);
@ -208,7 +209,11 @@ history_builtin (list)
else if (flags & WFLAG) /* Write entire history. */
result = write_history (filename);
else if (flags & RFLAG) /* Read entire file. */
result = read_history (filename);
{
result = read_history (filename);
history_lines_in_file = history_lines_read_from_file;
/* history_lines_in_file = where_history () + history_base - 1; */
}
else if (flags & NFLAG) /* Read `new' history from file. */
{
/* Read all of the lines in the file that we haven't already read. */
@ -219,7 +224,8 @@ history_builtin (list)
result = read_history_range (filename, history_lines_in_file, -1);
using_history ();
history_lines_in_file = where_history ();
history_lines_in_file = history_lines_read_from_file;
/* history_lines_in_file = where_history () + history_base - 1; */
/* If we're rewriting the history file at shell exit rather than just
appending the lines from this session to it, the question is whether
@ -254,6 +260,9 @@ histtime (hlist, histtimefmt)
t = history_get_time (hlist);
if (t)
strftime (timestr, sizeof (timestr), histtimefmt, localtime (&t));
else if (hlist->timestamp && hlist->timestamp[0])
snprintf (timestr, sizeof (timestr), _("%s: invalid timestamp"),
(hlist->timestamp[0] == '#') ? hlist->timestamp + 1: hlist->timestamp);
else
strcpy (timestr, "??");
return timestr;

View file

@ -1,7 +1,7 @@
This file is jobs.def, from which is created jobs.c.
It implements the builtins "jobs" and "disown" in Bash.
Copyright (C) 1987-2009 Free Software Foundation, Inc.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -32,7 +32,7 @@ Without options, the status of all active jobs is displayed.
Options:
-l lists process IDs in addition to the normal information
-n lists only processes that have changed status since the last
notification
notification
-p lists process IDs only
-r restrict output to running jobs
-s restrict output to stopped jobs
@ -118,6 +118,7 @@ jobs_builtin (list)
state = JSTATE_STOPPED;
break;
CASE_HELPOPT;
default:
builtin_usage ();
return (EX_USAGE);
@ -212,7 +213,7 @@ execute_list_with_replacements (list)
$BUILTIN disown
$FUNCTION disown_builtin
$DEPENDS_ON JOB_CONTROL
$SHORT_DOC disown [-h] [-ar] [jobspec ...]
$SHORT_DOC disown [-h] [-ar] [jobspec ... | pid ...]
Remove jobs from current shell.
Removes each JOBSPEC argument from the table of active jobs. Without
@ -221,7 +222,7 @@ any JOBSPECs, the shell uses its notion of the current job.
Options:
-a remove all jobs if JOBSPEC is not supplied
-h mark each JOBSPEC so that SIGHUP is not sent to the job if the
shell receives a SIGHUP
shell receives a SIGHUP
-r remove only running jobs
Exit Status:
@ -252,6 +253,7 @@ disown_builtin (list)
case 'r':
running_jobs = 1;
break;
CASE_HELPOPT;
default:
builtin_usage ();
return (EX_USAGE);

View file

@ -1,7 +1,7 @@
This file is kill.def, from which is created kill.c.
It implements the builtin "kill" in Bash.
Copyright (C) 1987-2010 Free Software Foundation, Inc.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -33,7 +33,8 @@ Options:
-s sig SIG is a signal name
-n sig SIG is a signal number
-l list the signal names; if arguments follow `-l' they are
assumed to be signal numbers for which names should be listed
assumed to be signal numbers for which names should be listed
-L synonym for -l
Kill is a shell builtin for two reasons: it allows job IDs to be used
instead of process IDs, and allows processes to be killed if the limit
@ -96,6 +97,7 @@ kill_builtin (list)
builtin_usage ();
return (EX_USAGE);
}
CHECK_HELPOPT (list);
any_succeeded = listing = saw_signal = 0;
sig = SIGTERM;
@ -107,7 +109,7 @@ kill_builtin (list)
{
word = list->word->word;
if (ISOPTION (word, 'l'))
if (ISOPTION (word, 'l') || ISOPTION (word, 'L'))
{
listing++;
list = list->next;

View file

@ -86,6 +86,8 @@ let_builtin (list)
intmax_t ret;
int expok;
CHECK_HELPOPT (list);
/* Skip over leading `--' argument. */
if (list && list->word && ISOPTION (list->word->word, '-'))
list = list->next;

View file

@ -2,7 +2,7 @@ This file is mapfile.def, from which is created mapfile.c.
It implements the builtin "mapfile" in Bash.
Copyright (C) 2005-2006 Rocky Bernstein for Free Software Foundation, Inc.
Copyright (C) 2008-2012 Free Software Foundation, Inc.
Copyright (C) 2008-2016 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -23,7 +23,7 @@ $PRODUCES mapfile.c
$BUILTIN mapfile
$FUNCTION mapfile_builtin
$SHORT_DOC mapfile [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]
$SHORT_DOC mapfile [-d delim] [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]
Read lines from the standard input into an indexed array variable.
Read lines from the standard input into the indexed array variable ARRAY, or
@ -31,16 +31,18 @@ from file descriptor FD if the -u option is supplied. The variable MAPFILE
is the default ARRAY.
Options:
-n count Copy at most COUNT lines. If COUNT is 0, all lines are copied.
-O origin Begin assigning to ARRAY at index ORIGIN. The default index is 0.
-s count Discard the first COUNT lines read.
-t Remove a trailing newline from each line read.
-u fd Read lines from file descriptor FD instead of the standard input.
-C callback Evaluate CALLBACK each time QUANTUM lines are read.
-c quantum Specify the number of lines read between each call to CALLBACK.
-d delim Use DELIM to terminate lines, instead of newline
-n count Copy at most COUNT lines. If COUNT is 0, all lines are copied
-O origin Begin assigning to ARRAY at index ORIGIN. The default index is 0
-s count Discard the first COUNT lines read
-t Remove a trailing DELIM from each line read (default newline)
-u fd Read lines from file descriptor FD instead of the standard input
-C callback Evaluate CALLBACK each time QUANTUM lines are read
-c quantum Specify the number of lines read between each call to
CALLBACK
Arguments:
ARRAY Array variable name to use for file data.
ARRAY Array variable name to use for file data
If -C is supplied without -c, the default quantum is 5000. When
CALLBACK is evaluated, it is supplied the index of the next array
@ -101,6 +103,8 @@ static int run_callback __P((const char *, unsigned int, const char *));
#define MAPF_CLEARARRAY 0x01
#define MAPF_CHOP 0x02
static int delim;
static int
run_callback (callback, curindex, curline)
const char *callback;
@ -129,21 +133,23 @@ run_callback (callback, curindex, curline)
}
static void
do_chop(line)
char * line;
do_chop(line, delim)
char *line;
unsigned char delim;
{
int length;
length = strlen (line);
if (length && line[length-1] == '\n')
if (length && line[length-1] == delim)
line[length-1] = '\0';
}
static int
mapfile (fd, line_count_goal, origin, nskip, callback_quantum, callback, array_name, flags)
mapfile (fd, line_count_goal, origin, nskip, callback_quantum, callback, array_name, delim, flags)
int fd;
long line_count_goal, origin, nskip, callback_quantum;
char *callback, *array_name;
int delim;
int flags;
{
char *line;
@ -184,11 +190,14 @@ mapfile (fd, line_count_goal, origin, nskip, callback_quantum, callback, array_n
unbuffered_read = 1;
#endif
if (delim != '\n')
unbuffered_read = 1;
zreset ();
/* Skip any lines at beginning of file? */
for (line_count = 0; line_count < nskip; line_count++)
if (zgetline (fd, &line, &line_length, unbuffered_read) < 0)
if (zgetline (fd, &line, &line_length, delim, unbuffered_read) < 0)
break;
line = 0;
@ -196,12 +205,12 @@ mapfile (fd, line_count_goal, origin, nskip, callback_quantum, callback, array_n
/* Reset the buffer for bash own stream */
for (array_index = origin, line_count = 1;
zgetline (fd, &line, &line_length, unbuffered_read) != -1;
zgetline (fd, &line, &line_length, delim, unbuffered_read) != -1;
array_index++)
{
/* Remove trailing newlines? */
if (flags & MAPF_CHOP)
do_chop (line);
do_chop (line, delim);
/* Has a callback been registered and if so is it time to call it? */
if (callback && line_count && (line_count % callback_quantum) == 0)
@ -246,12 +255,16 @@ mapfile_builtin (list)
flags = MAPF_CLEARARRAY;
callback_quantum = DEFAULT_QUANTUM;
callback = 0;
delim = '\n';
reset_internal_getopt ();
while ((opt = internal_getopt (list, "u:n:O:tC:c:s:")) != -1)
while ((opt = internal_getopt (list, "d:u:n:O:tC:c:s:")) != -1)
{
switch (opt)
{
case 'd':
delim = *list_optarg;
break;
case 'u':
code = legal_number (list_optarg, &intval);
if (code == 0 || intval < 0 || intval != (int)intval)
@ -317,6 +330,7 @@ mapfile_builtin (list)
else
nskip = intval;
break;
CASE_HELPOPT;
default:
builtin_usage ();
return (EX_USAGE);
@ -339,13 +353,13 @@ mapfile_builtin (list)
else
array_name = list->word->word;
if (legal_identifier (array_name) == 0 && valid_array_reference (array_name) == 0)
if (legal_identifier (array_name) == 0)
{
sh_invalidid (array_name);
return (EXECUTION_FAILURE);
}
return mapfile (fd, lines, origin, nskip, callback_quantum, callback, array_name, flags);
return mapfile (fd, lines, origin, nskip, callback_quantum, callback, array_name, delim, flags);
}
#else

View file

@ -1,7 +1,7 @@
/* mkbuiltins.c - Create builtins.c, builtext.h, and builtdoc.c from
a single source file called builtins.def. */
/* Copyright (C) 1987-2011 Free Software Foundation, Inc.
/* Copyright (C) 1987-2016 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -71,7 +71,8 @@ extern char *strcpy ();
/* Flag values that builtins can have. */
#define BUILTIN_FLAG_SPECIAL 0x01
#define BUILTIN_FLAG_ASSIGNMENT 0x02
#define BUILTIN_FLAG_POSIX_BUILTIN 0x04
#define BUILTIN_FLAG_LOCALVAR 0x04
#define BUILTIN_FLAG_POSIX_BUILTIN 0x08
#define BASE_INDENT 4
@ -159,6 +160,11 @@ char *assignment_builtins[] =
(char *)NULL
};
char *localvar_builtins[] =
{
"declare", "local", "typeset", (char *)NULL
};
/* The builtin commands that are special to the POSIX search order. */
char *posix_builtins[] =
{
@ -170,6 +176,7 @@ char *posix_builtins[] =
/* Forward declarations. */
static int is_special_builtin ();
static int is_assignment_builtin ();
static int is_localvar_builtin ();
static int is_posix_builtin ();
#if !defined (HAVE_RENAME)
@ -820,6 +827,8 @@ builtin_handler (self, defs, arg)
new->flags |= BUILTIN_FLAG_SPECIAL;
if (is_assignment_builtin (name))
new->flags |= BUILTIN_FLAG_ASSIGNMENT;
if (is_localvar_builtin (name))
new->flags |= BUILTIN_FLAG_LOCALVAR;
if (is_posix_builtin (name))
new->flags |= BUILTIN_FLAG_POSIX_BUILTIN;
@ -1102,7 +1111,7 @@ char *structfile_header[] = {
"/* This file is manufactured by ./mkbuiltins, and should not be",
" edited by hand. See the source to mkbuiltins for details. */",
"",
"/* Copyright (C) 1987-2012 Free Software Foundation, Inc.",
"/* Copyright (C) 1987-2015 Free Software Foundation, Inc.",
"",
" This file is part of GNU Bash, the Bourne Again SHell.",
"",
@ -1132,6 +1141,8 @@ char *structfile_header[] = {
" the list of shell reserved control structures, like `if' and `while'.",
" The end of the list is denoted with a NULL name field. */",
"",
"/* TRANSLATORS: Please do not translate command names in descriptions */",
"",
"#include \"../builtins.h\"",
(char *)NULL
};
@ -1239,23 +1250,36 @@ write_builtins (defs, structfile, externfile)
else
fprintf (structfile, "(sh_builtin_func_t *)0x0, ");
fprintf (structfile, "%s%s%s%s, %s_doc,\n",
fprintf (structfile, "%s%s%s%s%s, %s_doc,\n",
"BUILTIN_ENABLED | STATIC_BUILTIN",
(builtin->flags & BUILTIN_FLAG_SPECIAL) ? " | SPECIAL_BUILTIN" : "",
(builtin->flags & BUILTIN_FLAG_ASSIGNMENT) ? " | ASSIGNMENT_BUILTIN" : "",
(builtin->flags & BUILTIN_FLAG_LOCALVAR) ? " | LOCALVAR_BUILTIN" : "",
(builtin->flags & BUILTIN_FLAG_POSIX_BUILTIN) ? " | POSIX_BUILTIN" : "",
document_name (builtin));
if (inhibit_functions)
fprintf
(structfile, " N_(\"%s\"), \"%s\" },\n",
builtin->shortdoc ? builtin->shortdoc : builtin->name,
document_name (builtin));
/* Don't translate short document summaries that are identical
to command names */
if (builtin->shortdoc && strcmp (builtin->name, builtin->shortdoc) == 0)
{
if (inhibit_functions)
fprintf (structfile, " \"%s\", \"%s\" },\n",
builtin->shortdoc ? builtin->shortdoc : builtin->name,
document_name (builtin));
else
fprintf (structfile, " \"%s\", (char *)NULL },\n",
builtin->shortdoc ? builtin->shortdoc : builtin->name);
}
else
fprintf
(structfile, " N_(\"%s\"), (char *)NULL },\n",
builtin->shortdoc ? builtin->shortdoc : builtin->name);
{
if (inhibit_functions)
fprintf (structfile, " N_(\"%s\"), \"%s\" },\n",
builtin->shortdoc ? builtin->shortdoc : builtin->name,
document_name (builtin));
else
fprintf (structfile, " N_(\"%s\"), (char *)NULL },\n",
builtin->shortdoc ? builtin->shortdoc : builtin->name);
}
}
if (structfile || separate_helpfiles)
@ -1607,6 +1631,13 @@ is_assignment_builtin (name)
return (_find_in_table (name, assignment_builtins));
}
static int
is_localvar_builtin (name)
char *name;
{
return (_find_in_table (name, localvar_builtins));
}
static int
is_posix_builtin (name)
char *name;

View file

@ -1,7 +1,7 @@
This file is printf.def, from which is created printf.c.
It implements the builtin "printf" in Bash.
Copyright (C) 1997-2010 Free Software Foundation, Inc.
Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -40,8 +40,8 @@ printf interprets:
%b expand backslash escape sequences in the corresponding argument
%q quote the argument in a way that can be reused as shell input
%(fmt)T output the date-time string resulting from using FMT as a format
string for strftime(3)
%(fmt)T output the date-time string resulting from using FMT as a format
string for strftime(3)
The format is re-used as necessary to consume all of the arguments. If
there are fewer arguments than the format requires, extra format
@ -116,6 +116,7 @@ extern int errno;
vbadd (b, 1); \
else \
putchar (c); \
QUIT; \
} while (0)
#define PF(f, func) \
@ -131,6 +132,7 @@ extern int errno;
else \
nw = vflag ? vbprintf (f, func) : printf (f, func); \
tw += nw; \
QUIT; \
if (ferror (stdout)) \
{ \
sh_wrerror (); \
@ -143,6 +145,7 @@ extern int errno;
#define PRETURN(value) \
do \
{ \
QUIT; \
if (vflag) \
{ \
bind_printf_variable (vname, vbuf, 0); \
@ -162,9 +165,9 @@ extern int errno;
} \
else if (vbuf) \
vbuf[0] = 0; \
terminate_immediately--; \
if (ferror (stdout) == 0) \
fflush (stdout); \
QUIT; \
if (ferror (stdout)) \
{ \
sh_wrerror (); \
@ -255,7 +258,7 @@ printf_builtin (list)
case 'v':
vname = list_optarg;
#if defined (ARRAY_VARS)
if (legal_identifier (vname) || valid_array_reference (vname))
if (legal_identifier (vname) || valid_array_reference (vname, 0))
#else
if (legal_identifier (vname))
#endif
@ -273,6 +276,7 @@ printf_builtin (list)
return (EX_USAGE);
}
break;
CASE_HELPOPT;
default:
builtin_usage ();
return (EX_USAGE);
@ -286,6 +290,14 @@ printf_builtin (list)
return (EX_USAGE);
}
/* Allow printf -v var "" to act like var="" */
if (vflag && list->word->word && list->word->word[0] == '\0')
{
bind_printf_variable (vname, "", 0);
stupidly_hack_special_variables (vname);
return (EXECUTION_SUCCESS);
}
if (list->word->word == 0 || list->word->word[0] == '\0')
return (EXECUTION_SUCCESS);
@ -298,8 +310,6 @@ printf_builtin (list)
if (format == 0 || *format == 0)
return (EXECUTION_SUCCESS);
terminate_immediately++;
/* Basic algorithm is to scan the format string for conversion
specifications -- once one is found, find out if the field
width or precision is a '*'; if it is, gather up value. Note,
@ -409,6 +419,7 @@ printf_builtin (list)
modstart[0] = convch;
modstart[1] = '\0';
QUIT;
switch(convch)
{
case 'c':
@ -759,6 +770,8 @@ printstr (fmt, string, len, fieldwidth, precision)
/* Error if precision > INT_MAX here? */
pr = (mpr < 0 || mpr > INT_MAX) ? INT_MAX : mpr;
}
else
pr = 0; /* "a null digit string is treated as zero" */
}
#if 0
@ -1045,7 +1058,7 @@ vbprintf (format, va_alist)
#ifdef DEBUG
if (strlen (vbuf) != vblen)
internal_error ("printf:vbadd: vblen (%d) != strlen (vbuf) (%d)", vblen, (int)strlen (vbuf));
internal_error ("printf:vbprintf: vblen (%d) != strlen (vbuf) (%d)", vblen, (int)strlen (vbuf));
#endif
return (blen);
@ -1255,7 +1268,7 @@ bind_printf_variable (name, value, flags)
SHELL_VAR *v;
#if defined (ARRAY_VARS)
if (valid_array_reference (name) == 0)
if (valid_array_reference (name, 0) == 0)
v = bind_variable (name, value, flags);
else
v = assign_array_element (name, value, flags);

View file

@ -1,7 +1,7 @@
This file is pushd.def, from which is created pushd.c. It implements the
builtins "pushd", "popd", and "dirs" in Bash.
Copyright (C) 1987-2013 Free Software Foundation, Inc.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -32,19 +32,19 @@ directory. With no arguments, exchanges the top two directories.
Options:
-n Suppresses the normal change of directory when adding
directories to the stack, so only the stack is manipulated.
directories to the stack, so only the stack is manipulated.
Arguments:
+N Rotates the stack so that the Nth directory (counting
from the left of the list shown by `dirs', starting with
zero) is at the top.
from the left of the list shown by `dirs', starting with
zero) is at the top.
-N Rotates the stack so that the Nth directory (counting
from the right of the list shown by `dirs', starting with
zero) is at the top.
from the right of the list shown by `dirs', starting with
zero) is at the top.
dir Adds DIR to the directory stack at the top, making it the
new current working directory.
new current working directory.
The `dirs' builtin displays the directory stack.
@ -64,16 +64,16 @@ the top directory from the stack, and changes to the new top directory.
Options:
-n Suppresses the normal change of directory when removing
directories from the stack, so only the stack is manipulated.
directories from the stack, so only the stack is manipulated.
Arguments:
+N Removes the Nth entry counting from the left of the list
shown by `dirs', starting with zero. For example: `popd +0'
removes the first directory, `popd +1' the second.
shown by `dirs', starting with zero. For example: `popd +0'
removes the first directory, `popd +1' the second.
-N Removes the Nth entry counting from the right of the list
shown by `dirs', starting with zero. For example: `popd -0'
removes the last directory, `popd -1' the next to last.
shown by `dirs', starting with zero. For example: `popd -0'
removes the last directory, `popd -1' the next to last.
The `dirs' builtin displays the directory stack.
@ -95,17 +95,19 @@ back up through the list with the `popd' command.
Options:
-c clear the directory stack by deleting all of the elements
-l do not print tilde-prefixed versions of directories relative
to your home directory
to your home directory
-p print the directory stack with one entry per line
-v print the directory stack with one entry per line prefixed
with its position in the stack
with its position in the stack
Arguments:
+N Displays the Nth entry counting from the left of the list shown by
dirs when invoked without options, starting with zero.
+N Displays the Nth entry counting from the left of the list
shown by dirs when invoked without options, starting with
zero.
-N Displays the Nth entry counting from the right of the list shown by
dirs when invoked without options, starting with zero.
-N Displays the Nth entry counting from the right of the list
shown by dirs when invoked without options, starting with
zero.
Exit Status:
Returns success unless an invalid option is supplied or an error occurs.
@ -178,6 +180,8 @@ pushd_builtin (list)
char direction;
orig_list = list;
CHECK_HELPOPT (list);
if (list && list->word && ISOPTION (list->word->word, '-'))
{
list = list->next;
@ -321,6 +325,8 @@ popd_builtin (list)
char direction;
char *which_word;
CHECK_HELPOPT (list);
which_word = (char *)NULL;
for (flags = 0, which = 0, direction = '+'; list; list = list->next)
{
@ -402,6 +408,7 @@ dirs_builtin (list)
intmax_t i;
char *temp, *w;
CHECK_HELPOPT (list);
for (flags = vflag = index_flag = 0, desired_index = -1, w = ""; list; list = list->next)
{
if (ISOPTION (list->word->word, 'l'))

View file

@ -1,7 +1,7 @@
This file is read.def, from which is created read.c.
It implements the builtin "read" in Bash.
Copyright (C) 1987-2012 Free Software Foundation, Inc.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -39,25 +39,27 @@ Options:
variable ARRAY, starting at zero
-d delim continue until the first character of DELIM is read, rather
than newline
-e use Readline to obtain the line in an interactive shell
-i text Use TEXT as the initial text for Readline
-e use Readline to obtain the line in an interactive shell
-i text use TEXT as the initial text for Readline
-n nchars return after reading NCHARS characters rather than waiting
for a newline, but honor a delimiter if fewer than NCHARS
characters are read before the delimiter
for a newline, but honor a delimiter if fewer than
NCHARS characters are read before the delimiter
-N nchars return only after reading exactly NCHARS characters, unless
EOF is encountered or read times out, ignoring any delimiter
EOF is encountered or read times out, ignoring any
delimiter
-p prompt output the string PROMPT without a trailing newline before
attempting to read
-r do not allow backslashes to escape any characters
-s do not echo input coming from a terminal
-t timeout time out and return failure if a complete line of input is
not read within TIMEOUT seconds. The value of the TMOUT
variable is the default timeout. TIMEOUT may be a
fractional number. If TIMEOUT is 0, read returns immediately,
without trying to read any data, returning success only if
input is available on the specified file descriptor. The
exit status is greater than 128 if the timeout is exceeded
-u fd read from file descriptor FD instead of the standard input
-r do not allow backslashes to escape any characters
-s do not echo input coming from a terminal
-t timeout time out and return failure if a complete line of
input is not read within TIMEOUT seconds. The value of the
TMOUT variable is the default timeout. TIMEOUT may be a
fractional number. If TIMEOUT is 0, read returns
immediately, without trying to read any data, returning
success only if input is available on the specified
file descriptor. The exit status is greater than 128
if the timeout is exceeded
-u fd read from file descriptor FD instead of the standard input
Exit Status:
The return code is zero, unless end-of-file is encountered, read times out
@ -163,8 +165,9 @@ sigalrm (s)
static void
reset_alarm ()
{
set_signal_handler (SIGALRM, old_alrm);
/* Cancel alarm before restoring signal handler. */
falarm (0, 0);
set_signal_handler (SIGALRM, old_alrm);
}
/* Read the value of the shell variables whose names follow.
@ -314,6 +317,7 @@ read_builtin (list)
case 'd':
delim = *list_optarg;
break;
CASE_HELPOPT;
default:
builtin_usage ();
return (EX_USAGE);
@ -333,7 +337,7 @@ read_builtin (list)
/* Convenience: check early whether or not the first of possibly several
variable names is a valid identifier, and bail early if so. */
#if defined (ARRAY_VARS)
if (list && legal_identifier (list->word->word) == 0 && valid_array_reference (list->word->word) == 0)
if (list && legal_identifier (list->word->word) == 0 && valid_array_reference (list->word->word, 0) == 0)
#else
if (list && legal_identifier (list->word->word) == 0)
#endif
@ -793,7 +797,10 @@ assign_vars:
}
else
var = bind_variable ("REPLY", input_string, 0);
VUNSETATTR (var, att_invisible);
if (var == 0 || readonly_p (var) || noassign_p (var))
retval = EXECUTION_FAILURE;
else
VUNSETATTR (var, att_invisible);
xfree (input_string);
return (retval);
@ -812,7 +819,7 @@ assign_vars:
{
varname = list->word->word;
#if defined (ARRAY_VARS)
if (legal_identifier (varname) == 0 && valid_array_reference (varname) == 0)
if (legal_identifier (varname) == 0 && valid_array_reference (varname, 0) == 0)
#else
if (legal_identifier (varname) == 0)
#endif
@ -860,7 +867,7 @@ assign_vars:
/* Now assign the rest of the line to the last variable argument. */
#if defined (ARRAY_VARS)
if (legal_identifier (list->word->word) == 0 && valid_array_reference (list->word->word) == 0)
if (legal_identifier (list->word->word) == 0 && valid_array_reference (list->word->word, 0) == 0)
#else
if (legal_identifier (list->word->word) == 0)
#endif
@ -923,7 +930,7 @@ bind_read_variable (name, value)
SHELL_VAR *v;
#if defined (ARRAY_VARS)
if (valid_array_reference (name) == 0)
if (valid_array_reference (name, 0) == 0)
v = bind_variable (name, value, 0);
else
v = assign_array_element (name, value, 0);

View file

@ -145,7 +145,7 @@ to indices 0 and 1 of an array variable NAME in the executing shell.
The default NAME is "COPROC".
Exit Status:
Returns the exit status of COMMAND.
The coproc command returns an exit status of 0.
$END
$BUILTIN function

View file

@ -1,7 +1,7 @@
This file is return.def, from which is created return.c.
It implements the builtin "return" in Bash.
Copyright (C) 1987-2009 Free Software Foundation, Inc.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -60,16 +60,12 @@ int
return_builtin (list)
WORD_LIST *list;
{
#if 0
if (no_options (list))
return (EX_USAGE);
list = loptend; /* skip over possible `--' */
#endif
CHECK_HELPOPT (list);
return_catch_value = get_exitstat (list);
if (return_catch_flag)
longjmp (return_catch, 1);
sh_longjmp (return_catch, 1);
else
{
builtin_error (_("can only `return' from a function or sourced script"));

View file

@ -1,7 +1,7 @@
This file is set.def, from which is created set.c.
It implements the "set" and "unset" builtins in Bash.
Copyright (C) 1987-2012 Free Software Foundation, Inc.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -141,7 +141,7 @@ Options:
#endif /* BANG_HISTORY */
-P If set, do not resolve symbolic links when executing commands
such as cd which change the current directory.
-T If set, the DEBUG trap is inherited by shell functions.
-T If set, the DEBUG and RETURN traps are inherited by shell functions.
-- Assign any remaining arguments to the positional parameters.
If there are no remaining arguments, the positional parameters
are unset.
@ -179,9 +179,13 @@ static int bash_set_history __P((int, char *));
static const char * const on = "on";
static const char * const off = "off";
static int previous_option_value;
/* A struct used to match long options for set -o to the corresponding
option letter or internal variable. The functions can be called to
dynamically generate values. */
dynamically generate values. If you add a new variable name here
that doesn't have a corresponding single-character option letter, make
sure to set the value appropriately in reset_shell_options. */
const struct {
char *name;
int letter;
@ -322,17 +326,52 @@ get_minus_o_opts ()
return ret;
}
char *
get_current_options ()
{
char *temp;
int i;
temp = (char *)xmalloc (1 + N_O_OPTIONS);
for (i = 0; o_options[i].name; i++)
{
if (o_options[i].letter)
temp[i] = *(find_flag (o_options[i].letter));
else
temp[i] = GET_BINARY_O_OPTION_VALUE (i, o_options[i].name);
}
temp[i] = '\0';
return (temp);
}
void
set_current_options (bitmap)
const char *bitmap;
{
int i;
if (bitmap == 0)
return;
for (i = 0; o_options[i].name; i++)
{
if (o_options[i].letter)
change_flag (o_options[i].letter, bitmap[i] ? FLAG_ON : FLAG_OFF);
else
SET_BINARY_O_OPTION_VALUE (i, bitmap[i] ? FLAG_ON : FLAG_OFF, o_options[i].name);
}
}
static int
set_ignoreeof (on_or_off, option_name)
int on_or_off;
char *option_name;
{
ignoreeof = on_or_off == FLAG_ON;
unbind_variable ("ignoreeof");
unbind_variable_noref ("ignoreeof");
if (ignoreeof)
bind_variable ("IGNOREEOF", "10", 0);
else
unbind_variable ("IGNOREEOF");
unbind_variable_noref ("IGNOREEOF");
sv_ignoreeof ("IGNOREEOF");
return 0;
}
@ -344,7 +383,7 @@ set_posix_mode (on_or_off, option_name)
{
posixly_correct = on_or_off == FLAG_ON;
if (posixly_correct == 0)
unbind_variable ("POSIXLY_CORRECT");
unbind_variable_noref ("POSIXLY_CORRECT");
else
bind_variable ("POSIXLY_CORRECT", "y", 0);
sv_strict_posix ("POSIXLY_CORRECT");
@ -425,12 +464,13 @@ set_minus_o_option (on_or_off, option_name)
{
if (o_options[i].letter == 0)
{
previous_option_value = GET_BINARY_O_OPTION_VALUE (i, o_options[i].name);
SET_BINARY_O_OPTION_VALUE (i, on_or_off, option_name);
return (EXECUTION_SUCCESS);
}
else
{
if (change_flag (o_options[i].letter, on_or_off) == FLAG_ERROR)
if ((previous_option_value = change_flag (o_options[i].letter, on_or_off)) == FLAG_ERROR)
{
sh_invalidoptname (option_name);
return (EXECUTION_FAILURE);
@ -585,10 +625,18 @@ initialize_shell_options (no_shellopts)
void
reset_shell_options ()
{
pipefail_opt = 0;
ignoreeof = 0;
#if defined (STRICT_POSIX)
posixly_correct = 1;
#else
posixly_correct = 0;
#endif
#if defined (HISTORY)
dont_save_function_defs = 0;
remember_on_history = enable_history_list = 1;
#endif
ignoreeof = 0;
}
/* Set some flags from the word values in the input list. If LIST is empty,
@ -615,6 +663,14 @@ set_builtin (list)
{
switch (flag_name)
{
case 'i': /* don't allow set -i */
s[0] = list_opttype;
s[1] = 'i';
s[2] = '\0';
sh_invalidopt (s);
builtin_usage ();
return (EX_USAGE);
CASE_HELPOPT;
case '?':
builtin_usage ();
return (list_optopt == '?' ? EXECUTION_SUCCESS : EX_USAGE);
@ -733,7 +789,7 @@ Options:
-f treat each NAME as a shell function
-v treat each NAME as a shell variable
-n treat each NAME as a name reference and unset the variable itself
rather than the variable it references
rather than the variable it references
Without options, unset first tries to unset a variable, and if that fails,
tries to unset a function.
@ -752,7 +808,7 @@ unset_builtin (list)
{
int unset_function, unset_variable, unset_array, opt, nameref, any_failed;
int global_unset_func, global_unset_var;
char *name;
char *name, *tname;
unset_function = unset_variable = unset_array = nameref = any_failed = 0;
global_unset_func = global_unset_var = 0;
@ -771,6 +827,7 @@ unset_builtin (list)
case 'n':
nameref = 1;
break;
CASE_HELPOPT;
default:
builtin_usage ();
return (EX_USAGE);
@ -802,7 +859,7 @@ unset_builtin (list)
#if defined (ARRAY_VARS)
unset_array = 0;
if (!unset_function && valid_array_reference (name))
if (!unset_function && nameref == 0 && valid_array_reference (name, 0))
{
t = strchr (name, '[');
*t++ = '\0';
@ -823,7 +880,7 @@ unset_builtin (list)
/* Only search for functions here if -f supplied. */
var = unset_function ? find_function (name)
: (nameref ? find_variable_last_nameref (name) : find_variable (name));
: (nameref ? find_variable_last_nameref (name, 0) : find_variable (name));
/* Some variables (but not functions yet) cannot be unset, period. */
if (var && unset_function == 0 && non_unsettable_p (var))
@ -832,11 +889,15 @@ unset_builtin (list)
NEXT_VARIABLE ();
}
/* if we have a nameref we want to use it */
if (var && unset_function == 0 && nameref == 0 && STREQ (name, name_cell(var)) == 0)
name = name_cell (var);
/* Posix.2 says try variables first, then functions. If we would
find a function after unsuccessfully searching for a variable,
note that we're acting on a function now as if -f were
supplied. The readonly check below takes care of it. */
if (var == 0 && unset_variable == 0 && unset_function == 0)
if (var == 0 && nameref == 0 && unset_variable == 0 && unset_function == 0)
{
if (var = find_function (name))
unset_function = 1;
@ -854,29 +915,52 @@ unset_builtin (list)
#if defined (ARRAY_VARS)
if (var && unset_array)
{
if (array_p (var) == 0 && assoc_p (var) == 0)
/* Let unbind_array_element decide what to do with non-array vars */
tem = unbind_array_element (var, t);
if (tem == -2 && array_p (var) == 0 && assoc_p (var) == 0)
{
builtin_error (_("%s: not an array variable"), var->name);
NEXT_VARIABLE ();
}
else
{
tem = unbind_array_element (var, t);
if (tem == -1)
any_failed++;
}
else if (tem < 0)
any_failed++;
}
else
#endif /* ARRAY_VARS */
tem = unset_function ? unbind_func (name) : (nameref ? unbind_nameref (name) : unbind_variable (name));
/* If we're trying to unset a nameref variable whose value isn't a set
variable, make sure we still try to unset the nameref's value */
if (var == 0 && nameref == 0 && unset_function == 0)
{
var = find_variable_last_nameref (name, 0);
if (var && nameref_p (var))
{
#if defined (ARRAY_VARS)
if (valid_array_reference (nameref_cell (var), 0))
{
tname = savestring (nameref_cell (var));
if (var = array_variable_part (tname, &t, 0))
tem = unbind_array_element (var, t);
free (tname);
}
else
#endif
tem = unbind_variable (nameref_cell (var));
}
else
tem = unbind_variable (name);
}
else
tem = unset_function ? unbind_func (name) : (nameref ? unbind_nameref (name) : unbind_variable (name));
/* This is what Posix.2 says: ``If neither -f nor -v
is specified, the name refers to a variable; if a variable by
that name does not exist, a function by that name, if any,
shall be unset.'' */
if (tem == -1 && unset_function == 0 && unset_variable == 0)
if (tem == -1 && nameref == 0 && unset_function == 0 && unset_variable == 0)
tem = unbind_func (name);
name = list->word->word; /* reset above for namerefs */
/* SUSv3, POSIX.1-2001 say: ``Unsetting a variable or function that
was not previously set shall not be considered an error.'' */

View file

@ -1,7 +1,7 @@
This file is setattr.def, from which is created setattr.c.
It implements the builtins "export" and "readonly", in Bash.
Copyright (C) 1987-2012 Free Software Foundation, Inc.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -34,6 +34,7 @@ $PRODUCES setattr.c
#include "../bashintl.h"
#include "../shell.h"
#include "../flags.h"
#include "common.h"
#include "bashgetopt.h"
@ -93,8 +94,8 @@ Options:
-a refer to indexed array variables
-A refer to associative array variables
-f refer to shell functions
-p display a list of all readonly variables or functions, depending on
whether or not the -f option is given
-p display a list of all readonly variables or functions,
depending on whether or not the -f option is given
An argument of `--' disables further option processing.
@ -133,6 +134,8 @@ set_or_show_attributes (list, attribute, nodefs)
#if defined (ARRAY_VARS)
WORD_LIST *nlist, *tlist;
WORD_DESC *w;
char optw[8];
int opti;
#endif
functions_only = arrays_only = assoc_only = 0;
@ -159,6 +162,7 @@ set_or_show_attributes (list, attribute, nodefs)
#endif
case 'p':
break;
CASE_HELPOPT;
default:
builtin_usage ();
return (EX_USAGE);
@ -187,6 +191,11 @@ set_or_show_attributes (list, attribute, nodefs)
builtin_error (_("%s: not a function"), name);
any_failed++;
}
else if ((attribute & att_exported) && undo == 0 && exportable_function_name (name) == 0)
{
builtin_error (_("%s: cannot export"), name);
any_failed++;
}
else
SETVARATTR (var, attribute, undo);
@ -231,8 +240,24 @@ set_or_show_attributes (list, attribute, nodefs)
{
tlist = list->next;
list->next = (WORD_LIST *)NULL;
w = arrays_only ? make_word ("-ra") : make_word ("-rA");
/* Add -g to avoid readonly/export creating local variables:
only local/declare/typeset create local variables */
opti = 0;
optw[opti++] = '-';
optw[opti++] = 'g';
if (attribute & att_readonly)
optw[opti++] = 'r';
if (attribute & att_exported)
optw[opti++] = 'x';
if (arrays_only)
optw[opti++] = 'a';
else
optw[opti++] = 'A';
optw[opti] = '\0';
w = make_word (optw);
nlist = make_word_list (w, list);
opt = declare_builtin (nlist);
if (opt != EXECUTION_SUCCESS)
assign_error++;
@ -296,6 +321,12 @@ set_or_show_attributes (list, attribute, nodefs)
else if (assoc_only && assoc_p (var) == 0)
continue;
#endif
/* If we imported a variable that's not a valid identifier, don't
show it in any lists. */
if ((var->attributes & (att_invisible|att_imported)) == (att_invisible|att_imported))
continue;
if ((var->attributes & attribute))
{
show_var_attributes (var, READONLY_OR_EXPORT, nodefs);
@ -336,18 +367,12 @@ show_all_var_attributes (v, nodefs)
return (any_failed == 0 ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
}
/* Show the attributes for shell variable VAR. If NODEFS is non-zero,
don't show function definitions along with the name. If PATTR is
non-zero, it indicates we're being called from `export' or `readonly'.
In POSIX mode, this prints the name of the calling builtin (`export'
or `readonly') instead of `declare', and doesn't print function defs
when called by `export' or `readonly'. */
int
show_var_attributes (var, pattr, nodefs)
var_attribute_string (var, pattr, flags)
SHELL_VAR *var;
int pattr, nodefs;
int pattr;
char *flags; /* filled in with attributes */
{
char flags[16], *x;
int i;
i = 0;
@ -405,6 +430,24 @@ show_var_attributes (var, pattr, nodefs)
}
flags[i] = '\0';
return i;
}
/* Show the attributes for shell variable VAR. If NODEFS is non-zero,
don't show function definitions along with the name. If PATTR is
non-zero, it indicates we're being called from `export' or `readonly'.
In POSIX mode, this prints the name of the calling builtin (`export'
or `readonly') instead of `declare', and doesn't print function defs
when called by `export' or `readonly'. */
int
show_var_attributes (var, pattr, nodefs)
SHELL_VAR *var;
int pattr, nodefs;
{
char flags[MAX_ATTRIBUTES], *x;
int i;
i = var_attribute_string (var, pattr, flags);
/* If we're printing functions with definitions, print the function def
first, then the attributes, instead of printing output that can't be
@ -425,10 +468,12 @@ show_var_attributes (var, pattr, nodefs)
printf ("%s ", this_command_name);
#if defined (ARRAY_VARS)
if (array_p (var))
print_array_assignment (var, 1);
if (invisible_p (var) && (array_p (var) || assoc_p (var)))
printf ("%s\n", var->name);
else if (array_p (var))
print_array_assignment (var, 0);
else if (assoc_p (var))
print_assoc_assignment (var, 1);
print_assoc_assignment (var, 0);
else
#endif
/* force `readonly' and `export' to not print out function definitions
@ -461,7 +506,7 @@ show_name_attributes (name, nodefs)
var = find_variable_noref (name);
#endif
if (var && invisible_p (var) == 0)
if (var /* && invisible_p (var) == 0 */) /* XXX bash-4.4/bash-5.0 */
{
show_var_attributes (var, READONLY_OR_EXPORT, nodefs);
return (0);
@ -493,8 +538,8 @@ set_var_attribute (name, attribute, undo)
char *name;
int attribute, undo;
{
SHELL_VAR *var, *tv, *v;
char *tvalue;
SHELL_VAR *var, *tv, *v, *refvar;
char *tvalue, *refname;
if (undo)
var = find_variable (name);
@ -509,6 +554,11 @@ set_var_attribute (name, attribute, undo)
tvalue = var_isset (tv) ? savestring (value_cell (tv)) : savestring ("");
var = bind_variable (tv->name, tvalue, 0);
if (var == 0)
{
free (tvalue);
return; /* XXX - no error message here */
}
var->attributes |= tv->attributes & ~att_tempvar;
/* This avoids an error message when propagating a read-only var
later on. */
@ -533,10 +583,23 @@ set_var_attribute (name, attribute, undo)
else
{
var = find_variable_notempenv (name);
if (var == 0)
{
/* We might have a nameref pointing to something that we can't
resolve to a shell variable. If we do, skip it. We do a little
checking just so we can print an error message. */
refvar = find_variable_nameref_for_create (name, 0);
if (refvar == INVALID_NAMEREF_VALUE)
return;
/* Otherwise we probably have a nameref pointing to a variable
that hasn't been created yet. bind_variable will take care
of that. */
}
if (var == 0)
{
var = bind_variable (name, (char *)NULL, 0);
VSETATTR (var, att_invisible);
if (var && no_invisible_vars == 0)
VSETATTR (var, att_invisible);
}
else if (var->context != 0)
VSETATTR (var, att_propagate);

View file

@ -61,6 +61,8 @@ shift_builtin (list)
register int count;
WORD_LIST *temp;
CHECK_HELPOPT (list);
if (get_numeric_arg (list, 0, &times) == 0)
return (EXECUTION_FAILURE);
@ -97,5 +99,8 @@ shift_builtin (list)
else
dollar_vars[9] = (char *)NULL;
}
invalidate_cached_quoted_dollar_at ();
return (EXECUTION_SUCCESS);
}

View 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-2012 Free Software Foundation, Inc.
Copyright (C) 1994-2016 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -90,6 +90,7 @@ extern int autocd;
extern int glob_star;
extern int glob_asciirange;
extern int lastpipe_opt;
extern int inherit_errexit;
#if defined (EXTENDED_GLOB)
extern int extended_glob;
@ -131,15 +132,21 @@ static int set_restricted_shell __P((char *, int));
static int shopt_set_complete_direxpand __P((char *, int));
#endif
static int shopt_set_debug_mode __P((char *, int));
static int shopt_login_shell;
static int shopt_compat31;
static int shopt_compat32;
static int shopt_compat40;
static int shopt_compat41;
static int shopt_compat42;
static int shopt_compat43;
typedef int shopt_set_func_t __P((char *, int));
/* If you add a new variable name here, make sure to set the default value
appropriately in reset_shopt_options. */
static struct {
char *name;
int *value;
@ -161,6 +168,7 @@ static struct {
{ "compat40", &shopt_compat40, set_compatibility_level },
{ "compat41", &shopt_compat41, set_compatibility_level },
{ "compat42", &shopt_compat42, set_compatibility_level },
{ "compat43", &shopt_compat43, set_compatibility_level },
#if defined (READLINE)
{ "complete_fullquote", &complete_fullquote, (shopt_set_func_t *)NULL},
{ "direxpand", &dircomplete_expand, shopt_set_complete_direxpand },
@ -170,7 +178,7 @@ static struct {
{ "execfail", &no_exit_on_failed_exec, (shopt_set_func_t *)NULL },
{ "expand_aliases", &expand_aliases, (shopt_set_func_t *)NULL },
#if defined (DEBUGGER)
{ "extdebug", &debugging_mode, (shopt_set_func_t *)NULL },
{ "extdebug", &debugging_mode, shopt_set_debug_mode },
#endif
#if defined (EXTENDED_GLOB)
{ "extglob", &extended_glob, (shopt_set_func_t *)NULL },
@ -180,8 +188,8 @@ static struct {
#if defined (READLINE)
{ "force_fignore", &force_fignore, (shopt_set_func_t *)NULL },
#endif
{ "globstar", &glob_star, (shopt_set_func_t *)NULL },
{ "globasciiranges", &glob_asciirange, (shopt_set_func_t *)NULL },
{ "globstar", &glob_star, (shopt_set_func_t *)NULL },
{ "gnu_errfmt", &gnu_error_format, (shopt_set_func_t *)NULL },
#if defined (HISTORY)
{ "histappend", &force_append_history, (shopt_set_func_t *)NULL },
@ -192,6 +200,7 @@ static struct {
{ "hostcomplete", &perform_hostname_completion, shopt_enable_hostname_completion },
#endif
{ "huponexit", &hup_on_exit, (shopt_set_func_t *)NULL },
{ "inherit_errexit", &inherit_errexit, (shopt_set_func_t *)NULL },
{ "interactive_comments", &interactive_comments, set_shellopts_after_change },
{ "lastpipe", &lastpipe_opt, (shopt_set_func_t *)NULL },
#if defined (HISTORY)
@ -267,6 +276,7 @@ shopt_builtin (list)
case 'p':
flags |= PFLAG;
break;
CASE_HELPOPT;
default:
builtin_usage ();
return (EX_USAGE);
@ -297,32 +307,67 @@ shopt_builtin (list)
}
/* Reset the options managed by `shopt' to the values they would have at
shell startup. */
shell startup. Variables from shopt_vars. */
void
reset_shopt_options ()
{
autocd = cdable_vars = cdspelling = 0;
check_hashed_filenames = CHECKHASH_DEFAULT;
check_window_size = CHECKWINSIZE_DEFAULT;
allow_null_glob_expansion = glob_dot_filenames = 0;
cdable_vars = mail_warning = 0;
no_exit_on_failed_exec = print_shift_error = 0;
check_hashed_filenames = cdspelling = expand_aliases = 0;
no_exit_on_failed_exec = 0;
expand_aliases = 0;
extended_quote = 1;
fail_glob_expansion = 0;
glob_asciirange = GLOBASCII_DEFAULT;
glob_star = 0;
gnu_error_format = 0;
hup_on_exit = 0;
inherit_errexit = 0;
interactive_comments = 1;
lastpipe_opt = 0;
mail_warning = 0;
glob_ignore_case = match_ignore_case = 0;
print_shift_error = 0;
source_uses_path = promptvars = 1;
check_window_size = CHECKWINSIZE_DEFAULT;
#if defined (JOB_CONTROL)
check_jobs_at_exit = 0;
#endif
#if defined (EXTENDED_GLOB)
extended_glob = 0;
extended_glob = EXTGLOB_DEFAULT;
#endif
#if defined (HISTORY)
literal_history = force_append_history = 0;
literal_history = 0;
force_append_history = 0;
command_oriented_history = 1;
#endif
#if defined (READLINE)
complete_fullquote = 1;
force_fignore = 1;
hist_verify = history_reediting = 0;
perform_hostname_completion = 1;
# if DIRCOMPLETE_EXPAND_DEFAULT
dircomplete_expand = 1;
# else
dircomplete_expand = 0;
#endif
dircomplete_spelling = 0;
no_empty_command_completion = 0;
#endif
#if defined (PROGRAMMABLE_COMPLETION)
prog_completion_enabled = 1;
#endif
#if defined (DEFAULT_ECHO_TO_XPG) || defined (STRICT_POSIX)
xpg_echo = 1;
#else
xpg_echo = 0;
#endif /* DEFAULT_ECHO_TO_XPG */
shopt_login_shell = login_shell;
}
@ -354,6 +399,7 @@ toggle_shopts (mode, list, quiet)
{
WORD_LIST *l;
int ind, rval;
SHELL_VAR *v;
for (l = list, rval = EXECUTION_SUCCESS; l; l = l->next)
{
@ -371,7 +417,9 @@ toggle_shopts (mode, list, quiet)
}
}
set_bashopts ();
/* Don't set $BASHOPTS here if it hasn't already been initialized */
if (v = find_variable ("BASHOPTS"))
set_bashopts ();
return (rval);
}
@ -516,6 +564,18 @@ set_shellopts_after_change (option_name, mode)
return (0);
}
static int
shopt_set_debug_mode (option_name, mode)
char *option_name;
int mode;
{
#if defined (DEBUGGER)
error_trace_mode = function_trace_mode = debugging_mode;
set_shellopts ();
#endif
return (0);
}
static int
shopt_enable_hostname_completion (option_name, mode)
char *option_name;
@ -537,7 +597,7 @@ set_compatibility_level (option_name, mode)
if (mode)
{
shopt_compat31 = shopt_compat32 = 0;
shopt_compat40 = shopt_compat41 = shopt_compat42 = 0;
shopt_compat40 = shopt_compat41 = shopt_compat42 = shopt_compat43 = 0;
ind = find_shopt (option_name);
*shopt_vars[ind].value = mode;
}
@ -553,6 +613,8 @@ set_compatibility_level (option_name, mode)
shell_compatibility_level = 41;
else if (shopt_compat42)
shell_compatibility_level = 42;
else if (shopt_compat43)
shell_compatibility_level = 43;
else
shell_compatibility_level = DEFAULT_COMPAT_LEVEL;
@ -564,11 +626,14 @@ set_compatibility_level (option_name, mode)
void
set_compatibility_opts ()
{
shopt_compat31 = shopt_compat32 = shopt_compat40 = shopt_compat41 = shopt_compat42 = 0;
shopt_compat31 = shopt_compat32 = 0;
shopt_compat40 = shopt_compat41 = shopt_compat42 = shopt_compat43 = 0;
switch (shell_compatibility_level)
{
case DEFAULT_COMPAT_LEVEL:
break;
case 43:
shopt_compat43 = 1; break;
case 42:
shopt_compat42 = 1; break;
case 41:
@ -745,7 +810,11 @@ parse_bashopts (value)
{
ind = find_shopt (vname);
if (ind >= 0)
*shopt_vars[ind].value = 1;
{
*shopt_vars[ind].value = 1;
if (shopt_vars[ind].set_func)
(*shopt_vars[ind].set_func) (shopt_vars[ind].name, 1);
}
free (vname);
}
}

View file

@ -1,7 +1,7 @@
This file is source.def, from which is created source.c.
It implements the builtins "." and "source" in Bash.
Copyright (C) 1987-2009 Free Software Foundation, Inc.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -108,6 +108,7 @@ maybe_pop_dollar_vars ()
if (debugging_mode)
pop_args (); /* restore BASH_ARGC and BASH_ARGV */
set_dollar_vars_unchanged ();
invalidate_cached_quoted_dollar_at (); /* just invalidate to be safe */
}
/* Read and execute commands from the file passed as argument. Guess what.
@ -119,7 +120,7 @@ source_builtin (list)
WORD_LIST *list;
{
int result;
char *filename, *debug_trap;
char *filename, *debug_trap, *x;
if (no_options (list))
return (EX_USAGE);
@ -152,7 +153,10 @@ source_builtin (list)
{
if (source_searches_cwd == 0)
{
builtin_error (_("%s: file not found"), list->word->word);
x = printable_filename (list->word->word, 0);
builtin_error (_("%s: file not found"), x);
if (x != list->word->word)
free (x);
if (posixly_correct && interactive_shell == 0 && executing_command_builtin == 0)
{
last_command_exit_value = 1;
@ -185,7 +189,7 @@ source_builtin (list)
{
debug_trap = savestring (debug_trap);
add_unwind_protect (xfree, debug_trap);
add_unwind_protect (set_debug_trap, debug_trap);
add_unwind_protect (maybe_set_debug_trap, debug_trap);
restore_default_signal (DEBUG_TRAP);
}

View file

@ -1,7 +1,7 @@
This file is suspend.def, from which is created suspend.c.
It implements the builtin "suspend" in Bash.
Copyright (C) 1987-2009 Free Software Foundation, Inc.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -89,6 +89,7 @@ suspend_builtin (list)
case 'f':
force++;
break;
CASE_HELPOPT;
default:
builtin_usage ();
return (EX_USAGE);

View file

@ -1,7 +1,7 @@
This file is test.def, from which is created test.c.
It implements the builtin "test" in Bash.
Copyright (C) 1987-2010 Free Software Foundation, Inc.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -83,8 +83,9 @@ String operators:
Other operators:
-o OPTION True if the shell option OPTION is enabled.
-v VAR True if the shell variable VAR is set
-R VAR True if the shell variable VAR is set and is a name reference.
-v VAR True if the shell variable VAR is set.
-R VAR True if the shell variable VAR is set and is a name
reference.
! EXPR True if expr is false.
EXPR1 -a EXPR2 True if both expr1 AND expr2 are true.
EXPR1 -o EXPR2 True if either expr1 OR expr2 is true.

View file

@ -1,7 +1,7 @@
This file is trap.def, from which is created trap.c.
It implements the builtin "trap" in Bash.
Copyright (C) 1987-2010 Free Software Foundation, Inc.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -86,7 +86,7 @@ static int display_traps __P((WORD_LIST *));
trap -p [sigspec ...]
trap [--]
Set things up so that ARG is executed when SIGNAL(s) N is recieved.
Set things up so that ARG is executed when SIGNAL(s) N is received.
If ARG is the empty string, then ignore the SIGNAL(s). If there is
no ARG, then set the trap for SIGNAL(s) to its original value. Just
plain "trap" means to print out the list of commands associated with
@ -119,6 +119,7 @@ trap_builtin (list)
case 'p':
display++;
break;
CASE_HELPOPT;
default:
builtin_usage ();
return (EX_USAGE);

View file

@ -1,7 +1,7 @@
This file is type.def, from which is created type.c.
It implements the builtin "type" in Bash.
Copyright (C) 1987-2011 Free Software Foundation, Inc.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -30,18 +30,18 @@ command name.
Options:
-a display all locations containing an executable named NAME;
includes aliases, builtins, and functions, if and only if
the `-p' option is not also used
includes aliases, builtins, and functions, if and only if
the `-p' option is not also used
-f suppress shell function lookup
-P force a PATH search for each NAME, even if it is an alias,
builtin, or function, and returns the name of the disk file
that would be executed
builtin, or function, and returns the name of the disk file
that would be executed
-p returns either the name of the disk file that would be executed,
or nothing if `type -t NAME' would not return `file'.
or nothing if `type -t NAME' would not return `file'
-t output a single word which is one of `alias', `keyword',
`function', `builtin', `file' or `', if NAME is an alias, shell
reserved word, shell function, shell builtin, disk file, or not
found, respectively
`function', `builtin', `file' or `', if NAME is an alias,
shell reserved word, shell function, shell builtin, disk file,
or not found, respectively
Arguments:
NAME Command name to be interpreted.
@ -168,6 +168,7 @@ type_builtin (list)
dflags |= (CDESC_PATH_ONLY|CDESC_FORCE_PATH);
dflags &= ~(CDESC_TYPE|CDESC_SHORTDESC);
break;
CASE_HELPOPT;
default:
builtin_usage ();
return (EX_USAGE);
@ -204,6 +205,7 @@ type_builtin (list)
* CDESC_FORCE_PATH force a path search for type -P
* CDESC_NOFUNCS skip function lookup for type -f
* CDESC_ABSPATH convert to absolute path, no ./ prefix
* CDESC_STDPATH command -p standard path list
*
* CDESC_ALL says whether or not to look for all occurrences of COMMAND, or
* return after finding it once.
@ -214,7 +216,7 @@ describe_command (command, dflags)
int dflags;
{
int found, i, found_file, f, all;
char *full_path, *x;
char *full_path, *x, *pathlist;
SHELL_VAR *func;
#if defined (ALIAS)
alias_t *alias;
@ -293,7 +295,12 @@ describe_command (command, dflags)
if (dflags & CDESC_TYPE)
puts ("builtin");
else if (dflags & CDESC_SHORTDESC)
printf (_("%s is a shell builtin\n"), command);
{
if (posixly_correct && find_special_builtin (command) != 0)
printf (_("%s is a special shell builtin\n"), command);
else
printf (_("%s is a shell builtin\n"), command);
}
else if (dflags & CDESC_REUSABLE)
printf ("%s\n", command);
@ -346,12 +353,17 @@ describe_command (command, dflags)
/* Now search through $PATH. */
while (1)
{
if (all == 0)
if (dflags & CDESC_STDPATH) /* command -p, all cannot be non-zero */
{
pathlist = conf_standard_path ();
full_path = find_in_path (command, pathlist, FS_EXEC_PREFERRED|FS_NODIRS);
free (pathlist);
/* Will only go through this once, since all == 0 if STDPATH set */
}
else if (all == 0)
full_path = find_user_command (command);
else
full_path =
user_command_matches (command, FS_EXEC_ONLY, found_file);
/* XXX - should that be FS_EXEC_PREFERRED? */
full_path = user_command_matches (command, FS_EXEC_ONLY, found_file); /* XXX - should that be FS_EXEC_PREFERRED? */
if (full_path == 0)
break;
@ -382,7 +394,11 @@ describe_command (command, dflags)
}
/* If we require a full path and don't have one, make one */
else if ((dflags & CDESC_ABSPATH) && ABSPATH (full_path) == 0)
full_path = sh_makepath ((char *)NULL, full_path, MP_DOCWD|MP_RMDOT);
{
x = sh_makepath ((char *)NULL, full_path, MP_DOCWD|MP_RMDOT);
free (full_path);
full_path = x;
}
found_file++;
found = 1;

View file

@ -1,7 +1,7 @@
This file is ulimit.def, from which is created ulimit.c.
It implements the builtin "ulimit" in Bash.
Copyright (C) 1987-2010 Free Software Foundation, Inc.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -23,7 +23,7 @@ $PRODUCES ulimit.c
$BUILTIN ulimit
$FUNCTION ulimit_builtin
$DEPENDS_ON !_MINIX
$SHORT_DOC ulimit [-SHabcdefilmnpqrstuvxT] [limit]
$SHORT_DOC ulimit [-SHabcdefiklmnpqrstuvxPT] [limit]
Modify shell resource limits.
Provides control over the resources available to the shell and processes
@ -39,6 +39,7 @@ Options:
-e the maximum scheduling priority (`nice')
-f the maximum size of files written by the shell and its children
-i the maximum number of pending signals
-k the maximum number of kqueues allocated for this process
-l the maximum size a process may lock into memory
-m the maximum resident set size
-n the maximum number of open file descriptors
@ -50,7 +51,8 @@ Options:
-u the maximum number of user processes
-v the size of virtual memory
-x the maximum number of file locks
-T the maximum number of threads
-P the maximum number of pseudoterminals
-T the maximum number of threads
Not all options are available on all platforms.
@ -131,11 +133,17 @@ extern int errno;
# define print_rlimtype(num, nl) printf ("%ld%s", num, nl ? "\n" : "")
#endif
/* Alternate names */
/* Some systems use RLIMIT_NOFILE, others use RLIMIT_OFILE */
#if defined (HAVE_RESOURCE) && defined (RLIMIT_OFILE) && !defined (RLIMIT_NOFILE)
# define RLIMIT_NOFILE RLIMIT_OFILE
#endif /* HAVE_RESOURCE && RLIMIT_OFILE && !RLIMIT_NOFILE */
#if defined (HAVE_RESOURCE) && defined (RLIMIT_POSIXLOCKS) && !defined (RLIMIT_LOCKS)
# define RLIMIT_LOCKS RLIMIT_POSIXLOCKS
#endif /* HAVE_RESOURCE && RLIMIT_POSIXLOCKS && !RLIMIT_LOCKS */
/* Some systems have these, some do not. */
#ifdef RLIMIT_FSIZE
# define RLIMIT_FILESIZE RLIMIT_FSIZE
@ -223,6 +231,9 @@ typedef struct {
} RESOURCE_LIMITS;
static RESOURCE_LIMITS limits[] = {
#ifdef RLIMIT_NPTS
{ 'P', RLIMIT_NPTS, 1, "number of pseudoterminals", (char *)NULL },
#endif
#ifdef RLIMIT_PTHREAD
{ 'T', RLIMIT_PTHREAD, 1, "number of threads", (char *)NULL },
#endif
@ -242,6 +253,9 @@ static RESOURCE_LIMITS limits[] = {
#ifdef RLIMIT_SIGPENDING
{ 'i', RLIMIT_SIGPENDING, 1, "pending signals", (char *)NULL },
#endif
#ifdef RLIMIT_KQUEUES
{ 'k', RLIMIT_KQUEUES, 1, "max kqueues", (char *)NULL },
#endif
#ifdef RLIMIT_MEMLOCK
{ 'l', RLIMIT_MEMLOCK, 1024, "max locked memory", "kbytes" },
#endif
@ -359,6 +373,7 @@ ulimit_builtin (list)
mode |= LIMIT_HARD;
break;
CASE_HELPOPT;
case '?':
builtin_usage ();
return (EX_USAGE);

View file

@ -1,7 +1,7 @@
This file is umask.def, from which is created umask.c.
It implements the builtin "umask" in Bash.
Copyright (C) 1987-2009 Free Software Foundation, Inc.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -91,6 +91,7 @@ umask_builtin (list)
case 'p':
pflag++;
break;
CASE_HELPOPT;
default:
builtin_usage ();
return (EX_USAGE);
@ -145,8 +146,12 @@ umask_builtin (list)
/* Print the umask in a symbolic form. In the output, a letter is
printed if the corresponding bit is clear in the umask. */
static void
#if defined (__STDC__)
print_symbolic_umask (mode_t um)
#else
print_symbolic_umask (um)
mode_t um;
#endif
{
char ubits[4], gbits[4], obits[4]; /* u=rwx,g=rwx,o=rwx */
int i;

View file

@ -1,7 +1,7 @@
This file is wait.def, from which is created wait.c.
It implements the builtin "wait" in Bash.
Copyright (C) 1987-2013 Free Software Foundation, Inc.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -73,8 +73,10 @@ $END
#include "bashgetopt.h"
extern int wait_signal_received;
extern int last_command_exit_signal;
procenv_t wait_intr_buf;
int wait_intr_flag;
/* Wait for the pid in LIST to stop or die. If no arguments are given, then
wait for all of the active background processes of the shell and return
@ -86,6 +88,7 @@ procenv_t wait_intr_buf;
{ \
interrupt_immediately = old_interrupt_immediately;\
wait_signal_received = 0; \
wait_intr_flag = 0; \
return (s);\
} \
while (0)
@ -110,6 +113,7 @@ wait_builtin (list)
nflag = 1;
break;
#endif
CASE_HELPOPT;
default:
builtin_usage ();
return (EX_USAGE);
@ -130,10 +134,14 @@ wait_builtin (list)
We handle SIGINT here; it's the only one that needs to be treated
specially (I think), since it's handled specially in {no,}jobs.c. */
code = setjmp (wait_intr_buf);
wait_intr_flag = 1;
code = setjmp_sigs (wait_intr_buf);
if (code)
{
last_command_exit_signal = wait_signal_received;
status = 128 + wait_signal_received;
wait_sigint_cleanup ();
WAIT_RETURN (status);
}
@ -171,7 +179,7 @@ wait_builtin (list)
if (legal_number (w, &pid_value) && pid_value == (pid_t)pid_value)
{
pid = (pid_t)pid_value;
status = wait_for_single_pid (pid);
status = wait_for_single_pid (pid, 1);
}
else
{

View file

@ -1,7 +1,7 @@
/* command.h -- The structures used internally to represent commands, and
the extern declarations of the functions used to create them. */
/* Copyright (C) 1993-2010 Free Software Foundation, Inc.
/* Copyright (C) 1993-2016 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -100,7 +100,15 @@ enum command_type { cm_for, cm_case, cm_while, cm_if, cm_simple, cm_select,
#define W_ARRAYIND 0x1000000 /* word is an array index being expanded */
#define W_ASSNGLOBAL 0x2000000 /* word is a global assignment to declare (declare/typeset -g) */
#define W_NOBRACE 0x4000000 /* Don't perform brace expansion */
#define W_ASSIGNINT 0x8000000 /* word is an integer assignment to declare */
#define W_COMPLETE 0x8000000 /* word is being expanded for completion */
/* Flags for the `pflags' argument to param_expand() and various
parameter_brace_expand_xxx functions; also used for string_list_dollar_at */
#define PF_NOCOMSUB 0x01 /* Do not perform command substitution */
#define PF_IGNUNBOUND 0x02 /* ignore unbound vars even if -u set */
#define PF_NOSPLIT2 0x04 /* same as W_NOSPLIT2 */
#define PF_ASSIGNRHS 0x08 /* same as W_ASSIGNRHS */
#define PF_COMPLETE 0x10 /* same as W_COMPLETE, sets SX_COMPLETE */
/* Possible values for subshell_environment */
#define SUBSHELL_ASYNC 0x01 /* subshell caused by `command &' */
@ -175,6 +183,7 @@ typedef struct element {
#define CMD_COMMAND_BUILTIN 0x0800 /* command executed by `command' builtin */
#define CMD_COPROC_SUBSHELL 0x1000
#define CMD_LASTPIPE 0x2000
#define CMD_STDPATH 0x4000 /* use standard path for command lookup */
/* What a command looks like. */
typedef struct command {

View file

@ -94,6 +94,10 @@
# undef COND_REGEXP
#endif
#if !HAVE_MKSTEMP
# undef USE_MKSTEMP
#endif
/* If the shell is called by this name, it will become restricted. */
#if defined (RESTRICTED_SHELL)
# define RESTRICTED_SHELL_NAME "rbash"

View file

@ -27,6 +27,10 @@
error messages about `break' and `continue' out of context. */
#define BREAK_COMPLAINS
/* Define CD_COMPLAINS if you want the non-standard, but sometimes-desired
error messages about multiple directory arguments to `cd'. */
#define CD_COMPLAINS
/* Define BUFFERED_INPUT if you want the shell to do its own input
buffering, rather than using stdio. Do not undefine this; it's
required to preserve semantics required by POSIX. */
@ -79,6 +83,9 @@
reply to the select query is an empty line. */
#define KSH_COMPATIBLE_SELECT
/* Default interactive shell startup file. */
#define DEFAULT_BASHRC "~/.bashrc"
/* System-wide .bashrc file for interactive shells. */
/* #define SYS_BASHRC "/etc/bash.bashrc" */
@ -110,6 +117,7 @@
#if defined (SYSLOG_HISTORY)
# define SYSLOG_FACILITY LOG_USER
# define SYSLOG_LEVEL LOG_INFO
# define OPENLOG_OPTS LOG_PID
#endif
/* Define if you want to include code in shell.c to support wordexp(3) */
@ -132,3 +140,23 @@
/* Define to 1 if you want to be able to export indexed arrays to processes
using the foo=([0]=one [1]=two) and so on */
/* #define ARRAY_EXPORT 1 */
/* Define to 1 if you want the shell to exit if it is running setuid and its
attempt to drop privilege using setuid(getuid()) fails with errno == EAGAIN */
/* #define EXIT_ON_SETUID_FAILURE 1 */
/* Define to 1 if you want the shell to re-check $PATH if a hashed filename
no longer exists. This behavior is the default in Posix mode. */
#define CHECKHASH_DEFAULT 0
/* Define to the maximum level of recursion you want for the eval builtin.
0 means the limit is not active. */
#define EVALNEST_MAX 0
/* Define to the maximum level of recursion you want for the source/. builtin.
0 means the limit is not active. */
#define SOURCENEST_MAX 0
/* Define to use libc mktemp/mkstemp instead of replacements in lib/sh/tmpfile.c */
#define USE_MKTEMP
#define USE_MKSTEMP

View file

@ -21,6 +21,17 @@
#ifndef _CONFIG_H_
#define _CONFIG_H_
/* Template settings for autoconf */
#undef __EXTENSIONS__
#undef _ALL_SOURCE
#undef _GNU_SOURCE
#undef _POSIX_SOURCE
#undef _POSIX_1_SOURCE
#undef _POSIX_PTHREAD_SEMANTICS
#undef _TANDEM_SOURCE
#undef _MINIX
/* Configuration feature settings controllable by autoconf. */
/* Define JOB_CONTROL if your operating system supports
@ -173,6 +184,9 @@
/* Define to make the `globasciiranges' shopt option enabled by default. */
#undef GLOBASCII_DEFAULT
/* Define to allow functions to be imported from the environment. */
#undef FUNCTION_IMPORT
/* Define AFS if you are using Transarc's AFS. */
#undef AFS
@ -201,6 +215,7 @@
#undef HAVE_LONG_DOUBLE
#undef PROTOTYPES
#undef __PROTOTYPES
#undef __CHAR_UNSIGNED__
@ -317,6 +332,9 @@
/* Define to `unsigned long' if <stdint.h> doesn't define. */
#undef uintmax_t
/* Define to integer type wide enough to hold a pointer if <stdint.h> doesn't define. */
#undef uintptr_t
/* Define to `int' if <sys/types.h> doesn't define. */
#undef uid_t
@ -543,7 +561,6 @@
#undef UNUSABLE_RT_SIGNALS
/* Presence of system and C library functions. */
/* Define if you have the asprintf function. */
@ -555,6 +572,9 @@
/* Define if you have the bzero function. */
#undef HAVE_BZERO
/* Define if you have the chown function. */
#undef HAVE_CHOWN
/* Define if you have the confstr function. */
#undef HAVE_CONFSTR
@ -719,15 +739,24 @@
/* Define if you have the mkfifo function. */
#undef HAVE_MKFIFO
/* Define if you have the mkstemp function. */
#undef HAVE_MKSTEMP
/* Define if you have the pathconf function. */
#undef HAVE_PATHCONF
/* Define if you have the pselect function. */
#undef HAVE_PSELECT
/* Define if you have the putenv function. */
#undef HAVE_PUTENV
/* Define if you have the raise function. */
#undef HAVE_RAISE
/* Define if you have the random function. */
#undef HAVE_RANDOM
/* Define if you have the readlink function. */
#undef HAVE_READLINK
@ -926,6 +955,9 @@
/* Define if you have the <langinfo.h> header file. */
#undef HAVE_LANGINFO_H
/* Define if you have the <libaudit.h> header file. */
#undef HAVE_LIBAUDIT_H
/* Define if you have the <libintl.h> header file. */
#undef HAVE_LIBINTL_H
@ -935,6 +967,9 @@
/* Define if you have the <locale.h> header file. */
#undef HAVE_LOCALE_H
/* Define if you have the <mbstr.h> header file. */
#undef HAVE_MBSTR_H
/* Define if you have the <ndir.h> header file. */
#undef HAVE_NDIR_H
@ -983,6 +1018,9 @@
/* Define if you have the <sys/file.h> header file. */
#undef HAVE_SYS_FILE_H
/* Define if you have the <sys/ioctl.h> header file. */
#undef HAVE_SYS_IOCTL_H
/* Define if you have the <sys/ndir.h> header file. */
#undef HAVE_SYS_NDIR_H
@ -1059,9 +1097,6 @@
/* Are we running the GNU C library, version 2.1 or later? */
#undef GLIBC21
/* Define if on MINIX. */
#undef _MINIX
/* Are we running SVR5 (UnixWare 7)? */
#undef SVR5

334
configure vendored
View file

@ -1,7 +1,7 @@
#! /bin/sh
# From configure.ac for Bash 4.3, version 4.063.
# From configure.ac for Bash 4.4, version 4.082.
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for bash 4.3-release.
# Generated by GNU Autoconf 2.69 for bash 4.4-release.
#
# Report bugs to <bug-bash@gnu.org>.
#
@ -581,8 +581,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='bash'
PACKAGE_TARNAME='bash'
PACKAGE_VERSION='4.3-release'
PACKAGE_STRING='bash 4.3-release'
PACKAGE_VERSION='4.4-release'
PACKAGE_STRING='bash 4.4-release'
PACKAGE_BUGREPORT='bug-bash@gnu.org'
PACKAGE_URL=''
@ -635,6 +635,8 @@ DEBUG
RELSTATUS
BASHVERS
ARFLAGS
headersdir
loadablesdir
BUILD_DIR
incdir
PROFILE_FLAGS
@ -727,7 +729,6 @@ MALLOC_LIBRARY
MALLOC_LIB
MALLOC_SRC
MALLOC_TARGET
PURIFY
TESTSCRIPT
CPPFLAGS_FOR_BUILD
LDFLAGS_FOR_BUILD
@ -788,8 +789,6 @@ with_bash_malloc
with_curses
with_gnu_malloc
with_installed_readline
with_purecov
with_purify
enable_minimal_config
enable_alias
enable_arith_for_command
@ -809,6 +808,7 @@ enable_disabled_builtins
enable_dparen_arithmetic
enable_extended_glob
enable_extended_glob_default
enable_function_import
enable_glob_asciiranges_default
enable_help_builtin
enable_history
@ -1393,7 +1393,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures bash 4.3-release to adapt to many kinds of systems.
\`configure' configures bash 4.4-release to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@ -1458,7 +1458,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of bash 4.3-release:";;
short | recursive ) echo "Configuration of bash 4.4-release:";;
esac
cat <<\_ACEOF
@ -1498,6 +1498,9 @@ Optional Features:
--enable-extended-glob-default
force extended pattern matching to be enabled by
default
--enable-function-import
allow bash to import exported function definitions
by default
--enable-glob-asciiranges-default
force bracket range expressions in pattern matching
to use the C locale by default
@ -1546,8 +1549,6 @@ Optional Packages:
--with-installed-readline
use a version of the readline library that is
already installed
--with-purecov configure to postprocess with pure coverage
--with-purify configure to postprocess with purify
--with-gnu-ld assume the C compiler uses GNU ld default=no
--with-libiconv-prefix[=DIR] search for libiconv in DIR/include and DIR/lib
--without-libiconv-prefix don't search for libiconv in includedir and libdir
@ -1650,7 +1651,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
bash configure 4.3-release
bash configure 4.4-release
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@ -2359,7 +2360,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by bash $as_me 4.3-release, which was
It was created by bash $as_me 4.4-release, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@ -2752,11 +2753,11 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
ac_config_headers="$ac_config_headers config.h"
BASHVERS=4.3
BASHVERS=4.4
RELSTATUS=release
case "$RELSTATUS" in
alp*|bet*|dev*|rc*|maint*) DEBUG='-DDEBUG' MALLOC_DEBUG='-DMALLOC_DEBUG' ;;
alp*|bet*|dev*|rc*|releng*|maint*) DEBUG='-DDEBUG' MALLOC_DEBUG='-DMALLOC_DEBUG' ;;
*) DEBUG= MALLOC_DEBUG= ;;
esac
@ -2834,8 +2835,6 @@ case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
opt_bash_malloc=yes
opt_purify=no
opt_purecov=no
opt_afs=no
opt_curses=no
opt_with_installed_readline=no
@ -2911,18 +2910,6 @@ if test "${with_installed_readline+set}" = set; then :
fi
# Check whether --with-purecov was given.
if test "${with_purecov+set}" = set; then :
withval=$with_purecov; opt_purecov=$withval
fi
# Check whether --with-purify was given.
if test "${with_purify+set}" = set; then :
withval=$with_purify; opt_purify=$withval
fi
if test "$opt_bash_malloc" = yes; then
MALLOC_TARGET=malloc
MALLOC_SRC=malloc.c
@ -2941,18 +2928,6 @@ else
MALLOC_DEP=
fi
if test "$opt_purify" = yes; then
PURIFY="purify "
$as_echo "#define DISABLE_MALLOC_WRAPPERS 1" >>confdefs.h
else
PURIFY=
fi
if test "$opt_purecov" = yes; then
PURIFY="${PURIFY}purecov"
fi
if test "$opt_afs" = yes; then
$as_echo "#define AFS 1" >>confdefs.h
@ -3002,6 +2977,7 @@ opt_casemod_expansions=yes
opt_extglob_default=no
opt_dircomplete_expand_default=no
opt_globascii_default=no
opt_function_import=yes
opt_static_link=no
opt_profiling=no
@ -3115,6 +3091,11 @@ if test "${enable_extended_glob_default+set}" = set; then :
enableval=$enable_extended_glob_default; opt_extglob_default=$enableval
fi
# Check whether --enable-function-import was given.
if test "${enable_function_import+set}" = set; then :
enableval=$enable_function_import; opt_function_import=$enableval
fi
# Check whether --enable-glob-asciiranges-default was given.
if test "${enable_glob_asciiranges_default+set}" = set; then :
enableval=$enable_glob_asciiranges_default; opt_globascii_default=$enableval
@ -3341,6 +3322,10 @@ $as_echo "#define GLOBASCII_DEFAULT 1" >>confdefs.h
else
$as_echo "#define GLOBASCII_DEFAULT 0" >>confdefs.h
fi
if test $opt_function_import = yes; then
$as_echo "#define FUNCTION_IMPORT 1" >>confdefs.h
fi
if test $opt_memscramble = yes; then
@ -3387,6 +3372,12 @@ fi
if test -z "$CFLAGS"; then
AUTO_CFLAGS="-g ${GCC+-O2} ${GCC+-Wno-parentheses}"
AUTO_LDFLAGS="-g ${GCC+-O2}"
else
AUTO_CFLAGS= AUTO_LDFLAGS=
fi
echo ""
echo "Beginning configuration for bash-$BASHVERS-$RELSTATUS for ${host_cpu}-${host_vendor}-${host_os}"
@ -4921,16 +4912,15 @@ fi
if test -z "$CFLAGS"; then
AUTO_CFLAGS="-g ${GCC+-O2}"
AUTO_LDFLAGS="-g ${GCC+-O2}"
else
AUTO_CFLAGS= AUTO_LDFLAGS=
fi
CFLAGS=${CFLAGS-"$AUTO_CFLAGS"}
# LDFLAGS=${LDFLAGS="$AUTO_LDFLAGS"} # XXX
# turn off paren warnings in gcc
if test "$GCC" = yes # && test -n "$DEBUG"
then
CFLAGS="$CFLAGS -Wno-parentheses -Wno-format-security"
fi
if test "$opt_profiling" = "yes"; then
PROFILE_FLAGS=-pg
case "$host_os" in
@ -5278,7 +5268,7 @@ if ${ac_cv_rl_version+:} false; then :
$as_echo_n "(cached) " >&6
else
if test "$cross_compiling" = yes; then :
ac_cv_rl_version='4.2'
ac_cv_rl_version='6.3'
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@ -9279,8 +9269,8 @@ fi
done
for ac_header in sys/pte.h sys/stream.h sys/select.h sys/file.h \
sys/resource.h sys/param.h sys/socket.h sys/stat.h \
for ac_header in sys/pte.h sys/stream.h sys/select.h sys/file.h sys/ioctl.h \
sys/param.h sys/socket.h sys/stat.h \
sys/time.h sys/times.h sys/types.h sys/wait.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
@ -9320,6 +9310,19 @@ fi
ac_fn_c_check_header_compile "$LINENO" "sys/resource.h" "ac_cv_header_sys_resource_h" "
#if HAVE_SYS_TIME_H
# include <sys/time.h>
#endif
"
if test "x$ac_cv_header_sys_resource_h" = xyes; then :
$as_echo "#define HAVE_SYS_RESOURCE_H 1" >>confdefs.h
fi
# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
# for constant arguments. Useless!
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working alloca.h" >&5
@ -9504,6 +9507,101 @@ cat >>confdefs.h <<_ACEOF
_ACEOF
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for uid_t in sys/types.h" >&5
$as_echo_n "checking for uid_t in sys/types.h... " >&6; }
if ${ac_cv_type_uid_t+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <sys/types.h>
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "uid_t" >/dev/null 2>&1; then :
ac_cv_type_uid_t=yes
else
ac_cv_type_uid_t=no
fi
rm -f conftest*
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_uid_t" >&5
$as_echo "$ac_cv_type_uid_t" >&6; }
if test $ac_cv_type_uid_t = no; then
$as_echo "#define uid_t int" >>confdefs.h
$as_echo "#define gid_t int" >>confdefs.h
fi
for ac_header in unistd.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "unistd.h" "ac_cv_header_unistd_h" "$ac_includes_default"
if test "x$ac_cv_header_unistd_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_UNISTD_H 1
_ACEOF
fi
done
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working chown" >&5
$as_echo_n "checking for working chown... " >&6; }
if ${ac_cv_func_chown_works+:} false; then :
$as_echo_n "(cached) " >&6
else
if test "$cross_compiling" = yes; then :
ac_cv_func_chown_works=no
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$ac_includes_default
#include <fcntl.h>
int
main ()
{
char *f = "conftest.chown";
struct stat before, after;
if (creat (f, 0600) < 0)
return 1;
if (stat (f, &before) < 0)
return 1;
if (chown (f, (uid_t) -1, (gid_t) -1) == -1)
return 1;
if (stat (f, &after) < 0)
return 1;
return ! (before.st_uid == after.st_uid && before.st_gid == after.st_gid);
;
return 0;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
ac_cv_func_chown_works=yes
else
ac_cv_func_chown_works=no
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
rm -f conftest.chown
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_chown_works" >&5
$as_echo "$ac_cv_func_chown_works" >&6; }
if test $ac_cv_func_chown_works = yes; then
$as_echo "#define HAVE_CHOWN 1" >>confdefs.h
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether getpgrp requires zero arguments" >&5
@ -9706,7 +9804,7 @@ fi
for ac_func in dup2 eaccess fcntl getdtablesize getgroups gethostname \
getpagesize getpeername getrlimit getrusage gettimeofday \
kill killpg lstat readlink sbrk select setdtablesize \
kill killpg lstat pselect readlink sbrk select setdtablesize \
setitimer tcgetpgrp uname ulimit waitpid
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
@ -9736,7 +9834,7 @@ fi
for ac_func in bcopy bzero confstr faccessat fnmatch \
getaddrinfo gethostbyname getservbyname getservent inet_aton \
imaxdiv memmove pathconf putenv raise regcomp regexec \
imaxdiv memmove pathconf putenv raise random regcomp regexec \
setenv setlinebuf setlocale setvbuf siginterrupt strchr \
sysconf syslog tcgetattr times ttyname tzset unsetenv
do :
@ -9787,6 +9885,17 @@ _ACEOF
fi
done
for ac_func in mkstemp
do :
ac_fn_c_check_func "$LINENO" "mkstemp" "ac_cv_func_mkstemp"
if test "x$ac_cv_func_mkstemp" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_MKSTEMP 1
_ACEOF
fi
done
ac_fn_c_check_func "$LINENO" "getcwd" "ac_cv_func_getcwd"
if test "x$ac_cv_func_getcwd" = xyes; then :
$as_echo "#define HAVE_GETCWD 1" >>confdefs.h
@ -10041,6 +10150,18 @@ fi
for ac_header in libaudit.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "libaudit.h" "ac_cv_header_libaudit_h" "$ac_includes_default"
if test "x$ac_cv_header_libaudit_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBAUDIT_H 1
_ACEOF
fi
done
ac_fn_c_check_decl "$LINENO" "AUDIT_USER_TTY" "ac_cv_have_decl_AUDIT_USER_TTY" "#include <linux/audit.h>
"
if test "x$ac_cv_have_decl_AUDIT_USER_TTY" = xyes; then :
@ -10965,6 +11086,19 @@ fi
done
for ac_header in mbstr.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "mbstr.h" "ac_cv_header_mbstr_h" "$ac_includes_default"
if test "x$ac_cv_header_mbstr_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_MBSTR_H 1
_ACEOF
fi
done
ac_fn_c_check_func "$LINENO" "mbrlen" "ac_cv_func_mbrlen"
if test "x$ac_cv_func_mbrlen" = xyes; then :
$as_echo "#define HAVE_MBRLEN 1" >>confdefs.h
@ -11279,7 +11413,7 @@ _ACEOF
if ac_fn_c_try_run "$LINENO"; then :
bash_cv_wcwidth_broken=yes
else
bash_cv_wcwdith_broken=no
bash_cv_wcwidth_broken=no
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
@ -11296,7 +11430,7 @@ fi
if test "$am_cv_func_iconv" = yes; then
OLDLIBS="$LIBS"
LIBS="$LIBS $LIBICONV"
LIBS="$LIBS $LIBINTL $LIBICONV"
for ac_func in locale_charset
do :
ac_fn_c_check_func "$LINENO" "locale_charset" "ac_cv_func_locale_charset"
@ -11667,36 +11801,6 @@ fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for uid_t in sys/types.h" >&5
$as_echo_n "checking for uid_t in sys/types.h... " >&6; }
if ${ac_cv_type_uid_t+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <sys/types.h>
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "uid_t" >/dev/null 2>&1; then :
ac_cv_type_uid_t=yes
else
ac_cv_type_uid_t=no
fi
rm -f conftest*
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_uid_t" >&5
$as_echo "$ac_cv_type_uid_t" >&6; }
if test $ac_cv_type_uid_t = no; then
$as_echo "#define uid_t int" >>confdefs.h
$as_echo "#define gid_t int" >>confdefs.h
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking type of array argument to getgroups" >&5
$as_echo_n "checking type of array argument to getgroups... " >&6; }
if ${ac_cv_type_getgroups+:} false; then :
@ -11838,6 +11942,44 @@ _ACEOF
fi
ac_fn_c_check_type "$LINENO" "uintptr_t" "ac_cv_type_uintptr_t" "$ac_includes_default"
if test "x$ac_cv_type_uintptr_t" = xyes; then :
$as_echo "#define HAVE_UINTPTR_T 1" >>confdefs.h
else
for ac_type in 'unsigned int' 'unsigned long int' \
'unsigned long long int'; do
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$ac_includes_default
int
main ()
{
static int test_array [1 - 2 * !(sizeof (void *) <= sizeof ($ac_type))];
test_array [0] = 0;
return test_array [0];
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
cat >>confdefs.h <<_ACEOF
#define uintptr_t $ac_type
_ACEOF
ac_type=
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
test -z "$ac_type" && break
done
fi
ac_fn_c_check_type "$LINENO" "ssize_t" "ac_cv_type_ssize_t" "$ac_includes_default"
if test "x$ac_cv_type_ssize_t" = xyes; then :
@ -15923,7 +16065,7 @@ solaris2*) LOCAL_CFLAGS=-DSOLARIS ;;
lynxos*) LOCAL_CFLAGS=-DRECYCLES_PIDS ;;
linux*) LOCAL_LDFLAGS=-rdynamic # allow dynamic loading
case "`uname -r`" in
2.[456789]*|3*) $as_echo "#define PGRP_PIPE 1" >>confdefs.h
2.[456789]*|[34]*) $as_echo "#define PGRP_PIPE 1" >>confdefs.h
;;
esac ;;
*qnx6*) LOCAL_CFLAGS="-Dqnx -Dqnx6" LOCAL_LIBS="-lncurses" ;;
@ -15938,6 +16080,8 @@ case "${host_os}-${CC}" in
aix4.2*-*gcc*) LOCAL_LDFLAGS="-Xlinker -bexpall -Xlinker -brtl" ;;
aix4.2*) LOCAL_LDFLAGS="-bexpall -brtl" ;;
bsdi4*-*gcc*) LOCAL_LDFLAGS="-rdynamic" ;; # allow dynamic loading, like Linux
bsdi5*-*gcc*) LOCAL_LDFLAGS="-rdynamic" ;; # allow dynamic loading, like Linux
hpux11*-gcc*) LOCAL_LDFLAGS="-Wl,-E" ;; # allow dynamic loading
esac
case "${host_os}" in
@ -16019,6 +16163,16 @@ fi
# directory where we install dynamically loadable builtins
if test -z "$loadablesdir"; then
loadablesdir='${libdir}/bash'
fi
if test -z "$headersdir"; then
headersdir='$(includedir)/$(PACKAGE_NAME)'
fi
@ -16040,7 +16194,7 @@ fi
#AC_SUBST(ALLOCA_SOURCE)
#AC_SUBST(ALLOCA_OBJECT)
ac_config_files="$ac_config_files Makefile builtins/Makefile lib/readline/Makefile lib/glob/Makefile lib/intl/Makefile lib/malloc/Makefile lib/sh/Makefile lib/termcap/Makefile lib/tilde/Makefile doc/Makefile support/Makefile po/Makefile.in examples/loadables/Makefile examples/loadables/perl/Makefile"
ac_config_files="$ac_config_files Makefile builtins/Makefile lib/readline/Makefile lib/glob/Makefile lib/intl/Makefile lib/malloc/Makefile lib/sh/Makefile lib/termcap/Makefile lib/tilde/Makefile doc/Makefile support/Makefile po/Makefile.in examples/loadables/Makefile examples/loadables/Makefile.inc examples/loadables/perl/Makefile support/bash.pc"
ac_config_commands="$ac_config_commands default"
@ -16551,7 +16705,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by bash $as_me 4.3-release, which was
This file was extended by bash $as_me 4.4-release, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@ -16617,7 +16771,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
bash config.status 4.3-release
bash config.status 4.4-release
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
@ -16765,7 +16919,9 @@ do
"support/Makefile") CONFIG_FILES="$CONFIG_FILES support/Makefile" ;;
"po/Makefile.in") CONFIG_FILES="$CONFIG_FILES po/Makefile.in" ;;
"examples/loadables/Makefile") CONFIG_FILES="$CONFIG_FILES examples/loadables/Makefile" ;;
"examples/loadables/Makefile.inc") CONFIG_FILES="$CONFIG_FILES examples/loadables/Makefile.inc" ;;
"examples/loadables/perl/Makefile") CONFIG_FILES="$CONFIG_FILES examples/loadables/perl/Makefile" ;;
"support/bash.pc") CONFIG_FILES="$CONFIG_FILES support/bash.pc" ;;
"default") CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;;
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;

View file

@ -1,11 +1,11 @@
dnl
dnl Configure script for bash-4.3
dnl Configure script for bash-4.4
dnl
dnl report bugs to chet@po.cwru.edu
dnl
dnl Process this file with autoconf to produce a configure script.
# Copyright (C) 1987-2013 Free Software Foundation, Inc.
# Copyright (C) 1987-2016 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
@ -21,9 +21,9 @@ dnl Process this file with autoconf to produce a configure script.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
AC_REVISION([for Bash 4.3, version 4.063])dnl
AC_REVISION([for Bash 4.4, version 4.082])dnl
define(bashvers, 4.3)
define(bashvers, 4.4)
define(relstatus, release)
AC_INIT([bash], bashvers-relstatus, [bug-bash@gnu.org])
@ -42,7 +42,7 @@ RELSTATUS=relstatus
dnl defaults for debug settings
case "$RELSTATUS" in
alp*|bet*|dev*|rc*|maint*) DEBUG='-DDEBUG' MALLOC_DEBUG='-DMALLOC_DEBUG' ;;
alp*|bet*|dev*|rc*|releng*|maint*) DEBUG='-DDEBUG' MALLOC_DEBUG='-DMALLOC_DEBUG' ;;
*) DEBUG= MALLOC_DEBUG= ;;
esac
@ -53,8 +53,6 @@ AC_CANONICAL_BUILD
dnl configure defaults
opt_bash_malloc=yes
opt_purify=no
opt_purecov=no
opt_afs=no
opt_curses=no
opt_with_installed_readline=no
@ -113,8 +111,6 @@ AC_ARG_WITH(bash-malloc, AC_HELP_STRING([--with-bash-malloc], [use the Bash vers
AC_ARG_WITH(curses, AC_HELP_STRING([--with-curses], [use the curses library instead of the termcap library]), opt_curses=$withval)
AC_ARG_WITH(gnu-malloc, AC_HELP_STRING([--with-gnu-malloc], [synonym for --with-bash-malloc]), opt_bash_malloc=$withval)
AC_ARG_WITH(installed-readline, AC_HELP_STRING([--with-installed-readline], [use a version of the readline library that is already installed]), opt_with_installed_readline=$withval)
AC_ARG_WITH(purecov, AC_HELP_STRING([--with-purecov], [configure to postprocess with pure coverage]), opt_purecov=$withval)
AC_ARG_WITH(purify, AC_HELP_STRING([--with-purify], [configure to postprocess with purify]), opt_purify=$withval)
if test "$opt_bash_malloc" = yes; then
MALLOC_TARGET=malloc
@ -133,17 +129,6 @@ else
MALLOC_DEP=
fi
if test "$opt_purify" = yes; then
PURIFY="purify "
AC_DEFINE(DISABLE_MALLOC_WRAPPERS)
else
PURIFY=
fi
if test "$opt_purecov" = yes; then
PURIFY="${PURIFY}purecov"
fi
if test "$opt_afs" = yes; then
AC_DEFINE(AFS)
fi
@ -193,6 +178,7 @@ opt_casemod_expansions=yes
opt_extglob_default=no
opt_dircomplete_expand_default=no
opt_globascii_default=no
opt_function_import=yes
dnl options that affect how bash is compiled and linked
opt_static_link=no
@ -234,6 +220,7 @@ AC_ARG_ENABLE(disabled-builtins, AC_HELP_STRING([--enable-disabled-builtins], [a
AC_ARG_ENABLE(dparen-arithmetic, AC_HELP_STRING([--enable-dparen-arithmetic], [include ((...)) command]), opt_dparen_arith=$enableval)
AC_ARG_ENABLE(extended-glob, AC_HELP_STRING([--enable-extended-glob], [include ksh-style extended pattern matching]), opt_extended_glob=$enableval)
AC_ARG_ENABLE(extended-glob-default, AC_HELP_STRING([--enable-extended-glob-default], [force extended pattern matching to be enabled by default]), opt_extglob_default=$enableval)
AC_ARG_ENABLE(function-import, AC_HELP_STRING([--enable-function-import], [allow bash to import exported function definitions by default]), opt_function_import=$enableval)
AC_ARG_ENABLE(glob-asciiranges-default, AC_HELP_STRING([--enable-glob-asciiranges-default], [force bracket range expressions in pattern matching to use the C locale by default]), opt_globascii_default=$enableval)
AC_ARG_ENABLE(help-builtin, AC_HELP_STRING([--enable-help-builtin], [include the help builtin]), opt_help=$enableval)
AC_ARG_ENABLE(history, AC_HELP_STRING([--enable-history], [turn on command history]), opt_history=$enableval)
@ -357,6 +344,9 @@ AC_DEFINE(GLOBASCII_DEFAULT, 1)
else
AC_DEFINE(GLOBASCII_DEFAULT, 0)
fi
if test $opt_function_import = yes; then
AC_DEFINE(FUNCTION_IMPORT)
fi
if test $opt_memscramble = yes; then
AC_DEFINE(MEMSCRAMBLE)
@ -386,7 +376,6 @@ fi
dnl now substitute in the values generated by arguments
AC_SUBST(TESTSCRIPT)
AC_SUBST(PURIFY)
AC_SUBST(MALLOC_TARGET)
AC_SUBST(MALLOC_SRC)
@ -403,6 +392,14 @@ AC_SUBST(HELPINSTALL)
AC_SUBST(HELPFILES_TARGET)
AC_SUBST(HELPSTRINGS)
dnl We want these before the checks, so the checks can modify their values.
if test -z "$CFLAGS"; then
AUTO_CFLAGS="-g ${GCC+-O2} ${GCC+-Wno-parentheses}"
AUTO_LDFLAGS="-g ${GCC+-O2}"
else
AUTO_CFLAGS= AUTO_LDFLAGS=
fi
echo ""
echo "Beginning configuration for bash-$BASHVERS-$RELSTATUS for ${host_cpu}-${host_vendor}-${host_os}"
echo ""
@ -460,18 +457,16 @@ AC_SUBST(SIGNAMES_O)
dnl END changes for cross-building
dnl We want these before the checks, so the checks can modify their values.
if test -z "$CFLAGS"; then
AUTO_CFLAGS="-g ${GCC+-O2}"
AUTO_LDFLAGS="-g ${GCC+-O2}"
else
AUTO_CFLAGS= AUTO_LDFLAGS=
fi
dnl default values
CFLAGS=${CFLAGS-"$AUTO_CFLAGS"}
# LDFLAGS=${LDFLAGS="$AUTO_LDFLAGS"} # XXX
# turn off paren warnings in gcc
if test "$GCC" = yes # && test -n "$DEBUG"
then
CFLAGS="$CFLAGS -Wno-parentheses -Wno-format-security"
fi
dnl handle options that alter how bash is compiled and linked
dnl these must come after the test for cc/gcc
if test "$opt_profiling" = "yes"; then
@ -706,8 +701,8 @@ AC_CHECK_HEADERS(unistd.h stdlib.h stdarg.h varargs.h limits.h string.h \
memory.h locale.h termcap.h termio.h termios.h dlfcn.h \
stdbool.h stddef.h stdint.h netdb.h pwd.h grp.h strings.h \
regex.h syslog.h ulimit.h)
AC_CHECK_HEADERS(sys/pte.h sys/stream.h sys/select.h sys/file.h \
sys/resource.h sys/param.h sys/socket.h sys/stat.h \
AC_CHECK_HEADERS(sys/pte.h sys/stream.h sys/select.h sys/file.h sys/ioctl.h \
sys/param.h sys/socket.h sys/stat.h \
sys/time.h sys/times.h sys/types.h sys/wait.h)
AC_CHECK_HEADERS(netinet/in.h arpa/inet.h)
@ -719,8 +714,17 @@ AC_CHECK_HEADER(sys/ptem.h, , ,[[
#endif
]])
dnl SunOS 4 needs to include <sys/time.h> before <sys/resource.h> to compile
dnl autoconf complains about presence but inability to compile
AC_CHECK_HEADER(sys/resource.h, AC_DEFINE(HAVE_SYS_RESOURCE_H), [], [[
#if HAVE_SYS_TIME_H
# include <sys/time.h>
#endif
]])
dnl special checks for libc functions
AC_FUNC_ALLOCA
AC_FUNC_CHOWN
AC_FUNC_GETPGRP
AC_FUNC_SETVBUF_REVERSED
AC_FUNC_VPRINTF
@ -766,20 +770,21 @@ AC_CHECK_FUNC(mkfifo,AC_DEFINE(HAVE_MKFIFO),AC_DEFINE(MKFIFO_MISSING))
dnl checks for system calls
AC_CHECK_FUNCS(dup2 eaccess fcntl getdtablesize getgroups gethostname \
getpagesize getpeername getrlimit getrusage gettimeofday \
kill killpg lstat readlink sbrk select setdtablesize \
kill killpg lstat pselect readlink sbrk select setdtablesize \
setitimer tcgetpgrp uname ulimit waitpid)
AC_REPLACE_FUNCS(rename)
dnl checks for c library functions
AC_CHECK_FUNCS(bcopy bzero confstr faccessat fnmatch \
getaddrinfo gethostbyname getservbyname getservent inet_aton \
imaxdiv memmove pathconf putenv raise regcomp regexec \
imaxdiv memmove pathconf putenv raise random regcomp regexec \
setenv setlinebuf setlocale setvbuf siginterrupt strchr \
sysconf syslog tcgetattr times ttyname tzset unsetenv)
AC_CHECK_FUNCS(vasprintf asprintf)
AC_CHECK_FUNCS(isascii isblank isgraph isprint isspace isxdigit)
AC_CHECK_FUNCS(getpwent getpwnam getpwuid)
AC_CHECK_FUNCS(mkstemp)
AC_REPLACE_FUNCS(getcwd memset)
AC_REPLACE_FUNCS(strcasecmp strcasestr strerror strftime strnlen strpbrk strstr)
AC_REPLACE_FUNCS(strtod strtol strtoul strtoll strtoull strtoimax strtoumax)
@ -787,6 +792,7 @@ AC_REPLACE_FUNCS(dprintf)
AC_REPLACE_FUNCS(strchrnul)
AC_REPLACE_FUNCS(strdup)
AC_CHECK_HEADERS(libaudit.h)
AC_CHECK_DECLS([AUDIT_USER_TTY],,, [[#include <linux/audit.h>]])
AC_CHECK_DECLS([confstr])
@ -886,6 +892,8 @@ AC_TYPE_MODE_T
AC_TYPE_UID_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_UINTPTR_T
AC_CHECK_TYPE(ssize_t, int)
AC_CHECK_TYPE(time_t, long)
@ -1085,7 +1093,7 @@ solaris2*) LOCAL_CFLAGS=-DSOLARIS ;;
lynxos*) LOCAL_CFLAGS=-DRECYCLES_PIDS ;;
linux*) LOCAL_LDFLAGS=-rdynamic # allow dynamic loading
case "`uname -r`" in
2.[[456789]]*|3*) AC_DEFINE(PGRP_PIPE) ;;
2.[[456789]]*|[[34]]*) AC_DEFINE(PGRP_PIPE) ;;
esac ;;
*qnx6*) LOCAL_CFLAGS="-Dqnx -Dqnx6" LOCAL_LIBS="-lncurses" ;;
*qnx*) LOCAL_CFLAGS="-Dqnx -F -3s" LOCAL_LDFLAGS="-3s" LOCAL_LIBS="-lunix -lncurses" ;;
@ -1100,6 +1108,8 @@ case "${host_os}-${CC}" in
aix4.2*-*gcc*) LOCAL_LDFLAGS="-Xlinker -bexpall -Xlinker -brtl" ;;
aix4.2*) LOCAL_LDFLAGS="-bexpall -brtl" ;;
bsdi4*-*gcc*) LOCAL_LDFLAGS="-rdynamic" ;; # allow dynamic loading, like Linux
bsdi5*-*gcc*) LOCAL_LDFLAGS="-rdynamic" ;; # allow dynamic loading, like Linux
hpux11*-gcc*) LOCAL_LDFLAGS="-Wl,-E" ;; # allow dynamic loading
esac
dnl FreeBSD-3.x can have either a.out or ELF
@ -1180,6 +1190,16 @@ AC_SUBST(BUILD_DIR)
AC_SUBST(datarootdir)
AC_SUBST(localedir)
# directory where we install dynamically loadable builtins
if test -z "$loadablesdir"; then
loadablesdir='${libdir}/bash'
fi
AC_SUBST(loadablesdir)
if test -z "$headersdir"; then
headersdir='$(includedir)/$(PACKAGE_NAME)'
fi
AC_SUBST(headersdir)
AC_SUBST(YACC)
AC_SUBST(AR)
AC_SUBST(ARFLAGS)
@ -1205,7 +1225,9 @@ AC_OUTPUT([Makefile builtins/Makefile lib/readline/Makefile lib/glob/Makefile \
lib/intl/Makefile \
lib/malloc/Makefile lib/sh/Makefile lib/termcap/Makefile \
lib/tilde/Makefile doc/Makefile support/Makefile po/Makefile.in \
examples/loadables/Makefile examples/loadables/perl/Makefile],
examples/loadables/Makefile examples/loadables/Makefile.inc \
examples/loadables/perl/Makefile \
support/bash.pc],
[
# Makefile uses this timestamp file to record whether config.h is up to date.
echo timestamp > stamp-h

16
doc/FAQ
View file

@ -1,4 +1,6 @@
This is the Bash FAQ, version 4.13, for Bash version 4.3.
This is the Bash FAQ, version 4.14, for Bash version 4.4.
[THIS FAQ IS NO LONGER MAINTAINED]
This document contains a set of frequently-asked questions concerning
Bash, the GNU Bourne-Again Shell. Bash is a freely-available command
@ -144,7 +146,7 @@ of Case Western Reserve University.
A2) What's the latest version?
The latest version is 4.3, first made available on xx December, 2013.
The latest version is 4.3, first made available on 26 February, 2014.
A3) Where can I get it?
@ -2169,11 +2171,17 @@ You may also need
Finally, you need to tell readline that you will be inputting and
displaying eight-bit characters. You use readline variables to do
this. These variables can be set in your .inputrc or using the bash
this. convert-meta says what to do if you read a character with its
eighth bit set. input-meta says whether to permit characters with the
eighth bit at all. output-meta determines how to display characters
with the eighth bit set: if on, they are output directly; if it is off,
such characters are displayed as a meta-prefixed escape sequence.
These variables can be set in your .inputrc or using the bash
`bind' builtin. Here's an example using `bind':
bash$ bind 'set convert-meta off'
bash$ bind 'set meta-flag on'
bash$ bind 'set input-meta on'
bash$ bind 'set output-meta on'
The `set' commands between the single quotes may also be placed

View file

@ -1,6 +1,6 @@
# This Makefile is for the Bash/documentation directory -*- text -*-.
#
# Copyright (C) 2003-2013 Free Software Foundation, Inc.
# Copyright (C) 2003-2015 Free Software Foundation, Inc.
# 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
@ -31,7 +31,7 @@ RM = rm -f
topdir = @top_srcdir@
srcdir = @srcdir@
VPATH = .:@srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
@ -79,6 +79,8 @@ 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
DVIPS = dvips -D ${PSDPI} $(QUIETPS) -t ${PAPERSIZE} -o $@ # tricky
# experimental; uses external texi2dvi for now; this needs pdftex to be present
TEXI2PDF = texi2dvi --pdf
TEXINPUTDIR = $(RL_LIBDIR)/doc
SET_TEXINPUTS = TEXINPUTS=.:$(TEXINPUTDIR):$$TEXINPUTS
@ -90,7 +92,9 @@ PSPDF = gs -sPAPERSIZE=${PAPERSIZE} -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -s
MKDIRS = ${SUPPORT_SRCDIR}/mkdirs
# This should be a program that converts troff to an ascii-readable format
NROFF = groff -Tascii
# added the -P -c for benefit of Mac OS X, which insists on adding colors if
# it's not present
NROFF = groff -Tascii -P -c
# This should be a program that converts troff to postscript
GROFF = groff
@ -146,13 +150,17 @@ BASHREF_FILES = $(srcdir)/bashref.texi $(srcdir)/fdl.texi $(srcdir)/version.texi
${RM} $@
-${DVIPS} $<
all: ps info dvi text html
#.texi.pdf:
# $(RM) $@
# -${TEXI2PDF} $<
all: ps info dvi text html $(MAN2HTML)
nodvi: ps info text html
everything: all pdf
PSFILES = bash.ps bashbug.ps article.ps builtins.ps rbash.ps
DVIFILES = bashref.dvi bashref.ps
INFOFILES = bashref.info
INFOFILES = bashref.info bash.info
MAN0FILES = bash.0 bashbug.0 builtins.0 rbash.0
HTMLFILES = bashref.html bash.html
PDFFILES = bash.pdf bashref.pdf article.pdf rose94.pdf
@ -170,17 +178,22 @@ bashref.dvi: $(BASHREF_FILES) $(HSUSER) $(RLUSER)
bashref.info: $(BASHREF_FILES) $(HSUSER) $(RLUSER)
$(MAKEINFO) --no-split -I$(TEXINPUTDIR) $(srcdir)/bashref.texi
# experimental
bashref.pdf: $(BASHREF_FILES) $(HSUSER) $(RLUSER)
${SET_TEXINPUTS} $(TEXI2PDF) $(srcdir)/bashref.texi || { ${RM} $@ ; exit 1; }
# can also use:
# $(MAKEINFO) --html --no-split -I$(TEXINPUTDIR) $(srcdir)/bashref.texi
# $(TEXI2HTML) -menu -monolithic -I $(TEXINPUTDIR) $(srcdir)/bashref.texi
bashref.html: $(BASHREF_FILES) $(HSUSER) $(RLUSER)
$(TEXI2HTML) -menu -monolithic -I $(TEXINPUTDIR) $(srcdir)/bashref.texi
$(MAKEINFO) --html --no-split -I$(TEXINPUTDIR) $(srcdir)/bashref.texi
bash.info: bashref.info
${SHELL} ${INFOPOST} < $(srcdir)/bashref.info > $@ ; \
bash.txt: bash.1
bash.ps: bash.1
bash.html: bash.1 $(MAN2HTML)
bash.html: bash.1
bashbug.ps: bashbug.1
builtins.ps: builtins.1 bash.1
rbash.ps: rbash.1 bash.1
@ -193,7 +206,9 @@ article.ps: article.ms
bashref.ps: bashref.dvi
article.pdf: article.ps
bashref.pdf: bashref.dvi
#bashref.pdf: bashref.dvi
# experimental
bashref.pdf: bashref.texi
bash.pdf: bash.ps
rose94.pdf: rose94.ps
@ -232,7 +247,7 @@ installdirs:
$(SHELL) $(SUPPORT_SRCDIR)/mkinstalldirs $(DESTDIR)$(htmldir) ; \
fi
install: info installdirs bash.info
install: info installdirs
-$(INSTALL_DATA) $(srcdir)/bash.1 $(DESTDIR)$(man1dir)/bash${man1ext}
-$(INSTALL_DATA) $(srcdir)/bashbug.1 $(DESTDIR)$(man1dir)/bashbug${man1ext}
-$(INSTALL_DATA) $(OTHER_DOCS) $(DESTDIR)$(docdir)
@ -259,10 +274,20 @@ install_builtins: installdirs
install_everything: install install_builtins
install-html: html
-if test -n "${htmldir}" ; then \
$(INSTALL_DATA) $(srcdir)/bash.html $(DESTDIR)$(htmldir) ; \
$(INSTALL_DATA) $(srcdir)/bashref.html $(DESTDIR)$(htmldir) ; \
fi
uninstall:
-$(RM) $(DESTDIR)$(man1dir)/bash${man1ext} $(DESTDIR)$(man1dir)/bashbug${man1ext}
-$(RM) $(DESTDIR)$(man1dir)/bash_builtins${man1ext}
$(RM) $(DESTDIR)$(infodir)/bash.info
# run install-info if it is present to update the info directory
if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then \
install-info --delete --dir-file=$(DESTDIR)$(infodir)/dir $(DESTDIR)$(infodir)/bash.info; \
else true; fi
-( cd $(DESTDIR)$(docdir) && $(RM) $(OTHER_INSTALLED_DOCS) )
-if test -n "$(htmldir)" ; then \
$(RM) $(DESTDIR)$(htmldir)/bash.html ; \
@ -313,4 +338,4 @@ rbash: bashref.texi
cmp -s RBASH ../RBASH || mv RBASH ../RBASH
$(RM) RBASH
xdist: pdf inst posix rbash
xdist: everything inst posix rbash

BIN
doc/aosa-bash-full.pdf Normal file

Binary file not shown.

Binary file not shown.

2827
doc/bash.0

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

11484
doc/bash.info Normal file

File diff suppressed because it is too large Load diff

Binary file not shown.

16233
doc/bash.ps

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
BASHBUG(1) BASHBUG(1)
BASHBUG(1) General Commands Manual BASHBUG(1)
@ -27,8 +27,9 @@ DDEESSCCRRIIPPTTIIOONN
EENNVVIIRROONNMMEENNTT
bbaasshhbbuugg will utilize the following environment variables if they exist:
EEDDIITTOORR Specifies the preferred editor. If EEDDIITTOORR is not set, bbaasshhbbuugg
defaults to eemmaaccss.
EEDDIITTOORR Specifies the preferred editor. If EEDDIITTOORR is not set, bbaasshhbbuugg
attempts to locate a number of alternative editors, including
eemmaaccss, and defaults to vvii.
HHOOMMEE Directory in which the failed bug report is saved if the mail
fails.
@ -47,4 +48,4 @@ AAUUTTHHOORRSS
GNU Bash-4.0 1998 July 30 BASHBUG(1)
GNU Bash-4.4 2016 February 15 BASHBUG(1)

View file

@ -5,9 +5,9 @@
.\" Case Western Reserve University
.\" chet@po.cwru.edu
.\"
.\" Last Change: Tue Apr 3 15:46:30 EDT 2007
.\" Last Change: Mon Feb 15 14:42:40 EST 2016
.\"
.TH BASHBUG 1 "1998 July 30" "GNU Bash-4.0"
.TH BASHBUG 1 "2016 February 15" "GNU Bash-4.4"
.SH NAME
bashbug \- report a bug in bash
.SH SYNOPSIS
@ -43,8 +43,9 @@ Specifies the preferred editor. If
.B EDITOR
is not set,
.B bashbug
defaults to
.BR emacs .
attempts to locate a number of alternative editors, including
.BR emacs ,
and defaults to \fBvi\fP.
.TP
.B HOME
Directory in which the failed bug report is saved if the mail fails.

View file

@ -1,20 +1,20 @@
%!PS-Adobe-3.0
%%Creator: groff version 1.19.2
%%CreationDate: Mon Nov 17 17:38:06 2008
%%Creator: groff version 1.22.3
%%CreationDate: Mon Mar 28 15:34:55 2016
%%DocumentNeededResources: font Times-Roman
%%+ font Times-Bold
%%+ font Times-Italic
%%DocumentSuppliedResources: procset grops 1.19 2
%%DocumentSuppliedResources: procset grops 1.22 3
%%Pages: 1
%%PageOrder: Ascend
%%DocumentMedia: Default 595 842 0 () ()
%%DocumentMedia: Default 612 792 0 () ()
%%Orientation: Portrait
%%EndComments
%%BeginDefaults
%%PageMedia: Default
%%EndDefaults
%%BeginProlog
%%BeginResource: procset grops 1.19 2
%%BeginResource: procset grops 1.22 3
%!PS-Adobe-3.0 Resource-ProcSet
/setpacking where{
pop
@ -72,6 +72,7 @@ exch pop add exch pop
/level0 save def
1 setlinecap
1 setlinejoin
DEFS/BPhook known{DEFS begin BPhook end}if
72 RES div dup scale
LS{
90 rotate
@ -137,7 +138,10 @@ pop
findfont
dup maxlength 1 index/FontName known not{1 add}if dict begin
{
1 index/FID ne{def}{pop pop}ifelse
1 index/FID ne
2 index/UniqueID ne
and
{def}{pop pop}ifelse
}forall
/Encoding exch def
dup/FontName exch def
@ -175,8 +179,10 @@ newpath
userdict begin
/showpage{}def
/setpagedevice{}def
mark
}bind def
/PEND{
cleartomark
countdictstack CNT sub{end}repeat
level1 restore
}bind def
@ -189,17 +195,17 @@ setpacking
%%EndProlog
%%BeginSetup
%%BeginFeature: *PageSize Default
<< /PageSize [ 595 842 ] /ImagingBBox null >> setpagedevice
<< /PageSize [ 612 792 ] /ImagingBBox null >> setpagedevice
%%EndFeature
%%IncludeResource: font Times-Roman
%%IncludeResource: font Times-Bold
%%IncludeResource: font Times-Italic
grops begin/DEFS 1 dict def DEFS begin/u{.001 mul}bind def end/RES 72
def/PL 841.89 def/LS false def/ENC0[/asciicircum/asciitilde/Scaron
/Zcaron/scaron/zcaron/Ydieresis/trademark/quotesingle/Euro/.notdef
def/PL 792 def/LS false def/ENC0[/asciicircum/asciitilde/Scaron/Zcaron
/scaron/zcaron/Ydieresis/trademark/quotesingle/Euro/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/space/exclam/quotedbl/numbersign/dollar/percent
/.notdef/.notdef/space/exclam/quotedbl/numbersign/dollar/percent
/ampersand/quoteright/parenleft/parenright/asterisk/plus/comma/hyphen
/period/slash/zero/one/two/three/four/five/six/seven/eight/nine/colon
/semicolon/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O
@ -229,13 +235,14 @@ def/PL 841.89 def/LS false def/ENC0[/asciicircum/asciitilde/Scaron
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Times-Roman@0 SF -.35(BA)72 48 S(SHB).35 E 347.52(UG\(1\) B)-.1 F
(ASHB)-.35 E(UG\(1\))-.1 E/F1 10.95/Times-Bold@0 SF -.219(NA)72 84 S(ME)
.219 E F0(bashb)108 96 Q(ug \255 report a b)-.2 E(ug in bash)-.2 E F1
(SYNOPSIS)72 112.8 Q/F2 10/Times-Bold@0 SF(bashb)108 124.8 Q(ug)-.2 E F0
([)2.5 E/F3 10/Times-Italic@0 SF(--ver)A(sion)-.1 E F0 2.5(][)C F3
(--help)-2.5 E F0 2.5(][)C F3(email-addr)-2.5 E(ess)-.37 E F0(])A F1
(DESCRIPTION)72 141.6 Q F2(bashb)108 153.6 Q(ug)-.2 E F0 .446
/F0 10/Times-Roman@0 SF -.35(BA)72 48 S(SHB).35 E 116.13
(UG\(1\) General)-.1 F(Commands Manual)2.5 E -.35(BA)118.63 G(SHB).35 E
(UG\(1\))-.1 E/F1 10.95/Times-Bold@0 SF -.219(NA)72 84 S(ME).219 E F0
(bashb)108 96 Q(ug \255 report a b)-.2 E(ug in bash)-.2 E F1(SYNOPSIS)72
112.8 Q/F2 10/Times-Bold@0 SF(bashb)108 124.8 Q(ug)-.2 E F0([)2.5 E/F3
10/Times-Italic@0 SF(--ver)A(sion)-.1 E F0 2.5(][)C F3(--help)-2.5 E F0
2.5(][)C F3(email-addr)-2.5 E(ess)-.37 E F0(])A F1(DESCRIPTION)72 141.6
Q F2(bashb)108 153.6 Q(ug)-.2 E F0 .446
(is a shell script to help the user compose and mail b)2.947 F .446
(ug reports concerning bash in a standard for)-.2 F(-)-.2 E(mat.)108
165.6 Q F2(bashb)5.961 E(ug)-.2 E F0(in)3.461 E -.2(vo)-.4 G -.1(ke).2 G
@ -265,20 +272,23 @@ F0(in the in)2.5 E -.2(vo)-.4 G(king user').2 E 2.5(sh)-.55 G
(Fix)5 E(es are encouraged.)-.15 E F1(ENVIR)72 271.2 Q(ONMENT)-.329 E F2
(bashb)108 283.2 Q(ug)-.2 E F0(will utilize the follo)2.5 E(wing en)-.25
E(vironment v)-.4 E(ariables if the)-.25 E 2.5(ye)-.15 G(xist:)-2.65 E
F2(EDIT)108 300 Q(OR)-.18 E F0(Speci\214es the preferred editor)144 312
Q 2.5(.I)-.55 G(f)-2.5 E F4(EDIT)2.5 E(OR)-.162 E F0(is not set,)2.25 E
F2(bashb)2.5 E(ug)-.2 E F0(def)2.5 E(aults to)-.1 E F2(emacs)2.5 E F0(.)
A F2(HOME)108 328.8 Q F0(Directory in which the f)144 340.8 Q(ailed b)
-.1 E(ug report is sa)-.2 E -.15(ve)-.2 G 2.5(di).15 G 2.5(ft)-2.5 G
(he mail f)-2.5 E(ails.)-.1 E F2(TMPDIR)108 357.6 Q F0
F2(EDIT)108 300 Q(OR)-.18 E F0 .327(Speci\214es the preferred editor)144
312 R 2.827(.I)-.55 G(f)-2.827 E F4(EDIT)2.827 E(OR)-.162 E F0 .327
(is not set,)2.577 F F2(bashb)2.827 E(ug)-.2 E F0 .328
(attempts to locate a number of alter)2.827 F(-)-.2 E(nati)144 324 Q .3
-.15(ve e)-.25 H(ditors, including).15 E F2(emacs)2.5 E F0 2.5(,a)C
(nd def)-2.5 E(aults to)-.1 E F2(vi)2.5 E F0(.)A F2(HOME)108 340.8 Q F0
(Directory in which the f)144 352.8 Q(ailed b)-.1 E(ug report is sa)-.2
E -.15(ve)-.2 G 2.5(di).15 G 2.5(ft)-2.5 G(he mail f)-2.5 E(ails.)-.1 E
F2(TMPDIR)108 369.6 Q F0
(Directory in which to create temporary \214les and directories.)144
369.6 Q F1(SEE ALSO)72 386.4 Q F3(bash)108 398.4 Q F0(\(1\))A F1 -.548
(AU)72 415.2 S(THORS).548 E F0(Brian F)108 427.2 Q(ox, Free Softw)-.15 E
(are F)-.1 E(oundation)-.15 E(bfox@gnu.or)108 439.2 Q(g)-.18 E
(Chet Rame)108 456 Q 1.3 -.65(y, C)-.15 H(ase W).65 E(estern Reserv)-.8
381.6 Q F1(SEE ALSO)72 398.4 Q F3(bash)108 410.4 Q F0(\(1\))A F1 -.548
(AU)72 427.2 S(THORS).548 E F0(Brian F)108 439.2 Q(ox, Free Softw)-.15 E
(are F)-.1 E(oundation)-.15 E(bfox@gnu.or)108 451.2 Q(g)-.18 E
(Chet Rame)108 468 Q 1.3 -.65(y, C)-.15 H(ase W).65 E(estern Reserv)-.8
E 2.5(eU)-.15 G(ni)-2.5 E -.15(ve)-.25 G(rsity).15 E(chet@po.cwru.edu)
108 468 Q(GNU Bash-4.0)72 768 Q(1998 July 30)148.175 E(1)203.165 E 0 Cg
EP
108 480 Q(GNU Bash-4.4)72 768 Q(2016 February 15)138.46 E(1)193.45 E 0
Cg EP
%%Trailer
end
%%EOF

Binary file not shown.

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

Binary file not shown.

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
RBASH(1) RBASH(1)
RBASH(1) General Commands Manual RBASH(1)
@ -18,16 +18,16 @@ RREESSTTRRIICCTTEEDD SSHHEELLLL
+o specifying command names containing //
+o specifying a filename containing a // as an argument to the ..
+o specifying a filename containing a // as an argument to the ..
builtin command
+o specifying a filename containing a slash as an argument to the
+o specifying a filename containing a slash as an argument to the
--pp option to the hhaasshh builtin command
+o importing function definitions from the shell environment at
+o importing function definitions from the shell environment at
startup
+o parsing the value of SSHHEELLLLOOPPTTSS from the shell environment at
+o parsing the value of SSHHEELLLLOOPPTTSS from the shell environment at
startup
+o redirecting output using the >, >|, <>, >&, &>, and >> redirect-
@ -36,10 +36,10 @@ RREESSTTRRIICCTTEEDD SSHHEELLLL
+o using the eexxeecc builtin command to replace the shell with another
command
+o adding or deleting builtin commands with the --ff and --dd options
+o adding or deleting builtin commands with the --ff and --dd options
to the eennaabbllee builtin command
+o using the eennaabbllee builtin command to enable disabled shell
+o using the eennaabbllee builtin command to enable disabled shell
builtins
+o specifying the --pp option to the ccoommmmaanndd builtin command
@ -48,8 +48,8 @@ RREESSTTRRIICCTTEEDD SSHHEELLLL
These restrictions are enforced after any startup files are read.
When a command that is found to be a shell script is executed, rrbbaasshh
turns off any restrictions in the shell spawned to execute the script.
When a command that is found to be a shell script is executed, rrbbaasshh
turns off any restrictions in the shell spawned to execute the script.
SSEEEE AALLSSOO
bash(1)

Some files were not shown because too many files have changed in this diff Show more