mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-06-27 23:53:18 +02:00
bash-5.2-alpha release
This commit is contained in:
@@ -1,3 +1,326 @@
|
||||
This document details the changes between this version, bash-5.2-alpha, and
|
||||
the previous version, bash-5.1-release.
|
||||
|
||||
1. Changes to Bash
|
||||
|
||||
a. Fixed a bug that assigned a value to the variable name supplied as an
|
||||
argument to `wait -p' when there were no jobs.
|
||||
|
||||
b. Fixed a bug that resulted in performing incorrect word expansion on the
|
||||
key/value pairs in a compound array assignment.
|
||||
|
||||
c. Fixed a bug that could put the child forked to run a command substitution
|
||||
into the wrong process group.
|
||||
|
||||
d. Fixed a problem that could cause the lastpipe option to work incorrectly if
|
||||
file descriptor 0 was closed.
|
||||
|
||||
e. Bash tries to suppress traps if a forked child receives a trapped signal
|
||||
before it has a chance to reset its signal handlers.
|
||||
|
||||
f. Fixed several memory leaks in compound array assignments.
|
||||
|
||||
g. Fixed a problem with performing an assignment with `+=' to an array element
|
||||
that was the value of a nameref.
|
||||
|
||||
h. Fixed a bug that could cause a nameref containing an array reference using
|
||||
`@' or `*' not to expand to multiple words.
|
||||
|
||||
i. Fixed a bug where extended glob functions could match `.' or `..' when it
|
||||
wasn't explicitly specified, even if dotglob was set.
|
||||
|
||||
j. Fixed a bug that caused non-interactive posix-mode shells not to exit on a
|
||||
variable assignment error while assigning into the temporary environment.
|
||||
|
||||
k. Fixed a bug that caused parsing errors if an alias contained a compound
|
||||
array assignment.
|
||||
|
||||
l. Fixed a couple of instances where bash checked syntax too aggressively when
|
||||
trying to determine how to add a partial command to command-oriented
|
||||
history.
|
||||
|
||||
m. Fixed a parser problem that caused it not to allow reserved words to follow
|
||||
the `((' and `[[' commands.
|
||||
|
||||
n. Fixed a bad offset calculation when using negative offsets to `history -d'.
|
||||
|
||||
o. Fixed an off-by-one error that caused a read past the end of a buffer when
|
||||
reading a multibyte character from the output of a command substitution.
|
||||
|
||||
p. Fixed a problem with a failed `exec' command not setting $? to the right
|
||||
value for an exit trap.
|
||||
|
||||
q. Fixed a problem that caused bash not to unlink FIFOs created as part of
|
||||
expanding redirections for an external command.
|
||||
|
||||
r. Fixed a bug that could cause aliases not to be expanded in case statements.
|
||||
|
||||
s. Fixed a bug that could cause word completion to attempt programmable
|
||||
completion for the target of a redirection, instead of filename completion.
|
||||
|
||||
t. Fixed a bug that could result in errors after rebinding a key sequence with
|
||||
`bind -x' multiple times.
|
||||
|
||||
u. Fixed a problem that could result in not quoting the result when performing
|
||||
command name completion with a glob pattern in the command name.
|
||||
|
||||
v. `mapfile' now uses fully-buffered reads in more cases, which should improve
|
||||
bulk read performance.
|
||||
|
||||
w. Fixed a bug that caused `wait -n' to not reset its internal state when
|
||||
interrupted by a signal, resulting in subsequent calls failing.
|
||||
|
||||
x. Fixed a bug with parsing numeric arguments to readline key sequences
|
||||
installed with `bind -x'.
|
||||
|
||||
y. Bash suppresses forking in several additional cases, including most uses
|
||||
of $(<file).
|
||||
|
||||
z. If there are multiple `!' tokens in a [[ command, toggle the invert state
|
||||
instead of setting it unconditionally.
|
||||
|
||||
aa. Fixed a bug where running `fc' on an empty history list would cause the
|
||||
shell to crash.
|
||||
|
||||
bb. Word completion now checks whether or not a quote character closes a
|
||||
quoted string begun on a previous line, so readline doesn't interpret the
|
||||
quote as starting a new quoted string.
|
||||
|
||||
cc. Fixed a typo that translated \UNNNNNNNN characters that were not valid in
|
||||
the current locale encoding as \uNNNNNNNN.
|
||||
|
||||
dd. Fixed an issue that could cause bash to print timing statistics for the
|
||||
wrong command when `set -e' causes a command to fail.
|
||||
|
||||
ee. Bash now runs the exit trap in function context if a failed command in
|
||||
the function causes the shell to exit.
|
||||
|
||||
ff. Some fixes to how subshells modify $SHLVL.
|
||||
|
||||
gg. Fixed a bug that caused `mapfile -t' not to remove the delimiter when the
|
||||
delimiter is > 128 in the current encoding.
|
||||
|
||||
hh. Fixed a problem that could cause the shell to attempt to free unallocated
|
||||
memory if an expansion error occurred.
|
||||
|
||||
ii. Fixed a bug in the bash malloc implementation of malloc_usable_size. Bash
|
||||
did not use it, but it could cause problems with library functions that
|
||||
did.
|
||||
|
||||
jj. If the `exec' builtin fails, and the shell does not exit, it restores
|
||||
trapped signals to their trapped state.
|
||||
|
||||
kk. Fixed a bug that could cause variable assignment arguments to `declare' to
|
||||
expand variables using attributes that the call to declare was turning off.
|
||||
|
||||
ll. Fixed a bug with LINENO and arithmetic for commands.
|
||||
|
||||
mm. Fixed a posix-mode bug that caused tildes not to be expanded after an
|
||||
unquoted colon on the right side of an assignment statement.
|
||||
|
||||
nn. Fixed a problem with `caller' and line numbers when executing an ERR trap.
|
||||
|
||||
oo. Fixed a problem that could make the value returned by ${a:=b} not be the
|
||||
final value assigned to a (e.g., if `a' has an attribute that modifies
|
||||
the value on assignment).
|
||||
|
||||
pp. Fixed a problem with saving multi-line here-documents to the history list
|
||||
where the here-document delimiter does not appear on the first line.
|
||||
|
||||
qq. Fixed a bug with using += to assign to dynamic variables like RANDOM.
|
||||
|
||||
rr. Fixed a bug that caused `set -n' to modify $? if set after execution had
|
||||
started.
|
||||
|
||||
ss. Builtins like printf/read/wait now behave more consistently when assigning
|
||||
arbitrary keys to associative arrays (like `]'. when appropriately quoted).
|
||||
|
||||
tt. Fixed a problem with here-document collection printing the wrong prompt
|
||||
when parsing a compound list in an interactive shell.
|
||||
|
||||
uu. Fixed a problem with quoting shell expansion characters (like `$') when
|
||||
they appear in a tab-completed word along with characters that do need
|
||||
quoting (e.g.. $HOME/VirtualBox VMs).
|
||||
|
||||
2. Changes to Readline
|
||||
|
||||
a. Fixed a problem with cleaning up active marks when using callback mode.
|
||||
|
||||
b. Fixed a problem with arithmetic comparison operators checking the version.
|
||||
|
||||
c. Fixed a problem that could cause readline not to build on systems without
|
||||
POSIX signal functions.
|
||||
|
||||
d. Fixed a bug that could cause readline to crash if the application removed
|
||||
the callback line handler before readline read all typeahead.
|
||||
|
||||
e. Added additional checks for read errors in the middle of readline commands.
|
||||
|
||||
f. Fixed a redisplay problem that occurred when switching from the digit-
|
||||
argument prompt `(arg: N)' back to the regular prompt and the regular
|
||||
prompt contained invisible characters.
|
||||
|
||||
g. Fixed a problem with restoring the prompt when aborting an incremental
|
||||
search.
|
||||
|
||||
h. Fix a problem with characters > 128 not being displayed correctly in certain
|
||||
single-byte encodings.
|
||||
|
||||
i. Fixed a problem with unix-filename-rubout that caused it to delete too much
|
||||
when applied to a pathname consisting only of one or more slashes.
|
||||
|
||||
j. Fixed a display problem that caused the prompt to be wrapped incorrectly if
|
||||
the screen changed dimensions during a call to readline() and the prompt
|
||||
became longer than the screen width.
|
||||
|
||||
k. Fixed a problem that caused the \r output by turning off bracketed paste
|
||||
to overwrite the line if terminal echo was disabled.
|
||||
|
||||
l. Fixed a bug that could cause colored-completion-prefix to not display if
|
||||
completion-prefix-display-length was set.
|
||||
|
||||
m. Fixed a problem with line wrapping prompts when a group of invisible
|
||||
characters runs to the right edge of the screen and the prompt extends
|
||||
longer then the screen width.
|
||||
|
||||
n. Fixed a couple problems that could cause rl_end to be set incorrectly by
|
||||
transpose-words.
|
||||
|
||||
3. New Features in Bash
|
||||
|
||||
a. The bash malloc returns memory that is aligned on 16-byte boundaries.
|
||||
|
||||
b. There is a new internal timer framework used for read builtin timeouts.
|
||||
|
||||
c. Rewrote the command substitution parsing code to call the parser recursively
|
||||
and rebuild the command string from the parsed command. This allows better
|
||||
syntax checking and catches errors much earlier.
|
||||
|
||||
d. The `ulimit' builtin now treats an operand remaining after all of the options
|
||||
and arguments are parsed as an argument to the last command specified by
|
||||
an option. This is for POSIX compatibility.
|
||||
|
||||
e. Here-document parsing now handles $'...' and $"..." quoting when reading the
|
||||
here-document body.
|
||||
|
||||
f. The `shell-expand-line' and `history-and-alias-expand-line' bindable readline
|
||||
commands now understand $'...' and $"..." quoting.
|
||||
|
||||
g. There is a new `spell-correct-word' bindable readline command to perform
|
||||
spelling correction on the current word.
|
||||
|
||||
h. The `unset' builtin now attempts to treat arguments as array subscripts
|
||||
without parsing or expanding the subscript, even when `assoc_expand_once'
|
||||
is not set.
|
||||
|
||||
i. There is a default value for $BASH_LOADABLES_PATH in config-top.h.
|
||||
|
||||
j. Associative array assignment and certain instances of referencing (e.g.,
|
||||
`test -v' now allow `@' and `*' to be used as keys.
|
||||
|
||||
k. Bash attempts to expand indexed array subscripts only once when executing
|
||||
shell constructs and word expansions.
|
||||
|
||||
l. The `unset' builtin allows a subscript of `@' or `*' to unset a key with
|
||||
that value for associative arrays instead of unsetting the entire array
|
||||
(which you can still do with `unset arrayname'). For indexed arrays, it
|
||||
removes all elements of the array without unsetting it (like `A=()').
|
||||
|
||||
m. Additional builtins (printf/test/read/wait) do a better job of not
|
||||
parsing array subscripts if array_expand_once is set.
|
||||
|
||||
n. New READLINE_ARGUMENT variable set to numeric argument for readline commands
|
||||
defined using `bind -x'.
|
||||
|
||||
o. The new `varredir_close' shell option causes bash to automatically close
|
||||
file descriptors opened with {var}<fn and other styles of varassign
|
||||
redirection unless they're arguments to the `exec' builtin.
|
||||
|
||||
p. The `$0' special parameter is now set to the name of the script when running
|
||||
any (non-interactive) startup files such as $BASH_ENV.
|
||||
|
||||
q. The `enable' builtin tries to load a loadable builtin using the default
|
||||
search path if `enable name' (without any options) attempts to enable a
|
||||
non-existent builtin.
|
||||
|
||||
r. The `printf' builtin has a new format specifier: %Q. This acts like %q but
|
||||
applies any specified precision to the original unquoted argument, then
|
||||
quotes and outputs the result.
|
||||
|
||||
s. The new `noexpand_translations' option controls whether or not the translated
|
||||
output of $"..." is single-quoted.
|
||||
|
||||
t. There is a new parameter transformation operator: @k. This is like @K, but
|
||||
expands the result to separate words after word splitting.
|
||||
|
||||
u. There is an alternate array implementation, selectable at `configure' time,
|
||||
that optimizes access speed over memory use (use the new configure
|
||||
--enable-alt-array-implementation option).
|
||||
|
||||
v. If an [N]<&WORD- or [N]>&WORD- redirection has WORD expand to the empty
|
||||
string, treat the redirection as [N]<&- or [N]>&- and close file descriptor
|
||||
N (default 0).
|
||||
|
||||
w. Invalid parameter transformation operators are now invalid word expansions,
|
||||
and so cause fatal errors in non-interactive shells.
|
||||
|
||||
x. New shell option: patsub_replacement. When enabled, a `&' in the replacement
|
||||
string of the pattern substitution expansion is replaced by the portion of
|
||||
the string that matched the pattern. Backslash will escape the `&' and
|
||||
insert a literal `&'.
|
||||
|
||||
y. `command -p' no longer looks in the hash table for the specified command.
|
||||
|
||||
z. The new `--enable-translatable-strings' option to `configure' allows $"..."
|
||||
support to be compiled in or out.
|
||||
|
||||
aa. The new `globskipdots' shell option forces pathname expansion never to
|
||||
return `.' or `..' unless explicitly matched.
|
||||
|
||||
bb. Array references using `@' and `*' that are the value of nameref variables
|
||||
(declare -n ref='v[@]' ; echo $ref) no longer cause the shell to exit if
|
||||
set -u is enabled and the array (v) is unset.
|
||||
|
||||
4. New Features in Readline
|
||||
|
||||
a. There is now an HS_HISTORY_VERSION containing the version number of the
|
||||
history library for applications to use.
|
||||
|
||||
b. History expansion better understands multiple history expansions that may
|
||||
contain strings that would ordinarily inhibit history expansion (e.g.,
|
||||
`abc!$!$').
|
||||
|
||||
c. There is a new framework for readline timeouts, including new public
|
||||
functions to set timeouts and query how much time is remaining before a
|
||||
timeout hits, and a hook function that can trigger when readline times
|
||||
out. There is a new state value to indicate a timeout.
|
||||
|
||||
d. Automatically bind termcap key sequences for page-up and page-down to
|
||||
history-search-backward and history-search-forward, respectively.
|
||||
|
||||
e. There is a new `fetch-history' bindable command that retrieves the history
|
||||
entry corresponding to its numeric argument. Negative arguments count back
|
||||
from the end of the history.
|
||||
|
||||
f. `vi-undo' is now a bindable command.
|
||||
|
||||
g. There is a new option: `enable-active-region'. This separates control of
|
||||
the active region and bracketed-paste. It has the same default value as
|
||||
bracketed-paste, and enabling bracketed paste enables the active region.
|
||||
Users can now turn off the active region while leaving bracketed paste
|
||||
enabled.
|
||||
|
||||
h. rl_completer_word_break_characters is now `const char *' like
|
||||
rl_basic_word_break_characters.
|
||||
|
||||
i. The non-incremental history searches now leave the current history offset
|
||||
at the position of the last matching history entry, like incremental search.
|
||||
|
||||
j. Readline looks in $LS_COLORS for a custom filename extension
|
||||
(*.readline-colored-completion-prefix) and uses that as the default color
|
||||
for the common prefix displayed when `colored-completion-prefix' is set.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
This document details the changes between this version, bash-5.1-rc3, and
|
||||
the previous version, bash-5.1-rc2.
|
||||
|
||||
|
||||
@@ -2,11 +2,11 @@ Compatibility with previous versions
|
||||
====================================
|
||||
|
||||
This document details the incompatibilities between this version of bash,
|
||||
bash-5.1, and the previous widely-available versions, bash-3.2 (which is
|
||||
bash-5.2, and the previous widely-available versions, bash-3.2 (which is
|
||||
still the `standard' version for Mac OS X), 4.2/4.3 (which are still
|
||||
standard on a few Linux distributions), and bash-4.4/bash-5.0, the current
|
||||
widely-available versions. These were discovered by users of bash-2.x
|
||||
through 5.x, so this list is not comprehensive. Some of these
|
||||
standard on a few Linux distributions), and bash-4.4/bash-5.0/bash-5.1,
|
||||
the current widely-available versions. These were discovered by users of
|
||||
bash-2.x through 5.x, so this list is not comprehensive. Some of these
|
||||
incompatibilities occur between the current version and versions 2.0 and
|
||||
above.
|
||||
|
||||
@@ -419,6 +419,14 @@ above.
|
||||
options that posix mode modifies to the state they had before enabling
|
||||
posix mode. Previous versions restored these options to default values.
|
||||
|
||||
66. Bash-5.2 attempts to prevent double-expansion of array subscripts under
|
||||
certain circumstances, especially arithmetic evaluation, by acting as if
|
||||
the `assoc_expand_once' shell option were set.
|
||||
|
||||
67. The `unset' builtin in bash-5.2 treats array subscripts `@' and `*'
|
||||
differently than previous versions, and differently depending on whether
|
||||
the array is indexed or associative.
|
||||
|
||||
|
||||
Shell Compatibility Level
|
||||
=========================
|
||||
@@ -543,6 +551,28 @@ compat50 (set using BASH_COMPAT)
|
||||
output in a format that can be reused as input (-l). Bash-5.1
|
||||
suppresses that message if -l is supplied
|
||||
|
||||
compat51 (set using BASH_COMPAT)
|
||||
- The `unset' builtin will unset the array a given an argument like
|
||||
`a[@]'. Bash-5.2 will unset an element with key `@' (associative
|
||||
arrays) or remove all the elements without unsetting the array
|
||||
(indexed arrays)
|
||||
- arithmetic commands ( ((...)) ) and the expressions in an arithmetic
|
||||
for statement can be expanded more than once
|
||||
- expressions used as arguments to arithmetic operators in the [[
|
||||
conditional command can be expanded more than once
|
||||
- the expressions in substring parameter brace expansion can be
|
||||
expanded more than once
|
||||
- the expressions in the $(( ... )) word expansion can be expanded
|
||||
more than once
|
||||
- arithmetic expressions used as indexed array subscripts can be
|
||||
expanded more than once;
|
||||
- `test -v', when given an argument of A[@], where A is an existing
|
||||
associative array, will return true if the array has any set
|
||||
elements. Bash-5.2 will look for a key named `@';
|
||||
- the ${param[:]=value} word expansion will return VALUE, before any
|
||||
variable-specific transformations have been performed (e.g.,
|
||||
converting to lowercase). Bash-5.2 will return the final value
|
||||
assigned to the variable, as POSIX specifies
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
|
||||
+2519
-8785
File diff suppressed because it is too large
Load Diff
Executable → Regular
@@ -20,20 +20,28 @@ The simplest way to compile Bash is:
|
||||
3. Optionally, type 'make tests' to run the Bash test suite.
|
||||
|
||||
4. Type 'make install' to install 'bash' and 'bashbug'. This will
|
||||
also install the manual pages and Info file.
|
||||
also install the manual pages and Info file, message translation
|
||||
files, some supplemental documentation, a number of example
|
||||
loadable builtin commands, and a set of header files for developing
|
||||
loadable builtins. You may need additional privileges to install
|
||||
'bash' to your desired destination, so 'sudo make install' might be
|
||||
required. More information about controlling the locations where
|
||||
'bash' and other files are installed is below (*note Installation
|
||||
Names::).
|
||||
|
||||
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.
|
||||
(the top directory, the 'builtins', 'doc', 'po', 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
|
||||
@@ -64,7 +72,7 @@ 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
|
||||
this, make sure you are using Autoconf version 2.50 or newer.
|
||||
this, make sure you are using Autoconf version 2.69 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
|
||||
@@ -122,10 +130,13 @@ 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'.
|
||||
'/usr/local/man', etc.; that is, the "installation prefix" defaults to
|
||||
'/usr/local'. You can specify an installation prefix other than
|
||||
'/usr/local' by giving 'configure' the option '--prefix=PATH', or by
|
||||
specifying a value for the 'prefix' 'make' variable when running 'make
|
||||
install' (e.g., 'make install prefix=PATH'). The 'prefix' variable
|
||||
provides a default for 'exec_prefix' and other variables used when
|
||||
installing bash.
|
||||
|
||||
You can specify separate installation prefixes for architecture-specific
|
||||
files and architecture-independent files. If you give 'configure' the
|
||||
@@ -133,6 +144,30 @@ 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.
|
||||
|
||||
If you would like to change the installation locations for a single run,
|
||||
you can specify these variables as arguments to 'make': 'make install
|
||||
exec_prefix=/' will install 'bash' and 'bashbug' into '/bin' instead of
|
||||
the default '/usr/local/bin'.
|
||||
|
||||
If you want to see the files bash will install and where it will install
|
||||
them without changing anything on your system, specify the variable
|
||||
'DESTDIR' as an argument to 'make'. Its value should be the absolute
|
||||
directory path you'd like to use as the root of your sample installation
|
||||
tree. For example,
|
||||
|
||||
mkdir /fs1/bash-install
|
||||
make install DESTDIR=/fs1/bash-install
|
||||
|
||||
will install 'bash' into '/fs1/bash-install/usr/local/bin/bash', the
|
||||
documentation into directories within
|
||||
'/fs1/bash-install/usr/local/share', the example loadable builtins into
|
||||
'/fs1/bash-install/usr/local/lib/bash', and so on. You can use the
|
||||
usual 'exec_prefix' and 'prefix' variables to alter the directory paths
|
||||
beneath the value of 'DESTDIR'.
|
||||
|
||||
The GNU Makefile standards provide a more complete description of these
|
||||
variables and their effects.
|
||||
|
||||
Specifying the System Type
|
||||
==========================
|
||||
|
||||
@@ -235,16 +270,20 @@ the Bash 'configure' recognizes.
|
||||
subdirectories of that directory (include files in PREFIX/'include'
|
||||
and the library in PREFIX/'lib').
|
||||
|
||||
'--with-purify'
|
||||
Define this to use the Purify memory allocation checker from
|
||||
Rational Software.
|
||||
'--with-libintl-prefix[=PREFIX]'
|
||||
Define this to make Bash link with a locally-installed version of
|
||||
the libintl library instead ofthe version in 'lib/intl'.
|
||||
|
||||
'--with-libiconv-prefix[=PREFIX]'
|
||||
Define this to make Bash look for libiconv in PREFIX instead of the
|
||||
standard system locations. There is no version included with Bash.
|
||||
|
||||
'--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
|
||||
and linked, rather than changing run-time features.
|
||||
There are several '--enable-' options that alter how Bash is compiled,
|
||||
linked, and installed, rather than changing run-time features.
|
||||
|
||||
'--enable-largefile'
|
||||
Enable support for large files
|
||||
@@ -257,6 +296,10 @@ and linked, rather than changing run-time features.
|
||||
This builds a Bash binary that produces profiling information to be
|
||||
processed by 'gprof' each time it is executed.
|
||||
|
||||
'--enable-separate-helpfiles'
|
||||
Use external files for the documentation displayed by the 'help'
|
||||
builtin instead of storing the text internally.
|
||||
|
||||
'--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.
|
||||
@@ -265,14 +308,21 @@ 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',
|
||||
'direxpand-default', and 'xpg-echo-default' are enabled by default,
|
||||
unless the operating system does not provide the necessary support.
|
||||
All of the following options except for 'alt-array-implementation',
|
||||
'disabled-builtins', 'direxpand-default', 'strict-posix-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'
|
||||
builtins (*note Aliases::).
|
||||
|
||||
'--enable-alt-array-implementation'
|
||||
This builds bash using an alternate implementation of arrays (*note
|
||||
Arrays::) that provides faster access at the expense of using more
|
||||
memory (sometimes many times more, depending on how sparse an array
|
||||
is).
|
||||
|
||||
'--enable-arith-for-command'
|
||||
Include support for the alternate form of the 'for' command that
|
||||
behaves like the C language 'for' statement (*note Looping
|
||||
@@ -292,7 +342,7 @@ unless the operating system does not provide the necessary support.
|
||||
|
||||
'--enable-casemod-attributes'
|
||||
Include support for case-modifying attributes in the 'declare'
|
||||
builtin and assignment statements. Variables with the UPPERCASE
|
||||
builtin and assignment statements. Variables with the 'uppercase'
|
||||
attribute, for example, will have their values converted to
|
||||
uppercase upon assignment.
|
||||
|
||||
@@ -351,7 +401,7 @@ unless the operating system does not provide the necessary support.
|
||||
described above under *note Pattern Matching::.
|
||||
|
||||
'--enable-extended-glob-default'
|
||||
Set the default value of the EXTGLOB shell option described above
|
||||
Set the default value of the 'extglob' shell option described above
|
||||
under *note The Shopt Builtin:: to be enabled.
|
||||
|
||||
'--enable-function-import'
|
||||
@@ -360,10 +410,10 @@ unless the operating system does not provide the necessary support.
|
||||
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.
|
||||
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
|
||||
@@ -414,10 +464,6 @@ unless the operating system does not provide the necessary support.
|
||||
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'
|
||||
builtin instead of storing the text internally.
|
||||
|
||||
'--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
|
||||
@@ -427,6 +473,10 @@ unless the operating system does not provide the necessary support.
|
||||
'--enable-strict-posix-default'
|
||||
Make Bash POSIX-conformant by default (*note Bash POSIX Mode::).
|
||||
|
||||
'--enable-translatable-strings'
|
||||
Enable support for '$"STRING"' translatable strings (*note Locale
|
||||
Translation::).
|
||||
|
||||
'--enable-usg-echo-default'
|
||||
A synonym for '--enable-xpg-echo-default'.
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ examples/startup-files d
|
||||
examples/misc d
|
||||
examples/loadables d
|
||||
examples/loadables/perl d
|
||||
examples/shellmath d
|
||||
include d
|
||||
lib d
|
||||
lib/glob d
|
||||
@@ -61,6 +62,7 @@ config-bot.h f
|
||||
config.h.in f
|
||||
aclocal.m4 f
|
||||
array.c f
|
||||
array2.c f
|
||||
arrayfunc.c f
|
||||
assoc.c f
|
||||
eval.c f
|
||||
@@ -230,6 +232,7 @@ include/shtty.h f
|
||||
include/stat-time.h f
|
||||
include/stdc.h f
|
||||
include/systimes.h f
|
||||
include/timer.h f
|
||||
include/typemax.h f
|
||||
include/unionwait.h f
|
||||
lib/glob/Makefile.in f
|
||||
@@ -366,6 +369,7 @@ lib/readline/posixdir.h f
|
||||
lib/readline/posixjmp.h f
|
||||
lib/readline/posixselect.h f
|
||||
lib/readline/posixstat.h f
|
||||
lib/readline/posixtime.h f
|
||||
lib/readline/ansi_stdlib.h f
|
||||
lib/readline/rlstdc.h f
|
||||
lib/readline/rlprivate.h f
|
||||
@@ -449,6 +453,7 @@ lib/sh/strtoul.c f
|
||||
lib/sh/strtoull.c f
|
||||
lib/sh/strtoumax.c f
|
||||
lib/sh/strtrans.c f
|
||||
lib/sh/timers.c f
|
||||
lib/sh/times.c f
|
||||
lib/sh/timeval.c f
|
||||
lib/sh/tmpfile.c f
|
||||
@@ -631,7 +636,6 @@ doc/bashref.info f
|
||||
doc/bash.info f
|
||||
doc/article.ms f
|
||||
doc/htmlpost.sh f 755
|
||||
doc/infopost.sh f 755
|
||||
doc/fdl.texi f
|
||||
doc/fdl.txt f
|
||||
#
|
||||
@@ -721,8 +725,8 @@ examples/loadables/setpgid.c f
|
||||
examples/loadables/sleep.c f
|
||||
examples/loadables/strftime.c f
|
||||
examples/loadables/truefalse.c f
|
||||
#examples/loadables/getconf.h f
|
||||
#examples/loadables/getconf.c f
|
||||
examples/loadables/getconf.h f
|
||||
examples/loadables/getconf.c f
|
||||
examples/loadables/fdflags.c f
|
||||
examples/loadables/finfo.c f
|
||||
examples/loadables/cat.c f
|
||||
@@ -862,6 +866,16 @@ examples/startup-files/bashrc f
|
||||
examples/misc/aliasconv.sh f
|
||||
examples/misc/aliasconv.bash f
|
||||
examples/misc/cshtobash f
|
||||
examples/shellmath/LICENSE f
|
||||
examples/shellmath/README.md f
|
||||
examples/shellmath/assert.sh f
|
||||
examples/shellmath/faster_e_demo.sh f
|
||||
examples/shellmath/image.png f
|
||||
examples/shellmath/runTests.sh f
|
||||
examples/shellmath/shellmath.sh f
|
||||
examples/shellmath/slower_e_demo.sh f
|
||||
examples/shellmath/testCases.in f
|
||||
examples/shellmath/timingData.txt f
|
||||
tests/README f
|
||||
tests/COPYRIGHT f
|
||||
tests/test-glue-functions f
|
||||
@@ -918,6 +932,8 @@ tests/array25.sub f
|
||||
tests/array26.sub f
|
||||
tests/array27.sub f
|
||||
tests/array28.sub f
|
||||
tests/array29.sub f
|
||||
tests/array30.sub f
|
||||
tests/array-at-star f
|
||||
tests/array2.right f
|
||||
tests/assoc.tests f
|
||||
@@ -933,6 +949,13 @@ tests/assoc8.sub f
|
||||
tests/assoc9.sub f
|
||||
tests/assoc10.sub f
|
||||
tests/assoc11.sub f
|
||||
tests/assoc12.sub f
|
||||
tests/assoc13.sub f
|
||||
tests/assoc14.sub f
|
||||
tests/assoc15.sub f
|
||||
tests/assoc16.sub f
|
||||
tests/assoc17.sub f
|
||||
tests/assoc18.sub f
|
||||
tests/attr.tests f
|
||||
tests/attr.right f
|
||||
tests/attr1.sub f
|
||||
@@ -971,6 +994,7 @@ tests/comsub1.sub f
|
||||
tests/comsub2.sub f
|
||||
tests/comsub3.sub f
|
||||
tests/comsub4.sub f
|
||||
tests/comsub5.sub f
|
||||
tests/comsub-eof.tests f
|
||||
tests/comsub-eof0.sub f
|
||||
tests/comsub-eof1.sub f
|
||||
@@ -985,6 +1009,7 @@ tests/comsub-posix.right f
|
||||
tests/comsub-posix1.sub f
|
||||
tests/comsub-posix2.sub f
|
||||
tests/comsub-posix3.sub f
|
||||
tests/comsub-posix5.sub f
|
||||
tests/cond.tests f
|
||||
tests/cond.right f
|
||||
tests/cond-regexp1.sub f
|
||||
@@ -1074,6 +1099,7 @@ tests/exp9.sub f
|
||||
tests/exp10.sub f
|
||||
tests/exp11.sub f
|
||||
tests/exp12.sub f
|
||||
tests/exp13.sub f
|
||||
tests/exportfunc.tests f
|
||||
tests/exportfunc.right f
|
||||
tests/exportfunc1.sub f
|
||||
@@ -1091,6 +1117,8 @@ tests/extglob3.tests f
|
||||
tests/extglob3.right f
|
||||
tests/extglob4.sub f
|
||||
tests/extglob5.sub f
|
||||
tests/extglob6.sub f
|
||||
tests/extglob7.sub f
|
||||
tests/func.tests f
|
||||
tests/func.right f
|
||||
tests/func1.sub f
|
||||
@@ -1119,6 +1147,7 @@ tests/glob6.sub f
|
||||
tests/glob7.sub f
|
||||
tests/glob8.sub f
|
||||
tests/glob9.sub f
|
||||
tests/glob10.sub f
|
||||
tests/glob.right f
|
||||
tests/globstar.tests f
|
||||
tests/globstar.right f
|
||||
@@ -1132,6 +1161,8 @@ tests/heredoc2.sub f
|
||||
tests/heredoc3.sub f
|
||||
tests/heredoc4.sub f
|
||||
tests/heredoc5.sub f
|
||||
tests/heredoc6.sub f
|
||||
tests/heredoc7.sub f
|
||||
tests/herestr.tests f
|
||||
tests/herestr.right f
|
||||
tests/herestr1.sub f
|
||||
@@ -1152,6 +1183,7 @@ tests/history2.sub f
|
||||
tests/history3.sub f
|
||||
tests/history4.sub f
|
||||
tests/history5.sub f
|
||||
tests/history6.sub f
|
||||
tests/ifs.tests f
|
||||
tests/ifs.right f
|
||||
tests/ifs1.sub f
|
||||
@@ -1183,6 +1215,7 @@ tests/lastpipe.right f
|
||||
tests/lastpipe.tests f
|
||||
tests/lastpipe1.sub f
|
||||
tests/lastpipe2.sub f
|
||||
tests/lastpipe3.sub f
|
||||
tests/mapfile.data f
|
||||
tests/mapfile.right f
|
||||
tests/mapfile.tests f
|
||||
@@ -1212,6 +1245,8 @@ tests/nameref18.sub f
|
||||
tests/nameref19.sub f
|
||||
tests/nameref20.sub f
|
||||
tests/nameref21.sub f
|
||||
tests/nameref22.sub f
|
||||
tests/nameref23.sub f
|
||||
tests/nameref.right f
|
||||
tests/new-exp.tests f
|
||||
tests/new-exp1.sub f
|
||||
@@ -1229,12 +1264,14 @@ tests/new-exp12.sub f
|
||||
tests/new-exp13.sub f
|
||||
tests/new-exp14.sub f
|
||||
tests/new-exp15.sub f
|
||||
tests/new-exp16.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/nquote4.sub f
|
||||
tests/nquote1.tests f
|
||||
tests/nquote1.right f
|
||||
tests/nquote2.tests f
|
||||
@@ -1285,6 +1322,13 @@ tests/quote1.sub f
|
||||
tests/quote2.sub f
|
||||
tests/quote3.sub f
|
||||
tests/quote4.sub f
|
||||
tests/quotearray.right f
|
||||
tests/quotearray.tests f
|
||||
tests/quotearray1.sub f
|
||||
tests/quotearray2.sub f
|
||||
tests/quotearray3.sub f
|
||||
tests/quotearray4.sub f
|
||||
tests/quotearray5.sub f
|
||||
tests/read.tests f
|
||||
tests/read.right f
|
||||
tests/read1.sub f
|
||||
@@ -1293,6 +1337,8 @@ tests/read3.sub f
|
||||
tests/read4.sub f
|
||||
tests/read5.sub f
|
||||
tests/read6.sub f
|
||||
tests/read7.sub f
|
||||
tests/read8.sub f
|
||||
tests/redir.tests f
|
||||
tests/redir.right f
|
||||
tests/redir1.sub f
|
||||
@@ -1385,6 +1431,7 @@ tests/run-precedence f
|
||||
tests/run-printf f
|
||||
tests/run-procsub f
|
||||
tests/run-quote f
|
||||
tests/run-quotearray f
|
||||
tests/run-read f
|
||||
tests/run-redir f
|
||||
tests/run-rhs-exp f
|
||||
@@ -1421,6 +1468,7 @@ tests/tilde.tests f
|
||||
tests/tilde.right f
|
||||
tests/tilde2.tests f
|
||||
tests/tilde2.right f
|
||||
tests/tilde3.sub f
|
||||
tests/trap.tests f
|
||||
tests/trap.right f
|
||||
tests/trap1.sub f 755
|
||||
@@ -1463,6 +1511,7 @@ tests/varenv18.sub f
|
||||
tests/varenv19.sub f
|
||||
tests/varenv20.sub f
|
||||
tests/varenv21.sub f
|
||||
tests/varenv22.sub f
|
||||
tests/version f
|
||||
tests/version.mini f
|
||||
tests/vredir.tests f
|
||||
@@ -1474,6 +1523,7 @@ tests/vredir4.sub f
|
||||
tests/vredir5.sub f
|
||||
tests/vredir6.sub f
|
||||
tests/vredir7.sub f
|
||||
tests/vredir8.sub f
|
||||
tests/misc/dev-tcp.tests f
|
||||
tests/misc/perf-script f
|
||||
tests/misc/perftest f
|
||||
|
||||
+57
-20
@@ -1,6 +1,6 @@
|
||||
# Makefile for bash-5.0, version 4.30
|
||||
# Makefile for bash-5.2, version 5.1
|
||||
#
|
||||
# Copyright (C) 1996-2018 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1996-2021 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
|
||||
@@ -87,6 +87,11 @@ INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALLMODE= -m 0755
|
||||
INSTALLMODE2 = -m 0555
|
||||
|
||||
CTAGS = ctags
|
||||
CTAGSFLAGS = -x
|
||||
ETAGS = etags
|
||||
ETAGSFLAGS =
|
||||
|
||||
TESTSCRIPT = @TESTSCRIPT@
|
||||
|
||||
DEBUGGER_START_FILE = @DEBUGGER_START_FILE@
|
||||
@@ -132,6 +137,7 @@ CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@ @CROSS_COMPILE@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CPPFLAGS_FOR_BUILD = @CPPFLAGS_FOR_BUILD@
|
||||
LOCAL_CFLAGS = @LOCAL_CFLAGS@ ${DEBUG} ${MALLOC_DEBUG}
|
||||
STYLE_CFLAGS = @STYLE_CFLAGS@
|
||||
DEFS = @DEFS@
|
||||
LOCAL_DEFS = @LOCAL_DEFS@
|
||||
|
||||
@@ -147,7 +153,7 @@ LOCAL_LDFLAGS = @LOCAL_LDFLAGS@
|
||||
SYSTEM_FLAGS = -DPROGRAM='"$(Program)"' -DCONF_HOSTTYPE='"$(Machine)"' -DCONF_OSTYPE='"$(OS)"' -DCONF_MACHTYPE='"$(MACHTYPE)"' -DCONF_VENDOR='"$(VENDOR)"' $(LOCALE_DEFS)
|
||||
|
||||
BASE_CCFLAGS = $(SYSTEM_FLAGS) $(LOCAL_DEFS) \
|
||||
$(DEFS) $(LOCAL_CFLAGS) $(INCLUDES)
|
||||
$(DEFS) $(LOCAL_CFLAGS) $(INCLUDES) $(STYLE_CFLAGS)
|
||||
|
||||
CCFLAGS = $(ADDON_CFLAGS) $(BASE_CCFLAGS) ${PROFILE_FLAGS} $(CPPFLAGS) $(CFLAGS)
|
||||
|
||||
@@ -232,7 +238,8 @@ SHLIB_SOURCE = ${SH_LIBSRC}/clktck.c ${SH_LIBSRC}/getcwd.c \
|
||||
${SH_LIBSRC}/fnxform.c ${SH_LIBSRC}/unicode.c \
|
||||
${SH_LIBSRC}/wcswidth.c ${SH_LIBSRC}/wcsnwidth.c \
|
||||
${SH_LIBSRC}/shmbchar.c ${SH_LIBSRC}/utf8.c \
|
||||
${SH_LIBSRC}/random.c ${SH_LIBSRC}/gettimeofday.c
|
||||
${SH_LIBSRC}/random.c ${SH_LIBSRC}/gettimeofday.c \
|
||||
${SH_LIBSRC}/timers.c
|
||||
|
||||
SHLIB_LIB = -lsh
|
||||
SHLIB_LIBNAME = libsh.a
|
||||
@@ -420,11 +427,12 @@ BASHINCFILES = $(BASHINCDIR)/posixstat.h $(BASHINCDIR)/ansi_stdlib.h \
|
||||
$(BASHINCDIR)/shtty.h $(BASHINCDIR)/typemax.h \
|
||||
$(BASHINCDIR)/ocache.h
|
||||
|
||||
LIBRARIES = $(GLOB_LIB) $(SHLIB_LIB) $(READLINE_LIB) $(HISTORY_LIB) $(TERMCAP_LIB) \
|
||||
$(TILDE_LIB) $(MALLOC_LIB) $(INTL_LIB) $(LIBICONV) $(LOCAL_LIBS)
|
||||
LIBRARIES = $(GLOB_LIB) $(SHLIB_LIB) $(READLINE_LIB) $(HISTORY_LIB) \
|
||||
$(TERMCAP_LIB) $(TILDE_LIB) $(MALLOC_LIB) $(INTL_LIB) $(LIBICONV) \
|
||||
$(LOCAL_LIBS)
|
||||
|
||||
LIBDEP = $(GLOB_DEP) $(SHLIB_DEP) $(INTL_DEP) $(READLINE_DEP) $(HISTORY_DEP) $(TERMCAP_DEP) \
|
||||
$(TILDE_DEP) $(MALLOC_DEP)
|
||||
LIBDEP = $(GLOB_DEP) $(SHLIB_DEP) $(INTL_DEP) $(READLINE_DEP) $(HISTORY_DEP) \
|
||||
$(TERMCAP_DEP) $(TILDE_DEP) $(MALLOC_DEP)
|
||||
|
||||
LIBRARY_LDFLAGS = $(READLINE_LDFLAGS) $(HISTORY_LDFLAGS) $(GLOB_LDFLAGS) \
|
||||
$(TILDE_LDFLAGS) $(MALLOC_LDFLAGS) $(SHLIB_LDFLAGS)
|
||||
@@ -475,12 +483,14 @@ JOBS_O = @JOBS_O@
|
||||
SIGLIST_O = @SIGLIST_O@
|
||||
SIGNAMES_O = @SIGNAMES_O@
|
||||
|
||||
ARRAY_O = @ARRAY_O@
|
||||
|
||||
# Matching object files.
|
||||
OBJECTS = shell.o eval.o y.tab.o general.o make_cmd.o print_cmd.o $(GLOBO) \
|
||||
dispose_cmd.o execute_cmd.o variables.o copy_cmd.o error.o \
|
||||
expr.o flags.o $(JOBS_O) subst.o hashcmd.o hashlib.o mailcheck.o \
|
||||
trap.o input.o unwind_prot.o pathexp.o sig.o test.o version.o \
|
||||
alias.o array.o arrayfunc.o assoc.o braces.o bracecomp.o bashhist.o \
|
||||
alias.o $(ARRAY_O) arrayfunc.o assoc.o braces.o bracecomp.o bashhist.o \
|
||||
bashline.o $(SIGLIST_O) list.o stringlib.o locale.o findcmd.o redir.o \
|
||||
pcomplete.o pcomplib.o syntax.o xmalloc.o $(SIGNAMES_O)
|
||||
|
||||
@@ -578,13 +588,13 @@ LOADABLES_DIR = ${top_builddir}/examples/loadables
|
||||
.made: $(Program) bashbug $(SDIR)/man2html$(EXEEXT)
|
||||
@echo "$(Program) last made for a $(Machine) running $(OS)" >.made
|
||||
|
||||
$(Program): .build $(OBJECTS) $(BUILTINS_DEP) $(LIBDEP)
|
||||
$(Program): $(OBJECTS) $(BUILTINS_DEP) $(LIBDEP) .build
|
||||
$(RM) $@
|
||||
$(PURIFY) $(CC) $(BUILTINS_LDFLAGS) $(LIBRARY_LDFLAGS) $(LDFLAGS) -o $(Program) $(OBJECTS) $(LIBS)
|
||||
ls -l $(Program)
|
||||
-$(SIZE) $(Program)
|
||||
|
||||
.build: $(SOURCES) config.h Makefile version.h $(VERSPROG)
|
||||
.build: $(SOURCES) config.h Makefile $(DEFDIR)/builtext.h version.h $(VERSPROG)
|
||||
@echo
|
||||
@echo " ***********************************************************"
|
||||
@echo " * *"
|
||||
@@ -609,6 +619,9 @@ lint:
|
||||
asan:
|
||||
${MAKE} ${MFLAGS} ADDON_CFLAGS='${ASAN_XCFLAGS}' ADDON_LDFLAGS='${ASAN_XLDFLAGS}' .made
|
||||
|
||||
valgrind:
|
||||
${MAKE} ${MFLAGS} ADDON_CFLAGS='-DDISABLE_MALLOC_WRAPPERS' ADDON_LDFLAGS= .made
|
||||
|
||||
# cheating
|
||||
gcov:
|
||||
${MAKE} ${MFLAGS} CFLAGS=-g ADDON_CFLAGS='${GCOV_XCFLAGS}' ADDON_LDFLAGS='${GCOV_XLDFLAGS}' .made
|
||||
@@ -649,6 +662,7 @@ ${GRAM_H}: y.tab.h
|
||||
y.tab.c: parse.y
|
||||
# -if test -f y.tab.h; then mv -f y.tab.h old-y.tab.h; fi
|
||||
$(YACC) -d $(srcdir)/parse.y
|
||||
$(RM) parser-built
|
||||
touch parser-built
|
||||
# -if cmp -s old-y.tab.h y.tab.h; then mv old-y.tab.h y.tab.h; else cp -p y.tab.h ${GRAM_H}; fi
|
||||
|
||||
@@ -733,7 +747,7 @@ syntax.c: mksyntax${EXEEXT} $(srcdir)/syntax.h
|
||||
$(RM) $@
|
||||
./mksyntax$(EXEEXT) -o $@
|
||||
|
||||
$(BUILTINS_LIBRARY): $(BUILTIN_DEFS) $(BUILTIN_C_SRC) config.h ${BASHINCDIR}/memalloc.h $(DEFDIR)/builtext.h version.h
|
||||
$(BUILTINS_LIBRARY): $(DEFDIR)/builtext.h $(BUILTIN_DEFS) $(BUILTIN_C_SRC) config.h ${BASHINCDIR}/memalloc.h version.h
|
||||
@(cd $(DEFDIR) && $(MAKE) $(MFLAGS) DEBUG=${DEBUG} targets ) || exit 1
|
||||
|
||||
# these require special rules to circumvent make builtin rules
|
||||
@@ -746,7 +760,7 @@ ${DEFDIR}/bashgetopt.o: $(BUILTIN_SRCDIR)/bashgetopt.c
|
||||
${DEFDIR}/builtext.h: $(BUILTIN_DEFS)
|
||||
@(cd $(DEFDIR) && $(MAKE) $(MFLAGS) builtext.h ) || exit 1
|
||||
|
||||
${DEFDIR}/pipesize.h:
|
||||
${DEFDIR}/pipesize.h: ${BUILTINS_LIBRARY}
|
||||
@(cd $(DEFDIR) && $(MAKE) $(MFLAGS) pipesize.h ) || exit 1
|
||||
|
||||
$(SDIR)/man2html$(EXEEXT): ${SUPPORT_SRC}/man2html.c
|
||||
@@ -807,10 +821,10 @@ force:
|
||||
|
||||
# unused
|
||||
TAGS: $(SOURCES) $(BUILTIN_C_SRC) $(LIBRARY_SOURCE)
|
||||
etags $(SOURCES) $(BUILTIN_C_SRC) $(LIBRARY_SOURCE)
|
||||
( cd $(topdir) && $(ETAGS) $(ETAGSFLAGS) $(SOURCES) $(BUILTIN_C_SRC) $(LIBRARY_SOURCE) )
|
||||
|
||||
tags: $(SOURCES) $(BUILTIN_C_SRC) $(LIBRARY_SOURCE)
|
||||
ctags -x $(SOURCES) $(BUILTIN_C_SRC) $(LIBRARY_SOURCE) > $@
|
||||
( cd $(topdir) && $(CTAGS) $(CTAGSFLAGS) $(SOURCES) $(BUILTIN_C_SRC) $(LIBRARY_SOURCE) > $@ )
|
||||
|
||||
# Targets that actually do things not part of the build
|
||||
|
||||
@@ -986,6 +1000,7 @@ hashtest: hashlib.c
|
||||
# Files that depend on the definitions in config-top.h, which are not meant
|
||||
# to be changed
|
||||
array.o: $(srcdir)/config-top.h
|
||||
array2.o: $(srcdir)/config-top.h
|
||||
bashhist.o: $(srcdir)/config-top.h
|
||||
shell.o: $(srcdir)/config-top.h
|
||||
input.o: $(srcdir)/config-top.h
|
||||
@@ -1204,7 +1219,7 @@ trap.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h arra
|
||||
trap.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h parser.h
|
||||
trap.o: make_cmd.h subst.h sig.h pathnames.h externs.h execute_cmd.h
|
||||
trap.o: signames.h $(DEFSRC)/common.h
|
||||
trap.o: ${DEFDIR}/builtext.h jobs.h
|
||||
trap.o: ${DEFDIR}/builtext.h builtins.h jobs.h
|
||||
unwind_prot.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h command.h ${BASHINCDIR}/stdc.h
|
||||
unwind_prot.o: general.h xmalloc.h unwind_prot.h quit.h sig.h
|
||||
unwind_prot.o: ${BASHINCDIR}/ocache.h ${BASHINCDIR}/chartypes.h error.h
|
||||
@@ -1249,6 +1264,13 @@ array.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
|
||||
array.o: make_cmd.h subst.h sig.h pathnames.h externs.h
|
||||
array.o: $(BASHINCDIR)/ocache.h $(BASHINCDIR)/chartypes.h
|
||||
array.o: $(DEFSRC)/common.h
|
||||
array2.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
|
||||
array2.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
|
||||
array2.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
|
||||
array2.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
|
||||
array2.o: make_cmd.h subst.h sig.h pathnames.h externs.h
|
||||
array2.o: $(BASHINCDIR)/ocache.h $(BASHINCDIR)/chartypes.h
|
||||
array2.o: $(DEFSRC)/common.h
|
||||
arrayfunc.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
|
||||
arrayfunc.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
|
||||
arrayfunc.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
|
||||
@@ -1281,18 +1303,24 @@ alias.o: ${BASHINCDIR}/chartypes.h
|
||||
|
||||
pcomplib.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h bashtypes.h
|
||||
pcomplib.o: ${BASHINCDIR}/stdc.h hashlib.h pcomplete.h shell.h syntax.h
|
||||
pcomplib.o: bashjmp.h command.h general.h xmalloc.h error.h variables.h arrayfunc.h conftypes.h quit.h
|
||||
pcomplib.o: bashjmp.h command.h general.h xmalloc.h error.h variables.h
|
||||
pcomplib.o: arrayfunc.h conftypes.h quit.h
|
||||
pcomplib.o: unwind_prot.h dispose_cmd.h make_cmd.h subst.h sig.h pathnames.h
|
||||
pcomplib.o: externs.h ${BASHINCDIR}/maxpath.h assoc.h array.h
|
||||
pcomplib.o: ${BASHINCDIR}/posixjmp.h ${BASHINCDIR}/ocache.h ${BASHINCDIR}/chartypes.h
|
||||
|
||||
pcomplete.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h bashtypes.h
|
||||
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: bashjmp.h command.h general.h xmalloc.h error.h variables.h
|
||||
pcomplete.o: execute_cmd.h pathexp.h arrayfunc.h conftypes.h quit.h trap.h
|
||||
pcomplete.o: jobs.h siglist.h bashline.h alias.h
|
||||
pcomplete.o: ${BASHINCDIR}/posixwait.h ${BASHINCDIR}/unionwait.h
|
||||
pcomplete.o: ${BASHINCDIR}/posixtime.h ${BASHINCDIR}/posixstat.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
|
||||
pcomplete.o: builtins.h ${DEFDIR}/builtext.h ${DEFSRC}/common.h
|
||||
pcomplete.o: ${GLOB_LIBSRC}/glob.h ${GLOB_LIBSRC}/strmatch.h
|
||||
|
||||
# library support files
|
||||
|
||||
@@ -1350,6 +1378,10 @@ variables.o: $(RL_LIBSRC)/rltypedefs.h
|
||||
jobs.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/chardefs.h
|
||||
jobs.o: $(RL_LIBSRC)/readline.h $(RL_LIBSRC)/rlstdc.h
|
||||
jobs.o: $(RL_LIBSRC)/rltypedefs.h
|
||||
pcomplete.o: $(RL_LIBSRC)/rlconf.h
|
||||
pcomplete.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/rlstdc.h
|
||||
pcomplete.o: $(RL_LIBSRC)/chardefs.h $(RL_LIBSRC)/readline.h
|
||||
pcomplete.o: $(RL_LIBSRC)/rltypedefs.h ${RL_LIBSRC}/rlmbutil.h
|
||||
|
||||
shell.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h
|
||||
variables.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h
|
||||
@@ -1357,12 +1389,14 @@ subst.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h
|
||||
bashline.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h
|
||||
bashhist.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h
|
||||
y.tab.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h
|
||||
pcomplete.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h
|
||||
|
||||
bashline.o: $(TILDE_LIBSRC)/tilde.h
|
||||
bracecomp.o: $(TILDE_LIBSRC)/tilde.h
|
||||
execute_cmd.o: $(TILDE_LIBSRC)/tilde.h
|
||||
general.o: $(TILDE_LIBSRC)/tilde.h
|
||||
mailcheck.o: $(TILDE_LIBSRC)/tilde.h
|
||||
pcomplete.o: $(TILDE_LIBSRC)/tilde.h
|
||||
shell.o: $(TILDE_LIBSRC)/tilde.h
|
||||
subst.o: $(TILDE_LIBSRC)/tilde.h
|
||||
variables.o: $(TILDE_LIBSRC)/tilde.h
|
||||
@@ -1435,7 +1469,7 @@ builtins/evalstring.o: ${BASHINCDIR}/memalloc.h variables.h arrayfunc.h conftype
|
||||
builtins/evalstring.o: quit.h unwind_prot.h ${BASHINCDIR}/maxpath.h jobs.h builtins.h
|
||||
builtins/evalstring.o: dispose_cmd.h make_cmd.h subst.h externs.h
|
||||
builtins/evalstring.o: jobs.h builtins.h flags.h input.h execute_cmd.h
|
||||
builtins/evalstring.o: bashhist.h $(DEFSRC)/common.h pathnames.h
|
||||
builtins/evalstring.o: bashhist.h $(DEFSRC)/common.h pathnames.h redir.h
|
||||
builtins/evalstring.o: ${DEFDIR}/builtext.h
|
||||
builtins/getopt.o: config.h ${BASHINCDIR}/memalloc.h
|
||||
builtins/getopt.o: shell.h syntax.h bashjmp.h command.h general.h xmalloc.h error.h
|
||||
@@ -1486,6 +1520,7 @@ builtins/declare.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.
|
||||
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 flags.h
|
||||
builtins/declare.o: ${DEFDIR}/builtext.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
|
||||
@@ -1510,6 +1545,7 @@ builtins/exit.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h x
|
||||
builtins/exit.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
|
||||
builtins/exit.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
|
||||
builtins/exit.o: pathnames.h execute_cmd.h
|
||||
builtins/exit.o: ${DEFDIR}/builtext.h
|
||||
builtins/fc.o: bashtypes.h ${BASHINCDIR}/posixstat.h
|
||||
builtins/fc.o: bashansi.h ${BASHINCDIR}/ansi_stdlib.h builtins.h command.h ${BASHINCDIR}/stdc.h
|
||||
builtins/fc.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
|
||||
@@ -1568,6 +1604,7 @@ builtins/pushd.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h
|
||||
builtins/pushd.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
|
||||
builtins/pushd.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
|
||||
builtins/pushd.o: $(DEFSRC)/common.h pathnames.h
|
||||
builtins/pushd.o: ${DEFDIR}/builtext.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
|
||||
|
||||
@@ -1,3 +1,142 @@
|
||||
This is a terse description of the new features added to bash-5.2 since
|
||||
the release of bash-5.1. As always, the manual page (doc/bash.1) is
|
||||
the place to look for complete descriptions.
|
||||
|
||||
1. New Features in Bash
|
||||
|
||||
a. The bash malloc returns memory that is aligned on 16-byte boundaries.
|
||||
|
||||
b. There is a new internal timer framework used for read builtin timeouts.
|
||||
|
||||
c. Rewrote the command substitution parsing code to call the parser recursively
|
||||
and rebuild the command string from the parsed command. This allows better
|
||||
syntax checking and catches errors much earlier.
|
||||
|
||||
d. The `ulimit' builtin now treats an operand remaining after all of the options
|
||||
and arguments are parsed as an argument to the last command specified by
|
||||
an option. This is for POSIX compatibility.
|
||||
|
||||
e. Here-document parsing now handles $'...' and $"..." quoting when reading the
|
||||
here-document body.
|
||||
|
||||
f. The `shell-expand-line' and `history-and-alias-expand-line' bindable readline
|
||||
commands now understand $'...' and $"..." quoting.
|
||||
|
||||
g. There is a new `spell-correct-word' bindable readline command to perform
|
||||
spelling correction on the current word.
|
||||
|
||||
h. The `unset' builtin now attempts to treat arguments as array subscripts
|
||||
without parsing or expanding the subscript, even when `assoc_expand_once'
|
||||
is not set.
|
||||
|
||||
i. There is a default value for $BASH_LOADABLES_PATH in config-top.h.
|
||||
|
||||
j. Associative array assignment and certain instances of referencing (e.g.,
|
||||
`test -v' now allow `@' and `*' to be used as keys.
|
||||
|
||||
k. Bash attempts to expand indexed array subscripts only once when executing
|
||||
shell constructs and word expansions.
|
||||
|
||||
l. The `unset' builtin allows a subscript of `@' or `*' to unset a key with
|
||||
that value for associative arrays instead of unsetting the entire array
|
||||
(which you can still do with `unset arrayname'). For indexed arrays, it
|
||||
removes all elements of the array without unsetting it (like `A=()').
|
||||
|
||||
m. Additional builtins (printf/test/read/wait) do a better job of not
|
||||
parsing array subscripts if array_expand_once is set.
|
||||
|
||||
n. New READLINE_ARGUMENT variable set to numeric argument for readline commands
|
||||
defined using `bind -x'.
|
||||
|
||||
o. The new `varredir_close' shell option causes bash to automatically close
|
||||
file descriptors opened with {var}<fn and other styles of varassign
|
||||
redirection unless they're arguments to the `exec' builtin.
|
||||
|
||||
p. The `$0' special parameter is now set to the name of the script when running
|
||||
any (non-interactive) startup files such as $BASH_ENV.
|
||||
|
||||
q. The `enable' builtin tries to load a loadable builtin using the default
|
||||
search path if `enable name' (without any options) attempts to enable a
|
||||
non-existent builtin.
|
||||
|
||||
r. The `printf' builtin has a new format specifier: %Q. This acts like %q but
|
||||
applies any specified precision to the original unquoted argument, then
|
||||
quotes and outputs the result.
|
||||
|
||||
s. The new `noexpand_translations' option controls whether or not the translated
|
||||
output of $"..." is single-quoted.
|
||||
|
||||
t. There is a new parameter transformation operator: @k. This is like @K, but
|
||||
expands the result to separate words after word splitting.
|
||||
|
||||
u. There is an alternate array implementation, selectable at `configure' time,
|
||||
that optimizes access speed over memory use (use the new configure
|
||||
--enable-alt-array-implementation option).
|
||||
|
||||
v. If an [N]<&WORD- or [N]>&WORD- redirection has WORD expand to the empty
|
||||
string, treat the redirection as [N]<&- or [N]>&- and close file descriptor
|
||||
N (default 0).
|
||||
|
||||
w. Invalid parameter transformation operators are now invalid word expansions,
|
||||
and so cause fatal errors in non-interactive shells.
|
||||
|
||||
x. New shell option: patsub_replacement. When enabled, a `&' in the replacement
|
||||
string of the pattern substitution expansion is replaced by the portion of
|
||||
the string that matched the pattern. Backslash will escape the `&' and
|
||||
insert a literal `&'.
|
||||
|
||||
y. `command -p' no longer looks in the hash table for the specified command.
|
||||
|
||||
z. The new `--enable-translatable-strings' option to `configure' allows $"..."
|
||||
support to be compiled in or out.
|
||||
|
||||
aa. The new `globskipdots' shell option forces pathname expansion never to
|
||||
return `.' or `..' unless explicitly matched.
|
||||
|
||||
bb. Array references using `@' and `*' that are the value of nameref variables
|
||||
(declare -n ref='v[@]' ; echo $ref) no longer cause the shell to exit if
|
||||
set -u is enabled and the array (v) is unset.
|
||||
|
||||
2. New Features in Readline
|
||||
|
||||
a. There is now an HS_HISTORY_VERSION containing the version number of the
|
||||
history library for applications to use.
|
||||
|
||||
b. History expansion better understands multiple history expansions that may
|
||||
contain strings that would ordinarily inhibit history expansion (e.g.,
|
||||
`abc!$!$').
|
||||
|
||||
c. There is a new framework for readline timeouts, including new public
|
||||
functions to set timeouts and query how much time is remaining before a
|
||||
timeout hits, and a hook function that can trigger when readline times
|
||||
out. There is a new state value to indicate a timeout.
|
||||
|
||||
d. Automatically bind termcap key sequences for page-up and page-down to
|
||||
history-search-backward and history-search-forward, respectively.
|
||||
|
||||
e. There is a new `fetch-history' bindable command that retrieves the history
|
||||
entry corresponding to its numeric argument. Negative arguments count back
|
||||
from the end of the history.
|
||||
|
||||
f. `vi-undo' is now a bindable command.
|
||||
|
||||
g. There is a new option: `enable-active-region'. This separates control of
|
||||
the active region and bracketed-paste. It has the same default value as
|
||||
bracketed-paste, and enabling bracketed paste enables the active region.
|
||||
Users can now turn off the active region while leaving bracketed paste
|
||||
enabled.
|
||||
|
||||
h. rl_completer_word_break_characters is now `const char *' like
|
||||
rl_basic_word_break_characters.
|
||||
|
||||
i. The non-incremental history searches now leave the current history offset
|
||||
at the position of the last matching history entry, like incremental search.
|
||||
|
||||
j. Readline looks in $LS_COLORS for a custom filename extension
|
||||
(*.readline-colored-completion-prefix) and uses that as the default color
|
||||
for the common prefix displayed when `colored-completion-prefix' is set.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
This is a terse description of the new features added to bash-5.1 since
|
||||
the release of bash-5.0. As always, the manual page (doc/bash.1) is
|
||||
the place to look for complete descriptions.
|
||||
|
||||
@@ -101,7 +101,11 @@ The following list is what's changed when 'POSIX mode' is in effect:
|
||||
|
||||
25. 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.
|
||||
special builtin, but not with any other simple command. For any
|
||||
other simple command, the shell aborts execution of that command,
|
||||
and execution continues at the top level ("the shell shall not
|
||||
perform any further processing of the command in which the error
|
||||
occurred").
|
||||
|
||||
26. A non-interactive shell exits with an error status if the
|
||||
iteration variable in a 'for' statement or the selection variable
|
||||
@@ -185,14 +189,14 @@ The following list is what's changed when 'POSIX mode' is in effect:
|
||||
variable values without quotes, unless they contain shell
|
||||
metacharacters, even if the result contains nonprinting characters.
|
||||
|
||||
48. When the 'cd' builtin is invoked in LOGICAL mode, and the pathname
|
||||
48. 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.
|
||||
instead of falling back to physical mode.
|
||||
|
||||
49. When the 'cd' builtin cannot change a directory because the length
|
||||
of the pathname constructed from '$PWD' and the directory name
|
||||
supplied as an argument exceeds PATH_MAX when all symbolic links
|
||||
supplied as an argument exceeds 'PATH_MAX' when all symbolic links
|
||||
are expanded, 'cd' will fail instead of attempting to use only the
|
||||
supplied directory name.
|
||||
|
||||
|
||||
@@ -29,7 +29,8 @@ with the exception that the following are disallowed or not performed:
|
||||
* 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'.
|
||||
* Turning off restricted mode with 'set +r' or 'shopt -u
|
||||
restricted_shell'.
|
||||
|
||||
These restrictions are enforced after any startup files are read.
|
||||
|
||||
@@ -40,10 +41,10 @@ spawned to execute the script.
|
||||
The restricted shell mode is only one component of a useful restricted
|
||||
environment. It should be accompanied by setting 'PATH' to a value that
|
||||
allows execution of only a few verified commands (commands that allow
|
||||
shell escapes are particularly vulnerable), leaving the user in a
|
||||
non-writable directory other than his home directory after login, not
|
||||
allowing the restricted shell to execute shell scripts, and cleaning the
|
||||
environment of variables that cause some commands to modify their
|
||||
shell escapes are particularly vulnerable), changing the current
|
||||
directory to a non-writable directory other than '$HOME' after login,
|
||||
not allowing the restricted shell to execute shell scripts, and cleaning
|
||||
the environment of variables that cause some commands to modify their
|
||||
behavior (e.g., 'VISUAL' or 'PAGER').
|
||||
|
||||
Modern systems provide more secure ways to implement a restricted
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Introduction
|
||||
============
|
||||
|
||||
This is GNU Bash, version 5.1. Bash is the GNU Project's Bourne
|
||||
This is GNU Bash, version 5.2. 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.4 and
|
||||
bash-5.0. For details, see the file COMPAT. The NEWS file tersely
|
||||
of Bash and previous widely-distributed versions, bash-4.4, bash-5.0,
|
||||
and bash-5.1. 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
|
||||
|
||||
Vendored
+430
-466
File diff suppressed because it is too large
Load Diff
@@ -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-2020 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* chet@ins.cwru.edu
|
||||
*/
|
||||
|
||||
/* Copyright (C) 1997-2020 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1997-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -84,7 +84,6 @@ array_create()
|
||||
ARRAY_ELEMENT *head;
|
||||
|
||||
r = (ARRAY *)xmalloc(sizeof(ARRAY));
|
||||
r->type = array_indexed;
|
||||
r->max_index = -1;
|
||||
r->num_elements = 0;
|
||||
r->lastref = (ARRAY_ELEMENT *)0;
|
||||
@@ -134,7 +133,6 @@ ARRAY *a;
|
||||
if (a == 0)
|
||||
return((ARRAY *) NULL);
|
||||
a1 = array_create();
|
||||
a1->type = a->type;
|
||||
a1->max_index = a->max_index;
|
||||
a1->num_elements = a->num_elements;
|
||||
for (ae = element_forw(a->head); ae != a->head; ae = element_forw(ae)) {
|
||||
@@ -161,7 +159,6 @@ ARRAY_ELEMENT *s, *e;
|
||||
arrayind_t mi;
|
||||
|
||||
a = array_create ();
|
||||
a->type = array->type;
|
||||
|
||||
for (mi = 0, p = s, i = 0; p != e; p = element_forw(p), i++) {
|
||||
n = array_create_element (element_index(p), element_value(p));
|
||||
@@ -796,6 +793,27 @@ ARRAY *a;
|
||||
return (REVERSE_LIST(list, WORD_LIST *));
|
||||
}
|
||||
|
||||
WORD_LIST *
|
||||
array_to_kvpair_list(a)
|
||||
ARRAY *a;
|
||||
{
|
||||
WORD_LIST *list;
|
||||
ARRAY_ELEMENT *ae;
|
||||
char *k, *v;
|
||||
|
||||
if (a == 0 || array_empty(a))
|
||||
return((WORD_LIST *)NULL);
|
||||
list = (WORD_LIST *)NULL;
|
||||
for (ae = element_forw(a->head); ae != a->head; ae = element_forw(ae)) {
|
||||
k = itos(element_index(ae));
|
||||
v = element_value(ae);
|
||||
list = make_word_list (make_bare_word(k), list);
|
||||
list = make_word_list (make_bare_word(v), list);
|
||||
free(k);
|
||||
}
|
||||
return (REVERSE_LIST(list, WORD_LIST *));
|
||||
}
|
||||
|
||||
ARRAY *
|
||||
array_assign_list (array, list)
|
||||
ARRAY *array;
|
||||
@@ -835,6 +853,55 @@ int *countp;
|
||||
*countp = i;
|
||||
return (ret);
|
||||
}
|
||||
|
||||
ARRAY *
|
||||
array_from_argv(a, vec, count)
|
||||
ARRAY *a;
|
||||
char **vec;
|
||||
int count;
|
||||
{
|
||||
arrayind_t i;
|
||||
ARRAY_ELEMENT *ae;
|
||||
char *t;
|
||||
|
||||
if (a == 0 || array_num_elements (a) == 0)
|
||||
{
|
||||
for (i = 0; i < count; i++)
|
||||
array_insert (a, i, t);
|
||||
return a;
|
||||
}
|
||||
|
||||
/* Fast case */
|
||||
if (array_num_elements (a) == count && count == 1)
|
||||
{
|
||||
ae = element_forw (a->head);
|
||||
t = vec[0] ? savestring (vec[0]) : 0;
|
||||
ARRAY_ELEMENT_REPLACE (ae, t);
|
||||
}
|
||||
else if (array_num_elements (a) <= count)
|
||||
{
|
||||
/* modify in array_num_elements members in place, then add */
|
||||
ae = a->head;
|
||||
for (i = 0; i < array_num_elements (a); i++)
|
||||
{
|
||||
ae = element_forw (ae);
|
||||
t = vec[0] ? savestring (vec[0]) : 0;
|
||||
ARRAY_ELEMENT_REPLACE (ae, t);
|
||||
}
|
||||
/* add any more */
|
||||
for ( ; i < count; i++)
|
||||
array_insert (a, i, vec[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* deleting elements. it's faster to rebuild the array. */
|
||||
array_flush (a);
|
||||
for (i = 0; i < count; i++)
|
||||
array_insert (a, i, vec[i]);
|
||||
}
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return a string that is the concatenation of the elements in A from START
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* array.h -- definitions for the interface exported by array.c that allows
|
||||
the rest of the shell to manipulate array variables. */
|
||||
|
||||
/* Copyright (C) 1997-2020 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1997-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -27,33 +27,55 @@
|
||||
|
||||
typedef intmax_t arrayind_t;
|
||||
|
||||
enum atype {array_indexed, array_assoc}; /* only array_indexed used */
|
||||
|
||||
typedef struct array {
|
||||
enum atype type;
|
||||
arrayind_t max_index;
|
||||
int num_elements;
|
||||
arrayind_t num_elements;
|
||||
#ifdef ALT_ARRAY_IMPLEMENTATION
|
||||
arrayind_t first_index;
|
||||
arrayind_t alloc_size;
|
||||
struct array_element **elements;
|
||||
#else
|
||||
struct array_element *head;
|
||||
struct array_element *lastref;
|
||||
#endif
|
||||
} ARRAY;
|
||||
|
||||
typedef struct array_element {
|
||||
arrayind_t ind;
|
||||
char *value;
|
||||
#ifndef ALT_ARRAY_IMPLEMENTATION
|
||||
struct array_element *next, *prev;
|
||||
#endif
|
||||
} ARRAY_ELEMENT;
|
||||
|
||||
#define ARRAY_DEFAULT_SIZE 1024
|
||||
|
||||
typedef int sh_ae_map_func_t PARAMS((ARRAY_ELEMENT *, void *));
|
||||
|
||||
/* Basic operations on entire arrays */
|
||||
#ifdef ALT_ARRAY_IMPLEMENTATION
|
||||
extern void array_alloc PARAMS((ARRAY *, arrayind_t));
|
||||
extern void array_resize PARAMS((ARRAY *, arrayind_t));
|
||||
extern void array_expand PARAMS((ARRAY *, arrayind_t));
|
||||
extern void array_dispose_elements PARAMS((ARRAY_ELEMENT **));
|
||||
#endif
|
||||
extern ARRAY *array_create PARAMS((void));
|
||||
extern void array_flush PARAMS((ARRAY *));
|
||||
extern void array_dispose PARAMS((ARRAY *));
|
||||
extern ARRAY *array_copy PARAMS((ARRAY *));
|
||||
#ifndef ALT_ARRAY_IMPLEMENTATION
|
||||
extern ARRAY *array_slice PARAMS((ARRAY *, ARRAY_ELEMENT *, ARRAY_ELEMENT *));
|
||||
#else
|
||||
extern ARRAY *array_slice PARAMS((ARRAY *, arrayind_t, arrayind_t));
|
||||
#endif
|
||||
|
||||
extern void array_walk PARAMS((ARRAY *, sh_ae_map_func_t *, void *));
|
||||
|
||||
#ifndef ALT_ARRAY_IMPLEMENTATION
|
||||
extern ARRAY_ELEMENT *array_shift PARAMS((ARRAY *, int, int));
|
||||
#else
|
||||
extern ARRAY_ELEMENT **array_shift PARAMS((ARRAY *, int, int));
|
||||
#endif
|
||||
extern int array_rshift PARAMS((ARRAY *, int, char *));
|
||||
extern ARRAY_ELEMENT *array_unshift_element PARAMS((ARRAY *));
|
||||
extern int array_shift_element PARAMS((ARRAY *, char *));
|
||||
@@ -81,10 +103,12 @@ extern char *array_reference PARAMS((ARRAY *, arrayind_t));
|
||||
extern WORD_LIST *array_to_word_list PARAMS((ARRAY *));
|
||||
extern ARRAY *array_from_word_list PARAMS((WORD_LIST *));
|
||||
extern WORD_LIST *array_keys_to_word_list PARAMS((ARRAY *));
|
||||
extern WORD_LIST *array_to_kvpair_list PARAMS((ARRAY *));
|
||||
|
||||
extern ARRAY *array_assign_list PARAMS((ARRAY *, WORD_LIST *));
|
||||
|
||||
extern char **array_to_argv PARAMS((ARRAY *, int *));
|
||||
extern ARRAY *array_from_argv PARAMS((ARRAY *, char **, int));
|
||||
|
||||
extern char *array_to_kvpair PARAMS((ARRAY *, int));
|
||||
extern char *array_to_assign PARAMS((ARRAY *, int));
|
||||
@@ -96,22 +120,42 @@ extern ARRAY *array_from_string PARAMS((char *, char *));
|
||||
|
||||
#define array_num_elements(a) ((a)->num_elements)
|
||||
#define array_max_index(a) ((a)->max_index)
|
||||
#ifndef ALT_ARRAY_IMPLEMENTATION
|
||||
#define array_first_index(a) ((a)->head->next->ind)
|
||||
#define array_head(a) ((a)->head)
|
||||
#define array_alloc_size(a) ((a)->alloc_size)
|
||||
#else
|
||||
#define array_first_index(a) ((a)->first_index)
|
||||
#define array_head(a) ((a)->elements)
|
||||
#endif
|
||||
#define array_empty(a) ((a)->num_elements == 0)
|
||||
|
||||
#define element_value(ae) ((ae)->value)
|
||||
#define element_index(ae) ((ae)->ind)
|
||||
|
||||
#ifndef ALT_ARRAY_IMPLEMENTATION
|
||||
#define element_forw(ae) ((ae)->next)
|
||||
#define element_back(ae) ((ae)->prev)
|
||||
#else
|
||||
extern arrayind_t element_forw PARAMS((ARRAY *, arrayind_t));
|
||||
extern arrayind_t element_back PARAMS((ARRAY *, arrayind_t));
|
||||
#endif
|
||||
|
||||
|
||||
#define set_element_value(ae, val) ((ae)->value = (val))
|
||||
|
||||
#ifdef ALT_ARRAY_IMPLEMENTATION
|
||||
#define set_first_index(a, i) ((a)->first_index = (i))
|
||||
#endif
|
||||
|
||||
#define set_max_index(a, i) ((a)->max_index = (i))
|
||||
#define set_num_elements(a, n) ((a)->num_elements = (n))
|
||||
|
||||
/* Convenience */
|
||||
#define array_push(a,v) \
|
||||
do { array_rshift ((a), 1, (v)); } while (0)
|
||||
#define array_pop(a) \
|
||||
do { array_dispose_element (array_shift ((a), 1, 0)); } while (0)
|
||||
do { array_shift ((a), 1, AS_DISPOSE); } while (0)
|
||||
|
||||
#define GET_ARRAY_FROM_VAR(n, v, a) \
|
||||
do { \
|
||||
@@ -119,6 +163,17 @@ extern ARRAY *array_from_string PARAMS((char *, char *));
|
||||
(a) = ((v) && array_p ((v))) ? array_cell (v) : (ARRAY *)0; \
|
||||
} while (0)
|
||||
|
||||
#define ARRAY_ELEMENT_REPLACE(ae, v) \
|
||||
do { \
|
||||
free ((ae)->value); \
|
||||
(ae)->value = (v); \
|
||||
} while (0)
|
||||
|
||||
#ifdef ALT_ARRAY_IMPLEMENTATION
|
||||
#define ARRAY_VALUE_REPLACE(a, i, v) \
|
||||
ARRAY_ELEMENT_REPLACE((a)->elements[(i)], (v))
|
||||
#endif
|
||||
|
||||
#define ALL_ELEMENT_SUB(c) ((c) == '@' || (c) == '*')
|
||||
|
||||
/* In eval.c, but uses ARRAY * */
|
||||
|
||||
+275
-98
@@ -1,6 +1,6 @@
|
||||
/* arrayfunc.c -- High-level array functions used by other parts of the shell. */
|
||||
|
||||
/* Copyright (C) 2001-2020 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 2001-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -53,14 +53,14 @@ int assoc_expand_once = 0;
|
||||
int array_expand_once = 0;
|
||||
|
||||
static SHELL_VAR *bind_array_var_internal PARAMS((SHELL_VAR *, arrayind_t, char *, char *, int));
|
||||
static SHELL_VAR *assign_array_element_internal PARAMS((SHELL_VAR *, char *, char *, char *, int, char *, int));
|
||||
static SHELL_VAR *assign_array_element_internal PARAMS((SHELL_VAR *, char *, char *, char *, int, char *, int, array_eltstate_t *));
|
||||
|
||||
static void assign_assoc_from_kvlist PARAMS((SHELL_VAR *, WORD_LIST *, HASH_TABLE *, int));
|
||||
|
||||
static char *quote_assign PARAMS((const char *));
|
||||
static void quote_array_assignment_chars PARAMS((WORD_LIST *));
|
||||
static char *quote_compound_array_word PARAMS((char *, int));
|
||||
static char *array_value_internal PARAMS((const char *, int, int, int *, arrayind_t *));
|
||||
static char *array_value_internal PARAMS((const char *, int, int, array_eltstate_t *));
|
||||
|
||||
/* Standard error message to use when encountering an invalid array subscript */
|
||||
const char * const bash_badsub_errmsg = N_("bad array subscript");
|
||||
@@ -318,19 +318,44 @@ bind_assoc_variable (entry, name, key, value, flags)
|
||||
return (bind_assoc_var_internal (entry, assoc_cell (entry), key, value, flags));
|
||||
}
|
||||
|
||||
inline void
|
||||
init_eltstate (array_eltstate_t *estatep)
|
||||
{
|
||||
if (estatep)
|
||||
{
|
||||
estatep->type = ARRAY_INVALID;
|
||||
estatep->subtype = 0;
|
||||
estatep->key = estatep->value = 0;
|
||||
estatep->ind = INTMAX_MIN;
|
||||
}
|
||||
}
|
||||
|
||||
inline void
|
||||
flush_eltstate (array_eltstate_t *estatep)
|
||||
{
|
||||
if (estatep)
|
||||
FREE (estatep->key);
|
||||
}
|
||||
|
||||
/* Parse NAME, a lhs of an assignment statement of the form v[s], and
|
||||
assign VALUE to that array element by calling bind_array_variable().
|
||||
Flags are ASS_ assignment flags */
|
||||
SHELL_VAR *
|
||||
assign_array_element (name, value, flags)
|
||||
assign_array_element (name, value, flags, estatep)
|
||||
char *name, *value;
|
||||
int flags;
|
||||
array_eltstate_t *estatep;
|
||||
{
|
||||
char *sub, *vname;
|
||||
int sublen, isassoc;
|
||||
int sublen, isassoc, avflags;
|
||||
SHELL_VAR *entry;
|
||||
|
||||
vname = array_variable_name (name, (flags & ASS_NOEXPAND) != 0, &sub, &sublen);
|
||||
avflags = 0;
|
||||
if (flags & ASS_NOEXPAND)
|
||||
avflags |= AV_NOEXPAND;
|
||||
if (flags & ASS_ONEWORD)
|
||||
avflags |= AV_ONEWORD;
|
||||
vname = array_variable_name (name, avflags, &sub, &sublen);
|
||||
|
||||
if (vname == 0)
|
||||
return ((SHELL_VAR *)NULL);
|
||||
@@ -338,21 +363,28 @@ assign_array_element (name, value, flags)
|
||||
entry = find_variable (vname);
|
||||
isassoc = entry && assoc_p (entry);
|
||||
|
||||
if (((isassoc == 0 || (flags & ASS_NOEXPAND) == 0) && (ALL_ELEMENT_SUB (sub[0]) && sub[1] == ']')) || (sublen <= 1))
|
||||
/* We don't allow assignment to `*' or `@' associative array keys if the
|
||||
caller hasn't told us the subscript has already been expanded
|
||||
(ASS_NOEXPAND). If the caller has explicitly told us it's ok
|
||||
(ASS_ALLOWALLSUB) we allow it. */
|
||||
if (((isassoc == 0 || (flags & (ASS_NOEXPAND|ASS_ALLOWALLSUB)) == 0) &&
|
||||
(ALL_ELEMENT_SUB (sub[0]) && sub[1] == ']')) ||
|
||||
(sublen <= 1) ||
|
||||
(sub[sublen] != '\0')) /* sanity check */
|
||||
{
|
||||
free (vname);
|
||||
err_badarraysub (name);
|
||||
return ((SHELL_VAR *)NULL);
|
||||
}
|
||||
|
||||
entry = assign_array_element_internal (entry, name, vname, sub, sublen, value, flags);
|
||||
entry = assign_array_element_internal (entry, name, vname, sub, sublen, value, flags, estatep);
|
||||
|
||||
free (vname);
|
||||
return entry;
|
||||
}
|
||||
|
||||
static SHELL_VAR *
|
||||
assign_array_element_internal (entry, name, vname, sub, sublen, value, flags)
|
||||
assign_array_element_internal (entry, name, vname, sub, sublen, value, flags, estatep)
|
||||
SHELL_VAR *entry;
|
||||
char *name; /* only used for error messages */
|
||||
char *vname;
|
||||
@@ -360,15 +392,19 @@ assign_array_element_internal (entry, name, vname, sub, sublen, value, flags)
|
||||
int sublen;
|
||||
char *value;
|
||||
int flags;
|
||||
array_eltstate_t *estatep;
|
||||
{
|
||||
char *akey;
|
||||
char *akey, *nkey;
|
||||
arrayind_t ind;
|
||||
char *newval;
|
||||
|
||||
/* rely on the caller to initialize estatep */
|
||||
|
||||
if (entry && assoc_p (entry))
|
||||
{
|
||||
sub[sublen-1] = '\0';
|
||||
if ((flags & ASS_NOEXPAND) == 0)
|
||||
akey = expand_assignment_string_to_string (sub, 0); /* [ */
|
||||
akey = expand_subscript_string (sub, 0); /* [ */
|
||||
else
|
||||
akey = savestring (sub);
|
||||
sub[sublen-1] = ']';
|
||||
@@ -378,7 +414,15 @@ assign_array_element_internal (entry, name, vname, sub, sublen, value, flags)
|
||||
FREE (akey);
|
||||
return ((SHELL_VAR *)NULL);
|
||||
}
|
||||
if (estatep)
|
||||
nkey = savestring (akey); /* assoc_insert/assoc_replace frees akey */
|
||||
entry = bind_assoc_variable (entry, vname, akey, value, flags);
|
||||
if (estatep)
|
||||
{
|
||||
estatep->type = ARRAY_ASSOC;
|
||||
estatep->key = nkey;
|
||||
estatep->value = entry ? assoc_reference (assoc_cell (entry), nkey) : 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -392,6 +436,12 @@ assign_array_element_internal (entry, name, vname, sub, sublen, value, flags)
|
||||
return ((SHELL_VAR *)NULL);
|
||||
}
|
||||
entry = bind_array_variable (vname, ind, value, flags);
|
||||
if (estatep)
|
||||
{
|
||||
estatep->type = ARRAY_INDEXED;
|
||||
estatep->ind = ind;
|
||||
estatep->value = entry ? array_reference (array_cell (entry), ind) : 0;
|
||||
}
|
||||
}
|
||||
|
||||
return (entry);
|
||||
@@ -523,8 +573,17 @@ expand_compound_array_assignment (var, value, flags)
|
||||
shell expansions including pathname generation and word splitting. */
|
||||
/* First we split the string on whitespace, using the shell parser
|
||||
(ksh93 seems to do this). */
|
||||
/* XXX - this needs a rethink, maybe use split_at_delims */
|
||||
list = parse_string_to_word_list (val, 1, "array assign");
|
||||
|
||||
/* If the parser has quoted CTLESC and CTNLNUL with CTLESC in unquoted
|
||||
words, we need to remove those here because the code below assumes
|
||||
they are there because they exist in the original word. */
|
||||
/* XXX - if we rethink parse_string_to_word_list above, change this. */
|
||||
for (nlist = list; nlist; nlist = nlist->next)
|
||||
if ((nlist->word->flags & W_QUOTED) == 0)
|
||||
remove_quoted_escapes (nlist->word->word);
|
||||
|
||||
/* Note that we defer expansion of the assignment statements for associative
|
||||
arrays here, so we don't have to scan the subscript and find the ending
|
||||
bracket twice. See the caller below. */
|
||||
@@ -573,7 +632,7 @@ assign_assoc_from_kvlist (var, nlist, h, flags)
|
||||
if (list->next)
|
||||
list = list->next;
|
||||
|
||||
akey = expand_assignment_string_to_string (k, 0);
|
||||
akey = expand_subscript_string (k, 0);
|
||||
if (akey == 0 || *akey == 0)
|
||||
{
|
||||
err_badarraysub (k);
|
||||
@@ -581,7 +640,7 @@ assign_assoc_from_kvlist (var, nlist, h, flags)
|
||||
continue;
|
||||
}
|
||||
|
||||
aval = expand_assignment_string_to_string (v, 0);
|
||||
aval = expand_subscript_string (v, 0);
|
||||
if (aval == 0)
|
||||
{
|
||||
aval = (char *)xmalloc (1);
|
||||
@@ -606,10 +665,13 @@ char *
|
||||
expand_and_quote_kvpair_word (w)
|
||||
char *w;
|
||||
{
|
||||
char *t, *r;
|
||||
char *r, *s, *t;
|
||||
|
||||
t = w ? expand_assignment_string_to_string (w, 0) : 0;
|
||||
r = sh_single_quote (t ? t : "");
|
||||
t = w ? expand_subscript_string (w, 0) : 0;
|
||||
s = (t && strchr (t, CTLESC)) ? quote_escapes (t) : t;
|
||||
r = sh_single_quote (s ? s : "");
|
||||
if (s != t)
|
||||
free (s);
|
||||
free (t);
|
||||
return r;
|
||||
}
|
||||
@@ -709,13 +771,10 @@ assign_compound_array_list (var, nlist, flags)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ALL_ELEMENT_SUB (w[1]) && len == 2)
|
||||
if (ALL_ELEMENT_SUB (w[1]) && len == 2 && array_p (var))
|
||||
{
|
||||
set_exit_status (EXECUTION_FAILURE);
|
||||
if (assoc_p (var))
|
||||
report_error (_("%s: invalid associative array key"), w);
|
||||
else
|
||||
report_error (_("%s: cannot assign to non-numeric index"), w);
|
||||
report_error (_("%s: cannot assign to non-numeric index"), w);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -737,7 +796,7 @@ assign_compound_array_list (var, nlist, flags)
|
||||
{
|
||||
/* This is not performed above, see expand_compound_array_assignment */
|
||||
w[len] = '\0'; /*[*/
|
||||
akey = expand_assignment_string_to_string (w+1, 0);
|
||||
akey = expand_subscript_string (w+1, 0);
|
||||
w[len] = ']';
|
||||
/* And we need to expand the value also, see below */
|
||||
if (akey == 0 || *akey == 0)
|
||||
@@ -773,7 +832,7 @@ assign_compound_array_list (var, nlist, flags)
|
||||
/* See above; we need to expand the value here */
|
||||
if (assoc_p (var))
|
||||
{
|
||||
val = expand_assignment_string_to_string (val, 0);
|
||||
val = expand_subscript_string (val, 0);
|
||||
if (val == 0)
|
||||
{
|
||||
val = (char *)xmalloc (1);
|
||||
@@ -888,26 +947,33 @@ quote_compound_array_word (w, type)
|
||||
int ind, wlen, i;
|
||||
|
||||
if (w[0] != LBRACK)
|
||||
return (sh_single_quote (w));
|
||||
return (sh_single_quote (w)); /* XXX - quote CTLESC */
|
||||
ind = skipsubscript (w, 0, 0);
|
||||
if (w[ind] != RBRACK)
|
||||
return (sh_single_quote (w));
|
||||
return (sh_single_quote (w)); /* XXX - quote CTLESC */
|
||||
|
||||
wlen = strlen (w);
|
||||
w[ind] = '\0';
|
||||
sub = sh_single_quote (w+1);
|
||||
t = (strchr (w+1, CTLESC)) ? quote_escapes (w+1) : w+1;
|
||||
sub = sh_single_quote (t);
|
||||
if (t != w+1)
|
||||
free (t);
|
||||
w[ind] = RBRACK;
|
||||
|
||||
nword = xmalloc (wlen * 4 + 5); /* wlen*4 is max single quoted length */
|
||||
nword[0] = LBRACK;
|
||||
i = STRLEN (sub);
|
||||
memcpy (nword+1, sub, i);
|
||||
free (sub);
|
||||
i++; /* accommodate the opening LBRACK */
|
||||
nword[i++] = w[ind++]; /* RBRACK */
|
||||
if (w[ind] == '+')
|
||||
nword[i++] = w[ind++];
|
||||
nword[i++] = w[ind++];
|
||||
value = sh_single_quote (w + ind);
|
||||
t = (strchr (w+ind, CTLESC)) ? quote_escapes (w+ind) : w+ind;
|
||||
value = sh_single_quote (t);
|
||||
if (t != w+ind)
|
||||
free (t);
|
||||
strcpy (nword + i, value);
|
||||
|
||||
return nword;
|
||||
@@ -925,19 +991,22 @@ expand_and_quote_assoc_word (w, type)
|
||||
char *w;
|
||||
int type;
|
||||
{
|
||||
char *nword, *key, *value, *t;
|
||||
char *nword, *key, *value, *s, *t;
|
||||
int ind, wlen, i;
|
||||
|
||||
if (w[0] != LBRACK)
|
||||
return (sh_single_quote (w));
|
||||
return (sh_single_quote (w)); /* XXX - quote_escapes */
|
||||
ind = skipsubscript (w, 0, 0);
|
||||
if (w[ind] != RBRACK)
|
||||
return (sh_single_quote (w));
|
||||
return (sh_single_quote (w)); /* XXX - quote_escapes */
|
||||
|
||||
w[ind] = '\0';
|
||||
t = expand_assignment_string_to_string (w+1, 0);
|
||||
t = expand_subscript_string (w+1, 0);
|
||||
s = (t && strchr (t, CTLESC)) ? quote_escapes (t) : t;
|
||||
key = sh_single_quote (s ? s : "");
|
||||
if (s != t)
|
||||
free (s);
|
||||
w[ind] = RBRACK;
|
||||
key = sh_single_quote (t ? t : "");
|
||||
free (t);
|
||||
|
||||
wlen = STRLEN (key);
|
||||
@@ -951,8 +1020,11 @@ expand_and_quote_assoc_word (w, type)
|
||||
nword[i++] = w[ind++];
|
||||
nword[i++] = w[ind++];
|
||||
|
||||
t = expand_assignment_string_to_string (w+ind, 0);
|
||||
value = sh_single_quote (t ? t : "");
|
||||
t = expand_subscript_string (w+ind, 0);
|
||||
s = (t && strchr (t, CTLESC)) ? quote_escapes (t) : t;
|
||||
value = sh_single_quote (s ? s : "");
|
||||
if (s != t)
|
||||
free (s);
|
||||
free (t);
|
||||
nword = xrealloc (nword, wlen + 5 + STRLEN (value));
|
||||
strcpy (nword + i, value);
|
||||
@@ -972,7 +1044,7 @@ quote_compound_array_list (list, type)
|
||||
WORD_LIST *list;
|
||||
int type;
|
||||
{
|
||||
char *t;
|
||||
char *s, *t;
|
||||
WORD_LIST *l;
|
||||
|
||||
for (l = list; l; l = l->next)
|
||||
@@ -980,7 +1052,12 @@ quote_compound_array_list (list, type)
|
||||
if (l->word == 0 || l->word->word == 0)
|
||||
continue; /* should not happen, but just in case... */
|
||||
if ((l->word->flags & W_ASSIGNMENT) == 0)
|
||||
t = sh_single_quote (l->word->word);
|
||||
{
|
||||
s = (strchr (l->word->word, CTLESC)) ? quote_escapes (l->word->word) : l->word->word;
|
||||
t = sh_single_quote (s);
|
||||
if (s != l->word->word)
|
||||
free (s);
|
||||
}
|
||||
else
|
||||
t = quote_compound_array_word (l->word->word, type);
|
||||
free (l->word->word);
|
||||
@@ -1020,32 +1097,34 @@ quote_array_assignment_chars (list)
|
||||
/* This function is called with SUB pointing to just after the beginning
|
||||
`[' of an array subscript and removes the array element to which SUB
|
||||
expands from array VAR. A subscript of `*' or `@' unsets the array. */
|
||||
/* If FLAGS&1 we don't expand the subscript; we just use it as-is. */
|
||||
/* If FLAGS&1 (VA_NOEXPAND) we don't expand the subscript; we just use it
|
||||
as-is. If FLAGS&VA_ONEWORD, we don't try to use skipsubscript to parse
|
||||
the subscript, we just assume the subscript ends with a close bracket,
|
||||
if one is present, and use what's inside the brackets. */
|
||||
int
|
||||
unbind_array_element (var, sub, flags)
|
||||
SHELL_VAR *var;
|
||||
char *sub;
|
||||
int flags;
|
||||
{
|
||||
int len;
|
||||
arrayind_t ind;
|
||||
char *akey;
|
||||
ARRAY_ELEMENT *ae;
|
||||
|
||||
len = skipsubscript (sub, 0, (flags&1) || (var && assoc_p(var))); /* XXX */
|
||||
if (sub[len] != ']' || len == 0)
|
||||
{
|
||||
builtin_error ("%s[%s: %s", var->name, sub, _(bash_badsub_errmsg));
|
||||
return -1;
|
||||
}
|
||||
sub[len] = '\0';
|
||||
/* Assume that the caller (unset_builtin) passes us a null-terminated SUB,
|
||||
so we don't have to use VA_ONEWORD or parse the subscript again with
|
||||
skipsubscript(). */
|
||||
|
||||
if (ALL_ELEMENT_SUB (sub[0]) && sub[1] == 0)
|
||||
{
|
||||
if (array_p (var) || assoc_p (var))
|
||||
{
|
||||
unbind_variable (var->name); /* XXX -- {array,assoc}_flush ? */
|
||||
return (0);
|
||||
if (flags & VA_ALLOWALL)
|
||||
{
|
||||
unbind_variable (var->name); /* XXX -- {array,assoc}_flush ? */
|
||||
return (0);
|
||||
}
|
||||
/* otherwise we fall through and try to unset element `@' or `*' */
|
||||
}
|
||||
else
|
||||
return -2; /* don't allow this to unset scalar variables */
|
||||
@@ -1053,7 +1132,7 @@ unbind_array_element (var, sub, flags)
|
||||
|
||||
if (assoc_p (var))
|
||||
{
|
||||
akey = (flags & 1) ? sub : expand_assignment_string_to_string (sub, 0);
|
||||
akey = (flags & VA_NOEXPAND) ? sub : expand_subscript_string (sub, 0);
|
||||
if (akey == 0 || *akey == 0)
|
||||
{
|
||||
builtin_error ("[%s]: %s", sub, _(bash_badsub_errmsg));
|
||||
@@ -1066,7 +1145,28 @@ unbind_array_element (var, sub, flags)
|
||||
}
|
||||
else if (array_p (var))
|
||||
{
|
||||
ind = array_expand_index (var, sub, len+1, 0);
|
||||
if (ALL_ELEMENT_SUB (sub[0]) && sub[1] == 0)
|
||||
{
|
||||
/* We can go several ways here:
|
||||
1) remove the array (backwards compatible)
|
||||
2) empty the array (new behavior)
|
||||
3) do nothing; treat the `@' or `*' as an expression and throw
|
||||
an error
|
||||
*/
|
||||
/* Behavior 1 */
|
||||
if (shell_compatibility_level <= 51)
|
||||
{
|
||||
unbind_variable (name_cell (var));
|
||||
return 0;
|
||||
}
|
||||
else /* Behavior 2 */
|
||||
{
|
||||
array_flush (array_cell (var));
|
||||
return 0;
|
||||
}
|
||||
/* Fall through for behavior 3 */
|
||||
}
|
||||
ind = array_expand_index (var, sub, strlen (sub) + 1, 0);
|
||||
/* negative subscripts to indexed arrays count back from end */
|
||||
if (ind < 0)
|
||||
ind = array_max_index (array_cell (var)) + 1 + ind;
|
||||
@@ -1082,7 +1182,7 @@ unbind_array_element (var, sub, flags)
|
||||
else /* array_p (var) == 0 && assoc_p (var) == 0 */
|
||||
{
|
||||
akey = this_command_name;
|
||||
ind = array_expand_index (var, sub, len+1, 0);
|
||||
ind = array_expand_index (var, sub, strlen (sub) + 1, 0);
|
||||
this_command_name = akey;
|
||||
if (ind == 0)
|
||||
{
|
||||
@@ -1144,14 +1244,23 @@ print_assoc_assignment (var, quoted)
|
||||
|
||||
/* Return 1 if NAME is a properly-formed array reference v[sub]. */
|
||||
|
||||
/* Return 1 if NAME is a properly-formed array reference v[sub]. */
|
||||
|
||||
/* When NAME is a properly-formed array reference and a non-null argument SUBP
|
||||
is supplied, '[' and ']' that enclose the subscript are replaced by '\0',
|
||||
and the pointer to the subscript in NAME is assigned to *SUBP, so that NAME
|
||||
and SUBP can be later used as the array name and the subscript,
|
||||
respectively. When SUBP is the null pointer, the original string NAME will
|
||||
not be modified. */
|
||||
/* We need to reserve 1 for FLAGS, which we pass to skipsubscript. */
|
||||
int
|
||||
valid_array_reference (name, flags)
|
||||
const char *name;
|
||||
tokenize_array_reference (name, flags, subp)
|
||||
char *name;
|
||||
int flags;
|
||||
char **subp;
|
||||
{
|
||||
char *t;
|
||||
int r, len, isassoc;
|
||||
int r, len, isassoc, ssflags;
|
||||
SHELL_VAR *entry;
|
||||
|
||||
t = mbschr (name, '['); /* ] */
|
||||
@@ -1166,10 +1275,15 @@ valid_array_reference (name, flags)
|
||||
if (r == 0)
|
||||
return 0;
|
||||
|
||||
ssflags = 0;
|
||||
if (isassoc && ((flags & (VA_NOEXPAND|VA_ONEWORD)) == (VA_NOEXPAND|VA_ONEWORD)))
|
||||
len = strlen (t) - 1;
|
||||
else if (isassoc)
|
||||
len = skipsubscript (t, 0, flags&VA_NOEXPAND); /* VA_NOEXPAND must be 1 */
|
||||
{
|
||||
if (flags & VA_NOEXPAND)
|
||||
ssflags |= 1;
|
||||
len = skipsubscript (t, 0, ssflags);
|
||||
}
|
||||
else
|
||||
/* Check for a properly-terminated non-null subscript. */
|
||||
len = skipsubscript (t, 0, 0); /* arithmetic expression */
|
||||
@@ -1182,16 +1296,34 @@ valid_array_reference (name, flags)
|
||||
existing associative arrays, using isassoc */
|
||||
for (r = 1; r < len; r++)
|
||||
if (whitespace (t[r]) == 0)
|
||||
return 1;
|
||||
return 0;
|
||||
#else
|
||||
break;
|
||||
if (r == len)
|
||||
return 0; /* Fail if the subscript contains only whitespaces. */
|
||||
#endif
|
||||
|
||||
if (subp)
|
||||
{
|
||||
t[0] = t[len] = '\0';
|
||||
*subp = t + 1;
|
||||
}
|
||||
|
||||
/* This allows blank subscripts */
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Return 1 if NAME is a properly-formed array reference v[sub]. */
|
||||
|
||||
/* We need to reserve 1 for FLAGS, which we pass to skipsubscript. */
|
||||
int
|
||||
valid_array_reference (name, flags)
|
||||
const char *name;
|
||||
int flags;
|
||||
{
|
||||
return tokenize_array_reference ((char *)name, flags, (char **)NULL);
|
||||
}
|
||||
|
||||
/* Expand the array index beginning at S and extending LEN characters. */
|
||||
arrayind_t
|
||||
array_expand_index (var, s, len, flags)
|
||||
@@ -1201,7 +1333,7 @@ array_expand_index (var, s, len, flags)
|
||||
int flags;
|
||||
{
|
||||
char *exp, *t, *savecmd;
|
||||
int expok;
|
||||
int expok, eflag;
|
||||
arrayind_t val;
|
||||
|
||||
exp = (char *)xmalloc (len);
|
||||
@@ -1212,11 +1344,13 @@ array_expand_index (var, s, len, flags)
|
||||
t = expand_arith_string (exp, Q_DOUBLE_QUOTES|Q_ARITH|Q_ARRAYSUB); /* XXX - Q_ARRAYSUB for future use */
|
||||
else
|
||||
t = exp;
|
||||
#endif
|
||||
#else
|
||||
t = expand_arith_string (exp, Q_DOUBLE_QUOTES|Q_ARITH|Q_ARRAYSUB); /* XXX - Q_ARRAYSUB for future use */
|
||||
#endif
|
||||
savecmd = this_command_name;
|
||||
this_command_name = (char *)NULL;
|
||||
val = evalexp (t, EXP_EXPANDED, &expok); /* XXX - was 0 but we expanded exp already */
|
||||
eflag = (shell_compatibility_level > 51) ? 0 : EXP_EXPANDED;
|
||||
val = evalexp (t, eflag, &expok); /* XXX - was 0 but we expanded exp already */
|
||||
this_command_name = savecmd;
|
||||
if (t != exp)
|
||||
free (t);
|
||||
@@ -1245,7 +1379,7 @@ array_variable_name (s, flags, subp, lenp)
|
||||
int *lenp;
|
||||
{
|
||||
char *t, *ret;
|
||||
int ind, ni;
|
||||
int ind, ni, ssflags;
|
||||
|
||||
t = mbschr (s, '[');
|
||||
if (t == 0)
|
||||
@@ -1257,7 +1391,15 @@ array_variable_name (s, flags, subp, lenp)
|
||||
return ((char *)NULL);
|
||||
}
|
||||
ind = t - s;
|
||||
ni = skipsubscript (s, ind, flags); /* XXX - was 0 not flags */
|
||||
if ((flags & (AV_NOEXPAND|AV_ONEWORD)) == (AV_NOEXPAND|AV_ONEWORD))
|
||||
ni = strlen (s) - 1;
|
||||
else
|
||||
{
|
||||
ssflags = 0;
|
||||
if (flags & AV_NOEXPAND)
|
||||
ssflags |= 1;
|
||||
ni = skipsubscript (s, ind, ssflags);
|
||||
}
|
||||
if (ni <= ind + 1 || s[ni] != ']')
|
||||
{
|
||||
err_badarraysub (s);
|
||||
@@ -1323,19 +1465,19 @@ array_variable_part (s, flags, subp, lenp)
|
||||
is non-null it gets 1 if the array reference is name[*], 2 if the
|
||||
reference is name[@], and 0 otherwise. */
|
||||
static char *
|
||||
array_value_internal (s, quoted, flags, rtype, indp)
|
||||
array_value_internal (s, quoted, flags, estatep)
|
||||
const char *s;
|
||||
int quoted, flags, *rtype;
|
||||
arrayind_t *indp;
|
||||
int quoted, flags;
|
||||
array_eltstate_t *estatep;
|
||||
{
|
||||
int len;
|
||||
int len, isassoc, subtype;
|
||||
arrayind_t ind;
|
||||
char *akey;
|
||||
char *retval, *t, *temp;
|
||||
WORD_LIST *l;
|
||||
SHELL_VAR *var;
|
||||
|
||||
var = array_variable_part (s, (flags&AV_NOEXPAND) ? 1 : 0, &t, &len); /* XXX */
|
||||
var = array_variable_part (s, flags, &t, &len); /* XXX */
|
||||
|
||||
/* Expand the index, even if the variable doesn't exist, in case side
|
||||
effects are needed, like ${w[i++]} where w is unset. */
|
||||
@@ -1347,38 +1489,53 @@ array_value_internal (s, quoted, flags, rtype, indp)
|
||||
if (len == 0)
|
||||
return ((char *)NULL); /* error message already printed */
|
||||
|
||||
isassoc = var && assoc_p (var);
|
||||
/* [ */
|
||||
akey = 0;
|
||||
if (ALL_ELEMENT_SUB (t[0]) && t[1] == ']')
|
||||
subtype = 0;
|
||||
if (estatep)
|
||||
estatep->value = (char *)NULL;
|
||||
|
||||
/* Backwards compatibility: we only change the behavior of A[@] and A[*]
|
||||
for associative arrays, and the caller has to request it. */
|
||||
if ((isassoc == 0 || (flags & AV_ATSTARKEYS) == 0) && ALL_ELEMENT_SUB (t[0]) && t[1] == ']')
|
||||
{
|
||||
if (rtype)
|
||||
*rtype = (t[0] == '*') ? 1 : 2;
|
||||
if (estatep)
|
||||
estatep->subtype = (t[0] == '*') ? 1 : 2;
|
||||
if ((flags & AV_ALLOWALL) == 0)
|
||||
{
|
||||
err_badarraysub (s);
|
||||
return ((char *)NULL);
|
||||
}
|
||||
else if (var == 0 || value_cell (var) == 0) /* XXX - check for invisible_p(var) ? */
|
||||
else if (var == 0 || value_cell (var) == 0)
|
||||
return ((char *)NULL);
|
||||
else if (invisible_p (var))
|
||||
return ((char *)NULL);
|
||||
else if (array_p (var) == 0 && assoc_p (var) == 0)
|
||||
l = add_string_to_list (value_cell (var), (WORD_LIST *)NULL);
|
||||
{
|
||||
if (estatep)
|
||||
estatep->type = ARRAY_SCALAR;
|
||||
l = add_string_to_list (value_cell (var), (WORD_LIST *)NULL);
|
||||
}
|
||||
else if (assoc_p (var))
|
||||
{
|
||||
if (estatep)
|
||||
estatep->type = ARRAY_ASSOC;
|
||||
l = assoc_to_word_list (assoc_cell (var));
|
||||
if (l == (WORD_LIST *)NULL)
|
||||
return ((char *)NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (estatep)
|
||||
estatep->type = ARRAY_ASSOC;
|
||||
l = array_to_word_list (array_cell (var));
|
||||
if (l == (WORD_LIST *)NULL)
|
||||
return ((char *) NULL);
|
||||
}
|
||||
|
||||
/* Caller of array_value takes care of inspecting rtype and duplicating
|
||||
retval if rtype == 0, so this is not a memory leak */
|
||||
/* Caller of array_value takes care of inspecting estatep->subtype and
|
||||
duplicating retval if subtype == 0, so this is not a memory leak */
|
||||
if (t[0] == '*' && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)))
|
||||
{
|
||||
temp = string_list_dollar_star (l, quoted, (flags & AV_ASSIGNRHS) ? PF_ASSIGNRHS : 0);
|
||||
@@ -1392,11 +1549,11 @@ array_value_internal (s, quoted, flags, rtype, indp)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rtype)
|
||||
*rtype = 0;
|
||||
if (estatep)
|
||||
estatep->subtype = 0;
|
||||
if (var == 0 || array_p (var) || assoc_p (var) == 0)
|
||||
{
|
||||
if ((flags & AV_USEIND) == 0 || indp == 0)
|
||||
if ((flags & AV_USEIND) == 0 || estatep == 0)
|
||||
{
|
||||
ind = array_expand_index (var, t, len, flags);
|
||||
if (ind < 0)
|
||||
@@ -1407,17 +1564,23 @@ array_value_internal (s, quoted, flags, rtype, indp)
|
||||
if (ind < 0)
|
||||
INDEX_ERROR();
|
||||
}
|
||||
if (indp)
|
||||
*indp = ind;
|
||||
if (estatep)
|
||||
estatep->ind = ind;
|
||||
}
|
||||
else if (indp)
|
||||
ind = *indp;
|
||||
else if (estatep && (flags & AV_USEIND))
|
||||
ind = estatep->ind;
|
||||
if (estatep && var)
|
||||
estatep->type = array_p (var) ? ARRAY_INDEXED : ARRAY_SCALAR;
|
||||
}
|
||||
else if (assoc_p (var))
|
||||
{
|
||||
t[len - 1] = '\0';
|
||||
if ((flags & AV_NOEXPAND) == 0)
|
||||
akey = expand_assignment_string_to_string (t, 0); /* [ */
|
||||
if (estatep)
|
||||
estatep->type = ARRAY_ASSOC;
|
||||
if ((flags & AV_USEIND) && estatep && estatep->key)
|
||||
akey = savestring (estatep->key);
|
||||
else if ((flags & AV_NOEXPAND) == 0)
|
||||
akey = expand_subscript_string (t, 0); /* [ */
|
||||
else
|
||||
akey = savestring (t);
|
||||
t[len - 1] = ']';
|
||||
@@ -1427,26 +1590,34 @@ array_value_internal (s, quoted, flags, rtype, indp)
|
||||
INDEX_ERROR();
|
||||
}
|
||||
}
|
||||
|
||||
if (var == 0 || value_cell (var) == 0) /* XXX - check invisible_p(var) ? */
|
||||
|
||||
if (var == 0 || value_cell (var) == 0)
|
||||
{
|
||||
FREE (akey);
|
||||
FREE (akey);
|
||||
return ((char *)NULL);
|
||||
}
|
||||
else if (invisible_p (var))
|
||||
{
|
||||
FREE (akey);
|
||||
FREE (akey);
|
||||
return ((char *)NULL);
|
||||
}
|
||||
if (array_p (var) == 0 && assoc_p (var) == 0)
|
||||
return (ind == 0 ? value_cell (var) : (char *)NULL);
|
||||
retval = (ind == 0) ? value_cell (var) : (char *)NULL;
|
||||
else if (assoc_p (var))
|
||||
{
|
||||
retval = assoc_reference (assoc_cell (var), akey);
|
||||
free (akey);
|
||||
if (estatep && estatep->key && (flags & AV_USEIND))
|
||||
free (akey); /* duplicated estatep->key */
|
||||
else if (estatep)
|
||||
estatep->key = akey; /* XXX - caller must manage */
|
||||
else /* not saving it anywhere */
|
||||
free (akey);
|
||||
}
|
||||
else
|
||||
retval = array_reference (array_cell (var), ind);
|
||||
|
||||
if (estatep)
|
||||
estatep->value = retval;
|
||||
}
|
||||
|
||||
return retval;
|
||||
@@ -1455,12 +1626,15 @@ array_value_internal (s, quoted, flags, rtype, indp)
|
||||
/* Return a string containing the elements described by the array and
|
||||
subscript contained in S, obeying quoting for subscripts * and @. */
|
||||
char *
|
||||
array_value (s, quoted, flags, rtype, indp)
|
||||
array_value (s, quoted, flags, estatep)
|
||||
const char *s;
|
||||
int quoted, flags, *rtype;
|
||||
arrayind_t *indp;
|
||||
int quoted, flags;
|
||||
array_eltstate_t *estatep;
|
||||
{
|
||||
return (array_value_internal (s, quoted, flags|AV_ALLOWALL, rtype, indp));
|
||||
char *retval;
|
||||
|
||||
retval = array_value_internal (s, quoted, flags|AV_ALLOWALL, estatep);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* Return the value of the array indexing expression S as a single string.
|
||||
@@ -1468,12 +1642,15 @@ array_value (s, quoted, flags, rtype, indp)
|
||||
is used by other parts of the shell such as the arithmetic expression
|
||||
evaluator in expr.c. */
|
||||
char *
|
||||
get_array_value (s, flags, rtype, indp)
|
||||
get_array_value (s, flags, estatep)
|
||||
const char *s;
|
||||
int flags, *rtype;
|
||||
arrayind_t *indp;
|
||||
int flags;
|
||||
array_eltstate_t *estatep;
|
||||
{
|
||||
return (array_value_internal (s, 0, flags, rtype, indp));
|
||||
char *retval;
|
||||
|
||||
retval = array_value_internal (s, 0, flags, estatep);
|
||||
return retval;
|
||||
}
|
||||
|
||||
char *
|
||||
|
||||
+47
-7
@@ -1,6 +1,6 @@
|
||||
/* arrayfunc.h -- declarations for miscellaneous array functions in arrayfunc.c */
|
||||
|
||||
/* Copyright (C) 2001-2020 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 2001-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -23,6 +23,29 @@
|
||||
|
||||
/* Must include variables.h before including this file. */
|
||||
|
||||
/* An object to encapsulate the state of an array element. It can describe
|
||||
an array assignment A[KEY]=VALUE or a[IND]=VALUE depending on TYPE, or
|
||||
for passing array subscript references around, where VALUE would be
|
||||
${a[IND]} or ${A[KEY]}. This is not dependent on ARRAY_VARS so we can
|
||||
use it in function parameters. */
|
||||
|
||||
/* values for `type' field */
|
||||
#define ARRAY_INVALID -1
|
||||
#define ARRAY_SCALAR 0
|
||||
#define ARRAY_INDEXED 1
|
||||
#define ARRAY_ASSOC 2
|
||||
|
||||
/* KEY will contain allocated memory if called through the assign_array_element
|
||||
code path because of how assoc_insert works. */
|
||||
typedef struct element_state
|
||||
{
|
||||
short type; /* assoc or indexed, says which fields are valid */
|
||||
short subtype; /* `*', `@', or something else */
|
||||
arrayind_t ind;
|
||||
char *key; /* can be allocated memory */
|
||||
char *value;
|
||||
} array_eltstate_t;
|
||||
|
||||
#if defined (ARRAY_VARS)
|
||||
|
||||
/* This variable means to not expand associative array subscripts more than
|
||||
@@ -32,17 +55,23 @@ extern int assoc_expand_once;
|
||||
/* The analog for indexed array subscripts */
|
||||
extern int array_expand_once;
|
||||
|
||||
/* Flags for array_value_internal and callers array_value/get_array_value */
|
||||
#define AV_ALLOWALL 0x001
|
||||
/* Flags for array_value_internal and callers array_value/get_array_value; also
|
||||
used by array_variable_name and array_variable_part. */
|
||||
#define AV_ALLOWALL 0x001 /* treat a[@] like $@ and a[*] like $* */
|
||||
#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[@]} */
|
||||
#define AV_NOEXPAND 0x020 /* don't run assoc subscripts through word expansion */
|
||||
#define AV_ONEWORD 0x040 /* not used yet */
|
||||
#define AV_ATSTARKEYS 0x080 /* accept a[@] and a[*] but use them as keys, not special values */
|
||||
|
||||
/* Flags for valid_array_reference. Value 1 is reserved for skipsubscript() */
|
||||
/* Flags for valid_array_reference. Value 1 is reserved for skipsubscript().
|
||||
Also used by unbind_array_element, which is currently the only function
|
||||
that uses VA_ALLOWALL. */
|
||||
#define VA_NOEXPAND 0x001
|
||||
#define VA_ONEWORD 0x002
|
||||
#define VA_ALLOWALL 0x004 /* allow @ to mean all elements of the array */
|
||||
|
||||
extern SHELL_VAR *convert_var_to_array PARAMS((SHELL_VAR *));
|
||||
extern SHELL_VAR *convert_var_to_assoc PARAMS((SHELL_VAR *));
|
||||
@@ -51,7 +80,7 @@ extern char *make_array_variable_value PARAMS((SHELL_VAR *, arrayind_t, char *,
|
||||
|
||||
extern SHELL_VAR *bind_array_variable PARAMS((char *, arrayind_t, char *, int));
|
||||
extern SHELL_VAR *bind_array_element PARAMS((SHELL_VAR *, arrayind_t, char *, int));
|
||||
extern SHELL_VAR *assign_array_element PARAMS((char *, char *, int));
|
||||
extern SHELL_VAR *assign_array_element PARAMS((char *, char *, int, array_eltstate_t *));
|
||||
|
||||
extern SHELL_VAR *bind_assoc_variable PARAMS((SHELL_VAR *, char *, char *, char *, int));
|
||||
|
||||
@@ -78,22 +107,33 @@ extern void print_assoc_assignment PARAMS((SHELL_VAR *, int));
|
||||
|
||||
extern arrayind_t array_expand_index PARAMS((SHELL_VAR *, char *, int, int));
|
||||
extern int valid_array_reference PARAMS((const char *, int));
|
||||
extern char *array_value PARAMS((const char *, int, int, int *, arrayind_t *));
|
||||
extern char *get_array_value PARAMS((const char *, int, int *, arrayind_t *));
|
||||
extern int tokenize_array_reference PARAMS((char *, int, char **));
|
||||
|
||||
extern char *array_value PARAMS((const char *, int, int, array_eltstate_t *));
|
||||
extern char *get_array_value PARAMS((const char *, int, array_eltstate_t *));
|
||||
|
||||
extern char *array_keys PARAMS((char *, int, int));
|
||||
|
||||
extern char *array_variable_name PARAMS((const char *, int, char **, int *));
|
||||
extern SHELL_VAR *array_variable_part PARAMS((const char *, int, char **, int *));
|
||||
|
||||
extern void init_eltstate (array_eltstate_t *);
|
||||
extern void flush_eltstate (array_eltstate_t *);
|
||||
|
||||
#else
|
||||
|
||||
#define AV_ALLOWALL 0
|
||||
#define AV_QUOTED 0
|
||||
#define AV_USEIND 0
|
||||
#define AV_USEVAL 0
|
||||
#define AV_ASSIGNRHS 0
|
||||
#define AV_NOEXPAND 0
|
||||
#define AV_ONEWORD 0
|
||||
#define AV_ATSTARKEYS 0
|
||||
|
||||
#define VA_NOEXPAND 0
|
||||
#define VA_ONEWORD 0
|
||||
#define VA_ALLOWALL 0
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* chet@ins.cwru.edu
|
||||
*/
|
||||
|
||||
/* Copyright (C) 2008,2009,2011-2020 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 2008,2009,2011-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -544,6 +544,30 @@ assoc_keys_to_word_list (h)
|
||||
return (assoc_to_word_list_internal (h, 1));
|
||||
}
|
||||
|
||||
WORD_LIST *
|
||||
assoc_to_kvpair_list (h)
|
||||
HASH_TABLE *h;
|
||||
{
|
||||
WORD_LIST *list;
|
||||
int i;
|
||||
BUCKET_CONTENTS *tlist;
|
||||
char *k, *v;
|
||||
|
||||
if (h == 0 || assoc_empty (h))
|
||||
return((WORD_LIST *)NULL);
|
||||
list = (WORD_LIST *)NULL;
|
||||
|
||||
for (i = 0; i < h->nbuckets; i++)
|
||||
for (tlist = hash_items (i, h); tlist; tlist = tlist->next)
|
||||
{
|
||||
k = (char *)tlist->key;
|
||||
v = (char *)tlist->data;
|
||||
list = make_word_list (make_bare_word (k), list);
|
||||
list = make_word_list (make_bare_word (v), list);
|
||||
}
|
||||
return (REVERSE_LIST(list, WORD_LIST *));
|
||||
}
|
||||
|
||||
char *
|
||||
assoc_to_string (h, sep, quoted)
|
||||
HASH_TABLE *h;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* assoc.h -- definitions for the interface exported by assoc.c that allows
|
||||
the rest of the shell to manipulate associative array variables. */
|
||||
|
||||
/* Copyright (C) 2008,2009-2020 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 2008,2009-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -60,6 +60,7 @@ extern char *assoc_to_assign PARAMS((HASH_TABLE *, int));
|
||||
|
||||
extern WORD_LIST *assoc_to_word_list PARAMS((HASH_TABLE *));
|
||||
extern WORD_LIST *assoc_keys_to_word_list PARAMS((HASH_TABLE *));
|
||||
extern WORD_LIST *assoc_to_kvpair_list PARAMS((HASH_TABLE *));
|
||||
|
||||
extern char *assoc_to_string PARAMS((HASH_TABLE *, char *, int));
|
||||
#endif /* _ASSOC_H_ */
|
||||
|
||||
+1
-4
@@ -1,6 +1,6 @@
|
||||
/* bashansi.h -- Typically included information required by picky compilers. */
|
||||
|
||||
/* Copyright (C) 1993-2009 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1993-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -22,9 +22,6 @@
|
||||
#define _BASHANSI_H_
|
||||
|
||||
#if defined (HAVE_STRING_H)
|
||||
# if ! defined (STDC_HEADERS) && defined (HAVE_MEMORY_H)
|
||||
# include <memory.h>
|
||||
# endif
|
||||
# include <string.h>
|
||||
#endif /* !HAVE_STRING_H */
|
||||
|
||||
|
||||
+10
-5
@@ -1,6 +1,6 @@
|
||||
/* bashhist.c -- bash interface to the GNU history library. */
|
||||
|
||||
/* Copyright (C) 1993-2019 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1993-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -374,8 +374,11 @@ bash_delete_history_range (first, last)
|
||||
HIST_ENTRY **discard_list;
|
||||
|
||||
discard_list = remove_history_range (first, last);
|
||||
for (i = 0; discard_list && discard_list[i]; i++)
|
||||
if (discard_list == 0)
|
||||
return 0;
|
||||
for (i = 0; discard_list[i]; i++)
|
||||
free_history_entry (discard_list[i]);
|
||||
free (discard_list);
|
||||
history_lines_this_session -= i;
|
||||
|
||||
return 1;
|
||||
@@ -653,6 +656,8 @@ shell_comment (line)
|
||||
char *p;
|
||||
int n;
|
||||
|
||||
if (dstack.delimiter_depth != 0 || (parser_state & PST_HEREDOC))
|
||||
return 0;
|
||||
if (line == 0)
|
||||
return 0;
|
||||
for (p = line; p && *p && whitespace (*p); p++)
|
||||
@@ -757,7 +762,7 @@ maybe_add_history (line)
|
||||
int is_comment;
|
||||
|
||||
hist_last_line_added = 0;
|
||||
is_comment = (parser_state & PST_HEREDOC) ? 0 : shell_comment (line);
|
||||
is_comment = shell_comment (line);
|
||||
|
||||
/* Don't use the value of history_control to affect the second
|
||||
and subsequent lines of a multi-line command (old code did
|
||||
@@ -874,7 +879,7 @@ bash_add_history (line)
|
||||
add_it = 1;
|
||||
if (command_oriented_history && current_command_line_count > 1)
|
||||
{
|
||||
is_comment = (parser_state & PST_HEREDOC) ? 0 : shell_comment (line);
|
||||
is_comment = shell_comment (line);
|
||||
|
||||
/* The second and subsequent lines of a here document have the trailing
|
||||
newline preserved. We don't want to add extra newlines here, but we
|
||||
@@ -887,7 +892,7 @@ bash_add_history (line)
|
||||
(current_command_line_count > 2)
|
||||
don't add a newline here. This will also take care of the literal_history
|
||||
case if the other conditions are met. */
|
||||
if ((parser_state & PST_HEREDOC) && current_command_line_count > 2 && line[strlen (line) - 1] == '\n')
|
||||
if ((parser_state & PST_HEREDOC) && here_doc_first_line == 0 && line[strlen (line) - 1] == '\n')
|
||||
chars_to_add = "";
|
||||
else if (current_command_line_count == current_command_line_comment+1)
|
||||
chars_to_add = "\n";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* bashjmp.h -- wrapper for setjmp.h with necessary bash definitions. */
|
||||
|
||||
/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -42,5 +42,6 @@ extern int no_longjmp_on_fatal_error;
|
||||
#define EXITPROG 3 /* Unconditionally exit the program now. */
|
||||
#define ERREXIT 4 /* Exit due to error condition */
|
||||
#define SIGEXIT 5 /* Exit due to fatal terminating signal */
|
||||
#define EXITBLTIN 6 /* Exit due to the exit builtin. */
|
||||
|
||||
#endif /* _BASHJMP_H_ */
|
||||
|
||||
+258
-72
@@ -1,6 +1,6 @@
|
||||
/* bashline.c -- Bash's interface to the readline library. */
|
||||
|
||||
/* Copyright (C) 1987-2020 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2022 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
#include "shmbutil.h"
|
||||
#include "trap.h"
|
||||
#include "flags.h"
|
||||
#include "timer.h"
|
||||
|
||||
#if defined (HAVE_MBSTR_H) && defined (HAVE_MBSCHR)
|
||||
# include <mbstr.h> /* mbschr */
|
||||
@@ -141,6 +142,8 @@ static int bash_kill_shellword PARAMS((int, int));
|
||||
static int bash_backward_kill_shellword PARAMS((int, int));
|
||||
static int bash_transpose_shellwords PARAMS((int, int));
|
||||
|
||||
static int bash_spell_correct_shellword PARAMS((int, int));
|
||||
|
||||
/* Helper functions for Readline. */
|
||||
static char *restore_tilde PARAMS((char *, char *));
|
||||
static char *maybe_restore_tilde PARAMS((char *, char *));
|
||||
@@ -189,6 +192,8 @@ static int return_zero PARAMS((const char *));
|
||||
|
||||
static char *bash_dequote_filename PARAMS((char *, int));
|
||||
static char *quote_word_break_chars PARAMS((char *));
|
||||
static int bash_check_expchar PARAMS((char *, int, int *, int *));
|
||||
static void set_filename_quote_chars PARAMS((int, int, int));
|
||||
static void set_filename_bstab PARAMS((const char *));
|
||||
static char *bash_quote_filename PARAMS((char *, int, char *));
|
||||
|
||||
@@ -225,6 +230,7 @@ static char **prog_complete_matches;
|
||||
|
||||
extern int no_symbolic_links;
|
||||
extern STRING_INT_ALIST word_token_alist[];
|
||||
extern sh_timer *read_timeout;
|
||||
|
||||
/* SPECIFIC_COMPLETION_FUNCTIONS specifies that we have individual
|
||||
completion functions which indicate what type of completion should be
|
||||
@@ -370,7 +376,8 @@ enable_hostname_completion (on_or_off)
|
||||
int on_or_off;
|
||||
{
|
||||
int old_value;
|
||||
char *at, *nv, *nval;
|
||||
char *nv, *nval;
|
||||
const char *at;
|
||||
|
||||
old_value = perform_hostname_completion;
|
||||
|
||||
@@ -430,7 +437,7 @@ enable_hostname_completion (on_or_off)
|
||||
strcpy (nval + 1, rl_completer_word_break_characters);
|
||||
}
|
||||
|
||||
free (rl_completer_word_break_characters);
|
||||
free ((void *)rl_completer_word_break_characters);
|
||||
rl_completer_word_break_characters = nval;
|
||||
}
|
||||
|
||||
@@ -468,6 +475,9 @@ initialize_readline ()
|
||||
rl_add_defun ("shell-backward-kill-word", bash_backward_kill_shellword, -1);
|
||||
rl_add_defun ("shell-transpose-words", bash_transpose_shellwords, -1);
|
||||
|
||||
rl_add_defun ("spell-correct-word", bash_spell_correct_shellword, -1);
|
||||
rl_bind_key_if_unbound_in_map ('s', bash_spell_correct_shellword, emacs_ctlx_keymap);
|
||||
|
||||
#ifdef ALIAS
|
||||
rl_add_defun ("alias-expand-line", alias_expand_line, -1);
|
||||
# ifdef BANG_HISTORY
|
||||
@@ -666,6 +676,8 @@ bashline_reset ()
|
||||
rl_attempted_completion_function = attempt_shell_completion;
|
||||
rl_completion_entry_function = NULL;
|
||||
rl_ignore_some_completions_function = filename_completion_ignore;
|
||||
|
||||
complete_fullquote = 1;
|
||||
rl_filename_quote_characters = default_filename_quote_characters;
|
||||
set_filename_bstab (rl_filename_quote_characters);
|
||||
|
||||
@@ -1028,6 +1040,8 @@ posix_edit_macros (count, key)
|
||||
char alias_name[3], *alias_value, *macro;
|
||||
|
||||
c = rl_read_key ();
|
||||
if (c <= 0)
|
||||
return 0;
|
||||
alias_name[0] = '_';
|
||||
alias_name[1] = c;
|
||||
alias_name[2] = '\0';
|
||||
@@ -1320,6 +1334,55 @@ bash_transpose_shellwords (count, key)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Directory name spelling correction on the current word (not shellword).
|
||||
COUNT > 1 is not exactly correct yet. */
|
||||
static int
|
||||
bash_spell_correct_shellword (count, key)
|
||||
int count, key;
|
||||
{
|
||||
int opoint, wbeg, wend;
|
||||
char *text, *newdir;
|
||||
|
||||
opoint = rl_point;
|
||||
while (count)
|
||||
{
|
||||
bash_backward_shellword (1, key);
|
||||
wbeg = rl_point;
|
||||
bash_forward_shellword (1, key);
|
||||
wend = rl_point;
|
||||
|
||||
if (wbeg > wend)
|
||||
break;
|
||||
|
||||
text = rl_copy_text (wbeg, wend);
|
||||
|
||||
newdir = dirspell (text);
|
||||
if (newdir)
|
||||
{
|
||||
rl_begin_undo_group ();
|
||||
rl_delete_text (wbeg, wend);
|
||||
rl_point = wbeg;
|
||||
if (*newdir)
|
||||
rl_insert_text (newdir);
|
||||
rl_mark = wbeg;
|
||||
rl_end_undo_group ();
|
||||
}
|
||||
|
||||
free (text);
|
||||
free (newdir);
|
||||
|
||||
if (rl_point >= rl_end)
|
||||
break;
|
||||
|
||||
count--;
|
||||
|
||||
if (count)
|
||||
bash_forward_shellword (1, key); /* XXX */
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* How To Do Shell Completion */
|
||||
@@ -1516,6 +1579,7 @@ attempt_shell_completion (text, start, end)
|
||||
matches = (char **)NULL;
|
||||
rl_ignore_some_completions_function = filename_completion_ignore;
|
||||
|
||||
complete_fullquote = 1; /* full filename quoting by default */
|
||||
rl_filename_quote_characters = default_filename_quote_characters;
|
||||
set_filename_bstab (rl_filename_quote_characters);
|
||||
set_directory_hook ();
|
||||
@@ -1560,7 +1624,7 @@ attempt_shell_completion (text, start, end)
|
||||
in_command_position++;
|
||||
|
||||
if (check_redir (ti) == 1)
|
||||
in_command_position = 0;
|
||||
in_command_position = -1; /* sentinel that we're not the first word on the line */
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1569,7 +1633,7 @@ attempt_shell_completion (text, start, end)
|
||||
assignments. */
|
||||
}
|
||||
|
||||
if (in_command_position && invalid_completion (text, ti))
|
||||
if (in_command_position > 0 && invalid_completion (text, ti))
|
||||
{
|
||||
rl_attempted_completion_over = 1;
|
||||
return ((char **)NULL);
|
||||
@@ -1577,9 +1641,9 @@ attempt_shell_completion (text, start, end)
|
||||
|
||||
/* 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] == '`' &&
|
||||
if (in_command_position > 0 && ti >= 0 && rl_line_buffer[ti] == '`' &&
|
||||
*text != '`' && unclosed_pair (rl_line_buffer, end, "`") == 0)
|
||||
in_command_position = 0;
|
||||
in_command_position = -1; /* not following a command separator */
|
||||
|
||||
/* Special handling for command substitution. If *TEXT is a backquote,
|
||||
it can be the start or end of an old-style command substitution, or
|
||||
@@ -1587,8 +1651,8 @@ attempt_shell_completion (text, start, end)
|
||||
succeed. Don't bother if readline found a single quote and we are
|
||||
completing on the substring. */
|
||||
if (*text == '`' && rl_completion_quote_character != '\'' &&
|
||||
(in_command_position || (unclosed_pair (rl_line_buffer, start, "`") &&
|
||||
unclosed_pair (rl_line_buffer, end, "`"))))
|
||||
(in_command_position > 0 || (unclosed_pair (rl_line_buffer, start, "`") &&
|
||||
unclosed_pair (rl_line_buffer, end, "`"))))
|
||||
matches = rl_completion_matches (text, command_subst_completion_function);
|
||||
|
||||
#if defined (PROGRAMMABLE_COMPLETION)
|
||||
@@ -1596,7 +1660,7 @@ attempt_shell_completion (text, start, end)
|
||||
have_progcomps = prog_completion_enabled && (progcomp_size () > 0);
|
||||
iw_compspec = progcomp_search (INITIALWORD);
|
||||
if (matches == 0 &&
|
||||
(in_command_position == 0 || text[0] == '\0' || (in_command_position && iw_compspec)) &&
|
||||
(in_command_position == 0 || text[0] == '\0' || (in_command_position > 0 && iw_compspec)) &&
|
||||
current_prompt_string == ps1_prompt)
|
||||
{
|
||||
int s, e, s1, e1, os, foundcs;
|
||||
@@ -1718,7 +1782,7 @@ attempt_shell_completion (text, start, end)
|
||||
if (matches == 0)
|
||||
{
|
||||
dflags = 0;
|
||||
if (in_command_position)
|
||||
if (in_command_position > 0)
|
||||
dflags |= DEFCOMP_CMDPOS;
|
||||
matches = bash_default_completion (text, start, end, qc, dflags);
|
||||
}
|
||||
@@ -1872,10 +1936,17 @@ executable_completion (filename, searching_path)
|
||||
const char *filename;
|
||||
int searching_path;
|
||||
{
|
||||
char *f;
|
||||
char *f, c;
|
||||
int r;
|
||||
|
||||
/* This gets an unquoted filename, so we need to quote special characters
|
||||
in the filename before the completion hook gets it. */
|
||||
#if 0
|
||||
f = savestring (filename);
|
||||
#else
|
||||
c = 0;
|
||||
f = bash_quote_filename ((char *)filename, SINGLE_MATCH, &c);
|
||||
#endif
|
||||
bash_directory_completion_hook (&f);
|
||||
|
||||
r = searching_path ? executable_file (f) : executable_or_directory (f);
|
||||
@@ -1927,6 +1998,8 @@ command_word_completion_function (hint_text, state)
|
||||
temp = rl_variable_value ("completion-ignore-case");
|
||||
igncase = RL_BOOLEAN_VARIABLE_VALUE (temp);
|
||||
|
||||
old_glob_ignore_case = glob_ignore_case;
|
||||
|
||||
if (glob_matches)
|
||||
{
|
||||
free (glob_matches);
|
||||
@@ -2112,6 +2185,8 @@ globword:
|
||||
{
|
||||
if (state == 0)
|
||||
{
|
||||
rl_filename_completion_desired = 1;
|
||||
|
||||
glob_ignore_case = igncase;
|
||||
glob_matches = shell_glob_filename (hint, 0);
|
||||
glob_ignore_case = old_glob_ignore_case;
|
||||
@@ -2232,10 +2307,16 @@ globword:
|
||||
|
||||
if (absolute_program (hint))
|
||||
{
|
||||
#if 0
|
||||
if (igncase == 0)
|
||||
match = strncmp (val, hint, hint_len) == 0;
|
||||
else
|
||||
match = strncasecmp (val, hint, hint_len) == 0;
|
||||
#else
|
||||
/* Why duplicate the comparison rl_filename_completion_function
|
||||
already performs? */
|
||||
match = 1;
|
||||
#endif
|
||||
|
||||
/* If we performed tilde expansion, restore the original
|
||||
filename. */
|
||||
@@ -2760,13 +2841,17 @@ static int
|
||||
history_and_alias_expand_line (count, ignore)
|
||||
int count, ignore;
|
||||
{
|
||||
char *new_line;
|
||||
char *new_line, *t;
|
||||
|
||||
new_line = 0;
|
||||
#if defined (BANG_HISTORY)
|
||||
new_line = history_expand_line_internal (rl_line_buffer);
|
||||
#endif
|
||||
|
||||
t = expand_string_dollar_quote (new_line ? new_line : rl_line_buffer, 0);
|
||||
FREE (new_line);
|
||||
new_line = t;
|
||||
|
||||
#if defined (ALIAS)
|
||||
if (new_line)
|
||||
{
|
||||
@@ -2798,7 +2883,7 @@ static int
|
||||
shell_expand_line (count, ignore)
|
||||
int count, ignore;
|
||||
{
|
||||
char *new_line;
|
||||
char *new_line, *t;
|
||||
WORD_LIST *expanded_string;
|
||||
WORD_DESC *w;
|
||||
|
||||
@@ -2807,6 +2892,10 @@ shell_expand_line (count, ignore)
|
||||
new_line = history_expand_line_internal (rl_line_buffer);
|
||||
#endif
|
||||
|
||||
t = expand_string_dollar_quote (new_line ? new_line : rl_line_buffer, 0);
|
||||
FREE (new_line);
|
||||
new_line = t;
|
||||
|
||||
#if defined (ALIAS)
|
||||
if (new_line)
|
||||
{
|
||||
@@ -3191,6 +3280,8 @@ bash_directory_expansion (dirname)
|
||||
free (d);
|
||||
*dirname = nd;
|
||||
}
|
||||
else
|
||||
free (d);
|
||||
}
|
||||
|
||||
/* If necessary, rewrite directory entry */
|
||||
@@ -3372,38 +3463,7 @@ bash_directory_completion_hook (dirname)
|
||||
return_value = should_expand_dirname = nextch = closer = 0;
|
||||
local_dirname = *dirname;
|
||||
|
||||
if (t = mbschr (local_dirname, '$'))
|
||||
{
|
||||
should_expand_dirname = '$';
|
||||
nextch = t[1];
|
||||
/* Deliberately does not handle the deprecated $[...] arithmetic
|
||||
expansion syntax */
|
||||
if (nextch == '(')
|
||||
closer = ')';
|
||||
else if (nextch == '{')
|
||||
closer = '}';
|
||||
else
|
||||
nextch = 0;
|
||||
|
||||
if (closer)
|
||||
{
|
||||
int p;
|
||||
char delims[2];
|
||||
|
||||
delims[0] = closer; delims[1] = 0;
|
||||
p = skip_to_delim (t, 1, delims, SD_NOJMP|SD_COMPLETE);
|
||||
if (t[p] != closer)
|
||||
should_expand_dirname = 0;
|
||||
}
|
||||
}
|
||||
else if (local_dirname[0] == '~')
|
||||
should_expand_dirname = '~';
|
||||
else
|
||||
{
|
||||
t = mbschr (local_dirname, '`');
|
||||
if (t && unclosed_pair (local_dirname, strlen (local_dirname), "`") == 0)
|
||||
should_expand_dirname = '`';
|
||||
}
|
||||
should_expand_dirname = bash_check_expchar (local_dirname, 1, &nextch, &closer);
|
||||
|
||||
if (should_expand_dirname && directory_exists (local_dirname, 1))
|
||||
should_expand_dirname = 0;
|
||||
@@ -3422,24 +3482,8 @@ bash_directory_completion_hook (dirname)
|
||||
free (new_dirname);
|
||||
dispose_words (wl);
|
||||
local_dirname = *dirname;
|
||||
/* XXX - change rl_filename_quote_characters here based on
|
||||
should_expand_dirname/nextch/closer. This is the only place
|
||||
custom_filename_quote_characters is modified. */
|
||||
if (rl_filename_quote_characters && *rl_filename_quote_characters)
|
||||
{
|
||||
int i, j, c;
|
||||
i = strlen (default_filename_quote_characters);
|
||||
custom_filename_quote_characters = xrealloc (custom_filename_quote_characters, i+1);
|
||||
for (i = j = 0; c = default_filename_quote_characters[i]; i++)
|
||||
{
|
||||
if (c == should_expand_dirname || c == nextch || c == closer)
|
||||
continue;
|
||||
custom_filename_quote_characters[j++] = c;
|
||||
}
|
||||
custom_filename_quote_characters[j] = '\0';
|
||||
rl_filename_quote_characters = custom_filename_quote_characters;
|
||||
set_filename_bstab (rl_filename_quote_characters);
|
||||
}
|
||||
|
||||
set_filename_quote_chars (should_expand_dirname, nextch, closer);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3494,7 +3538,16 @@ bash_directory_completion_hook (dirname)
|
||||
subsequent directory checks don't fail. */
|
||||
if (temp2 == 0 && dircomplete_spelling && dircomplete_expand)
|
||||
{
|
||||
size_t l1, l2;
|
||||
|
||||
temp2 = dirspell (temp1);
|
||||
l2 = STRLEN (temp2);
|
||||
/* Don't take matches if they are shorter than the original path */
|
||||
if (temp2 && l2 < strlen (temp1) && STREQN (temp1, temp2, l2))
|
||||
{
|
||||
free (temp2);
|
||||
temp2 = 0;
|
||||
}
|
||||
if (temp2)
|
||||
{
|
||||
free (temp1);
|
||||
@@ -3729,7 +3782,7 @@ bash_complete_filename_internal (what_to_do)
|
||||
rl_completion_func_t *orig_attempt_func;
|
||||
rl_icppfunc_t *orig_dir_func;
|
||||
rl_compignore_func_t *orig_ignore_func;
|
||||
/*const*/ char *orig_rl_completer_word_break_characters;
|
||||
const char *orig_rl_completer_word_break_characters;
|
||||
int r;
|
||||
|
||||
orig_func = rl_completion_entry_function;
|
||||
@@ -4099,6 +4152,95 @@ quote_word_break_chars (text)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Return a character in DIRNAME that will cause shell expansion to be
|
||||
performed. If NEXTP is non-null, *NEXTP gets the expansion character that
|
||||
follows RET (e.g., '{' or `(' for `$'). If CLOSERP is non-null, *CLOSERP
|
||||
gets the character that should close <RET><NEXTP>. If NEED_CLOSER is non-
|
||||
zero, any expansion pair that isn't closed causes this function to
|
||||
return 0, which indicates that we didn't find an expansion character. It's
|
||||
used in case DIRNAME is going to be expanded. If DIRNAME is just going to
|
||||
be quoted, NEED_CLOSER will be 0. */
|
||||
static int
|
||||
bash_check_expchar (dirname, need_closer, nextp, closerp)
|
||||
char *dirname;
|
||||
int need_closer;
|
||||
int *nextp, *closerp;
|
||||
{
|
||||
char *t;
|
||||
int ret, n, c;
|
||||
|
||||
ret = n = c = 0;
|
||||
if (t = mbschr (dirname, '$'))
|
||||
{
|
||||
ret = '$';
|
||||
n = t[1];
|
||||
/* Deliberately does not handle the deprecated $[...] arithmetic
|
||||
expansion syntax */
|
||||
if (n == '(')
|
||||
c = ')';
|
||||
else if (n == '{')
|
||||
c = '}';
|
||||
else
|
||||
n = 0;
|
||||
|
||||
if (c && need_closer) /* XXX */
|
||||
{
|
||||
int p;
|
||||
char delims[2];
|
||||
|
||||
delims[0] = c; delims[1] = 0;
|
||||
p = skip_to_delim (t, 1, delims, SD_NOJMP|SD_COMPLETE);
|
||||
if (t[p] != c)
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
else if (dirname[0] == '~')
|
||||
ret = '~';
|
||||
else
|
||||
{
|
||||
t = mbschr (dirname, '`');
|
||||
if (t)
|
||||
{
|
||||
if (need_closer == 0)
|
||||
ret = '`';
|
||||
else if (unclosed_pair (dirname, strlen (dirname), "`") == 0)
|
||||
ret = '`';
|
||||
}
|
||||
}
|
||||
|
||||
if (nextp)
|
||||
*nextp = n;
|
||||
if (closerp)
|
||||
*closerp = c;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Make sure EXPCHAR and, if non-zero, NEXTCH and CLOSER are not in the set
|
||||
of characters to be backslash-escaped. This is the only place
|
||||
custom_filename_quote_characters is modified. */
|
||||
static void
|
||||
set_filename_quote_chars (expchar, nextch, closer)
|
||||
int expchar, nextch, closer;
|
||||
{
|
||||
int i, j, c;
|
||||
|
||||
if (rl_filename_quote_characters && *rl_filename_quote_characters)
|
||||
{
|
||||
i = strlen (default_filename_quote_characters);
|
||||
custom_filename_quote_characters = xrealloc (custom_filename_quote_characters, i+1);
|
||||
for (i = j = 0; c = default_filename_quote_characters[i]; i++)
|
||||
{
|
||||
if (c == expchar || c == nextch || c == closer)
|
||||
continue;
|
||||
custom_filename_quote_characters[j++] = c;
|
||||
}
|
||||
custom_filename_quote_characters[j] = '\0';
|
||||
rl_filename_quote_characters = custom_filename_quote_characters;
|
||||
set_filename_bstab (rl_filename_quote_characters);
|
||||
}
|
||||
}
|
||||
|
||||
/* Use characters in STRING to populate the table of characters that should
|
||||
be backslash-quoted. The table will be used for sh_backslash_quote from
|
||||
this file. */
|
||||
@@ -4127,6 +4269,7 @@ bash_quote_filename (s, rtype, qcp)
|
||||
{
|
||||
char *rtext, *mtext, *ret;
|
||||
int rlen, cs;
|
||||
int expchar, nextch, closer;
|
||||
|
||||
rtext = (char *)NULL;
|
||||
|
||||
@@ -4144,7 +4287,17 @@ bash_quote_filename (s, rtype, qcp)
|
||||
the word being completed contains newlines, since those are not
|
||||
quoted correctly using backslashes (a backslash-newline pair is
|
||||
special to the shell parser). */
|
||||
if (*qcp == '\0' && cs == COMPLETE_BSQUOTE && mbschr (s, '\n'))
|
||||
expchar = nextch = closer = 0;
|
||||
if (*qcp == '\0' && cs == COMPLETE_BSQUOTE && dircomplete_expand == 0 &&
|
||||
(expchar = bash_check_expchar (s, 0, &nextch, &closer)))
|
||||
{
|
||||
/* Usually this will have been set by bash_directory_completion_hook, but
|
||||
there are rare cases where it will not be. */
|
||||
if (rl_filename_quote_characters != custom_filename_quote_characters)
|
||||
set_filename_quote_chars (expchar, nextch, closer);
|
||||
complete_fullquote = 0;
|
||||
}
|
||||
else if (*qcp == '\0' && cs == COMPLETE_BSQUOTE && mbschr (s, '\n'))
|
||||
cs = COMPLETE_SQUOTE;
|
||||
else if (*qcp == '"')
|
||||
cs = COMPLETE_DQUOTE;
|
||||
@@ -4294,12 +4447,28 @@ bash_execute_unix_command (count, key)
|
||||
SHELL_VAR *v;
|
||||
char ibuf[INT_STRLEN_BOUND(int) + 1];
|
||||
Keymap cmd_xmap;
|
||||
const char *kseq;
|
||||
size_t kslen;
|
||||
|
||||
kseq = rl_executing_keyseq;
|
||||
kslen = rl_key_sequence_length;
|
||||
|
||||
/* If we have a numeric argument, chop it off the front of the key sequence */
|
||||
if (count > 1 || rl_explicit_arg)
|
||||
{
|
||||
i = rl_trim_arg_from_keyseq (rl_executing_keyseq, rl_key_sequence_length, rl_get_keymap ());
|
||||
if (i > 0)
|
||||
{
|
||||
kseq = rl_executing_keyseq + i;
|
||||
kslen = rl_key_sequence_length - i;
|
||||
}
|
||||
}
|
||||
|
||||
/* First, we need to find the right command to execute. This is tricky,
|
||||
because we might have already indirected into another keymap, so we
|
||||
have to walk cmd_xmap using the entire key sequence. */
|
||||
cmd_xmap = get_cmd_xmap_from_keymap (rl_get_keymap ());
|
||||
cmd = (char *)rl_function_of_keyseq_len (rl_executing_keyseq, rl_key_sequence_length, cmd_xmap, &type);
|
||||
cmd = (char *)rl_function_of_keyseq_len (kseq, kslen, cmd_xmap, &type);
|
||||
|
||||
if (type == ISKMAP && (type = ((Keymap) cmd)[ANYOTHERKEY].type) == ISMACR)
|
||||
cmd = (char*)((Keymap) cmd)[ANYOTHERKEY].function;
|
||||
@@ -4336,6 +4505,14 @@ bash_execute_unix_command (count, key)
|
||||
v = bind_int_variable ("READLINE_MARK", value, 0);
|
||||
if (v)
|
||||
VSETATTR (v, att_exported);
|
||||
|
||||
if (count > 1 || rl_explicit_arg)
|
||||
{
|
||||
value = inttostr (count, ibuf, sizeof (ibuf));
|
||||
v = bind_int_variable ("READLINE_ARGUMENT", value, 0);
|
||||
if (v)
|
||||
VSETATTR (v, att_exported);
|
||||
}
|
||||
array_needs_making = 1;
|
||||
|
||||
save_parser_state (&ps);
|
||||
@@ -4358,6 +4535,7 @@ bash_execute_unix_command (count, key)
|
||||
check_unbind_variable ("READLINE_LINE");
|
||||
check_unbind_variable ("READLINE_POINT");
|
||||
check_unbind_variable ("READLINE_MARK");
|
||||
check_unbind_variable ("READLINE_ARGUMENT");
|
||||
array_needs_making = 1;
|
||||
|
||||
/* and restore the readline buffer and display after command execution. */
|
||||
@@ -4625,21 +4803,29 @@ bash_event_hook ()
|
||||
sig = terminating_signal;
|
||||
else if (interrupt_state)
|
||||
sig = SIGINT;
|
||||
else if (sigalrm_seen)
|
||||
else if (read_timeout && read_timeout->alrmflag)
|
||||
sig = SIGALRM;
|
||||
else if (RL_ISSTATE (RL_STATE_TIMEOUT)) /* just in case */
|
||||
{
|
||||
sig = SIGALRM;
|
||||
if (read_timeout)
|
||||
read_timeout->alrmflag = 1;
|
||||
}
|
||||
else
|
||||
sig = first_pending_trap ();
|
||||
|
||||
/* If we're going to longjmp to top_level, make sure we clean up readline.
|
||||
check_signals will call QUIT, which will eventually longjmp to top_level,
|
||||
calling run_interrupt_trap along the way. The check for sigalrm_seen is
|
||||
to clean up the read builtin's state. */
|
||||
if (terminating_signal || interrupt_state || sigalrm_seen)
|
||||
calling run_interrupt_trap along the way. The check against read_timeout
|
||||
is so we can clean up the read builtin's state. */
|
||||
if (terminating_signal || interrupt_state || (read_timeout && read_timeout->alrmflag))
|
||||
rl_cleanup_after_signal ();
|
||||
bashline_reset_event_hook ();
|
||||
|
||||
RL_UNSETSTATE (RL_STATE_TIMEOUT); /* XXX */
|
||||
|
||||
/* posix mode SIGINT during read -e. We only get here if SIGINT is trapped. */
|
||||
if (posixly_correct && this_shell_builtin == read_builtin && sig == 2)
|
||||
if (posixly_correct && this_shell_builtin == read_builtin && sig == SIGINT)
|
||||
{
|
||||
last_command_exit_value = 128|SIGINT;
|
||||
throw_to_top_level ();
|
||||
|
||||
+2
-1
@@ -1,6 +1,6 @@
|
||||
/* builtins.h -- What a builtin looks like, and where to find them. */
|
||||
|
||||
/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
#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 ARRAYREF_BUILTIN 0x80 /* This builtin takes array references as arguments */
|
||||
|
||||
#define BASE_INDENT 4
|
||||
|
||||
|
||||
+16
-4
@@ -1,6 +1,6 @@
|
||||
# This Makefile for building libbuiltins.a is in -*- text -*- for Emacs.
|
||||
#
|
||||
# Copyright (C) 1996-2017 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1996-2021 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
|
||||
@@ -59,6 +59,7 @@ LIBBUILD = ${BUILD_DIR}/lib
|
||||
PROFILE_FLAGS = @PROFILE_FLAGS@
|
||||
CFLAGS = @CFLAGS@
|
||||
CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@ @CROSS_COMPILE@
|
||||
STYLE_CFLAGS = @STYLE_CFLAGS@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CPPFLAGS_FOR_BUILD = @CPPFLAGS_FOR_BUILD@
|
||||
LOCAL_CFLAGS = @LOCAL_CFLAGS@ ${DEBUG}
|
||||
@@ -92,7 +93,7 @@ HELPFILES_TARGET = @HELPFILES_TARGET@
|
||||
INCLUDES = -I. -I.. @RL_INCLUDE@ -I$(topdir) -I$(BASHINCDIR) -I$(topdir)/lib -I$(srcdir) ${INTL_INC}
|
||||
|
||||
BASE_CCFLAGS = ${PROFILE_FLAGS} $(DEFS) $(LOCAL_DEFS) $(SYSTEM_FLAGS) \
|
||||
${INCLUDES} $(LOCAL_CFLAGS)
|
||||
${INCLUDES} $(STYLE_CFLAGS) $(LOCAL_CFLAGS)
|
||||
|
||||
CCFLAGS = ${ADDON_CFLAGS} $(BASE_CCFLAGS) $(CPPFLAGS) $(CFLAGS)
|
||||
|
||||
@@ -182,7 +183,7 @@ gen-helpfiles.o: gen-helpfiles.c
|
||||
$(CC_FOR_BUILD) -c $(CCFLAGS_FOR_BUILD) $<
|
||||
|
||||
gen-helpfiles: tmpbuiltins.o gen-helpfiles.o
|
||||
$(CC_FOR_BUILD) ${CCFLAGS_FOR_BUILD} $(LDFLAGS_FOR_BUILD) -o $@ gen-helpfiles.o tmpbuiltins.o $(LIBS_FOR_BUILD)
|
||||
$(CC_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@ gen-helpfiles.o tmpbuiltins.o $(LIBS_FOR_BUILD)
|
||||
|
||||
builtext.h builtins.c: $(MKBUILTINS) $(DEFSRC)
|
||||
@-if test -f builtins.c; then mv -f builtins.c old-builtins.c; fi
|
||||
@@ -203,7 +204,7 @@ builtext.h builtins.c: $(MKBUILTINS) $(DEFSRC)
|
||||
helpdoc: gen-helpfiles
|
||||
./gen-helpfiles ${HELPDIRDEFINE}
|
||||
|
||||
install-help:
|
||||
install-help: $(HELPFILES_TARGET)
|
||||
@-if test -n "${HELPDIR}" && test -d helpfiles ; then \
|
||||
test -d $(DESTDIR)${HELPDIR} || ${SHELL} ${MKDIRS} $(DESTDIR)$(HELPDIR) ;\
|
||||
( for f in helpfiles/*; do \
|
||||
@@ -707,3 +708,14 @@ suspend.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
|
||||
type.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
|
||||
ulimit.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
|
||||
umask.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
|
||||
|
||||
cd.o: $(topdir)/config-top.h
|
||||
command.o: $(topdir)/config-top.h
|
||||
common.o: $(topdir)/config-top.h
|
||||
declare.o: $(topdir)/config-top.h
|
||||
break.o: $(topdir)/config-top.h
|
||||
echo.o: $(topdir)/config-top.h
|
||||
evalstring.o: $(topdir)/config-top.h
|
||||
exit.o: $(topdir)/config-top.h
|
||||
kill.o: $(topdir)/config-top.h
|
||||
shopt.o: $(topdir)/config-top.h
|
||||
|
||||
+15
-2
@@ -1,6 +1,6 @@
|
||||
/* bashgetopt.c -- `getopt' for use by the builtins. */
|
||||
|
||||
/* Copyright (C) 1992-2002 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1992-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
static int sp;
|
||||
|
||||
char *list_optarg;
|
||||
int list_optflags;
|
||||
int list_optopt;
|
||||
int list_opttype;
|
||||
|
||||
@@ -62,6 +63,7 @@ char *opts;
|
||||
|
||||
if (list == 0) {
|
||||
list_optarg = (char *)NULL;
|
||||
list_optflags = 0;
|
||||
loptend = (WORD_LIST *)NULL; /* No non-option arguments */
|
||||
return -1;
|
||||
}
|
||||
@@ -102,6 +104,7 @@ char *opts;
|
||||
sp = 1;
|
||||
}
|
||||
list_optarg = NULL;
|
||||
list_optflags = 0;
|
||||
if (lcurrent)
|
||||
loptend = lcurrent->next;
|
||||
return('?');
|
||||
@@ -113,6 +116,7 @@ char *opts;
|
||||
/* We allow -l2 as equivalent to -l 2 */
|
||||
if (lcurrent->word->word[sp+1]) {
|
||||
list_optarg = lcurrent->word->word + sp + 1;
|
||||
list_optflags = 0;
|
||||
lcurrent = lcurrent->next;
|
||||
/* If the specifier is `;', don't set optarg if the next
|
||||
argument looks like another option. */
|
||||
@@ -123,15 +127,18 @@ char *opts;
|
||||
#endif
|
||||
lcurrent = lcurrent->next;
|
||||
list_optarg = lcurrent->word->word;
|
||||
list_optflags = lcurrent->word->flags;
|
||||
lcurrent = lcurrent->next;
|
||||
} else if (*cp == ';') {
|
||||
list_optarg = (char *)NULL;
|
||||
list_optflags = 0;
|
||||
lcurrent = lcurrent->next;
|
||||
} else { /* lcurrent->next == NULL */
|
||||
errstr[1] = c;
|
||||
sh_needarg (errstr);
|
||||
sp = 1;
|
||||
list_optarg = (char *)NULL;
|
||||
list_optflags = 0;
|
||||
return('?');
|
||||
}
|
||||
sp = 1;
|
||||
@@ -140,19 +147,24 @@ char *opts;
|
||||
if (lcurrent->word->word[sp+1]) {
|
||||
if (DIGIT(lcurrent->word->word[sp+1])) {
|
||||
list_optarg = lcurrent->word->word + sp + 1;
|
||||
list_optflags = 0;
|
||||
lcurrent = lcurrent->next;
|
||||
} else
|
||||
} else {
|
||||
list_optarg = (char *)NULL;
|
||||
list_optflags = 0;
|
||||
}
|
||||
} else {
|
||||
if (lcurrent->next && legal_number(lcurrent->next->word->word, (intmax_t *)0)) {
|
||||
lcurrent = lcurrent->next;
|
||||
list_optarg = lcurrent->word->word;
|
||||
list_optflags = lcurrent->word->flags;
|
||||
lcurrent = lcurrent->next;
|
||||
} else {
|
||||
errstr[1] = c;
|
||||
sh_neednumarg (errstr);
|
||||
sp = 1;
|
||||
list_optarg = (char *)NULL;
|
||||
list_optflags = 0;
|
||||
return ('?');
|
||||
}
|
||||
}
|
||||
@@ -164,6 +176,7 @@ char *opts;
|
||||
lcurrent = lcurrent->next;
|
||||
}
|
||||
list_optarg = (char *)NULL;
|
||||
list_optflags = 0;
|
||||
}
|
||||
|
||||
return(c);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* bashgetopt.h -- extern declarations for stuff defined in bashgetopt.c. */
|
||||
|
||||
/* Copyright (C) 1993-2020 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1993-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#define GETOPT_HELP -99
|
||||
|
||||
extern char *list_optarg;
|
||||
extern int list_optflags;
|
||||
|
||||
extern int list_optopt;
|
||||
extern int list_opttype;
|
||||
|
||||
+2
-2
@@ -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-2020 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -290,7 +290,7 @@ bind_builtin (list)
|
||||
|
||||
if (nlen < olen) /* fewer bind -x bindings */
|
||||
for (d = olen - nlen, i = 0; i < olen && d > 0; i++)
|
||||
if (nlen == 0 || strvec_search (nbindings, obindings[i]) >= 0)
|
||||
if (nlen == 0 || strvec_search (nbindings, obindings[i]) < 0)
|
||||
{
|
||||
unbind_unix_command (obindings[i]);
|
||||
d--;
|
||||
|
||||
@@ -124,9 +124,7 @@ command_builtin (list)
|
||||
|
||||
#define COMMAND_BUILTIN_FLAGS (CMD_NO_FUNCTIONS | CMD_INHIBIT_EXPANSION | CMD_COMMAND_BUILTIN | (use_standard_path ? CMD_STDPATH : 0))
|
||||
|
||||
#ifdef DEBUG
|
||||
itrace("command_builtin: running execute_command for `%s'", list->word->word);
|
||||
#endif
|
||||
INTERNAL_DEBUG (("command_builtin: running execute_command for `%s'", list->word->word));
|
||||
|
||||
/* 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. */
|
||||
|
||||
+87
-7
@@ -1,6 +1,6 @@
|
||||
/* common.c - utility functions for all builtins */
|
||||
|
||||
/* Copyright (C) 1987-2020 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -266,6 +266,13 @@ sh_readonly (s)
|
||||
builtin_error (_("%s: readonly variable"), s);
|
||||
}
|
||||
|
||||
void
|
||||
sh_noassign (s)
|
||||
const char *s;
|
||||
{
|
||||
internal_error (_("%s: cannot assign"), s); /* XXX */
|
||||
}
|
||||
|
||||
void
|
||||
sh_erange (s, desc)
|
||||
char *s, *desc;
|
||||
@@ -451,7 +458,7 @@ shift_args (times)
|
||||
int
|
||||
number_of_args ()
|
||||
{
|
||||
#ifdef DEBUG
|
||||
#if 0
|
||||
register WORD_LIST *list;
|
||||
int n;
|
||||
|
||||
@@ -462,9 +469,9 @@ number_of_args ()
|
||||
|
||||
if (n != posparam_count)
|
||||
itrace("number_of_args: n (%d) != posparam_count (%d)", n, posparam_count);
|
||||
#endif
|
||||
|
||||
#else
|
||||
return posparam_count;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int changed_dollar_vars;
|
||||
@@ -935,7 +942,7 @@ find_special_builtin (name)
|
||||
current_builtin->function :
|
||||
(sh_builtin_func_t *)NULL);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
shell_builtin_compare (sbp1, sbp2)
|
||||
struct builtin *sbp1, *sbp2;
|
||||
@@ -971,6 +978,7 @@ builtin_help ()
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Assign NAME=VALUE, passing FLAGS to the assignment functions. */
|
||||
SHELL_VAR *
|
||||
builtin_bind_variable (name, value, flags)
|
||||
char *name;
|
||||
@@ -978,12 +986,22 @@ builtin_bind_variable (name, value, flags)
|
||||
int flags;
|
||||
{
|
||||
SHELL_VAR *v;
|
||||
int vflags, bindflags;
|
||||
|
||||
#if defined (ARRAY_VARS)
|
||||
if (valid_array_reference (name, assoc_expand_once ? (VA_NOEXPAND|VA_ONEWORD) : 0) == 0)
|
||||
/* Callers are responsible for calling this with array references that have
|
||||
already undergone valid_array_reference checks (read, printf). */
|
||||
vflags = assoc_expand_once ? (VA_NOEXPAND|VA_ONEWORD) : 0;
|
||||
bindflags = flags | (assoc_expand_once ? ASS_NOEXPAND : 0) | ASS_ALLOWALLSUB;
|
||||
if (flags & ASS_NOEXPAND)
|
||||
vflags |= VA_NOEXPAND;
|
||||
if (flags & ASS_ONEWORD)
|
||||
vflags |= VA_ONEWORD;
|
||||
|
||||
if (valid_array_reference (name, vflags) == 0)
|
||||
v = bind_variable (name, value, flags);
|
||||
else
|
||||
v = assign_array_element (name, value, flags | (assoc_expand_once ? ASS_NOEXPAND : 0));
|
||||
v = assign_array_element (name, value, bindflags, (array_eltstate_t *)0);
|
||||
#else /* !ARRAY_VARS */
|
||||
v = bind_variable (name, value, flags);
|
||||
#endif /* !ARRAY_VARS */
|
||||
@@ -994,6 +1012,18 @@ builtin_bind_variable (name, value, flags)
|
||||
return v;
|
||||
}
|
||||
|
||||
SHELL_VAR *
|
||||
builtin_bind_var_to_int (name, val, flags)
|
||||
char *name;
|
||||
intmax_t val;
|
||||
int flags;
|
||||
{
|
||||
SHELL_VAR *v;
|
||||
|
||||
v = bind_var_to_int (name, val, flags|ASS_ALLOWALLSUB);
|
||||
return v;
|
||||
}
|
||||
|
||||
/* Like check_unbind_variable, but for use by builtins (only matters for
|
||||
error messages). */
|
||||
int
|
||||
@@ -1015,3 +1045,53 @@ builtin_unbind_variable (vname)
|
||||
}
|
||||
return (unbind_variable (vname));
|
||||
}
|
||||
|
||||
int
|
||||
builtin_arrayref_flags (w, baseflags)
|
||||
WORD_DESC *w;
|
||||
int baseflags;
|
||||
{
|
||||
char *t;
|
||||
int vflags;
|
||||
|
||||
vflags = baseflags;
|
||||
|
||||
/* Don't require assoc_expand_once if we have an argument that's already
|
||||
passed through valid_array_reference and been expanded once. That
|
||||
doesn't protect it from normal expansions like word splitting, so
|
||||
proper quoting is still required. */
|
||||
if (w->flags & W_ARRAYREF)
|
||||
vflags |= VA_ONEWORD|VA_NOEXPAND;
|
||||
|
||||
# if 0
|
||||
/* This is a little sketchier but handles quoted arguments. */
|
||||
if (assoc_expand_once && (t = strchr (w->word, '[')) && t[strlen(t) - 1] == ']')
|
||||
vflags |= VA_ONEWORD|VA_NOEXPAND;
|
||||
# endif
|
||||
|
||||
return vflags;
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* External interface to manipulate shell options */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
#if defined (ARRAY_VARS)
|
||||
int
|
||||
set_expand_once (nval, uwp)
|
||||
int nval, uwp;
|
||||
{
|
||||
int oa;
|
||||
|
||||
oa = assoc_expand_once;
|
||||
if (shell_compatibility_level > 51) /* XXX - internal */
|
||||
{
|
||||
if (uwp)
|
||||
unwind_protect_int (assoc_expand_once);
|
||||
assoc_expand_once = nval;
|
||||
}
|
||||
return oa;
|
||||
}
|
||||
#endif
|
||||
|
||||
+36
-7
@@ -1,6 +1,6 @@
|
||||
/* common.h -- extern declarations for functions defined in common.c. */
|
||||
|
||||
/* Copyright (C) 1993-2020 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1993-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -40,7 +40,7 @@ do { \
|
||||
builtin_help (); \
|
||||
return (EX_USAGE)
|
||||
|
||||
/* Flag values for parse_and_execute () */
|
||||
/* Flag values for parse_and_execute () and parse_string () */
|
||||
#define SEVAL_NONINT 0x001
|
||||
#define SEVAL_INTERACT 0x002
|
||||
#define SEVAL_NOHIST 0x004
|
||||
@@ -95,10 +95,11 @@ extern void sh_invalidoptname PARAMS((char *));
|
||||
extern void sh_invalidid PARAMS((char *));
|
||||
extern void sh_invalidnum PARAMS((char *));
|
||||
extern void sh_invalidsig PARAMS((char *));
|
||||
extern void sh_readonly PARAMS((const char *));
|
||||
extern void sh_noassign PARAMS((const char *));
|
||||
extern void sh_erange PARAMS((char *, char *));
|
||||
extern void sh_badpid PARAMS((char *));
|
||||
extern void sh_badjob PARAMS((char *));
|
||||
extern void sh_readonly PARAMS((const char *));
|
||||
extern void sh_nojobs PARAMS((char *));
|
||||
extern void sh_restricted PARAMS((char *));
|
||||
extern void sh_notbuiltin PARAMS((char *));
|
||||
@@ -138,6 +139,10 @@ extern sh_builtin_func_t *builtin_address PARAMS((char *));
|
||||
extern sh_builtin_func_t *find_special_builtin PARAMS((char *));
|
||||
extern void initialize_shell_builtins PARAMS((void));
|
||||
|
||||
#if defined (ARRAY_VARS)
|
||||
extern int set_expand_once PARAMS((int, int));
|
||||
#endif
|
||||
|
||||
/* Functions from exit.def */
|
||||
extern void bash_logout PARAMS((void));
|
||||
|
||||
@@ -151,6 +156,9 @@ extern void builtin_help PARAMS((void));
|
||||
extern void read_tty_cleanup PARAMS((void));
|
||||
extern int read_tty_modified PARAMS((void));
|
||||
|
||||
extern int read_builtin_timeout PARAMS((int));
|
||||
extern void check_read_timeout PARAMS((void));
|
||||
|
||||
/* Functions from set.def */
|
||||
extern int minus_o_option_value PARAMS((char *));
|
||||
extern void list_minus_o_opts PARAMS((int, int));
|
||||
@@ -205,9 +213,10 @@ extern WORD_LIST *get_directory_stack PARAMS((int));
|
||||
extern int parse_and_execute PARAMS((char *, const char *, int));
|
||||
extern int evalstring PARAMS((char *, const char *, int));
|
||||
extern void parse_and_execute_cleanup PARAMS((int));
|
||||
extern int parse_string PARAMS((char *, const char *, int, char **));
|
||||
extern int parse_string PARAMS((char *, const char *, int, COMMAND **, char **));
|
||||
extern int should_suppress_fork PARAMS((COMMAND *));
|
||||
extern int can_optimize_connection PARAMS((COMMAND *));
|
||||
extern int can_optimize_cat_file PARAMS((COMMAND *));
|
||||
extern void optimize_fork PARAMS((COMMAND *));
|
||||
extern void optimize_subshell_command PARAMS((COMMAND *));
|
||||
extern void optimize_shell_function PARAMS((COMMAND *));
|
||||
@@ -223,8 +232,11 @@ extern sh_builtin_func_t *this_shell_builtin;
|
||||
extern sh_builtin_func_t *last_shell_builtin;
|
||||
|
||||
extern SHELL_VAR *builtin_bind_variable PARAMS((char *, char *, int));
|
||||
extern SHELL_VAR *builtin_bind_var_to_int PARAMS((char *, intmax_t, int));
|
||||
extern int builtin_unbind_variable PARAMS((const char *));
|
||||
|
||||
extern int builtin_arrayref_flags PARAMS((WORD_DESC *, int));
|
||||
|
||||
/* variables from evalfile.c */
|
||||
extern int sourcelevel;
|
||||
|
||||
@@ -236,12 +248,14 @@ extern int breaking;
|
||||
extern int continuing;
|
||||
extern int loop_level;
|
||||
|
||||
/* variables from read.def */
|
||||
extern int sigalrm_seen;
|
||||
|
||||
/* variables from shift.def */
|
||||
extern int print_shift_error;
|
||||
|
||||
/* variables from shopt.def */
|
||||
#if defined (ARRAY_VARS)
|
||||
extern int expand_once_flag;
|
||||
#endif
|
||||
|
||||
/* variables from source.def */
|
||||
extern int source_searches_cwd;
|
||||
extern int source_uses_path;
|
||||
@@ -249,4 +263,19 @@ extern int source_uses_path;
|
||||
/* variables from wait.def */
|
||||
extern int wait_intr_flag;
|
||||
|
||||
/* common code to set flags for valid_array_reference and builtin_bind_variable */
|
||||
#if defined (ARRAY_VARS)
|
||||
#define SET_VFLAGS(wordflags, vflags, bindflags) \
|
||||
do { \
|
||||
vflags = assoc_expand_once ? VA_NOEXPAND : 0; \
|
||||
bindflags = assoc_expand_once ? ASS_NOEXPAND : 0; \
|
||||
if (assoc_expand_once && (wordflags & W_ARRAYREF)) \
|
||||
vflags |= VA_ONEWORD|VA_NOEXPAND; \
|
||||
if (vflags & VA_NOEXPAND) \
|
||||
bindflags |= ASS_NOEXPAND; \
|
||||
if (vflags & VA_ONEWORD) \
|
||||
bindflags |= ASS_ONEWORD; \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#endif /* !__COMMON_H */
|
||||
|
||||
+10
-2
@@ -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-2020 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -541,6 +541,8 @@ static void
|
||||
print_cmd_name (cmd)
|
||||
const char *cmd;
|
||||
{
|
||||
char *x;
|
||||
|
||||
if (STREQ (cmd, DEFAULTCMD))
|
||||
printf ("-D");
|
||||
else if (STREQ (cmd, EMPTYCMD))
|
||||
@@ -549,6 +551,12 @@ print_cmd_name (cmd)
|
||||
printf ("-I");
|
||||
else if (*cmd == 0) /* XXX - can this happen? */
|
||||
printf ("''");
|
||||
else if (sh_contains_shell_metas (cmd))
|
||||
{
|
||||
x = sh_single_quote (cmd);
|
||||
printf ("%s", x);
|
||||
free (x);
|
||||
}
|
||||
else
|
||||
printf ("%s", cmd);
|
||||
}
|
||||
@@ -575,7 +583,7 @@ print_one_completion (cmd, cs)
|
||||
print_arg (cs->command, "-C", 1);
|
||||
|
||||
/* simple arguments that don't require quoting */
|
||||
print_arg (cs->funcname, "-F", 0);
|
||||
print_arg (cs->funcname, "-F", sh_contains_shell_metas (cs->funcname) != 0);
|
||||
|
||||
print_cmd_name (cmd);
|
||||
printf ("\n");
|
||||
|
||||
+528
-480
File diff suppressed because it is too large
Load Diff
+44
-10
@@ -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-2020 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -75,6 +75,7 @@ $END
|
||||
#define ENABLED 1
|
||||
#define DISABLED 2
|
||||
#define SPECIAL 4
|
||||
#define SILENT 8 /* affects dyn_load_builtin behavior */
|
||||
|
||||
#define AFLAG 0x01
|
||||
#define DFLAG 0x02
|
||||
@@ -110,6 +111,7 @@ enable_builtin (list)
|
||||
{
|
||||
int result, flags;
|
||||
int opt, filter;
|
||||
WORD_LIST *next;
|
||||
#if defined (HAVE_DLOPEN) && defined (HAVE_DLSYM)
|
||||
char *filename;
|
||||
#endif
|
||||
@@ -178,6 +180,7 @@ enable_builtin (list)
|
||||
filter |= SPECIAL;
|
||||
|
||||
list_some_builtins (filter);
|
||||
result = sh_chkwrite (EXECUTION_SUCCESS);
|
||||
}
|
||||
#if defined (HAVE_DLOPEN) && defined (HAVE_DLSYM)
|
||||
else if (flags & FFLAG)
|
||||
@@ -187,6 +190,8 @@ enable_builtin (list)
|
||||
filter |= SPECIAL;
|
||||
|
||||
result = dyn_load_builtin (list, filter, filename);
|
||||
if (result != EXECUTION_SUCCESS)
|
||||
result = EXECUTION_FAILURE; /* normalize return value */
|
||||
#if defined (PROGRAMMABLE_COMPLETION)
|
||||
set_itemlist_dirty (&it_builtins);
|
||||
#endif
|
||||
@@ -212,13 +217,37 @@ enable_builtin (list)
|
||||
while (list)
|
||||
{
|
||||
opt = enable_shell_command (list->word->word, flags & NFLAG);
|
||||
next = list->next;
|
||||
|
||||
if (opt == EXECUTION_FAILURE)
|
||||
#if defined (HAVE_DLOPEN) && defined (HAVE_DLSYM)
|
||||
/* If we try to enable a non-existent builtin, and we have dynamic
|
||||
loading, try the equivalent of `enable -f name name'. */
|
||||
if (opt == EX_NOTFOUND)
|
||||
{
|
||||
int dflags, r;
|
||||
|
||||
dflags = ENABLED|SILENT|((flags & SFLAG) ? SPECIAL : 0);
|
||||
|
||||
list->next = 0;
|
||||
r = dyn_load_builtin (list, dflags, list->word->word);
|
||||
list->next = next;
|
||||
if (r == EXECUTION_SUCCESS)
|
||||
opt = r;
|
||||
#if defined (PROGRAMMABLE_COMPLETION)
|
||||
set_itemlist_dirty (&it_builtins);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
if (opt == EX_NOTFOUND)
|
||||
{
|
||||
sh_notbuiltin (list->word->word);
|
||||
result = EXECUTION_FAILURE;
|
||||
}
|
||||
list = list->next;
|
||||
else if (opt != EXECUTION_SUCCESS)
|
||||
result = EXECUTION_FAILURE;
|
||||
|
||||
list = next;
|
||||
}
|
||||
}
|
||||
return (result);
|
||||
@@ -260,7 +289,7 @@ enable_shell_command (name, disable_p)
|
||||
|
||||
b = builtin_address_internal (name, 1);
|
||||
if (b == 0)
|
||||
return (EXECUTION_FAILURE);
|
||||
return (EX_NOTFOUND);
|
||||
|
||||
if (disable_p)
|
||||
b->flags &= ~BUILTIN_ENABLED;
|
||||
@@ -339,11 +368,16 @@ dyn_load_builtin (list, flags, filename)
|
||||
|
||||
if (handle == 0)
|
||||
{
|
||||
name = printable_filename (filename, 0);
|
||||
builtin_error (_("cannot open shared object %s: %s"), name, dlerror ());
|
||||
if (name != filename)
|
||||
free (name);
|
||||
return (EXECUTION_FAILURE);
|
||||
/* If we've been told to be quiet, don't complain about not finding the
|
||||
specified shared object. */
|
||||
if ((flags & SILENT) == 0)
|
||||
{
|
||||
name = printable_filename (filename, 0);
|
||||
builtin_error (_("cannot open shared object %s: %s"), name, dlerror ());
|
||||
if (name != filename)
|
||||
free (name);
|
||||
}
|
||||
return (EX_NOTFOUND);
|
||||
}
|
||||
|
||||
for (new = 0, l = list; l; l = l->next, new++)
|
||||
@@ -369,7 +403,7 @@ dyn_load_builtin (list, flags, filename)
|
||||
{
|
||||
name = printable_filename (filename, 0);
|
||||
builtin_error (_("cannot find %s in shared object %s: %s"),
|
||||
struct_name, name, dlerror ());
|
||||
struct_name, name, dlerror ());
|
||||
if (name != filename)
|
||||
free (name);
|
||||
free (struct_name);
|
||||
|
||||
+73
-26
@@ -1,6 +1,6 @@
|
||||
/* evalstring.c - evaluate a string as one or more shell commands. */
|
||||
|
||||
/* Copyright (C) 1996-2020 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1996-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -88,24 +88,18 @@ int
|
||||
should_suppress_fork (command)
|
||||
COMMAND *command;
|
||||
{
|
||||
#if 0 /* TAG: bash-5.2 */
|
||||
int subshell;
|
||||
|
||||
subshell = subshell_environment & SUBSHELL_PROCSUB; /* salt to taste */
|
||||
#endif
|
||||
return (startup_state == 2 && parse_and_execute_level == 1 &&
|
||||
running_trap == 0 &&
|
||||
*bash_input.location.string == '\0' &&
|
||||
parser_expanding_alias () == 0 &&
|
||||
running_trap == 0 &&
|
||||
command->type == cm_simple &&
|
||||
signal_is_trapped (EXIT_TRAP) == 0 &&
|
||||
signal_is_trapped (ERROR_TRAP) == 0 &&
|
||||
any_signals_trapped () < 0 &&
|
||||
#if 0 /* TAG: bash-5.2 */
|
||||
(subshell || (command->redirects == 0 && command->value.Simple->redirects == 0)) &&
|
||||
#else
|
||||
command->redirects == 0 && command->value.Simple->redirects == 0 &&
|
||||
#endif
|
||||
((command->flags & CMD_TIME_PIPELINE) == 0) &&
|
||||
((command->flags & CMD_INVERT_RETURN) == 0));
|
||||
}
|
||||
@@ -175,6 +169,19 @@ optimize_shell_function (command)
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
can_optimize_cat_file (command)
|
||||
COMMAND *command;
|
||||
{
|
||||
return (command->type == cm_simple && !command->redirects &&
|
||||
(command->flags & CMD_TIME_PIPELINE) == 0 &&
|
||||
command->value.Simple->words == 0 &&
|
||||
command->value.Simple->redirects &&
|
||||
command->value.Simple->redirects->next == 0 &&
|
||||
command->value.Simple->redirects->instruction == r_input_direction &&
|
||||
command->value.Simple->redirects->redirector.dest == 0);
|
||||
}
|
||||
|
||||
/* How to force parse_and_execute () to clean up after itself. */
|
||||
void
|
||||
parse_and_execute_cleanup (old_running_trap)
|
||||
@@ -364,6 +371,25 @@ parse_and_execute (string, from_file, flags)
|
||||
should_jump_to_top_level = 1;
|
||||
goto out;
|
||||
|
||||
case EXITBLTIN:
|
||||
if (command)
|
||||
{
|
||||
if (variable_context && signal_is_trapped (0))
|
||||
{
|
||||
/* Let's make sure we run the exit trap in the function
|
||||
context, as we do when not running parse_and_execute.
|
||||
The pe_dispose unwind frame comes before any unwind-
|
||||
protects installed by the string we're evaluating, so
|
||||
it will undo the current function scope. */
|
||||
dispose_command (command);
|
||||
discard_unwind_frame ("pe_dispose");
|
||||
}
|
||||
else
|
||||
run_unwind_frame ("pe_dispose");
|
||||
}
|
||||
should_jump_to_top_level = 1;
|
||||
goto out;
|
||||
|
||||
case DISCARD:
|
||||
if (command)
|
||||
run_unwind_frame ("pe_dispose");
|
||||
@@ -473,13 +499,7 @@ parse_and_execute (string, from_file, flags)
|
||||
if (startup_state == 2 &&
|
||||
(subshell_environment & SUBSHELL_COMSUB) &&
|
||||
*bash_input.location.string == '\0' &&
|
||||
command->type == cm_simple && !command->redirects &&
|
||||
(command->flags & CMD_TIME_PIPELINE) == 0 &&
|
||||
command->value.Simple->words == 0 &&
|
||||
command->value.Simple->redirects &&
|
||||
command->value.Simple->redirects->next == 0 &&
|
||||
command->value.Simple->redirects->instruction == r_input_direction &&
|
||||
command->value.Simple->redirects->redirector.dest == 0)
|
||||
can_optimize_cat_file (command))
|
||||
{
|
||||
int r;
|
||||
r = cat_file (command->value.Simple->redirects);
|
||||
@@ -543,10 +563,11 @@ parse_and_execute (string, from_file, flags)
|
||||
command substitutions during parsing to obey Posix rules about finding
|
||||
the end of the command and balancing parens. */
|
||||
int
|
||||
parse_string (string, from_file, flags, endp)
|
||||
parse_string (string, from_file, flags, cmdp, endp)
|
||||
char *string;
|
||||
const char *from_file;
|
||||
int flags;
|
||||
COMMAND **cmdp;
|
||||
char **endp;
|
||||
{
|
||||
int code, nc;
|
||||
@@ -575,9 +596,9 @@ parse_string (string, from_file, flags, endp)
|
||||
|
||||
code = should_jump_to_top_level = 0;
|
||||
oglobal = global_command;
|
||||
ostring = string;
|
||||
|
||||
with_input_from_string (string, from_file);
|
||||
ostring = bash_input.location.string;
|
||||
while (*(bash_input.location.string)) /* XXX - parser_expanding_alias () ? */
|
||||
{
|
||||
command = (COMMAND *)NULL;
|
||||
@@ -593,15 +614,15 @@ parse_string (string, from_file, flags, endp)
|
||||
|
||||
if (code)
|
||||
{
|
||||
#if defined (DEBUG)
|
||||
itrace("parse_string: longjmp executed: code = %d", code);
|
||||
#endif
|
||||
INTERNAL_DEBUG(("parse_string: longjmp executed: code = %d", code));
|
||||
|
||||
should_jump_to_top_level = 0;
|
||||
switch (code)
|
||||
{
|
||||
case FORCE_EOF:
|
||||
case ERREXIT:
|
||||
case EXITPROG:
|
||||
case EXITBLTIN:
|
||||
case DISCARD: /* XXX */
|
||||
if (command)
|
||||
dispose_command (command);
|
||||
@@ -621,7 +642,10 @@ itrace("parse_string: longjmp executed: code = %d", code);
|
||||
|
||||
if (parse_command () == 0)
|
||||
{
|
||||
dispose_command (global_command);
|
||||
if (cmdp)
|
||||
*cmdp = global_command;
|
||||
else
|
||||
dispose_command (global_command);
|
||||
global_command = (COMMAND *)NULL;
|
||||
}
|
||||
else
|
||||
@@ -637,7 +661,11 @@ itrace("parse_string: longjmp executed: code = %d", code);
|
||||
}
|
||||
|
||||
if (current_token == yacc_EOF || current_token == shell_eof_token)
|
||||
{
|
||||
if (current_token == shell_eof_token)
|
||||
rewind_input_string ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
@@ -663,12 +691,10 @@ out:
|
||||
return (nc);
|
||||
}
|
||||
|
||||
/* Handle a $( < file ) command substitution. This expands the filename,
|
||||
returning errors as appropriate, then just cats the file to the standard
|
||||
output. */
|
||||
static int
|
||||
cat_file (r)
|
||||
int
|
||||
open_redir_file (r, fnp)
|
||||
REDIRECT *r;
|
||||
char **fnp;
|
||||
{
|
||||
char *fn;
|
||||
int fd, rval;
|
||||
@@ -694,9 +720,30 @@ cat_file (r)
|
||||
{
|
||||
file_error (fn);
|
||||
free (fn);
|
||||
if (fnp)
|
||||
*fnp = 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (fnp)
|
||||
*fnp = fn;
|
||||
return fd;
|
||||
}
|
||||
|
||||
/* Handle a $( < file ) command substitution. This expands the filename,
|
||||
returning errors as appropriate, then just cats the file to the standard
|
||||
output. */
|
||||
static int
|
||||
cat_file (r)
|
||||
REDIRECT *r;
|
||||
{
|
||||
char *fn;
|
||||
int fd, rval;
|
||||
|
||||
fd = open_redir_file (r, &fn);
|
||||
if (fd < 0)
|
||||
return -1;
|
||||
|
||||
rval = zcatfd (fd, 1, fn);
|
||||
|
||||
free (fn);
|
||||
|
||||
+7
-4
@@ -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-2019 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -215,7 +215,7 @@ exec_builtin (list)
|
||||
maybe_save_shell_history ();
|
||||
#endif /* HISTORY */
|
||||
|
||||
restore_original_signals ();
|
||||
reset_signal_handlers (); /* leave trap strings in place */
|
||||
|
||||
#if defined (JOB_CONTROL)
|
||||
orig_job_control = job_control; /* XXX - was also interactive_shell */
|
||||
@@ -253,7 +253,7 @@ failed_exec:
|
||||
FREE (command);
|
||||
|
||||
if (subshell_environment || (interactive == 0 && no_exit_on_failed_exec == 0))
|
||||
exit_shell (exit_value);
|
||||
exit_shell (last_command_exit_value = exit_value);
|
||||
|
||||
if (args)
|
||||
strvec_dispose (args);
|
||||
@@ -261,8 +261,11 @@ failed_exec:
|
||||
if (env && env != export_env)
|
||||
strvec_dispose (env);
|
||||
|
||||
initialize_traps ();
|
||||
/* If we're not exiting after the exec fails, we restore the shell signal
|
||||
handlers and then modify the signal dispositions based on the trap strings
|
||||
before the failed exec. */
|
||||
initialize_signals (1);
|
||||
restore_traps ();
|
||||
|
||||
#if defined (JOB_CONTROL)
|
||||
if (orig_job_control)
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
This file is exit.def, from which is created exit.c.
|
||||
It implements the builtins "exit", and "logout" in Bash.
|
||||
|
||||
Copyright (C) 1987-2020 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -151,7 +151,7 @@ exit_or_logout (list)
|
||||
last_command_exit_value = exit_value;
|
||||
|
||||
/* Exit the program. */
|
||||
jump_to_top_level (EXITPROG);
|
||||
jump_to_top_level (EXITBLTIN);
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
|
||||
+5
-2
@@ -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-2020 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -450,6 +450,8 @@ fc_builtin (list)
|
||||
for (i = reverse ? histend : histbeg; reverse ? i >= histbeg : i <= histend; reverse ? i-- : i++)
|
||||
{
|
||||
QUIT;
|
||||
if (hlist[i] == 0)
|
||||
continue;
|
||||
if (numbering)
|
||||
fprintf (stream, "%d", i + history_base);
|
||||
if (listing)
|
||||
@@ -459,7 +461,8 @@ fc_builtin (list)
|
||||
else
|
||||
fprintf (stream, "\t%c", histdata (i) ? '*' : ' ');
|
||||
}
|
||||
fprintf (stream, "%s\n", histline (i));
|
||||
if (histline (i))
|
||||
fprintf (stream, "%s\n", histline (i));
|
||||
}
|
||||
|
||||
if (listing)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* gen-helpfiles - create files containing builtin help text */
|
||||
|
||||
/* Copyright (C) 2012-2020 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 2012-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -64,6 +64,7 @@
|
||||
#undef xrealloc
|
||||
#undef xfree
|
||||
|
||||
#undef malloc
|
||||
#undef free /* defined in xmalloc.h */
|
||||
#endif
|
||||
|
||||
|
||||
+2
-2
@@ -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-2020 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -138,7 +138,7 @@ hash_builtin (list)
|
||||
(list_portably == 0 || shell_compatibility_level <= 50))
|
||||
printf (_("%s: hash table empty\n"), this_command_name);
|
||||
|
||||
return (EXECUTION_SUCCESS);
|
||||
return (sh_chkwrite (EXECUTION_SUCCESS));
|
||||
}
|
||||
|
||||
if (expunge_hash_table)
|
||||
|
||||
+2
-3
@@ -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-2020 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -186,8 +186,7 @@ help_builtin (list)
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
fflush (stdout);
|
||||
return (EXECUTION_SUCCESS);
|
||||
return (sh_chkwrite (EXECUTION_SUCCESS));
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
+22
-24
@@ -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-2020 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -100,6 +100,10 @@ static int expand_and_print_history PARAMS((WORD_LIST *));
|
||||
#define CFLAG 0x40
|
||||
#define DFLAG 0x80
|
||||
|
||||
#ifndef TIMELEN_MAX
|
||||
# define TIMELEN_MAX 128
|
||||
#endif
|
||||
|
||||
int
|
||||
history_builtin (list)
|
||||
WORD_LIST *list;
|
||||
@@ -189,35 +193,29 @@ history_builtin (list)
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
if (delete_arg[0] == '-' && delete_start < 0)
|
||||
{
|
||||
/* the_history[history_length] == 0x0, so this is correct */
|
||||
delete_start += history_length;
|
||||
if (delete_start < history_base)
|
||||
{
|
||||
start_error:
|
||||
sh_erange (delete_arg, _("history position"));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
}
|
||||
/* the_history[history_length] == 0x0, so this is correct */
|
||||
delete_start += history_length;
|
||||
/* numbers as displayed by display_history are offset by history_base */
|
||||
else if (delete_start > 0)
|
||||
delete_start -= history_base;
|
||||
|
||||
if (delete_start < 0 || delete_start >= history_length)
|
||||
goto start_error;
|
||||
{
|
||||
sh_erange (delete_arg, _("history position"));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
if (range[0] == '-' && delete_end < 0)
|
||||
{
|
||||
delete_end += history_length;
|
||||
if (delete_end < history_base)
|
||||
{
|
||||
range_error:
|
||||
sh_erange (range, _("history position"));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
}
|
||||
delete_end += history_length;
|
||||
else if (delete_end > 0)
|
||||
delete_end -= history_base;
|
||||
|
||||
if (delete_end < 0 || delete_end >= history_length)
|
||||
goto range_error;
|
||||
{
|
||||
sh_erange (range, _("history position"));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
/* XXX - print error if end < start? */
|
||||
result = bash_delete_history_range (delete_start, delete_end);
|
||||
if (where_history () > history_length)
|
||||
history_set_pos (history_length);
|
||||
@@ -237,7 +235,7 @@ range_error:
|
||||
that history -d -1 will delete the last history entry, which at
|
||||
this point is the history -d -1 we just added. */
|
||||
ind = history_length + delete_offset;
|
||||
if (ind < history_base)
|
||||
if (ind < 0) /* offset by history_base below */
|
||||
{
|
||||
sh_erange (delete_arg, _("history position"));
|
||||
return (EXECUTION_FAILURE);
|
||||
@@ -328,7 +326,7 @@ histtime (hlist, histtimefmt)
|
||||
HIST_ENTRY *hlist;
|
||||
const char *histtimefmt;
|
||||
{
|
||||
static char timestr[128];
|
||||
static char timestr[TIMELEN_MAX];
|
||||
time_t t;
|
||||
struct tm *tm;
|
||||
|
||||
|
||||
+14
-9
@@ -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-2020 Free Software Foundation, Inc.
|
||||
Copyright (C) 2008-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -68,6 +68,7 @@ $END
|
||||
#include <config.h>
|
||||
|
||||
#include "builtins.h"
|
||||
#include "../bashtypes.h"
|
||||
#include "posixstat.h"
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
@@ -140,7 +141,7 @@ do_chop(line, delim)
|
||||
int length;
|
||||
|
||||
length = strlen (line);
|
||||
if (length && line[length-1] == delim)
|
||||
if (length && (unsigned char)line[length-1] == delim)
|
||||
line[length-1] = '\0';
|
||||
}
|
||||
|
||||
@@ -156,6 +157,7 @@ mapfile (fd, line_count_goal, origin, nskip, callback_quantum, callback, array_n
|
||||
size_t line_length;
|
||||
unsigned int array_index, line_count;
|
||||
SHELL_VAR *entry;
|
||||
struct stat sb;
|
||||
int unbuffered_read;
|
||||
|
||||
line = NULL;
|
||||
@@ -180,19 +182,22 @@ mapfile (fd, line_count_goal, origin, nskip, callback_quantum, callback, array_n
|
||||
}
|
||||
else if (invisible_p (entry))
|
||||
VUNSETATTR (entry, att_invisible); /* no longer invisible */
|
||||
|
||||
|
||||
if (flags & MAPF_CLEARARRAY)
|
||||
array_flush (array_cell (entry));
|
||||
|
||||
#ifndef __CYGWIN__
|
||||
unbuffered_read = (lseek (fd, 0L, SEEK_CUR) < 0) && (errno == ESPIPE);
|
||||
/* If the delimiter is a newline, turn on unbuffered reads for pipes
|
||||
(terminals are ok). If the delimiter is not a newline, unbuffered reads
|
||||
for every file descriptor that's not a regular file. */
|
||||
if (delim == '\n')
|
||||
unbuffered_read = (lseek (fd, 0L, SEEK_CUR) < 0) && (errno == ESPIPE);
|
||||
else
|
||||
unbuffered_read = (fstat (fd, &sb) != 0) || (S_ISREG (sb.st_mode) == 0);
|
||||
#else
|
||||
unbuffered_read = 1;
|
||||
#endif
|
||||
|
||||
if (delim != '\n')
|
||||
unbuffered_read = 1;
|
||||
|
||||
zreset ();
|
||||
|
||||
/* Skip any lines at beginning of file? */
|
||||
@@ -215,11 +220,11 @@ mapfile (fd, line_count_goal, origin, nskip, callback_quantum, callback, array_n
|
||||
/* Has a callback been registered and if so is it time to call it? */
|
||||
if (callback && line_count && (line_count % callback_quantum) == 0)
|
||||
{
|
||||
run_callback (callback, array_index, line);
|
||||
|
||||
/* Reset the buffer for bash own stream. */
|
||||
if (unbuffered_read == 0)
|
||||
zsyncfd (fd);
|
||||
|
||||
run_callback (callback, array_index, line);
|
||||
}
|
||||
|
||||
/* XXX - bad things can happen if the callback modifies ENTRY, e.g.,
|
||||
|
||||
+26
-4
@@ -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-2020 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -72,7 +72,8 @@ extern char *strcpy ();
|
||||
#define BUILTIN_FLAG_SPECIAL 0x01
|
||||
#define BUILTIN_FLAG_ASSIGNMENT 0x02
|
||||
#define BUILTIN_FLAG_LOCALVAR 0x04
|
||||
#define BUILTIN_FLAG_POSIX_BUILTIN 0x08
|
||||
#define BUILTIN_FLAG_POSIX_BUILTIN 0x08
|
||||
#define BUILTIN_FLAG_ARRAYREF_ARG 0x10
|
||||
|
||||
#define BASE_INDENT 4
|
||||
|
||||
@@ -173,11 +174,22 @@ char *posix_builtins[] =
|
||||
(char *)NULL
|
||||
};
|
||||
|
||||
/* The builtin commands that can take array references as arguments and pay
|
||||
attention to `assoc_expand_once'. These are the ones that don't assign
|
||||
values, but need to avoid double expansions. */
|
||||
char *arrayvar_builtins[] =
|
||||
{
|
||||
"declare", "let", "local", "printf", "read", "test", "[",
|
||||
"typeset", "unset", "wait", /*]*/
|
||||
(char *)NULL
|
||||
};
|
||||
|
||||
/* Forward declarations. */
|
||||
static int is_special_builtin ();
|
||||
static int is_assignment_builtin ();
|
||||
static int is_localvar_builtin ();
|
||||
static int is_posix_builtin ();
|
||||
static int is_arrayvar_builtin ();
|
||||
|
||||
#if !defined (HAVE_RENAME)
|
||||
static int rename ();
|
||||
@@ -831,6 +843,8 @@ builtin_handler (self, defs, arg)
|
||||
new->flags |= BUILTIN_FLAG_LOCALVAR;
|
||||
if (is_posix_builtin (name))
|
||||
new->flags |= BUILTIN_FLAG_POSIX_BUILTIN;
|
||||
if (is_arrayvar_builtin (name))
|
||||
new->flags |= BUILTIN_FLAG_ARRAYREF_ARG;
|
||||
|
||||
array_add ((char *)new, defs->builtins);
|
||||
building_builtin = 1;
|
||||
@@ -1111,7 +1125,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-2015 Free Software Foundation, Inc.",
|
||||
"/* Copyright (C) 1987-2021 Free Software Foundation, Inc.",
|
||||
"",
|
||||
" This file is part of GNU Bash, the Bourne Again SHell.",
|
||||
"",
|
||||
@@ -1250,12 +1264,13 @@ write_builtins (defs, structfile, externfile)
|
||||
else
|
||||
fprintf (structfile, "(sh_builtin_func_t *)0x0, ");
|
||||
|
||||
fprintf (structfile, "%s%s%s%s%s, %s_doc,\n",
|
||||
fprintf (structfile, "%s%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" : "",
|
||||
(builtin->flags & BUILTIN_FLAG_ARRAYREF_ARG) ? " | ARRAYREF_BUILTIN" : "",
|
||||
document_name (builtin));
|
||||
|
||||
/* Don't translate short document summaries that are identical
|
||||
@@ -1645,6 +1660,13 @@ is_posix_builtin (name)
|
||||
return (_find_in_table (name, posix_builtins));
|
||||
}
|
||||
|
||||
static int
|
||||
is_arrayvar_builtin (name)
|
||||
char *name;
|
||||
{
|
||||
return (_find_in_table (name, arrayvar_builtins));
|
||||
}
|
||||
|
||||
#if !defined (HAVE_RENAME)
|
||||
static int
|
||||
rename (from, to)
|
||||
|
||||
+46
-12
@@ -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-2020 Free Software Foundation, Inc.
|
||||
Copyright (C) 1997-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -40,6 +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
|
||||
%Q like %q, but apply any precision to the unquoted argument before
|
||||
quoting
|
||||
%(fmt)T output the date-time string resulting from using FMT as a format
|
||||
string for strftime(3)
|
||||
|
||||
@@ -149,7 +151,7 @@ extern int errno;
|
||||
if (vflag) \
|
||||
{ \
|
||||
SHELL_VAR *v; \
|
||||
v = builtin_bind_variable (vname, vbuf, 0); \
|
||||
v = builtin_bind_variable (vname, vbuf, bindflags); \
|
||||
stupidly_hack_special_variables (vname); \
|
||||
if (v == 0 || readonly_p (v) || noassign_p (v)) \
|
||||
return (EXECUTION_FAILURE); \
|
||||
@@ -184,6 +186,10 @@ extern int errno;
|
||||
#define SKIP1 "#'-+ 0"
|
||||
#define LENMODS "hjlLtz"
|
||||
|
||||
#ifndef TIMELEN_MAX
|
||||
# define TIMELEN_MAX 128
|
||||
#endif
|
||||
|
||||
extern time_t shell_start_time;
|
||||
|
||||
#if !HAVE_ASPRINTF
|
||||
@@ -226,6 +232,7 @@ static int conversion_error;
|
||||
|
||||
/* printf -v var support */
|
||||
static int vflag = 0;
|
||||
static int bindflags = 0;
|
||||
static char *vbuf, *vname;
|
||||
static size_t vbsize;
|
||||
static int vblen;
|
||||
@@ -241,7 +248,7 @@ printf_builtin (list)
|
||||
{
|
||||
int ch, fieldwidth, precision;
|
||||
int have_fieldwidth, have_precision;
|
||||
char convch, thisch, nextch, *format, *modstart, *fmt, *start;
|
||||
char convch, thisch, nextch, *format, *modstart, *precstart, *fmt, *start;
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
char mbch[25]; /* 25 > MB_LEN_MAX, plus can handle 4-byte UTF-8 and large Unicode characters*/
|
||||
int mbind, mblen;
|
||||
@@ -251,8 +258,6 @@ printf_builtin (list)
|
||||
#endif
|
||||
|
||||
conversion_error = 0;
|
||||
retval = EXECUTION_SUCCESS;
|
||||
|
||||
vflag = 0;
|
||||
|
||||
reset_internal_getopt ();
|
||||
@@ -262,12 +267,14 @@ printf_builtin (list)
|
||||
{
|
||||
case 'v':
|
||||
vname = list_optarg;
|
||||
bindflags = 0;
|
||||
#if defined (ARRAY_VARS)
|
||||
arrayflags = assoc_expand_once ? (VA_NOEXPAND|VA_ONEWORD) : 0;
|
||||
if (legal_identifier (vname) || valid_array_reference (vname, arrayflags))
|
||||
SET_VFLAGS (list_optflags, arrayflags, bindflags);
|
||||
retval = legal_identifier (vname) || valid_array_reference (vname, arrayflags);
|
||||
#else
|
||||
if (legal_identifier (vname))
|
||||
retval = legal_identifier (vname);
|
||||
#endif
|
||||
if (retval)
|
||||
{
|
||||
vflag = 1;
|
||||
if (vbsize == 0)
|
||||
@@ -310,6 +317,7 @@ printf_builtin (list)
|
||||
|
||||
format = list->word->word;
|
||||
tw = 0;
|
||||
retval = EXECUTION_SUCCESS;
|
||||
|
||||
garglist = orig_arglist = list->next;
|
||||
|
||||
@@ -331,6 +339,7 @@ printf_builtin (list)
|
||||
{
|
||||
precision = fieldwidth = 0;
|
||||
have_fieldwidth = have_precision = 0;
|
||||
precstart = 0;
|
||||
|
||||
if (*fmt == '\\')
|
||||
{
|
||||
@@ -404,6 +413,8 @@ printf_builtin (list)
|
||||
if (*fmt == '-')
|
||||
#endif
|
||||
fmt++;
|
||||
if (DIGIT (*fmt))
|
||||
precstart = fmt;
|
||||
while (DIGIT (*fmt))
|
||||
fmt++;
|
||||
}
|
||||
@@ -449,7 +460,7 @@ printf_builtin (list)
|
||||
|
||||
case '(':
|
||||
{
|
||||
char *timefmt, timebuf[128], *t;
|
||||
char *timefmt, timebuf[TIMELEN_MAX], *t;
|
||||
int n;
|
||||
intmax_t arg;
|
||||
time_t secs;
|
||||
@@ -531,7 +542,7 @@ printf_builtin (list)
|
||||
if (var && *var)
|
||||
{
|
||||
if (legal_identifier (var))
|
||||
bind_var_to_int (var, tw);
|
||||
bind_var_to_int (var, tw, 0);
|
||||
else
|
||||
{
|
||||
sh_invalidid (var);
|
||||
@@ -573,12 +584,27 @@ printf_builtin (list)
|
||||
}
|
||||
|
||||
case 'q': /* print with shell quoting */
|
||||
case 'Q':
|
||||
{
|
||||
char *p, *xp;
|
||||
int r;
|
||||
int r, mpr;
|
||||
size_t slen;
|
||||
|
||||
r = 0;
|
||||
p = getstr ();
|
||||
/* Decode precision and apply it to the unquoted string. */
|
||||
if (convch == 'Q' && precstart)
|
||||
{
|
||||
mpr = *precstart++ - '0';
|
||||
while (DIGIT (*precstart))
|
||||
mpr = (mpr * 10) + (*precstart++ - '0');
|
||||
/* Error if precision > INT_MAX here? */
|
||||
precision = (mpr < 0 || mpr > INT_MAX) ? INT_MAX : mpr;
|
||||
slen = strlen (p);
|
||||
/* printf precision works in bytes. */
|
||||
if (precision < slen)
|
||||
p[precision] = '\0';
|
||||
}
|
||||
if (p && *p == 0) /* XXX - getstr never returns null */
|
||||
xp = savestring ("''");
|
||||
else if (ansic_shouldquote (p))
|
||||
@@ -587,6 +613,12 @@ printf_builtin (list)
|
||||
xp = sh_backslash_quote (p, 0, 3);
|
||||
if (xp)
|
||||
{
|
||||
if (convch == 'Q')
|
||||
{
|
||||
slen = strlen (xp);
|
||||
if (slen > precision)
|
||||
precision = slen;
|
||||
}
|
||||
/* Use printstr to get fieldwidth and precision right. */
|
||||
r = printstr (start, xp, strlen (xp), fieldwidth, precision);
|
||||
if (r < 0)
|
||||
@@ -760,7 +792,7 @@ printstr (fmt, string, len, fieldwidth, precision)
|
||||
fw = (mfw < 0 || mfw > INT_MAX) ? INT_MAX : mfw;
|
||||
}
|
||||
|
||||
/* get precision, if present */
|
||||
/* get precision, if present. doesn't handle negative precisions */
|
||||
if (*fmt == '.')
|
||||
{
|
||||
fmt++;
|
||||
@@ -776,6 +808,8 @@ printstr (fmt, string, len, fieldwidth, precision)
|
||||
mpr = (mpr * 10) + (*fmt++ - '0');
|
||||
/* Error if precision > INT_MAX here? */
|
||||
pr = (mpr < 0 || mpr > INT_MAX) ? INT_MAX : mpr;
|
||||
if (pr < precision && precision < INT_MAX)
|
||||
pr = precision; /* XXX */
|
||||
}
|
||||
else
|
||||
pr = 0; /* "a null digit string is treated as zero" */
|
||||
|
||||
+133
-39
@@ -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-2020 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -30,7 +30,8 @@ if the -u option is supplied. The line is split into fields as with word
|
||||
splitting, and the first word is assigned to the first NAME, the second
|
||||
word to the second NAME, and so on, with any leftover words assigned to
|
||||
the last NAME. Only the characters found in $IFS are recognized as word
|
||||
delimiters.
|
||||
delimiters. By default, the backslash character escapes delimiter characters
|
||||
and newline.
|
||||
|
||||
If no NAMEs are supplied, the line read is stored in the REPLY variable.
|
||||
|
||||
@@ -107,6 +108,7 @@ $END
|
||||
#endif
|
||||
|
||||
#include "shmbutil.h"
|
||||
#include "timer.h"
|
||||
|
||||
#if !defined(errno)
|
||||
extern int errno;
|
||||
@@ -124,19 +126,19 @@ static int set_itext PARAMS((void));
|
||||
static char *edit_line PARAMS((char *, char *));
|
||||
static void set_eol_delim PARAMS((int));
|
||||
static void reset_eol_delim PARAMS((char *));
|
||||
static void set_readline_timeout PARAMS((sh_timer *t, time_t, long));
|
||||
#endif
|
||||
static SHELL_VAR *bind_read_variable PARAMS((char *, char *));
|
||||
static SHELL_VAR *bind_read_variable PARAMS((char *, char *, int));
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
static int read_mbchar PARAMS((int, char *, int, int, int));
|
||||
#endif
|
||||
static void ttyrestore PARAMS((struct ttsave *));
|
||||
|
||||
static sighandler sigalrm PARAMS((int));
|
||||
static void reset_alarm PARAMS((void));
|
||||
static void reset_timeout PARAMS((void));
|
||||
|
||||
/* Try this to see what the rest of the shell can do with the information. */
|
||||
procenv_t alrmbuf;
|
||||
int sigalrm_seen;
|
||||
sh_timer *read_timeout;
|
||||
|
||||
static int reading, tty_modified;
|
||||
static SigHandler *old_alrm;
|
||||
@@ -148,21 +150,44 @@ static struct ttsave termsave;
|
||||
avoids problems with the semi-tricky stuff we do with the xfree of
|
||||
input_string at the top of the unwind-protect list (see below). */
|
||||
|
||||
/* Set a flag that CHECK_ALRM can check. This relies on zread or read_builtin
|
||||
calling trap.c:check_signals(), which knows about sigalrm_seen and alrmbuf. */
|
||||
/* Set a flag that check_read_timeout can check. This relies on zread or
|
||||
read_builtin calling trap.c:check_signals() (which calls check_read_timeout()) */
|
||||
static sighandler
|
||||
sigalrm (s)
|
||||
int s;
|
||||
{
|
||||
sigalrm_seen = 1;
|
||||
/* Display warning if this is called without read_timeout set? */
|
||||
if (read_timeout)
|
||||
read_timeout->alrmflag = 1;
|
||||
}
|
||||
|
||||
static void
|
||||
reset_alarm ()
|
||||
reset_timeout ()
|
||||
{
|
||||
/* Cancel alarm before restoring signal handler. */
|
||||
falarm (0, 0);
|
||||
set_signal_handler (SIGALRM, old_alrm);
|
||||
if (read_timeout)
|
||||
shtimer_clear (read_timeout);
|
||||
read_timeout = 0;
|
||||
}
|
||||
|
||||
void
|
||||
check_read_timeout ()
|
||||
{
|
||||
if (read_timeout && shtimer_chktimeout (read_timeout))
|
||||
sh_longjmp (read_timeout->jmpenv, 1);
|
||||
}
|
||||
|
||||
int
|
||||
read_builtin_timeout (fd)
|
||||
int fd;
|
||||
{
|
||||
if ((read_timeout == 0) ||
|
||||
(read_timeout->fd != fd) ||
|
||||
(read_timeout->tmout.tv_sec == 0 && read_timeout->tmout.tv_usec == 0))
|
||||
return 0;
|
||||
|
||||
return ((read_timeout->flags & SHTIMER_ALARM) ? shtimer_alrm (read_timeout)
|
||||
: shtimer_select (read_timeout));
|
||||
}
|
||||
|
||||
/* Read the value of the shell variables whose names follow.
|
||||
@@ -191,10 +216,12 @@ read_builtin (list)
|
||||
struct stat tsb;
|
||||
SHELL_VAR *var;
|
||||
TTYSTRUCT ttattrs, ttset;
|
||||
sigset_t chldset, prevset;
|
||||
#if defined (ARRAY_VARS)
|
||||
WORD_LIST *alist;
|
||||
int vflags;
|
||||
#endif
|
||||
int bindflags;
|
||||
#if defined (READLINE)
|
||||
char *rlbuf, *itext;
|
||||
int rlind;
|
||||
@@ -225,7 +252,8 @@ read_builtin (list)
|
||||
USE_VAR(ps2);
|
||||
USE_VAR(lastsig);
|
||||
|
||||
sigalrm_seen = reading = tty_modified = 0;
|
||||
reading = tty_modified = 0;
|
||||
read_timeout = 0;
|
||||
|
||||
i = 0; /* Index into the string that we are reading. */
|
||||
raw = edit = 0; /* Not reading raw input by default. */
|
||||
@@ -330,18 +358,16 @@ read_builtin (list)
|
||||
/* `read -t 0 var' tests whether input is available with select/FIONREAD,
|
||||
and fails if those are unavailable */
|
||||
if (have_timeout && tmsec == 0 && tmusec == 0)
|
||||
#if 0
|
||||
return (EXECUTION_FAILURE);
|
||||
#else
|
||||
return (input_avail (fd) ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
|
||||
#endif
|
||||
|
||||
/* 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)
|
||||
vflags = assoc_expand_once ? (VA_NOEXPAND|VA_ONEWORD) : 0;
|
||||
if (list)
|
||||
SET_VFLAGS (list->word->flags, vflags, bindflags);
|
||||
if (list && legal_identifier (list->word->word) == 0 && valid_array_reference (list->word->word, vflags) == 0)
|
||||
#else
|
||||
bindflags = 0;
|
||||
if (list && legal_identifier (list->word->word) == 0)
|
||||
#endif
|
||||
{
|
||||
@@ -387,6 +413,12 @@ read_builtin (list)
|
||||
}
|
||||
}
|
||||
|
||||
#if defined (SIGCHLD)
|
||||
sigemptyset (&chldset);
|
||||
sigprocmask (SIG_BLOCK, (sigset_t *)0, &chldset);
|
||||
sigaddset (&chldset, SIGCHLD);
|
||||
#endif
|
||||
|
||||
begin_unwind_frame ("read_builtin");
|
||||
|
||||
#if defined (BUFFERED_INPUT)
|
||||
@@ -435,10 +467,27 @@ read_builtin (list)
|
||||
|
||||
if (tmsec > 0 || tmusec > 0)
|
||||
{
|
||||
code = setjmp_nosigs (alrmbuf);
|
||||
read_timeout = shtimer_alloc ();
|
||||
read_timeout->flags = SHTIMER_LONGJMP;
|
||||
|
||||
#if defined (HAVE_SELECT)
|
||||
read_timeout->flags |= edit ? SHTIMER_ALARM : SHTIMER_SELECT;
|
||||
#else
|
||||
read_timeout->flags |= SHTIMER_ALARM;
|
||||
#endif
|
||||
read_timeout->fd = fd;
|
||||
|
||||
read_timeout->alrm_handler = sigalrm;
|
||||
}
|
||||
|
||||
if (tmsec > 0 || tmusec > 0)
|
||||
{
|
||||
code = setjmp_nosigs (read_timeout->jmpenv);
|
||||
if (code)
|
||||
{
|
||||
sigalrm_seen = 0;
|
||||
reset_timeout ();
|
||||
sigprocmask (SIG_SETMASK, &prevset, (sigset_t *)0);
|
||||
|
||||
/* Tricky. The top of the unwind-protect stack is the free of
|
||||
input_string. We want to run all the rest and use input_string,
|
||||
so we have to save input_string temporarily, run the unwind-
|
||||
@@ -460,16 +509,17 @@ read_builtin (list)
|
||||
}
|
||||
if (interactive_shell == 0)
|
||||
initialize_terminating_signals ();
|
||||
old_alrm = set_signal_handler (SIGALRM, sigalrm);
|
||||
add_unwind_protect (reset_alarm, (char *)NULL);
|
||||
add_unwind_protect (reset_timeout, (char *)NULL);
|
||||
#if defined (READLINE)
|
||||
if (edit)
|
||||
{
|
||||
add_unwind_protect (reset_attempted_completion_function, (char *)NULL);
|
||||
add_unwind_protect (bashline_reset_event_hook, (char *)NULL);
|
||||
set_readline_timeout (read_timeout, tmsec, tmusec);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
falarm (tmsec, tmusec);
|
||||
shtimer_set (read_timeout, tmsec, tmusec);
|
||||
}
|
||||
|
||||
/* If we've been asked to read only NCHARS chars, or we're using some
|
||||
@@ -545,12 +595,16 @@ read_builtin (list)
|
||||
of the unwind-protect stack after the realloc() works right. */
|
||||
add_unwind_protect (xfree, input_string);
|
||||
|
||||
CHECK_ALRM;
|
||||
check_read_timeout ();
|
||||
/* These only matter if edit == 0 */
|
||||
if ((nchars > 0) && (input_is_tty == 0) && ignore_delim) /* read -N */
|
||||
unbuffered_read = 2;
|
||||
#if 0
|
||||
else if ((nchars > 0) || (delim != '\n') || input_is_pipe)
|
||||
#else
|
||||
else if (((nchars > 0 || delim != '\n') && input_is_tty) || input_is_pipe)
|
||||
unbuffered_read = 1;
|
||||
|
||||
#endif
|
||||
if (prompt && edit == 0)
|
||||
{
|
||||
fprintf (stderr, "%s", prompt);
|
||||
@@ -564,7 +618,7 @@ read_builtin (list)
|
||||
ps2 = 0;
|
||||
for (print_ps2 = eof = retval = 0;;)
|
||||
{
|
||||
CHECK_ALRM;
|
||||
check_read_timeout ();
|
||||
|
||||
#if defined (READLINE)
|
||||
if (edit)
|
||||
@@ -575,6 +629,10 @@ read_builtin (list)
|
||||
free (rlbuf);
|
||||
rlbuf = (char *)0;
|
||||
}
|
||||
#if defined (SIGCHLD)
|
||||
if (tmsec > 0 || tmusec > 0)
|
||||
sigprocmask (SIG_SETMASK, &chldset, &prevset);
|
||||
#endif
|
||||
if (rlbuf == 0)
|
||||
{
|
||||
reading = 1;
|
||||
@@ -582,6 +640,10 @@ read_builtin (list)
|
||||
reading = 0;
|
||||
rlind = 0;
|
||||
}
|
||||
#if defined (SIGCHLD)
|
||||
if (tmsec > 0 || tmusec > 0)
|
||||
sigprocmask (SIG_SETMASK, &prevset, (sigset_t *)0);
|
||||
#endif
|
||||
if (rlbuf == 0)
|
||||
{
|
||||
eof = 1;
|
||||
@@ -603,14 +665,24 @@ read_builtin (list)
|
||||
}
|
||||
|
||||
reading = 1;
|
||||
CHECK_ALRM;
|
||||
check_read_timeout ();
|
||||
errno = 0;
|
||||
|
||||
#if defined (SIGCHLD)
|
||||
if (tmsec > 0 || tmusec > 0)
|
||||
sigprocmask (SIG_SETMASK, &chldset, &prevset);
|
||||
#endif
|
||||
if (unbuffered_read == 2)
|
||||
retval = posixly_correct ? zreadintr (fd, &c, 1) : zreadn (fd, &c, nchars - nr);
|
||||
else if (unbuffered_read)
|
||||
retval = posixly_correct ? zreadintr (fd, &c, 1) : zread (fd, &c, 1);
|
||||
else
|
||||
retval = posixly_correct ? zreadcintr (fd, &c) : zreadc (fd, &c);
|
||||
#if defined (SIGCHLD)
|
||||
if (tmsec > 0 || tmusec > 0)
|
||||
sigprocmask (SIG_SETMASK, &prevset, (sigset_t *)0);
|
||||
#endif
|
||||
|
||||
reading = 0;
|
||||
|
||||
if (retval <= 0)
|
||||
@@ -644,7 +716,7 @@ read_builtin (list)
|
||||
#endif
|
||||
|
||||
if (retval <= 0) /* XXX shouldn't happen */
|
||||
CHECK_ALRM;
|
||||
check_read_timeout ();
|
||||
|
||||
/* XXX -- use i + mb_cur_max (at least 4) for multibyte/read_mbchar */
|
||||
if (i + (mb_cur_max > 4 ? mb_cur_max : 4) >= size)
|
||||
@@ -704,7 +776,7 @@ read_builtin (list)
|
||||
|
||||
add_char:
|
||||
input_string[i++] = c;
|
||||
CHECK_ALRM;
|
||||
check_read_timeout ();
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
/* XXX - what if C == 127? Can DEL introduce a multibyte sequence? */
|
||||
@@ -741,7 +813,7 @@ add_char:
|
||||
break;
|
||||
}
|
||||
input_string[i] = '\0';
|
||||
CHECK_ALRM;
|
||||
check_read_timeout ();
|
||||
|
||||
#if defined (READLINE)
|
||||
if (edit)
|
||||
@@ -758,7 +830,7 @@ add_char:
|
||||
}
|
||||
|
||||
if (tmsec > 0 || tmusec > 0)
|
||||
reset_alarm ();
|
||||
reset_timeout ();
|
||||
|
||||
if (nchars > 0 || delim != '\n')
|
||||
{
|
||||
@@ -883,6 +955,7 @@ assign_vars:
|
||||
{
|
||||
varname = list->word->word;
|
||||
#if defined (ARRAY_VARS)
|
||||
SET_VFLAGS (list->word->flags, vflags, bindflags);
|
||||
if (legal_identifier (varname) == 0 && valid_array_reference (varname, vflags) == 0)
|
||||
#else
|
||||
if (legal_identifier (varname) == 0)
|
||||
@@ -906,16 +979,16 @@ assign_vars:
|
||||
if (t && saw_escape)
|
||||
{
|
||||
t1 = dequote_string (t);
|
||||
var = bind_read_variable (varname, t1);
|
||||
var = bind_read_variable (varname, t1, bindflags);
|
||||
free (t1);
|
||||
}
|
||||
else
|
||||
var = bind_read_variable (varname, t ? t : "");
|
||||
var = bind_read_variable (varname, t ? t : "", bindflags);
|
||||
}
|
||||
else
|
||||
{
|
||||
t = (char *)0;
|
||||
var = bind_read_variable (varname, "");
|
||||
var = bind_read_variable (varname, "", bindflags);
|
||||
}
|
||||
|
||||
FREE (t);
|
||||
@@ -931,6 +1004,7 @@ assign_vars:
|
||||
|
||||
/* Now assign the rest of the line to the last variable argument. */
|
||||
#if defined (ARRAY_VARS)
|
||||
SET_VFLAGS (list->word->flags, vflags, bindflags);
|
||||
if (legal_identifier (list->word->word) == 0 && valid_array_reference (list->word->word, vflags) == 0)
|
||||
#else
|
||||
if (legal_identifier (list->word->word) == 0)
|
||||
@@ -967,11 +1041,11 @@ assign_vars:
|
||||
if (saw_escape && input_string && *input_string)
|
||||
{
|
||||
t = dequote_string (input_string);
|
||||
var = bind_read_variable (list->word->word, t);
|
||||
var = bind_read_variable (list->word->word, t, bindflags);
|
||||
free (t);
|
||||
}
|
||||
else
|
||||
var = bind_read_variable (list->word->word, input_string ? input_string : "");
|
||||
var = bind_read_variable (list->word->word, input_string ? input_string : "", bindflags);
|
||||
|
||||
if (var)
|
||||
{
|
||||
@@ -988,12 +1062,13 @@ assign_vars:
|
||||
}
|
||||
|
||||
static SHELL_VAR *
|
||||
bind_read_variable (name, value)
|
||||
bind_read_variable (name, value, flags)
|
||||
char *name, *value;
|
||||
int flags;
|
||||
{
|
||||
SHELL_VAR *v;
|
||||
|
||||
v = builtin_bind_variable (name, value, 0);
|
||||
v = builtin_bind_variable (name, value, flags);
|
||||
return (v == 0 ? v
|
||||
: ((readonly_p (v) || noassign_p (v)) ? (SHELL_VAR *)NULL : v));
|
||||
}
|
||||
@@ -1131,7 +1206,15 @@ edit_line (p, itext)
|
||||
bashline_reset_event_hook ();
|
||||
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
{
|
||||
if (RL_ISSTATE (RL_STATE_TIMEOUT))
|
||||
{
|
||||
sigalrm (SIGALRM); /* simulate receiving SIGALRM */
|
||||
check_read_timeout ();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
len = strlen (ret);
|
||||
ret = (char *)xrealloc (ret, len + 2);
|
||||
ret[len++] = delim;
|
||||
@@ -1139,6 +1222,17 @@ edit_line (p, itext)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
set_readline_timeout (t, sec, usec)
|
||||
sh_timer *t;
|
||||
time_t sec;
|
||||
long usec;
|
||||
{
|
||||
t->tmout.tv_sec = sec;
|
||||
t->tmout.tv_usec = usec;
|
||||
rl_set_timeout (sec, usec);
|
||||
}
|
||||
|
||||
static int old_delim_ctype;
|
||||
static rl_command_func_t *old_delim_func;
|
||||
static int old_newline_ctype;
|
||||
|
||||
@@ -114,22 +114,22 @@ Returns the status of the last command executed.
|
||||
$END
|
||||
|
||||
$BUILTIN while
|
||||
$SHORT_DOC while COMMANDS; do COMMANDS; done
|
||||
$SHORT_DOC while COMMANDS; do COMMANDS-2; done
|
||||
Execute commands as long as a test succeeds.
|
||||
|
||||
Expand and execute COMMANDS as long as the final command in the
|
||||
`while' COMMANDS has an exit status of zero.
|
||||
Expand and execute COMMANDS-2 as long as the final command in COMMANDS has
|
||||
an exit status of zero.
|
||||
|
||||
Exit Status:
|
||||
Returns the status of the last command executed.
|
||||
$END
|
||||
|
||||
$BUILTIN until
|
||||
$SHORT_DOC until COMMANDS; do COMMANDS; done
|
||||
$SHORT_DOC until COMMANDS; do COMMANDS-2; done
|
||||
Execute commands as long as a test does not succeed.
|
||||
|
||||
Expand and execute COMMANDS as long as the final command in the
|
||||
`until' COMMANDS has an exit status which is not zero.
|
||||
Expand and execute COMMANDS-2 as long as the final command in COMMANDS has
|
||||
an exit status which is not zero.
|
||||
|
||||
Exit Status:
|
||||
Returns the status of the last command executed.
|
||||
|
||||
+22
-12
@@ -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-2020 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -52,7 +52,7 @@ $PRODUCES set.c
|
||||
|
||||
$BUILTIN set
|
||||
$FUNCTION set_builtin
|
||||
$SHORT_DOC set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]
|
||||
$SHORT_DOC set [-abefhkmnptuvxBCEHPT] [-o option-name] [--] [-] [arg ...]
|
||||
Set or unset values of shell options and positional parameters.
|
||||
|
||||
Change the value of shell attributes and positional parameters, or
|
||||
@@ -835,7 +835,7 @@ unset_builtin (list)
|
||||
WORD_LIST *list;
|
||||
{
|
||||
int unset_function, unset_variable, unset_array, opt, nameref, any_failed;
|
||||
int global_unset_func, global_unset_var, vflags, valid_id;
|
||||
int global_unset_func, global_unset_var, vflags, base_vflags, valid_id;
|
||||
char *name, *tname;
|
||||
|
||||
unset_function = unset_variable = unset_array = nameref = any_failed = 0;
|
||||
@@ -873,7 +873,7 @@ unset_builtin (list)
|
||||
nameref = 0;
|
||||
|
||||
#if defined (ARRAY_VARS)
|
||||
vflags = assoc_expand_once ? (VA_NOEXPAND|VA_ONEWORD) : 0;
|
||||
base_vflags = assoc_expand_once ? VA_NOEXPAND : 0;
|
||||
#endif
|
||||
|
||||
while (list)
|
||||
@@ -889,15 +889,15 @@ unset_builtin (list)
|
||||
unset_function = global_unset_func;
|
||||
unset_variable = global_unset_var;
|
||||
|
||||
#if defined (ARRAY_VARS)
|
||||
vflags = builtin_arrayref_flags (list->word, base_vflags);
|
||||
#endif
|
||||
|
||||
#if defined (ARRAY_VARS)
|
||||
unset_array = 0;
|
||||
/* XXX valid array reference second arg was 0 */
|
||||
if (!unset_function && nameref == 0 && valid_array_reference (name, vflags))
|
||||
{
|
||||
t = strchr (name, '[');
|
||||
*t++ = '\0';
|
||||
unset_array++;
|
||||
}
|
||||
if (!unset_function && nameref == 0 && tokenize_array_reference (name, vflags, &t))
|
||||
unset_array = 1;
|
||||
#endif
|
||||
/* Get error checking out of the way first. The low-level functions
|
||||
just perform the unset, relying on the caller to verify. */
|
||||
@@ -959,6 +959,9 @@ unset_builtin (list)
|
||||
#if defined (ARRAY_VARS)
|
||||
if (var && unset_array)
|
||||
{
|
||||
if (shell_compatibility_level <= 51)
|
||||
vflags |= VA_ALLOWALL;
|
||||
|
||||
/* Let unbind_array_element decide what to do with non-array vars */
|
||||
tem = unbind_array_element (var, t, vflags); /* XXX new third arg */
|
||||
if (tem == -2 && array_p (var) == 0 && assoc_p (var) == 0)
|
||||
@@ -981,9 +984,16 @@ unset_builtin (list)
|
||||
#if defined (ARRAY_VARS)
|
||||
if (valid_array_reference (nameref_cell (var), 0))
|
||||
{
|
||||
int len;
|
||||
|
||||
tname = savestring (nameref_cell (var));
|
||||
if (var = array_variable_part (tname, 0, &t, (int *)0))
|
||||
tem = unbind_array_element (var, t, vflags); /* XXX new third arg */
|
||||
if (var = array_variable_part (tname, 0, &t, &len))
|
||||
{
|
||||
/* change to what unbind_array_element now expects */
|
||||
if (t[len - 1] == ']')
|
||||
t[len - 1] = 0;
|
||||
tem = unbind_array_element (var, t, vflags); /* XXX new third arg */
|
||||
}
|
||||
free (tname);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -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-2020 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -514,7 +514,10 @@ show_var_attributes (var, pattr, nodefs)
|
||||
printf ("%s\n", var->name);
|
||||
else
|
||||
{
|
||||
x = sh_double_quote (value_cell (var));
|
||||
if (ansic_shouldquote (value_cell (var)))
|
||||
x = ansic_quote (value_cell (var), 0, (int *)0);
|
||||
else
|
||||
x = sh_double_quote (value_cell (var));
|
||||
printf ("%s=%s\n", var->name, x);
|
||||
free (x);
|
||||
}
|
||||
|
||||
+33
-3
@@ -1,7 +1,7 @@
|
||||
This file is shopt.def, from which is created shopt.c.
|
||||
It implements the Bash `shopt' builtin.
|
||||
|
||||
Copyright (C) 1994-2020 Free Software Foundation, Inc.
|
||||
Copyright (C) 1994-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -89,10 +89,14 @@ extern int check_jobs_at_exit;
|
||||
extern int autocd;
|
||||
extern int glob_star;
|
||||
extern int glob_asciirange;
|
||||
extern int glob_always_skip_dot_and_dotdot;
|
||||
extern int lastpipe_opt;
|
||||
extern int inherit_errexit;
|
||||
extern int localvar_inherit;
|
||||
extern int localvar_unset;
|
||||
extern int varassign_redir_autoclose;
|
||||
extern int singlequote_translations;
|
||||
extern int patsub_replacement;
|
||||
|
||||
#if defined (EXTENDED_GLOB)
|
||||
extern int extended_glob;
|
||||
@@ -120,6 +124,7 @@ extern int debugging_mode;
|
||||
#if defined (ARRAY_VARS)
|
||||
extern int assoc_expand_once;
|
||||
extern int array_expand_once;
|
||||
int expand_once_flag;
|
||||
#endif
|
||||
|
||||
#if defined (SYSLOG_HISTORY)
|
||||
@@ -140,6 +145,10 @@ static int shopt_enable_hostname_completion PARAMS((char *, int));
|
||||
static int shopt_set_complete_direxpand PARAMS((char *, int));
|
||||
#endif
|
||||
|
||||
#if defined (ARRAY_VARS)
|
||||
static int set_assoc_expand PARAMS((char *, int));
|
||||
#endif
|
||||
|
||||
static int shopt_set_debug_mode PARAMS((char *, int));
|
||||
|
||||
static int shopt_login_shell;
|
||||
@@ -163,7 +172,7 @@ static struct {
|
||||
} shopt_vars[] = {
|
||||
{ "autocd", &autocd, (shopt_set_func_t *)NULL },
|
||||
#if defined (ARRAY_VARS)
|
||||
{ "assoc_expand_once", &assoc_expand_once, (shopt_set_func_t *)NULL },
|
||||
{ "assoc_expand_once", &expand_once_flag, set_assoc_expand },
|
||||
#endif
|
||||
{ "cdable_vars", &cdable_vars, (shopt_set_func_t *)NULL },
|
||||
{ "cdspell", &cdspelling, (shopt_set_func_t *)NULL },
|
||||
@@ -202,6 +211,7 @@ static struct {
|
||||
{ "force_fignore", &force_fignore, (shopt_set_func_t *)NULL },
|
||||
#endif
|
||||
{ "globasciiranges", &glob_asciirange, (shopt_set_func_t *)NULL },
|
||||
{ "globskipdots", &glob_always_skip_dot_and_dotdot, (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)
|
||||
@@ -228,7 +238,9 @@ static struct {
|
||||
#endif
|
||||
{ "nocaseglob", &glob_ignore_case, (shopt_set_func_t *)NULL },
|
||||
{ "nocasematch", &match_ignore_case, (shopt_set_func_t *)NULL },
|
||||
{ "noexpand_translation", &singlequote_translations, (shopt_set_func_t *)NULL },
|
||||
{ "nullglob", &allow_null_glob_expansion, (shopt_set_func_t *)NULL },
|
||||
{ "patsub_replacement", &patsub_replacement, (shopt_set_func_t *)NULL },
|
||||
#if defined (PROGRAMMABLE_COMPLETION)
|
||||
{ "progcomp", &prog_completion_enabled, (shopt_set_func_t *)NULL },
|
||||
# if defined (ALIAS)
|
||||
@@ -244,6 +256,7 @@ static struct {
|
||||
#if defined (SYSLOG_HISTORY) && defined (SYSLOG_SHOPT)
|
||||
{ "syslog_history", &syslog_history, (shopt_set_func_t *)NULL },
|
||||
#endif
|
||||
{ "varredir_close", &varassign_redir_autoclose, (shopt_set_func_t *)NULL },
|
||||
{ "xpg_echo", &xpg_echo, (shopt_set_func_t *)NULL },
|
||||
{ (char *)0, (int *)0, (shopt_set_func_t *)NULL }
|
||||
};
|
||||
@@ -352,6 +365,9 @@ reset_shopt_options ()
|
||||
glob_ignore_case = match_ignore_case = 0;
|
||||
print_shift_error = 0;
|
||||
source_uses_path = promptvars = 1;
|
||||
varassign_redir_autoclose = 0;
|
||||
singlequote_translations = 0;
|
||||
patsub_replacement = 1;
|
||||
|
||||
#if defined (JOB_CONTROL)
|
||||
check_jobs_at_exit = 0;
|
||||
@@ -362,7 +378,7 @@ reset_shopt_options ()
|
||||
#endif
|
||||
|
||||
#if defined (ARRAY_VARS)
|
||||
assoc_expand_once = 0;
|
||||
expand_once_flag = assoc_expand_once = 0;
|
||||
#endif
|
||||
|
||||
#if defined (HISTORY)
|
||||
@@ -897,3 +913,17 @@ initialize_bashopts (no_bashopts)
|
||||
/* Set up the $BASHOPTS variable. */
|
||||
set_bashopts ();
|
||||
}
|
||||
|
||||
#if defined (ARRAY_VARS)
|
||||
static int
|
||||
set_assoc_expand (option_name, mode)
|
||||
char *option_name;
|
||||
int mode;
|
||||
{
|
||||
#if 0 /* leave this disabled */
|
||||
if (shell_compatibility_level <= 51)
|
||||
#endif
|
||||
assoc_expand_once = expand_once_flag;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
+5
-2
@@ -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-2020 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -250,7 +250,9 @@ showtrap (i, show_default)
|
||||
int i, show_default;
|
||||
{
|
||||
char *t, *p, *sn;
|
||||
int free_t;
|
||||
|
||||
free_t = 1;
|
||||
p = trap_list[i];
|
||||
if (p == (char *)DEFAULT_SIG && signal_is_hard_ignored (i) == 0)
|
||||
{
|
||||
@@ -258,6 +260,7 @@ showtrap (i, show_default)
|
||||
t = "-";
|
||||
else
|
||||
return;
|
||||
free_t = 0;
|
||||
}
|
||||
else if (signal_is_hard_ignored (i))
|
||||
t = (char *)NULL;
|
||||
@@ -279,7 +282,7 @@ showtrap (i, show_default)
|
||||
else
|
||||
printf ("trap -- %s %s\n", t ? t : "''", sn);
|
||||
|
||||
if (show_default == 0)
|
||||
if (free_t)
|
||||
FREE (t);
|
||||
}
|
||||
|
||||
|
||||
+11
-2
@@ -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-2020 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2021 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 [-SHabcdefiklmnpqrstuvxPT] [limit]
|
||||
$SHORT_DOC ulimit [-SHabcdefiklmnpqrstuvxPRT] [limit]
|
||||
Modify shell resource limits.
|
||||
|
||||
Provides control over the resources available to the shell and processes
|
||||
@@ -428,6 +428,15 @@ ulimit_builtin (list)
|
||||
}
|
||||
}
|
||||
|
||||
/* POSIX compatibility. If the last item in cmdlist does not have an option
|
||||
argument, but there is an operand (list != 0), treat the operand as if
|
||||
it were an option argument for that last command. */
|
||||
if (list && list->word && cmdlist[ncmd - 1].arg == 0)
|
||||
{
|
||||
cmdlist[ncmd - 1].arg = list->word->word;
|
||||
list = list->next;
|
||||
}
|
||||
|
||||
for (c = 0; c < ncmd; c++)
|
||||
if (ulimit_internal (cmdlist[c].cmd, cmdlist[c].arg, mode, ncmd > 1) == EXECUTION_FAILURE)
|
||||
return (EXECUTION_FAILURE);
|
||||
|
||||
+10
-6
@@ -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-2020 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -111,7 +111,7 @@ int
|
||||
wait_builtin (list)
|
||||
WORD_LIST *list;
|
||||
{
|
||||
int status, code, opt, nflag;
|
||||
int status, code, opt, nflag, vflags, bindflags;
|
||||
volatile int wflags;
|
||||
char *vname;
|
||||
SHELL_VAR *pidvar;
|
||||
@@ -119,7 +119,7 @@ wait_builtin (list)
|
||||
|
||||
USE_VAR(list);
|
||||
|
||||
nflag = wflags = 0;
|
||||
nflag = wflags = vflags = 0;
|
||||
vname = NULL;
|
||||
pidvar = (SHELL_VAR *)NULL;
|
||||
reset_internal_getopt ();
|
||||
@@ -136,6 +136,7 @@ wait_builtin (list)
|
||||
break;
|
||||
case 'p':
|
||||
vname = list_optarg;
|
||||
vflags = list_optflags;
|
||||
break;
|
||||
#endif
|
||||
CASE_HELPOPT;
|
||||
@@ -152,9 +153,10 @@ wait_builtin (list)
|
||||
#if defined (ARRAY_VARS)
|
||||
int arrayflags;
|
||||
|
||||
arrayflags = assoc_expand_once ? (VA_NOEXPAND|VA_ONEWORD) : 0;
|
||||
SET_VFLAGS (vflags, arrayflags, bindflags);
|
||||
if (legal_identifier (vname) == 0 && valid_array_reference (vname, arrayflags) == 0)
|
||||
#else
|
||||
bindflags = 0;
|
||||
if (legal_identifier (vname) == 0)
|
||||
#endif
|
||||
{
|
||||
@@ -181,8 +183,10 @@ wait_builtin (list)
|
||||
last_command_exit_signal = wait_signal_received;
|
||||
status = 128 + wait_signal_received;
|
||||
wait_sigint_cleanup ();
|
||||
#if defined (JOB_CONTROL)
|
||||
if (wflags & JWAIT_WAITING)
|
||||
unset_waitlist ();
|
||||
#endif
|
||||
WAIT_RETURN (status);
|
||||
}
|
||||
|
||||
@@ -217,7 +221,7 @@ wait_builtin (list)
|
||||
|
||||
status = wait_for_any_job (wflags, &pstat);
|
||||
if (vname && status >= 0)
|
||||
bind_var_to_int (vname, pstat.pid);
|
||||
builtin_bind_var_to_int (vname, pstat.pid, bindflags);
|
||||
|
||||
if (status < 0)
|
||||
status = 127;
|
||||
@@ -233,7 +237,7 @@ wait_builtin (list)
|
||||
{
|
||||
wait_for_background_pids (&pstat);
|
||||
if (vname)
|
||||
bind_var_to_int (vname, pstat.pid);
|
||||
builtin_bind_var_to_int (vname, pstat.pid, bindflags);
|
||||
WAIT_RETURN (EXECUTION_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
@@ -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-2020 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1993-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -81,18 +81,18 @@ enum command_type { cm_for, cm_case, cm_while, cm_if, cm_simple, cm_select,
|
||||
#define W_NOGLOB (1 << 5) /* Do not perform globbing on this word. */
|
||||
#define W_NOSPLIT2 (1 << 6) /* Don't split word except for $@ expansion (using spaces) because context does not allow it. */
|
||||
#define W_TILDEEXP (1 << 7) /* Tilde expand this assignment word */
|
||||
#define W_DOLLARAT (1 << 8) /* $@ and its special handling -- UNUSED */
|
||||
#define W_DOLLARSTAR (1 << 9) /* $* and its special handling -- UNUSED */
|
||||
#define W_DOLLARAT (1 << 8) /* UNUSED - $@ and its special handling */
|
||||
#define W_ARRAYREF (1 << 9) /* word is a valid array reference */
|
||||
#define W_NOCOMSUB (1 << 10) /* Don't perform command substitution on this word */
|
||||
#define W_ASSIGNRHS (1 << 11) /* Word is rhs of an assignment statement */
|
||||
#define W_NOTILDE (1 << 12) /* Don't perform tilde expansion on this word */
|
||||
#define W_ITILDE (1 << 13) /* Internal flag for word expansion */
|
||||
#define W_NOASSNTILDE (1 << 13) /* don't do tilde expansion like an assignment statement */
|
||||
#define W_EXPANDRHS (1 << 14) /* Expanding word in ${paramOPword} */
|
||||
#define W_COMPASSIGN (1 << 15) /* Compound assignment */
|
||||
#define W_ASSNBLTIN (1 << 16) /* word is a builtin command that takes assignments */
|
||||
#define W_ASSIGNARG (1 << 17) /* word is assignment argument to command */
|
||||
#define W_HASQUOTEDNULL (1 << 18) /* word contains a quoted null character */
|
||||
#define W_DQUOTE (1 << 19) /* word should be treated as if double-quoted */
|
||||
#define W_DQUOTE (1 << 19) /* UNUSED - word should be treated as if double-quoted */
|
||||
#define W_NOPROCSUB (1 << 20) /* don't perform process substitution */
|
||||
#define W_SAWQUOTEDNULL (1 << 21) /* word contained a quoted null that was removed */
|
||||
#define W_ASSIGNASSOC (1 << 22) /* word looks like associative array assignment */
|
||||
@@ -102,8 +102,8 @@ enum command_type { cm_for, cm_case, cm_while, cm_if, cm_simple, cm_select,
|
||||
#define W_NOBRACE (1 << 26) /* Don't perform brace expansion */
|
||||
#define W_COMPLETE (1 << 27) /* word is being expanded for completion */
|
||||
#define W_CHKLOCAL (1 << 28) /* check for local vars on assignment */
|
||||
#define W_NOASSNTILDE (1 << 29) /* don't do tilde expansion like an assignment statement */
|
||||
#define W_FORCELOCAL (1 << 30) /* force assignments to be to local variables, non-fatal on assignment errors */
|
||||
#define W_FORCELOCAL (1 << 29) /* force assignments to be to local variables, non-fatal on assignment errors */
|
||||
/* UNUSED (1 << 30) */
|
||||
|
||||
/* Flags for the `pflags' argument to param_expand() and various
|
||||
parameter_brace_expand_xxx functions; also used for string_list_dollar_at */
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
/* config-bot.h */
|
||||
/* modify settings or make new ones based on what autoconf tells us. */
|
||||
|
||||
/* Copyright (C) 1989-2009 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1989-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -99,7 +99,7 @@
|
||||
#endif
|
||||
|
||||
#if !HAVE_MKDTEMP
|
||||
# undef USE_MKDTMP
|
||||
# undef USE_MKDTEMP
|
||||
#endif
|
||||
|
||||
/* If the shell is called by this name, it will become restricted. */
|
||||
|
||||
+8
-2
@@ -1,6 +1,6 @@
|
||||
/* config-top.h - various user-settable options not under the control of autoconf. */
|
||||
|
||||
/* Copyright (C) 2002-2009 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 2002-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -77,6 +77,12 @@
|
||||
"/bin:/usr/bin:/sbin:/usr/sbin:/etc:/usr/etc"
|
||||
#endif
|
||||
|
||||
/* The default path for enable -f */
|
||||
#ifndef DEFAULT_LOADABLE_BUILTINS_PATH
|
||||
#define DEFAULT_LOADABLE_BUILTINS_PATH \
|
||||
"/usr/local/lib/bash:/usr/lib/bash:/opt/local/lib/bash:/usr/pkg/lib/bash:/opt/pkg/lib/bash:."
|
||||
#endif
|
||||
|
||||
/* Default primary and secondary prompt strings. */
|
||||
#define PPROMPT "\\s-\\v\\$ "
|
||||
#define SPROMPT "> "
|
||||
@@ -108,7 +114,7 @@
|
||||
|
||||
/* Define if you want the case-toggling operators (~[~]) and the
|
||||
`capcase' variable attribute (declare -c). */
|
||||
/* TAG: bash-5.2 disable */
|
||||
/* TAG: bash-5.2 disable? */
|
||||
#define CASEMOD_TOGGLECASE
|
||||
#define CASEMOD_CAPCASE
|
||||
|
||||
|
||||
+25
-30
@@ -23,15 +23,6 @@
|
||||
|
||||
/* 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
|
||||
@@ -219,10 +210,10 @@
|
||||
|
||||
#undef __CHAR_UNSIGNED__
|
||||
|
||||
/* Define if the compiler supports `long long' variables. */
|
||||
#undef HAVE_LONG_LONG
|
||||
/* Define if the compiler supports `long long int' variables. */
|
||||
#undef HAVE_LONG_LONG_INT
|
||||
|
||||
#undef HAVE_UNSIGNED_LONG_LONG
|
||||
#undef HAVE_UNSIGNED_LONG_LONG_INT
|
||||
|
||||
/* The number of bytes in a int. */
|
||||
#undef SIZEOF_INT
|
||||
@@ -233,6 +224,9 @@
|
||||
/* The number of bytes in a pointer to char. */
|
||||
#undef SIZEOF_CHAR_P
|
||||
|
||||
/* The number of bytes in a size_t. */
|
||||
#undef SIZEOF_SIZE_T
|
||||
|
||||
/* The number of bytes in a double (hopefully 8). */
|
||||
#undef SIZEOF_DOUBLE
|
||||
|
||||
@@ -252,6 +246,8 @@
|
||||
/* Characteristics of the system's header files and libraries that affect
|
||||
the compilation environment. */
|
||||
|
||||
/* These are set by AC_USE_SYSTEM_EXTENSIONS */
|
||||
|
||||
/* Define if the system does not provide POSIX.1 features except
|
||||
with this defined. */
|
||||
#undef _POSIX_1_SOURCE
|
||||
@@ -259,11 +255,18 @@
|
||||
/* Define if you need to in order for stat and other things to work. */
|
||||
#undef _POSIX_SOURCE
|
||||
|
||||
/* Define to use GNU libc extensions */
|
||||
/* Define to use GNU libc extensions. */
|
||||
#undef _GNU_SOURCE
|
||||
|
||||
/* Define if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
/* Define to enable general system extensions on Solaris. */
|
||||
#undef __EXTENSIONS__
|
||||
|
||||
/* General system extensions on AIX */
|
||||
#undef _ALL_SOURCE
|
||||
|
||||
#undef _POSIX_PTHREAD_SEMANTICS
|
||||
#undef _TANDEM_SOURCE
|
||||
#undef _MINIX
|
||||
|
||||
/* Memory management functions. */
|
||||
|
||||
@@ -513,11 +516,6 @@
|
||||
|
||||
#undef PGRP_PIPE
|
||||
|
||||
/* Define if the setvbuf function takes the buffering type as its second
|
||||
argument and the buffer pointer as the third, as on System V
|
||||
before release 3. */
|
||||
#undef SETVBUF_REVERSED
|
||||
|
||||
#undef STAT_MACROS_BROKEN
|
||||
|
||||
#undef ULIMIT_MAXFDS
|
||||
@@ -530,8 +528,6 @@
|
||||
|
||||
#undef HAVE_PRINTF_A_FORMAT
|
||||
|
||||
#undef CTYPE_NON_ASCII
|
||||
|
||||
/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
|
||||
#undef HAVE_LANGINFO_CODESET
|
||||
|
||||
@@ -554,12 +550,6 @@
|
||||
|
||||
/* Type and behavior of signal handling functions. */
|
||||
|
||||
/* Define as the return type of signal handlers (int or void). */
|
||||
#undef RETSIGTYPE
|
||||
|
||||
/* Define if return type of signal handlers is void */
|
||||
#undef VOID_SIGHANDLER
|
||||
|
||||
#undef MUST_REINSTALL_SIGHANDLERS
|
||||
|
||||
#undef HAVE_BSD_SIGNALS
|
||||
@@ -1092,8 +1082,6 @@
|
||||
/* Define if you have <sys/time.h> */
|
||||
#undef HAVE_SYS_TIME_H
|
||||
|
||||
#undef TIME_WITH_SYS_TIME
|
||||
|
||||
/* Define if you have <sys/times.h> */
|
||||
#undef HAVE_SYS_TIMES_H
|
||||
|
||||
@@ -1169,6 +1157,13 @@
|
||||
|
||||
#undef DEV_FD_STAT_BROKEN
|
||||
|
||||
/* An array implementation that prioritizes speed (O(1) access) over space,
|
||||
in array2.c */
|
||||
#undef ALT_ARRAY_IMPLEMENTATION
|
||||
|
||||
/* Support for $"..." translatable strings. */
|
||||
#undef TRANSLATABLE_STRINGS
|
||||
|
||||
/* Additional defines for configuring lib/intl, maintained by autoscan/autoheader */
|
||||
|
||||
/* Define if you have the <argz.h> header file. */
|
||||
|
||||
+124
-112
@@ -1,11 +1,11 @@
|
||||
dnl
|
||||
dnl Configure script for bash-5.1
|
||||
dnl Configure script for bash-5.2
|
||||
dnl
|
||||
dnl report bugs to chet@po.cwru.edu
|
||||
dnl
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
|
||||
# Copyright (C) 1987-2020 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1987-2022 Free Software Foundation, Inc.
|
||||
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
@@ -21,15 +21,15 @@ 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 5.1, version 5.022])dnl
|
||||
AC_REVISION([for Bash 5.2, version 5.039])dnl
|
||||
|
||||
define(bashvers, 5.1)
|
||||
define(relstatus, release)
|
||||
define(bashvers, 5.2)
|
||||
define(relstatus, alpha)
|
||||
|
||||
AC_INIT([bash], bashvers-relstatus, [bug-bash@gnu.org])
|
||||
|
||||
dnl make sure we are using a recent autoconf version
|
||||
AC_PREREQ(2.61)
|
||||
AC_PREREQ(2.69)
|
||||
|
||||
AC_CONFIG_SRCDIR(shell.h)
|
||||
dnl where to find install.sh, config.sub, and config.guess
|
||||
@@ -108,11 +108,11 @@ AC_ARG_VAR(DEBUGGER_START_FILE, [location of bash debugger initialization file])
|
||||
|
||||
dnl arguments to configure
|
||||
dnl packages
|
||||
AC_ARG_WITH(afs, AC_HELP_STRING([--with-afs], [if you are running AFS]), opt_afs=$withval)
|
||||
AC_ARG_WITH(bash-malloc, AC_HELP_STRING([--with-bash-malloc], [use the Bash version of malloc]), opt_bash_malloc=$withval)
|
||||
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(afs, AS_HELP_STRING([--with-afs], [if you are running AFS]), opt_afs=$withval)
|
||||
AC_ARG_WITH(bash-malloc, AS_HELP_STRING([--with-bash-malloc], [use the Bash version of malloc]), opt_bash_malloc=$withval)
|
||||
AC_ARG_WITH(curses, AS_HELP_STRING([--with-curses], [use the curses library instead of the termcap library]), opt_curses=$withval)
|
||||
AC_ARG_WITH(gnu-malloc, AS_HELP_STRING([--with-gnu-malloc], [synonym for --with-bash-malloc]), opt_bash_malloc=$withval)
|
||||
AC_ARG_WITH(installed-readline, AS_HELP_STRING([--with-installed-readline], [use a version of the readline library that is already installed]), opt_with_installed_readline=$withval)
|
||||
|
||||
if test "$opt_bash_malloc" = yes; then
|
||||
MALLOC_TARGET=malloc
|
||||
@@ -182,13 +182,18 @@ opt_dircomplete_expand_default=no
|
||||
opt_globascii_default=yes
|
||||
opt_function_import=yes
|
||||
opt_dev_fd_stat_broken=no
|
||||
opt_alt_array_impl=no
|
||||
opt_translatable_strings=yes
|
||||
|
||||
dnl modified by alternate array implementation option
|
||||
ARRAY_O=array.o
|
||||
|
||||
dnl options that affect how bash is compiled and linked
|
||||
opt_static_link=no
|
||||
opt_profiling=no
|
||||
|
||||
dnl argument parsing for optional features
|
||||
AC_ARG_ENABLE(minimal-config, AC_HELP_STRING([--enable-minimal-config], [a minimal sh-like configuration]), opt_minimal_config=$enableval)
|
||||
AC_ARG_ENABLE(minimal-config, AS_HELP_STRING([--enable-minimal-config], [a minimal sh-like configuration]), opt_minimal_config=$enableval)
|
||||
|
||||
dnl a minimal configuration turns everything off, but features can be
|
||||
dnl added individually
|
||||
@@ -202,51 +207,54 @@ if test $opt_minimal_config = yes; then
|
||||
opt_net_redirs=no opt_progcomp=no opt_separate_help=no
|
||||
opt_multibyte=yes opt_cond_regexp=no opt_coproc=no
|
||||
opt_casemod_attrs=no opt_casemod_expansions=no opt_extglob_default=no
|
||||
opt_translatable_strings=no
|
||||
opt_globascii_default=yes
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(alias, AC_HELP_STRING([--enable-alias], [enable shell aliases]), opt_alias=$enableval)
|
||||
AC_ARG_ENABLE(arith-for-command, AC_HELP_STRING([--enable-arith-for-command], [enable arithmetic for command]), opt_arith_for_command=$enableval)
|
||||
AC_ARG_ENABLE(array-variables, AC_HELP_STRING([--enable-array-variables], [include shell array variables]), opt_array_variables=$enableval)
|
||||
AC_ARG_ENABLE(bang-history, AC_HELP_STRING([--enable-bang-history], [turn on csh-style history substitution]), opt_bang_history=$enableval)
|
||||
AC_ARG_ENABLE(brace-expansion, AC_HELP_STRING([--enable-brace-expansion], [include brace expansion]), opt_brace_expansion=$enableval)
|
||||
AC_ARG_ENABLE(casemod-attributes, AC_HELP_STRING([--enable-casemod-attributes], [include case-modifying variable attributes]), opt_casemod_attrs=$enableval)
|
||||
AC_ARG_ENABLE(casemod-expansions, AC_HELP_STRING([--enable-casemod-expansions], [include case-modifying word expansions]), opt_casemod_expansions=$enableval)
|
||||
AC_ARG_ENABLE(command-timing, AC_HELP_STRING([--enable-command-timing], [enable the time reserved word and command timing]), opt_command_timing=$enableval)
|
||||
AC_ARG_ENABLE(cond-command, AC_HELP_STRING([--enable-cond-command], [enable the conditional command]), opt_cond_command=$enableval)
|
||||
AC_ARG_ENABLE(cond-regexp, AC_HELP_STRING([--enable-cond-regexp], [enable extended regular expression matching in conditional commands]), opt_cond_regexp=$enableval)
|
||||
AC_ARG_ENABLE(coprocesses, AC_HELP_STRING([--enable-coprocesses], [enable coprocess support and the coproc reserved word]), opt_coproc=$enableval)
|
||||
AC_ARG_ENABLE(debugger, AC_HELP_STRING([--enable-debugger], [enable support for bash debugger]), opt_debugger=$enableval)
|
||||
AC_ARG_ENABLE(dev-fd-stat-broken, AC_HELP_STRING([--enable-dev-fd-stat-broken], [enable this option if stat on /dev/fd/N and fstat on file descriptor N don't return the same results]), opt_dev_fd_stat_broken=$enableval)
|
||||
AC_ARG_ENABLE(direxpand-default, AC_HELP_STRING([--enable-direxpand-default], [enable the direxpand shell option by default]), opt_dircomplete_expand_default=$enableval)
|
||||
AC_ARG_ENABLE(directory-stack, AC_HELP_STRING([--enable-directory-stack], [enable builtins pushd/popd/dirs]), opt_dirstack=$enableval)
|
||||
AC_ARG_ENABLE(disabled-builtins, AC_HELP_STRING([--enable-disabled-builtins], [allow disabled builtins to still be invoked]), opt_disabled_builtins=$enableval)
|
||||
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)
|
||||
AC_ARG_ENABLE(job-control, AC_HELP_STRING([--enable-job-control], [enable job control features]), opt_job_control=$enableval)
|
||||
AC_ARG_ENABLE(multibyte, AC_HELP_STRING([--enable-multibyte], [enable multibyte characters if OS supports them]), opt_multibyte=$enableval)
|
||||
AC_ARG_ENABLE(net-redirections, AC_HELP_STRING([--enable-net-redirections], [enable /dev/tcp/host/port redirection]), opt_net_redirs=$enableval)
|
||||
AC_ARG_ENABLE(process-substitution, AC_HELP_STRING([--enable-process-substitution], [enable process substitution]), opt_process_subst=$enableval)
|
||||
AC_ARG_ENABLE(progcomp, AC_HELP_STRING([--enable-progcomp], [enable programmable completion and the complete builtin]), opt_progcomp=$enableval)
|
||||
AC_ARG_ENABLE(prompt-string-decoding, AC_HELP_STRING([--enable-prompt-string-decoding], [turn on escape character decoding in prompts]), opt_prompt_decoding=$enableval)
|
||||
AC_ARG_ENABLE(readline, AC_HELP_STRING([--enable-readline], [turn on command line editing]), opt_readline=$enableval)
|
||||
AC_ARG_ENABLE(restricted, AC_HELP_STRING([--enable-restricted], [enable a restricted shell]), opt_restricted=$enableval)
|
||||
AC_ARG_ENABLE(select, AC_HELP_STRING([--enable-select], [include select command]), opt_select=$enableval)
|
||||
AC_ARG_ENABLE(separate-helpfiles, AC_HELP_STRING([--enable-separate-helpfiles], [use external files for help builtin documentation]), opt_separate_help=$enableval)
|
||||
AC_ARG_ENABLE(single-help-strings, AC_HELP_STRING([--enable-single-help-strings], [store help documentation as a single string to ease translation]), opt_single_longdoc_strings=$enableval)
|
||||
AC_ARG_ENABLE(strict-posix-default, AC_HELP_STRING([--enable-strict-posix-default], [configure bash to be posix-conformant by default]), opt_strict_posix=$enableval)
|
||||
AC_ARG_ENABLE(usg-echo-default, AC_HELP_STRING([--enable-usg-echo-default], [a synonym for --enable-xpg-echo-default]), opt_xpg_echo=$enableval)
|
||||
AC_ARG_ENABLE(xpg-echo-default, AC_HELP_STRING([--enable-xpg-echo-default], [make the echo builtin expand escape sequences by default]), opt_xpg_echo=$enableval)
|
||||
AC_ARG_ENABLE(alias, AS_HELP_STRING([--enable-alias], [enable shell aliases]), opt_alias=$enableval)
|
||||
AC_ARG_ENABLE(alt-array-implementation, AS_HELP_STRING([--enable-alt-array-implementation], [enable an alternate array implementation that optimizes speed at the cost of space]), opt_alt_array_impl=$enableval)
|
||||
AC_ARG_ENABLE(arith-for-command, AS_HELP_STRING([--enable-arith-for-command], [enable arithmetic for command]), opt_arith_for_command=$enableval)
|
||||
AC_ARG_ENABLE(array-variables, AS_HELP_STRING([--enable-array-variables], [include shell array variables]), opt_array_variables=$enableval)
|
||||
AC_ARG_ENABLE(bang-history, AS_HELP_STRING([--enable-bang-history], [turn on csh-style history substitution]), opt_bang_history=$enableval)
|
||||
AC_ARG_ENABLE(brace-expansion, AS_HELP_STRING([--enable-brace-expansion], [include brace expansion]), opt_brace_expansion=$enableval)
|
||||
AC_ARG_ENABLE(casemod-attributes, AS_HELP_STRING([--enable-casemod-attributes], [include case-modifying variable attributes]), opt_casemod_attrs=$enableval)
|
||||
AC_ARG_ENABLE(casemod-expansions, AS_HELP_STRING([--enable-casemod-expansions], [include case-modifying word expansions]), opt_casemod_expansions=$enableval)
|
||||
AC_ARG_ENABLE(command-timing, AS_HELP_STRING([--enable-command-timing], [enable the time reserved word and command timing]), opt_command_timing=$enableval)
|
||||
AC_ARG_ENABLE(cond-command, AS_HELP_STRING([--enable-cond-command], [enable the conditional command]), opt_cond_command=$enableval)
|
||||
AC_ARG_ENABLE(cond-regexp, AS_HELP_STRING([--enable-cond-regexp], [enable extended regular expression matching in conditional commands]), opt_cond_regexp=$enableval)
|
||||
AC_ARG_ENABLE(coprocesses, AS_HELP_STRING([--enable-coprocesses], [enable coprocess support and the coproc reserved word]), opt_coproc=$enableval)
|
||||
AC_ARG_ENABLE(debugger, AS_HELP_STRING([--enable-debugger], [enable support for bash debugger]), opt_debugger=$enableval)
|
||||
AC_ARG_ENABLE(dev-fd-stat-broken, AS_HELP_STRING([--enable-dev-fd-stat-broken], [enable this option if stat on /dev/fd/N and fstat on file descriptor N don't return the same results]), opt_dev_fd_stat_broken=$enableval)
|
||||
AC_ARG_ENABLE(direxpand-default, AS_HELP_STRING([--enable-direxpand-default], [enable the direxpand shell option by default]), opt_dircomplete_expand_default=$enableval)
|
||||
AC_ARG_ENABLE(directory-stack, AS_HELP_STRING([--enable-directory-stack], [enable builtins pushd/popd/dirs]), opt_dirstack=$enableval)
|
||||
AC_ARG_ENABLE(disabled-builtins, AS_HELP_STRING([--enable-disabled-builtins], [allow disabled builtins to still be invoked]), opt_disabled_builtins=$enableval)
|
||||
AC_ARG_ENABLE(dparen-arithmetic, AS_HELP_STRING([--enable-dparen-arithmetic], [include ((...)) command]), opt_dparen_arith=$enableval)
|
||||
AC_ARG_ENABLE(extended-glob, AS_HELP_STRING([--enable-extended-glob], [include ksh-style extended pattern matching]), opt_extended_glob=$enableval)
|
||||
AC_ARG_ENABLE(extended-glob-default, AS_HELP_STRING([--enable-extended-glob-default], [force extended pattern matching to be enabled by default]), opt_extglob_default=$enableval)
|
||||
AC_ARG_ENABLE(function-import, AS_HELP_STRING([--enable-function-import], [allow bash to import exported function definitions by default]), opt_function_import=$enableval)
|
||||
AC_ARG_ENABLE(glob-asciiranges-default, AS_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, AS_HELP_STRING([--enable-help-builtin], [include the help builtin]), opt_help=$enableval)
|
||||
AC_ARG_ENABLE(history, AS_HELP_STRING([--enable-history], [turn on command history]), opt_history=$enableval)
|
||||
AC_ARG_ENABLE(job-control, AS_HELP_STRING([--enable-job-control], [enable job control features]), opt_job_control=$enableval)
|
||||
AC_ARG_ENABLE(multibyte, AS_HELP_STRING([--enable-multibyte], [enable multibyte characters if OS supports them]), opt_multibyte=$enableval)
|
||||
AC_ARG_ENABLE(net-redirections, AS_HELP_STRING([--enable-net-redirections], [enable /dev/tcp/host/port redirection]), opt_net_redirs=$enableval)
|
||||
AC_ARG_ENABLE(process-substitution, AS_HELP_STRING([--enable-process-substitution], [enable process substitution]), opt_process_subst=$enableval)
|
||||
AC_ARG_ENABLE(progcomp, AS_HELP_STRING([--enable-progcomp], [enable programmable completion and the complete builtin]), opt_progcomp=$enableval)
|
||||
AC_ARG_ENABLE(prompt-string-decoding, AS_HELP_STRING([--enable-prompt-string-decoding], [turn on escape character decoding in prompts]), opt_prompt_decoding=$enableval)
|
||||
AC_ARG_ENABLE(readline, AS_HELP_STRING([--enable-readline], [turn on command line editing]), opt_readline=$enableval)
|
||||
AC_ARG_ENABLE(restricted, AS_HELP_STRING([--enable-restricted], [enable a restricted shell]), opt_restricted=$enableval)
|
||||
AC_ARG_ENABLE(select, AS_HELP_STRING([--enable-select], [include select command]), opt_select=$enableval)
|
||||
AC_ARG_ENABLE(separate-helpfiles, AS_HELP_STRING([--enable-separate-helpfiles], [use external files for help builtin documentation]), opt_separate_help=$enableval)
|
||||
AC_ARG_ENABLE(single-help-strings, AS_HELP_STRING([--enable-single-help-strings], [store help documentation as a single string to ease translation]), opt_single_longdoc_strings=$enableval)
|
||||
AC_ARG_ENABLE(strict-posix-default, AS_HELP_STRING([--enable-strict-posix-default], [configure bash to be posix-conformant by default]), opt_strict_posix=$enableval)
|
||||
AC_ARG_ENABLE(translatable-strings, AS_HELP_STRING([--enable-translatable-strings], [include support for $"..." translatable strings]), opt_translatable_strings=$enableval)
|
||||
AC_ARG_ENABLE(usg-echo-default, AS_HELP_STRING([--enable-usg-echo-default], [a synonym for --enable-xpg-echo-default]), opt_xpg_echo=$enableval)
|
||||
AC_ARG_ENABLE(xpg-echo-default, AS_HELP_STRING([--enable-xpg-echo-default], [make the echo builtin expand escape sequences by default]), opt_xpg_echo=$enableval)
|
||||
|
||||
dnl options that alter how bash is compiled and linked
|
||||
AC_ARG_ENABLE(mem-scramble, AC_HELP_STRING([--enable-mem-scramble], [scramble memory on calls to malloc and free]), opt_memscramble=$enableval)
|
||||
AC_ARG_ENABLE(profiling, AC_HELP_STRING([--enable-profiling], [allow profiling with gprof]), opt_profiling=$enableval)
|
||||
AC_ARG_ENABLE(static-link, AC_HELP_STRING([--enable-static-link], [link bash statically, for use as a root shell]), opt_static_link=$enableval)
|
||||
AC_ARG_ENABLE(mem-scramble, AS_HELP_STRING([--enable-mem-scramble], [scramble memory on calls to malloc and free]), opt_memscramble=$enableval)
|
||||
AC_ARG_ENABLE(profiling, AS_HELP_STRING([--enable-profiling], [allow profiling with gprof]), opt_profiling=$enableval)
|
||||
AC_ARG_ENABLE(static-link, AS_HELP_STRING([--enable-static-link], [link bash statically, for use as a root shell]), opt_static_link=$enableval)
|
||||
|
||||
dnl So-called `precious' variables
|
||||
AC_ARG_VAR([CC_FOR_BUILD], [C compiler used when compiling binaries used only at build time])
|
||||
@@ -354,6 +362,13 @@ fi
|
||||
if test $opt_dev_fd_stat_broken = yes; then
|
||||
AC_DEFINE(DEV_FD_STAT_BROKEN)
|
||||
fi
|
||||
if test $opt_alt_array_impl = yes; then
|
||||
AC_DEFINE(ALT_ARRAY_IMPLEMENTATION)
|
||||
ARRAY_O=array2.o
|
||||
fi
|
||||
if test $opt_translatable_strings = yes; then
|
||||
AC_DEFINE(TRANSLATABLE_STRINGS)
|
||||
fi
|
||||
|
||||
if test $opt_memscramble = yes; then
|
||||
AC_DEFINE(MEMSCRAMBLE)
|
||||
@@ -368,7 +383,7 @@ fi
|
||||
HELPDIR= HELPDIRDEFINE= HELPINSTALL= HELPFILES_TARGET=
|
||||
if test "$opt_separate_help" != no; then
|
||||
if test "$opt_separate_help" = "yes" ; then
|
||||
HELPDIR='${datadir}/bash'
|
||||
HELPDIR='${datadir}/bash/helpfiles'
|
||||
else
|
||||
HELPDIR=$opt_separate_help
|
||||
fi
|
||||
@@ -391,6 +406,8 @@ AC_SUBST(MALLOC_LIBRARY)
|
||||
AC_SUBST(MALLOC_LDFLAGS)
|
||||
AC_SUBST(MALLOC_DEP)
|
||||
|
||||
AC_SUBST(ARRAY_O)
|
||||
|
||||
AC_SUBST(htmldir)
|
||||
|
||||
AC_SUBST(HELPDIR)
|
||||
@@ -414,17 +431,16 @@ dnl different environment
|
||||
AC_PROG_CC
|
||||
|
||||
if test -n "$want_auto_cflags"; then
|
||||
AUTO_CFLAGS="-g ${GCC+-O2}"
|
||||
AUTO_LDFLAGS="-g ${GCC+-O2}"
|
||||
STYLE_CFLAGS="${GCC+-Wno-parentheses} ${GCC+-Wno-format-security}"
|
||||
AUTO_CFLAGS="-g ${GCC:+-O2}"
|
||||
AUTO_LDFLAGS="-g ${GCC:+-O2}"
|
||||
# STYLE_CFLAGS="${GCC:+-Wno-parentheses} ${GCC:+-Wno-format-security} ${GCC:+-Wno-tautological-constant-out-of-range-compare}"
|
||||
STYLE_CFLAGS="${GCC:+-Wno-parentheses} ${GCC:+-Wno-format-security}"
|
||||
else
|
||||
AUTO_CFLAGS= AUTO_LDFLAGS= STYLE_CFLAGS=
|
||||
fi
|
||||
|
||||
dnl test for Unix variants
|
||||
AC_ISC_POSIX
|
||||
AC_MINIX
|
||||
|
||||
AC_USE_SYSTEM_EXTENSIONS
|
||||
AC_SYS_LARGEFILE
|
||||
|
||||
dnl BEGIN changes for cross-building (currently cygwin, minGW, and
|
||||
@@ -494,7 +510,7 @@ if test "$opt_static_link" = yes; then
|
||||
prefer_static=yes
|
||||
prefer_shared=no
|
||||
# if we're using gcc, add `-static' to LDFLAGS, except on Solaris >= 2
|
||||
if test -n "$GCC" || test "$ac_cv_prog_gcc" = "yes"; then
|
||||
if test "$GCC" = "yes"; then
|
||||
STATIC_LD="-static"
|
||||
case "$host_os" in
|
||||
solaris2*|linux*) ;;
|
||||
@@ -516,9 +532,12 @@ if test "X$cross_compiling" = "Xno"; then
|
||||
fi
|
||||
# CFLAGS set above to default value if not passed in environment
|
||||
if test -n "$want_auto_cflags" ; then
|
||||
CFLAGS_FOR_BUILD="${CFLAGS} ${STYLE_CFLAGS}"
|
||||
CFLAGS_FOR_BUILD="${CFLAGS}"
|
||||
BASE_CFLAGS_FOR_BUILD="${CFLAGS}"
|
||||
else
|
||||
# passed in environment
|
||||
CFLAGS_FOR_BUILD=${CFLAGS-'$(CFLAGS)'}
|
||||
BASE_CFLAGS_FOR_BUILD=${CFLAGS-'$(CFLAGS)'}
|
||||
fi
|
||||
LIBS_FOR_BUILD=${LIBS_FOR_BUILD-'$(LIBS)'}
|
||||
else
|
||||
@@ -526,6 +545,7 @@ else
|
||||
CPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-""}
|
||||
LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-""}
|
||||
CFLAGS_FOR_BUILD=${CFLAGS_FOR_BUILD="-g"}
|
||||
BASE_CFLAGS_FOR_BUILD=${BASE_CFLAGS_FOR_BUILD="-g"}
|
||||
LIBS_FOR_BUILD=${LIBS_FOR_BUILD-""}
|
||||
fi
|
||||
|
||||
@@ -536,6 +556,8 @@ AC_SUBST(STATIC_LD)
|
||||
|
||||
AC_SUBST(CC_FOR_BUILD)
|
||||
AC_SUBST(CFLAGS_FOR_BUILD)
|
||||
AC_SUBST(BASE_CFLAGS_FOR_BUILD)
|
||||
AC_SUBST(STYLE_CFLAGS)
|
||||
AC_SUBST(CPPFLAGS_FOR_BUILD)
|
||||
AC_SUBST(LDFLAGS_FOR_BUILD)
|
||||
AC_SUBST(LIBS_FOR_BUILD)
|
||||
@@ -729,26 +751,22 @@ m4_include([m4/wchar_t.m4])
|
||||
m4_include([m4/wint_t.m4])
|
||||
m4_include([m4/xsize.m4])
|
||||
|
||||
dnl Turn on any extensions available in the GNU C library.
|
||||
AC_DEFINE(_GNU_SOURCE, 1)
|
||||
|
||||
dnl C compiler characteristics
|
||||
AC_C_CONST
|
||||
AC_C_INLINE
|
||||
AC_C_BIGENDIAN
|
||||
AC_C_STRINGIZE
|
||||
AC_C_LONG_DOUBLE
|
||||
AC_TYPE_LONG_DOUBLE
|
||||
AC_C_PROTOTYPES
|
||||
AC_C_CHAR_UNSIGNED
|
||||
AC_C_VOLATILE
|
||||
AC_C_RESTRICT
|
||||
|
||||
dnl initialize GNU gettext
|
||||
AM_GNU_GETTEXT([no-libtool], [need-ngettext], [lib/intl])
|
||||
BASH_GNU_GETTEXT([no-libtool], [need-ngettext], [lib/intl])
|
||||
|
||||
dnl header files
|
||||
AC_HEADER_DIRENT
|
||||
AC_HEADER_TIME
|
||||
AC_HEADER_MAJOR
|
||||
|
||||
BASH_HEADER_INTTYPES
|
||||
@@ -782,7 +800,6 @@ dnl special checks for libc functions
|
||||
AC_FUNC_ALLOCA
|
||||
AC_FUNC_CHOWN
|
||||
AC_FUNC_GETPGRP
|
||||
AC_FUNC_SETVBUF_REVERSED
|
||||
AC_FUNC_VPRINTF
|
||||
AC_FUNC_STRCOLL
|
||||
|
||||
@@ -813,15 +830,12 @@ if test "$ac_cv_func_vprintf" = no && test "$ac_cv_func__doprnt" = "yes"; then
|
||||
AC_LIBOBJ(vprint)
|
||||
fi
|
||||
|
||||
dnl signal stuff
|
||||
AC_TYPE_SIGNAL
|
||||
|
||||
dnl checks for certain version-specific system calls and libc functions
|
||||
AC_CHECK_FUNC(__setostype, AC_DEFINE(HAVE_SETOSTYPE))
|
||||
AC_CHECK_FUNC(wait3, AC_DEFINE(HAVE_WAIT3))
|
||||
|
||||
dnl checks for missing libc functions
|
||||
AC_CHECK_FUNC(mkfifo,AC_DEFINE(HAVE_MKFIFO),AC_DEFINE(MKFIFO_MISSING))
|
||||
AC_CHECK_FUNC(mkfifo, AC_DEFINE(HAVE_MKFIFO), AC_DEFINE(MKFIFO_MISSING))
|
||||
|
||||
dnl checks for system calls
|
||||
AC_CHECK_FUNCS(dup2 eaccess fcntl getdtablesize getentropy getgroups \
|
||||
@@ -857,8 +871,6 @@ AC_CHECK_DECLS([confstr])
|
||||
AC_CHECK_DECLS([printf])
|
||||
AC_CHECK_DECLS([sbrk])
|
||||
AC_CHECK_DECLS([setregid])
|
||||
dnl AC_CHECK_DECLS[(setresuid])
|
||||
dnl AC_CHECK_DECLS[(setresgid])
|
||||
AC_CHECK_DECLS([strcpy])
|
||||
AC_CHECK_DECLS([strsignal])
|
||||
|
||||
@@ -868,12 +880,13 @@ dnl Extra test to detect the horribly broken HP/UX 11.00 strtold(3)
|
||||
AC_CHECK_DECLS([strtold], [
|
||||
AC_MSG_CHECKING([for broken strtold])
|
||||
AC_CACHE_VAL(bash_cv_strtold_broken,
|
||||
[AC_TRY_COMPILE(
|
||||
[#include <stdlib.h>],
|
||||
[long double r; char *foo, bar; r = strtold(foo, &bar);],
|
||||
bash_cv_strtold_broken=no, bash_cv_strtold_broken=yes,
|
||||
[AC_MSG_WARN(cannot check for broken strtold if cross-compiling, defaulting to no)])
|
||||
]
|
||||
[AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[#include <stdlib.h>]],
|
||||
[[long double r; char *foo, bar; r = strtold(foo, &bar);]]
|
||||
)],
|
||||
[bash_cv_strtold_broken=no],[bash_cv_strtold_broken=yes])
|
||||
]
|
||||
)
|
||||
AC_MSG_RESULT($bash_cv_strtold_broken)
|
||||
if test "$bash_cv_strtold_broken" = "yes" ; then
|
||||
@@ -881,18 +894,18 @@ AC_CHECK_DECLS([strtold], [
|
||||
fi
|
||||
])
|
||||
|
||||
BASH_CHECK_DECL(strtoimax)
|
||||
BASH_CHECK_DECL(strtol)
|
||||
BASH_CHECK_DECL(strtoll)
|
||||
BASH_CHECK_DECL(strtoul)
|
||||
BASH_CHECK_DECL(strtoull)
|
||||
BASH_CHECK_DECL(strtoumax)
|
||||
AC_CHECK_DECLS(strtoimax)
|
||||
AC_CHECK_DECLS(strtol)
|
||||
AC_CHECK_DECLS(strtoll)
|
||||
AC_CHECK_DECLS(strtoul)
|
||||
AC_CHECK_DECLS(strtoull)
|
||||
AC_CHECK_DECLS(strtoumax)
|
||||
|
||||
AC_FUNC_MKTIME
|
||||
|
||||
dnl
|
||||
dnl Checks for lib/intl and related code (uses some of the output from
|
||||
dnl AM_GNU_GETTEXT)
|
||||
dnl BASH_GNU_GETTEXT)
|
||||
dnl
|
||||
|
||||
AC_CHECK_HEADERS([argz.h errno.h fcntl.h malloc.h stdio_ext.h])
|
||||
@@ -924,9 +937,6 @@ AC_CHECK_LIB(dl, dlopen)
|
||||
AC_CHECK_FUNCS(dlopen dlclose dlsym)
|
||||
fi
|
||||
|
||||
dnl this defines HAVE_DECL_SYS_SIGLIST
|
||||
AC_DECL_SYS_SIGLIST
|
||||
|
||||
dnl network functions -- check for inet_aton again
|
||||
if test "$ac_cv_func_inet_aton" != 'yes'; then
|
||||
BASH_FUNC_INET_ATON
|
||||
@@ -959,10 +969,9 @@ AC_TYPE_UINTPTR_T
|
||||
AC_CHECK_TYPE(ssize_t, int)
|
||||
AC_CHECK_TYPE(time_t, long)
|
||||
|
||||
BASH_TYPE_LONG_LONG
|
||||
BASH_TYPE_UNSIGNED_LONG_LONG
|
||||
AC_TYPE_LONG_LONG_INT
|
||||
AC_TYPE_UNSIGNED_LONG_LONG_INT
|
||||
|
||||
AC_TYPE_SIGNAL
|
||||
BASH_TYPE_SIG_ATOMIC_T
|
||||
|
||||
AC_CHECK_SIZEOF(char, 1)
|
||||
@@ -970,6 +979,7 @@ AC_CHECK_SIZEOF(short, 2)
|
||||
AC_CHECK_SIZEOF(int, 4)
|
||||
AC_CHECK_SIZEOF(long, 4)
|
||||
AC_CHECK_SIZEOF(char *, 4)
|
||||
AC_CHECK_SIZEOF(size_t, 4)
|
||||
AC_CHECK_SIZEOF(double, 8)
|
||||
AC_CHECK_SIZEOF([long long], 8)
|
||||
|
||||
@@ -999,7 +1009,6 @@ BASH_FUNC_LSTAT
|
||||
fi
|
||||
|
||||
dnl behavior of system calls and library functions
|
||||
BASH_FUNC_CTYPE_NONASCII
|
||||
BASH_FUNC_DUP2_CLOEXEC_CHECK
|
||||
BASH_SYS_PGRP_SYNC
|
||||
BASH_SYS_SIGNAL_VINTAGE
|
||||
@@ -1010,18 +1019,18 @@ BASH_SYS_SIGLIST
|
||||
BASH_UNDER_SYS_SIGLIST
|
||||
|
||||
dnl various system types
|
||||
BASH_TYPE_SIGHANDLER
|
||||
BASH_CHECK_TYPE(clock_t, [#include <sys/times.h>], long)
|
||||
BASH_CHECK_TYPE(sigset_t, [#include <signal.h>], int)
|
||||
BASH_CHECK_TYPE(sig_atomic_t, [#include <signal.h>], int)
|
||||
BASH_CHECK_TYPE(quad_t, , long, HAVE_QUAD_T)
|
||||
BASH_CHECK_TYPE(intmax_t, , $bash_cv_type_long_long)
|
||||
BASH_CHECK_TYPE(uintmax_t, , $bash_cv_type_unsigned_long_long)
|
||||
if test "$ac_cv_header_sys_socket_h" = "yes"; then
|
||||
BASH_CHECK_TYPE(socklen_t, [#include <sys/socket.h>], [unsigned int], HAVE_SOCKLEN_T)
|
||||
fi
|
||||
|
||||
AC_CHECK_TYPE(quad_t, AC_DEFINE([HAVE_QUAD_T], [1]), [], )
|
||||
BASH_TYPE_RLIMIT
|
||||
|
||||
AC_TYPE_INTMAX_T
|
||||
AC_TYPE_UINTMAX_T
|
||||
|
||||
AC_CHECK_SIZEOF(intmax_t, 8)
|
||||
|
||||
dnl presence and contents of structures used by system calls
|
||||
@@ -1164,7 +1173,7 @@ linux*) LOCAL_LDFLAGS=-rdynamic # allow dynamic loading
|
||||
*) AC_DEFINE(PGRP_PIPE) ;;
|
||||
esac ;;
|
||||
netbsd*|openbsd*) LOCAL_CFLAGS="-DDEV_FD_STAT_BROKEN" ;;
|
||||
freebsd*) LOCAL_CFLAGS='-DHEREDOC_PIPESIZE=4096' ;;
|
||||
freebsd*|midnightbsd*) LOCAL_CFLAGS='-DHEREDOC_PIPESIZE=4096' ;;
|
||||
*qnx[[67]]*) LOCAL_LIBS="-lncurses" ;;
|
||||
*qnx*) LOCAL_CFLAGS="-Dqnx -F -3s" LOCAL_LDFLAGS="-3s" LOCAL_LIBS="-lunix -lncurses" ;;
|
||||
powerux*) LOCAL_LIBS="-lgen" ;;
|
||||
@@ -1190,6 +1199,7 @@ freebsd[[3-9]]*)
|
||||
fi ;;
|
||||
freebsdelf*) LOCAL_LDFLAGS=-rdynamic ;; # allow dynamic loading
|
||||
dragonfly*) LOCAL_LDFLAGS=-rdynamic ;; # allow dynamic loading
|
||||
midnightbsd*) LOCAL_LDFLAGS=-rdynamic ;; # allow dynamic loading
|
||||
esac
|
||||
|
||||
case "$host_cpu" in
|
||||
@@ -1206,7 +1216,7 @@ mips-pyramid-sysv4) LOCAL_CFLAGS=-Xa ;;
|
||||
esac
|
||||
|
||||
# turn off paren warnings in gcc
|
||||
CFLAGS="$CFLAGS ${STYLE_CFLAGS}"
|
||||
#CFLAGS="$CFLAGS ${STYLE_CFLAGS}"
|
||||
|
||||
#
|
||||
# Shared object configuration section. These values are generated by
|
||||
@@ -1297,14 +1307,16 @@ AC_SUBST(LOCAL_DEFS)
|
||||
#AC_SUBST(ALLOCA_SOURCE)
|
||||
#AC_SUBST(ALLOCA_OBJECT)
|
||||
|
||||
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/Makefile.inc \
|
||||
examples/loadables/perl/Makefile \
|
||||
support/bash.pc support/bashbug.sh],
|
||||
[
|
||||
# Makefile uses this timestamp file to record whether config.h is up to date.
|
||||
echo timestamp > stamp-h
|
||||
])
|
||||
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 support/bashbug.sh])
|
||||
|
||||
dnl Makefile uses this timestamp file to record whether config.h is up to date.
|
||||
AC_CONFIG_COMMANDS([stamp-h], [echo timestamp > stamp-h])
|
||||
|
||||
AC_OUTPUT
|
||||
|
||||
-1161
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,6 @@
|
||||
This is the Bash FAQ, version 4.15, for Bash version 5.0.
|
||||
This is the Bash FAQ, version 4.15, for Bash version 5.1.
|
||||
|
||||
[This document 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
|
||||
|
||||
+16
-14
@@ -74,7 +74,6 @@ TEXI2DVI = ${SUPPORT_SRCDIR}/texi2dvi
|
||||
TEXI2HTML = ${SUPPORT_SRCDIR}/texi2html
|
||||
MAN2HTML = ${BUILD_DIR}/support/man2html
|
||||
HTMLPOST = ${srcdir}/htmlpost.sh
|
||||
INFOPOST = ${srcdir}/infopost.sh
|
||||
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
|
||||
@@ -108,11 +107,11 @@ BASHREF_FILES = $(srcdir)/bashref.texi $(srcdir)/fdl.texi $(srcdir)/version.texi
|
||||
|
||||
.1.ps:
|
||||
$(RM) $@
|
||||
-${GROFF} -man $< > $@
|
||||
-${GROFF} -I${srcdir} -man $< > $@
|
||||
|
||||
.1.0:
|
||||
$(RM) $@
|
||||
-${NROFF} -man $< > $@
|
||||
-${NROFF} -I${srcdir} -man $< > $@
|
||||
|
||||
.1.html:
|
||||
$(RM) $@
|
||||
@@ -128,11 +127,11 @@ BASHREF_FILES = $(srcdir)/bashref.texi $(srcdir)/fdl.texi $(srcdir)/version.texi
|
||||
|
||||
.3.ps:
|
||||
$(RM) $@
|
||||
-${GROFF} -man $< > $@
|
||||
-${GROFF} -I${srcdir} -man $< > $@
|
||||
|
||||
.3.0:
|
||||
$(RM) $@
|
||||
-${NROFF} -man $< > $@
|
||||
-${NROFF} -I${srcdir} -man $< > $@
|
||||
|
||||
.3.html:
|
||||
$(RM) $@
|
||||
@@ -173,23 +172,26 @@ html: ${HTMLFILES}
|
||||
pdf: ${PDFFILES}
|
||||
|
||||
bashref.dvi: $(BASHREF_FILES) $(HSUSER) $(RLUSER)
|
||||
$(RM) $@
|
||||
${SET_TEXINPUTS} $(TEXI2DVI) $(srcdir)/bashref.texi || { ${RM} $@ ; exit 1; }
|
||||
|
||||
bashref.info: $(BASHREF_FILES) $(HSUSER) $(RLUSER)
|
||||
$(RM) $@
|
||||
$(MAKEINFO) --no-split -I$(TEXINPUTDIR) $(srcdir)/bashref.texi
|
||||
|
||||
# experimental
|
||||
bashref.pdf: $(BASHREF_FILES) $(HSUSER) $(RLUSER)
|
||||
$(RM) $@
|
||||
${SET_TEXINPUTS} $(TEXI2PDF) $(srcdir)/bashref.texi || { ${RM} $@ ; exit 1; }
|
||||
|
||||
|
||||
# can also use:
|
||||
# $(TEXI2HTML) -menu -monolithic -I $(TEXINPUTDIR) $(srcdir)/bashref.texi
|
||||
bashref.html: $(BASHREF_FILES) $(HSUSER) $(RLUSER)
|
||||
$(MAKEINFO) --html --no-split -I$(TEXINPUTDIR) $(srcdir)/bashref.texi
|
||||
|
||||
bash.info: bashref.info
|
||||
${SHELL} ${INFOPOST} < $(srcdir)/bashref.info > $@ ; \
|
||||
bash.info: $(BASHREF_FILES) $(HSUSER) $(RLUSER)
|
||||
$(RM) $@
|
||||
$(MAKEINFO) -o $@ --no-split -I$(TEXINPUTDIR) $(srcdir)/bashref.texi
|
||||
|
||||
bash.txt: bash.1
|
||||
bash.ps: bash.1
|
||||
@@ -324,18 +326,18 @@ faq.mail: FAQ faq.headers.mail faq.version
|
||||
cat faq.headers.mail faq.version FAQ > $@
|
||||
|
||||
inst: bashref.texi
|
||||
$(SHELL) ./mkinstall
|
||||
cmp -s INSTALL ../INSTALL || mv INSTALL ../INSTALL
|
||||
$(SHELL) ${srcdir}/mkinstall -t ${topdir} -s ${srcdir}
|
||||
cmp -s INSTALL ${topdir}/INSTALL || mv INSTALL ${topdir}/INSTALL
|
||||
$(RM) INSTALL
|
||||
|
||||
posix: bashref.texi
|
||||
$(SHELL) ./mkposix
|
||||
cmp -s POSIX ../POSIX || mv POSIX ../POSIX
|
||||
$(SHELL) ${srcdir}/mkposix -t ${topdir} -s ${srcdir}
|
||||
cmp -s POSIX ${topdir}/POSIX || mv POSIX ${topdir}/POSIX
|
||||
$(RM) POSIX
|
||||
|
||||
rbash: bashref.texi
|
||||
$(SHELL) ./mkrbash
|
||||
cmp -s RBASH ../RBASH || mv RBASH ../RBASH
|
||||
$(SHELL) ${srcdir}/mkrbash -t ${topdir} -s ${srcdir}
|
||||
cmp -s RBASH ${topdir}/RBASH || mv RBASH ${topdir}/RBASH
|
||||
$(RM) RBASH
|
||||
|
||||
xdist: everything inst posix rbash
|
||||
|
||||
+1730
-1535
File diff suppressed because it is too large
Load Diff
+448
-141
File diff suppressed because it is too large
Load Diff
+510
-150
File diff suppressed because it is too large
Load Diff
+1179
-739
File diff suppressed because it is too large
Load Diff
Binary file not shown.
+8635
-8324
File diff suppressed because it is too large
Load Diff
Binary file not shown.
+2717
-2681
File diff suppressed because it is too large
Load Diff
+1179
-738
File diff suppressed because it is too large
Load Diff
Binary file not shown.
+10026
-9481
File diff suppressed because it is too large
Load Diff
+849
-385
File diff suppressed because it is too large
Load Diff
+590
-524
File diff suppressed because it is too large
Load Diff
+5
-5
@@ -7,14 +7,14 @@
|
||||
.de FN
|
||||
\fI\|\\$1\|\fP
|
||||
..
|
||||
.TH BASH_BUILTINS 1 "2004 Apr 20" "GNU Bash 5.0"
|
||||
.TH BASH_BUILTINS 1 "2021 November 22" "GNU Bash 5.2"
|
||||
.SH NAME
|
||||
bash, :, ., [, alias, bg, bind, break, builtin, caller,
|
||||
cd, command, compgen, complete,
|
||||
compopt, continue, declare, dirs, disown, echo, enable, eval, exec, exit,
|
||||
:, ., [, alias, bg, bind, break, builtin, caller,
|
||||
cd, command, compgen, complete, compopt,
|
||||
continue, declare, dirs, disown, echo, enable, eval, exec, exit,
|
||||
export, false, fc, fg, getopts, hash, help, history, jobs, kill,
|
||||
let, local, logout, mapfile, popd, printf, pushd, pwd, read,
|
||||
readonly, return, set,
|
||||
readarray, readonly, return, set,
|
||||
shift, shopt, source, suspend, test, times, trap, true, type, typeset,
|
||||
ulimit, umask, unalias, unset, wait \- bash built-in commands, see \fBbash\fR(1)
|
||||
.SH BASH BUILTIN COMMANDS
|
||||
|
||||
+2469
-2360
File diff suppressed because it is too large
Load Diff
+4
-3
@@ -48,11 +48,12 @@ RREESSTTRRIICCTTEEDD SSHHEELLLL
|
||||
|
||||
+o specifying the --pp option to the ccoommmmaanndd builtin command
|
||||
|
||||
+o turning off restricted mode with sseett ++rr or sseett ++oo rreessttrriicctteedd.
|
||||
+o turning off restricted mode with sseett ++rr or sshhoopptt --uu rree--
|
||||
ssttrriicctteedd__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
|
||||
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
|
||||
@@ -60,4 +61,4 @@ SSEEEE AALLSSOO
|
||||
|
||||
|
||||
|
||||
GNU Bash-4.0 2004 Apr 20 RBASH(1)
|
||||
Bash-5.2 2021 November 22 RBASH(1)
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH RBASH 1 "2004 Apr 20" "GNU Bash-4.0"
|
||||
.TH RBASH 1 "2021 November 22" "Bash-5.2"
|
||||
.SH NAME
|
||||
rbash \- restricted bash, see \fBbash\fR(1)
|
||||
.SH RESTRICTED SHELL
|
||||
|
||||
+5
-5
@@ -1,6 +1,6 @@
|
||||
%!PS-Adobe-3.0
|
||||
%%Creator: groff version 1.22.4
|
||||
%%CreationDate: Wed Nov 18 15:13:06 2020
|
||||
%%CreationDate: Tue Jan 11 15:02:05 2022
|
||||
%%DocumentNeededResources: font Times-Roman
|
||||
%%+ font Times-Bold
|
||||
%%DocumentSuppliedResources: procset grops 1.22 4
|
||||
@@ -276,15 +276,15 @@ F2<ad66>2.5 E F0(and)2.5 E F2<ad64>2.5 E F0(options to the)2.5 E F2
|
||||
379.2 Q(specifying the)144 379.2 Q F2<ad70>2.5 E F0(option to the)2.5 E
|
||||
F2(command)2.5 E F0 -.2(bu)2.5 G(iltin command).2 E<83>108 396 Q
|
||||
(turning of)144 396 Q 2.5(fr)-.25 G(estricted mode with)-2.5 E F2
|
||||
(set +r)2.5 E F0(or)2.5 E F2(set +o r)2.5 E(estricted)-.18 E F0(.)A
|
||||
(These restrictions are enforced after an)108 412.8 Q 2.5(ys)-.15 G
|
||||
(set +r)2.5 E F0(or)2.5 E F2(shopt -u r)2.5 E(estricted_shell)-.18 E F0
|
||||
(.)A(These restrictions are enforced after an)108 412.8 Q 2.5(ys)-.15 G
|
||||
(tartup \214les are read.)-2.5 E .429
|
||||
(When a command that is found to be a shell script is e)108 429.6 R -.15
|
||||
(xe)-.15 G(cuted,).15 E F2(rbash)2.929 E F0 .429(turns of)2.929 F 2.929
|
||||
(fa)-.25 G .729 -.15(ny r)-2.929 H .429(estrictions in the shell).15 F
|
||||
(spa)108 441.6 Q(wned to e)-.15 E -.15(xe)-.15 G(cute the script.).15 E
|
||||
F1(SEE ALSO)72 458.4 Q F0(bash\(1\))108 470.4 Q(GNU Bash-4.0)72 768 Q
|
||||
(2004 Apr 20)148.735 E(1)203.725 E 0 Cg EP
|
||||
F1(SEE ALSO)72 458.4 Q F0(bash\(1\))108 470.4 Q 157.215(Bash-5.2 2021)72
|
||||
768 R(No)2.5 E -.15(ve)-.15 G(mber 22).15 E(1)190.545 E 0 Cg EP
|
||||
%%Trailer
|
||||
end
|
||||
%%EOF
|
||||
|
||||
+6
-6
@@ -1,11 +1,11 @@
|
||||
@ignore
|
||||
Copyright (C) 1988-2020 Free Software Foundation, Inc.
|
||||
Copyright (C) 1988-2021 Free Software Foundation, Inc.
|
||||
@end ignore
|
||||
|
||||
@set LASTCHANGE Thu Oct 29 16:18:54 EDT 2020
|
||||
@set LASTCHANGE Sun Dec 26 16:02:48 EST 2021
|
||||
|
||||
@set EDITION 5.1
|
||||
@set VERSION 5.1
|
||||
@set EDITION 5.2
|
||||
@set VERSION 5.2
|
||||
|
||||
@set UPDATED 29 October 2020
|
||||
@set UPDATED-MONTH October 2020
|
||||
@set UPDATED 26 December 2021
|
||||
@set UPDATED-MONTH December 2021
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* error.c -- Functions for handling errors. */
|
||||
|
||||
/* Copyright (C) 1993-2020 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1993-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -294,6 +294,32 @@ internal_inform (format, va_alist)
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
void
|
||||
#if defined (PREFER_STDARG)
|
||||
internal_debug (const char *format, ...)
|
||||
#else
|
||||
internal_debug (format, va_alist)
|
||||
const char *format;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
#ifdef DEBUG
|
||||
va_list args;
|
||||
|
||||
error_prolog (1);
|
||||
fprintf (stderr, _("DEBUG warning: "));
|
||||
|
||||
SH_VA_START (args, format);
|
||||
|
||||
vfprintf (stderr, format, args);
|
||||
fprintf (stderr, "\n");
|
||||
|
||||
va_end (args);
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
#if defined (PREFER_STDARG)
|
||||
sys_error (const char *format, ...)
|
||||
|
||||
@@ -50,6 +50,9 @@ extern void internal_error PARAMS((const char *, ...)) __attribute__((__format_
|
||||
/* Report an internal warning. */
|
||||
extern void internal_warning PARAMS((const char *, ...)) __attribute__((__format__ (printf, 1, 2)));
|
||||
|
||||
/* Report an internal warning for debugging purposes. */
|
||||
extern void internal_debug PARAMS((const char *, ...)) __attribute__((__format__ (printf, 1, 2)));
|
||||
|
||||
/* Report an internal informational notice. */
|
||||
extern void internal_inform PARAMS((const char *, ...)) __attribute__((__format__ (printf, 1, 2)));
|
||||
|
||||
@@ -70,4 +73,10 @@ extern void err_badarraysub PARAMS((const char *));
|
||||
extern void err_unboundvar PARAMS((const char *));
|
||||
extern void err_readonly PARAMS((const char *));
|
||||
|
||||
#ifdef DEBUG
|
||||
# define INTERNAL_DEBUG(x) internal_debug x
|
||||
#else
|
||||
# define INTERNAL_DEBUG(x)
|
||||
#endif
|
||||
|
||||
#endif /* !_ERROR_H_ */
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* eval.c -- reading and evaluating commands. */
|
||||
|
||||
/* Copyright (C) 1996-2020 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1996-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -93,6 +93,7 @@ reader_loop ()
|
||||
case FORCE_EOF:
|
||||
case ERREXIT:
|
||||
case EXITPROG:
|
||||
case EXITBLTIN:
|
||||
current_command = (COMMAND *)NULL;
|
||||
if (exit_immediately_on_error)
|
||||
variable_context = 0; /* not in a function */
|
||||
@@ -139,7 +140,7 @@ reader_loop ()
|
||||
{
|
||||
if (interactive_shell == 0 && read_but_dont_execute)
|
||||
{
|
||||
set_exit_status (EXECUTION_SUCCESS);
|
||||
set_exit_status (last_command_exit_value);
|
||||
dispose_command (global_command);
|
||||
global_command = (COMMAND *)NULL;
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ host_os = @host_os@
|
||||
host_cpu = @host_cpu@
|
||||
host_vendor = @host_vendor@
|
||||
|
||||
STYLE_CFLAGS = @STYLE_CFLAGS@
|
||||
CFLAGS = @CFLAGS@
|
||||
LOCAL_CFLAGS = @LOCAL_CFLAGS@
|
||||
DEFS = @DEFS@
|
||||
@@ -76,7 +77,7 @@ INTL_BUILDDIR = ${LIBBUILD}/intl
|
||||
INTL_INC = @INTL_INC@
|
||||
LIBINTL_H = @LIBINTL_H@
|
||||
|
||||
CCFLAGS = $(DEFS) $(LOCAL_DEFS) $(LOCAL_CFLAGS) $(CPPFLAGS) $(CFLAGS)
|
||||
CCFLAGS = $(DEFS) $(LOCAL_DEFS) $(LOCAL_CFLAGS) $(CPPFLAGS) $(CFLAGS) $(STYLE_CFLAGS)
|
||||
|
||||
#
|
||||
# These values are generated for configure by ${topdir}/support/shobj-conf.
|
||||
@@ -103,8 +104,8 @@ INC = -I. -I.. -I$(topdir) -I$(topdir)/lib -I$(topdir)/builtins -I${srcdir} \
|
||||
ALLPROG = print truefalse sleep finfo logname basename dirname fdflags \
|
||||
tty pathchk tee head mkdir rmdir mkfifo mktemp printenv id whoami \
|
||||
uname sync push ln unlink realpath strftime mypid setpgid seq rm \
|
||||
accept csv cut
|
||||
OTHERPROG = necho hello cat pushd stat asort
|
||||
accept csv cut stat getconf
|
||||
OTHERPROG = necho hello cat pushd asort
|
||||
|
||||
all: $(SHOBJ_STATUS)
|
||||
|
||||
@@ -191,6 +192,9 @@ head: head.o
|
||||
printenv: printenv.o
|
||||
$(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ printenv.o $(SHOBJ_LIBS)
|
||||
|
||||
getconf: getconf.o
|
||||
$(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ getconf.o $(SHOBJ_LIBS)
|
||||
|
||||
id: id.o
|
||||
$(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ id.o $(SHOBJ_LIBS)
|
||||
|
||||
@@ -294,6 +298,7 @@ truefalse.o: truefalse.c
|
||||
accept.o: accept.c
|
||||
sleep.o: sleep.c
|
||||
finfo.o: finfo.c
|
||||
getconf.o: getconf.c getconf.h
|
||||
logname.o: logname.c
|
||||
basename.o: basename.c
|
||||
dirname.o: dirname.c
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
Some examples of ready-to-dynamic-load builtins. Most of the
|
||||
examples given are reimplementations of standard commands whose
|
||||
execution time is dominated by process startup time. The
|
||||
execution time is dominated by process startup time. Some
|
||||
exceptions are sleep, which allows you to sleep for fractions
|
||||
of a second, finfo, which provides access to the rest of the
|
||||
elements of the `stat' structure that `test' doesn't let you
|
||||
see, and pushd/popd/dirs, which allows you to compile them out
|
||||
of the shell.
|
||||
see, csv, which allows you to manipulate data from comma-separated
|
||||
values files, fdflags, which lets you change the flags associated
|
||||
with one of the shell's file descriptors, and pushd/popd/dirs, which
|
||||
allows you to compile them out of the shell.
|
||||
|
||||
All of the new builtins in ksh93 that bash didn't already have
|
||||
are included here, as is the ksh `print' builtin.
|
||||
@@ -40,6 +42,8 @@ without having to search for the right CFLAGS and LDFLAGS.
|
||||
|
||||
basename.c Return non-directory portion of pathname.
|
||||
cat.c cat(1) replacement with no options - the way cat was intended.
|
||||
csv.c Process a line of csv data and store it in an indexed array.
|
||||
cut.c Cut out selected portions of each line of a file.
|
||||
dirname.c Return directory portion of pathname.
|
||||
fdflags.c Change the flag associated with one of bash's open file descriptors.
|
||||
finfo.c Print file info.
|
||||
@@ -52,7 +56,9 @@ logname.c Print login name of current user.
|
||||
Makefile.in Simple makefile for the sample loadable builtins.
|
||||
Makefile.inc.in Sample makefile to use for loadable builtin development.
|
||||
mkdir.c Make directories.
|
||||
mypid.c Add $MYPID variable, demonstrate use of unload hook functio.n
|
||||
mkfifo.c Create named pipes.
|
||||
mktemp.c Make unique temporary file name.
|
||||
mypid.c Add $MYPID variable, demonstrate use of unload hook function.
|
||||
necho.c echo without options or argument interpretation.
|
||||
pathchk.c Check pathnames for validity and portability.
|
||||
print.c Loadable ksh-93 style print builtin.
|
||||
|
||||
+27
-16
@@ -30,6 +30,7 @@
|
||||
#include "bashtypes.h"
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <limits.h>
|
||||
#include "typemax.h"
|
||||
|
||||
#include <sys/socket.h>
|
||||
@@ -44,11 +45,10 @@ int
|
||||
accept_builtin (list)
|
||||
WORD_LIST *list;
|
||||
{
|
||||
WORD_LIST *l;
|
||||
SHELL_VAR *v;
|
||||
intmax_t iport;
|
||||
int opt;
|
||||
char *tmoutarg, *fdvar, *rhostvar, *rhost;
|
||||
char *tmoutarg, *fdvar, *rhostvar, *rhost, *bindaddr;
|
||||
unsigned short uport;
|
||||
int servsock, clisock;
|
||||
struct sockaddr_in server, client;
|
||||
@@ -56,13 +56,16 @@ accept_builtin (list)
|
||||
struct timeval timeval;
|
||||
struct linger linger = { 0, 0 };
|
||||
|
||||
rhostvar = tmoutarg = fdvar = rhost = (char *)NULL;
|
||||
rhostvar = tmoutarg = fdvar = rhost = bindaddr = (char *)NULL;
|
||||
|
||||
reset_internal_getopt ();
|
||||
while ((opt = internal_getopt (list, "r:t:v:")) != -1)
|
||||
while ((opt = internal_getopt (list, "b:r:t:v:")) != -1)
|
||||
{
|
||||
switch (opt)
|
||||
{
|
||||
case 'b':
|
||||
bindaddr = list_optarg;
|
||||
break;
|
||||
case 'r':
|
||||
rhostvar = list_optarg;
|
||||
break;
|
||||
@@ -125,7 +128,17 @@ accept_builtin (list)
|
||||
memset ((char *)&server, 0, sizeof (server));
|
||||
server.sin_family = AF_INET;
|
||||
server.sin_port = htons(uport);
|
||||
server.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
server.sin_addr.s_addr = bindaddr ? inet_addr (bindaddr) : htonl(INADDR_ANY);
|
||||
|
||||
if (server.sin_addr.s_addr == INADDR_NONE)
|
||||
{
|
||||
builtin_error ("invalid address: %s", strerror (errno));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
opt = 1;
|
||||
setsockopt (servsock, SOL_SOCKET, SO_REUSEADDR, (void *)&opt, sizeof (opt));
|
||||
setsockopt (servsock, SOL_SOCKET, SO_LINGER, (void *)&linger, sizeof (linger));
|
||||
|
||||
if (bind (servsock, (struct sockaddr *)&server, sizeof (server)) < 0)
|
||||
{
|
||||
@@ -134,10 +147,6 @@ accept_builtin (list)
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
opt = 1;
|
||||
setsockopt (servsock, SOL_SOCKET, SO_REUSEADDR, (void *)&opt, sizeof (opt));
|
||||
setsockopt (servsock, SOL_SOCKET, SO_LINGER, (void *)&linger, sizeof (linger));
|
||||
|
||||
if (listen (servsock, 1) < 0)
|
||||
{
|
||||
builtin_error ("listen failure: %s", strerror (errno));
|
||||
@@ -154,12 +163,12 @@ accept_builtin (list)
|
||||
|
||||
opt = select (servsock+1, &iofds, 0, 0, &timeval);
|
||||
if (opt < 0)
|
||||
builtin_error ("select failure: %s", strerror (errno));
|
||||
builtin_error ("select failure: %s", strerror (errno));
|
||||
if (opt <= 0)
|
||||
{
|
||||
close (servsock);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
{
|
||||
close (servsock);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
clientlen = sizeof (client);
|
||||
@@ -193,7 +202,7 @@ accept_bind_variable (varname, intval)
|
||||
char ibuf[INT_STRLEN_BOUND (int) + 1], *p;
|
||||
|
||||
p = fmtulong (intval, 10, ibuf, sizeof (ibuf), 0);
|
||||
v = builtin_bind_variable (varname, p, 0);
|
||||
v = builtin_bind_variable (varname, p, 0); /* XXX */
|
||||
if (v == 0 || readonly_p (v) || noassign_p (v))
|
||||
builtin_error ("%s: cannot set variable", varname);
|
||||
return (v != 0);
|
||||
@@ -205,6 +214,8 @@ char *accept_doc[] = {
|
||||
"This builtin allows a bash script to act as a TCP/IP server.",
|
||||
"",
|
||||
"Options, if supplied, have the following meanings:",
|
||||
" -b address use ADDRESS as the IP address to listen on; the",
|
||||
" default is INADDR_ANY",
|
||||
" -t timeout wait TIMEOUT seconds for a connection. TIMEOUT may",
|
||||
" be a decimal number including a fractional portion",
|
||||
" -v varname store the numeric file descriptor of the connected",
|
||||
@@ -229,6 +240,6 @@ struct builtin accept_struct = {
|
||||
accept_builtin, /* function implementing the builtin */
|
||||
BUILTIN_ENABLED, /* initial flags for builtin */
|
||||
accept_doc, /* array of long documentation strings. */
|
||||
"accept [-t timeout] [-v varname] [-r addrvar ] port", /* usage synopsis; becomes short_doc */
|
||||
"accept [-b address] [-t timeout] [-v varname] [-r addrvar ] port", /* usage synopsis; becomes short_doc */
|
||||
0 /* reserved for internal use */
|
||||
};
|
||||
|
||||
@@ -36,13 +36,25 @@ extern char *strerror ();
|
||||
extern char **make_builtin_argv ();
|
||||
|
||||
static int
|
||||
fcopy(fd)
|
||||
fcopy(fd, fn)
|
||||
int fd;
|
||||
char *fn;
|
||||
{
|
||||
char buf[1024], *s;
|
||||
int n, w, e;
|
||||
|
||||
while (n = read(fd, buf, sizeof (buf))) {
|
||||
if (n < 0) {
|
||||
e = errno;
|
||||
write(2, "cat: read error: ", 18);
|
||||
write(2, fn, strlen(fn));
|
||||
write(2, ": ", 2);
|
||||
s = strerror(e);
|
||||
write(2, s, strlen(s));
|
||||
write(2, "\n", 1);
|
||||
return 1;
|
||||
}
|
||||
QUIT;
|
||||
w = write(1, buf, n);
|
||||
if (w != n) {
|
||||
e = errno;
|
||||
@@ -52,6 +64,7 @@ int fd;
|
||||
write(2, "\n", 1);
|
||||
return 1;
|
||||
}
|
||||
QUIT;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -65,9 +78,10 @@ char **argv;
|
||||
char *s;
|
||||
|
||||
if (argc == 1)
|
||||
return (fcopy(0));
|
||||
return (fcopy(0, "standard input"));
|
||||
|
||||
for (i = r = 1; i < argc; i++) {
|
||||
QUIT;
|
||||
if (argv[i][0] == '-' && argv[i][1] == '\0')
|
||||
fd = 0;
|
||||
else {
|
||||
@@ -82,10 +96,11 @@ char **argv;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
r = fcopy(fd);
|
||||
r = fcopy(fd, argv[i]);
|
||||
if (fd != 0)
|
||||
close(fd);
|
||||
}
|
||||
QUIT;
|
||||
return (r);
|
||||
}
|
||||
|
||||
@@ -97,6 +112,7 @@ WORD_LIST *list;
|
||||
int c, r;
|
||||
|
||||
v = make_builtin_argv(list, &c);
|
||||
QUIT;
|
||||
r = cat_main(c, v);
|
||||
free(v);
|
||||
|
||||
|
||||
@@ -415,10 +415,14 @@ cutfile (v, list, ops)
|
||||
#endif
|
||||
|
||||
while ((n = zgetline (fd, &line, &llen, '\n', unbuffered_read)) != -1)
|
||||
{
|
||||
QUIT;
|
||||
cutline (v, line, ops); /* can modify line */
|
||||
}
|
||||
if (fd > 0)
|
||||
close (fd);
|
||||
|
||||
QUIT;
|
||||
if (l)
|
||||
l = l->next;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
Copyright (C) 2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash.
|
||||
Bash is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Bash is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/* getconf.h -- replacement definitions for ones the system doesn't provide
|
||||
and don't appear in <typemax.h> */
|
||||
|
||||
#ifndef _GETCONF_H
|
||||
#define _GETCONF_H
|
||||
|
||||
/* Some systems do not define these; use POSIX.2 minimum recommended values. */
|
||||
#ifndef _POSIX2_COLL_WEIGHTS_MAX
|
||||
# define _POSIX2_COLL_WEIGHTS_MAX 2
|
||||
#endif
|
||||
|
||||
/* If we're on a posix system, but the system doesn't define the necessary
|
||||
constants, use posix.1 minimum values. */
|
||||
#if defined (_POSIX_VERSION)
|
||||
|
||||
#ifndef _POSIX_ARG_MAX
|
||||
# define _POSIX_ARG_MAX 4096
|
||||
#endif
|
||||
#ifndef _POSIX_CHILD_MAX
|
||||
# define _POSIX_CHILD_MAX 6
|
||||
#endif
|
||||
#ifndef _POSIX_LINK_MAX
|
||||
# define _POSIX_LINK_MAX 8
|
||||
#endif
|
||||
#ifndef _POSIX_MAX_CANON
|
||||
# define _POSIX_MAX_CANON 255
|
||||
#endif
|
||||
#ifndef _POSIX_MAX_INPUT
|
||||
# define _POSIX_MAX_INPUT 255
|
||||
#endif
|
||||
#ifndef _POSIX_NAME_MAX
|
||||
# define _POSIX_NAME_MAX 14
|
||||
#endif
|
||||
#ifndef _POSIX_NGROUPS_MAX
|
||||
# define _POSIX_NGROUPS_MAX 0
|
||||
#endif
|
||||
#ifndef _POSIX_OPEN_MAX
|
||||
# define _POSIX_OPEN_MAX 16
|
||||
#endif
|
||||
#ifndef _POSIX_PATH_MAX
|
||||
# define _POSIX_PATH_MAX 255
|
||||
#endif
|
||||
#ifndef _POSIX_PIPE_BUF
|
||||
# define _POSIX_PIPE_BUF 512
|
||||
#endif
|
||||
#ifndef _POSIX_SSIZE_MAX
|
||||
# define _POSIX_SSIZE_MAX 32767
|
||||
#endif
|
||||
#ifndef _POSIX_STREAM_MAX
|
||||
# define _POSIX_STREAM_MAX 8
|
||||
#endif
|
||||
#ifndef _POSIX_TZNAME_MAX
|
||||
# define _POSIX_TZNAME_MAX 3
|
||||
#endif
|
||||
|
||||
#ifndef _POSIX2_BC_BASE_MAX
|
||||
# define _POSIX2_BC_BASE_MAX 99
|
||||
#endif
|
||||
#ifndef _POSIX2_BC_DIM_MAX
|
||||
# define _POSIX2_BC_DIM_MAX 2048
|
||||
#endif
|
||||
#ifndef _POSIX2_BC_SCALE_MAX
|
||||
# define _POSIX2_BC_SCALE_MAX 99
|
||||
#endif
|
||||
#ifndef _POSIX2_BC_STRING_MAX
|
||||
# define _POSIX2_BC_STRING_MAX 1000
|
||||
#endif
|
||||
#ifndef _POSIX2_EQUIV_CLASS_MAX
|
||||
# define _POSIX2_EQUIV_CLASS_MAX 2
|
||||
#endif
|
||||
#ifndef _POSIX2_EXPR_NEST_MAX
|
||||
# define _POSIX2_EXPR_NEST_MAX 32
|
||||
#endif
|
||||
#ifndef _POSIX2_LINE_MAX
|
||||
# define _POSIX2_LINE_MAX 2048
|
||||
#endif
|
||||
#ifndef _POSIX2_RE_DUP_MAX
|
||||
# define _POSIX2_RE_DUP_MAX 255
|
||||
#endif
|
||||
|
||||
#endif /* _POSIX_VERSION */
|
||||
|
||||
/* ANSI/ISO C, POSIX.1-200x, XPG 4.2, and C language type limits.
|
||||
Defined only if the system include files and <typemax.h> don't. */
|
||||
|
||||
#ifndef CHAR_MAX
|
||||
# define CHAR_MAX 127
|
||||
#endif
|
||||
#ifndef CHAR_MIN
|
||||
# define CHAR_MIN -128
|
||||
#endif
|
||||
#ifndef SCHAR_MAX
|
||||
# define SCHAR_MAX 127
|
||||
#endif
|
||||
#ifndef SCHAR_MIN
|
||||
# define SCHAR_MIN -128
|
||||
#endif
|
||||
|
||||
#ifndef INT_BIT
|
||||
# define INT_BIT (sizeof (int) * CHAR_BIT)
|
||||
#endif
|
||||
|
||||
#ifndef LONG_BIT
|
||||
# define LONG_BIT (sizeof (long int) * CHAR_BIT)
|
||||
#endif
|
||||
|
||||
#ifndef WORD_BIT
|
||||
# define WORD_BIT (sizeof (int) * CHAR_BIT)
|
||||
#endif
|
||||
|
||||
#if !defined (PRIdMAX)
|
||||
# if HAVE_LONG_LONG
|
||||
# define PRIdMAX "lld"
|
||||
# else
|
||||
# define PRIdMAX "ld"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* _GETCONF_H */
|
||||
@@ -79,11 +79,13 @@ file_head (fp, cnt)
|
||||
{
|
||||
while ((ch = getc (fp)) != EOF)
|
||||
{
|
||||
QUIT;
|
||||
if (putchar (ch) == EOF)
|
||||
{
|
||||
builtin_error ("write error: %s", strerror (errno));
|
||||
return EXECUTION_FAILURE;
|
||||
}
|
||||
QUIT;
|
||||
if (ch == '\n')
|
||||
break;
|
||||
}
|
||||
@@ -141,6 +143,7 @@ head_builtin (list)
|
||||
printf ("%s==> %s <==\n", opt ? "" : "\n", l->word->word);
|
||||
opt = 0;
|
||||
}
|
||||
QUIT;
|
||||
rval = file_head (fp, nline);
|
||||
fclose (fp);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
/*
|
||||
* realpath -- canonicalize pathnames, resolving symlinks
|
||||
*
|
||||
* usage: realpath [-csv] pathname [pathname...]
|
||||
* usage: realpath [-csv] [-a name] pathname [pathname...]
|
||||
*
|
||||
* options: -c check whether or not each resolved path exists
|
||||
* options: -a name assign each canonicalized pathname to indexed array
|
||||
* variable NAME
|
||||
* -c check whether or not each resolved path exists
|
||||
* -s no output, exit status determines whether path is valid
|
||||
* -S strip . and .. from the pathname only, no symlink resolution
|
||||
* -v produce verbose output
|
||||
*
|
||||
*
|
||||
@@ -19,7 +22,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (C) 1999-2009 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999-2009,2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash.
|
||||
Bash is free software: you can redistribute it and/or modify
|
||||
@@ -61,28 +64,46 @@ extern int errno;
|
||||
extern char *sh_realpath();
|
||||
|
||||
int
|
||||
realpath_builtin(list)
|
||||
WORD_LIST *list;
|
||||
realpath_builtin(WORD_LIST *list)
|
||||
{
|
||||
int opt, cflag, vflag, sflag, es;
|
||||
char *r, realbuf[PATH_MAX], *p;
|
||||
int opt, cflag, vflag, sflag, Sflag, aflag, es;
|
||||
char *r, realbuf[PATH_MAX], *p, *newpath;
|
||||
struct stat sb;
|
||||
#if defined (ARRAY_VARS)
|
||||
arrayind_t ind;
|
||||
char *aname;
|
||||
SHELL_VAR *v;
|
||||
#endif
|
||||
|
||||
if (list == 0) {
|
||||
builtin_usage();
|
||||
return (EX_USAGE);
|
||||
}
|
||||
|
||||
vflag = cflag = sflag = 0;
|
||||
vflag = cflag = sflag = aflag = Sflag = 0;
|
||||
#if defined (ARRAY_VARS)
|
||||
aname = NULL;
|
||||
v = NULL;
|
||||
ind = 0;
|
||||
#endif
|
||||
reset_internal_getopt();
|
||||
while ((opt = internal_getopt (list, "csv")) != -1) {
|
||||
while ((opt = internal_getopt (list, "a:Scsv")) != -1) {
|
||||
switch (opt) {
|
||||
#if defined (ARRAY_VARS)
|
||||
case 'a':
|
||||
aflag = 1;
|
||||
aname = list_optarg;
|
||||
break;
|
||||
#endif
|
||||
case 'c':
|
||||
cflag = 1;
|
||||
break;
|
||||
case 's':
|
||||
sflag = 1;
|
||||
break;
|
||||
case 'S':
|
||||
Sflag = 1;
|
||||
break;
|
||||
case 'v':
|
||||
vflag = 1;
|
||||
break;
|
||||
@@ -100,26 +121,62 @@ WORD_LIST *list;
|
||||
return (EX_USAGE);
|
||||
}
|
||||
|
||||
#if defined (ARRAY_VARS)
|
||||
if (aflag && legal_identifier (aname) == 0) {
|
||||
sh_invalidid(aname);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
if (aname && builtin_unbind_variable (aname) == -2)
|
||||
return (EXECUTION_FAILURE);
|
||||
if (aname) {
|
||||
v = find_or_make_array_variable (aname, 1);
|
||||
if (v == 0 || readonly_p (v) || noassign_p (v)) {
|
||||
if (v && readonly_p (v))
|
||||
err_readonly (aname);
|
||||
return (EXECUTION_FAILURE);
|
||||
} else if (array_p (v) == 0) {
|
||||
builtin_error ("%s: not an indexed array", aname);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
if (invisible_p (v))
|
||||
VUNSETATTR (v, att_invisible);
|
||||
array_flush (array_cell (v));
|
||||
}
|
||||
#endif
|
||||
|
||||
for (es = EXECUTION_SUCCESS; list; list = list->next) {
|
||||
p = list->word->word;
|
||||
r = sh_realpath(p, realbuf);
|
||||
if (Sflag) {
|
||||
/* sh_canonpath doesn't convert to absolute pathnames */
|
||||
newpath = make_absolute(p, get_string_value("PWD"));
|
||||
r = sh_canonpath(newpath, PATH_CHECKDOTDOT|PATH_CHECKEXISTS);
|
||||
free(newpath);
|
||||
} else
|
||||
r = sh_realpath(p, realbuf);
|
||||
if (r == 0) {
|
||||
es = EXECUTION_FAILURE;
|
||||
if (sflag == 0)
|
||||
builtin_error("%s: cannot resolve: %s", p, strerror(errno));
|
||||
continue;
|
||||
}
|
||||
if (cflag && (stat(realbuf, &sb) < 0)) {
|
||||
if (cflag && (stat(r, &sb) < 0)) {
|
||||
es = EXECUTION_FAILURE;
|
||||
if (sflag == 0)
|
||||
builtin_error("%s: %s", p, strerror(errno));
|
||||
continue;
|
||||
}
|
||||
if (sflag == 0) {
|
||||
if (vflag)
|
||||
printf ("%s -> ", p);
|
||||
printf("%s\n", realbuf);
|
||||
if (aflag) {
|
||||
bind_array_element (v, ind, r, 0);
|
||||
ind++;
|
||||
} else {
|
||||
if (vflag)
|
||||
printf ("%s -> ", p);
|
||||
printf("%s\n", r);
|
||||
}
|
||||
}
|
||||
if (Sflag)
|
||||
free (r);
|
||||
}
|
||||
return es;
|
||||
}
|
||||
@@ -128,10 +185,14 @@ char *realpath_doc[] = {
|
||||
"Display pathname in canonical form.",
|
||||
"",
|
||||
"Display the canonicalized version of each PATHNAME argument, resolving",
|
||||
"symbolic links. The -c option checks whether or not each resolved name",
|
||||
"exists. The -s option produces no output; the exit status determines the",
|
||||
"validity of each PATHNAME. The -v option produces verbose output. The",
|
||||
"exit status is 0 if each PATHNAME was resolved; non-zero otherwise.",
|
||||
"symbolic links.",
|
||||
"If the -S option is supplied, canonicalize . and .. pathname components",
|
||||
"without resolving symbolic links.",
|
||||
"The -c option checks whether or not each resolved name exists.",
|
||||
"The -s option produces no output; the exit status determines the",
|
||||
"validity of each PATHNAME.",
|
||||
"The -v option produces verbose output.",
|
||||
"The exit status is 0 if each PATHNAME was resolved; non-zero otherwise.",
|
||||
(char *)NULL
|
||||
};
|
||||
|
||||
@@ -140,6 +201,6 @@ struct builtin realpath_struct = {
|
||||
realpath_builtin, /* function implementing the builtin */
|
||||
BUILTIN_ENABLED, /* initial flags for builtin */
|
||||
realpath_doc, /* array of long documentation strings */
|
||||
"realpath [-csv] pathname [pathname...]", /* usage synopsis */
|
||||
"realpath [-Scsv] pathname [pathname...]", /* usage synopsis */
|
||||
0 /* reserved for internal use */
|
||||
};
|
||||
|
||||
@@ -59,7 +59,8 @@ _remove_directory(const char *dirname)
|
||||
char *fname;
|
||||
int fnsize;
|
||||
#endif
|
||||
|
||||
|
||||
QUIT;
|
||||
if (*dp->d_name == '.' && (dp->d_name[1] == 0 || (dp->d_name[1] == '.' && dp->d_name[2] == 0)))
|
||||
continue;
|
||||
|
||||
@@ -76,6 +77,7 @@ _remove_directory(const char *dirname)
|
||||
#ifndef __GNUC__
|
||||
free (fname);
|
||||
#endif
|
||||
QUIT;
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
@@ -98,6 +100,7 @@ rm_file(const char *fname)
|
||||
if (unlink (fname) == 0)
|
||||
return 0;
|
||||
|
||||
QUIT;
|
||||
/* If FNAME is a directory glibc returns EISDIR but correct POSIX value
|
||||
would be EPERM. If we get that error and FNAME is a directory and -r
|
||||
was supplied, recursively remove the directory and its contents */
|
||||
@@ -155,6 +158,7 @@ rm_builtin (list)
|
||||
|
||||
for (l = list; l; l = l->next)
|
||||
{
|
||||
QUIT;
|
||||
if (rm_file(l->word->word) && force == 0)
|
||||
rval = EXECUTION_FAILURE;
|
||||
}
|
||||
|
||||
+88
-10
@@ -2,10 +2,12 @@
|
||||
* sleep -- sleep for fractions of a second
|
||||
*
|
||||
* usage: sleep seconds[.fraction]
|
||||
*
|
||||
* as an extension, we support the GNU time interval format (2m20s)
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (C) 1999-2020 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash.
|
||||
Bash is free software: you can redistribute it and/or modify
|
||||
@@ -44,13 +46,80 @@
|
||||
#include <stdio.h>
|
||||
#include "chartypes.h"
|
||||
|
||||
#include "shell.h"
|
||||
#include "builtins.h"
|
||||
#include "common.h"
|
||||
#include "loadables.h"
|
||||
|
||||
#define S_SEC 1
|
||||
#define S_MIN (60*S_SEC)
|
||||
#define S_HOUR (60*S_MIN)
|
||||
#define S_DAY (24*S_HOUR)
|
||||
|
||||
static int
|
||||
parse_gnutimefmt (char *string, long *sp, long *up)
|
||||
{
|
||||
int c, r;
|
||||
char *s, *ep;
|
||||
long tsec, tusec, accumsec, accumusec, t;
|
||||
int mult;
|
||||
|
||||
tsec = tusec = 0;
|
||||
accumsec = accumusec = 0;
|
||||
mult = 1;
|
||||
|
||||
for (s = string; s && *s; s++) {
|
||||
r = uconvert(s, &accumsec, &accumusec, &ep);
|
||||
if (r == 0 && *ep == 0)
|
||||
return r;
|
||||
c = *ep;
|
||||
mult = 1;
|
||||
switch (c) {
|
||||
case '\0':
|
||||
case 's':
|
||||
mult = S_SEC;
|
||||
break;
|
||||
case 'm':
|
||||
mult = S_MIN;
|
||||
break;
|
||||
case 'h':
|
||||
mult = S_HOUR;
|
||||
break;
|
||||
case 'd':
|
||||
mult = S_DAY;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* multiply the accumulated value by the multiplier */
|
||||
t = accumusec * mult;
|
||||
accumsec = accumsec * mult + (t / 1000000);
|
||||
accumusec = t % 1000000;
|
||||
|
||||
/* add to running total */
|
||||
tsec += accumsec;
|
||||
tusec += accumusec;
|
||||
if (tusec >= 1000000) {
|
||||
tsec++;
|
||||
tusec -= 1000000;
|
||||
}
|
||||
|
||||
/* reset and continue */
|
||||
accumsec = accumusec = 0;
|
||||
mult = 1;
|
||||
if (c == 0)
|
||||
break;
|
||||
s = ep;
|
||||
}
|
||||
|
||||
if (sp)
|
||||
*sp = tsec;
|
||||
if (up)
|
||||
*up = tusec;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
sleep_builtin (list)
|
||||
WORD_LIST *list;
|
||||
sleep_builtin (WORD_LIST *list)
|
||||
{
|
||||
long sec, usec;
|
||||
char *ep;
|
||||
@@ -72,14 +141,22 @@ WORD_LIST *list;
|
||||
}
|
||||
|
||||
r = uconvert(list->word->word, &sec, &usec, &ep);
|
||||
/* Maybe postprocess conversion failures here based on EP */
|
||||
/*
|
||||
* Maybe postprocess conversion failures here based on EP
|
||||
*
|
||||
* A heuristic: if the conversion failed, but the argument appears to
|
||||
* contain a GNU-like interval specifier (e.g. "1m30s"), try to parse
|
||||
* it. If we can't, return the right exit code to tell
|
||||
* execute_builtin to try and execute a disk command instead.
|
||||
*/
|
||||
if (r == 0 && (strchr ("dhms", *ep) || strpbrk (list->word->word, "dhms")))
|
||||
r = parse_gnutimefmt (list->word->word, &sec, &usec);
|
||||
|
||||
if (r) {
|
||||
if (r) {
|
||||
fsleep(sec, usec);
|
||||
QUIT;
|
||||
return(EXECUTION_SUCCESS);
|
||||
}
|
||||
|
||||
}
|
||||
builtin_error("%s: bad sleep interval", list->word->word);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
@@ -88,6 +165,7 @@ static char *sleep_doc[] = {
|
||||
"Suspend execution for specified period.",
|
||||
""
|
||||
"sleep suspends execution for a minimum of SECONDS[.FRACTION] seconds.",
|
||||
"As an extension, sleep accepts GNU-style time intervals (e.g., 2m30s).",
|
||||
(char *)NULL
|
||||
};
|
||||
|
||||
|
||||
+40
-16
@@ -72,6 +72,13 @@ static char *arraysubs[] =
|
||||
0
|
||||
};
|
||||
|
||||
#define DEFTIMEFMT "%a %b %e %k:%M:%S %Z %Y"
|
||||
#ifndef TIMELEN_MAX
|
||||
# define TIMELEN_MAX 128
|
||||
#endif
|
||||
|
||||
static char *stattime (time_t, const char *);
|
||||
|
||||
static int
|
||||
getstat (fname, flags, sp)
|
||||
const char *fname;
|
||||
@@ -253,24 +260,33 @@ statmode(mode)
|
||||
}
|
||||
|
||||
static char *
|
||||
stattime (t)
|
||||
stattime (t, timefmt)
|
||||
time_t t;
|
||||
const char *timefmt;
|
||||
{
|
||||
char *tbuf, *ret;
|
||||
const char *fmt;
|
||||
size_t tlen;
|
||||
struct tm *tm;
|
||||
|
||||
fmt = timefmt ? timefmt : DEFTIMEFMT;
|
||||
tm = localtime (&t);
|
||||
|
||||
ret = xmalloc (TIMELEN_MAX);
|
||||
|
||||
tlen = strftime (ret, TIMELEN_MAX, fmt, tm);
|
||||
if (tlen == 0)
|
||||
tlen = strftime (ret, TIMELEN_MAX, DEFTIMEFMT, tm);
|
||||
|
||||
tbuf = ctime (&t);
|
||||
tlen = strlen (tbuf);
|
||||
ret = savestring (tbuf);
|
||||
ret[tlen-1] = '\0';
|
||||
return ret;
|
||||
}
|
||||
|
||||
static char *
|
||||
statval (which, fname, flags, sp)
|
||||
statval (which, fname, flags, fmt, sp)
|
||||
int which;
|
||||
char *fname;
|
||||
int flags;
|
||||
char *fmt;
|
||||
struct stat *sp;
|
||||
{
|
||||
int temp;
|
||||
@@ -296,11 +312,11 @@ statval (which, fname, flags, sp)
|
||||
case ST_SIZE:
|
||||
return itos (sp->st_size);
|
||||
case ST_ATIME:
|
||||
return ((flags & 2) ? stattime (sp->st_atime) : itos (sp->st_atime));
|
||||
return ((flags & 2) ? stattime (sp->st_atime, fmt) : itos (sp->st_atime));
|
||||
case ST_MTIME:
|
||||
return ((flags & 2) ? stattime (sp->st_mtime) : itos (sp->st_mtime));
|
||||
return ((flags & 2) ? stattime (sp->st_mtime, fmt) : itos (sp->st_mtime));
|
||||
case ST_CTIME:
|
||||
return ((flags & 2) ? stattime (sp->st_ctime) : itos (sp->st_ctime));
|
||||
return ((flags & 2) ? stattime (sp->st_ctime, fmt) : itos (sp->st_ctime));
|
||||
case ST_BLKSIZE:
|
||||
return itos (sp->st_blksize);
|
||||
case ST_BLOCKS:
|
||||
@@ -316,11 +332,12 @@ statval (which, fname, flags, sp)
|
||||
}
|
||||
|
||||
static int
|
||||
loadstat (vname, var, fname, flags, sp)
|
||||
loadstat (vname, var, fname, flags, fmt, sp)
|
||||
char *vname;
|
||||
SHELL_VAR *var;
|
||||
char *fname;
|
||||
int flags;
|
||||
char *fmt;
|
||||
struct stat *sp;
|
||||
{
|
||||
int i;
|
||||
@@ -330,7 +347,7 @@ loadstat (vname, var, fname, flags, sp)
|
||||
for (i = 0; arraysubs[i]; i++)
|
||||
{
|
||||
key = savestring (arraysubs[i]);
|
||||
value = statval (i, fname, flags, sp);
|
||||
value = statval (i, fname, flags, fmt, sp);
|
||||
v = bind_assoc_variable (var, vname, key, value, ASS_FORCE);
|
||||
}
|
||||
return 0;
|
||||
@@ -341,15 +358,16 @@ stat_builtin (list)
|
||||
WORD_LIST *list;
|
||||
{
|
||||
int opt, flags;
|
||||
char *aname, *fname;
|
||||
char *aname, *fname, *timefmt;
|
||||
struct stat st;
|
||||
SHELL_VAR *v;
|
||||
|
||||
aname = "STAT";
|
||||
flags = 0;
|
||||
timefmt = 0;
|
||||
|
||||
reset_internal_getopt ();
|
||||
while ((opt = internal_getopt (list, "A:Ll")) != -1)
|
||||
while ((opt = internal_getopt (list, "A:F:Ll")) != -1)
|
||||
{
|
||||
switch (opt)
|
||||
{
|
||||
@@ -362,6 +380,9 @@ stat_builtin (list)
|
||||
case 'l':
|
||||
flags |= 2;
|
||||
break;
|
||||
case 'F':
|
||||
timefmt = list_optarg;
|
||||
break;
|
||||
CASE_HELPOPT;
|
||||
default:
|
||||
builtin_usage ();
|
||||
@@ -391,7 +412,7 @@ stat_builtin (list)
|
||||
builtin_error ("%s: cannot create variable", aname);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
if (loadstat (aname, v, fname, flags, &st) < 0)
|
||||
if (loadstat (aname, v, fname, flags, timefmt, &st) < 0)
|
||||
{
|
||||
builtin_error ("%s: cannot assign file status information", aname);
|
||||
unbind_variable (aname);
|
||||
@@ -412,8 +433,11 @@ char *stat_doc[] = {
|
||||
"by the -A option. The default array name is STAT. If the -L",
|
||||
"option is supplied, stat does not resolve symbolic links and",
|
||||
"reports information about the link itself. The -l option results",
|
||||
"in longer-form listings for some of the fields. The exit status is 0",
|
||||
"unless the stat fails or assigning the array is unsuccessful.",
|
||||
"in longer-form listings for some of the fields. When -l is used,",
|
||||
"the -F option supplies a format string passed to strftime(3) to",
|
||||
"display the file time information.",
|
||||
"The exit status is 0 unless the stat fails or assigning the array",
|
||||
"is unsuccessful.",
|
||||
(char *)NULL
|
||||
};
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/* See Makefile for compilation details. */
|
||||
|
||||
/*
|
||||
Copyright (C) 1999-2009 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash.
|
||||
Bash is free software: you can redistribute it and/or modify
|
||||
@@ -121,6 +121,7 @@ tee_builtin (list)
|
||||
fl = fl->next;
|
||||
fl->next = (FLIST *)NULL;
|
||||
}
|
||||
QUIT;
|
||||
}
|
||||
|
||||
while ((nr = read(0, buf, TEE_BUFSIZE)) > 0)
|
||||
@@ -137,6 +138,7 @@ tee_builtin (list)
|
||||
break;
|
||||
}
|
||||
bp += nw;
|
||||
QUIT;
|
||||
}
|
||||
while (n -= nw);
|
||||
}
|
||||
@@ -156,7 +158,8 @@ tee_builtin (list)
|
||||
tee_flist = tee_flist->next;
|
||||
free (fl);
|
||||
}
|
||||
|
||||
|
||||
QUIT;
|
||||
return (rval);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/* See Makefile for compilation details. */
|
||||
|
||||
/*
|
||||
Copyright (C) 1999-2009 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash.
|
||||
Bash is free software: you can redistribute it and/or modify
|
||||
@@ -55,6 +55,7 @@ tty_builtin (list)
|
||||
list = loptend;
|
||||
|
||||
t = ttyname (0);
|
||||
QUIT;
|
||||
if (sflag == 0)
|
||||
puts (t ? t : "not a tty");
|
||||
return (t ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
|
||||
|
||||
Executable → Regular
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user