so a function that returns a non-zero value and triggers an ERR trap
has the right value for LINENO. Any simple command in the function
body can change it. Bug report from Paul Donohue <gnu@paulsd.com>
+
+ 3/5
+ ---
+lib/sh/shquote.c
+ - sh_backslash_quote: cast `c' to `unsigned char' before using as
+ index into backslash_table. Report and fix from
+ alexeyv.90@gmail.com
+
+arrayfunc.[ch]
+ - valid_array_reference: added second `flags' argument for future use;
+ currently unused
+
+parse.y,{redir,subst,variables,test}.c
+builtins/{declare,printf,read,set}.def
+ - valid_array_reference: changed callers
+
+ 3/7
+ ---
+lib/readline/signals.c
+ - _rl_handle_signal: if readline gets a SIGTSTP or SIGTTIN, block
+ SIGTTOU so a backgrounded readline can reset the terminal settings
+ appropriately, otherwise the terminal state and readline's idea
+ of it can get messed up. Original report from Dave Wysochanski
+ <dwysocha@redhat.com> and Dave Anderson <anderson@redhat.com>
+
+trap.c
+ - run_pending_traps: don't allow recursive SIGWINCH trap invocations;
+ they're wasteful and trying to handle a stream of signals while a
+ user resizes the terminal can lead to malloc errors trying to save
+ and restore the_pipeline multiple times. Problem reported most
+ recently by Martin M. S. Pederson (Fedora bash bug 1197768
+ https://bugzilla.redhat.com/show_bug.cgi?id=1197768)
+ - reset_or_restore_signal_handlers: set pending_traps to 0 for all
+ signals when forking a child. TENTATIVE fix
+
+jobs.c
+ - {save,restore}_pipeline: block SIGCHLD while manipulating the_pipeline
+ like cleanup_the_pipeline does. XXX - may not be necessary
+
+lib/readline/display.c
+ - rl_redisplay: fixed case where multibyte character in the prompt
+ (e.g., \u03bb) in the last screen column causes problems with line
+ wrapping because the newline marker is put in the middle of the
+ multibyte char. Most recently reported on Ubuntu by
+ <sterpe@gmail.com>
+
+pathexp.c
+ - quote_string_for_globbing: if a bracket expression doesn't have a
+ closing right bracket, rescan it from just after the opening
+ bracket without treating it as a bracket expression. Bug report
+ from Stephane Chazelas <stephane.chazelas@gmail.com>
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.
-
-To find out more about the options and arguments that the `configure'
+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'
script understands, type
bash-2.04$ ./configure --help
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'.
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
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.
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.
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.
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.
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.
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'
+'--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-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.
+ 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
+'--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-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.
+'--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.
+
+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.
+
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
+ 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.
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
+ 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'.
+ by 'command'.
- 10. 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').
- 11. The output of `kill -l' prints all the signal names on a single
- line, separated by spaces, without the `SIG' prefix.
+ 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'
+ 12. The 'kill' builtin does not accept signal names with a 'SIG'
prefix.
- 13. Non-interactive shells exit if FILENAME in `.' FILENAME is not
+ 13. Non-interactive shells exit if FILENAME in '.' FILENAME is not
found.
- 14. Non-interactive shells exit if a syntax error in an arithmetic
+ 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.
+ 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.
+ 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
+ 17. 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
+ 18. 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
+ 19. Function names may not be the same as one of the POSIX special
builtins.
- 20. POSIX special builtins are found before shell functions during
+ 20. 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
+ 21. Literal tildes that appear as the first character in elements of
+ the 'PATH' variable are not expanded as described above under *note
+ Tilde Expansion::.
+
+ 22. 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
+ 23. 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 `-'.
+ 24. 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
+ 25. 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
+ 26. 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
+ 27. 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.
+ 28. 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.
+ 29. Process substitution is not available.
- 29. While variable indirection is available, it may not be applied to
- the `#' and `?' special parameters.
+ 30. While variable indirection is available, it may not be applied to
+ the '#' and '?' special parameters.
- 30. Assignment statements preceding POSIX special builtins persist in
+ 31. 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
+ 32. 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
+ 33. 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'.
+ 34. The 'trap' builtin displays signal names without the leading
+ 'SIG'.
- 34. The `trap' builtin doesn't check the first argument for a possible
+ 35. 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'.
+ 36. 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.
+ 37. 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.
- 37. Alias expansion is always enabled, even in non-interactive shells.
+ 38. 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
+ 39. 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
+ 40. 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
+ 41. 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
+ 42. 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
+ 43. 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
+ 44. 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'.
+ 45. 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'.
+ 46. 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'.
+ 47. 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
+ 48. 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.
+ 49. 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.
+ 50. 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
+ 51. 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.
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::).
+
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.
/* Return 1 if NAME is a properly-formed array reference v[sub]. */
int
-valid_array_reference (name)
+valid_array_reference (name, flags)
char *name;
+ int flags;
{
char *t;
int r, len;
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 int valid_array_reference __P((char *, int));
extern char *array_value __P((char *, int, int, int *, arrayind_t *));
extern char *get_array_value __P((char *, int, int *, arrayind_t *));
if (flags_on & att_nameref)
{
#if defined (ARRAY_VARIABLES)
- if (valid_array_reference (name))
+ if (valid_array_reference (name, 0))
{
builtin_error (_("%s: reference variable cannot be an array"), name);
assign_error++;
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 && valid_array_reference (name, 0) == 0)
{
sh_invalidid (name);
assign_error++;
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
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);
/* 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
{
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
/* 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
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);
#if defined (ARRAY_VARS)
unset_array = 0;
- if (!unset_function && valid_array_reference (name))
+ if (!unset_function && valid_array_reference (name, 0))
{
t = strchr (name, '[');
*t++ = '\0';
mkdir_builtin (list)
WORD_LIST *list;
{
- int opt, pflag, omode, rval, octal, nmode, parent_mode, um;
+ int opt, pflag, omode, rval, nmode, parent_mode;
char *mode;
WORD_LIST *l;
builtin_error ("invalid file mode: %s", mode);
return (EXECUTION_FAILURE);
}
- octal = 1;
}
else if (mode)
{
builtin_error ("invalid file mode: %s", mode);
return (EXECUTION_FAILURE);
}
- octal = 0;
}
/* Make the new mode */
save_pipeline (clear)
int clear;
{
+ sigset_t set, oset;
+
+ BLOCK_CHILD (set, oset);
saved_pipeline = the_pipeline;
if (clear)
the_pipeline = (PROCESS *)NULL;
saved_already_making_children = already_making_children;
+ UNBLOCK_CHILD (oset);
}
void
int discard;
{
PROCESS *old_pipeline;
+ sigset_t set, oset;
+ BLOCK_CHILD (set, oset);
old_pipeline = the_pipeline;
the_pipeline = saved_pipeline;
already_making_children = saved_already_making_children;
+ UNBLOCK_CHILD (oset);
+
if (discard && old_pipeline)
discard_pipeline (old_pipeline);
}
contents of the command line? */
while (lpos >= _rl_screenwidth)
{
- int z;
+ int z, p;
/* fix from Darin Johnson <darin@acuson.com> for prompt string with
invisible characters that is longer than the screen width. The
prompt_invis_chars_first_line variable could be made into an array
break;
}
else if (z == _rl_screenwidth)
- break;
+ {
+ /* If we are in the middle or at the end of a multibyte
+ character, we want to move to the start, then find out
+ where it ends so we know where to insert the newline.
+ If this isn't a multibyte character, its the same as num++ */
+ p = _rl_find_prev_mbchar (local_prompt, num, MB_FIND_ANY);
+ num = _rl_find_next_mbchar (local_prompt, p, 1, MB_FIND_ANY);
+ break;
+ }
num++;
}
temp = num;
rl_free_line_state ();
/* FALLTHROUGH */
- case SIGTERM:
- case SIGHUP:
#if defined (SIGTSTP)
case SIGTSTP:
- case SIGTTOU:
case SIGTTIN:
+# if defined (HAVE_POSIX_SIGNALS)
+ /* Block SIGTTOU so we can restore the terminal settings to something
+ sane without stopping on SIGTTOU if we have been placed into the
+ background. Even trying to get the current terminal pgrp with
+ tcgetpgrp() will generate SIGTTOU, so we don't bother. Don't bother
+ doing this if we've been stopped on SIGTTOU; it's aready too late. */
+ sigemptyset (&set);
+ sigaddset (&set, SIGTTOU);
+ sigprocmask (SIG_BLOCK, &set, (sigset_t *)NULL);
+# endif
+ case SIGTTOU:
#endif /* SIGTSTP */
+ case SIGTERM:
+ case SIGHUP:
#if defined (SIGALRM)
case SIGALRM:
#endif
rl_cleanup_after_signal ();
#if defined (HAVE_POSIX_SIGNALS)
+ /* Unblock SIGTTOU blocked above */
+ if (sig == SIGTTIN || sig == SIGTSTP)
+ sigprocmask (SIG_UNBLOCK, &set, (sigset_t *)NULL);
+
sigemptyset (&set);
sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &set);
sigdelset (&set, sig);
continue;
}
#endif
- if (backslash_table[c] == 1)
+ if (backslash_table[(unsigned char)c] == 1)
*r++ = '\\';
else if (c == '#' && s == string) /* comment char */
*r++ = '\\';
/* can use token; already copied to the_word */
token[token_index-1] = '\0';
#if defined (ARRAY_VARS)
- if (legal_identifier (token+1) || valid_array_reference (token+1))
+ if (legal_identifier (token+1) || valid_array_reference (token+1, 0))
#else
if (legal_identifier (token+1))
#endif
char *temp;
register int i, j;
int brack, cclass, collsym, equiv, c, last_was_backslash;
+ int savei, savej;
temp = (char *)xmalloc (2 * strlen (pathname) + 1);
{
brack = 1;
temp[j++] = pathname[i++]; /* open bracket */
+ savej = j;
+ savei = i;
c = pathname[i++]; /* c == char after open bracket */
do
{
else
temp[j++] = c;
}
- while ((c = pathname[i++]) != ']');
+ while (((c = pathname[i++]) != ']') && c != 0);
+
+ /* If we don't find the closing bracket before we hit the end of
+ the string, rescan string without treating it as a bracket
+ expression (has implications for backslash and special ERE
+ chars) */
+ if (c == 0)
+ {
+ i = savei - 1; /* -1 for autoincrement above */
+ j = savej;
+ continue;
+ }
+
temp[j++] = c; /* closing right bracket */
i--; /* increment will happen above in loop */
continue; /* skip double assignment below */
w = redir->redirector.filename->word; /* shorthand */
/* XXX - handle set -u here? */
#if defined (ARRAY_VARS)
- if (vr = valid_array_reference (w))
+ if (vr = valid_array_reference (w, 0))
v = array_variable_part (w, &sub, &len);
else
#endif
else if (var_is_special)
return 1;
#if defined (ARRAY_VARS)
- else if (valid_array_reference (name))
+ else if (valid_array_reference (name, 0))
return 1;
#endif /* ARRAY_VARS */
else if (legal_identifier (name))
/* Now check for ${array[@]} and ${array[*]} */
#if defined (ARRAY_VARS)
- else if (valid_array_reference (name))
+ else if (valid_array_reference (name, 0))
{
temp1 = mbschr (name, '[');
if (temp1 && temp1[1] == '@' && temp1[2] == ']')
free (tt);
}
#if defined (ARRAY_VARS)
- else if (valid_array_reference (name))
+ else if (valid_array_reference (name, 0))
{
expand_arrayref:
/* XXX - does this leak if name[@] or name[*]? */
temp = nameref_cell (var);
#if defined (ARRAY_VARS)
/* Handle expanding nameref whose value is x[n] */
- if (temp && *temp && valid_array_reference (temp))
+ if (temp && *temp && valid_array_reference (temp, 0))
{
name = temp;
goto expand_arrayref;
}
#if defined (ARRAY_VARS)
- if (valid_array_reference (vname))
+ if (valid_array_reference (vname, 0))
assign_array_element (vname, t1, 0);
else
#endif /* ARRAY_VARS */
((sh_syntaxtab[(unsigned char) name[1]] & CSPECVAR) && name[2] == '\0') || /* special param */
(DIGIT (name[1]) && all_digits (name + 1)) || /* ${#11} */
#if defined (ARRAY_VARS)
- valid_array_reference (name + 1) || /* ${#a[7]} */
+ valid_array_reference (name + 1, 0) || /* ${#a[7]} */
#endif
legal_identifier (name + 1)); /* ${#PS1} */
}
FREE (t);
}
#if defined (ARRAY_VARS)
- else if (valid_array_reference (name + 1))
+ else if (valid_array_reference (name + 1, 0))
number = array_length_reference (name + 1);
#endif /* ARRAY_VARS */
else
*varp = (SHELL_VAR *)NULL;
#if defined (ARRAY_VARS)
- if (valid_array_reference (vname))
+ if (valid_array_reference (vname, 0))
{
v = array_variable_part (vname, &temp, (int *)0);
/* If we want to signal array_value to use an already-computed index,
#if defined (ARRAY_VARS)
/* Process ${!ARRAY[@]} and ${!ARRAY[*]} expansion. */ /* [ */
if (want_indir && string[sindex - 1] == RBRACE &&
- string[sindex - 2] == ']' && valid_array_reference (name+1))
+ string[sindex - 2] == ']' && valid_array_reference (name+1, 0))
{
char *x, *x1;
}
#if defined (ARRAY_VARS)
- if (valid_array_reference (name))
+ if (valid_array_reference (name, 0))
chk_atstar (name, quoted, quoted_dollar_atp, contains_dollar_at);
#endif
{
temp = nameref_cell (var);
#if defined (ARRAY_VARS)
- if (temp && *temp && valid_array_reference (temp))
+ if (temp && *temp && valid_array_reference (temp, 0))
{
tdesc = parameter_brace_expand_word (temp, SPECIAL_VAR (temp, 0), quoted, pflags, (arrayind_t *)NULL);
if (tdesc == &expand_wdesc_error || tdesc == &expand_wdesc_fatal)
case 'v':
v = find_variable (arg);
#if defined (ARRAY_VARS)
- if (v == 0 && valid_array_reference (arg))
+ if (v == 0 && valid_array_reference (arg, 0))
{
char *t;
t = array_value (arg, 0, 0, (int *)0, (arrayind_t *)0);
#if defined (DEBUG)
internal_warning ("run_pending_traps: recursive invocation while running trap for signal %d", running_trap-1);
#endif
-#if 0
- return; /* no recursive trap invocations */
+#if defined (SIGWINCH)
+ if (running_trap == SIGWINCH+1 && pending_traps[SIGWINCH])
+ return; /* no recursive SIGWINCH trap invocations */
#else
;
#endif
}
else if (sigmodes[i] & SIG_SPECIAL)
(*reset) (i);
+ pending_traps[i] = 0; /* XXX */
}
/* Command substitution and other child processes don't inherit the
newval = nameref_cell (entry);
#if defined (ARRAY_VARS)
/* declare -n foo=x[2] */
- if (valid_array_reference (newval))
+ if (valid_array_reference (newval, 0))
/* XXX - should it be aflags? */
entry = assign_array_element (newval, make_variable_value (entry, value, 0), aflags);
else
if (nameref_cell (nv) == 0)
return (bind_variable_internal (nv->name, value, nvc->table, 0, flags));
#if defined (ARRAY_VARS)
- else if (valid_array_reference (nameref_cell (nv)))
+ else if (valid_array_reference (nameref_cell (nv), 0))
return (assign_array_element (nameref_cell (nv), value, flags));
else
#endif
{
t = make_variable_value (var, value, aflags);
#if defined (ARRAY_VARS)
- if ((aflags & ASS_NAMEREF) && (t == 0 || *t == 0 || (legal_identifier (t) == 0 && valid_array_reference (t) == 0)))
+ if ((aflags & ASS_NAMEREF) && (t == 0 || *t == 0 || (legal_identifier (t) == 0 && valid_array_reference (t, 0) == 0)))
#else
if ((aflags & ASS_NAMEREF) && (t == 0 || *t == 0 || legal_identifier (t) == 0))
#endif
isint = isarr = implicitarray = 0;
#if defined (ARRAY_VARS)
- if (valid_array_reference (lhs))
+ if (valid_array_reference (lhs, 0))
{
isarr = 1;
v = array_variable_part (lhs, (char **)0, (int *)0);