bash-5.1 distribution sources and documentation

This commit is contained in:
Chet Ramey
2020-12-06 15:51:17 -05:00
parent 36f2c406ff
commit 8868edaf22
828 changed files with 94641 additions and 56509 deletions
+657 -23
View File
@@ -1,3 +1,637 @@
This document details the changes between this version, bash-5.1-rc3, and
the previous version, bash-5.1-rc2.
1. Changes to Bash
a. The `assoc_expand_once' option now affects the evaluation of the -v primary
to test and the [[ compound command.
2. Changes to Readline
a. Fixed a bug that could cause point to be set beyond the end of the line
buffer when aborting an incremental search.
3. New Features in Bash
4. New Features in Readline
------------------------------------------------------------------------------
This document details the changes between this version, bash-5.1-rc2, and
the previous version, bash-5.1-rc1.
1. Changes to Bash
a. Process substitutions started from an interactive shell no longer have their
standard input implicitly redirected from /dev/null.
b. Fixed an issue with setting the SIGINT trap handler in an interactive shell
when temporarily running $PROMPT_COMMAND non-interactively.
2. Changes to Readline
a. Terminals that are named "dumb" or unknown do not enable bracketed paste
by default.
b. Ensure that disabling bracketed paste turns off highlighting the incremental
search string when the search is successful.
3. New Features in Bash
4. New Features in Readline
------------------------------------------------------------------------------
This document details the changes between this version, bash-5.1-rc1, and
the previous version, bash-5.1-beta.
1. Changes to Bash
a. Fixed an inconsistency in the way HISTCMD is calculated when it's expanded
during a multi-line command.
b. Modified the change to here-document expansion containing backslash-quoted
double quotes.
c. Fixed a case where the shells's exit status could be greater than 255.
d. Modified changed to process substitution so the executed command has its
stdin redirected from /dev/null if it was previously interactive and
reading commands from the terminal.
2. New Features in Bash
a. There is a new contributed loadable builtin: asort.
3. Changes to Readline
a. Fixed a bug that could cause an application with an application-specific
redisplay function to crash if the line data structures had not been
initialized.
4. New Features in Readline
------------------------------------------------------------------------------
This document details the changes between this version, bash-5.1-beta, and
the previous version, bash-5.1-alpha.
1. Changes to Bash
a. Fixed a bug that caused name references to variables to not update the
referenced variable's assignment side effects.
b. Tightened up the parameter transformation error checking for invalid
transformation operators.
c. System-specific changes for: FreeBSD
d. A few minor changes to move potential uses of stdio functions out of signal
handling paths.
e. Make sure SIGCHLD is blocked in all cases where waitchld() is not called
from a signal handler.
f. Changed `command' builtin processing so it no longer starts an extra process
when run asynchronously (command x &).
g. Avoid performing tilde expansion after `:' in words that look like assignment
statements when in posix mode.
h. Slight changes to how the `complete' builtin prints out options and actions
for completion specifications.
i. Several changes to how `local -' restores the values of options and
$SHELLOPTS.
j. Don't treat a word in a compound assignment as an assignment statement
unless it has a valid subscript before the `='.
k. Fixed a bug with the DEBUG trap and process substitution that caused the
terminal's process group to be set incorrectly.
l. Fixed a bug that left readline's signal handlers installed while running a
shell command from a bindable readline command.
m. Fixed the `fc' builtin to clamp out of range history specifications at the
boundaries of the history list for POSIX conformance.
n. Fixed a bug that caused ${foo@a} to treat foo as an unset variable if it
was an array without a value for subscript 0/"0" but had other set
elements.
o. Fixed a bug that caused the history code to attempt to parse command
substitutions looking for shell comments before adding them to the history,
even while parsing here-documents.
p. Fixed a bug that could cause a syntax error in a command read by `eval' to
exit an interactive shell.
2. New Features in Bash
a. If the hash builtin is listing hashed filenames portably, don't print
anything if the table is empty.
b. GLOBIGNORE now ignores `.' and `..' as a terminal pathname component.
c. Bash attempts to optimize away forks in the last command in a function body
under appropriate circumstances.
d. The globbing code now uses fnmatch(3) to check collation elements (if
available) even in cases without multibyte characters.
e. The `fg' and `bg' builtins now return an error in a command substitution
when asked to restart a job inherited from the parent shell.
f. The shell now attempts to unlink all FIFOs on exit, whether a consuming
process has finished with them or not.
3. Changes to Readline
a. Make sure that all undo groups are closed when leaving vi insertion mode.
b. Make sure that the vi-mode `C' and `c' commands enter insert mode even if
the motion command doesn't have any effect.
c. Fixed several potential memory leaks in the callback mode context handling.
d. If readline is handling a SIGTTOU, make sure SIGTTOU is blocked while
executing the terminal cleanup code, since it's no longer run in a signal
handling context.
4. New Features in Readline
a. The signal cleanup code now blocks SIGINT while processing after a SIGINT.
------------------------------------------------------------------------------
This document details the changes between this version, bash-5.1-alpha, and
the previous version, bash-5.0-release.
1. Changes to Bash
a. Fixed a bug that caused a posix-mode shell to not exit if the return builtin
was executed outside a function or dot script.
b. Fixed a bug where `declare +f' could potentially turn off the function
attribute.
c. Restored bash-4.4 pathname expansion behavior when a word to be expanded had
only backslashes, not any of the other globbing characters. This came after
an extensive POSIX group discussion (interp #1234).
d. There are more changes to avoid performing word expansions multiple times on
arithmetic expressions.
e. Fixed a bug with alias expansion when the alias ends with a TAB.
f. Fixed a bug that caused programmable completion to return an error if the
shell function name supplied as an argument to `complete -F' was invalid.
g. There are several fixes to buffer overflows found as the result of fuzzing
with random input.
h. Fixed a bug that caused the edit-and-execute-command editing command to
start with the previous history line if invoked on an empty line.
i. Fixed a bug that potentially caused `bind --help' to change readline's
output stream.
j. Turning off posix mode now restores the vi-insertion mode binding for TAB
that was in effect when posix mode was enabled.
k. Restore the previous state of job control being enabled if `exec' fails in
an interactive shell.
l. Fixed a bug that caused the terminal's process group to be set incorrectly
if job control was turned off before starting an interactive shell.
m. Fixed a bug that caused a crash when HISTSIZE=0.
n. Fixed a word expansion bug that caused null strings on the rhs of expansions
to be discarded incorrectly.
o. History list management does a better job of handling the situation where
the number of history entries from the current shell session is greater than
the number of entries in the history list.
p. Fixed a bug that caused the `fc' builtin to attempt to dereference a newly-
freed history entry.
q. Fixed a bug that made the `Q' variable transformation not work well with
`set -u'.
r. There are several word expansion fixes for expanding $* and $@ in contexts
where word splitting is not going to be performed, since each positional
parameter must expand to a separate word.
s. Fixed a bug that could cause ^D to exit bash immediately even if there were
stopped jobs.
t. Fixed a bug with double-quoting and backslash-quoting strings containing
multibyte characters for reuse.
u. Fixed a bug that caused the line number to be reported incorrectly if the
shell executed a (command) subshell.
v. Fixed a bug that caused the shell to fail to reap process substitutions
when they went out of scope, which had unpredictable results.
w. Fixed a bug that caused null strings in arguments to [[ conditional command
operators to compare incorrectly.
x. Changed the behavior of `wait' without arguments to only wait for background
processes the current shell instance started, not background children it may
have inherited.
y. Fixed a bug that could cause command substitution to leave file descriptors
open if the shell received many SIGINTs.
z. Bash now behaves better if the `**' filename expansion operator encounters a
symbolic link to a directory, avoiding more cases where it might return
duplicate pathnames.
aa. Programmable completion now canonicalizes directory names in the same way
as bash word completion, so `..' is handled consistently.
bb. Fixed a bug when using RETURN as the delimiter to the read builtin; it
caused readline to set the binding for RETURN incorrectly.
cc. Fixed a bug that caused `history -d' to delay printing an out-of-range
error message.
dd. Fixed a bug with `bash -c command' where `command' ends with an expanded
alias.
ee. Fixed a bug that could result in `history -n' adding spurious line feeds to
commands in the history list.
ff. The $RANDOM random number generator now XORs the top and bottom halves of
the internal 32-bit value to introduce more randomness. Setting the shell
compatibility level to 50 or lower undoes this.
gg. Fixed several problems caused by running the DEBUG trap on simple commands
executed as part of a pipeline.
ii. Fixed a bug that didn't allow `bind -r' to remove the binding for \C-@.
jj. Several fixes to the bash-backward-shellword bindable readline command to
behave better when at the last character on the line.
kk. If `set -x' is enabled, bash doesn't print a command twice if it's run by
the `command' builtin.
ll. Fixed a bug with printing function definitions containing here documents.
mm. Fixed a bug that could cause the `bind' builtin to set $? to -1.
nn. Fixed a bug that didn't reset the timezone information correctly when the
TZ variable was unset.
oo. Fixed several issues with assigning an associative array variable using a
compound assignment that expands the value of the same variable.
pp. Fixed several places where the shell set $? without setting PIPESTATUS.
qq. Fixed a problem with glob bracket expressions containing invalid character
classes, collating symbols, or equivalence classes -- they should not
require a closing right bracket.
rr. Fixed a bug where running a builtin in a subshell did not run the EXIT trap.
ss. Fixed several problems with posix-mode variable assignments preceding
shell function calls and posix special builtins, so that they create and
modify variables at the current scope.
tt. Fix history initialization so `bash +o history' works as expected.
uu. Fixed a bug in the bindable edit-and-execute-command command that could
interfere with the shell's parsing state.
vv. Fixed an issue with nested traps running command substitutions in command
lines with command substitutions.
ww. Fixed a bug with globbing pathnames that contain invalid multibyte
characters (sequences that don't correspond to a character in the current
locale).
xx. Fixed a bug that caused the shell not to exit if a function definition
failed while errexit was enabled.
yy. Process substitution processes now get their input from /dev/null, since
they are asynchronous, not interactive, and not jobs.
zz. Setting nocaseglob no longer turns on case-insensitive regexp matching.
aaa. Fixed a bug that resulted in extra blank lines being added to some history
entries containing here-documents.
bbb. Fixed a bug that resulted in incorrect matching of some patterns in word
expansion if they expanded to the empty string.
ccc. Fixed here-string expansion so it behaves the same as expansion of the
rhs of an assignment statement.
ddd. Changed here-document parsing to no longer allow the end of the here
document to delimit a command substitution.
eee. Several fixes to history expansion: multiple :p modifiers work, a ^ word
designator works as part of a range, and a `-' is treated as part of a
search string if it immediately follows a `!'.
fff. Fixed a bug in pattern substitution with null matches in a string
containing multibyte characters.
ggg. Unbinding a key sequence bound with `bind -x' now removes the key sequence
from the additional keymap `bind -x' uses.
hhh. Fixed a bug with command start detection for completion so that it doesn't
mistake brace expansion for the start of a command.
iii. Fixed a bug that caused local variables with the same name as variables
appearing in a function's temporary environment to not be marked as local.
jjj. Fixed a bug that could cause SIGCHLD to be blocked when executing return
or exec in the rightmost pipeline element with lastpipe enabled.
kkk. Fixed a bug that could result in commands without the execute bit set
being added to the command hash table.
lll. Fixed a bug that allowed non-digits to follow the `#' in a `base#number'
integer constant.
mmm. Fixed a bug that made `time -- command' attempt to execute `--'.
nnn. Fixed a couple of bugs with variable transformation using arrays
subscripted with `*' or `@'.
ooo. A failure to create a variable using `declare' in a function no longer
causes the function to return immediately.
ppp. Fixed a bug that could cause the := word expansion to add a non-null
value if attempting to assign a null string when double-quoted.
qqq. Fixed a bug that could cause backslashes quoting double quotes in here
document bodies to not be removed when expanding the body.
rrr. Fixed a bug that caused commands following a subshell while the shell is
reading input from stdin but not interactive, while job control is
enabled, to be executed twice.
sss. Fixed a bug where receiving SIGTERM from a different process while
readline was active could cause the shell to terminate.
ttt. In posix mode, running a trap after the read builtin now sees the exit
status of the read builtin (e.g., 130 after a SIGINT) in $?.
uuu. Fixed a bug with nameref variables referencing array subscripts used in
arithmetic expressions.
vvv. Fixed a bug that caused the pipeline process group id to be reset in the
middle of a command list run by a shell started to run a command
substitution.
www. Restricted shells can no longer read and write history files with pathnames
containing slashes.
xxx. Fixed a couple of problems with 0 and -0 used as arguments to `fc' when
not listing commands from the history.
yyy. When `test' is supplied four or more arguments, treat an argument that
looks like an operator (e.g., -e), but is in a place where only a string
is valid, as a string, as it would be when using the POSIX rules, instead
of an operator with a missing argument.
zzz. There is no `compat50' shopt option. Changes to the shell compatibility
level should use the BASH_COMPAT variable.
aaaa. Redirection failures with compound commands are now treated as errors
that cause the shell to exit if `errexit' is enabled.
bbbb. Redirection failure error messages no longer expand the word in the
redirection again.
cccc. History expansion is no longer performed while parsing a here-document
inside a command substitution.
2. Changes to Readline
a. There are a number of fixes that were found as the result of fuzzing with
random input.
b. Changed the revert-all-at-newline behavior to make sure to start at the end
of the history list when doing it, instead of the line where the user hit
return.
c. When parsing `set' commands from the inputrc file or an application, readline
now allows trailing whitespace.
d. Fixed a bug that left a file descriptor open to the history file if the
file size was 0.
e. Fixed a problem with binding key sequences containing meta characters.
f. Fixed a bug that caused the wrong line to be displayed if the user tried to
move back beyond the beginning of the history list, or forward past the end
of the history list.
g. If readline catches SIGTSTP, it now sets a hook that allows the calling
application to handle it if it desires.
h. Fixed a redisplay problem with a prompt string containing embedded newlines.
i. Fixed a problem with completing filenames containing invalid multibyte
sequences when case-insensitive comparisons are enabled.
j. Fixed a redisplay problem with prompt strings containing invisible multibyte
characters.
k. Fixed a problem with multibyte characters mapped to editing commands that
modify the search string in incremental search.
l. Fixed a bug with maintaining the key sequence while resolving a bound
command in the presence of ambiguous sequences (sequences with a common
prefix), in most cases while attempting to unbind it.
m. Fixed several buffer overflows found as the result of fuzzing.
n. Reworked backslash handling when translating key sequences for key binding
to be more uniform and consistent, which introduces a slight backwards
incompatibility.
o. Fixed a bug with saving the history that resulted in errors not being
propagated to the calling application when the history file is not writable.
p. Readline only calls chown(2) on a newly-written history file if it really
needs to, instead of having it be a no-op.
q. Readline now behaves better when operate-and-get-next is used when the
history list is `full': when there are already $HISTSIZE entries.
r. Fixed a bug that could cause vi redo (`.') of a replace command not to work
correctly in the C or POSIX locale.
s. Fixed a bug with vi-mode digit arguments that caused the last command to be
set incorrectly. This prevents yank-last-arg from working as intended, for
example.
3. New Features in Bash
a. `bind -x' now supports different bindings for different editing modes and
keymaps.
b. Bash attempts to optimize the number of times it forks when executing
commands in subshells and from `bash -c'.
c. Here documents and here strings now use pipes for the expanded document if
it's smaller than the pipe buffer size, reverting to temporary files if it's
larger.
d. There are new loadable builtins: mktemp, accept, mkfifo, csv, cut/lcut
e. In posix mode, `trap -p' now displays signals whose disposition is SIG_DFL
and those that were SIG_IGN when the shell starts.
f. The shell now expands the history number (e.g., in PS1) even if it is not
currently saving commands to the history list.
g. `read -e' may now be used with arbitrary file descriptors (`read -u N').
h. The `select' builtin now runs traps if its internal call to the read builtin
is interrupted by a signal.
i. SRANDOM: a new variable that expands to a 32-bit random number that is not
produced by an LCRNG, and uses getrandom/getentropy, falling back to
/dev/urandom or arc4random if available. There is a fallback generator if
none of these are available.
j. shell-transpose-words: a new bindable readline command that uses the same
definition of word as shell-forward-word, etc.
k. The shell now adds default bindings for shell-forward-word,
shell-backward-word, shell-transpose-words, and shell-kill-word.
l. Bash now allows ARGV0 appearing in the initial shell environment to set $0.
m. If `unset' is executed without option arguments, bash tries to unset a shell
function if a name argument cannot be a shell variable name because it's not
an identifier.
n. The `test -N' operator uses nanosecond timestamp granularity if it's
available.
o. Bash posix mode now treats assignment statements preceding shell function
definitions the same as in its default mode, since POSIX has changed and
no longer requires those assignments to persist after the function returns
(POSIX interp 654).
p. BASH_REMATCH is no longer readonly.
q. wait: has a new -p VARNAME option, which stores the PID returned by `wait -n'
or `wait' without arguments.
r. Sorting the results of pathname expansion now uses byte-by-byte comparisons
if two strings collate equally to impose a total order; the result of a
POSIX interpretation (#963 and #1070).
s. Bash now allows SIGINT trap handlers to execute recursively.
t. Bash now saves and restores state around setting and unsetting posix mode,
instead of having unsetting posix mode set a known state.
u. Process substitution is now available in posix mode.
v. READLINE_MARK: a new variable available while executing commands bound with
`bind -x', contains the value of the mark.
w. Bash removes SIGCHLD from the set of blocked signals if it's blocked at shell
startup.
x. `test -v N' can now test whether or not positional parameter N is set.
y. `local' now honors the `-p' option to display all local variables at the
current context.
z. The `@a' variable transformation now prints attributes for unset array
variables.
aa. The `@A' variable transformation now prints a declare command that sets a
variable's attributes if the variable has attributes but is unset.
bb. `declare' and `local' now have a -I option that inherits attributes and
value from a variable with the same name at a previous scope.
cc. When run from a -c command, `jobs' now reports the status of completed jobs.
dd. New `U', `u', and `L' parameter transformations to convert to uppercase,
convert first character to uppercase, and convert to lowercase,
respectively.
ee. PROMPT_COMMAND: can now be an array variable, each element of which can
contain a command to be executed like a string PROMPT_COMMAND variable.
ff. `ulimit' has a -R option to report and set the RLIMIT_RTTIME resource.
gg. Associative arrays may be assigned using a list of key-value pairs within
a compound assignment. Compound assignments where the words are not of
the form [key]=value are assumed to be key-value assignments. A missing or
empty key is an error; a missing value is treated as NULL. Assignments may
not mix the two forms.
hh. New `K' parameter transformation to display associative arrays as key-
value pairs.
ii. Writing history to syslog now handles messages longer than the syslog max
length by writing multiple messages with a sequence number.
jj. SECONDS and RANDOM may now be assigned using arithmetic expressions, since
they are nominally integer variables. LINENO is not an integer variable.
kk. Bash temporarily suppresses the verbose option when running the DEBUG trap
while running a command from the `fc' builtin.
ll. `wait -n' now accepts a list of job specifications as arguments and will
wait for the first one in the list to change state.
mm. The associative array implementation can now dynamically increase the
size of the hash table based on insertion patterns.
nn. HISTFILE is now readonly in a restricted shell.
oo. The bash malloc now returns memory that is 16-byte aligned on 64-bit
systems.
4. New Features in Readline
a. If a second consecutive completion attempt produces matches where the first
did not, treat it as a new completion attempt and insert a match as
appropriate.
b. Bracketed paste mode works in more places: incremental search strings, vi
overstrike mode, character search, and reading numeric arguments.
c. Readline automatically switches to horizontal scrolling if the terminal has
only one line.
d. Unbinding all key sequences bound to a particular readline function now
descends into keymaps for multi-key sequences.
e. rl-clear-display: new bindable command that clears the screen and, if
possible, the scrollback buffer (bound to emacs mode M-C-l by default).
f. New active mark and face feature: when enabled, it will highlight the text
inserted by a bracketed paste (the `active region') and the text found by
incremental and non-incremental history searches. This is tied to bracketed
paste and can be disabled by turning off bracketed paste.
g. Readline sets the mark in several additional commands.
h. Bracketed paste mode is enabled by default.
i. Readline tries to take advantage of the more regular structure of UTF-8
characters to identify the beginning and end of characters when moving
through the line buffer.
j. The bindable operate-and-get-next command (and its default bindings) are
now part of readline instead of a bash-specific addition.
------------------------------------------------------------------------------
This document details the changes between this version, bash-5.0-release, and
the previous version, bash-5.0-rc1.
@@ -79,7 +713,7 @@ d. Fixed a problem with using `*' and `@' as subscripts when assigning values
e. Fixed a bug that could cause a huge memory allocation when completing a
word beginning with an invalid tilde expansion.
f. Cleaned up some incompatiblities with bash-4.4 when expanding indexed array
f. Cleaned up some incompatibilities with bash-4.4 when expanding indexed array
subscripts used in arithmetic expansions when assoc_expand_once is enabled.
g. The ${parameter@a} expansion will display attributes even if `parameter' is
@@ -731,7 +1365,7 @@ h. The `name' argument to the `coproc' reserved word now undergoes word
i. A nameref name resolution loop in a function now resolves to a variable by
that name in the global scope.
j. The `wait' builtin now has a `-f' option, which signfies to wait until the
j. The `wait' builtin now has a `-f' option, which signifies to wait until the
specified job or process terminates, instead of waiting until it changes
state.
@@ -1374,7 +2008,7 @@ j. Fixed a bug involving sign extension when reallocating the input line
k. Bash now does a better job at identifying syntax errors during word
completion and tailoring completion appropriately.
l. Bash now uses the current locale's decimal point in comamnd timing output.
l. Bash now uses the current locale's decimal point in command timing output.
m. Fixed a bug that caused segmentation faults while reading here documents if
PS2 contains a command substitution.
@@ -1417,7 +2051,7 @@ x. Fixed a bug that caused the shell to exit with the wrong (but non-zero)
y. Fixed a bug that caused the `time' reserved word to not be recognized as
such in all contexts where it should have been.
z. Fixed a bug that caused the shell to close process subsitution file
z. Fixed a bug that caused the shell to close process substitution file
descriptors when executing a script without the `#!' leading line.
aa. Fixed a typo that caused the `compat42' shell option to set the wrong
@@ -1814,7 +2448,7 @@ bb. Aliases whose value ends in a shell metacharacter now expand in a way to
4. New Features in Readline
a. The history truncation code now uses the same error recovery mechansim as
a. The history truncation code now uses the same error recovery mechanism as
the history writing code, and restores the old version of the history file
on error. The error recovery mechanism handles symlinked history files.
@@ -2151,7 +2785,7 @@ c. Fixed a bug that caused the pattern removal and pattern substitution word
expansions and case statement word expansion to not match the empty string.
d. Fixed a bug that caused the tzset() function to not work after changing
the TZ enviroment variable.
the TZ environment variable.
e. Fixed a bug that caused the RHS of an assignment statement to undergo
word splitting when it contained an unquoted $@.
@@ -2202,7 +2836,7 @@ t. Fixed a problem with the bash malloc's internal idea of the top of the
memory heap that resulted in incorrect decisions to try to reduce the
break and give memory back to the kernel.
u. There are changes to the expansions peformed on compound array assignments,
u. There are changes to the expansions performed on compound array assignments,
in an effort to make foo=( [ind1]=bar [ind2]=baz ) identical to
foo[ind1]=bar foo[ind2]=baz.
@@ -3204,7 +3838,7 @@ j. Fixed a bug in brace expansion that caused unwanted zero padding of the
k. Fixed a bug that prevented the |& construct from working as intended when
used with a simple command with additional redirections.
l. Fixed a bug with the case statment ;& terminator that caused the shell to
l. Fixed a bug with the case statement ;& terminator that caused the shell to
dereference a NULL pointer.
m. Fixed a bug that caused assignment statements or redirections preceding
@@ -3937,7 +4571,7 @@ l. Fixed a bug in the code that buffers characters received very quickly in
succession which caused characters to be dropped.
m. Fixed a bug that caused readline to reference uninitialized data structures
if it received a SIGWINCH before completing initialzation.
if it received a SIGWINCH before completing initialization.
n. Fixed a bug that caused the vi-mode `last command' to be set incorrectly
and therefore unrepeatable.
@@ -4269,7 +4903,7 @@ x. Fixed a bug that caused the shell to dump core when performing filename
y. Returned to the original Bourne shell rules for parsing ``: no recursive
parsing of embedded quoted strings or ${...} constructs.
z. The inheritence of the DEBUG, RETURN, and ERR traps is now dependent only
z. The inheritance of the DEBUG, RETURN, and ERR traps is now dependent only
on the settings of the `functrace' and `errtrace' shell options, rather
than whether or not the shell is in debugging mode.
@@ -4504,7 +5138,7 @@ and the previous version, bash-3.1-alpha1.
a. Added some system-specific signal names.
b. Fixed a typo in the ulimit builtin to make `x' the right option to
maniuplate the limit on file locks.
manipulate the limit on file locks.
c. Fixed a problem with using += to append to index 0 of an array variable
when not using subscript syntax.
@@ -5205,7 +5839,7 @@ y. Fixed a problem that could cause here documents to not be created correctly
2. Changes to Readline
a. Change to history expansion functions to treat `^' as equivalent to word
one, as the documention states.
one, as the documentation states.
b. Some changes to the display code to improve display and redisplay of
multibyte characters.
@@ -5822,7 +6456,7 @@ c. Fixed a problem which caused the display to be messed up when the last
line of a multi-line prompt (possibly containing invisible characters)
was longer than the screen width.
d. Fixed a problem with the vi-mode `r' command that ocurred on systems with
d. Fixed a problem with the vi-mode `r' command that occurred on systems with
support for multibyte characters when running in a locale without any
multibyte characters.
@@ -6235,7 +6869,7 @@ l. The `printf' builtin now handles the `ll' and `j' length modifiers
passed to printf(3).
m. Renamed a number of the bash-specific autoconf macros in aclocal.m4 to
have more sytematic naming, with accompanying changes to configure.in.
have more systematic naming, with accompanying changes to configure.in.
n. Fixed snprintf to handle long doubles and the %a/%A conversions by
falling back to sprintf, as long as sprintf supports them.
@@ -6348,7 +6982,7 @@ and the previous version, bash-2.05a-alpha1.
1. Changes to Bash
a. Fixed a bug in the evalution of arithmetic `for' statements when the
a. Fixed a bug in the evaluation of arithmetic `for' statements when the
expanded expression is NULL.
b. Fixed an unassigned variable problem in the redirection printing code.
@@ -6404,7 +7038,7 @@ o. `umask' now prints four digits when printing in octal mode, for
p. Lots of changes to the `printf' builtin from Paul Eggert: it handles `L'
formats and long doubles better, and internal functions have been
simpified where appropriate.
simplified where appropriate.
q. Some `time_t' fixes for machines were a time_t is bigger than a long.
@@ -6477,7 +7111,7 @@ c. `ulimit' prints `hard' or `soft' when a value is not `unlimited' but is
a. New bindable variable `history-preserve-point'. If set, the history
code attempts to place the user at the same location on each history
line retrived with previous-history or next-history.
line retrieved with previous-history or next-history.
------------------------------------------------------------------------------
This document details the changes between this version, bash-2.05a-alpha1,
@@ -6544,9 +7178,9 @@ v. Fixes, mostly from Paul Eggert, for a few possible buffer overflows in
w. Fixes from Paul Eggert to avoid most of the type casts in the shell code,
and use more appropriate types for a number of variables.
x. Command substition no longer inherits the DEBUG trap.
x. Command substitution no longer inherits the DEBUG trap.
y. Some fixes to the process substition code on machines without /dev/fd so
y. Some fixes to the process substitution code on machines without /dev/fd so
that named pipes are not removed inappropriately.
z. The loadable `getconf' builtin is now much more complete, and will become
@@ -6943,7 +7577,7 @@ g. Renamed rltty_set_default_bindings to rl_tty_set_default_bindings and
a. A new loadable builtin, realpath, which canonicalizes and expands symlinks
in pathname arguments.
b. When `set' is called without options, it prints function defintions in a
b. When `set' is called without options, it prints function definitions in a
way that allows them to be reused as input. This affects `declare' and
`declare -p' as well.
@@ -7702,7 +8336,7 @@ m. Improvements were made to the `read' builtin so that it makes many
n. The expansion of $- will include `c' and `s' when those options are
supplied at shell invocation.
o. Several improvments were made to the completion code: variable completion
o. Several improvements were made to the completion code: variable completion
now works better when there are unterminated expansions, command
completion understands quotes better, and completion now works in certain
unclosed $(... constructs.
@@ -7790,7 +8424,7 @@ d. There is a new shell option, no_empty_command_completion, which, when
enabled, disables command completion when TAB is typed on an empty line.
e. The `help' builtin has a `-s' option to just print a builtin's usage
synopsys.
synopsis.
f. There are several new arithmetic operators: id++, id-- (variable
post-increment/decrement), ++id, --id (variabl pre-increment/decrement),
@@ -9674,5 +10308,5 @@ b. A bug encountered when expand-tilde was enabled and file completion was
c. A slight change was made to the incremental search termination behavior.
ESC still terminates the search, but if input is pending or arrives
within 0.1 seconds (on systems with select(2)), it is used as a prefix
character. This is intented to allow users to terminate searches with
character. This is intended to allow users to terminate searches with
the arrow keys and get the behavior they expect.
+108 -41
View File
@@ -2,11 +2,11 @@ Compatibility with previous versions
====================================
This document details the incompatibilities between this version of bash,
bash-5.0, and the previous widely-available versions, bash-3.x (which is
bash-5.1, 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, the current
widely-available version. These were discovered by users of bash-2.x
through 4.x, so this list is not comprehensive. Some of these
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
incompatibilities occur between the current version and versions 2.0 and
above.
@@ -292,7 +292,7 @@ above.
36. Bash-4.0 now allows process substitution constructs to pass unchanged
through brace expansion, so any expansion of the contents will have to be
separately specified, and each process subsitution will have to be
separately specified, and each process substitution will have to be
separately entered.
37. Bash-4.0 now allows SIGCHLD to interrupt the wait builtin, as Posix
@@ -404,78 +404,145 @@ above.
contexts (including the global context) unless the shell is in posix
mode, since export and readonly are special builtins.
63. Bash-5.1 changes the way posix-mode shells handle assignment statements
preceding shell function calls. Previous versions of POSIX specified that
such assignments would persist after the function returned; subsequent
versions of the standard removed that requirement (interpretation #654).
Bash-5.1 posix mode assignment statements preceding shell function calls
do not persist after the function returns.
64. Bash-5.1 reverts to the bash-4.4 treatment of pathname expansion of words
containing backslashes but no other special globbing characters. This comes
after a protracted discussion and a POSIX interpretation (#1234).
65. In bash-5.1, disabling posix mode attempts to restore the state of several
options that posix mode modifies to the state they had before enabling
posix mode. Previous versions restored these options to default values.
Shell Compatibility Level
=========================
Bash-4.0 introduced the concept of a `shell compatibility level', specified
as a set of options to the shopt builtin (compat31, compat32, compat40,
compat41, and compat42 at this writing). There is only one current
compatibility level -- each option is mutually exclusive. This list does not
mention behavior that is standard for a particular version (e.g., setting
compat32 means that quoting the rhs of the regexp matching operator quotes
special regexp characters in the word, which is default behavior in bash-3.2
and above).
as a set of options to the shopt builtin (compat31, compat32, compat40,
compat41, and so on). There is only one current compatibility level --
each option is mutually exclusive. The compatibility level is intended to
allow users to select behavior from previous versions that is incompatible
with newer versions while they migrate scripts to use current features and
behavior. It's intended to be a temporary solution.
Bash-4.3 introduces a new shell variable: BASH_COMPAT. The value assigned
This section does not mention behavior that is standard for a particular
version (e.g., setting compat32 means that quoting the rhs of the regexp
matching operator quotes special regexp characters in the word, which is
default behavior in bash-3.2 and above).
If a user enables, say, compat32, it may affect the behavior of other
compatibility levels up to and including the current compatibility level.
The idea is that each compatibility level controls behavior that changed in
that version of bash, but that behavior may have been present in earlier
versions. For instance, the change to use locale-based comparisons with
the `[[' command came in bash-4.1, and earlier versions used ASCII-based
comparisons, so enabling compat32 will enable ASCII-based comparisons as
well. That granularity may not be sufficient for all uses, and as a result
users should employ compatibility levels carefully. Read the documentation
for a particular feature to find out the current behavior.
Bash-4.3 introduced a new shell variable: BASH_COMPAT. The value assigned
to this variable (a decimal version number like 4.2, or an integer
corresponding to the compatNN option, like 42) determines the compatibility
level.
Bash-4.4 has begun deprecating older compatibility levels. Eventually, the
options will be removed in favor of the BASH_COMPAT variable.
Starting with bash-4.4, bash has begun deprecating older compatibility
levels. Eventually, the options will be removed in favor of the
BASH_COMPAT variable.
compat31 set
Bash-5.0 is the final version for which there will be an individual shopt
option for the previous version. Users should use the BASH_COMPAT variable
on bash-5.0 and later versions.
The following table describes the behavior changes controlled by each
compatibility level setting. The `compatNN' tag is used as shorthand for
setting the compatibility level to NN using one of the following
mechanisms. For versions prior to bash-5.0, the compatibility level may be
set using the corresponding compatNN shopt option. For bash-4.3 and later
versions, the BASH_COMPAT variable is preferred, and it is required for
bash-5.1 and later versions.
compat31
- the < and > operators to the [[ command do not consider the current
locale when comparing strings; they use ASCII ordering
- quoting the rhs of the regexp matching operator (=~) has no
special effect
- quoting the rhs of the [[ command's regexp matching operator (=~)
has no special effect
compat32 set
- the < and > operators to the [[ command do not consider the current
locale when comparing strings; they use ASCII ordering
compat40 set
compat32
- the < and > operators to the [[ command do not consider the current
locale when comparing strings; they use ASCII ordering
- interrupting a command list such as "a ; b ; c" causes the execution
of the entire list to be aborted (in versions before bash-4.0,
interrupting one command in a list caused the next to be executed)
of the next command in the list (in bash-4.0 and later versions,
the shell acts as if it received the interrupt, so interrupting
one command in a list aborts the execution of the entire list)
compat41 set
- interrupting a command list such as "a ; b ; c" causes the execution
of the entire list to be aborted (in versions before bash-4.0,
interrupting one command in a list caused the next to be executed)
- when in posix mode, single quotes in the `word' portion of a
double-quoted parameter expansion define a new quoting context and
are treated specially
compat40
- the < and > operators to the [[ command do not consider the current
locale when comparing strings; they use ASCII ordering.
Bash versions prior to bash-4.1 use ASCII collation and strcmp(3);
bash-4.1 and later use the current locale's collation sequence and
strcoll(3).
compat42 set
compat41
- in posix mode, `time' may be followed by options and still be
recognized as a reserved word (this is POSIX interpretation 267)
- in posix mode, the parser requires that an even number of single
quotes occur in the `word' portion of a double-quoted ${...}
parameter expansion and treats them specially, so that characters
within the single quotes are considered quoted (this is POSIX
interpretation 221)
compat42
- the replacement string in double-quoted pattern substitution is not
run through quote removal, as in previous versions
run through quote removal, as it is in versions after bash-4.2
- in posix mode, single quotes are considered special when expanding
the `word' portion of a double-quoted ${...} parameter expansion
and can be used to quote a closing brace or other special character
(this is part of POSIX interpretation 221); in later versions,
single quotes are not special within double-quoted word expansions
compat43 set
compat43
- the shell does not print a warning message if an attempt is made to
use a quoted compound assignment as an argument to declare
(declare -a foo='(1 2)')
(declare -a foo='(1 2)'). Later versions warn that this usage is
deprecated.
- word expansion errors are considered non-fatal errors that cause the
current command to fail, even in Posix mode
current command to fail, even in posix mode (the default behavior is
to make them fatal errors that cause the shell to exit)
- when executing a shell function, the loop state (while/until/etc.)
is not reset, so `break' or `continue' in that function will break
or continue loops in the calling context. Bash-4.4 and later reset
the loop state to prevent this.
the loop state to prevent this
compat44 set
compat44
- the shell sets up the values used by BASH_ARGV and BASH_ARGC so
they can expand to the shell's positional parameters even if extended
debug mode is not enabled
- a subshell inherits loops from its parent contenxt, so `break'
or `continue' will cause the subshell to exit
- a subshell inherits loops from its parent context, so `break'
or `continue' will cause the subshell to exit. Bash-5.0 and later
reset the loop state to prevent the exit
- variable assignments preceding builtins like export and readonly
that set attributes continue to affect variables with the same
name in the calling environment even if the shell is not in posix
mode
compat50 (set using BASH_COMPAT)
- Bash-5.1 changed the way $RANDOM is generated to introduce slightly
more randomness. If the shell compatibility level is set to 50 or
lower, it reverts to the method from bash-5.0 and previous versions,
so seeding the random number generator by assigning a value to
RANDOM will produce the same sequence as in bash-5.0
- If the command hash table is empty, bash versions prior to bash-5.1
printed an informational message to that effect even when writing
output in a format that can be reused as input (-l). Bash-5.1
suppresses that message if -l is supplied
-------------------------------------------------------------------------------
+4217 -2
View File
File diff suppressed because it is too large Load Diff
+84 -3
View File
@@ -405,6 +405,7 @@ lib/sh/fnxform.c f
lib/sh/fpurge.c f
lib/sh/getcwd.c f
lib/sh/getenv.c f
lib/sh/gettimeofday.c f
lib/sh/inet_aton.c f
lib/sh/input_avail.c f
lib/sh/itos.c f
@@ -420,6 +421,7 @@ lib/sh/netopen.c f
lib/sh/oslib.c f
lib/sh/pathcanon.c f
lib/sh/pathphys.c f
lib/sh/random.c f
lib/sh/rename.c f
lib/sh/setlinebuf.c f
lib/sh/shmatch.c f
@@ -477,6 +479,41 @@ lib/tilde/tilde.h f
lib/tilde/shell.c f
m4/stat-time.m4 f
m4/timespec.m4 f
m4/codeset.m4 f
m4/extern-inline.m4 f
m4/fcntl-o.m4 f
m4/gettext.m4 f
m4/glibc2.m4 f
m4/glibc21.m4 f
m4/host-cpu-c-abi.m4 f
m4/iconv.m4 f
m4/intdiv0.m4 f
m4/intl-thread-locale.m4 f
m4/intl.m4 f
m4/intlmacosx.m4 f
m4/intmax.m4 f
m4/inttypes-pri.m4 f
m4/inttypes.m4 f
m4/inttypes_h.m4 f
m4/lcmessage.m4 f
m4/lib-ld.m4 f
m4/lib-link.m4 f
m4/lib-prefix.m4 f
m4/lock.m4 f
m4/nls.m4 f
m4/po.m4 f
m4/printf-posix.m4 f
m4/progtest.m4 f
m4/pthread_rwlock_rdlock.m4 f
m4/size_max.m4 f
m4/stdint_h.m4 f
m4/threadlib.m4 f
m4/uintmax_t.m4 f
m4/ulonglong.m4 f
m4/visibility.m4 f
m4/wchar_t.m4 f
m4/wint_t.m4 f
m4/xsize.m4 f
po/LINGUAS f
po/Makefile.in.in f
po/Makevars f
@@ -530,6 +567,8 @@ po/it.gmo f
po/it.po f
po/ja.gmo f
po/ja.po f
po/ko.gmo f
po/ko.po f
po/lt.gmo f
po/lt.po f
po/nl.gmo f
@@ -673,6 +712,8 @@ examples/loadables/Makefile.in f
examples/loadables/Makefile.inc.in f
examples/loadables/necho.c f
examples/loadables/hello.c f
examples/loadables/asort.c f
examples/loadables/accept.c f
examples/loadables/print.c f
examples/loadables/realpath.c f
examples/loadables/seq.c f
@@ -685,7 +726,8 @@ examples/loadables/truefalse.c f
examples/loadables/fdflags.c f
examples/loadables/finfo.c f
examples/loadables/cat.c f
#examples/loadables/cut.c f
examples/loadables/csv.c f
examples/loadables/cut.c f
examples/loadables/logname.c f
examples/loadables/basename.c f
examples/loadables/dirname.c f
@@ -702,6 +744,8 @@ examples/loadables/whoami.c f
examples/loadables/uname.c f
examples/loadables/sync.c f
examples/loadables/mkdir.c f
examples/loadables/mkfifo.c f
examples/loadables/mktemp.c f
examples/loadables/ln.c f
examples/loadables/mypid.c f
examples/loadables/unlink.c f
@@ -826,6 +870,7 @@ tests/alias1.sub f
tests/alias2.sub f
tests/alias3.sub f
tests/alias4.sub f
tests/alias5.sub f
tests/alias.right f
tests/appendop.tests f
tests/appendop1.sub f
@@ -872,6 +917,7 @@ tests/array24.sub f
tests/array25.sub f
tests/array26.sub f
tests/array27.sub f
tests/array28.sub f
tests/array-at-star f
tests/array2.right f
tests/assoc.tests f
@@ -886,6 +932,7 @@ tests/assoc7.sub f
tests/assoc8.sub f
tests/assoc9.sub f
tests/assoc10.sub f
tests/assoc11.sub f
tests/attr.tests f
tests/attr.right f
tests/attr1.sub f
@@ -900,6 +947,7 @@ tests/builtins3.sub f
tests/builtins4.sub f
tests/builtins5.sub f
tests/builtins6.sub f
tests/builtins7.sub f
tests/source1.sub f
tests/source2.sub f
tests/source3.sub f
@@ -915,6 +963,8 @@ tests/case3.sub f
tests/case4.sub f
tests/casemod.tests f
tests/casemod.right f
tests/complete.tests f
tests/complete.right f
tests/comsub.tests f
tests/comsub.right f
tests/comsub1.sub f
@@ -928,6 +978,7 @@ tests/comsub-eof2.sub f
tests/comsub-eof3.sub f
tests/comsub-eof4.sub f
tests/comsub-eof5.sub f
tests/comsub-eof6.sub f
tests/comsub-eof.right f
tests/comsub-posix.tests f
tests/comsub-posix.right f
@@ -958,6 +1009,7 @@ tests/dollar-at-star5.sub f
tests/dollar-at-star6.sub f
tests/dollar-at-star7.sub f
tests/dollar-at-star8.sub f
tests/dollar-at-star9.sub f
tests/dollar-at1.sub f
tests/dollar-at2.sub f
tests/dollar-at3.sub f
@@ -974,6 +1026,7 @@ tests/dollar-star6.sub f
tests/dollar-star7.sub f
tests/dollar-star8.sub f
tests/dollar-star9.sub f
tests/dollar-star10.sub f
tests/dollar.right f
tests/dstack.tests f
tests/dstack.right f
@@ -1006,6 +1059,7 @@ tests/exec10.sub f
tests/exec11.sub f
tests/exec12.sub f
tests/exec13.sub f
tests/exec14.sub f
tests/exp.tests f
tests/exp.right f
tests/exp1.sub f
@@ -1060,17 +1114,24 @@ tests/glob1.sub f
tests/glob2.sub f
tests/glob3.sub f
tests/glob4.sub f
tests/glob5.sub f
tests/glob6.sub f
tests/glob7.sub f
tests/glob8.sub f
tests/glob9.sub f
tests/glob.right f
tests/globstar.tests f
tests/globstar.right f
tests/globstar1.sub f
tests/globstar2.sub f
tests/globstar3.sub f
tests/heredoc.tests f
tests/heredoc.right f
tests/heredoc1.sub f
tests/heredoc2.sub f
tests/heredoc3.sub f
tests/heredoc4.sub f
tests/heredoc5.sub f
tests/herestr.tests f
tests/herestr.right f
tests/herestr1.sub f
@@ -1081,6 +1142,7 @@ tests/histexp3.sub f
tests/histexp4.sub f
tests/histexp5.sub f
tests/histexp6.sub f
tests/histexp7.sub f
tests/histexp.right f
tests/history.tests f
tests/history.right f
@@ -1088,6 +1150,8 @@ tests/history.list f 444
tests/history1.sub f
tests/history2.sub f
tests/history3.sub f
tests/history4.sub f
tests/history5.sub f
tests/ifs.tests f
tests/ifs.right f
tests/ifs1.sub f
@@ -1113,6 +1177,7 @@ tests/jobs3.sub f
tests/jobs4.sub f
tests/jobs5.sub f
tests/jobs6.sub f
tests/jobs7.sub f
tests/jobs.right f
tests/lastpipe.right f
tests/lastpipe.tests f
@@ -1160,6 +1225,10 @@ tests/new-exp8.sub f
tests/new-exp9.sub f
tests/new-exp10.sub f
tests/new-exp11.sub f
tests/new-exp12.sub f
tests/new-exp13.sub f
tests/new-exp14.sub f
tests/new-exp15.sub f
tests/new-exp.right f
tests/nquote.tests f
tests/nquote.right f
@@ -1191,6 +1260,7 @@ tests/posixexp4.sub f
tests/posixexp5.sub f
tests/posixexp6.sub f
tests/posixexp7.sub f
tests/posixexp8.sub f
tests/posixexp2.tests f
tests/posixexp2.right f
tests/posixpat.tests f
@@ -1198,7 +1268,7 @@ tests/posixpat.right f
tests/posixpipe.tests f
tests/posixpipe.right f
tests/prec.right f
tests/precedence f
tests/precedence.tests f
tests/printf.tests f
tests/printf.right f
tests/printf1.sub f
@@ -1208,10 +1278,13 @@ tests/printf4.sub f
tests/procsub.tests f
tests/procsub.right f
tests/procsub1.sub f
tests/procsub2.sub f
tests/quote.tests f
tests/quote.right f
tests/quote1.sub f
tests/quote2.sub f
tests/quote3.sub f
tests/quote4.sub f
tests/read.tests f
tests/read.right f
tests/read1.sub f
@@ -1257,6 +1330,7 @@ tests/run-braces f
tests/run-builtins f
tests/run-case f
tests/run-casemod f
tests/run-complete f
tests/run-comsub f
tests/run-comsub-eof f
tests/run-comsub-posix f
@@ -1335,7 +1409,8 @@ tests/set-e.right f
tests/set-x.tests f
tests/set-x1.sub f
tests/set-x.right f
tests/shopt.tests f
tests/shopt.tests f
tests/shopt1.sub f
tests/shopt.right f
tests/strip.tests f
tests/strip.right f
@@ -1382,6 +1457,12 @@ tests/varenv13.sub f
tests/varenv14.sub f
tests/varenv15.sub f
tests/varenv15.in f
tests/varenv16.sub f
tests/varenv17.sub f
tests/varenv18.sub f
tests/varenv19.sub f
tests/varenv20.sub f
tests/varenv21.sub f
tests/version f
tests/version.mini f
tests/vredir.tests f
+126 -38
View File
@@ -1,4 +1,4 @@
# Makefile for bash-5.0, version 4.27
# Makefile for bash-5.0, version 4.30
#
# Copyright (C) 1996-2018 Free Software Foundation, Inc.
@@ -231,7 +231,8 @@ SHLIB_SOURCE = ${SH_LIBSRC}/clktck.c ${SH_LIBSRC}/getcwd.c \
${SH_LIBSRC}/input_avail.c ${SH_LIBSRC}/mbscasecmp.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}/shmbchar.c ${SH_LIBSRC}/utf8.c \
${SH_LIBSRC}/random.c ${SH_LIBSRC}/gettimeofday.c
SHLIB_LIB = -lsh
SHLIB_LIBNAME = libsh.a
@@ -592,7 +593,7 @@ $(Program): .build $(OBJECTS) $(BUILTINS_DEP) $(LIBDEP)
@echo " ***********************************************************"
@echo
bashbug: $(SDIR)/bashbug.sh config.h Makefile $(VERSPROG)
bashbug: $(SDIR)/bashbug.sh $(VERSPROG)
@sed -e "s%!PATCHLEVEL!%$(PatchLevel)%" \
$(SDIR)/bashbug.sh > $@
@chmod a+rx bashbug
@@ -618,7 +619,7 @@ asan-tests: asan $(TESTS_SUPPORT)
@-test -d tests || mkdir tests
@cp $(TESTS_SUPPORT) tests
@( cd $(srcdir)/tests && \
PATH=$(BUILD_DIR)/tests:$$PATH THIS_SH=$(THIS_SH) $(SHELL) ${TESTSCRIPT} )
BUILD_DIR=$(BUILD_DIR) PATH=$(BUILD_DIR)/tests:$$PATH THIS_SH=$(THIS_SH) $(SHELL) ${TESTSCRIPT} )
profiling-tests: ${PROGRAM}
@test "X$$PROFILE_FLAGS" == "X" && { echo "profiling-tests: must be built with profiling enabled" >&2; exit 1; }
@@ -628,12 +629,15 @@ version.h: $(SOURCES) config.h Makefile patchlevel.h
$(SHELL) $(SUPPORT_SRC)mkversion.sh -b -S ${topdir} -s $(RELSTATUS) -d $(Version) -o newversion.h \
&& mv newversion.h version.h
bashversion$(EXEEXT): patchlevel.h conftypes.h version.h buildversion.o $(SUPPORT_SRC)bashversion.c
bashversion$(EXEEXT): buildversion.o $(SUPPORT_SRC)bashversion.c
$(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) ${LDFLAGS_FOR_BUILD} -o $@ $(SUPPORT_SRC)bashversion.c buildversion.o ${LIBS_FOR_BUILD}
buildversion.o: version.h conftypes.h patchlevel.h $(srcdir)/version.c
buildversion.o: $(srcdir)/version.c
$(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) -DBUILDTOOL -c -o $@ $(srcdir)/version.c
buildversion.o: bashintl.h $(BASHINCDIR)/gettext.h
buildversion.o: version.h patchlevel.h conftypes.h
# old rules
GRAM_H = parser-built
y.tab.o: y.tab.h y.tab.c ${GRAM_H} command.h ${BASHINCDIR}/stdc.h input.h
@@ -691,7 +695,7 @@ $(SHLIB_LIBRARY): config.h ${SHLIB_SOURCE}
${INTL_LIBRARY}: config.h ${INTL_LIBDIR}/Makefile
@echo making $@ in ${INTL_LIBDIR}
@(cd ${INTL_LIBDIR} && \
$(MAKE) $(MFLAGS) all) || exit 1
$(MAKE) $(MFLAGS) XCFLAGS="${LOCAL_CFLAGS}" all) || exit 1
${LIBINTL_H}: ${INTL_DEP}
@@ -711,7 +715,7 @@ mksignames$(EXEEXT): mksignames.o buildsignames.o
$(RM) $@
$(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) ${LDFLAGS_FOR_BUILD} -o $@ mksignames.o buildsignames.o ${LIBS_FOR_BUILD}
mksyntax$(EXEEXT): ${srcdir}/mksyntax.c config.h syntax.h ${BASHINCDIR}/chartypes.h
mksyntax$(EXEEXT): ${srcdir}/mksyntax.c config.h syntax.h ${BASHINCDIR}/chartypes.h bashansi.h
$(RM) $@
${CC_FOR_BUILD} ${CCFLAGS_FOR_BUILD} ${LDFLAGS_FOR_BUILD} -o $@ ${srcdir}/mksyntax.c ${LIBS_FOR_BUILD}
@@ -742,6 +746,9 @@ ${DEFDIR}/bashgetopt.o: $(BUILTIN_SRCDIR)/bashgetopt.c
${DEFDIR}/builtext.h: $(BUILTIN_DEFS)
@(cd $(DEFDIR) && $(MAKE) $(MFLAGS) builtext.h ) || exit 1
${DEFDIR}/pipesize.h:
@(cd $(DEFDIR) && $(MAKE) $(MFLAGS) pipesize.h ) || exit 1
$(SDIR)/man2html$(EXEEXT): ${SUPPORT_SRC}/man2html.c
@(cd $(SDIR) && $(MAKE) $(MFLAGS) all ) || exit 1
@@ -753,7 +760,7 @@ Makefile makefile: config.status $(srcdir)/Makefile.in
Makefiles makefiles: config.status $(srcdir)/Makefile.in
@for mf in $(CREATED_MAKEFILES); do \
CONFIG_FILES=$$mf CONFIG_HEADERS= $(SHELL) ./config.status ; \
CONFIG_FILES=$$mf CONFIG_HEADERS= $(SHELL) ./config.status || exit 1; \
done
config.h: stamp-h
@@ -839,16 +846,20 @@ install-headers-dirs:
install-headers: install-headers-dirs
@for hf in $(INSTALLED_HEADERS) ; do \
${INSTALL_DATA} $(srcdir)/"$$hf" $(DESTDIR)$(headersdir)/$$hf; \
${INSTALL_DATA} $(srcdir)/"$$hf" $(DESTDIR)$(headersdir)/$$hf || exit 1; \
done
@for hf in $(INSTALLED_INCFILES) ; do \
${INSTALL_DATA} $(BASHINCDIR)/"$$hf" $(DESTDIR)$(headersdir)/include/$$hf; \
${INSTALL_DATA} $(BASHINCDIR)/"$$hf" $(DESTDIR)$(headersdir)/include/$$hf || exit 1; \
done
@for hf in $(INSTALLED_BUILTINS_HEADERS) ; do \
${INSTALL_DATA} $(BUILTIN_SRCDIR)/"$$hf" $(DESTDIR)$(headersdir)/builtins/$$hf; \
${INSTALL_DATA} $(BUILTIN_SRCDIR)/"$$hf" $(DESTDIR)$(headersdir)/builtins/$$hf || exit 1; \
done
@for hf in $(CREATED_HEADERS) ; do \
${INSTALL_DATA} $(BUILD_DIR)/"$$hf" $(DESTDIR)$(headersdir)/$$hf; \
if test -f $(BUILD_DIR)/"$$hf" ; then \
${INSTALL_DATA} $(BUILD_DIR)/"$$hf" $(DESTDIR)$(headersdir)/$$hf || exit 1; \
else \
${INSTALL_DATA} $(srcdir)/"$$hf" $(DESTDIR)$(headersdir)/$$hf || exit 1; \
fi ; \
done
-$(INSTALL_DATA) $(SDIR)/bash.pc $(DESTDIR)$(pkgconfigdir)/bash.pc
@@ -947,7 +958,7 @@ test tests check: force $(Program) $(TESTS_SUPPORT)
@-test -d tests || mkdir tests
@cp $(TESTS_SUPPORT) tests
@( cd $(srcdir)/tests && \
PATH=$(BUILD_DIR)/tests:$$PATH THIS_SH=$(THIS_SH) $(SHELL) ${TESTSCRIPT} )
BUILD_DIR=$(BUILD_DIR) PATH=$(BUILD_DIR)/tests:$$PATH THIS_SH=$(THIS_SH) $(SHELL) ${TESTSCRIPT} )
symlinks:
$(SHELL) $(SUPPORT_SRC)fixlinks -s $(srcdir)
@@ -968,39 +979,50 @@ depends: force
#### PRIVATE TARGETS ####
hashtest: hashlib.c
$(CC) -DTEST_HASHING $(CCFLAGS) $(TEST_NBUCKETS) -o $@ $(srcdir)/hashlib.c xmalloc.o $(INTL_LIB)
$(CC) -DTEST_HASHING $(CCFLAGS) $(TEST_NBUCKETS) -o $@ $(srcdir)/hashlib.c xmalloc.o $(INTL_LIB) $(MALLOC_LIBRARY)
############################ DEPENDENCIES ###############################
# Files that depend on the definitions in config-top.h, which are not meant
# to be changed
bashhist.o: config-top.h
shell.o: config-top.h
input.o: config-top.h
y.tab.o: config-top.h
jobs.o: config-top.h
nojobs.o: config-top.h
execute_cmd.o: config-top.h
variables.o: config-top.h
builtins/command.o: config-top.h
builtins/common.o: config-top.h
builtins/break.o: config-top.h
builtins/echo.o: config-top.h
builtins/evalstring.o: config-top.h
builtins/exit.o: config-top.h
builtins/kill.o: config-top.h
array.o: $(srcdir)/config-top.h
bashhist.o: $(srcdir)/config-top.h
shell.o: $(srcdir)/config-top.h
input.o: $(srcdir)/config-top.h
y.tab.o: $(srcdir)/config-top.h
jobs.o: $(srcdir)/config-top.h
nojobs.o: $(srcdir)/config-top.h
execute_cmd.o: $(srcdir)/config-top.h
variables.o: $(srcdir)/config-top.h
findcmd.o: $(srcdir)/config-top.h
subst.o: $(srcdir)/config-top.h
builtins/cd.o: $(srcdir)/config-top.h
builtins/command.o: $(srcdir)/config-top.h
builtins/common.o: $(srcdir)/config-top.h
builtins/declare.o: $(srcdir)/config-top.h
builtins/break.o: $(srcdir)/config-top.h
builtins/echo.o: $(srcdir)/config-top.h
builtins/evalstring.o: $(srcdir)/config-top.h
builtins/exit.o: $(srcdir)/config-top.h
builtins/kill.o: $(srcdir)/config-top.h
builtins/shopt.o: $(srcdir)/config-top.h
# XXX
${SH_LIBDIR}/tmpfile.o: $(srcdir)/config-top.h
# shell basics
copy_cmd.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
copy_cmd.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
copy_cmd.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
copy_cmd.o: make_cmd.h subst.h sig.h pathnames.h externs.h
copy_cmd.o: bashansi.h assoc.h $(BASHINCDIR)/ocache.h $(BASHINCDIR)/chartypes.h
dispose_cmd.o: bashansi.h ${BASHINCDIR}/ansi_stdlib.h
dispose_cmd.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h
dispose_cmd.o: error.h general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
dispose_cmd.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
dispose_cmd.o: make_cmd.h subst.h sig.h pathnames.h externs.h
dispose_cmd.o: ${BASHINCDIR}/ocache.h
dispose_cmd.o: assoc.h ${BASHINCDIR}/chartypes.h
error.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h flags.h ${BASHINCDIR}/stdc.h error.h
error.o: command.h general.h xmalloc.h externs.h input.h bashhist.h
error.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
@@ -1008,12 +1030,14 @@ error.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h arr
error.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
error.o: make_cmd.h subst.h sig.h pathnames.h externs.h execute_cmd.h
error.o: input.h execute_cmd.h
error.o: $(BASHINCDIR)/ocache.h $(BASHINCDIR)/chartypes.h assoc.h
eval.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h trap.h flags.h ${DEFSRC}/common.h
eval.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
eval.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
eval.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
eval.o: make_cmd.h subst.h sig.h pathnames.h externs.h parser.h
eval.o: input.h execute_cmd.h
eval.o: bashhist.h assoc.h ${BASHINCDIR}/ocache.h ${BASHINCDIR}/chartypes.h
execute_cmd.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
execute_cmd.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
execute_cmd.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
@@ -1024,12 +1048,15 @@ execute_cmd.o: execute_cmd.h findcmd.h redir.h trap.h test.h pathexp.h
execute_cmd.o: $(DEFSRC)/common.h ${DEFDIR}/builtext.h ${GLOB_LIBSRC}/strmatch.h
execute_cmd.o: ${BASHINCDIR}/posixtime.h ${BASHINCDIR}/chartypes.h
execute_cmd.o: $(DEFSRC)/getopt.h
execute_cmd.o: bashhist.h input.h ${GRAM_H} assoc.h hashcmd.h alias.h
execute_cmd.o: ${BASHINCDIR}/ocache.h ${BASHINCDIR}/posixwait.h
expr.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
expr.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
expr.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
expr.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
expr.o: make_cmd.h subst.h sig.h pathnames.h externs.h flags.h execute_cmd.h
expr.o: ${BASHINCDIR}/chartypes.h
expr.o: assoc.h ${BASHINCDIR}/ocache.h ${BASHINCDIR}/typemax.h
findcmd.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h ${BASHINCDIR}/posixstat.h bashansi.h
findcmd.o: ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/memalloc.h shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h
findcmd.o: ${BASHINCDIR}/stdc.h error.h general.h xmalloc.h variables.h arrayfunc.h conftypes.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h
@@ -1041,13 +1068,17 @@ flags.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h
flags.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
flags.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h execute_cmd.h
flags.o: make_cmd.h subst.h sig.h pathnames.h externs.h bashhist.h
flags.o: ${BASHINCDIR}/ocache.h ${BASHINCDIR}/chartypes.h bashansi.h assoc.h
general.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h ${BASHINCDIR}/filecntl.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
general.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
general.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
general.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
general.o: make_cmd.h subst.h sig.h pathnames.h externs.h flags.h parser.h
general.o: pathexp.h
general.o: ${BASHINCDIR}/maxpath.h ${BASHINCDIR}/posixtime.h
general.o: ${BASHINCDIR}/chartypes.h
general.o: trap.h input.h assoc.h test.h findcmd.h
general.o: ${BASHINCDIR}/ocache.h $(DEFSRC)/common.h
hashcmd.o: config.h ${BASHINCDIR}/posixstat.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
hashcmd.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
hashcmd.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashcmd.h
@@ -1058,6 +1089,7 @@ hashlib.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.
hashlib.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
hashlib.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
hashlib.o: make_cmd.h subst.h sig.h pathnames.h externs.h
hashlib.o: assoc.h ${BASHINCDIR}/ocache.h ${BASHINCDIR}/chartypes.h
input.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
input.o: command.h ${BASHINCDIR}/stdc.h general.h xmalloc.h input.h error.h externs.h
input.o: quit.h shell.h pathnames.h
@@ -1065,12 +1097,14 @@ list.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h $
list.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
list.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
list.o: make_cmd.h subst.h sig.h pathnames.h externs.h
locale.o: config.h bashtypes.h bashintl.h ${LIBINTL_H} bashansi.h ${BASHINCDIR}/ansi_stdlib.h
list.o: ${BASHINCDIR}/ocache.h ${BASHINCDIR}/chartypes.h bashansi.h assoc.h
locale.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
locale.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
locale.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
locale.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
locale.o: make_cmd.h subst.h sig.h pathnames.h externs.h
locale.o: ${BASHINCDIR}/chartypes.h
locale.o: input.h assoc.h ${BASHINCDIR}/ocache.h
mailcheck.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
mailcheck.o: ${BASHINCDIR}/posixtime.h
mailcheck.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
@@ -1078,12 +1112,15 @@ mailcheck.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h
mailcheck.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
mailcheck.o: make_cmd.h subst.h sig.h pathnames.h externs.h
mailcheck.o: execute_cmd.h mailcheck.h
mailcheck.o: ${BASHINCDIR}/ocache.h ${BASHINCDIR}/chartypes.h assoc.h
make_cmd.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h bashansi.h
make_cmd.o: command.h ${BASHINCDIR}/stdc.h general.h xmalloc.h error.h flags.h make_cmd.h
make_cmd.o: variables.h arrayfunc.h conftypes.h array.h hashlib.h subst.h input.h externs.h
make_cmd.o: jobs.h quit.h sig.h siglist.h syntax.h dispose_cmd.h parser.h
make_cmd.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h ${BASHINCDIR}/ocache.h
make_cmd.o: shell.h execute_cmd.h pathnames.h
make_cmd.o: $(BASHINCDIR)/maxpath.h make_cmd.c assoc.h $(BASHINCDIR)/chartypes.h
make_cmd.o: unwind_prot.h $(BASHINCDIR)/posixjmp.h bashjmp.h $(BASHINCDIR)/posixwait.h
y.tab.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/memalloc.h
y.tab.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
y.tab.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
@@ -1091,6 +1128,8 @@ y.tab.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
y.tab.o: make_cmd.h subst.h sig.h pathnames.h externs.h test.h execute_cmd.o
y.tab.o: trap.h flags.h parser.h input.h mailcheck.h $(DEFSRC)/common.h
y.tab.o: $(DEFDIR)/builtext.h bashline.h bashhist.h jobs.h siglist.h alias.h
y.tab.o: ${BASHINCDIR}/typemax.h assoc.h ${BASHINCDIR}/ocache.h
y.tab.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h ${BASHINCDIR}/posixwait.h
pathexp.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
pathexp.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
pathexp.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
@@ -1099,6 +1138,7 @@ pathexp.o: make_cmd.h subst.h sig.h pathnames.h externs.h
pathexp.o: pathexp.h flags.h
pathexp.o: $(GLOB_LIBSRC)/glob.h $(GLOB_LIBSRC)/strmatch.h
pathexp.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
pathexp.o: ${BASHINCDIR}/ocache.h ${BASHINCDIR}/chartypes.h assoc.h
print_cmd.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
print_cmd.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
print_cmd.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
@@ -1106,11 +1146,15 @@ print_cmd.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
print_cmd.o: make_cmd.h subst.h sig.h pathnames.h externs.h
print_cmd.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
print_cmd.o: ${GRAM_H} $(DEFSRC)/common.h
print_cmd.o: flags.h input.h assoc.h
print_cmd.o: $(BASHINCDIR)/ocache.h $(BASHINCDIR)/chartypes.h
redir.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/filecntl.h
redir.o: ${BASHINCDIR}/memalloc.h shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
redir.o: general.h xmalloc.h variables.h arrayfunc.h conftypes.h array.h hashlib.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h
redir.o: dispose_cmd.h make_cmd.h subst.h sig.h pathnames.h externs.h
redir.o: flags.h execute_cmd.h redir.h input.h
redir.o: ${DEFDIR}/pipesize.h
redir.o: trap.h assoc.h $(BASHINCDIR)/ocache.h $(BASHINCDIR)/chartypes.h
shell.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/filecntl.h
shell.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
shell.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
@@ -1118,7 +1162,8 @@ shell.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
shell.o: make_cmd.h subst.h sig.h pathnames.h externs.h parser.h
shell.o: flags.h trap.h mailcheck.h builtins.h $(DEFSRC)/common.h
shell.o: jobs.h siglist.h input.h execute_cmd.h findcmd.h bashhist.h bashline.h
shell.o: ${GLOB_LIBSRC}/strmatch.h ${BASHINCDIR}/posixtime.h
shell.o: ${GLOB_LIBSRC}/strmatch.h ${BASHINCDIR}/posixtime.h ${BASHINCDIR}/posixwait.h
shell.o: ${BASHINCDIR}/ocache.h ${BASHINCDIR}/chartypes.h assoc.h alias.h
sig.o: config.h bashtypes.h
sig.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
sig.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
@@ -1132,6 +1177,7 @@ stringlib.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h comman
stringlib.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
stringlib.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
stringlib.o: make_cmd.h subst.h sig.h pathnames.h externs.h
stringlib.o: bashansi.h pathexp.h assoc.h $(BASHINCDIR)/ocache.h
stringlib.o: ${GLOB_LIBSRC}/glob.h ${GLOB_LIBSRC}/strmatch.h
subst.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/posixstat.h
subst.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
@@ -1149,6 +1195,8 @@ test.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h $
test.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
test.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
test.o: make_cmd.h subst.h sig.h pathnames.h externs.h test.h
test.o: ${BASHINCDIR}/stat-time.h ${BASHINCDIR}/ocache.h ${BASHINCDIR}/chartypes.h
test.o: $(GLOB_LIBSRC)/strmatch.h bashansi.h pathexp.h assoc.h
test.o: ${DEFSRC}/common.h
trap.o: config.h bashtypes.h trap.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
trap.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
@@ -1159,6 +1207,7 @@ trap.o: signames.h $(DEFSRC)/common.h
trap.o: ${DEFDIR}/builtext.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
variables.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
variables.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
variables.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
@@ -1167,15 +1216,16 @@ variables.o: make_cmd.h subst.h sig.h pathnames.h externs.h parser.h
variables.o: flags.h execute_cmd.h mailcheck.h input.h $(DEFSRC)/common.h
variables.o: findcmd.h bashhist.h hashcmd.h pathexp.h
variables.o: pcomplete.h ${BASHINCDIR}/chartypes.h
variables.o: ${BASHINCDIR}/posixtime.h assoc.h
variables.o: ${BASHINCDIR}/posixtime.h assoc.h ${DEFSRC}/getopt.h
variables.o: version.h $(DEFDIR)/builtext.h
version.o: conftypes.h patchlevel.h version.h
version.o: conftypes.h patchlevel.h version.h
xmalloc.o: config.h bashtypes.h ${BASHINCDIR}/ansi_stdlib.h error.h
xmalloc.o: ${BASHINCDIR}/stdc.h $(ALLOC_LIBSRC)/shmalloc.h
# job control
jobs.o: config.h bashtypes.h trap.h ${BASHINCDIR}/filecntl.h input.h ${BASHINCDIR}/shtty.h
jobs.o: bashansi.h ${BASHINCDIR}/ansi_stdlib.h
jobs.o: bashansi.h ${BASHINCDIR}/ansi_stdlib.h assoc.h
jobs.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
jobs.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
jobs.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h parser.h
@@ -1183,10 +1233,12 @@ jobs.o: execute_cmd.h make_cmd.h subst.h sig.h pathnames.h externs.h
jobs.o: jobs.h flags.h $(DEFSRC)/common.h $(DEFDIR)/builtext.h
jobs.o: ${BASHINCDIR}/posixwait.h ${BASHINCDIR}/unionwait.h
jobs.o: ${BASHINCDIR}/posixtime.h
jobs.o: $(BASHINCDIR)/ocache.h $(BASHINCDIR)/chartypes.h $(BASHINCDIR)/typemax.h
nojobs.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h bashjmp.h ${BASHINCDIR}/posixjmp.h
nojobs.o: command.h ${BASHINCDIR}/stdc.h general.h xmalloc.h jobs.h quit.h siglist.h externs.h
nojobs.o: sig.h error.h ${BASHINCDIR}/shtty.h input.h parser.h
nojobs.o: $(DEFDIR)/builtext.h
nojobs.o: $(BASHINCDIR)/ocache.h $(BASHINCDIR)/chartypes.h $(BASHINCDIR)/typemax.h
# shell features that may be compiled in
@@ -1195,6 +1247,7 @@ array.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h
array.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
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
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
@@ -1202,6 +1255,7 @@ arrayfunc.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h
arrayfunc.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
arrayfunc.o: make_cmd.h subst.h sig.h pathnames.h externs.h pathexp.h
arrayfunc.o: execute_cmd.h
arrayfunc.o: assoc.h $(BASHINCDIR)/ocache.h $(BASHINCDIR)/chartypes.h
arrayfunc.o: $(DEFSRC)/common.h
arrayfunc.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
assoc.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
@@ -1211,6 +1265,7 @@ assoc.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h
assoc.o: assoc.h hashlib.h
assoc.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
assoc.o: make_cmd.h subst.h sig.h pathnames.h externs.h
assoc.o: array.h ${BASHINCDIR}/ocache.h ${BASHINCDIR}/chartypes.h
assoc.o: $(DEFSRC)/common.h
braces.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
braces.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
@@ -1218,16 +1273,18 @@ braces.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h ar
braces.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
braces.o: make_cmd.h subst.h sig.h pathnames.h externs.h
braces.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
braces.o: ${BASHINCDIR}/typemax.h ${BASHINCDIR}/ocache.h ${BASHINCDIR}/chartypes.h
alias.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h command.h ${BASHINCDIR}/stdc.h
alias.o: general.h xmalloc.h bashtypes.h externs.h alias.h
alias.o: pcomplete.h
alias.o: pcomplete.h hashlib.h
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: unwind_prot.h dispose_cmd.h make_cmd.h subst.h sig.h pathnames.h
pcomplib.o: externs.h ${BASHINCDIR}/maxpath.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
@@ -1246,13 +1303,15 @@ bashhist.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h
bashhist.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
bashhist.o: make_cmd.h subst.h sig.h pathnames.h externs.h parser.h
bashhist.o: flags.h input.h parser.h pathexp.h $(DEFSRC)/common.h bashline.h
bashhist.o: $(GLOB_LIBSRC)/strmatch.h
bashhist.o: ${BASHINCDIR}/ocache.h ${BASHINCDIR}/chartypes.h bashhist.h assoc.h
bashhist.o: $(GLOB_LIBSRC)/strmatch.h ${GLOB_LIBSRC}/glob.h
bashline.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
bashline.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
bashline.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
bashline.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
bashline.o: make_cmd.h subst.h sig.h pathnames.h externs.h parser.h
bashline.o: builtins.h bashhist.h bashline.h execute_cmd.h findcmd.h pathexp.h
bashline.o: trap.h flags.h assoc.h $(BASHINCDIR)/ocache.h
bashline.o: $(DEFSRC)/common.h $(GLOB_LIBSRC)/glob.h alias.h
bashline.o: pcomplete.h ${BASHINCDIR}/chartypes.h input.h
bashline.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
@@ -1263,32 +1322,51 @@ bracecomp.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h
bracecomp.o: array.h hashlib.h alias.h builtins.h
bracecomp.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
bracecomp.o: make_cmd.h subst.h sig.h pathnames.h externs.h
bracecomp.o: ${BASHINCDIR}/ocache.h ${BASHINCDIR}/chartypes.h bashhist.h assoc.h
bracecomp.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
# library dependencies
bashhist.o: $(RL_LIBSRC)/rltypedefs.h
bashline.o: $(RL_LIBSRC)/rlconf.h
bashline.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/rlstdc.h
bashline.o: $(RL_LIBSRC)/chardefs.h $(RL_LIBSRC)/readline.h
bashline.o: $(RL_LIBSRC)/rltypedefs.h ${RL_LIBSRC}/rlmbutil.h
bracecomp.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/chardefs.h
bracecomp.o: $(RL_LIBSRC)/readline.h $(RL_LIBSRC)/rlstdc.h
bracecomp.o: $(RL_LIBSRC)/rltypedefs.h
y.tab.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/chardefs.h
y.tab.o: $(RL_LIBSRC)/readline.h $(RL_LIBSRC)/rlstdc.h
y.tab.o: $(RL_LIBSRC)/rltypedefs.h
subst.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/chardefs.h
subst.o: $(RL_LIBSRC)/readline.h $(RL_LIBSRC)/rlstdc.h
shell.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/chardefs.h
shell.o: $(RL_LIBSRC)/readline.h $(RL_LIBSRC)/rlstdc.h
shell.o: $(RL_LIBSRC)/rltypedefs.h
variables.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/chardefs.h
variables.o: $(RL_LIBSRC)/readline.h $(RL_LIBSRC)/rlstdc.h
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
shell.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h
variables.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h
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
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
shell.o: $(TILDE_LIBSRC)/tilde.h
subst.o: $(TILDE_LIBSRC)/tilde.h
variables.o: $(TILDE_LIBSRC)/tilde.h
jobs.o: $(TILDE_LIBSRC)/tilde.h
y.tab.o: $(TILDE_LIBSRC)/tilde.h
# libintl dependencies
arrayfunc.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
@@ -1302,6 +1380,7 @@ expr.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
general.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
input.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
jobs.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
locale.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
mailcheck.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
make_cmd.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
nojobs.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
@@ -1321,6 +1400,9 @@ variables.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
version.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
xmalloc.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
# XXX
$(MALLOC_SOURCE): bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
signames.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
# XXX - dependencies checked through here
@@ -1360,6 +1442,7 @@ builtins/getopt.o: make_cmd.h subst.h sig.h pathnames.h externs.h
builtins/getopt.o: $(DEFSRC)/getopt.h
builtins/mkbuiltins.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h ${BASHINCDIR}/filecntl.h
builtins/mkbuiltins.o: bashansi.h ${BASHINCDIR}/ansi_stdlib.h
builtins/mkbuiltins.o: $(BASHINCDIR)/stdc.h
# builtin def files
builtins/alias.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
@@ -1389,6 +1472,10 @@ builtins/cd.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xma
builtins/cd.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
builtins/cd.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/cd.o: $(DEFSRC)/common.h quit.h pathnames.h
builtins/colon.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
builtins/colon.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
builtins/colon.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/colon.o: pathnames.h
builtins/command.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
builtins/command.o: quit.h $(DEFSRC)/bashgetopt.h
builtins/command.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
@@ -1401,6 +1488,7 @@ builtins/echo.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h x
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
builtins/echo.o: pathnames.h
builtins/echo.o: $(DEFSRC)/common.h
builtins/enable.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
builtins/enable.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
builtins/enable.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+192 -6
View File
@@ -1,3 +1,189 @@
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.
1. New Features in Bash
a. `bind -x' now supports different bindings for different editing modes and
keymaps.
b. Bash attempts to optimize the number of times it forks when executing
commands in subshells and from `bash -c'.
c. Here documents and here strings now use pipes for the expanded document if
it's smaller than the pipe buffer size, reverting to temporary files if it's
larger.
d. There are new loadable builtins: mktemp, accept, mkfifo, csv, cut/lcut
e. In posix mode, `trap -p' now displays signals whose disposition is SIG_DFL
and those that were SIG_IGN when the shell starts.
f. The shell now expands the history number (e.g., in PS1) even if it is not
currently saving commands to the history list.
g. `read -e' may now be used with arbitrary file descriptors (`read -u N').
h. The `select' builtin now runs traps if its internal call to the read builtin
is interrupted by a signal.
i. SRANDOM: a new variable that expands to a 32-bit random number that is not
produced by an LCRNG, and uses getrandom/getentropy, falling back to
/dev/urandom or arc4random if available. There is a fallback generator if
none of these are available.
j. shell-transpose-words: a new bindable readline command that uses the same
definition of word as shell-forward-word, etc.
k. The shell now adds default bindings for shell-forward-word,
shell-backward-word, shell-transpose-words, and shell-kill-word.
l. Bash now allows ARGV0 appearing in the initial shell environment to set $0.
m. If `unset' is executed without option arguments, bash tries to unset a shell
function if a name argument cannot be a shell variable name because it's not
an identifier.
n. The `test -N' operator uses nanosecond timestamp granularity if it's
available.
o. Bash posix mode now treats assignment statements preceding shell function
definitions the same as in its default mode, since POSIX has changed and
no longer requires those assignments to persist after the function returns
(POSIX interp 654).
p. BASH_REMATCH is no longer readonly.
q. wait: has a new -p VARNAME option, which stores the PID returned by `wait -n'
or `wait' without arguments.
r. Sorting the results of pathname expansion now uses byte-by-byte comparisons
if two strings collate equally to impose a total order; the result of a
POSIX interpretation.
s. Bash now allows SIGINT trap handlers to execute recursively.
t. Bash now saves and restores state around setting and unsetting posix mode,
instead of having unsetting posix mode set a known state.
u. Process substitution is now available in posix mode.
v. READLINE_MARK: a new variable available while executing commands bound with
`bind -x', contains the value of the mark.
w. Bash removes SIGCHLD from the set of blocked signals if it's blocked at shell
startup.
x. `test -v N' can now test whether or not positional parameter N is set.
y. `local' now honors the `-p' option to display all local variables at the
current context.
z. The `@a' variable transformation now prints attributes for unset array
variables.
aa. The `@A' variable transformation now prints a declare command that sets a
variable's attributes if the variable has attributes but is unset.
bb. `declare' and `local' now have a -I option that inherits attributes and
value from a variable with the same name at a previous scope.
cc. When run from a -c command, `jobs' now reports the status of completed jobs.
dd. New `U', `u', and `L' parameter transformations to convert to uppercase,
convert first character to uppercase, and convert to lowercase,
respectively.
ee. PROMPT_COMMAND: can now be an array variable, each element of which can
contain a command to be executed like a string PROMPT_COMMAND variable.
ff. `ulimit' has a -R option to report and set the RLIMIT_RTTIME resource.
gg. Associative arrays may be assigned using a list of key-value pairs within
a compound assignment. Compound assignments where the words are not of
the form [key]=value are assumed to be key-value assignments. A missing or
empty key is an error; a missing value is treated as NULL. Assignments may
not mix the two forms.
hh. New `K' parameter transformation to display associative arrays as key-
value pairs.
ii. Writing history to syslog now handles messages longer than the syslog max
length by writing multiple messages with a sequence number.
jj. SECONDS and RANDOM may now be assigned using arithmetic expressions, since
they are nominally integer variables. LINENO is not an integer variable.
kk. Bash temporarily suppresses the verbose option when running the DEBUG trap
while running a command from the `fc' builtin.
ll. `wait -n' now accepts a list of job specifications as arguments and will
wait for the first one in the list to change state.
mm. The associative array implementation can now dynamically increase the
size of the hash table based on insertion patterns.
nn. HISTFILE is now readonly in a restricted shell.
oo. The bash malloc now returns memory that is 16-byte aligned on 64-bit
systems.
pp. If the hash builtin is listing hashed filenames portably, don't print
anything if the table is empty.
qq. GLOBIGNORE now ignores `.' and `..' as a terminal pathname component.
rr. Bash attempts to optimize away forks in the last command in a function body
under appropriate circumstances.
ss. The globbing code now uses fnmatch(3) to check collation elements (if
available) even in cases without multibyte characters.
tt. The `fg' and `bg' builtins now return an error in a command substitution
when asked to restart a job inherited from the parent shell.
uu. The shell now attempts to unlink all FIFOs on exit, whether a consuming
process has finished with them or not.
vv. There is a new contributed loadable builtin: asort.
2. New Features in Readline
a. If a second consecutive completion attempt produces matches where the first
did not, treat it as a new completion attempt and insert a match as
appropriate.
b. Bracketed paste mode works in more places: incremental search strings, vi
overstrike mode, character search, and reading numeric arguments.
c. Readline automatically switches to horizontal scrolling if the terminal has
only one line.
d. Unbinding all key sequences bound to a particular readline function now
descends into keymaps for multi-key sequences.
e. rl-clear-display: new bindable command that clears the screen and, if
possible, the scrollback buffer (bound to emacs mode M-C-l by default).
f. New active mark and face feature: when enabled, it will highlight the text
inserted by a bracketed paste (the `active region') and the text found by
incremental and non-incremental history searches. This is tied to bracketed
paste and can be disabled by turning off bracketed paste.
g. Readline sets the mark in several additional commands.
h. Bracketed paste mode is enabled by default.
i. Readline tries to take advantage of the more regular structure of UTF-8
characters to identify the beginning and end of characters when moving
through the line buffer.
j. The bindable operate-and-get-next command (and its default bindings) are
now part of readline instead of a bash-specific addition.
k. The signal cleanup code now blocks SIGINT while processing after a SIGINT.
-------------------------------------------------------------------------------
This is a terse description of the new features added to bash-5.0 since
the release of bash-4.4. As always, the manual page (doc/bash.1) is
the place to look for complete descriptions.
@@ -29,7 +215,7 @@ h. The `name' argument to the `coproc' reserved word now undergoes word
i. A nameref name resolution loop in a function now resolves to a variable by
that name in the global scope.
j. The `wait' builtin now has a `-f' option, which signfies to wait until the
j. The `wait' builtin now has a `-f' option, which signifies to wait until the
specified job or process terminates, instead of waiting until it changes
state.
@@ -328,7 +514,7 @@ rr. Bash now uses mktemp() when creating internal temporary files; it produces
2. New Features in Readline
a. The history truncation code now uses the same error recovery mechansim as
a. The history truncation code now uses the same error recovery mechanism as
the history writing code, and restores the old version of the history file
on error. The error recovery mechanism handles symlinked history files.
@@ -1549,7 +1735,7 @@ e. The history expansion code now allows any character to terminate a
f. New bindable variable `history-preserve-point'. If set, the history
code attempts to place the user at the same location on each history
line retrived with previous-history or next-history.
line retrieved with previous-history or next-history.
-------------------------------------------------------------------------------
This is a terse description of the new features added to bash-2.05 since
@@ -1578,7 +1764,7 @@ c. `complete' and `compgen' now take a `-o value' option, which controls some
d. A new loadable builtin, realpath, which canonicalizes and expands symlinks
in pathname arguments.
e. When `set' is called without options, it prints function defintions in a
e. When `set' is called without options, it prints function definitions in a
way that allows them to be reused as input. This affects `declare' and
`declare -p' as well. This only happens when the shell is not in POSIX
mode, since POSIX.2 forbids this behavior.
@@ -1989,7 +2175,7 @@ p. The shell now supports integer-indexed arrays of unlimited length,
q. ${!var}: indirect variable expansion, equivalent to eval \${$var}.
r. ${paramter:offset[:length]}: variable substring extraction.
r. ${parameter:offset[:length]}: variable substring extraction.
s. ${parameter/pattern[/[/]string]}: variable pattern substitution.
@@ -2113,7 +2299,7 @@ iii. Changes to Posix mode:
any symbolic links.
o A non-interactive shell exits if a variable assignment error
occurs when no command name follows the assignment statements.
o A non-interactive shell exits if the interation variable in a
o A non-interactive shell exits if the iteration variable in a
`for' statement or the selection variable in a `select' statement
is read-only or another variable assignment error occurs.
o The `<>' redirection operator now opens a file for both stdin and
+1 -1
View File
@@ -1,4 +1,4 @@
Platform-Specific Configuration and Operation Notes [somewhat dated]
Platform-Specific Configuration and Operation Notes [very dated]
====================================================================
1. configure --without-gnu-malloc on:
+41 -40
View File
@@ -17,106 +17,108 @@ The following list is what's changed when 'POSIX mode' is in effect:
re-search '$PATH' to find the new location. This is also available
with 'shopt -s checkhash'.
3. The message printed by the job control code and builtins when a job
exits with a non-zero status is 'Done(status)'.
3. Bash will not insert a command without the execute bit set into the
command hash table, even if it returns it as a (last-ditch) result
from a '$PATH' search.
4. The message printed by the job control code and builtins when a job
exits with a non-zero status is 'Done(status)'.
5. The message printed by the job control code and builtins when a job
is stopped is 'Stopped(SIGNAME)', where SIGNAME is, for example,
'SIGTSTP'.
5. Alias expansion is always enabled, even in non-interactive shells.
6. Alias expansion is always enabled, even in non-interactive shells.
6. Reserved words appearing in a context where reserved words are
7. Reserved words appearing in a context where reserved words are
recognized do not undergo alias expansion.
7. The POSIX 'PS1' and 'PS2' expansions of '!' to the history number
8. The POSIX 'PS1' and 'PS2' expansions of '!' to the history number
and '!!' to '!' are enabled, and parameter expansion is performed
on the values of 'PS1' and 'PS2' regardless of the setting of the
'promptvars' option.
8. The POSIX startup files are executed ('$ENV') rather than the
9. The POSIX startup files are executed ('$ENV') rather than the
normal Bash files.
9. Tilde expansion is only performed on assignments preceding a
10. Tilde expansion is only performed on assignments preceding a
command name, rather than on all assignment statements on the line.
10. The default history file is '~/.sh_history' (this is the default
11. The default history file is '~/.sh_history' (this is the default
value of '$HISTFILE').
11. Redirection operators do not perform filename expansion on the
12. Redirection operators do not perform filename expansion on the
word in the redirection unless the shell is interactive.
12. Redirection operators do not perform word splitting on the word in
13. Redirection operators do not perform word splitting on the word in
the redirection.
13. Function names must be valid shell 'name's. That is, they may not
14. Function names must be valid shell 'name's. That is, they may not
contain characters other than letters, digits, and underscores, and
may not start with a digit. Declaring a function with an invalid
name causes a fatal syntax error in non-interactive shells.
14. Function names may not be the same as one of the POSIX special
15. Function names may not be the same as one of the POSIX special
builtins.
15. POSIX special builtins are found before shell functions during
16. POSIX special builtins are found before shell functions during
command lookup.
16. When printing shell function definitions (e.g., by 'type'), Bash
17. When printing shell function definitions (e.g., by 'type'), Bash
does not print the 'function' keyword.
17. Literal tildes that appear as the first character in elements of
18. Literal tildes that appear as the first character in elements of
the 'PATH' variable are not expanded as described above under *note
Tilde Expansion::.
18. The 'time' reserved word may be used by itself as a command. When
19. The 'time' reserved word may be used by itself as a command. When
used in this way, it displays timing statistics for the shell and
its completed children. The 'TIMEFORMAT' variable controls the
format of the timing information.
19. When parsing and expanding a ${...} expansion that appears within
20. When parsing and expanding a ${...} expansion that appears within
double quotes, single quotes are no longer special and cannot be
used to quote a closing brace or other special character, unless
the operator is one of those defined to perform pattern removal.
In this case, they do not have to appear as matched pairs.
20. The parser does not recognize 'time' as a reserved word if the
21. The parser does not recognize 'time' as a reserved word if the
next token begins with a '-'.
21. The '!' character does not introduce history expansion within a
22. The '!' character does not introduce history expansion within a
double-quoted string, even if the 'histexpand' option is enabled.
22. If a POSIX special builtin returns an error status, a
23. If a POSIX special builtin returns an error status, a
non-interactive shell exits. The fatal errors are those listed in
the POSIX standard, and include things like passing incorrect
options, redirection errors, variable assignment errors for
assignments preceding the command name, and so on.
23. A non-interactive shell exits with an error status if a variable
24. A non-interactive shell exits with an error status if a variable
assignment error occurs when no command name follows the assignment
statements. A variable assignment error occurs, for example, when
trying to assign a value to a readonly variable.
24. A non-interactive shell exits with an error status if a variable
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.
25. A non-interactive shell exits with an error status if the
26. A non-interactive shell exits with an error status if the
iteration variable in a 'for' statement or the selection variable
in a 'select' statement is a readonly variable.
26. Non-interactive shells exit if FILENAME in '.' FILENAME is not
27. Non-interactive shells exit if FILENAME in '.' FILENAME is not
found.
27. Non-interactive shells exit if a syntax error in an arithmetic
28. Non-interactive shells exit if a syntax error in an arithmetic
expansion results in an invalid expression.
28. Non-interactive shells exit if a parameter expansion error occurs.
29. Non-interactive shells exit if a parameter expansion error occurs.
29. Non-interactive shells exit if there is a syntax error in a script
30. Non-interactive shells exit if there is a syntax error in a script
read with the '.' or 'source' builtins, or in a string processed by
the 'eval' builtin.
30. Process substitution is not available.
31. While variable indirection is available, it may not be applied to
the '#' and '?' special parameters.
@@ -127,39 +129,38 @@ The following list is what's changed when 'POSIX mode' is in effect:
33. Assignment statements preceding POSIX special builtins persist in
the shell environment after the builtin completes.
34. Assignment statements preceding shell function calls persist in
the shell environment after the function returns, as if a POSIX
special builtin command had been executed.
35. The 'command' builtin does not prevent builtins that take
34. The 'command' builtin does not prevent builtins that take
assignment statements as arguments from expanding them as
assignment statements; when not in POSIX mode, assignment builtins
lose their assignment statement expansion properties when preceded
by 'command'.
36. The 'bg' builtin uses the required format to describe each job
35. The 'bg' builtin uses the required format to describe each job
placed in the background, which does not include an indication of
whether the job is the current or previous job.
37. The output of 'kill -l' prints all the signal names on a single
36. The output of 'kill -l' prints all the signal names on a single
line, separated by spaces, without the 'SIG' prefix.
38. The 'kill' builtin does not accept signal names with a 'SIG'
37. The 'kill' builtin does not accept signal names with a 'SIG'
prefix.
39. The 'export' and 'readonly' builtin commands display their output
38. The 'export' and 'readonly' builtin commands display their output
in the format required by POSIX.
40. The 'trap' builtin displays signal names without the leading
39. The 'trap' builtin displays signal names without the leading
'SIG'.
41. The 'trap' builtin doesn't check the first argument for a possible
40. The 'trap' builtin doesn't check the first argument for a possible
signal specification and revert the signal handling to the original
disposition if it is, unless that argument consists solely of
digits and is a valid signal number. If users want to reset the
handler for a given signal to the original disposition, they should
use '-' as the first argument.
41. 'trap -p' displays signals whose dispositions are set to SIG_DFL
and those that were ignored when the shell started.
42. The '.' and 'source' builtins do not search the current directory
for the filename argument if it is not found by searching 'PATH'.
+16 -2
View File
@@ -8,11 +8,13 @@ the standard shell. A restricted shell behaves identically to 'bash'
with the exception that the following are disallowed or not performed:
* Changing directories with the 'cd' builtin.
* Setting or unsetting the values of the 'SHELL', 'PATH', 'ENV', or
'BASH_ENV' variables.
* Setting or unsetting the values of the 'SHELL', 'PATH', 'HISTFILE',
'ENV', or 'BASH_ENV' variables.
* Specifying command names containing slashes.
* Specifying a filename containing a slash as an argument to the '.'
builtin command.
* Specifying a filename containing a slash as an argument to the
'history' builtin command.
* Specifying a filename containing a slash as an argument to the '-p'
option to the 'hash' builtin command.
* Importing function definitions from the shell environment at
@@ -35,3 +37,15 @@ When a command that is found to be a shell script is executed (*note
Shell Scripts::), 'rbash' turns off any restrictions in the shell
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
behavior (e.g., 'VISUAL' or 'PAGER').
Modern systems provide more secure ways to implement a restricted
environment, such as 'jails', 'zones', or 'containers'.
+3 -3
View File
@@ -1,7 +1,7 @@
Introduction
============
This is GNU Bash, version 5.0. Bash is the GNU Project's Bourne
This is GNU Bash, version 5.1. 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.3 and
bash-4.4. For details, see the file COMPAT. The NEWS file tersely
of Bash and previous widely-distributed versions, bash-4.4 and
bash-5.0. 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
+85 -2045
View File
File diff suppressed because it is too large Load Diff
+21 -15
View File
@@ -1,7 +1,7 @@
/* alias.c -- Not a full alias, but just the kind that we use in the
shell. Csh style alias is somewhere else (`over there, in a box'). */
/* Copyright (C) 1987-2015 Free Software Foundation, Inc.
/* Copyright (C) 1987-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -48,17 +48,17 @@
#define ALIAS_HASH_BUCKETS 64 /* must be power of two */
typedef int sh_alias_map_func_t __P((alias_t *));
typedef int sh_alias_map_func_t PARAMS((alias_t *));
static void free_alias_data __P((PTR_T));
static alias_t **map_over_aliases __P((sh_alias_map_func_t *));
static void sort_aliases __P((alias_t **));
static int qsort_alias_compare __P((alias_t **, alias_t **));
static void free_alias_data PARAMS((PTR_T));
static alias_t **map_over_aliases PARAMS((sh_alias_map_func_t *));
static void sort_aliases PARAMS((alias_t **));
static int qsort_alias_compare PARAMS((alias_t **, alias_t **));
#if defined (READLINE)
static int skipquotes __P((char *, int));
static int skipws __P((char *, int));
static int rd_token __P((char *, int));
static int skipquotes PARAMS((char *, int));
static int skipws PARAMS((char *, int));
static int rd_token PARAMS((char *, int));
#endif
/* Non-zero means expand all words on the line. Otherwise, expand
@@ -127,9 +127,12 @@ add_alias (name, value)
free (temp->value);
temp->value = savestring (value);
temp->flags &= ~AL_EXPANDNEXT;
n = value[strlen (value) - 1];
if (n == ' ' || n == '\t')
temp->flags |= AL_EXPANDNEXT;
if (value[0])
{
n = value[strlen (value) - 1];
if (n == ' ' || n == '\t')
temp->flags |= AL_EXPANDNEXT;
}
}
else
{
@@ -138,9 +141,12 @@ add_alias (name, value)
temp->value = savestring (value);
temp->flags = 0;
n = value[strlen (value) - 1];
if (n == ' ' || n == '\t')
temp->flags |= AL_EXPANDNEXT;
if (value[0])
{
n = value[strlen (value) - 1];
if (n == ' ' || n == '\t')
temp->flags |= AL_EXPANDNEXT;
}
elt = hash_insert (savestring (name), aliases, HASH_NOSRCH);
elt->data = temp;
+11 -11
View File
@@ -1,6 +1,6 @@
/* alias.h -- structure definitions. */
/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
/* Copyright (C) 1987-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -38,36 +38,36 @@ typedef struct alias {
/* The list of known aliases. */
extern HASH_TABLE *aliases;
extern void initialize_aliases __P((void));
extern void initialize_aliases PARAMS((void));
/* Scan the list of aliases looking for one with NAME. Return NULL
if the alias doesn't exist, else a pointer to the alias. */
extern alias_t *find_alias __P((char *));
extern alias_t *find_alias PARAMS((char *));
/* Return the value of the alias for NAME, or NULL if there is none. */
extern char *get_alias_value __P((char *));
extern char *get_alias_value PARAMS((char *));
/* Make a new alias from NAME and VALUE. If NAME can be found,
then replace its value. */
extern void add_alias __P((char *, char *));
extern void add_alias PARAMS((char *, char *));
/* Remove the alias with name NAME from the alias list. Returns
the index of the removed alias, or -1 if the alias didn't exist. */
extern int remove_alias __P((char *));
extern int remove_alias PARAMS((char *));
/* Remove all aliases. */
extern void delete_all_aliases __P((void));
extern void delete_all_aliases PARAMS((void));
/* Return an array of all defined aliases. */
extern alias_t **all_aliases __P((void));
extern alias_t **all_aliases PARAMS((void));
/* Expand a single word for aliases. */
extern char *alias_expand_word __P((char *));
extern char *alias_expand_word PARAMS((char *));
/* Return a new line, with any aliases expanded. */
extern char *alias_expand __P((char *));
extern char *alias_expand PARAMS((char *));
/* Helper definition for the parser */
extern void clear_string_list_expander __P((alias_t *));
extern void clear_string_list_expander PARAMS((alias_t *));
#endif /* _ALIAS_H_ */
+75 -12
View File
@@ -9,7 +9,7 @@
* chet@ins.cwru.edu
*/
/* Copyright (C) 1997-2016 Free Software Foundation, Inc.
/* Copyright (C) 1997-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -61,7 +61,7 @@
ae->next = new; \
} while (0)
static char *array_to_string_internal __P((ARRAY_ELEMENT *, ARRAY_ELEMENT *, char *, int));
static char *array_to_string_internal PARAMS((ARRAY_ELEMENT *, ARRAY_ELEMENT *, char *, int));
static char *spacesep = " ";
@@ -398,10 +398,10 @@ ARRAY *array;
* Since arrays are sparse, unset array elements are not counted.
*/
char *
array_subrange (a, start, nelem, starsub, quoted)
array_subrange (a, start, nelem, starsub, quoted, pflags)
ARRAY *a;
arrayind_t start, nelem;
int starsub, quoted;
int starsub, quoted, pflags;
{
ARRAY *a2;
ARRAY_ELEMENT *h, *p;
@@ -436,7 +436,7 @@ int starsub, quoted;
array_dispose(a2);
if (wl == 0)
return (char *)NULL;
t = string_list_pos_params(starsub ? '*' : '@', wl, quoted);
t = string_list_pos_params(starsub ? '*' : '@', wl, quoted, pflags); /* XXX */
dispose_words(wl);
return t;
@@ -449,7 +449,7 @@ char *pat, *rep;
int mflags;
{
char *t;
int pchar, qflags;
int pchar, qflags, pflags;
WORD_LIST *wl, *save;
if (a == 0 || array_head(a) == 0 || array_empty(a))
@@ -467,8 +467,9 @@ int mflags;
pchar = (mflags & MATCH_STARSUB) == MATCH_STARSUB ? '*' : '@';
qflags = (mflags & MATCH_QUOTED) == MATCH_QUOTED ? Q_DOUBLE_QUOTES : 0;
pflags = (mflags & MATCH_ASSIGNRHS) ? PF_ASSIGNRHS : 0;
t = string_list_pos_params (pchar, save, qflags);
t = string_list_pos_params (pchar, save, qflags, pflags);
dispose_words(save);
return t;
@@ -482,7 +483,7 @@ int modop;
int mflags;
{
char *t;
int pchar, qflags;
int pchar, qflags, pflags;
WORD_LIST *wl, *save;
if (a == 0 || array_head(a) == 0 || array_empty(a))
@@ -500,8 +501,9 @@ int mflags;
pchar = (mflags & MATCH_STARSUB) == MATCH_STARSUB ? '*' : '@';
qflags = (mflags & MATCH_QUOTED) == MATCH_QUOTED ? Q_DOUBLE_QUOTES : 0;
pflags = (mflags & MATCH_ASSIGNRHS) ? PF_ASSIGNRHS : 0;
t = string_list_pos_params (pchar, save, qflags);
t = string_list_pos_params (pchar, save, qflags, pflags);
dispose_words(save);
return t;
@@ -808,22 +810,29 @@ WORD_LIST *list;
}
char **
array_to_argv (a)
array_to_argv (a, countp)
ARRAY *a;
int *countp;
{
char **ret, *t;
int i;
ARRAY_ELEMENT *ae;
if (a == 0 || array_empty(a))
if (a == 0 || array_empty(a)) {
if (countp)
*countp = 0;
return ((char **)NULL);
}
ret = strvec_create (array_num_elements (a) + 1);
i = 0;
for (ae = element_forw(a->head); ae != a->head; ae = element_forw(ae)) {
t = element_value (ae);
ret[i++] = t ? savestring (t) : (char *)NULL;
if (t)
ret[i++] = savestring (t);
}
ret[i] = (char *)NULL;
if (countp)
*countp = i;
return (ret);
}
@@ -872,6 +881,60 @@ int quoted;
return(result);
}
char *
array_to_kvpair (a, quoted)
ARRAY *a;
int quoted;
{
char *result, *valstr, *is;
char indstr[INT_STRLEN_BOUND(intmax_t) + 1];
ARRAY_ELEMENT *ae;
int rsize, rlen, elen;
if (a == 0 || array_empty (a))
return((char *)NULL);
result = (char *)xmalloc (rsize = 128);
result[rlen = 0] = '\0';
for (ae = element_forw(a->head); ae != a->head; ae = element_forw(ae)) {
is = inttostr (element_index(ae), indstr, sizeof(indstr));
valstr = element_value (ae) ?
(ansic_shouldquote (element_value (ae)) ?
ansic_quote (element_value(ae), 0, (int *)0) :
sh_double_quote (element_value (ae)))
: (char *)NULL;
elen = STRLEN (is) + 8 + STRLEN (valstr);
RESIZE_MALLOCED_BUFFER (result, rlen, (elen + 1), rsize, rsize);
strcpy (result + rlen, is);
rlen += STRLEN (is);
result[rlen++] = ' ';
if (valstr) {
strcpy (result + rlen, valstr);
rlen += STRLEN (valstr);
} else {
strcpy (result + rlen, "\"\"");
rlen += 2;
}
if (element_forw(ae) != a->head)
result[rlen++] = ' ';
FREE (valstr);
}
RESIZE_MALLOCED_BUFFER (result, rlen, 1, rsize, 8);
result[rlen] = '\0';
if (quoted) {
/* This is not as efficient as it could be... */
valstr = sh_single_quote (result);
free (result);
result = valstr;
}
return(result);
}
char *
array_to_assign (a, quoted)
ARRAY *a;
+40 -36
View File
@@ -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-2009 Free Software Foundation, Inc.
/* Copyright (C) 1997-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -27,14 +27,14 @@
typedef intmax_t arrayind_t;
enum atype {array_indexed, array_assoc};
enum atype {array_indexed, array_assoc}; /* only array_indexed used */
typedef struct array {
enum atype type;
arrayind_t max_index;
int num_elements;
struct array_element *lastref;
struct array_element *head;
struct array_element *lastref;
} ARRAY;
typedef struct array_element {
@@ -43,52 +43,53 @@ typedef struct array_element {
struct array_element *next, *prev;
} ARRAY_ELEMENT;
typedef int sh_ae_map_func_t __P((ARRAY_ELEMENT *, void *));
typedef int sh_ae_map_func_t PARAMS((ARRAY_ELEMENT *, void *));
/* Basic operations on entire arrays */
extern ARRAY *array_create __P((void));
extern void array_flush __P((ARRAY *));
extern void array_dispose __P((ARRAY *));
extern ARRAY *array_copy __P((ARRAY *));
extern ARRAY *array_slice __P((ARRAY *, ARRAY_ELEMENT *, ARRAY_ELEMENT *));
extern void array_walk __P((ARRAY *, sh_ae_map_func_t *, void *));
extern ARRAY *array_create PARAMS((void));
extern void array_flush PARAMS((ARRAY *));
extern void array_dispose PARAMS((ARRAY *));
extern ARRAY *array_copy PARAMS((ARRAY *));
extern ARRAY *array_slice PARAMS((ARRAY *, ARRAY_ELEMENT *, ARRAY_ELEMENT *));
extern void array_walk PARAMS((ARRAY *, sh_ae_map_func_t *, void *));
extern ARRAY_ELEMENT *array_shift __P((ARRAY *, int, int));
extern int array_rshift __P((ARRAY *, int, char *));
extern ARRAY_ELEMENT *array_unshift_element __P((ARRAY *));
extern int array_shift_element __P((ARRAY *, char *));
extern ARRAY_ELEMENT *array_shift PARAMS((ARRAY *, int, int));
extern int array_rshift PARAMS((ARRAY *, int, char *));
extern ARRAY_ELEMENT *array_unshift_element PARAMS((ARRAY *));
extern int array_shift_element PARAMS((ARRAY *, char *));
extern ARRAY *array_quote __P((ARRAY *));
extern ARRAY *array_quote_escapes __P((ARRAY *));
extern ARRAY *array_dequote __P((ARRAY *));
extern ARRAY *array_dequote_escapes __P((ARRAY *));
extern ARRAY *array_remove_quoted_nulls __P((ARRAY *));
extern ARRAY *array_quote PARAMS((ARRAY *));
extern ARRAY *array_quote_escapes PARAMS((ARRAY *));
extern ARRAY *array_dequote PARAMS((ARRAY *));
extern ARRAY *array_dequote_escapes PARAMS((ARRAY *));
extern ARRAY *array_remove_quoted_nulls PARAMS((ARRAY *));
extern char *array_subrange __P((ARRAY *, arrayind_t, arrayind_t, int, int));
extern char *array_patsub __P((ARRAY *, char *, char *, int));
extern char *array_modcase __P((ARRAY *, char *, int, int));
extern char *array_subrange PARAMS((ARRAY *, arrayind_t, arrayind_t, int, int, int));
extern char *array_patsub PARAMS((ARRAY *, char *, char *, int));
extern char *array_modcase PARAMS((ARRAY *, char *, int, int));
/* Basic operations on array elements. */
extern ARRAY_ELEMENT *array_create_element __P((arrayind_t, char *));
extern ARRAY_ELEMENT *array_copy_element __P((ARRAY_ELEMENT *));
extern void array_dispose_element __P((ARRAY_ELEMENT *));
extern ARRAY_ELEMENT *array_create_element PARAMS((arrayind_t, char *));
extern ARRAY_ELEMENT *array_copy_element PARAMS((ARRAY_ELEMENT *));
extern void array_dispose_element PARAMS((ARRAY_ELEMENT *));
extern int array_insert __P((ARRAY *, arrayind_t, char *));
extern ARRAY_ELEMENT *array_remove __P((ARRAY *, arrayind_t));
extern char *array_reference __P((ARRAY *, arrayind_t));
extern int array_insert PARAMS((ARRAY *, arrayind_t, char *));
extern ARRAY_ELEMENT *array_remove PARAMS((ARRAY *, arrayind_t));
extern char *array_reference PARAMS((ARRAY *, arrayind_t));
/* Converting to and from arrays */
extern WORD_LIST *array_to_word_list __P((ARRAY *));
extern ARRAY *array_from_word_list __P((WORD_LIST *));
extern WORD_LIST *array_keys_to_word_list __P((ARRAY *));
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 ARRAY *array_assign_list __P((ARRAY *, WORD_LIST *));
extern ARRAY *array_assign_list PARAMS((ARRAY *, WORD_LIST *));
extern char **array_to_argv __P((ARRAY *));
extern char **array_to_argv PARAMS((ARRAY *, int *));
extern char *array_to_assign __P((ARRAY *, int));
extern char *array_to_string __P((ARRAY *, char *, int));
extern ARRAY *array_from_string __P((char *, char *));
extern char *array_to_kvpair PARAMS((ARRAY *, int));
extern char *array_to_assign PARAMS((ARRAY *, int));
extern char *array_to_string PARAMS((ARRAY *, char *, int));
extern ARRAY *array_from_string PARAMS((char *, char *));
/* Flags for array_shift */
#define AS_DISPOSE 0x01
@@ -120,4 +121,7 @@ extern ARRAY *array_from_string __P((char *, char *));
#define ALL_ELEMENT_SUB(c) ((c) == '@' || (c) == '*')
/* In eval.c, but uses ARRAY * */
extern int execute_array_command PARAMS((ARRAY *, void *));
#endif /* _ARRAY_H_ */
+261 -31
View File
@@ -1,6 +1,6 @@
/* arrayfunc.c -- High-level array functions used by other parts of the shell. */
/* Copyright (C) 2001-2016 Free Software Foundation, Inc.
/* Copyright (C) 2001-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -40,6 +40,11 @@
#include "builtins/common.h"
#ifndef LBRACK
# define LBRACK '['
# define RBRACK ']'
#endif
/* This variable means to not expand associative array subscripts more than
once, when performing variable expansion. */
int assoc_expand_once = 0;
@@ -47,12 +52,15 @@ int assoc_expand_once = 0;
/* Ditto for indexed array subscripts -- currently unused */
int array_expand_once = 0;
static SHELL_VAR *bind_array_var_internal __P((SHELL_VAR *, arrayind_t, char *, char *, int));
static SHELL_VAR *assign_array_element_internal __P((SHELL_VAR *, char *, char *, char *, int, char *, int));
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 char *quote_assign __P((const char *));
static void quote_array_assignment_chars __P((WORD_LIST *));
static char *array_value_internal __P((const char *, int, int, int *, arrayind_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 *));
/* Standard error message to use when encountering an invalid array subscript */
const char * const bash_badsub_errmsg = N_("bad array subscript");
@@ -89,7 +97,8 @@ convert_var_to_array (var)
array_needs_making++;
VSETATTR (var, att_array);
VUNSETATTR (var, att_invisible);
if (oldval)
VUNSETATTR (var, att_invisible);
/* Make sure it's not marked as an associative array any more */
VUNSETATTR (var, att_assoc);
@@ -126,7 +135,8 @@ convert_var_to_assoc (var)
array_needs_making++;
VSETATTR (var, att_assoc);
VUNSETATTR (var, att_invisible);
if (oldval)
VUNSETATTR (var, att_invisible);
/* Make sure it's not marked as an indexed array any more */
VUNSETATTR (var, att_array);
@@ -177,7 +187,41 @@ make_array_variable_value (entry, ind, key, value, flags)
return newval;
}
/* Assign HASH[KEY]=VALUE according to FLAGS. ENTRY is an associative array
variable; HASH is the hash table to assign into. HASH may or may not be
the hash table associated with ENTRY; if it's not, the caller takes care
of it.
XXX - make sure that any dynamic associative array variables recreate the
hash table on each assignment. BASH_CMDS and BASH_ALIASES already do this */
static SHELL_VAR *
bind_assoc_var_internal (entry, hash, key, value, flags)
SHELL_VAR *entry;
HASH_TABLE *hash;
char *key;
char *value;
int flags;
{
char *newval;
/* Use the existing array contents to expand the value */
newval = make_array_variable_value (entry, 0, key, value, flags);
if (entry->assign_func)
(*entry->assign_func) (entry, newval, 0, key);
else
assoc_insert (hash, key, newval);
FREE (newval);
VUNSETATTR (entry, att_invisible); /* no longer invisible */
/* check mark_modified_variables if we ever want to export array vars */
return (entry);
}
/* Perform ENTRY[IND]=VALUE or ENTRY[KEY]=VALUE. This is not called for every
assignment to an associative array; see assign_compound_array_list below. */
static SHELL_VAR *
bind_array_var_internal (entry, ind, key, value, flags)
SHELL_VAR *entry;
@@ -271,7 +315,7 @@ bind_assoc_variable (entry, name, key, value, flags)
return (entry);
}
return (bind_array_var_internal (entry, 0, key, value, flags));
return (bind_assoc_var_internal (entry, assoc_cell (entry), key, value, flags));
}
/* Parse NAME, a lhs of an assignment statement of the form v[s], and
@@ -398,7 +442,7 @@ find_or_make_array_variable (name, flags)
}
else if ((flags & 2) && array_p (var))
{
last_command_exit_value = 1;
set_exit_status (EXECUTION_FAILURE);
report_error (_("%s: cannot convert indexed to associative array"), name);
return ((SHELL_VAR *)NULL);
}
@@ -481,6 +525,9 @@ expand_compound_array_assignment (var, value, flags)
(ksh93 seems to do this). */
list = parse_string_to_word_list (val, 1, "array assign");
/* 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. */
if (var && assoc_p (var))
{
if (val != value)
@@ -507,7 +554,59 @@ expand_compound_array_assignment (var, value, flags)
return nlist;
}
/* Callers ensure that VAR is not NULL */
#if ASSOC_KVPAIR_ASSIGNMENT
static void
assign_assoc_from_kvlist (var, nlist, h, flags)
SHELL_VAR *var;
WORD_LIST *nlist;
HASH_TABLE *h;
int flags;
{
WORD_LIST *list;
char *akey, *aval, *k, *v;
int free_aval;
for (list = nlist; list; list = list->next)
{
free_aval = 0;
k = list->word->word;
v = list->next ? list->next->word->word : 0;
if (list->next)
list = list->next;
akey = expand_assignment_string_to_string (k, 0);
aval = expand_assignment_string_to_string (v, 0);
if (akey == 0 || *akey == 0)
{
err_badarraysub (k);
FREE (akey);
continue;
}
if (aval == 0)
{
aval = (char *)xmalloc (1);
aval[0] = '\0'; /* like do_assignment_internal */
free_aval = 1;
}
bind_assoc_var_internal (var, h, akey, aval, flags);
if (free_aval)
free (aval);
}
}
#endif
/* Callers ensure that VAR is not NULL. Associative array assignments have not
been expanded when this is called, or have been expanded once and single-
quoted, so we don't have to scan through an unquoted expanded subscript to
find the ending bracket; indexed array assignments have been expanded and
possibly single-quoted to prevent further expansion.
If this is an associative array, we perform the assignments into NHASH and
set NHASH to be the value of VAR after processing the assignments in NLIST */
void
assign_compound_array_list (var, nlist, flags)
SHELL_VAR *var;
@@ -515,7 +614,7 @@ assign_compound_array_list (var, nlist, flags)
int flags;
{
ARRAY *a;
HASH_TABLE *h;
HASH_TABLE *h, *nhash;
WORD_LIST *list;
char *w, *val, *nval, *savecmd;
int len, iflags, free_val;
@@ -523,7 +622,7 @@ assign_compound_array_list (var, nlist, flags)
char *akey;
a = (var && array_p (var)) ? array_cell (var) : (ARRAY *)0;
h = (var && assoc_p (var)) ? assoc_cell (var) : (HASH_TABLE *)0;
nhash = h = (var && assoc_p (var)) ? assoc_cell (var) : (HASH_TABLE *)0;
akey = (char *)0;
ind = 0;
@@ -535,11 +634,26 @@ assign_compound_array_list (var, nlist, flags)
if (a && array_p (var))
array_flush (a);
else if (h && assoc_p (var))
assoc_flush (h);
nhash = assoc_create (h->nbuckets);
}
last_ind = (a && (flags & ASS_APPEND)) ? array_max_index (a) + 1 : 0;
#if ASSOC_KVPAIR_ASSIGNMENT
if (assoc_p (var) && nlist && (nlist->word->flags & W_ASSIGNMENT) == 0 && nlist->word->word[0] != '[') /*]*/
{
iflags = flags & ~ASS_APPEND;
assign_assoc_from_kvlist (var, nlist, nhash, iflags);
if (nhash && nhash != h)
{
h = assoc_cell (var);
var_setassoc (var, nhash);
assoc_dispose (h);
}
return;
}
#endif
for (list = nlist; list; list = list->next)
{
/* Don't allow var+=(values) to make assignments in VALUES append to
@@ -581,7 +695,7 @@ assign_compound_array_list (var, nlist, flags)
if (ALL_ELEMENT_SUB (w[1]) && len == 2)
{
last_command_exit_value = 1;
set_exit_status (EXECUTION_FAILURE);
if (assoc_p (var))
report_error (_("%s: invalid associative array key"), w);
else
@@ -629,7 +743,7 @@ assign_compound_array_list (var, nlist, flags)
}
else if (assoc_p (var))
{
last_command_exit_value = 1;
set_exit_status (EXECUTION_FAILURE);
report_error (_("%s: %s: must use subscript when assigning associative array"), var->name, w);
continue;
}
@@ -655,13 +769,23 @@ assign_compound_array_list (var, nlist, flags)
savecmd = this_command_name;
if (integer_p (var))
this_command_name = (char *)NULL; /* no command name for errors */
bind_array_var_internal (var, ind, akey, val, iflags);
if (assoc_p (var))
bind_assoc_var_internal (var, nhash, akey, val, iflags);
else
bind_array_var_internal (var, ind, akey, val, iflags);
last_ind++;
this_command_name = savecmd;
if (free_val)
free (val);
}
if (assoc_p (var) && nhash && nhash != h)
{
h = assoc_cell (var);
var_setassoc (var, nhash);
assoc_dispose (h);
}
}
/* Perform a compound array assignment: VAR->name=( VALUE ). The
@@ -735,6 +859,119 @@ quote_assign (string)
return temp;
}
/* Take a word W of the form [IND]=VALUE and transform it to ['IND']='VALUE'
to prevent further expansion. This is called for compound assignments to
indexed arrays. W has already undergone word expansions. If W has no [IND]=,
just single-quote and return it. */
static char *
quote_compound_array_word (w, type)
char *w;
int type;
{
char *nword, *sub, *value, *t;
int ind, wlen, i;
if (w[0] != LBRACK)
return (sh_single_quote (w));
ind = skipsubscript (w, 0, 0);
if (w[ind] != RBRACK)
return (sh_single_quote (w));
wlen = strlen (w);
w[ind] = '\0';
sub = sh_single_quote (w+1);
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);
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);
strcpy (nword + i, value);
return nword;
}
/* Expand the key and value in W, which is of the form [KEY]=VALUE, and
reconstruct W with the expanded and single-quoted version:
['expanded-key']='expanded-value'. If there is no [KEY]=, single-quote the
word and return it. Very similar to previous function, but does not assume
W has already been expanded, and expands the KEY and VALUE separately.
Used for compound assignments to associative arrays that are arguments to
declaration builtins (declare -A a=( list )). */
char *
expand_and_quote_assoc_word (w, type)
char *w;
int type;
{
char *nword, *key, *value, *t;
int ind, wlen, i;
if (w[0] != LBRACK)
return (sh_single_quote (w));
ind = skipsubscript (w, 0, 0);
if (w[ind] != RBRACK)
return (sh_single_quote (w));
w[ind] = '\0';
t = expand_assignment_string_to_string (w+1, 0);
w[ind] = RBRACK;
key = sh_single_quote (t ? t : "");
free (t);
wlen = STRLEN (key);
nword = xmalloc (wlen + 5);
nword[0] = LBRACK;
memcpy (nword+1, key, wlen);
i = wlen + 1; /* accommodate the opening LBRACK */
nword[i++] = w[ind++]; /* RBRACK */
if (w[ind] == '+')
nword[i++] = w[ind++];
nword[i++] = w[ind++];
t = expand_assignment_string_to_string (w+ind, 0);
value = sh_single_quote (t ? t : "");
free (t);
nword = xrealloc (nword, wlen + 5 + STRLEN (value));
strcpy (nword + i, value);
free (key);
free (value);
return nword;
}
/* For each word in a compound array assignment, if the word looks like
[ind]=value, single-quote ind and value, but leave the brackets and
the = sign (and any `+') alone. If it's not an assignment, just single-
quote the word. This is used for indexed arrays. */
void
quote_compound_array_list (list, type)
WORD_LIST *list;
int type;
{
char *t;
WORD_LIST *l;
for (l = list; l; l = l->next)
{
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);
else
t = quote_compound_array_word (l->word->word, type);
free (l->word->word);
l->word->word = t;
}
}
/* For each word in a compound array assignment, if the word looks like
[ind]=value, quote globbing chars and characters in $IFS before the `='. */
static void
@@ -954,7 +1191,7 @@ array_expand_index (var, s, len, flags)
exp = (char *)xmalloc (len);
strncpy (exp, s, len - 1);
exp[len - 1] = '\0';
#if 0 /* XXX - not yet -- maybe bash-5.1 */
#if 0 /* TAG: maybe bash-5.2 */
if ((flags & AV_NOEXPAND) == 0)
t = expand_arith_string (exp, Q_DOUBLE_QUOTES|Q_ARITH|Q_ARRAYSUB); /* XXX - Q_ARRAYSUB for future use */
else
@@ -963,14 +1200,14 @@ 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 */
savecmd = this_command_name;
this_command_name = (char *)NULL;
val = evalexp (t, 0, &expok);
val = evalexp (t, EXP_EXPANDED, &expok); /* XXX - was 0 but we expanded exp already */
this_command_name = savecmd;
if (t != exp)
free (t);
free (exp);
if (expok == 0)
{
last_command_exit_value = EXECUTION_FAILURE;
set_exit_status (EXECUTION_FAILURE);
if (no_longjmp_on_fatal_error)
return 0;
@@ -1224,9 +1461,9 @@ get_array_value (s, flags, rtype, indp)
}
char *
array_keys (s, quoted)
array_keys (s, quoted, pflags)
char *s;
int quoted;
int quoted, pflags;
{
int len;
char *retval, *t, *temp;
@@ -1251,14 +1488,7 @@ array_keys (s, quoted)
if (l == (WORD_LIST *)NULL)
return ((char *) NULL);
if (t[0] == '*' && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)))
{
temp = string_list_dollar_star (l, quoted, 0);
retval = quote_string (temp);
free (temp);
}
else /* ${!name[@]} or unquoted ${!name[*]} */
retval = string_list_dollar_at (l, quoted, 0);
retval = string_list_pos_params (t[0], l, quoted, pflags);
dispose_words (l);
return retval;
+28 -25
View File
@@ -1,6 +1,6 @@
/* arrayfunc.h -- declarations for miscellaneous array functions in arrayfunc.c */
/* Copyright (C) 2001-2010 Free Software Foundation, Inc.
/* Copyright (C) 2001-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -44,41 +44,44 @@ extern int array_expand_once;
#define VA_NOEXPAND 0x001
#define VA_ONEWORD 0x002
extern SHELL_VAR *convert_var_to_array __P((SHELL_VAR *));
extern SHELL_VAR *convert_var_to_assoc __P((SHELL_VAR *));
extern SHELL_VAR *convert_var_to_array PARAMS((SHELL_VAR *));
extern SHELL_VAR *convert_var_to_assoc PARAMS((SHELL_VAR *));
extern char *make_array_variable_value __P((SHELL_VAR *, arrayind_t, char *, char *, int));
extern char *make_array_variable_value PARAMS((SHELL_VAR *, arrayind_t, char *, char *, int));
extern SHELL_VAR *bind_array_variable __P((char *, arrayind_t, char *, int));
extern SHELL_VAR *bind_array_element __P((SHELL_VAR *, arrayind_t, char *, int));
extern SHELL_VAR *assign_array_element __P((char *, char *, int));
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 *bind_assoc_variable __P((SHELL_VAR *, char *, char *, char *, int));
extern SHELL_VAR *bind_assoc_variable PARAMS((SHELL_VAR *, char *, char *, char *, int));
extern SHELL_VAR *find_or_make_array_variable __P((char *, int));
extern SHELL_VAR *find_or_make_array_variable PARAMS((char *, int));
extern SHELL_VAR *assign_array_from_string __P((char *, char *, int));
extern SHELL_VAR *assign_array_var_from_word_list __P((SHELL_VAR *, WORD_LIST *, int));
extern SHELL_VAR *assign_array_from_string PARAMS((char *, char *, int));
extern SHELL_VAR *assign_array_var_from_word_list PARAMS((SHELL_VAR *, WORD_LIST *, int));
extern WORD_LIST *expand_compound_array_assignment __P((SHELL_VAR *, char *, int));
extern void assign_compound_array_list __P((SHELL_VAR *, WORD_LIST *, int));
extern SHELL_VAR *assign_array_var_from_string __P((SHELL_VAR *, char *, int));
extern WORD_LIST *expand_compound_array_assignment PARAMS((SHELL_VAR *, char *, int));
extern void assign_compound_array_list PARAMS((SHELL_VAR *, WORD_LIST *, int));
extern SHELL_VAR *assign_array_var_from_string PARAMS((SHELL_VAR *, char *, int));
extern int unbind_array_element __P((SHELL_VAR *, char *, int));
extern int skipsubscript __P((const char *, int, int));
extern char *expand_and_quote_assoc_word PARAMS((char *, int));
extern void quote_compound_array_list PARAMS((WORD_LIST *, int));
extern void print_array_assignment __P((SHELL_VAR *, int));
extern void print_assoc_assignment __P((SHELL_VAR *, int));
extern int unbind_array_element PARAMS((SHELL_VAR *, char *, int));
extern int skipsubscript PARAMS((const char *, int, int));
extern arrayind_t array_expand_index __P((SHELL_VAR *, char *, int, int));
extern int valid_array_reference __P((const char *, int));
extern char *array_value __P((const char *, int, int, int *, arrayind_t *));
extern char *get_array_value __P((const char *, int, int *, arrayind_t *));
extern void print_array_assignment PARAMS((SHELL_VAR *, int));
extern void print_assoc_assignment PARAMS((SHELL_VAR *, int));
extern char *array_keys __P((char *, 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 char *array_variable_name __P((const char *, int, char **, int *));
extern SHELL_VAR *array_variable_part __P((const char *, int, char **, int *));
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 *));
#else
+83 -12
View File
@@ -7,7 +7,7 @@
* chet@ins.cwru.edu
*/
/* Copyright (C) 2008,2009,2011 Free Software Foundation, Inc.
/* Copyright (C) 2008,2009,2011-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -44,7 +44,7 @@
#include "assoc.h"
#include "builtins/common.h"
static WORD_LIST *assoc_to_word_list_internal __P((HASH_TABLE *, int));
static WORD_LIST *assoc_to_word_list_internal PARAMS((HASH_TABLE *, int));
/* assoc_create == hash_create */
@@ -258,10 +258,10 @@ assoc_remove_quoted_nulls (h)
* the STARTth element and spanning NELEM members. Null elements are counted.
*/
char *
assoc_subrange (hash, start, nelem, starsub, quoted)
HASH_TABLE *hash;
arrayind_t start, nelem;
int starsub, quoted;
assoc_subrange (hash, start, nelem, starsub, quoted, pflags)
HASH_TABLE *hash;
arrayind_t start, nelem;
int starsub, quoted, pflags;
{
WORD_LIST *l, *save, *h, *t;
int i, j;
@@ -289,7 +289,7 @@ int starsub, quoted;
t->next = (WORD_LIST *)NULL;
ret = string_list_pos_params (starsub ? '*' : '@', h, quoted);
ret = string_list_pos_params (starsub ? '*' : '@', h, quoted, pflags);
if (t != l)
t->next = l;
@@ -306,7 +306,7 @@ assoc_patsub (h, pat, rep, mflags)
int mflags;
{
char *t;
int pchar, qflags;
int pchar, qflags, pflags;
WORD_LIST *wl, *save;
if (h == 0 || assoc_empty (h))
@@ -325,8 +325,9 @@ assoc_patsub (h, pat, rep, mflags)
pchar = (mflags & MATCH_STARSUB) == MATCH_STARSUB ? '*' : '@';
qflags = (mflags & MATCH_QUOTED) == MATCH_QUOTED ? Q_DOUBLE_QUOTES : 0;
pflags = (mflags & MATCH_ASSIGNRHS) == MATCH_ASSIGNRHS ? PF_ASSIGNRHS : 0;
t = string_list_pos_params (pchar, save, qflags);
t = string_list_pos_params (pchar, save, qflags, pflags);
dispose_words (save);
return t;
@@ -340,7 +341,7 @@ assoc_modcase (h, pat, modop, mflags)
int mflags;
{
char *t;
int pchar, qflags;
int pchar, qflags, pflags;
WORD_LIST *wl, *save;
if (h == 0 || assoc_empty (h))
@@ -359,13 +360,84 @@ assoc_modcase (h, pat, modop, mflags)
pchar = (mflags & MATCH_STARSUB) == MATCH_STARSUB ? '*' : '@';
qflags = (mflags & MATCH_QUOTED) == MATCH_QUOTED ? Q_DOUBLE_QUOTES : 0;
pflags = (mflags & MATCH_ASSIGNRHS) == MATCH_ASSIGNRHS ? PF_ASSIGNRHS : 0;
t = string_list_pos_params (pchar, save, qflags);
t = string_list_pos_params (pchar, save, qflags, pflags);
dispose_words (save);
return t;
}
char *
assoc_to_kvpair (hash, quoted)
HASH_TABLE *hash;
int quoted;
{
char *ret;
char *istr, *vstr;
int i, rsize, rlen, elen;
BUCKET_CONTENTS *tlist;
if (hash == 0 || assoc_empty (hash))
return (char *)0;
ret = xmalloc (rsize = 128);
ret[rlen = 0] = '\0';
for (i = 0; i < hash->nbuckets; i++)
for (tlist = hash_items (i, hash); tlist; tlist = tlist->next)
{
if (ansic_shouldquote (tlist->key))
istr = ansic_quote (tlist->key, 0, (int *)0);
else if (sh_contains_shell_metas (tlist->key))
istr = sh_double_quote (tlist->key);
else if (ALL_ELEMENT_SUB (tlist->key[0]) && tlist->key[1] == '\0')
istr = sh_double_quote (tlist->key);
else
istr = tlist->key;
vstr = tlist->data ? (ansic_shouldquote ((char *)tlist->data) ?
ansic_quote ((char *)tlist->data, 0, (int *)0) :
sh_double_quote ((char *)tlist->data))
: (char *)0;
elen = STRLEN (istr) + 4 + STRLEN (vstr);
RESIZE_MALLOCED_BUFFER (ret, rlen, (elen+1), rsize, rsize);
strcpy (ret+rlen, istr);
rlen += STRLEN (istr);
ret[rlen++] = ' ';
if (vstr)
{
strcpy (ret + rlen, vstr);
rlen += STRLEN (vstr);
}
else
{
strcpy (ret + rlen, "\"\"");
rlen += 2;
}
ret[rlen++] = ' ';
if (istr != tlist->key)
FREE (istr);
FREE (vstr);
}
RESIZE_MALLOCED_BUFFER (ret, rlen, 1, rsize, 8);
ret[rlen] = '\0';
if (quoted)
{
vstr = sh_single_quote (ret);
free (ret);
ret = vstr;
}
return ret;
}
char *
assoc_to_assign (hash, quoted)
HASH_TABLE *hash;
@@ -415,7 +487,6 @@ assoc_to_assign (hash, quoted)
}
ret[rlen++] = ' ';
if (istr != tlist->key)
FREE (istr);
+22 -19
View File
@@ -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 Free Software Foundation, Inc.
/* Copyright (C) 2008,2009-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -25,6 +25,8 @@
#include "stdc.h"
#include "hashlib.h"
#define ASSOC_HASH_BUCKETS 1024
#define assoc_empty(h) ((h)->nentries == 0)
#define assoc_num_elements(h) ((h)->nentries)
@@ -34,29 +36,30 @@
#define assoc_walk(h, f) (hash_walk((h), (f))
extern void assoc_dispose __P((HASH_TABLE *));
extern void assoc_flush __P((HASH_TABLE *));
extern void assoc_dispose PARAMS((HASH_TABLE *));
extern void assoc_flush PARAMS((HASH_TABLE *));
extern int assoc_insert __P((HASH_TABLE *, char *, char *));
extern PTR_T assoc_replace __P((HASH_TABLE *, char *, char *));
extern void assoc_remove __P((HASH_TABLE *, char *));
extern int assoc_insert PARAMS((HASH_TABLE *, char *, char *));
extern PTR_T assoc_replace PARAMS((HASH_TABLE *, char *, char *));
extern void assoc_remove PARAMS((HASH_TABLE *, char *));
extern char *assoc_reference __P((HASH_TABLE *, char *));
extern char *assoc_reference PARAMS((HASH_TABLE *, char *));
extern char *assoc_subrange __P((HASH_TABLE *, arrayind_t, arrayind_t, int, int));
extern char *assoc_patsub __P((HASH_TABLE *, char *, char *, int));
extern char *assoc_modcase __P((HASH_TABLE *, char *, int, int));
extern char *assoc_subrange PARAMS((HASH_TABLE *, arrayind_t, arrayind_t, int, int, int));
extern char *assoc_patsub PARAMS((HASH_TABLE *, char *, char *, int));
extern char *assoc_modcase PARAMS((HASH_TABLE *, char *, int, int));
extern HASH_TABLE *assoc_quote __P((HASH_TABLE *));
extern HASH_TABLE *assoc_quote_escapes __P((HASH_TABLE *));
extern HASH_TABLE *assoc_dequote __P((HASH_TABLE *));
extern HASH_TABLE *assoc_dequote_escapes __P((HASH_TABLE *));
extern HASH_TABLE *assoc_remove_quoted_nulls __P((HASH_TABLE *));
extern HASH_TABLE *assoc_quote PARAMS((HASH_TABLE *));
extern HASH_TABLE *assoc_quote_escapes PARAMS((HASH_TABLE *));
extern HASH_TABLE *assoc_dequote PARAMS((HASH_TABLE *));
extern HASH_TABLE *assoc_dequote_escapes PARAMS((HASH_TABLE *));
extern HASH_TABLE *assoc_remove_quoted_nulls PARAMS((HASH_TABLE *));
extern char *assoc_to_assign __P((HASH_TABLE *, int));
extern char *assoc_to_kvpair PARAMS((HASH_TABLE *, int));
extern char *assoc_to_assign PARAMS((HASH_TABLE *, int));
extern WORD_LIST *assoc_to_word_list __P((HASH_TABLE *));
extern WORD_LIST *assoc_keys_to_word_list __P((HASH_TABLE *));
extern WORD_LIST *assoc_to_word_list PARAMS((HASH_TABLE *));
extern WORD_LIST *assoc_keys_to_word_list PARAMS((HASH_TABLE *));
extern char *assoc_to_string __P((HASH_TABLE *, char *, int));
extern char *assoc_to_string PARAMS((HASH_TABLE *, char *, int));
#endif /* _ASSOC_H_ */
+63 -32
View File
@@ -1,6 +1,6 @@
/* bashhist.c -- bash interface to the GNU history library. */
/* Copyright (C) 1993-2015 Free Software Foundation, Inc.
/* Copyright (C) 1993-2019 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -68,10 +68,10 @@ extern int rl_done, rl_dispatching; /* should really include readline.h */
extern int errno;
#endif
static int histignore_item_func __P((struct ign *));
static int check_history_control __P((char *));
static void hc_erasedups __P((char *));
static void really_add_history __P((char *));
static int histignore_item_func PARAMS((struct ign *));
static int check_history_control PARAMS((char *));
static void hc_erasedups PARAMS((char *));
static void really_add_history PARAMS((char *));
static struct ignorevar histignore =
{
@@ -89,7 +89,7 @@ static struct ignorevar histignore =
list. This is different than the user-controlled behaviour; this
becomes zero when we read lines from a file, for example. */
int remember_on_history = 0;
int enable_history_list = 0; /* value for `set -o history' */
int enable_history_list = -1; /* value for `set -o history' */
/* The number of lines that Bash has added to this history session. The
difference between the number of the top element in the history list
@@ -193,17 +193,17 @@ int hist_verify;
int dont_save_function_defs;
#if defined (BANG_HISTORY)
static int bash_history_inhibit_expansion __P((char *, int));
static int bash_history_inhibit_expansion PARAMS((char *, int));
#endif
#if defined (READLINE)
static void re_edit __P((char *));
static void re_edit PARAMS((char *));
#endif
static int history_expansion_p __P((char *));
static int shell_comment __P((char *));
static int should_expand __P((char *));
static HIST_ENTRY *last_history_entry __P((void));
static char *expand_histignore_pattern __P((char *));
static int history_should_ignore __P((char *));
static int history_expansion_p PARAMS((char *));
static int shell_comment PARAMS((char *));
static int should_expand PARAMS((char *));
static HIST_ENTRY *last_history_entry PARAMS((void));
static char *expand_histignore_pattern PARAMS((char *));
static int history_should_ignore PARAMS((char *));
#if defined (BANG_HISTORY)
/* Is the history expansion starting at string[i] one that should not
@@ -359,10 +359,11 @@ bash_delete_histent (i)
discard = remove_history (i);
if (discard)
free_history_entry (discard);
history_lines_this_session--;
return 1;
{
free_history_entry (discard);
history_lines_this_session--;
}
return discard != 0;
}
int
@@ -436,11 +437,11 @@ int
maybe_append_history (filename)
char *filename;
{
int fd, result;
int fd, result, histlen;
struct stat buf;
result = EXECUTION_SUCCESS;
if (history_lines_this_session > 0 && (history_lines_this_session <= where_history ()))
if (history_lines_this_session > 0)
{
/* If the filename was supplied, then create it if necessary. */
if (stat (filename, &buf) == -1 && errno == ENOENT)
@@ -453,6 +454,10 @@ maybe_append_history (filename)
}
close (fd);
}
/* cap the number of lines we write at the length of the history list */
histlen = where_history ();
if (histlen > 0 && history_lines_this_session > histlen)
history_lines_this_session = histlen; /* reset below anyway */
result = append_history (history_lines_this_session, filename);
/* Pretend we already read these lines from the file because we just
added them */
@@ -752,7 +757,7 @@ maybe_add_history (line)
int is_comment;
hist_last_line_added = 0;
is_comment = shell_comment (line);
is_comment = (parser_state & PST_HEREDOC) ? 0 : 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
@@ -800,7 +805,9 @@ check_add_history (line, force)
}
#if defined (SYSLOG_HISTORY)
#define SYSLOG_MAXLEN 600
#define SYSLOG_MAXMSG 1024
#define SYSLOG_MAXLEN SYSLOG_MAXMSG
#define SYSLOG_MAXHDR 256
#ifndef OPENLOG_OPTS
#define OPENLOG_OPTS 0
@@ -816,7 +823,10 @@ void
bash_syslog_history (line)
const char *line;
{
char trunc[SYSLOG_MAXLEN];
char trunc[SYSLOG_MAXLEN], *msg;
char loghdr[SYSLOG_MAXHDR];
char seqbuf[32], *seqnum;
int hdrlen, msglen, seqlen, chunks, i;
static int first = 1;
if (first)
@@ -825,13 +835,25 @@ bash_syslog_history (line)
first = 0;
}
if (strlen(line) < SYSLOG_MAXLEN)
syslog (SYSLOG_FACILITY|SYSLOG_LEVEL, "HISTORY: PID=%d UID=%d %s", getpid(), current_user.uid, line);
hdrlen = snprintf (loghdr, sizeof(loghdr), "HISTORY: PID=%d UID=%d", getpid(), current_user.uid);
msglen = strlen (line);
if ((msglen + hdrlen + 1) < SYSLOG_MAXLEN)
syslog (SYSLOG_FACILITY|SYSLOG_LEVEL, "%s %s", loghdr, line);
else
{
strncpy (trunc, line, SYSLOG_MAXLEN);
trunc[SYSLOG_MAXLEN - 1] = '\0';
syslog (SYSLOG_FACILITY|SYSLOG_LEVEL, "HISTORY (TRUNCATED): PID=%d UID=%d %s", getpid(), current_user.uid, trunc);
chunks = ((msglen + hdrlen) / SYSLOG_MAXLEN) + 1;
for (msg = line, i = 0; i < chunks; i++)
{
seqnum = inttostr (i + 1, seqbuf, sizeof (seqbuf));
seqlen = STRLEN (seqnum);
/* 7 == "(seq=) " */
strncpy (trunc, msg, SYSLOG_MAXLEN - hdrlen - seqlen - 7 - 1);
trunc[SYSLOG_MAXLEN - 1] = '\0';
syslog (SYSLOG_FACILITY|SYSLOG_LEVEL, "%s (seq=%s) %s", loghdr, seqnum, trunc);
msg += SYSLOG_MAXLEN - hdrlen - seqlen - 8;
}
}
}
#endif
@@ -845,13 +867,15 @@ void
bash_add_history (line)
char *line;
{
int add_it, offset, curlen;
int add_it, offset, curlen, is_comment;
HIST_ENTRY *current, *old;
char *chars_to_add, *new_line;
add_it = 1;
if (command_oriented_history && current_command_line_count > 1)
{
is_comment = (parser_state & PST_HEREDOC) ? 0 : 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
do want to add one after the first line (which is the command that
@@ -859,7 +883,11 @@ bash_add_history (line)
does the right thing to take care of this for us. We don't want to
add extra newlines if the user chooses to enable literal_history,
so we have to duplicate some of what that function does here. */
if ((parser_state & PST_HEREDOC) && literal_history && current_command_line_count > 2 && line[strlen (line) - 1] == '\n')
/* If we're in a here document and past the first 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')
chars_to_add = "";
else if (current_command_line_count == current_command_line_comment+1)
chars_to_add = "\n";
@@ -871,7 +899,7 @@ bash_add_history (line)
using_history ();
current = previous_history ();
current_command_line_comment = shell_comment (line) ? current_command_line_count : -2;
current_command_line_comment = is_comment ? current_command_line_count : -2;
if (current)
{
@@ -911,6 +939,9 @@ bash_add_history (line)
}
}
if (add_it && history_is_stifled() && history_length == 0 && history_length == history_max_entries)
add_it = 0;
if (add_it)
really_add_history (line);
@@ -936,7 +967,7 @@ int
history_number ()
{
using_history ();
return (remember_on_history ? history_base + where_history () : 1);
return ((remember_on_history || enable_history_list) ? history_base + where_history () : 1);
}
static int
+20 -20
View File
@@ -1,6 +1,6 @@
/* bashhist.h -- interface to the bash history functions in bashhist.c. */
/* Copyright (C) 1993-2009 Free Software Foundation, Inc.
/* Copyright (C) 1993-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -64,26 +64,26 @@ extern int history_expansion_inhibited;
extern int double_quotes_inhibit_history_expansion;
# endif /* BANG_HISTORY */
extern void bash_initialize_history __P((void));
extern void bash_history_reinit __P((int));
extern void bash_history_disable __P((void));
extern void bash_history_enable __P((void));
extern void bash_clear_history __P((void));
extern int bash_delete_histent __P((int));
extern int bash_delete_history_range __P((int, int));
extern int bash_delete_last_history __P((void));
extern void load_history __P((void));
extern void save_history __P((void));
extern int maybe_append_history __P((char *));
extern int maybe_save_shell_history __P((void));
extern char *pre_process_line __P((char *, int, int));
extern void maybe_add_history __P((char *));
extern void bash_add_history __P((char *));
extern int check_add_history __P((char *, int));
extern int history_number __P((void));
extern void bash_initialize_history PARAMS((void));
extern void bash_history_reinit PARAMS((int));
extern void bash_history_disable PARAMS((void));
extern void bash_history_enable PARAMS((void));
extern void bash_clear_history PARAMS((void));
extern int bash_delete_histent PARAMS((int));
extern int bash_delete_history_range PARAMS((int, int));
extern int bash_delete_last_history PARAMS((void));
extern void load_history PARAMS((void));
extern void save_history PARAMS((void));
extern int maybe_append_history PARAMS((char *));
extern int maybe_save_shell_history PARAMS((void));
extern char *pre_process_line PARAMS((char *, int, int));
extern void maybe_add_history PARAMS((char *));
extern void bash_add_history PARAMS((char *));
extern int check_add_history PARAMS((char *, int));
extern int history_number PARAMS((void));
extern void setup_history_ignore __P((char *));
extern void setup_history_ignore PARAMS((char *));
extern char *last_history_line __P((void));
extern char *last_history_line PARAMS((void));
#endif /* _BASHHIST_H_ */
+447 -253
View File
File diff suppressed because it is too large Load Diff
+23 -21
View File
@@ -1,6 +1,6 @@
/* bashline.h -- interface to the bash readline functions in bashline.c. */
/* Copyright (C) 1993-2009 Free Software Foundation, Inc.
/* Copyright (C) 1993-2019 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -35,33 +35,35 @@ extern int dircomplete_expand;
extern int dircomplete_expand_relpath;
extern int complete_fullquote;
extern void posix_readline_initialize __P((int));
extern void reset_completer_word_break_chars __P((void));
extern int enable_hostname_completion __P((int));
extern void initialize_readline __P((void));
extern void bashline_reset __P((void));
extern void bashline_reinitialize __P((void));
extern int bash_re_edit __P((char *));
extern void posix_readline_initialize PARAMS((int));
extern void reset_completer_word_break_chars PARAMS((void));
extern int enable_hostname_completion PARAMS((int));
extern void initialize_readline PARAMS((void));
extern void bashline_reset PARAMS((void));
extern void bashline_reinitialize PARAMS((void));
extern int bash_re_edit PARAMS((char *));
extern void bashline_set_event_hook __P((void));
extern void bashline_reset_event_hook __P((void));
extern void bashline_set_event_hook PARAMS((void));
extern void bashline_reset_event_hook PARAMS((void));
extern int bind_keyseq_to_unix_command __P((char *));
extern int print_unix_command_map __P((void));
extern int bind_keyseq_to_unix_command PARAMS((char *));
extern int bash_execute_unix_command PARAMS((int, int));
extern int print_unix_command_map PARAMS((void));
extern int unbind_unix_command PARAMS((char *));
extern char **bash_default_completion __P((const char *, int, int, int, int));
extern char **bash_default_completion PARAMS((const char *, int, int, int, int));
void set_directory_hook __P((void));
void set_directory_hook PARAMS((void));
/* Used by programmable completion code. */
extern char *command_word_completion_function __P((const char *, int));
extern char *bash_groupname_completion_function __P((const char *, int));
extern char *bash_servicename_completion_function __P((const char *, int));
extern char *command_word_completion_function PARAMS((const char *, int));
extern char *bash_groupname_completion_function PARAMS((const char *, int));
extern char *bash_servicename_completion_function PARAMS((const char *, int));
extern char **get_hostname_list __P((void));
extern void clear_hostname_list __P((void));
extern char **get_hostname_list PARAMS((void));
extern void clear_hostname_list PARAMS((void));
extern char **bash_directory_completion_matches __P((const char *));
extern char *bash_dequote_text __P((const char *));
extern char **bash_directory_completion_matches PARAMS((const char *));
extern char *bash_dequote_text PARAMS((const char *));
#endif /* _BASHLINE_H_ */
+2 -2
View File
@@ -4,7 +4,7 @@
/* Original version by tromey@cns.caltech.edu, Fri Feb 7 1992. */
/* Copyright (C) 1993-2009 Free Software Foundation, Inc.
/* Copyright (C) 1993-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -41,7 +41,7 @@
#include "shell.h"
#include <readline/readline.h>
static int _strcompare __P((char **, char **));
static int _strcompare PARAMS((char **, char **));
/* Find greatest common prefix of two strings. */
static int
+9 -32
View File
@@ -1,6 +1,6 @@
/* braces.c -- code for doing word expansion in curly braces. */
/* Copyright (C) 1987-2018 Free Software Foundation, Inc.
/* Copyright (C) 1987-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -59,11 +59,7 @@ extern int errno;
#define BRACE_SEQ_SPECIFIER ".."
extern int asprintf __P((char **, const char *, ...)) __attribute__((__format__ (printf, 2, 3)));
#if defined (NOTDEF)
extern int last_command_exit_value;
#endif
extern int asprintf PARAMS((char **, const char *, ...)) __attribute__((__format__ (printf, 2, 3)));
/* Basic idea:
@@ -77,12 +73,12 @@ extern int last_command_exit_value;
/* The character which is used to separate arguments. */
static const int brace_arg_separator = ',';
#if defined (__P)
static int brace_gobbler __P((char *, size_t, int *, int));
static char **expand_amble __P((char *, size_t, int));
static char **expand_seqterm __P((char *, size_t));
static char **mkseq __P((intmax_t, intmax_t, intmax_t, int, int));
static char **array_concat __P((char **, char **));
#if defined (PARAMS)
static int brace_gobbler PARAMS((char *, size_t, int *, int));
static char **expand_amble PARAMS((char *, size_t, int));
static char **expand_seqterm PARAMS((char *, size_t));
static char **mkseq PARAMS((intmax_t, intmax_t, intmax_t, int, int));
static char **array_concat PARAMS((char **, char **));
#else
static int brace_gobbler ();
static char **expand_amble ();
@@ -190,7 +186,7 @@ brace_expand (text)
if (text[j] == brace_arg_separator)
{ /* { */
strvec_dispose (result);
last_command_exit_value = 1;
set_exit_status (EXECUTION_FAILURE);
report_error ("no closing `%c' in %s", '}', text);
throw_to_top_level ();
}
@@ -360,25 +356,6 @@ expand_amble (text, tlen, flags)
#define ST_CHAR 2
#define ST_ZINT 3
#ifndef sh_imaxabs
# define sh_imaxabs(x) (((x) >= 0) ? (x) : -(x))
#endif
/* Handle signed arithmetic overflow and underflow. Have to do it this way
to avoid compilers optimizing out simpler overflow checks. */
/* Make sure that a+b does not exceed MAXV or is smaller than MINV (if b < 0).
Assumes that b > 0 if a > 0 and b < 0 if a < 0 */
#define ADDOVERFLOW(a,b,minv,maxv) \
((((a) > 0) && ((b) > ((maxv) - (a)))) || \
(((a) < 0) && ((b) < ((minv) - (a)))))
/* Make sure that a-b is not smaller than MINV or exceeds MAXV (if b < 0).
Assumes that b > 0 if a > 0 and b < 0 if a < 0 */
#define SUBOVERFLOW(a,b,minv,maxv) \
((((b) > 0) && ((a) < ((minv) + (b)))) || \
(((b) < 0) && ((a) > ((maxv) + (b)))))
static char **
mkseq (start, end, incr, type, width)
intmax_t start, end, incr;
+7
View File
@@ -410,6 +410,12 @@ cd.o: $(topdir)/make_cmd.h $(topdir)/subst.h $(topdir)/externs.h
cd.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
cd.o: $(srcdir)/common.h $(BASHINCDIR)/maxpath.h ../pathnames.h
cd.o: $(topdir)/sig.h
colon.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
colon.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/subst.h $(topdir)/externs.h
colon.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
colon.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
colon.o: $(BASHINCDIR)/maxpath.h ../pathnames.h
colon.o: $(srcdir)/common.h
command.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
command.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/externs.h
command.o: $(topdir)/quit.h $(srcdir)/bashgetopt.h $(BASHINCDIR)/maxpath.h
@@ -429,6 +435,7 @@ echo.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/subst.h $(topdir)/exte
echo.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
echo.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
echo.o: $(BASHINCDIR)/maxpath.h ../pathnames.h
echo.o: $(srcdir)/common.h
enable.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
enable.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
enable.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
+2 -2
View File
@@ -1,7 +1,7 @@
This file is alias.def, from which is created alias.c
It implements the builtins "alias" and "unalias" in Bash.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
Copyright (C) 1987-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -63,7 +63,7 @@ $END
/* Flags for print_alias */
#define AL_REUSABLE 0x01
static void print_alias __P((alias_t *, int));
static void print_alias PARAMS((alias_t *, int));
/* Hack the alias command in a Korn shell way. */
int
+3 -3
View File
@@ -1,6 +1,6 @@
/* bashgetopt.h -- extern declarations for stuff defined in bashgetopt.c. */
/* Copyright (C) 1993 Free Software Foundation, Inc.
/* Copyright (C) 1993-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -36,7 +36,7 @@ extern int list_opttype;
extern WORD_LIST *lcurrent;
extern WORD_LIST *loptend;
extern int internal_getopt __P((WORD_LIST *, char *));
extern void reset_internal_getopt __P((void));
extern int internal_getopt PARAMS((WORD_LIST *, char *));
extern void reset_internal_getopt PARAMS((void));
#endif /* !__BASH_GETOPT_H */
+37 -7
View File
@@ -1,7 +1,7 @@
This file is bind.def, from which is created bind.c.
It implements the builtin "bind" in Bash.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
Copyright (C) 1987-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -86,9 +86,9 @@ extern int errno;
#include "bashgetopt.h"
#include "common.h"
static int query_bindings __P((char *));
static int unbind_command __P((char *));
static int unbind_keyseq __P((char *));
static int query_bindings PARAMS((char *));
static int unbind_command PARAMS((char *));
static int unbind_keyseq PARAMS((char *));
#define BIND_RETURN(x) do { return_code = x; goto bind_exit; } while (0)
@@ -192,7 +192,7 @@ bind_builtin (list)
case 'X':
flags |= XXFLAG;
break;
CASE_HELPOPT;
case GETOPT_HELP:
default:
builtin_usage ();
BIND_RETURN (EX_USAGE);
@@ -277,7 +277,28 @@ bind_builtin (list)
/* Process the rest of the arguments as binding specifications. */
while (list)
{
int olen, nlen, d, i;
char **obindings, **nbindings;
obindings = rl_invoking_keyseqs (bash_execute_unix_command);
olen = obindings ? strvec_len (obindings) : 0;
rl_parse_and_bind (list->word->word);
nbindings = rl_invoking_keyseqs (bash_execute_unix_command);
nlen = nbindings ? strvec_len (nbindings) : 0;
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)
{
unbind_unix_command (obindings[i]);
d--;
}
strvec_dispose (obindings);
strvec_dispose (nbindings);
list = list->next;
}
@@ -287,6 +308,9 @@ bind_builtin (list)
run_unwind_frame ("bind_builtin");
if (return_code < 0)
return_code = EXECUTION_FAILURE;
return (sh_chkwrite (return_code));
}
@@ -344,7 +368,8 @@ unbind_keyseq (seq)
char *seq;
{
char *kseq;
int kslen;
int kslen, type;
rl_command_func_t *f;
kseq = (char *)xmalloc ((2 * strlen (seq)) + 1);
if (rl_translate_keyseq (seq, kseq, &kslen))
@@ -353,11 +378,13 @@ unbind_keyseq (seq)
builtin_error (_("`%s': cannot unbind"), seq);
return EXECUTION_FAILURE;
}
if (rl_function_of_keyseq (kseq, (Keymap)0, (int *)0) == 0)
if ((f = rl_function_of_keyseq_len (kseq, kslen, (Keymap)0, &type)) == 0)
{
free (kseq);
return (EXECUTION_SUCCESS);
}
if (type == ISKMAP)
f = ((Keymap) f)[ANYOTHERKEY].function;
/* I wish this didn't have to translate the key sequence again, but readline
doesn't have a binding function that takes a translated key sequence as
@@ -369,6 +396,9 @@ unbind_keyseq (seq)
return (EXECUTION_FAILURE);
}
if (f == bash_execute_unix_command)
unbind_unix_command (seq);
free (kseq);
return (EXECUTION_SUCCESS);
}
+2 -2
View File
@@ -1,7 +1,7 @@
This file is break.def, from which is created break.c.
It implements the builtins "break" and "continue" in Bash.
Copyright (C) 1987-2009 Free Software Foundation, Inc.
Copyright (C) 1987-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -46,7 +46,7 @@ $END
#include "../execute_cmd.h"
#include "common.h"
static int check_loop_level __P((void));
static int check_loop_level PARAMS((void));
/* The depth of while's and until's. */
int loop_level = 0;
+3 -3
View File
@@ -2,7 +2,7 @@ This file is caller.def, from which is created caller.c. It implements the
builtin "caller" in Bash.
Copyright (C) 2002-2008 Rocky Bernstein for Free Software Foundation, Inc.
Copyright (C) 2008-2013 Free Software Foundation, Inc.
Copyright (C) 2008-2019 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -135,8 +135,8 @@ caller_builtin (list)
static char *caller_doc[] = {
N_("Returns the context of the current subroutine call.\n\
\n\
Without EXPR, returns "$line $filename". With EXPR, returns\n\
"$line $subroutine $filename"; this extra information can be used to\n\
Without EXPR, returns \"$line $filename\". With EXPR, returns\n\
\"$line $subroutine $filename\"; this extra information can be used to\n\
provide a stack trace.\n\
\n\
The value of EXPR indicates how many call frames to go back before the\n\
+8 -7
View File
@@ -1,7 +1,7 @@
This file is cd.def, from which is created cd.c. It implements the
builtins "cd" and "pwd" in Bash.
Copyright (C) 1987-2016 Free Software Foundation, Inc.
Copyright (C) 1987-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -56,13 +56,13 @@ extern int errno;
extern const char * const bash_getcwd_errstr;
static int bindpwd __P((int));
static int setpwd __P((char *));
static char *resetpwd __P((char *));
static int change_to_directory __P((char *, int, int));
static int bindpwd PARAMS((int));
static int setpwd PARAMS((char *));
static char *resetpwd PARAMS((char *));
static int change_to_directory PARAMS((char *, int, int));
static int cdxattr __P((char *, char **));
static void resetxattr __P((void));
static int cdxattr PARAMS((char *, char **));
static void resetxattr PARAMS((void));
/* Change this to 1 to get cd spelling correction by default. */
int cdspelling = 0;
@@ -149,6 +149,7 @@ bindpwd (no_symlinks)
#undef tcwd
/* If canonicalization fails, reset dirname to the_current_working_directory */
canon_failed = 0;
if (dirname == 0)
{
canon_failed = 1;
+12 -3
View File
@@ -1,7 +1,7 @@
This file is colon.def, from which is created colon.c.
It implements the builtin ":" in Bash.
Copyright (C) 1987-2009 Free Software Foundation, Inc.
Copyright (C) 1987-2019 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -50,10 +50,19 @@ Exit Status:
Always fails.
$END
#include <config.h>
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif
#include "../bashansi.h"
#include "../shell.h"
/* Return a successful result. */
int
colon_builtin (ignore)
char *ignore;
WORD_LIST *ignore;
{
return (0);
}
@@ -61,7 +70,7 @@ colon_builtin (ignore)
/* Return an unsuccessful result. */
int
false_builtin (ignore)
char *ignore;
WORD_LIST *ignore;
{
return (1);
}
+6 -2
View File
@@ -1,7 +1,7 @@
This file is command.def, from which is created command.c.
It implements the builtin "command" in Bash.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
Copyright (C) 1987-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -57,7 +57,7 @@ $END
#include "common.h"
#if defined (_CS_PATH) && defined (HAVE_CONFSTR) && !HAVE_DECL_CONFSTR
extern size_t confstr __P((int, char *, size_t));
extern size_t confstr PARAMS((int, char *, size_t));
#endif
/* Run the commands mentioned in LIST without paying attention to shell
@@ -124,6 +124,10 @@ 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
/* 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. */
command = make_bare_simple_command ();
+110 -3
View File
@@ -1,6 +1,6 @@
/* common.c - utility functions for all builtins */
/* Copyright (C) 1987-2017 Free Software Foundation, Inc.
/* Copyright (C) 1987-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -373,7 +373,8 @@ make_builtin_argv (list, ip)
/* Remember LIST in $1 ... $9, and REST_OF_ARGS. If DESTRUCTIVE is
non-zero, then discard whatever the existing arguments are, else
only discard the ones that are to be replaced. */
only discard the ones that are to be replaced. Set POSPARAM_COUNT
to the number of args assigned (length of LIST). */
void
remember_args (list, destructive)
WORD_LIST *list;
@@ -381,6 +382,8 @@ remember_args (list, destructive)
{
register int i;
posparam_count = 0;
for (i = 1; i < 10; i++)
{
if ((destructive || list) && dollar_vars[i])
@@ -391,7 +394,7 @@ remember_args (list, destructive)
if (list)
{
dollar_vars[i] = savestring (list->word->word);
dollar_vars[posparam_count = i] = savestring (list->word->word);
list = list->next;
}
}
@@ -403,6 +406,7 @@ remember_args (list, destructive)
{
dispose_words (rest_of_args);
rest_of_args = copy_word_list (list);
posparam_count += list_length (list);
}
if (destructive)
@@ -411,6 +415,58 @@ remember_args (list, destructive)
invalidate_cached_quoted_dollar_at ();
}
void
shift_args (times)
int times;
{
WORD_LIST *temp;
int count;
if (times <= 0) /* caller should check */
return;
while (times-- > 0)
{
if (dollar_vars[1])
free (dollar_vars[1]);
for (count = 1; count < 9; count++)
dollar_vars[count] = dollar_vars[count + 1];
if (rest_of_args)
{
temp = rest_of_args;
dollar_vars[9] = savestring (temp->word->word);
rest_of_args = rest_of_args->next;
temp->next = (WORD_LIST *)NULL;
dispose_words (temp);
}
else
dollar_vars[9] = (char *)NULL;
posparam_count--;
}
}
int
number_of_args ()
{
#ifdef DEBUG
register WORD_LIST *list;
int n;
for (n = 0; n < 9 && dollar_vars[n+1]; n++)
;
for (list = rest_of_args; list; list = list->next)
n++;
if (n != posparam_count)
itrace("number_of_args: n (%d) != posparam_count (%d)", n, posparam_count);
#endif
return posparam_count;
}
static int changed_dollar_vars;
/* Have the dollar variables been reset to new values since we last
@@ -908,3 +964,54 @@ builtin_help ()
printf ("%s: %s\n", this_command_name, _("help not available in this version"));
}
#endif
/* **************************************************************** */
/* */
/* Variable assignments during builtin commands */
/* */
/* **************************************************************** */
SHELL_VAR *
builtin_bind_variable (name, value, flags)
char *name;
char *value;
int flags;
{
SHELL_VAR *v;
#if defined (ARRAY_VARS)
if (valid_array_reference (name, assoc_expand_once ? (VA_NOEXPAND|VA_ONEWORD) : 0) == 0)
v = bind_variable (name, value, flags);
else
v = assign_array_element (name, value, flags | (assoc_expand_once ? ASS_NOEXPAND : 0));
#else /* !ARRAY_VARS */
v = bind_variable (name, value, flags);
#endif /* !ARRAY_VARS */
if (v && readonly_p (v) == 0 && noassign_p (v) == 0)
VUNSETATTR (v, att_invisible);
return v;
}
/* Like check_unbind_variable, but for use by builtins (only matters for
error messages). */
int
builtin_unbind_variable (vname)
const char *vname;
{
SHELL_VAR *v;
v = find_variable (vname);
if (v && readonly_p (v))
{
builtin_error (_("%s: cannot unset: readonly %s"), vname, "variable");
return -2;
}
else if (v && non_unsettable_p (v))
{
builtin_error (_("%s: cannot unset"), vname);
return -2;
}
return (unbind_variable (vname));
}
+98 -89
View File
@@ -1,6 +1,6 @@
/* common.h -- extern declarations for functions defined in common.c. */
/* Copyright (C) 1993-2015 Free Software Foundation, Inc.
/* Copyright (C) 1993-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -80,142 +80,151 @@ do { \
#define MAX_ATTRIBUTES 16
/* Functions from common.c */
extern void builtin_error __P((const char *, ...)) __attribute__((__format__ (printf, 1, 2)));
extern void builtin_warning __P((const char *, ...)) __attribute__((__format__ (printf, 1, 2)));
extern void builtin_usage __P((void));
extern void no_args __P((WORD_LIST *));
extern int no_options __P((WORD_LIST *));
extern void builtin_error PARAMS((const char *, ...)) __attribute__((__format__ (printf, 1, 2)));
extern void builtin_warning PARAMS((const char *, ...)) __attribute__((__format__ (printf, 1, 2)));
extern void builtin_usage PARAMS((void));
extern void no_args PARAMS((WORD_LIST *));
extern int no_options PARAMS((WORD_LIST *));
/* common error message functions */
extern void sh_needarg __P((char *));
extern void sh_neednumarg __P((char *));
extern void sh_notfound __P((char *));
extern void sh_invalidopt __P((char *));
extern void sh_invalidoptname __P((char *));
extern void sh_invalidid __P((char *));
extern void sh_invalidnum __P((char *));
extern void sh_invalidsig __P((char *));
extern void sh_erange __P((char *, char *));
extern void sh_badpid __P((char *));
extern void sh_badjob __P((char *));
extern void sh_readonly __P((const char *));
extern void sh_nojobs __P((char *));
extern void sh_restricted __P((char *));
extern void sh_notbuiltin __P((char *));
extern void sh_wrerror __P((void));
extern void sh_ttyerror __P((int));
extern int sh_chkwrite __P((int));
extern void sh_needarg PARAMS((char *));
extern void sh_neednumarg PARAMS((char *));
extern void sh_notfound PARAMS((char *));
extern void sh_invalidopt PARAMS((char *));
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_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 *));
extern void sh_wrerror PARAMS((void));
extern void sh_ttyerror PARAMS((int));
extern int sh_chkwrite PARAMS((int));
extern char **make_builtin_argv __P((WORD_LIST *, int *));
extern void remember_args __P((WORD_LIST *, int));
extern char **make_builtin_argv PARAMS((WORD_LIST *, int *));
extern void remember_args PARAMS((WORD_LIST *, int));
extern void shift_args PARAMS((int));
extern int number_of_args PARAMS((void));
extern int dollar_vars_changed __P((void));
extern void set_dollar_vars_unchanged __P((void));
extern void set_dollar_vars_changed __P((void));
extern int dollar_vars_changed PARAMS((void));
extern void set_dollar_vars_unchanged PARAMS((void));
extern void set_dollar_vars_changed PARAMS((void));
extern int get_numeric_arg __P((WORD_LIST *, int, intmax_t *));
extern int get_exitstat __P((WORD_LIST *));
extern int read_octal __P((char *));
extern int get_numeric_arg PARAMS((WORD_LIST *, int, intmax_t *));
extern int get_exitstat PARAMS((WORD_LIST *));
extern int read_octal PARAMS((char *));
/* Keeps track of the current working directory. */
extern char *the_current_working_directory;
extern char *get_working_directory __P((char *));
extern void set_working_directory __P((char *));
extern char *get_working_directory PARAMS((char *));
extern void set_working_directory PARAMS((char *));
#if defined (JOB_CONTROL)
extern int get_job_by_name __P((const char *, int));
extern int get_job_spec __P((WORD_LIST *));
extern int get_job_by_name PARAMS((const char *, int));
extern int get_job_spec PARAMS((WORD_LIST *));
#endif
extern int display_signal_list __P((WORD_LIST *, int));
extern int display_signal_list PARAMS((WORD_LIST *, int));
/* It's OK to declare a function as returning a Function * without
providing a definition of what a `Function' is. */
extern struct builtin *builtin_address_internal __P((char *, int));
extern sh_builtin_func_t *find_shell_builtin __P((char *));
extern sh_builtin_func_t *builtin_address __P((char *));
extern sh_builtin_func_t *find_special_builtin __P((char *));
extern void initialize_shell_builtins __P((void));
extern struct builtin *builtin_address_internal PARAMS((char *, int));
extern sh_builtin_func_t *find_shell_builtin PARAMS((char *));
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));
/* Functions from exit.def */
extern void bash_logout __P((void));
extern void bash_logout PARAMS((void));
/* Functions from getopts.def */
extern void getopts_reset __P((int));
extern void getopts_reset PARAMS((int));
/* Functions from help.def */
extern void builtin_help __P((void));
extern void builtin_help PARAMS((void));
/* Functions from read.def */
extern void read_tty_cleanup __P((void));
extern int read_tty_modified __P((void));
extern void read_tty_cleanup PARAMS((void));
extern int read_tty_modified PARAMS((void));
/* Functions from set.def */
extern int minus_o_option_value __P((char *));
extern void list_minus_o_opts __P((int, int));
extern char **get_minus_o_opts __P((void));
extern int set_minus_o_option __P((int, char *));
extern int minus_o_option_value PARAMS((char *));
extern void list_minus_o_opts PARAMS((int, int));
extern char **get_minus_o_opts PARAMS((void));
extern int set_minus_o_option PARAMS((int, char *));
extern void set_shellopts __P((void));
extern void parse_shellopts __P((char *));
extern void initialize_shell_options __P((int));
extern void set_shellopts PARAMS((void));
extern void parse_shellopts PARAMS((char *));
extern void initialize_shell_options PARAMS((int));
extern void reset_shell_options __P((void));
extern void reset_shell_options PARAMS((void));
extern char *get_current_options __P((void));
extern void set_current_options __P((const char *));
extern char *get_current_options PARAMS((void));
extern void set_current_options PARAMS((const char *));
/* Functions from shopt.def */
extern void reset_shopt_options __P((void));
extern char **get_shopt_options __P((void));
extern void reset_shopt_options PARAMS((void));
extern char **get_shopt_options PARAMS((void));
extern int shopt_setopt __P((char *, int));
extern int shopt_listopt __P((char *, int));
extern int shopt_setopt PARAMS((char *, int));
extern int shopt_listopt PARAMS((char *, int));
extern int set_login_shell __P((char *, int));
extern int set_login_shell PARAMS((char *, int));
extern void set_bashopts __P((void));
extern void parse_bashopts __P((char *));
extern void initialize_bashopts __P((int));
extern void set_bashopts PARAMS((void));
extern void parse_bashopts PARAMS((char *));
extern void initialize_bashopts PARAMS((int));
extern void set_compatibility_opts __P((void));
extern void set_compatibility_opts PARAMS((void));
/* Functions from type.def */
extern int describe_command __P((char *, int));
extern int describe_command PARAMS((char *, int));
/* Functions from setattr.def */
extern int set_or_show_attributes __P((WORD_LIST *, int, int));
extern int show_all_var_attributes __P((int, int));
extern int show_var_attributes __P((SHELL_VAR *, int, int));
extern int show_name_attributes __P((char *, int));
extern int show_func_attributes __P((char *, int));
extern void set_var_attribute __P((char *, int, int));
extern int var_attribute_string __P((SHELL_VAR *, int, char *));
extern int set_or_show_attributes PARAMS((WORD_LIST *, int, int));
extern int show_all_var_attributes PARAMS((int, int));
extern int show_local_var_attributes PARAMS((int, int));
extern int show_var_attributes PARAMS((SHELL_VAR *, int, int));
extern int show_name_attributes PARAMS((char *, int));
extern int show_localname_attributes PARAMS((char *, int));
extern int show_func_attributes PARAMS((char *, int));
extern void set_var_attribute PARAMS((char *, int, int));
extern int var_attribute_string PARAMS((SHELL_VAR *, int, char *));
/* Functions from pushd.def */
extern char *get_dirstack_from_string __P((char *));
extern char *get_dirstack_element __P((intmax_t, int));
extern void set_dirstack_element __P((intmax_t, int, char *));
extern WORD_LIST *get_directory_stack __P((int));
extern char *get_dirstack_from_string PARAMS((char *));
extern char *get_dirstack_element PARAMS((intmax_t, int));
extern void set_dirstack_element PARAMS((intmax_t, int, char *));
extern WORD_LIST *get_directory_stack PARAMS((int));
/* Functions from evalstring.c */
extern int parse_and_execute __P((char *, const char *, int));
extern int evalstring __P((char *, const char *, int));
extern void parse_and_execute_cleanup __P((int));
extern int parse_string __P((char *, const char *, int, char **));
extern int should_suppress_fork __P((COMMAND *));
extern void optimize_fork __P((COMMAND *));
extern void optimize_subshell_command __P((COMMAND *));
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 should_suppress_fork PARAMS((COMMAND *));
extern int can_optimize_connection PARAMS((COMMAND *));
extern void optimize_fork PARAMS((COMMAND *));
extern void optimize_subshell_command PARAMS((COMMAND *));
extern void optimize_shell_function PARAMS((COMMAND *));
/* Functions from evalfile.c */
extern int maybe_execute_file __P((const char *, int));
extern int force_execute_file __P((const char *, int));
extern int source_file __P((const char *, int));
extern int fc_execute_file __P((const char *));
extern int maybe_execute_file PARAMS((const char *, int));
extern int force_execute_file PARAMS((const char *, int));
extern int source_file PARAMS((const char *, int));
extern int fc_execute_file PARAMS((const char *));
/* variables from common.c */
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 int builtin_unbind_variable PARAMS((const char *));
/* variables from evalfile.c */
extern int sourcelevel;
+99 -144
View File
@@ -1,7 +1,7 @@
This file is complete.def, from which is created complete.c.
It implements the builtins "complete", "compgen", and "compopt" in Bash.
Copyright (C) 1999-2015 Free Software Foundation, Inc.
Copyright (C) 1999-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -23,7 +23,7 @@ $PRODUCES complete.c
$BUILTIN complete
$DEPENDS_ON PROGRAMMABLE_COMPLETION
$FUNCTION complete_builtin
$SHORT_DOC complete [-abcdefgjksuv] [-pr] [-DEI] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [name ...]
$SHORT_DOC complete [-abcdefgjksuv] [-pr] [-DEI] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [name ...]
Specify how arguments are to be completed by Readline.
For each NAME, specify how arguments are to be completed. If no options
@@ -42,7 +42,7 @@ Options:
command) word
When completion is attempted, the actions are applied in the order the
uppercase-letter options are listed above. If multiple options are supplied,
uppercase-letter options are listed above. If multiple options are supplied,
the -D option takes precedence over -E, and both take precedence over -I.
Exit Status:
@@ -84,24 +84,29 @@ struct _optflags {
int Iflag;
};
static int find_compact __P((char *));
static int find_compopt __P((char *));
static int find_compact PARAMS((char *));
static int find_compopt PARAMS((char *));
static int build_actions __P((WORD_LIST *, struct _optflags *, unsigned long *, unsigned long *));
static int build_actions PARAMS((WORD_LIST *, struct _optflags *, unsigned long *, unsigned long *));
static int remove_cmd_completions __P((WORD_LIST *));
static int remove_cmd_completions PARAMS((WORD_LIST *));
static int print_one_completion __P((char *, COMPSPEC *));
static int print_compitem __P((BUCKET_CONTENTS *));
static void print_compopts __P((const char *, COMPSPEC *, int));
static void print_all_completions __P((void));
static int print_cmd_completions __P((WORD_LIST *));
static int print_one_completion PARAMS((char *, COMPSPEC *));
static int print_compitem PARAMS((BUCKET_CONTENTS *));
static void print_compopts PARAMS((const char *, COMPSPEC *, int));
static void print_all_completions PARAMS((void));
static int print_cmd_completions PARAMS((WORD_LIST *));
static void print_compoptions PARAMS((unsigned long, int));
static void print_compactions PARAMS((unsigned long));
static void print_arg PARAMS((const char *, const char *, int));
static void print_cmd_name PARAMS((const char *));
static char *Garg, *Warg, *Parg, *Sarg, *Xarg, *Farg, *Carg;
static const struct _compacts {
const char * const actname;
int actflag;
unsigned long actflag;
int actopt;
} compacts[] = {
{ "alias", CA_ALIAS, 'a' },
@@ -134,7 +139,7 @@ static const struct _compacts {
/* This should be a STRING_INT_ALIST */
static const struct _compopt {
const char * const optname;
int optflag;
unsigned long optflag;
} compopts[] = {
{ "bashdefault", COPT_BASHDEFAULT },
{ "default", COPT_DEFAULT },
@@ -193,6 +198,7 @@ build_actions (list, flagp, actp, optp)
{
int opt, ind, opt_given;
unsigned long acts, copts;
WORD_DESC w;
acts = copts = (unsigned long)0L;
opt_given = 0;
@@ -323,7 +329,13 @@ build_actions (list, flagp, actp, optp)
return (EX_USAGE);
}
case 'F':
Farg = list_optarg;
w.word = Farg = list_optarg;
w.flags = 0;
if (check_identifier (&w, posixly_correct) == 0 || strpbrk (Farg, shell_break_chars) != 0)
{
sh_invalidid (Farg);
return (EX_USAGE);
}
break;
case 'G':
Garg = list_optarg;
@@ -478,122 +490,95 @@ remove_cmd_completions (list)
return ret;
}
#define SQPRINTARG(a, f) \
do { \
if (a) \
{ \
x = sh_single_quote (a); \
printf ("%s %s ", f, x); \
free (x); \
} \
} while (0)
static void
print_compoptions (copts, full)
unsigned long copts;
int full;
{
const struct _compopt *co;
#define PRINTARG(a, f) \
do { \
if (a) \
printf ("%s %s ", f, a); \
} while (0)
for (co = compopts; co->optname; co++)
if (copts & co->optflag)
printf ("-o %s ", co->optname);
else if (full)
printf ("+o %s ", co->optname);
}
#define PRINTOPT(a, f) \
do { \
if (acts & a) \
printf ("%s ", f); \
} while (0)
static void
print_compactions (acts)
unsigned long acts;
{
const struct _compacts *ca;
#define PRINTACT(a, f) \
do { \
if (acts & a) \
printf ("-A %s ", f); \
} while (0)
/* simple flags first */
for (ca = compacts; ca->actname; ca++)
if (ca->actopt && (acts & ca->actflag))
printf ("-%c ", ca->actopt);
#define PRINTCOMPOPT(a, f) \
do { \
if (copts & a) \
printf ("-o %s ", f); \
} while (0)
/* then the rest of the actions */
for (ca = compacts; ca->actname; ca++)
if (ca->actopt == 0 && (acts & ca->actflag))
printf ("-A %s ", ca->actname);
}
#define XPRINTCOMPOPT(a, f) \
do { \
if (copts & a) \
printf ("-o %s ", f); \
else \
printf ("+o %s ", f); \
} while (0)
static void
print_arg (arg, flag, quote)
const char *arg, *flag;
int quote;
{
char *x;
if (arg)
{
x = quote ? sh_single_quote (arg) : (char *)arg;
printf ("%s %s ", flag, x);
if (x != arg)
free (x);
}
}
static void
print_cmd_name (cmd)
const char *cmd;
{
if (STREQ (cmd, DEFAULTCMD))
printf ("-D");
else if (STREQ (cmd, EMPTYCMD))
printf ("-E");
else if (STREQ (cmd, INITIALWORD))
printf ("-I");
else if (*cmd == 0) /* XXX - can this happen? */
printf ("''");
else
printf ("%s", cmd);
}
static int
print_one_completion (cmd, cs)
char *cmd;
COMPSPEC *cs;
{
unsigned long acts, copts;
char *x;
printf ("complete ");
copts = cs->options;
/* First, print the -o options. */
PRINTCOMPOPT (COPT_BASHDEFAULT, "bashdefault");
PRINTCOMPOPT (COPT_DEFAULT, "default");
PRINTCOMPOPT (COPT_DIRNAMES, "dirnames");
PRINTCOMPOPT (COPT_FILENAMES, "filenames");
PRINTCOMPOPT (COPT_NOQUOTE, "noquote");
PRINTCOMPOPT (COPT_NOSORT, "nosort");
PRINTCOMPOPT (COPT_NOSPACE, "nospace");
PRINTCOMPOPT (COPT_PLUSDIRS, "plusdirs");
acts = cs->actions;
/* simple flags next */
PRINTOPT (CA_ALIAS, "-a");
PRINTOPT (CA_BUILTIN, "-b");
PRINTOPT (CA_COMMAND, "-c");
PRINTOPT (CA_DIRECTORY, "-d");
PRINTOPT (CA_EXPORT, "-e");
PRINTOPT (CA_FILE, "-f");
PRINTOPT (CA_GROUP, "-g");
PRINTOPT (CA_JOB, "-j");
PRINTOPT (CA_KEYWORD, "-k");
PRINTOPT (CA_SERVICE, "-s");
PRINTOPT (CA_USER, "-u");
PRINTOPT (CA_VARIABLE, "-v");
/* now the rest of the actions */
PRINTACT (CA_ARRAYVAR, "arrayvar");
PRINTACT (CA_BINDING, "binding");
PRINTACT (CA_DISABLED, "disabled");
PRINTACT (CA_ENABLED, "enabled");
PRINTACT (CA_FUNCTION, "function");
PRINTACT (CA_HELPTOPIC, "helptopic");
PRINTACT (CA_HOSTNAME, "hostname");
PRINTACT (CA_RUNNING, "running");
PRINTACT (CA_SETOPT, "setopt");
PRINTACT (CA_SHOPT, "shopt");
PRINTACT (CA_SIGNAL, "signal");
PRINTACT (CA_STOPPED, "stopped");
print_compoptions (cs->options, 0);
print_compactions (cs->actions);
/* now the rest of the arguments */
/* arguments that require quoting */
SQPRINTARG (cs->globpat, "-G");
SQPRINTARG (cs->words, "-W");
SQPRINTARG (cs->prefix, "-P");
SQPRINTARG (cs->suffix, "-S");
SQPRINTARG (cs->filterpat, "-X");
print_arg (cs->globpat, "-G", 1);
print_arg (cs->words, "-W", 1);
print_arg (cs->prefix, "-P", 1);
print_arg (cs->suffix, "-S", 1);
print_arg (cs->filterpat, "-X", 1);
SQPRINTARG (cs->command, "-C");
print_arg (cs->command, "-C", 1);
/* simple arguments that don't require quoting */
PRINTARG (cs->funcname, "-F");
print_arg (cs->funcname, "-F", 0);
if (STREQ (cmd, DEFAULTCMD))
printf ("-D\n");
else if (STREQ (cmd, EMPTYCMD))
printf ("-E\n");
else if (STREQ (cmd, INITIALWORD))
printf ("-I\n");
else
printf ("%s\n", cmd);
print_cmd_name (cmd);
printf ("\n");
return (0);
}
@@ -604,42 +589,12 @@ print_compopts (cmd, cs, full)
COMPSPEC *cs;
int full;
{
int copts;
printf ("compopt ");
copts = cs->options;
if (full)
{
XPRINTCOMPOPT (COPT_BASHDEFAULT, "bashdefault");
XPRINTCOMPOPT (COPT_DEFAULT, "default");
XPRINTCOMPOPT (COPT_DIRNAMES, "dirnames");
XPRINTCOMPOPT (COPT_FILENAMES, "filenames");
XPRINTCOMPOPT (COPT_NOQUOTE, "noquote");
XPRINTCOMPOPT (COPT_NOSORT, "nosort");
XPRINTCOMPOPT (COPT_NOSPACE, "nospace");
XPRINTCOMPOPT (COPT_PLUSDIRS, "plusdirs");
}
else
{
PRINTCOMPOPT (COPT_BASHDEFAULT, "bashdefault");
PRINTCOMPOPT (COPT_DEFAULT, "default");
PRINTCOMPOPT (COPT_DIRNAMES, "dirnames");
PRINTCOMPOPT (COPT_FILENAMES, "filenames");
PRINTCOMPOPT (COPT_NOQUOTE, "noquote");
PRINTCOMPOPT (COPT_NOSORT, "nosort");
PRINTCOMPOPT (COPT_NOSPACE, "nospace");
PRINTCOMPOPT (COPT_PLUSDIRS, "plusdirs");
}
print_compoptions (cs->options, full);
print_cmd_name (cmd);
if (STREQ (cmd, DEFAULTCMD))
printf ("-D\n");
else if (STREQ (cmd, EMPTYCMD))
printf ("-E\n");
else if (STREQ (cmd, INITIALWORD))
printf ("-I\n");
else
printf ("%s\n", cmd);
printf ("\n");
}
static int
@@ -687,7 +642,7 @@ print_cmd_completions (list)
$BUILTIN compgen
$DEPENDS_ON PROGRAMMABLE_COMPLETION
$FUNCTION compgen_builtin
$SHORT_DOC compgen [-abcdefgjksuv] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [word]
$SHORT_DOC compgen [-abcdefgjksuv] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [word]
Display possible completions depending on the options.
Intended to be used from within a shell function generating possible
+33 -33
View File
@@ -1,7 +1,7 @@
This file is declare.def, from which is created declare.c.
It implements the builtins "declare" and "local" in Bash.
Copyright (C) 1987-2016 Free Software Foundation, Inc.
Copyright (C) 1987-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -22,7 +22,7 @@ $PRODUCES declare.c
$BUILTIN declare
$FUNCTION declare_builtin
$SHORT_DOC declare [-aAfFgilnrtux] [-p] [name[=value] ...]
$SHORT_DOC declare [-aAfFgiIlnrtux] [-p] [name[=value] ...]
Set variable values and attributes.
Declare variables and give them attributes. If no NAMEs are given,
@@ -34,6 +34,8 @@ Options:
source file when debugging)
-g create global variables when used in a shell function; otherwise
ignored
-I if creating a local variable, inherit the attributes and value
of a variable with the same name at a previous scope
-p display the attributes and value of each NAME
Options which set attributes:
@@ -62,7 +64,7 @@ $END
$BUILTIN typeset
$FUNCTION declare_builtin
$SHORT_DOC typeset [-aAfFgilnrtux] [-p] name[=value] ...
$SHORT_DOC typeset [-aAfFgiIlnrtux] [-p] name[=value] ...
Set variable values and attributes.
A synonym for `declare'. See `help declare'.
@@ -88,8 +90,8 @@ $END
#include "builtext.h"
#include "bashgetopt.h"
static SHELL_VAR *declare_find_variable __P((const char *, int, int));
static int declare_internal __P((register WORD_LIST *, int));
static SHELL_VAR *declare_find_variable PARAMS((const char *, int, int));
static int declare_internal PARAMS((register WORD_LIST *, int));
/* Declare or change variable attributes. */
int
@@ -135,9 +137,9 @@ local_builtin (list)
}
#if defined (ARRAY_VARS)
# define DECLARE_OPTS "+acfgilnprtuxAFG"
# define DECLARE_OPTS "+acfgilnprtuxAFGI"
#else
# define DECLARE_OPTS "+cfgilnprtuxFG"
# define DECLARE_OPTS "+cfgilnprtuxFGI"
#endif
static SHELL_VAR *
@@ -168,13 +170,13 @@ declare_internal (list, local_var)
{
int flags_on, flags_off, *flags;
int any_failed, assign_error, pflag, nodefs, opt, onref, offref;
int mkglobal, chklocal;
int mkglobal, chklocal, inherit_flag;
char *t, *subscript_start;
SHELL_VAR *var, *refvar, *v;
FUNCTION_DEF *shell_fn;
flags_on = flags_off = any_failed = assign_error = pflag = nodefs = 0;
mkglobal = chklocal = 0;
mkglobal = chklocal = inherit_flag = 0;
refvar = (SHELL_VAR *)NULL;
reset_internal_getopt ();
while ((opt = internal_getopt (list, DECLARE_OPTS)) != -1)
@@ -202,7 +204,7 @@ declare_internal (list, local_var)
return (EX_USAGE);
#endif
case 'p':
if (local_var == 0)
/* if (local_var == 0) */
pflag++;
break;
case 'F':
@@ -255,6 +257,9 @@ declare_internal (list, local_var)
flags_off |= att_capcase|att_lowercase;
break;
#endif /* CASEMOD_ATTRS */
case 'I':
inherit_flag = MKLOC_INHERIT;
break;
CASE_HELPOPT;
default:
builtin_usage ();
@@ -271,20 +276,7 @@ declare_internal (list, local_var)
/* Show local variables defined at this context level if this is
the `local' builtin. */
if (local_var)
{
register SHELL_VAR **vlist;
register int i;
vlist = all_local_variables ();
if (vlist)
{
for (i = 0; vlist[i]; i++)
print_assignment (vlist[i]);
free (vlist);
}
}
show_local_var_attributes (0, nodefs); /* XXX - fix up args later */
else if (pflag && (flags_on == 0 || flags_on == att_function))
show_all_var_attributes (flags_on == 0, nodefs);
else if (flags_on == 0)
@@ -301,6 +293,8 @@ declare_internal (list, local_var)
{
if (flags_on & att_function)
pflag = show_func_attributes (list->word->word, nodefs);
else if (local_var)
pflag = show_localname_attributes (list->word->word, nodefs);
else
pflag = show_name_attributes (list->word->word, nodefs);
if (pflag)
@@ -463,9 +457,9 @@ restart_new_var_name:
return an existing {array,assoc} variable to be flagged as an
error below. */
if (flags_on & att_assoc)
var = make_local_assoc_variable (newname, 1);
var = make_local_assoc_variable (newname, MKLOC_ARRAYOK|inherit_flag);
else if ((flags_on & att_array) || making_array_special)
var = make_local_array_variable (newname, 1);
var = make_local_array_variable (newname, MKLOC_ASSOCOK|inherit_flag);
else
#endif
if (offset == 0 && (flags_on & att_nameref))
@@ -479,18 +473,18 @@ restart_new_var_name:
if (refvar && refvar->context != variable_context)
{
refvar = 0;
var = make_local_variable (name, 0);
var = make_local_variable (name, inherit_flag);
}
else if (refvar && refvar->context == variable_context)
var = refvar;
/* Maybe we just want to create a new local variable */
else if (var == 0 || var->context != variable_context)
var = make_local_variable (name, 0);
var = make_local_variable (name, inherit_flag);
/* otherwise we have a var at the right context */
}
else
/* XXX - check name for validity here with valid_nameref_value */
var = make_local_variable ((flags_on & att_nameref) ? name : newname, 0); /* sets att_invisible for new vars */
var = make_local_variable ((flags_on & att_nameref) ? name : newname, inherit_flag); /* sets att_invisible for new vars */
if (var == 0)
{
@@ -533,7 +527,12 @@ restart_new_var_name:
any_failed++;
NEXT_VARIABLE ();
}
else if (flags_on & (att_array|att_assoc))
{
sh_invalidopt ((flags_on & att_array) ? "-a" : "-A");
any_failed++;
NEXT_VARIABLE ();
}
/* declare -[Ff] name [name...] */
if (flags_on == att_function && flags_off == 0)
{
@@ -558,6 +557,7 @@ restart_new_var_name:
else /* declare -[fF] -[rx] name [name...] */
{
VSETATTR (var, flags_on);
flags_off &= ~att_function; /* makes no sense */
VUNSETATTR (var, flags_off);
}
}
@@ -727,20 +727,20 @@ restart_new_var_name:
if (flags_on & att_assoc)
{
var = make_new_assoc_variable (name);
if (var && offset == 0 && no_invisible_vars == 0)
if (var && offset == 0)
VSETATTR (var, att_invisible);
}
else if ((flags_on & att_array) || making_array_special)
{
var = make_new_array_variable (name);
if (var && offset == 0 && no_invisible_vars == 0)
if (var && offset == 0)
VSETATTR (var, att_invisible);
}
else
#endif
{
var = mkglobal ? bind_global_variable (name, (char *)NULL, ASS_FORCE) : bind_variable (name, (char *)NULL, ASS_FORCE);
if (var && offset == 0 && no_invisible_vars == 0)
if (var && offset == 0)
VSETATTR (var, att_invisible);
}
if (var == 0)
+13 -8
View File
@@ -1,7 +1,7 @@
This file is enable.def, from which is created enable.c.
It implements the builtin "enable" in Bash.
Copyright (C) 1987-2016 Free Software Foundation, Inc.
Copyright (C) 1987-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -84,13 +84,13 @@ $END
#define SFLAG 0x20
#if defined (HAVE_DLOPEN) && defined (HAVE_DLSYM)
static int dyn_load_builtin __P((WORD_LIST *, int, char *));
static int dyn_load_builtin PARAMS((WORD_LIST *, int, char *));
#endif
#if defined (HAVE_DLCLOSE)
static int dyn_unload_builtin __P((char *));
static void delete_builtin __P((struct builtin *));
static int local_dlclose __P((void *));
static int dyn_unload_builtin PARAMS((char *));
static void delete_builtin PARAMS((struct builtin *));
static int local_dlclose PARAMS((void *));
#endif
#define STRUCT_SUFFIX "_struct"
@@ -98,8 +98,8 @@ static int local_dlclose __P((void *));
#define LOAD_SUFFIX "_builtin_load"
#define UNLOAD_SUFFIX "_builtin_unload"
static void list_some_builtins __P((int));
static int enable_shell_command __P((char *, int));
static void list_some_builtins PARAMS((int));
static int enable_shell_command PARAMS((char *, int));
/* Enable/disable shell commands present in LIST. If list is not specified,
then print out a list of shell commands showing which are enabled and
@@ -362,6 +362,8 @@ dyn_load_builtin (list, flags, filename)
strcpy (struct_name, name);
strcpy (struct_name + size, STRUCT_SUFFIX);
old_builtin = builtin_address_internal (name, 1);
b = (struct builtin *)dlsym (handle, struct_name);
if (b == 0)
{
@@ -381,6 +383,9 @@ dyn_load_builtin (list, flags, filename)
loadfunc = (sh_load_func_t *)dlsym (handle, funcname);
if (loadfunc)
{
/* Add warning if running an init function more than once */
if (old_builtin && (old_builtin->flags & STATIC_BUILTIN) == 0)
builtin_warning (_("%s: dynamic builtin already loaded"), name);
r = (*loadfunc) (name);
if (r == 0)
{
@@ -396,7 +401,7 @@ dyn_load_builtin (list, flags, filename)
b->flags |= SPECIAL_BUILTIN;
b->handle = handle;
if (old_builtin = builtin_address_internal (name, 1))
if (old_builtin)
{
replaced++;
FASTCOPY ((char *)b, (char *)old_builtin, sizeof (struct builtin));
+1 -1
View File
@@ -123,7 +123,7 @@ file_error_and_exit:
if (flags & FEVAL_LONGJMP)
{
last_command_exit_value = 1;
last_command_exit_value = EXECUTION_FAILURE;
jump_to_top_level (EXITPROG);
}
+36 -5
View File
@@ -1,6 +1,6 @@
/* evalstring.c - evaluate a string as one or more shell commands. */
/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
/* Copyright (C) 1996-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -63,7 +63,7 @@ extern int errno;
int parse_and_execute_level = 0;
static int cat_file __P((REDIRECT *));
static int cat_file PARAMS((REDIRECT *));
#define PE_TAG "parse_and_execute top"
#define PS_TAG "parse_string top"
@@ -88,6 +88,11 @@ 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' &&
@@ -96,7 +101,11 @@ should_suppress_fork (command)
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));
}
@@ -145,7 +154,27 @@ optimize_subshell_command (command)
(command->value.Connection->connector == AND_AND || command->value.Connection->connector == OR_OR))
optimize_subshell_command (command->value.Connection->second);
}
void
optimize_shell_function (command)
COMMAND *command;
{
COMMAND *fc;
fc = (command->type == cm_group) ? command->value.Group->command : command;
if (fc->type == cm_simple && should_suppress_fork (fc))
{
fc->flags |= CMD_NO_FORK;
fc->value.Simple->flags |= CMD_NO_FORK;
}
else if (fc->type == cm_connection && can_optimize_connection (fc) && should_suppress_fork (fc->value.Connection->second))
{
fc->value.Connection->second->flags |= CMD_NO_FORK;
fc->value.Connection->second->value.Simple->flags |= CMD_NO_FORK;
}
}
/* How to force parse_and_execute () to clean up after itself. */
void
parse_and_execute_cleanup (old_running_trap)
@@ -339,6 +368,7 @@ parse_and_execute (string, from_file, flags)
if (command)
run_unwind_frame ("pe_dispose");
last_result = last_command_exit_value = EXECUTION_FAILURE; /* XXX */
set_pipestatus_from_exit (last_command_exit_value);
if (subshell_environment)
{
should_jump_to_top_level = 1;
@@ -389,6 +419,7 @@ parse_and_execute (string, from_file, flags)
internal_warning (_("%s: ignoring function definition attempt"), from_file);
should_jump_to_top_level = 0;
last_result = last_command_exit_value = EX_BADUSAGE;
set_pipestatus_from_exit (last_command_exit_value);
reset_parser ();
break;
}
@@ -609,7 +640,7 @@ itrace("parse_string: longjmp executed: code = %d", code);
break;
}
out:
out:
global_command = oglobal;
nc = bash_input.location.string - ostring;
@@ -654,7 +685,7 @@ cat_file (r)
if (fn == 0)
{
redirection_error (r, AMBIGUOUS_REDIRECT);
redirection_error (r, AMBIGUOUS_REDIRECT, fn);
return -1;
}
+7 -4
View File
@@ -1,7 +1,7 @@
This file is exec.def, from which is created exec.c.
It implements the builtin "exec" in Bash.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
Copyright (C) 1987-2019 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -22,7 +22,7 @@ $PRODUCES exec.c
$BUILTIN exec
$FUNCTION exec_builtin
$SHORT_DOC exec [-cl] [-a name] [command [arguments ...]] [redirection ...]
$SHORT_DOC exec [-cl] [-a name] [command [argument ...]] [redirection ...]
Replace the shell with the given command.
Execute COMMAND, replacing this shell with the specified program.
@@ -52,6 +52,8 @@ $END
# include <unistd.h>
#endif
#include <stdio.h>
#include "../bashansi.h"
#include "../bashintl.h"
@@ -99,7 +101,7 @@ exec_builtin (list)
WORD_LIST *list;
{
int exit_value = EXECUTION_FAILURE;
int cleanenv, login, opt;
int cleanenv, login, opt, orig_job_control;
char *argv0, *command, **args, **env, *newname, *com2;
cleanenv = login = 0;
@@ -216,6 +218,7 @@ exec_builtin (list)
restore_original_signals ();
#if defined (JOB_CONTROL)
orig_job_control = job_control; /* XXX - was also interactive_shell */
if (subshell_environment == 0)
end_job_control ();
if (interactive || job_control)
@@ -262,7 +265,7 @@ failed_exec:
initialize_signals (1);
#if defined (JOB_CONTROL)
if (interactive_shell || job_control)
if (orig_job_control)
restart_job_control ();
#endif /* JOB_CONTROL */
+2 -2
View File
@@ -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-2009 Free Software Foundation, Inc.
Copyright (C) 1987-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -50,7 +50,7 @@ $END
extern int check_jobs_at_exit;
static int exit_or_logout __P((WORD_LIST *));
static int exit_or_logout PARAMS((WORD_LIST *));
static int sourced_logout;
int
+104 -30
View File
@@ -1,7 +1,7 @@
This file is fc.def, from which is created fc.c.
It implements the builtin "fc" in Bash.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
Copyright (C) 1987-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -86,9 +86,19 @@ $END
extern int errno;
#endif /* !errno */
extern int unlink __P((const char *));
#define HIST_INVALID INT_MIN
#define HIST_ERANGE INT_MIN+1
#define HIST_NOTFOUND INT_MIN+2
extern FILE *sh_mktmpfp __P((char *, int, char **));
/* Values for the flags argument to fc_gethnum */
#define HN_LISTING 0x01
#define HN_FIRST 0x02
extern int unlink PARAMS((const char *));
extern FILE *sh_mktmpfp PARAMS((char *, int, char **));
extern int suppress_debug_trap_verbose;
/* **************************************************************** */
/* */
@@ -144,14 +154,14 @@ typedef struct repl {
} \
} while (0)
static char *fc_dosubs __P((char *, REPL *));
static char *fc_gethist __P((char *, HIST_ENTRY **));
static int fc_gethnum __P((char *, HIST_ENTRY **));
static int fc_number __P((WORD_LIST *));
static void fc_replhist __P((char *));
static char *fc_dosubs PARAMS((char *, REPL *));
static char *fc_gethist PARAMS((char *, HIST_ENTRY **, int));
static int fc_gethnum PARAMS((char *, HIST_ENTRY **, int));
static int fc_number PARAMS((WORD_LIST *));
static void fc_replhist PARAMS((char *));
#ifdef INCLUDE_UNUSED
static char *fc_readline __P((FILE *));
static void fc_addhist __P((char *));
static char *fc_readline PARAMS((FILE *));
static void fc_addhist PARAMS((char *));
#endif
static void
@@ -199,7 +209,7 @@ fc_builtin (list)
break;
case 'l':
listing = 1;
listing = HN_LISTING; /* for fc_gethnum */
break;
case 'r':
@@ -258,7 +268,7 @@ fc_builtin (list)
/* If we still have something in list, it is a command spec.
Otherwise, we use the most recent command in time. */
command = fc_gethist (list ? list->word->word : (char *)NULL, hlist);
command = fc_gethist (list ? list->word->word : (char *)NULL, hlist, 0);
if (command == NULL)
{
@@ -319,18 +329,15 @@ fc_builtin (list)
while (last_hist >= 0 && hlist[last_hist] == 0)
last_hist--;
if (last_hist < 0)
{
sh_erange ((char *)NULL, _("history specification"));
return (EXECUTION_FAILURE);
}
last_hist = 0; /* per POSIX */
if (list)
{
histbeg = fc_gethnum (list->word->word, hlist);
histbeg = fc_gethnum (list->word->word, hlist, listing|HN_FIRST);
list = list->next;
if (list)
histend = fc_gethnum (list->word->word, hlist);
histend = fc_gethnum (list->word->word, hlist, listing);
else if (histbeg == real_last)
histend = listing ? real_last : histbeg;
else
@@ -351,6 +358,28 @@ fc_builtin (list)
histbeg = histend = last_hist;
}
if (histbeg == HIST_INVALID || histend == HIST_INVALID)
{
sh_erange ((char *)NULL, _("history specification"));
return (EXECUTION_FAILURE);
}
else if (histbeg == HIST_ERANGE || histend == HIST_ERANGE)
{
sh_erange ((char *)NULL, _("history specification"));
return (EXECUTION_FAILURE);
}
else if (histbeg == HIST_NOTFOUND || histend == HIST_NOTFOUND)
{
builtin_error (_("no command found"));
return (EXECUTION_FAILURE);
}
/* We don't throw an error for line specifications out of range, per POSIX */
if (histbeg < 0)
histbeg = 0;
if (histend < 0)
histend = 0;
/* "When not listing, the fc command that caused the editing shall not be
entered into the history list." */
if (listing == 0 && hist_last_line_added)
@@ -364,14 +393,36 @@ fc_builtin (list)
in parse_and_execute(). */
if (histbeg == histend && histend == last_hist && hlist[last_hist] == 0)
last_hist = histbeg = --histend;
if (hlist[last_hist] == 0)
last_hist--;
if (histend >= last_hist)
histend = last_hist;
else if (histbeg >= last_hist)
histbeg = last_hist;
}
/* We print error messages for line specifications out of range. */
if ((histbeg < 0) || (histend < 0))
if (histbeg == HIST_INVALID || histend == HIST_INVALID)
{
sh_erange ((char *)NULL, _("history specification"));
return (EXECUTION_FAILURE);
}
else if (histbeg == HIST_ERANGE || histend == HIST_ERANGE)
{
sh_erange ((char *)NULL, _("history specification"));
return (EXECUTION_FAILURE);
}
else if (histbeg == HIST_NOTFOUND || histend == HIST_NOTFOUND)
{
builtin_error (_("no command found"));
return (EXECUTION_FAILURE);
}
/* We don't throw an error for line specifications out of range, per POSIX */
if (histbeg < 0)
histbeg = 0;
if (histend < 0)
histend = 0;
if (histend < histbeg)
{
@@ -445,7 +496,7 @@ fc_builtin (list)
}
#if defined (READLINE)
/* If we're executing as part of a dispatched readline commnand like
/* If we're executing as part of a dispatched readline command like
{emacs,vi}_edit_and_execute_command, the readline state will indicate it.
We could remove the partial command from the history, but ksh93 doesn't
so we stay compatible. */
@@ -463,7 +514,9 @@ fc_builtin (list)
add_unwind_protect (xfree, fn);
add_unwind_protect (unlink, fn);
add_unwind_protect (set_verbose_flag, (char *)NULL);
unwind_protect_int (suppress_debug_trap_verbose);
echo_input_at_read = 1;
suppress_debug_trap_verbose = 1;
retval = fc_execute_file (fn);
run_unwind_frame ("fc builtin");
@@ -488,16 +541,21 @@ fc_number (list)
/* Return an absolute index into HLIST which corresponds to COMMAND. If
COMMAND is a number, then it was specified in relative terms. If it
is a string, then it is the start of a command line present in HLIST. */
is a string, then it is the start of a command line present in HLIST.
MODE includes HN_LISTING if we are listing commands, and does not if we
are executing them. If MODE includes HN_FIRST we are looking for the
first history number specification. */
static int
fc_gethnum (command, hlist)
fc_gethnum (command, hlist, mode)
char *command;
HIST_ENTRY **hlist;
int mode;
{
int sign, n, clen, rh;
register int i, j, last_hist, real_last;
register int i, j, last_hist, real_last, listing;
register char *s;
listing = mode & HN_LISTING;
sign = 1;
/* Count history elements. */
for (i = 0; hlist[i]; i++);
@@ -550,19 +608,33 @@ fc_gethnum (command, hlist)
n = atoi (s);
n *= sign;
/* We want to return something that is an offset to HISTORY_BASE. */
/* If the value is negative or zero, then it is an offset from
the current history item. */
/* We don't use HN_FIRST here, so we don't return different values
depending on whether we're looking for the first or last in a
pair of range arguments, but nobody else does, either. */
if (n < 0)
{
n += i + 1;
return (n < 0 ? 0 : n);
}
else if (n == 0)
return ((sign == -1) ? real_last : i);
return ((sign == -1) ? (listing ? real_last : HIST_INVALID) : i);
else
{
/* If we're out of range (greater than I (last history entry) or
less than HISTORY_BASE, we want to return different values
based on whether or not we are looking for the first or last
value in a desired range of history entries. */
n -= history_base;
return (i < n ? i : n);
if (n < 0)
return (mode & HN_FIRST ? 0 : i);
else if (n >= i)
return (mode & HN_FIRST ? 0 : i);
else
return n;
}
}
@@ -572,22 +644,24 @@ fc_gethnum (command, hlist)
if (STREQN (command, histline (j), clen))
return (j);
}
return (-1);
return (HIST_NOTFOUND);
}
/* Locate the most recent history line which begins with
COMMAND in HLIST, and return a malloc()'ed copy of it. */
COMMAND in HLIST, and return a malloc()'ed copy of it.
MODE is 1 if we are listing commands, 0 if we are executing them. */
static char *
fc_gethist (command, hlist)
fc_gethist (command, hlist, mode)
char *command;
HIST_ENTRY **hlist;
int mode;
{
int i;
if (hlist == 0)
return ((char *)NULL);
i = fc_gethnum (command, hlist);
i = fc_gethnum (command, hlist, mode);
if (i >= 0)
return (savestring (histline (i)));
+2 -2
View File
@@ -1,7 +1,7 @@
This file is fg_bg.def, from which is created fg_bg.c.
It implements the builtins "bg" and "fg" in Bash.
Copyright (C) 1987-2009 Free Software Foundation, Inc.
Copyright (C) 1987-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -52,7 +52,7 @@ $END
#include "bashgetopt.h"
#if defined (JOB_CONTROL)
static int fg_bg __P((WORD_LIST *, int));
static int fg_bg PARAMS((WORD_LIST *, int));
/* How to bring a job into the foreground. */
int
+3 -3
View File
@@ -1,6 +1,6 @@
/* gen-helpfiles - create files containing builtin help text */
/* Copyright (C) 2012 Free Software Foundation, Inc.
/* Copyright (C) 2012-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -98,11 +98,11 @@ char *helpfile_directory;
/* Forward declarations. */
int write_helpfiles __P((struct builtin *));
int write_helpfiles PARAMS((struct builtin *));
/* For each file mentioned on the command line, process it and
write the information to STRUCTFILE and EXTERNFILE, while
creating the production file if neccessary. */
creating the production file if necessary. */
int
main (argc, argv)
int argc;
+7 -7
View File
@@ -1,6 +1,6 @@
/* getopt.h - declarations for getopt. */
/* Copyright (C) 1989, 1990, 1991, 1992, 1993, 2008,2009 Free Software Foundation, Inc.
/* Copyright (C) 1989-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -59,7 +59,7 @@ extern int sh_optopt;
/* Set to 1 when an unrecognized option is encountered. */
extern int sh_badopt;
extern int sh_getopt __P((int, char *const *, const char *));
extern int sh_getopt PARAMS((int, char *const *, const char *));
typedef struct sh_getopt_state
{
@@ -71,12 +71,12 @@ typedef struct sh_getopt_state
int gs_flags;
} sh_getopt_state_t;
extern void sh_getopt_restore_state __P((char **));
extern void sh_getopt_restore_state PARAMS((char **));
extern sh_getopt_state_t *sh_getopt_alloc_istate __P((void));
extern void sh_getopt_dispose_istate __P((sh_getopt_state_t *));
extern sh_getopt_state_t *sh_getopt_alloc_istate PARAMS((void));
extern void sh_getopt_dispose_istate PARAMS((sh_getopt_state_t *));
extern sh_getopt_state_t *sh_getopt_save_istate __P((void));
extern void sh_getopt_restore_istate __P((sh_getopt_state_t *));
extern sh_getopt_state_t *sh_getopt_save_istate PARAMS((void));
extern void sh_getopt_restore_istate PARAMS((sh_getopt_state_t *));
#endif /* _SH_GETOPT_H */
+8 -11
View File
@@ -1,7 +1,7 @@
This file is getopts.def, from which is created getopts.c.
It implements the builtin "getopts" in Bash.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
Copyright (C) 1987-2019 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -22,7 +22,7 @@ $PRODUCES getopts.c
$BUILTIN getopts
$FUNCTION getopts_builtin
$SHORT_DOC getopts optstring name [arg]
$SHORT_DOC getopts optstring name [arg ...]
Parse option arguments.
Getopts is used by shell procedures to parse positional parameters
@@ -54,8 +54,8 @@ If the shell variable OPTERR has the value 0, getopts disables the
printing of error messages, even if the first character of
OPTSTRING is not a colon. OPTERR has the value 1 by default.
Getopts normally parses the positional parameters ($0 - $9), but if
more arguments are given, they are parsed instead.
Getopts normally parses the positional parameters, but if arguments
are supplied as ARG values, they are parsed instead.
Exit Status:
Returns success if an option is found; fails if the end of options is
@@ -86,9 +86,9 @@ $END
#define G_INVALID_OPT -2
#define G_ARG_MISSING -3
static int getopts_unbind_variable __P((char *));
static int getopts_bind_variable __P((char *, char *));
static int dogetopts __P((int, char **));
static int getopts_unbind_variable PARAMS((char *));
static int getopts_bind_variable PARAMS((char *, char *));
static int dogetopts PARAMS((int, char **));
/* getopts_reset is magic code for when OPTIND is reset. N is the
value that has just been assigned to OPTIND. */
@@ -212,10 +212,7 @@ dogetopts (argc, argv)
register WORD_LIST *words;
char **v;
for (i = 0; i < 10 && dollar_vars[i]; i++)
;
for (words = rest_of_args; words; words = words->next, i++)
;
i = number_of_args () + 1; /* +1 for $0 */
v = strvec_create (i + 1);
for (i = 0; i < 10 && dollar_vars[i]; i++)
v[i] = dollar_vars[i];
+10 -9
View File
@@ -1,7 +1,7 @@
This file is hash.def, from which is created hash.c.
It implements the builtin "hash" in Bash.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
Copyright (C) 1987-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -70,11 +70,11 @@ $END
extern int dot_found_in_search;
static int add_hashed_command __P((char *, int));
static int print_hash_info __P((BUCKET_CONTENTS *));
static int print_portable_hash_info __P((BUCKET_CONTENTS *));
static int print_hashed_commands __P((int));
static int list_hashed_filename_targets __P((WORD_LIST *, int));
static int add_hashed_command PARAMS((char *, int));
static int print_hash_info PARAMS((BUCKET_CONTENTS *));
static int print_portable_hash_info PARAMS((BUCKET_CONTENTS *));
static int print_hashed_commands PARAMS((int));
static int list_hashed_filename_targets PARAMS((WORD_LIST *, int));
/* Print statistics on the current state of hashed commands. If LIST is
not empty, then rehash (or hash in the first place) the specified
@@ -123,9 +123,9 @@ hash_builtin (list)
list = loptend;
/* hash -t requires at least one argument. */
if (list == 0 && list_targets)
if (list == 0 && (delete || list_targets))
{
sh_needarg ("-t");
sh_needarg (delete ? "-d" : "-t");
return (EXECUTION_FAILURE);
}
@@ -134,7 +134,8 @@ hash_builtin (list)
if (list == 0 && expunge_hash_table == 0)
{
opt = print_hashed_commands (list_portably);
if (opt == 0 && posixly_correct == 0)
if (opt == 0 && posixly_correct == 0 &&
(list_portably == 0 || shell_compatibility_level <= 50))
printf (_("%s: hash table empty\n"), this_command_name);
return (EXECUTION_SUCCESS);
+8 -8
View File
@@ -1,7 +1,7 @@
This file is help.def, from which is created help.c.
It implements the builtin "help" in Bash.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
Copyright (C) 1987-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -79,11 +79,11 @@ extern int errno;
extern const char * const bash_copyright;
extern const char * const bash_license;
static void show_builtin_command_help __P((void));
static int open_helpfile __P((char *));
static void show_desc __P((char *, int));
static void show_manpage __P((char *, int));
static void show_longdoc __P((int));
static void show_builtin_command_help PARAMS((void));
static int open_helpfile PARAMS((char *));
static void show_desc PARAMS((char *, int));
static void show_manpage PARAMS((char *, int));
static void show_longdoc PARAMS((int));
/* Print out a list of the known functions in the shell, and what they do.
If LIST is supplied, print out the list which matches for each pattern
@@ -128,11 +128,11 @@ help_builtin (list)
/* We should consider making `help bash' do something. */
if (glob_pattern_p (list->word->word))
if (glob_pattern_p (list->word->word) == 1)
{
printf ("%s", ngettext ("Shell commands matching keyword `", "Shell commands matching keywords `", (list->next ? 2 : 1)));
print_word_list (list, ", ");
printf ("'\n\n");
printf ("%s", _("'\n\n"));
}
for (match_found = 0, pattern = ""; list; list = list->next)
+15 -6
View File
@@ -1,7 +1,7 @@
This file is history.def, from which is created history.c.
It implements the builtin "history" in Bash.
Copyright (C) 1987-2018 Free Software Foundation, Inc.
Copyright (C) 1987-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -75,6 +75,7 @@ $END
#include "../bashintl.h"
#include "../shell.h"
#include "../flags.h"
#include "../parser.h"
#include "../bashhist.h"
#include <readline/history.h>
@@ -85,10 +86,10 @@ $END
extern int errno;
#endif
static char *histtime __P((HIST_ENTRY *, const char *));
static int display_history __P((WORD_LIST *));
static void push_history __P((WORD_LIST *));
static int expand_and_print_history __P((WORD_LIST *));
static char *histtime PARAMS((HIST_ENTRY *, const char *));
static int display_history PARAMS((WORD_LIST *));
static void push_history PARAMS((WORD_LIST *));
static int expand_and_print_history PARAMS((WORD_LIST *));
#define AFLAG 0x01
#define RFLAG 0x02
@@ -243,7 +244,7 @@ range_error:
}
opt = ind + history_base; /* compensate for opt - history_base below */
}
else if ((delete_offset < history_base) || (delete_offset > (history_base + history_length)))
else if ((delete_offset < history_base) || (delete_offset >= (history_base + history_length)))
{
sh_erange (delete_arg, _("history position"));
return (EXECUTION_FAILURE);
@@ -269,6 +270,14 @@ range_error:
filename = list ? list->word->word : get_string_value ("HISTFILE");
result = EXECUTION_SUCCESS;
#if defined (RESTRICTED_SHELL)
if (restricted && strchr (filename, '/'))
{
sh_restricted (filename);
return (EXECUTION_FAILURE);
}
#endif
if (flags & AFLAG) /* Append session's history to file. */
result = maybe_append_history (filename);
else if (flags & WFLAG) /* Write entire history. */
+3 -3
View File
@@ -1,7 +1,7 @@
This file is jobs.def, from which is created jobs.c.
It implements the builtins "jobs" and "disown" in Bash.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
Copyright (C) 1987-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -68,7 +68,7 @@ $END
#define JSTATE_RUNNING 0x1
#define JSTATE_STOPPED 0x2
static int execute_list_with_replacements __P((WORD_LIST *));
static int execute_list_with_replacements PARAMS((WORD_LIST *));
/* The `jobs' command. Prints outs a list of active jobs. If the
argument `-l' is given, then the process id's are printed also.
@@ -276,7 +276,7 @@ disown_builtin (list)
{
BLOCK_CHILD (set, oset);
job = (list && legal_number (list->word->word, &pid_value) && pid_value == (pid_t) pid_value)
? get_job_by_pid ((pid_t) pid_value, 0)
? get_job_by_pid ((pid_t) pid_value, 0, 0)
: get_job_spec (list);
if (job == NO_JOB || jobs == 0 || INVALID_JOB (job))
+2 -2
View File
@@ -1,7 +1,7 @@
This file is kill.def, from which is created kill.c.
It implements the builtin "kill" in Bash.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
Copyright (C) 1987-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -70,7 +70,7 @@ $END
extern int errno;
#endif /* !errno */
static void kill_error __P((pid_t, int));
static void kill_error PARAMS((pid_t, int));
#if !defined (CONTINUE_AFTER_KILL_ERROR)
# define CONTINUE_OR_FAIL return (EXECUTION_FAILURE)
+2 -2
View File
@@ -2,7 +2,7 @@ This file is mapfile.def, from which is created mapfile.c.
It implements the builtin "mapfile" in Bash.
Copyright (C) 2005-2006 Rocky Bernstein for Free Software Foundation, Inc.
Copyright (C) 2008-2016 Free Software Foundation, Inc.
Copyright (C) 2008-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -91,7 +91,7 @@ extern int errno;
#if defined (ARRAY_VARS)
static int run_callback __P((const char *, unsigned int, const char *));
static int run_callback PARAMS((const char *, unsigned int, const char *));
#define DEFAULT_ARRAY_NAME "MAPFILE"
#define DEFAULT_VARIABLE_NAME "MAPLINE" /* not used right now */
+11 -11
View File
@@ -1,7 +1,7 @@
/* mkbuiltins.c - Create builtins.c, builtext.h, and builtdoc.c from
a single source file called builtins.def. */
/* Copyright (C) 1987-2016 Free Software Foundation, Inc.
/* Copyright (C) 1987-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -439,7 +439,7 @@ array_free (array)
/* The definition of a function. */
typedef int Function ();
typedef int mk_handler_func_t __P((char *, DEF_FILE *, char *));
typedef int mk_handler_func_t PARAMS((char *, DEF_FILE *, char *));
/* Structure handles processor directives. */
typedef struct {
@@ -447,14 +447,14 @@ typedef struct {
mk_handler_func_t *function;
} HANDLER_ENTRY;
extern int builtin_handler __P((char *, DEF_FILE *, char *));
extern int function_handler __P((char *, DEF_FILE *, char *));
extern int short_doc_handler __P((char *, DEF_FILE *, char *));
extern int comment_handler __P((char *, DEF_FILE *, char *));
extern int depends_on_handler __P((char *, DEF_FILE *, char *));
extern int produces_handler __P((char *, DEF_FILE *, char *));
extern int end_handler __P((char *, DEF_FILE *, char *));
extern int docname_handler __P((char *, DEF_FILE *, char *));
extern int builtin_handler PARAMS((char *, DEF_FILE *, char *));
extern int function_handler PARAMS((char *, DEF_FILE *, char *));
extern int short_doc_handler PARAMS((char *, DEF_FILE *, char *));
extern int comment_handler PARAMS((char *, DEF_FILE *, char *));
extern int depends_on_handler PARAMS((char *, DEF_FILE *, char *));
extern int produces_handler PARAMS((char *, DEF_FILE *, char *));
extern int end_handler PARAMS((char *, DEF_FILE *, char *));
extern int docname_handler PARAMS((char *, DEF_FILE *, char *));
HANDLER_ENTRY handlers[] = {
{ "BUILTIN", builtin_handler },
@@ -1233,7 +1233,7 @@ write_builtins (defs, structfile, externfile)
if (externfile)
{
if (builtin->function)
fprintf (externfile, "extern int %s __P((WORD_LIST *));\n",
fprintf (externfile, "extern int %s PARAMS((WORD_LIST *));\n",
builtin->function);
fprintf (externfile, "extern char * const %s_doc[];\n",
+21 -45
View File
@@ -1,7 +1,7 @@
This file is printf.def, from which is created printf.c.
It implements the builtin "printf" in Bash.
Copyright (C) 1997-2017 Free Software Foundation, Inc.
Copyright (C) 1997-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -149,7 +149,7 @@ extern int errno;
if (vflag) \
{ \
SHELL_VAR *v; \
v = bind_printf_variable (vname, vbuf, 0); \
v = builtin_bind_variable (vname, vbuf, 0); \
stupidly_hack_special_variables (vname); \
if (v == 0 || readonly_p (v) || noassign_p (v)) \
return (EXECUTION_FAILURE); \
@@ -187,26 +187,25 @@ extern int errno;
extern time_t shell_start_time;
#if !HAVE_ASPRINTF
extern int asprintf __P((char **, const char *, ...)) __attribute__((__format__ (printf, 2, 3)));
extern int asprintf PARAMS((char **, const char *, ...)) __attribute__((__format__ (printf, 2, 3)));
#endif
#if !HAVE_VSNPRINTF
extern int vsnprintf __P((char *, size_t, const char *, va_list)) __attribute__((__format__ (printf, 3, 0)));
extern int vsnprintf PARAMS((char *, size_t, const char *, va_list)) __attribute__((__format__ (printf, 3, 0)));
#endif
static void printf_erange __P((char *));
static int printstr __P((char *, char *, int, int, int));
static int tescape __P((char *, char *, int *, int *));
static char *bexpand __P((char *, int, int *, int *));
static char *vbadd __P((char *, int));
static int vbprintf __P((const char *, ...)) __attribute__((__format__ (printf, 1, 2)));
static char *mklong __P((char *, char *, size_t));
static int getchr __P((void));
static char *getstr __P((void));
static int getint __P((void));
static intmax_t getintmax __P((void));
static uintmax_t getuintmax __P((void));
static SHELL_VAR *bind_printf_variable __P((char *, char *, int));
static void printf_erange PARAMS((char *));
static int printstr PARAMS((char *, char *, int, int, int));
static int tescape PARAMS((char *, char *, int *, int *));
static char *bexpand PARAMS((char *, int, int *, int *));
static char *vbadd PARAMS((char *, int));
static int vbprintf PARAMS((const char *, ...)) __attribute__((__format__ (printf, 1, 2)));
static char *mklong PARAMS((char *, char *, size_t));
static int getchr PARAMS((void));
static char *getstr PARAMS((void));
static int getint PARAMS((void));
static intmax_t getintmax PARAMS((void));
static uintmax_t getuintmax PARAMS((void));
#if defined (HAVE_LONG_DOUBLE) && HAVE_DECL_STRTOLD && !defined(STRTOLD_BROKEN)
typedef long double floatmax_t;
@@ -217,11 +216,11 @@ typedef double floatmax_t;
# define FLOATMAX_CONV ""
# define strtofltmax strtod
#endif
static floatmax_t getfloatmax __P((void));
static floatmax_t getfloatmax PARAMS((void));
static intmax_t asciicode __P((void));
static intmax_t asciicode PARAMS((void));
static WORD_LIST *garglist;
static WORD_LIST *garglist, *orig_arglist;
static int retval;
static int conversion_error;
@@ -301,7 +300,7 @@ printf_builtin (list)
if (vflag && list->word->word && list->word->word[0] == '\0')
{
SHELL_VAR *v;
v = bind_printf_variable (vname, "", 0);
v = builtin_bind_variable (vname, "", 0);
stupidly_hack_special_variables (vname);
return ((v == 0 || readonly_p (v) || noassign_p (v)) ? EXECUTION_FAILURE : EXECUTION_SUCCESS);
}
@@ -312,7 +311,7 @@ printf_builtin (list)
format = list->word->word;
tw = 0;
garglist = list->next;
garglist = orig_arglist = list->next;
/* If the format string is empty after preprocessing, return immediately. */
if (format == 0 || *format == 0)
@@ -1271,26 +1270,3 @@ asciicode ()
garglist = garglist->next;
return (ch);
}
static SHELL_VAR *
bind_printf_variable (name, value, flags)
char *name;
char *value;
int flags;
{
SHELL_VAR *v;
#if defined (ARRAY_VARS)
if (valid_array_reference (name, assoc_expand_once ? (VA_NOEXPAND|VA_ONEWORD) : 0) == 0)
v = bind_variable (name, value, flags);
else
v = assign_array_element (name, value, flags | (assoc_expand_once ? ASS_NOEXPAND : 0));
#else /* !ARRAY_VARS */
v = bind_variable (name, value, flags);
#endif /* !ARRAY_VARS */
if (v && readonly_p (v) == 0 && noassign_p (v) == 0)
VUNSETATTR (v, att_invisible);
return v;
}
+7 -7
View File
@@ -1,7 +1,7 @@
This file is pushd.def, from which is created pushd.c. It implements the
builtins "pushd", "popd", and "dirs" in Bash.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
Copyright (C) 1987-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -157,12 +157,12 @@ static int directory_list_size;
/* Offset to the end of the list. */
static int directory_list_offset;
static void pushd_error __P((int, char *));
static void clear_directory_stack __P((void));
static int cd_to_string __P((char *));
static int change_to_temp __P((char *));
static void add_dirstack_element __P((char *));
static int get_dirstack_index __P((intmax_t, int, int *));
static void pushd_error PARAMS((int, char *));
static void clear_directory_stack PARAMS((void));
static int cd_to_string PARAMS((char *));
static int change_to_temp PARAMS((char *));
static void add_dirstack_element PARAMS((char *));
static int get_dirstack_index PARAMS((intmax_t, int, int *));
#define NOCD 0x01
#define ROTATE 0x02
+47 -25
View File
@@ -1,7 +1,7 @@
This file is read.def, from which is created read.c.
It implements the builtin "read" in Bash.
Copyright (C) 1987-2017 Free Software Foundation, Inc.
Copyright (C) 1987-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -119,20 +119,20 @@ struct ttsave
};
#if defined (READLINE)
static void reset_attempted_completion_function __P((char *));
static int set_itext __P((void));
static char *edit_line __P((char *, char *));
static void set_eol_delim __P((int));
static void reset_eol_delim __P((char *));
static void reset_attempted_completion_function PARAMS((char *));
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 *));
#endif
static SHELL_VAR *bind_read_variable __P((char *, char *));
static SHELL_VAR *bind_read_variable PARAMS((char *, char *));
#if defined (HANDLE_MULTIBYTE)
static int read_mbchar __P((int, char *, int, int, int));
static int read_mbchar PARAMS((int, char *, int, int, int));
#endif
static void ttyrestore __P((struct ttsave *));
static void ttyrestore PARAMS((struct ttsave *));
static sighandler sigalrm __P((int));
static void reset_alarm __P((void));
static sighandler sigalrm PARAMS((int));
static void reset_alarm PARAMS((void));
/* Try this to see what the rest of the shell can do with the information. */
procenv_t alrmbuf;
@@ -198,6 +198,7 @@ read_builtin (list)
#if defined (READLINE)
char *rlbuf, *itext;
int rlind;
FILE *save_instream;
#endif
USE_VAR(size);
@@ -273,7 +274,7 @@ read_builtin (list)
break;
#endif
case 't':
code = uconvert (list_optarg, &ival, &uval);
code = uconvert (list_optarg, &ival, &uval, (char **)NULL);
if (code == 0 || ival < 0 || uval < 0)
{
builtin_error (_("%s: invalid timeout specification"), list_optarg);
@@ -376,7 +377,7 @@ read_builtin (list)
/* $TMOUT, if set, is the default timeout for read. */
if (have_timeout == 0 && (e = get_string_value ("TMOUT")))
{
code = uconvert (e, &ival, &uval);
code = uconvert (e, &ival, &uval, (char **)NULL);
if (code == 0 || ival < 0 || uval < 0)
tmsec = tmusec = 0;
else
@@ -527,6 +528,19 @@ read_builtin (list)
initialize_terminating_signals ();
}
#if defined (READLINE)
save_instream = 0;
if (edit && fd != 0)
{
if (bash_readline_initialized == 0)
initialize_readline ();
unwind_protect_var (rl_instream);
save_instream = rl_instream;
rl_instream = fdopen (fd, "r");
}
#endif
/* This *must* be the top unwind-protect on the stack, so the manipulation
of the unwind-protect stack after the realloc() works right. */
add_unwind_protect (xfree, input_string);
@@ -555,7 +569,8 @@ read_builtin (list)
#if defined (READLINE)
if (edit)
{
if (rlbuf && rlbuf[rlind] == '\0')
/* If we have a null delimiter, don't treat NULL as ending the line */
if (rlbuf && rlbuf[rlind] == '\0' && delim != '\0')
{
free (rlbuf);
rlbuf = (char *)0;
@@ -589,6 +604,7 @@ read_builtin (list)
reading = 1;
CHECK_ALRM;
errno = 0;
if (unbuffered_read == 2)
retval = posixly_correct ? zreadintr (fd, &c, 1) : zreadn (fd, &c, nchars - nr);
else if (unbuffered_read)
@@ -599,13 +615,18 @@ read_builtin (list)
if (retval <= 0)
{
int t;
t = errno;
if (retval < 0 && errno == EINTR)
{
check_signals (); /* in case we didn't call zread via zreadc */
lastsig = LASTSIG();
if (lastsig == 0)
lastsig = trapped_signal_received;
#if 0
run_pending_traps (); /* because interrupt_immediately is not set */
#endif
}
else
lastsig = 0;
@@ -613,6 +634,7 @@ read_builtin (list)
ttyrestore (&termsave); /* fix terminal before exiting */
CHECK_TERMSIG;
eof = 1;
errno = t; /* preserve it for the error message below */
break;
}
@@ -759,6 +781,11 @@ add_char:
if (unbuffered_read == 0)
zsyncfd (fd);
#if defined (READLINE)
if (save_instream)
rl_instream = save_instream; /* can't portably free it */
#endif
discard_unwind_frame ("read_builtin");
retval = eof ? EXECUTION_FAILURE : EXECUTION_SUCCESS;
@@ -966,14 +993,7 @@ bind_read_variable (name, value)
{
SHELL_VAR *v;
#if defined (ARRAY_VARS)
if (valid_array_reference (name, assoc_expand_once ? (VA_NOEXPAND|VA_ONEWORD) : 0) == 0)
v = bind_variable (name, value, 0);
else
v = assign_array_element (name, value, assoc_expand_once ? ASS_NOEXPAND : 0);
#else /* !ARRAY_VARS */
v = bind_variable (name, value, 0);
#endif /* !ARRAY_VARS */
v = builtin_bind_variable (name, value, 0);
return (v == 0 ? v
: ((readonly_p (v) || noassign_p (v)) ? (SHELL_VAR *)NULL : v));
}
@@ -1136,15 +1156,17 @@ set_eol_delim (c)
initialize_readline ();
cmap = rl_get_keymap ();
/* Change newline to self-insert */
/* Save the old delimiter char binding */
old_newline_ctype = cmap[RETURN].type;
old_newline_func = cmap[RETURN].function;
old_delim_ctype = cmap[c].type;
old_delim_func = cmap[c].function;
/* Change newline to self-insert */
cmap[RETURN].type = ISFUNC;
cmap[RETURN].function = rl_insert;
/* Bind the delimiter character to accept-line. */
old_delim_ctype = cmap[c].type;
old_delim_func = cmap[c].function;
cmap[c].type = ISFUNC;
cmap[c].function = rl_newline;
+2 -2
View File
@@ -2,7 +2,7 @@ This file is reserved.def, in which the shell reserved words are defined.
It has no direct C file production, but defines builtins for the Bash
builtin help command.
Copyright (C) 1987-2009 Free Software Foundation, Inc.
Copyright (C) 1987-2019 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -194,7 +194,7 @@ $SHORT_DOC (( expression ))
Evaluate arithmetic expression.
The EXPRESSION is evaluated according to the rules for arithmetic
evaluation. Equivalent to "let EXPRESSION".
evaluation. Equivalent to `let "EXPRESSION"'.
Exit Status:
Returns 1 if EXPRESSION evaluates to 0; returns 0 otherwise.
+1 -1
View File
@@ -66,6 +66,6 @@ return_builtin (list)
else
{
builtin_error (_("can only `return' from a function or sourced script"));
return (EXECUTION_FAILURE);
return (EX_USAGE);
}
}
+46 -18
View File
@@ -1,7 +1,7 @@
This file is set.def, from which is created set.c.
It implements the "set" and "unset" builtins in Bash.
Copyright (C) 1987-2018 Free Software Foundation, Inc.
Copyright (C) 1987-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -151,24 +151,24 @@ Exit Status:
Returns success unless an invalid option is given.
$END
typedef int setopt_set_func_t __P((int, char *));
typedef int setopt_get_func_t __P((char *));
typedef int setopt_set_func_t PARAMS((int, char *));
typedef int setopt_get_func_t PARAMS((char *));
static int find_minus_o_option __P((char *));
static int find_minus_o_option PARAMS((char *));
static void print_minus_o_option __P((char *, int, int));
static void print_all_shell_variables __P((void));
static void print_minus_o_option PARAMS((char *, int, int));
static void print_all_shell_variables PARAMS((void));
static int set_ignoreeof __P((int, char *));
static int set_posix_mode __P((int, char *));
static int set_ignoreeof PARAMS((int, char *));
static int set_posix_mode PARAMS((int, char *));
#if defined (READLINE)
static int set_edit_mode __P((int, char *));
static int get_edit_mode __P((char *));
static int set_edit_mode PARAMS((int, char *));
static int get_edit_mode PARAMS((char *));
#endif
#if defined (HISTORY)
static int bash_set_history __P((int, char *));
static int bash_set_history PARAMS((int, char *));
#endif
static const char * const on = "on";
@@ -358,17 +358,29 @@ void
set_current_options (bitmap)
const char *bitmap;
{
int i;
int i, v, cv, *on_or_off;
if (bitmap == 0)
return;
for (i = 0; o_options[i].name; i++)
{
v = bitmap[i] ? FLAG_ON : FLAG_OFF;
if (o_options[i].letter)
change_flag (o_options[i].letter, bitmap[i] ? FLAG_ON : FLAG_OFF);
{
/* We should not get FLAG_UNKNOWN here */
on_or_off = find_flag (o_options[i].letter);
cv = *on_or_off ? FLAG_ON : FLAG_OFF;
if (v != cv)
change_flag (o_options[i].letter, v);
}
else
SET_BINARY_O_OPTION_VALUE (i, bitmap[i] ? FLAG_ON : FLAG_OFF, o_options[i].name);
{
cv = GET_BINARY_O_OPTION_VALUE (i, o_options[i].name);
cv = cv ? FLAG_ON : FLAG_OFF;
if (v != cv)
SET_BINARY_O_OPTION_VALUE (i, v, o_options[i].name);
}
}
/* Now reset the variables changed by posix mode */
@@ -395,6 +407,11 @@ set_posix_mode (on_or_off, option_name)
int on_or_off;
char *option_name;
{
/* short-circuit on no-op */
if ((on_or_off == FLAG_ON && posixly_correct) ||
(on_or_off == FLAG_OFF && posixly_correct == 0))
return 0;
posixly_correct = on_or_off == FLAG_ON;
if (posixly_correct == 0)
unbind_variable_noref ("POSIXLY_CORRECT");
@@ -646,7 +663,7 @@ reset_shell_options ()
#endif
#if defined (HISTORY)
dont_save_function_defs = 0;
remember_on_history = enable_history_list = 1;
remember_on_history = enable_history_list = 1; /* XXX */
#endif
}
@@ -818,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;
int global_unset_func, global_unset_var, vflags, valid_id;
char *name, *tname;
unset_function = unset_variable = unset_array = nameref = any_failed = 0;
@@ -884,17 +901,28 @@ unset_builtin (list)
#endif
/* Get error checking out of the way first. The low-level functions
just perform the unset, relying on the caller to verify. */
valid_id = legal_identifier (name);
/* Whether or not we are in posix mode, if neither -f nor -v appears,
skip over trying to unset variables with invalid names and just
treat them as potential shell function names. */
if (global_unset_func == 0 && global_unset_var == 0 && valid_id == 0)
{
unset_variable = unset_array = 0;
unset_function = 1;
}
/* Bash allows functions with names which are not valid identifiers
to be created when not in posix mode, so check only when in posix
mode when unsetting a function. */
if (((unset_function && posixly_correct) || !unset_function) && legal_identifier (name) == 0)
if (unset_function == 0 && valid_id == 0)
{
sh_invalidid (name);
NEXT_VARIABLE ();
}
/* Only search for functions here if -f supplied. */
/* Search for functions here if -f supplied or if NAME cannot be a
variable name. */
var = unset_function ? find_function (name)
: (nameref ? find_variable_last_nameref (name, 0) : find_variable (name));
+46 -8
View File
@@ -1,7 +1,7 @@
This file is setattr.def, from which is created setattr.c.
It implements the builtins "export" and "readonly", in Bash.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
Copyright (C) 1987-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -42,7 +42,7 @@ $PRODUCES setattr.c
extern sh_builtin_func_t *this_shell_builtin;
#ifdef ARRAY_VARS
extern int declare_builtin __P((WORD_LIST *));
extern int declare_builtin PARAMS((WORD_LIST *));
#endif
#define READONLY_OR_EXPORT \
@@ -371,6 +371,30 @@ show_all_var_attributes (v, nodefs)
return (any_failed == 0 ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
}
/* Show all local variable variables with their attributes. This shows unset
local variables (all_local_variables called with 0 argment). */
int
show_local_var_attributes (v, nodefs)
int v, nodefs;
{
SHELL_VAR **variable_list, *var;
int any_failed;
register int i;
variable_list = all_local_variables (0);
if (variable_list == 0)
return (EXECUTION_SUCCESS);
for (i = any_failed = 0; var = variable_list[i]; i++)
{
show_var_attributes (var, READONLY_OR_EXPORT, nodefs);
if (any_failed = sh_chkwrite (any_failed))
break;
}
free (variable_list);
return (any_failed == 0 ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
}
int
var_attribute_string (var, pattr, flags)
SHELL_VAR *var;
@@ -504,13 +528,27 @@ show_name_attributes (name, nodefs)
{
SHELL_VAR *var;
#if 0
var = find_variable_tempenv (name);
#else
var = find_variable_noref (name);
#endif
if (var /* && invisible_p (var) == 0 */)
if (var) /* show every variable with attributes, even unset ones */
{
show_var_attributes (var, READONLY_OR_EXPORT, nodefs);
return (0);
}
else
return (1);
}
int
show_localname_attributes (name, nodefs)
char *name;
int nodefs;
{
SHELL_VAR *var;
var = find_variable_noref (name);
if (var && local_p (var) && var->context == variable_context) /* show every variable with attributes, even unset ones */
{
show_var_attributes (var, READONLY_OR_EXPORT, nodefs);
return (0);
@@ -607,7 +645,7 @@ set_var_attribute (name, attribute, undo)
if (var == 0)
{
var = bind_variable (name, (char *)NULL, 0);
if (var && no_invisible_vars == 0)
if (var)
VSETATTR (var, att_invisible);
}
else if (var->context != 0)
+8 -24
View File
@@ -1,7 +1,7 @@
This file is shift.def, from which is created shift.c.
It implements the builtin "shift" in Bash.
Copyright (C) 1987-2009 Free Software Foundation, Inc.
Copyright (C) 1987-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -58,8 +58,7 @@ shift_builtin (list)
WORD_LIST *list;
{
intmax_t times;
register int count;
WORD_LIST *temp;
int itimes, nargs;
CHECK_HELPOPT (list);
@@ -73,32 +72,17 @@ shift_builtin (list)
sh_erange (list ? list->word->word : NULL, _("shift count"));
return (EXECUTION_FAILURE);
}
else if (times > number_of_args ())
nargs = number_of_args ();
if (times > nargs)
{
if (print_shift_error)
sh_erange (list ? list->word->word : NULL, _("shift count"));
return (EXECUTION_FAILURE);
}
while (times-- > 0)
{
if (dollar_vars[1])
free (dollar_vars[1]);
for (count = 1; count < 9; count++)
dollar_vars[count] = dollar_vars[count + 1];
if (rest_of_args)
{
temp = rest_of_args;
dollar_vars[9] = savestring (temp->word->word);
rest_of_args = rest_of_args->next;
temp->next = (WORD_LIST *)NULL;
dispose_words (temp);
}
else
dollar_vars[9] = (char *)NULL;
}
else if (times == nargs)
clear_dollar_vars ();
else
shift_args (itimes = times);
invalidate_cached_quoted_dollar_at ();
+26 -18
View File
@@ -1,7 +1,7 @@
This file is shopt.def, from which is created shopt.c.
It implements the Bash `shopt' builtin.
Copyright (C) 1994-2018 Free Software Foundation, Inc.
Copyright (C) 1994-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -105,7 +105,7 @@ extern int force_fignore;
extern int dircomplete_spelling, dircomplete_expand;
extern int complete_fullquote;
extern int enable_hostname_completion __P((int));
extern int enable_hostname_completion PARAMS((int));
#endif
#if defined (PROGRAMMABLE_COMPLETION)
@@ -126,21 +126,21 @@ extern int array_expand_once;
extern int syslog_history;
#endif
static void shopt_error __P((char *));
static void shopt_error PARAMS((char *));
static int set_shellopts_after_change __P((char *, int));
static int set_compatibility_level __P((char *, int));
static int set_shellopts_after_change PARAMS((char *, int));
static int set_compatibility_level PARAMS((char *, int));
#if defined (RESTRICTED_SHELL)
static int set_restricted_shell __P((char *, int));
static int set_restricted_shell PARAMS((char *, int));
#endif
#if defined (READLINE)
static int shopt_enable_hostname_completion __P((char *, int));
static int shopt_set_complete_direxpand __P((char *, int));
static int shopt_enable_hostname_completion PARAMS((char *, int));
static int shopt_set_complete_direxpand PARAMS((char *, int));
#endif
static int shopt_set_debug_mode __P((char *, int));
static int shopt_set_debug_mode PARAMS((char *, int));
static int shopt_login_shell;
static int shopt_compat31;
@@ -151,7 +151,7 @@ static int shopt_compat42;
static int shopt_compat43;
static int shopt_compat44;
typedef int shopt_set_func_t __P((char *, int));
typedef int shopt_set_func_t PARAMS((char *, int));
/* If you add a new variable name here, make sure to set the default value
appropriately in reset_shopt_options. */
@@ -255,14 +255,14 @@ static struct {
static const char * const on = "on";
static const char * const off = "off";
static int find_shopt __P((char *));
static int toggle_shopts __P((int, WORD_LIST *, int));
static void print_shopt __P((char *, int, int));
static int list_shopts __P((WORD_LIST *, int));
static int list_some_shopts __P((int, int));
static int list_shopt_o_options __P((WORD_LIST *, int));
static int list_some_o_options __P((int, int));
static int set_shopt_o_options __P((int, WORD_LIST *, int));
static int find_shopt PARAMS((char *));
static int toggle_shopts PARAMS((int, WORD_LIST *, int));
static void print_shopt PARAMS((char *, int, int));
static int list_shopts PARAMS((WORD_LIST *, int));
static int list_some_shopts PARAMS((int, int));
static int list_shopt_o_options PARAMS((WORD_LIST *, int));
static int list_some_o_options PARAMS((int, int));
static int set_shopt_o_options PARAMS((int, WORD_LIST *, int));
#define SFLAG 0x01
#define UFLAG 0x02
@@ -347,6 +347,7 @@ reset_shopt_options ()
inherit_errexit = 0;
interactive_comments = 1;
lastpipe_opt = 0;
localvar_inherit = localvar_unset = 0;
mail_warning = 0;
glob_ignore_case = match_ignore_case = 0;
print_shift_error = 0;
@@ -360,6 +361,10 @@ reset_shopt_options ()
extended_glob = EXTGLOB_DEFAULT;
#endif
#if defined (ARRAY_VARS)
assoc_expand_once = 0;
#endif
#if defined (HISTORY)
literal_history = 0;
force_append_history = 0;
@@ -390,6 +395,9 @@ reset_shopt_options ()
#if defined (PROGRAMMABLE_COMPLETION)
prog_completion_enabled = 1;
# if defined (ALIAS)
progcomp_alias = 0;
# endif
#endif
#if defined (DEFAULT_ECHO_TO_XPG) || defined (STRICT_POSIX)
+3 -3
View File
@@ -1,7 +1,7 @@
This file is source.def, from which is created source.c.
It implements the builtins "." and "source" in Bash.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
Copyright (C) 1987-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -80,7 +80,7 @@ $END
extern int errno;
#endif /* !errno */
static void maybe_pop_dollar_vars __P((void));
static void maybe_pop_dollar_vars PARAMS((void));
/* If non-zero, `.' uses $PATH to look up the script to be sourced. */
int source_uses_path = 1;
@@ -156,7 +156,7 @@ source_builtin (list)
free (x);
if (posixly_correct && interactive_shell == 0 && executing_command_builtin == 0)
{
last_command_exit_value = 1;
last_command_exit_value = EXECUTION_FAILURE;
jump_to_top_level (EXITPROG);
}
return (EXECUTION_FAILURE);
+2 -2
View File
@@ -1,7 +1,7 @@
This file is suspend.def, from which is created suspend.c.
It implements the builtin "suspend" in Bash.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
Copyright (C) 1987-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -54,7 +54,7 @@ $END
#include "common.h"
#include "bashgetopt.h"
static sighandler suspend_continue __P((int));
static sighandler suspend_continue PARAMS((int));
static SigHandler *old_cont;
#if 0
+19 -12
View File
@@ -1,7 +1,7 @@
This file is trap.def, from which is created trap.c.
It implements the builtin "trap" in Bash.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
Copyright (C) 1987-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -75,8 +75,8 @@ $END
#include "common.h"
#include "bashgetopt.h"
static void showtrap __P((int));
static int display_traps __P((WORD_LIST *));
static void showtrap PARAMS((int, int));
static int display_traps PARAMS((WORD_LIST *, int));
/* The trap command:
@@ -133,7 +133,7 @@ trap_builtin (list)
{
initialize_terminating_signals ();
get_all_original_signals ();
return (sh_chkwrite (display_traps (list)));
return (sh_chkwrite (display_traps (list, display && posixly_correct)));
}
else
{
@@ -211,7 +211,7 @@ trap_builtin (list)
if (interactive)
set_signal_handler (SIGINT, sigint_sighandler);
/* special cases for interactive == 0 */
else if (interactive_shell && (sourcelevel||running_trap))
else if (interactive_shell && (sourcelevel||running_trap||parse_and_execute_level))
set_signal_handler (SIGINT, sigint_sighandler);
else
set_signal_handler (SIGINT, termsig_sighandler);
@@ -246,14 +246,19 @@ trap_builtin (list)
}
static void
showtrap (i)
int i;
showtrap (i, show_default)
int i, show_default;
{
char *t, *p, *sn;
p = trap_list[i];
if (p == (char *)DEFAULT_SIG && signal_is_hard_ignored (i) == 0)
return;
{
if (show_default)
t = "-";
else
return;
}
else if (signal_is_hard_ignored (i))
t = (char *)NULL;
else
@@ -274,19 +279,21 @@ showtrap (i)
else
printf ("trap -- %s %s\n", t ? t : "''", sn);
FREE (t);
if (show_default == 0)
FREE (t);
}
static int
display_traps (list)
display_traps (list, show_all)
WORD_LIST *list;
int show_all;
{
int result, i;
if (list == 0)
{
for (i = 0; i < BASH_NSIG; i++)
showtrap (i);
showtrap (i, show_all);
return (EXECUTION_SUCCESS);
}
@@ -299,7 +306,7 @@ display_traps (list)
result = EXECUTION_FAILURE;
}
else
showtrap (i);
showtrap (i, show_all);
}
return (result);
+2 -2
View File
@@ -1,7 +1,7 @@
This file is type.def, from which is created type.c.
It implements the builtin "type" in Bash.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
Copyright (C) 1987-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -76,7 +76,7 @@ $END
#include "common.h"
#include "bashgetopt.h"
extern int find_reserved_word __P((char *));
extern int find_reserved_word PARAMS((char *));
/* For each word in LIST, find out what the shell is going to do with
it as a simple command. i.e., which file would this shell use to
+18 -14
View File
@@ -1,7 +1,7 @@
This file is ulimit.def, from which is created ulimit.c.
It implements the builtin "ulimit" in Bash.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
Copyright (C) 1987-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -52,6 +52,7 @@ Options:
-v the size of virtual memory
-x the maximum number of file locks
-P the maximum number of pseudoterminals
-R the maximum time a real-time process can run before blocking
-T the maximum number of threads
Not all options are available on all platforms.
@@ -203,22 +204,22 @@ extern int errno;
#define BLOCKSIZE(x) (((x) == POSIXBLK) ? (posixly_correct ? 512 : 1024) : (x))
static int _findlim __P((int));
static int _findlim PARAMS((int));
static int ulimit_internal __P((int, char *, int, int));
static int ulimit_internal PARAMS((int, char *, int, int));
static int get_limit __P((int, RLIMTYPE *, RLIMTYPE *));
static int set_limit __P((int, RLIMTYPE, int));
static int get_limit PARAMS((int, RLIMTYPE *, RLIMTYPE *));
static int set_limit PARAMS((int, RLIMTYPE, int));
static void printone __P((int, RLIMTYPE, int));
static void print_all_limits __P((int));
static void printone PARAMS((int, RLIMTYPE, int));
static void print_all_limits PARAMS((int));
static int set_all_limits __P((int, RLIMTYPE));
static int set_all_limits PARAMS((int, RLIMTYPE));
static int filesize __P((RLIMTYPE *));
static int pipesize __P((RLIMTYPE *));
static int getmaxuprc __P((RLIMTYPE *));
static int getmaxvm __P((RLIMTYPE *, RLIMTYPE *));
static int filesize PARAMS((RLIMTYPE *));
static int pipesize PARAMS((RLIMTYPE *));
static int getmaxuprc PARAMS((RLIMTYPE *));
static int getmaxvm PARAMS((RLIMTYPE *, RLIMTYPE *));
typedef struct {
int option; /* The ulimit option for this limit. */
@@ -232,8 +233,11 @@ static RESOURCE_LIMITS limits[] = {
#ifdef RLIMIT_NPTS
{ 'P', RLIMIT_NPTS, 1, "number of pseudoterminals", (char *)NULL },
#endif
#ifdef RLIMIT_RTTIME
{ 'R', RLIMIT_RTTIME, 1, "real-time non-blocking time", "microseconds" },
#endif
#ifdef RLIMIT_PTHREAD
{ 'T', RLIMIT_PTHREAD, 1, "number of threads", (char *)NULL },
{ 'T', RLIMIT_PTHREAD, 1, "number of threads", (char *)NULL },
#endif
#ifdef RLIMIT_SBSIZE
{ 'b', RLIMIT_SBSIZE, 1, "socket buffer size", "bytes" },
@@ -741,7 +745,7 @@ printone (limind, curlim, pdesc)
else
sprintf (unitstr, "(-%c) ", limits[limind].option);
printf ("%-20s %16s", limits[limind].description, unitstr);
printf ("%-20s %20s", limits[limind].description, unitstr);
}
if (curlim == RLIM_INFINITY)
puts ("unlimited");
+3 -3
View File
@@ -1,7 +1,7 @@
This file is umask.def, from which is created umask.c.
It implements the builtin "umask" in Bash.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
Copyright (C) 1987-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -67,8 +67,8 @@ $END
/* */
/* **************************************************************** */
static void print_symbolic_umask __P((mode_t));
static int symbolic_umask __P((WORD_LIST *));
static void print_symbolic_umask PARAMS((mode_t));
static int symbolic_umask PARAMS((WORD_LIST *));
/* Set or display the mask used by the system when creating files. Flag
of -S means display the umask in a symbolic mode. */
+148 -14
View File
@@ -1,7 +1,7 @@
This file is wait.def, from which is created wait.c.
It implements the builtin "wait" in Bash.
Copyright (C) 1987-2017 Free Software Foundation, Inc.
Copyright (C) 1987-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -22,7 +22,7 @@ $BUILTIN wait
$FUNCTION wait_builtin
$DEPENDS_ON JOB_CONTROL
$PRODUCES wait.c
$SHORT_DOC wait [-fn] [id ...]
$SHORT_DOC wait [-fn] [-p var] [id ...]
Wait for job completion and return exit status.
Waits for each process identified by an ID, which may be a process ID or a
@@ -31,15 +31,22 @@ given, waits for all currently active child processes, and the return
status is zero. If ID is a job specification, waits for all processes
in that job's pipeline.
If the -n option is supplied, waits for the next job to terminate and
returns its exit status.
If the -n option is supplied, waits for a single job from the list of IDs,
or, if no IDs are supplied, for the next job to complete and returns its
exit status.
If the -p option is supplied, the process or job identifier of the job
for which the exit status is returned is assigned to the variable VAR
named by the option argument. The variable will be unset initially, before
any assignment. This is useful only when the -n option is supplied.
If the -f option is supplied, and job control is enabled, waits for the
specified ID to terminate, instead of waiting for it to change status.
Exit Status:
Returns the status of the last ID; fails if ID is invalid or an invalid
option is given.
option is given, or if -n is supplied and the shell has no unwaited-for
children.
$END
$BUILTIN wait
@@ -73,6 +80,8 @@ $END
#include "../shell.h"
#include "../execute_cmd.h"
#include "../jobs.h"
#include "../trap.h"
#include "../sig.h"
#include "common.h"
#include "bashgetopt.h"
@@ -81,6 +90,9 @@ extern int wait_signal_received;
procenv_t wait_intr_buf;
int wait_intr_flag;
static int set_waitlist PARAMS((WORD_LIST *));
static void unset_waitlist PARAMS((void));
/* Wait for the pid in LIST to stop or die. If no arguments are given, then
wait for all of the active background processes of the shell and return
0. If a list of pids or job specs are given, return the exit status of
@@ -89,7 +101,6 @@ int wait_intr_flag;
#define WAIT_RETURN(s) \
do \
{ \
interrupt_immediately = old_interrupt_immediately;\
wait_signal_received = 0; \
wait_intr_flag = 0; \
return (s);\
@@ -101,13 +112,17 @@ wait_builtin (list)
WORD_LIST *list;
{
int status, code, opt, nflag, wflags;
volatile int old_interrupt_immediately;
char *vname;
SHELL_VAR *pidvar;
struct procstat pstat;
USE_VAR(list);
nflag = wflags = 0;
vname = NULL;
pidvar = (SHELL_VAR *)NULL;
reset_internal_getopt ();
while ((opt = internal_getopt (list, "nf")) != -1)
while ((opt = internal_getopt (list, "fnp:")) != -1)
{
switch (opt)
{
@@ -118,6 +133,9 @@ wait_builtin (list)
case 'f':
wflags |= JWAIT_FORCE;
break;
case 'p':
vname = list_optarg;
break;
#endif
CASE_HELPOPT;
default:
@@ -127,10 +145,24 @@ wait_builtin (list)
}
list = loptend;
old_interrupt_immediately = interrupt_immediately;
#if 0
interrupt_immediately++;
/* Sanity-check variable name if -p supplied. */
if (vname)
{
#if defined (ARRAY_VARS)
int arrayflags;
arrayflags = assoc_expand_once ? (VA_NOEXPAND|VA_ONEWORD) : 0;
if (legal_identifier (vname) == 0 && valid_array_reference (vname, arrayflags) == 0)
#else
if (legal_identifier (vname) == 0)
#endif
{
sh_invalidid (vname);
WAIT_RETURN (EXECUTION_FAILURE);
}
if (builtin_unbind_variable (vname) == -2)
WAIT_RETURN (EXECUTION_FAILURE);
}
/* POSIX.2 says: When the shell is waiting (by means of the wait utility)
for asynchronous commands to complete, the reception of a signal for
@@ -151,15 +183,43 @@ wait_builtin (list)
WAIT_RETURN (status);
}
opt = first_pending_trap ();
#if defined (SIGCHLD)
/* We special case SIGCHLD when not in posix mode because we don't break
out of the wait even when the signal is trapped; we run the trap after
the wait completes. See how it's handled in jobs.c:waitchld(). */
if (opt == SIGCHLD && posixly_correct == 0)
opt = next_pending_trap (opt+1);
#endif
if (opt != -1)
{
last_command_exit_signal = wait_signal_received = opt;
status = opt + 128;
WAIT_RETURN (status);
}
/* We support jobs or pids.
wait <pid-or-job> [pid-or-job ...] */
#if defined (JOB_CONTROL)
if (nflag)
{
status = wait_for_any_job (wflags);
if (list)
{
opt = set_waitlist (list);
if (opt == 0)
WAIT_RETURN (127);
wflags |= JWAIT_WAITING;
}
status = wait_for_any_job (wflags, &pstat);
if (status < 0)
status = 127;
if (vname && status >= 0)
bind_var_to_int (vname, pstat.pid);
if (list)
unset_waitlist ();
WAIT_RETURN (status);
}
#endif
@@ -168,7 +228,9 @@ wait_builtin (list)
currently active background processes. */
if (list == 0)
{
wait_for_background_pids ();
wait_for_background_pids (&pstat);
if (vname)
bind_var_to_int (vname, pstat.pid);
WAIT_RETURN (EXECUTION_SUCCESS);
}
@@ -186,10 +248,14 @@ wait_builtin (list)
{
pid = (pid_t)pid_value;
status = wait_for_single_pid (pid, wflags|JWAIT_PERROR);
pstat.pid = pid;
pstat.status = status;
}
else
{
sh_badpid (w);
pstat.pid = NO_PID;
pstat.status = 127;
WAIT_RETURN (EXECUTION_FAILURE);
}
}
@@ -209,22 +275,90 @@ wait_builtin (list)
sh_badjob (list->word->word);
UNBLOCK_CHILD (oset);
status = 127; /* As per Posix.2, section 4.70.2 */
pstat.pid = NO_PID;
pstat.status = status;
list = list->next;
continue;
}
/* Job spec used. Wait for the last pid in the pipeline. */
UNBLOCK_CHILD (oset);
status = wait_for_job (job, wflags);
status = wait_for_job (job, wflags, &pstat);
}
#endif /* JOB_CONTROL */
else
{
sh_badpid (w);
pstat.pid = NO_PID;
pstat.status = 127;
status = EXECUTION_FAILURE;
}
/* Don't waste time with a longjmp. */
if (wait_signal_received)
{
last_command_exit_signal = wait_signal_received;
status = 128 + wait_signal_received;
wait_sigint_cleanup ();
WAIT_RETURN (status);
}
list = list->next;
}
WAIT_RETURN (status);
}
#if defined (JOB_CONTROL)
/* Take each valid pid or jobspec in LIST and mark the corresponding job as
J_WAITING, so wait -n knows which jobs to wait for. Return the number of
jobs we found. */
static int
set_waitlist (list)
WORD_LIST *list;
{
sigset_t set, oset;
int job, r, njob;
intmax_t pid;
WORD_LIST *l;
BLOCK_CHILD (set, oset);
njob = 0;
for (l = list; l; l = l->next)
{
job = NO_JOB;
job = (l && legal_number (l->word->word, &pid) && pid == (pid_t) pid)
? get_job_by_pid ((pid_t) pid, 0, 0)
: get_job_spec (l);
if (job == NO_JOB || jobs == 0 || INVALID_JOB (job))
{
sh_badjob (l->word->word);
continue;
}
/* We don't check yet to see if one of the desired jobs has already
terminated, but we could. We wait until wait_for_any_job(). This
has the advantage of validating all the arguments. */
if ((jobs[job]->flags & J_WAITING) == 0)
{
njob++;
jobs[job]->flags |= J_WAITING;
}
}
UNBLOCK_CHILD (oset);
return (njob);
}
/* Clean up after a call to wait -n jobs */
static void
unset_waitlist ()
{
int i;
sigset_t set, oset;
BLOCK_CHILD (set, oset);
for (i = 0; i < js.j_jobslots; i++)
if (jobs[i] && (jobs[i]->flags & J_WAITING))
jobs[i]->flags &= ~J_WAITING;
UNBLOCK_CHILD (oset);
}
#endif
+41 -38
View File
@@ -1,7 +1,7 @@
/* command.h -- The structures used internally to represent commands, and
the extern declarations of the functions used to create them. */
/* Copyright (C) 1993-2016 Free Software Foundation, Inc.
/* Copyright (C) 1993-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -73,36 +73,37 @@ enum command_type { cm_for, cm_case, cm_while, cm_if, cm_simple, cm_select,
cm_arith, cm_cond, cm_arith_for, cm_subshell, cm_coproc };
/* Possible values for the `flags' field of a WORD_DESC. */
#define W_HASDOLLAR 0x000001 /* Dollar sign present. */
#define W_QUOTED 0x000002 /* Some form of quote character is present. */
#define W_ASSIGNMENT 0x000004 /* This word is a variable assignment. */
#define W_SPLITSPACE 0x000008 /* Split this word on " " regardless of IFS */
#define W_NOSPLIT 0x000010 /* Do not perform word splitting on this word because ifs is empty string. */
#define W_NOGLOB 0x000020 /* Do not perform globbing on this word. */
#define W_NOSPLIT2 0x000040 /* Don't split word except for $@ expansion (using spaces) because context does not allow it. */
#define W_TILDEEXP 0x000080 /* Tilde expand this assignment word */
#define W_DOLLARAT 0x000100 /* $@ and its special handling */
#define W_DOLLARSTAR 0x000200 /* $* and its special handling */
#define W_NOCOMSUB 0x000400 /* Don't perform command substitution on this word */
#define W_ASSIGNRHS 0x000800 /* Word is rhs of an assignment statement */
#define W_NOTILDE 0x001000 /* Don't perform tilde expansion on this word */
#define W_ITILDE 0x002000 /* Internal flag for word expansion */
#define W_NOEXPAND 0x004000 /* Don't expand at all -- do quote removal */
#define W_COMPASSIGN 0x008000 /* Compound assignment */
#define W_ASSNBLTIN 0x010000 /* word is a builtin command that takes assignments */
#define W_ASSIGNARG 0x020000 /* word is assignment argument to command */
#define W_HASQUOTEDNULL 0x040000 /* word contains a quoted null character */
#define W_DQUOTE 0x080000 /* word should be treated as if double-quoted */
#define W_NOPROCSUB 0x100000 /* don't perform process substitution */
#define W_SAWQUOTEDNULL 0x200000 /* word contained a quoted null that was removed */
#define W_ASSIGNASSOC 0x400000 /* word looks like associative array assignment */
#define W_ASSIGNARRAY 0x800000 /* word looks like a compound indexed array assignment */
#define W_ARRAYIND 0x1000000 /* word is an array index being expanded */
#define W_ASSNGLOBAL 0x2000000 /* word is a global assignment to declare (declare/typeset -g) */
#define W_NOBRACE 0x4000000 /* Don't perform brace expansion */
#define W_COMPLETE 0x8000000 /* word is being expanded for completion */
#define W_CHKLOCAL 0x10000000 /* check for local vars on assignment */
#define W_NOASSNTILDE 0x20000000 /* don't do tilde expansion like an assignment statement */
#define W_HASDOLLAR (1 << 0) /* Dollar sign present. */
#define W_QUOTED (1 << 1) /* Some form of quote character is present. */
#define W_ASSIGNMENT (1 << 2) /* This word is a variable assignment. */
#define W_SPLITSPACE (1 << 3) /* Split this word on " " regardless of IFS */
#define W_NOSPLIT (1 << 4) /* Do not perform word splitting on this word because ifs is empty string. */
#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_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_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_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 */
#define W_ASSIGNARRAY (1 << 23) /* word looks like a compound indexed array assignment */
#define W_ARRAYIND (1 << 24) /* word is an array index being expanded */
#define W_ASSNGLOBAL (1 << 25) /* word is a global assignment to declare (declare/typeset -g) */
#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 */
/* Flags for the `pflags' argument to param_expand() and various
parameter_brace_expand_xxx functions; also used for string_list_dollar_at */
@@ -111,6 +112,8 @@ enum command_type { cm_for, cm_case, cm_while, cm_if, cm_simple, cm_select,
#define PF_NOSPLIT2 0x04 /* same as W_NOSPLIT2 */
#define PF_ASSIGNRHS 0x08 /* same as W_ASSIGNRHS */
#define PF_COMPLETE 0x10 /* same as W_COMPLETE, sets SX_COMPLETE */
#define PF_EXPANDRHS 0x20 /* same as W_EXPANDRHS */
#define PF_ALLINDS 0x40 /* array, act as if [@] was supplied */
/* Possible values for subshell_environment */
#define SUBSHELL_ASYNC 0x01 /* subshell caused by `command &' */
@@ -393,13 +396,13 @@ extern Coproc sh_coproc;
/* Forward declarations of functions declared in copy_cmd.c. */
extern FUNCTION_DEF *copy_function_def_contents __P((FUNCTION_DEF *, FUNCTION_DEF *));
extern FUNCTION_DEF *copy_function_def __P((FUNCTION_DEF *));
extern FUNCTION_DEF *copy_function_def_contents PARAMS((FUNCTION_DEF *, FUNCTION_DEF *));
extern FUNCTION_DEF *copy_function_def PARAMS((FUNCTION_DEF *));
extern WORD_DESC *copy_word __P((WORD_DESC *));
extern WORD_LIST *copy_word_list __P((WORD_LIST *));
extern REDIRECT *copy_redirect __P((REDIRECT *));
extern REDIRECT *copy_redirects __P((REDIRECT *));
extern COMMAND *copy_command __P((COMMAND *));
extern WORD_DESC *copy_word PARAMS((WORD_DESC *));
extern WORD_LIST *copy_word_list PARAMS((WORD_LIST *));
extern REDIRECT *copy_redirect PARAMS((REDIRECT *));
extern REDIRECT *copy_redirects PARAMS((REDIRECT *));
extern COMMAND *copy_command PARAMS((COMMAND *));
#endif /* _COMMAND_H_ */
+5 -1
View File
@@ -98,6 +98,10 @@
# undef USE_MKSTEMP
#endif
#if !HAVE_MKDTEMP
# undef USE_MKDTMP
#endif
/* If the shell is called by this name, it will become restricted. */
#if defined (RESTRICTED_SHELL)
# define RESTRICTED_SHELL_NAME "rbash"
@@ -137,7 +141,7 @@
/* check multibyte capability for I18N code */
/************************************************/
/* For platforms which support the ISO C amendement 1 functionality we
/* For platforms which support the ISO C amendment 1 functionality we
support user defined character classes. */
/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>. */
#if defined (HAVE_WCTYPE_H) && defined (HAVE_WCHAR_H) && defined (HAVE_LOCALE_H)
+9 -2
View File
@@ -106,9 +106,11 @@
which can be fooled under certain not-uncommon circumstances. */
/* #define SSH_SOURCE_BASHRC */
/* Define if you want the case-capitalizing operators (~[~]) and the
/* Define if you want the case-toggling operators (~[~]) and the
`capcase' variable attribute (declare -c). */
#define CASEMOD_CAPCASE
/* TAG: bash-5.2 disable */
#define CASEMOD_TOGGLECASE
#define CASEMOD_CAPCASE
/* This is used as the name of a shell function to call when a command
name is not found. If you want to name it something other than the
@@ -173,6 +175,7 @@
/* Define to use libc mktemp/mkstemp instead of replacements in lib/sh/tmpfile.c */
#define USE_MKTEMP
#define USE_MKSTEMP
#define USE_MKDTEMP
/* Define to force the value of OLDPWD inherited from the environment to be a
directory */
@@ -186,3 +189,7 @@
interactive shells; define to 1 for the historical behavior of enabling
when the shell is interactive. */
#define HISTEXPAND_DEFAULT 1
/* Undefine or define to 0 if you don't want to allow associative array
assignment using a compound list of key-value pairs. */
#define ASSOC_KVPAIR_ASSIGNMENT 1
+29 -1
View File
@@ -1,6 +1,6 @@
/* config.h -- Configuration file for bash. */
/* Copyright (C) 1987-2009,2011-2012 Free Software Foundation, Inc.
/* Copyright (C) 1987-2009,2011-2012,2013-2019 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -285,6 +285,11 @@
/* Define if you have <alloca.h> and it should be used (not on Ultrix). */
#undef HAVE_ALLOCA_H
/* Define if major/minor/makedev is defined in <sys/mkdev.h> */
#undef MAJOR_IN_MAKEDEV
/* Define if major/minor/makedev is defined in <sys/sysmacros.h> */
#undef MAJOR_IN_SYSMACROS
/* SYSTEM TYPES */
@@ -567,6 +572,9 @@
/* Presence of system and C library functions. */
/* Define if you have the arc4random function. */
#undef HAVE_ARC4RANDOM
/* Define if you have the asprintf function. */
#undef HAVE_ASPRINTF
@@ -626,6 +634,9 @@
/* Define if you have the getcwd function. */
#undef HAVE_GETCWD
/* Define if you have the getentropy function. */
#undef HAVE_GETENTROPY
/* Define if you have the getdtablesize function. */
#undef HAVE_GETDTABLESIZE
@@ -653,6 +664,9 @@
/* Define if you have the getpwuid function. */
#undef HAVE_GETPWUID
/* Define if you have the getrandom function. */
#undef HAVE_GETRANDOM
/* Define if you have the getrlimit function. */
#undef HAVE_GETRLIMIT
@@ -746,6 +760,9 @@
/* Define if you have the memset function. */
#undef HAVE_MEMSET
/* Define if you have the mkdtemp function. */
#undef HAVE_MKDTEMP
/* Define if you have the mkfifo function. */
#undef HAVE_MKFIFO
@@ -807,6 +824,14 @@
#undef HAVE_SETREGID
#undef HAVE_DECL_SETREGID
/* Define if you have the setregid function. */
#undef HAVE_SETRESGID
#undef HAVE_DECL_SETRESGID
/* Define if you have the setresuid function. */
#undef HAVE_SETRESUID
#undef HAVE_DECL_SETRESUID
/* Define if you have the setvbuf function. */
#undef HAVE_SETVBUF
@@ -1046,6 +1071,9 @@
/* Define if you have the <sys/ptem.h> header file. */
#undef HAVE_SYS_PTEM_H
/* Define if you have the <sys/random.h> header file. */
#undef HAVE_SYS_RANDOM_H
/* Define if you have the <sys/resource.h> header file. */
#undef HAVE_SYS_RESOURCE_H
Vendored
+4716 -611
View File
File diff suppressed because it is too large Load Diff
+78 -33
View File
@@ -1,11 +1,11 @@
dnl
dnl Configure script for bash-5.0
dnl Configure script for bash-5.1
dnl
dnl report bugs to chet@po.cwru.edu
dnl
dnl Process this file with autoconf to produce a configure script.
# Copyright (C) 1987-2018 Free Software Foundation, Inc.
# Copyright (C) 1987-2020 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
@@ -21,9 +21,9 @@ dnl Process this file with autoconf to produce a configure script.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
AC_REVISION([for Bash 5.0, version 5.005])dnl
AC_REVISION([for Bash 5.1, version 5.022])dnl
define(bashvers, 5.0)
define(bashvers, 5.1)
define(relstatus, release)
AC_INIT([bash], bashvers-relstatus, [bug-bash@gnu.org])
@@ -77,6 +77,9 @@ m68k-sysv) opt_bash_malloc=no ;; # fixes file descriptor leak in closedir
sparc-linux*) opt_bash_malloc=no ;; # sparc running linux; requires ELF
*-aix*) opt_bash_malloc=no ;; # AIX machines
*-cygwin*) opt_bash_malloc=no ;; # Cygnus's CYGWIN environment
# These lack a working sbrk(2)
aarch64-freebsd*) opt_bash_malloc=no ;;
riscv*-freebsd*) opt_bash_malloc=no ;;
# Mach-derived systems have a ton of extra malloc functions and lack sbrk(2)
*-nextstep*) opt_bash_malloc=no ;; # NeXT machines running NeXTstep
*-openstep*) opt_bash_malloc=no ;; # i386/Sparc/HP machines running Openstep
@@ -88,13 +91,7 @@ sparc-linux*) opt_bash_malloc=no ;; # sparc running linux; requires ELF
*-qnx*) opt_bash_malloc=no ;; # QNX 4.2, QNX [67].x
*-nsk*) opt_bash_malloc=no ;; # HP NonStop
*-haiku*) opt_bash_malloc=no ;; # Haiku OS
# Deprecated -- bash malloc is suitable
#sparc-netbsd*) opt_bash_malloc=no ;; # needs 8-byte alignment
#mips-irix6*) opt_bash_malloc=no ;; # needs 8-byte alignment
#*-freebsd*-gnu) opt_bash_malloc=no ;; # there's some undetermined problem here
#*-freebsd*) opt_bash_malloc=no ;; # they claim it's better; I disagree
#*-openbsd*) opt_bash_malloc=no ;; # they claim it needs eight-bit alignment
#*-mirbsd*) opt_bash_malloc=no ;; # they claim it needs eight-bit alignment
*-genode*) opt_bash_malloc=no ;; # Genode has no sbrk
esac
# memory scrambling on free()
@@ -404,10 +401,7 @@ AC_SUBST(HELPSTRINGS)
dnl We want these before the checks, so the checks can modify their values.
if test -z "$CFLAGS"; then
AUTO_CFLAGS="-g ${GCC+-O2} ${GCC+-Wno-parentheses}"
AUTO_LDFLAGS="-g ${GCC+-O2}"
else
AUTO_CFLAGS= AUTO_LDFLAGS=
want_auto_cflags=1
fi
echo ""
@@ -419,6 +413,14 @@ dnl AC_PROG_CC sets $cross_compiling to `yes' if cross-compiling for a
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}"
else
AUTO_CFLAGS= AUTO_LDFLAGS= STYLE_CFLAGS=
fi
dnl test for Unix variants
AC_ISC_POSIX
AC_MINIX
@@ -513,7 +515,11 @@ if test "X$cross_compiling" = "Xno"; then
LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-'$(LDFLAGS)'}
fi
# CFLAGS set above to default value if not passed in environment
CFLAGS_FOR_BUILD=${CFLAGS-'$(CFLAGS)'}
if test -n "$want_auto_cflags" ; then
CFLAGS_FOR_BUILD="${CFLAGS} ${STYLE_CFLAGS}"
else
CFLAGS_FOR_BUILD=${CFLAGS-'$(CFLAGS)'}
fi
LIBS_FOR_BUILD=${LIBS_FOR_BUILD-'$(LIBS)'}
else
CC_FOR_BUILD=${CC_FOR_BUILD-"gcc"}
@@ -685,6 +691,44 @@ AC_SUBST(SIZE)
m4_include([m4/stat-time.m4])
m4_include([m4/timespec.m4])
dnl include files for gettext
m4_include([m4/codeset.m4])
m4_include([m4/extern-inline.m4])
m4_include([m4/fcntl-o.m4])
m4_include([m4/gettext.m4])
m4_include([m4/glibc2.m4])
m4_include([m4/glibc21.m4])
m4_include([m4/host-cpu-c-abi.m4])
m4_include([m4/iconv.m4])
m4_include([m4/intdiv0.m4])
m4_include([m4/intl.m4])
m4_include([m4/intlmacosx.m4])
m4_include([m4/intl-thread-locale.m4])
m4_include([m4/intmax.m4])
m4_include([m4/inttypes-pri.m4])
m4_include([m4/inttypes.m4])
m4_include([m4/inttypes_h.m4])
m4_include([m4/lcmessage.m4])
m4_include([m4/lib-ld.m4])
m4_include([m4/lib-link.m4])
m4_include([m4/lib-prefix.m4])
m4_include([m4/lock.m4])
m4_include([m4/nls.m4])
m4_include([m4/po.m4])
m4_include([m4/printf-posix.m4])
m4_include([m4/progtest.m4])
m4_include([m4/pthread_rwlock_rdlock.m4])
m4_include([m4/size_max.m4])
m4_include([m4/stdint_h.m4])
m4_include([m4/threadlib.m4])
m4_include([m4/uintmax_t.m4])
m4_include([m4/ulonglong.m4])
m4_include([m4/visibility.m4])
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)
@@ -705,6 +749,7 @@ AM_GNU_GETTEXT([no-libtool], [need-ngettext], [lib/intl])
dnl header files
AC_HEADER_DIRENT
AC_HEADER_TIME
AC_HEADER_MAJOR
BASH_HEADER_INTTYPES
@@ -713,7 +758,7 @@ AC_CHECK_HEADERS(unistd.h stdlib.h stdarg.h varargs.h limits.h string.h \
stdbool.h stddef.h stdint.h netdb.h pwd.h grp.h strings.h \
regex.h syslog.h ulimit.h)
AC_CHECK_HEADERS(sys/pte.h sys/stream.h sys/select.h sys/file.h sys/ioctl.h \
sys/mman.h sys/param.h sys/socket.h sys/stat.h \
sys/mman.h sys/param.h sys/random.h sys/socket.h sys/stat.h \
sys/time.h sys/times.h sys/types.h sys/wait.h)
AC_CHECK_HEADERS(netinet/in.h arpa/inet.h)
@@ -779,10 +824,10 @@ dnl checks for missing libc functions
AC_CHECK_FUNC(mkfifo,AC_DEFINE(HAVE_MKFIFO),AC_DEFINE(MKFIFO_MISSING))
dnl checks for system calls
AC_CHECK_FUNCS(dup2 eaccess fcntl getdtablesize getgroups gethostname \
getpagesize getpeername getrlimit getrusage gettimeofday \
kill killpg lstat pselect readlink select setdtablesize \
setitimer tcgetpgrp uname ulimit waitpid)
AC_CHECK_FUNCS(dup2 eaccess fcntl getdtablesize getentropy getgroups \
gethostname getpagesize getpeername getrandom getrlimit \
getrusage gettimeofday kill killpg lstat pselect readlink \
select setdtablesize setitimer tcgetpgrp uname ulimit waitpid)
AC_REPLACE_FUNCS(rename)
dnl checks for c library functions
@@ -795,7 +840,9 @@ AC_CHECK_FUNCS(bcopy bzero confstr faccessat fnmatch \
AC_CHECK_FUNCS(vasprintf asprintf)
AC_CHECK_FUNCS(isascii isblank isgraph isprint isspace isxdigit)
AC_CHECK_FUNCS(getpwent getpwnam getpwuid)
AC_CHECK_FUNCS(mkstemp)
AC_CHECK_FUNCS(mkstemp mkdtemp)
AC_CHECK_FUNCS(arc4random)
AC_REPLACE_FUNCS(getcwd memset)
AC_REPLACE_FUNCS(strcasecmp strcasestr strerror strftime strnlen strpbrk strstr)
AC_REPLACE_FUNCS(strtod strtol strtoul strtoll strtoull strtoimax strtoumax)
@@ -810,9 +857,13 @@ 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])
AC_CHECK_FUNCS(setresuid setresgid)
dnl Extra test to detect the horribly broken HP/UX 11.00 strtold(3)
AC_CHECK_DECLS([strtold], [
AC_MSG_CHECKING([for broken strtold])
@@ -1084,15 +1135,15 @@ LOCAL_DEFS=-DSHELL
dnl use this section to possibly define more cpp variables, specify local
dnl libraries, and specify any additional local cc or ld flags
dnl
dnl this should really go away someday
dnl most of these are really old; this should really go away someday
case "${host_os}" in
sysv4.2*) AC_DEFINE(SVR4_2)
AC_DEFINE(SVR4) ;;
sysv4*) AC_DEFINE(SVR4) ;;
sysv5*) AC_DEFINE(SVR5) ;;
hpux9*) LOCAL_CFLAGS="-DHPUX9 -DHPUX" ;;
hpux*) LOCAL_CFLAGS=-DHPUX ;;
hpux9*) LOCAL_CFLAGS="-DHPUX9 -DHPUX -DTGETENT_BROKEN -DTGETFLAG_BROKEN" ;;
hpux*) LOCAL_CFLAGS="-DHPUX -DTGETENT_BROKEN -DTGETFLAG_BROKEN" ;;
dgux*) LOCAL_CFLAGS=-D_DGUX_SOURCE; LOCAL_LIBS=-ldgc ;;
isc*) LOCAL_CFLAGS=-Disc386 ;;
rhapsody*) LOCAL_CFLAGS=-DRHAPSODY ;;
@@ -1113,6 +1164,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' ;;
*qnx[[67]]*) LOCAL_LIBS="-lncurses" ;;
*qnx*) LOCAL_CFLAGS="-Dqnx -F -3s" LOCAL_LDFLAGS="-3s" LOCAL_LIBS="-lunix -lncurses" ;;
powerux*) LOCAL_LIBS="-lgen" ;;
@@ -1154,14 +1206,7 @@ mips-pyramid-sysv4) LOCAL_CFLAGS=-Xa ;;
esac
# turn off paren warnings in gcc
if test "$GCC" = yes # && test -n "$DEBUG"
then
CFLAGS="$CFLAGS -Wno-parentheses -Wno-format-security"
# if test -n "$DEBUG"
# then
# CFLAGS="$CFLAGS -Werror"
# fi
fi
CFLAGS="$CFLAGS ${STYLE_CFLAGS}"
#
# Shared object configuration section. These values are generated by
+14 -14
View File
@@ -2,7 +2,7 @@
primarily for making function definitions, but I'm not sure
that anyone else will need it. */
/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
/* Copyright (C) 1987-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -32,25 +32,25 @@
#include "shell.h"
static PATTERN_LIST *copy_case_clause __P((PATTERN_LIST *));
static PATTERN_LIST *copy_case_clauses __P((PATTERN_LIST *));
static FOR_COM *copy_for_command __P((FOR_COM *));
static PATTERN_LIST *copy_case_clause PARAMS((PATTERN_LIST *));
static PATTERN_LIST *copy_case_clauses PARAMS((PATTERN_LIST *));
static FOR_COM *copy_for_command PARAMS((FOR_COM *));
#if defined (ARITH_FOR_COMMAND)
static ARITH_FOR_COM *copy_arith_for_command __P((ARITH_FOR_COM *));
static ARITH_FOR_COM *copy_arith_for_command PARAMS((ARITH_FOR_COM *));
#endif
static GROUP_COM *copy_group_command __P((GROUP_COM *));
static SUBSHELL_COM *copy_subshell_command __P((SUBSHELL_COM *));
static COPROC_COM *copy_coproc_command __P((COPROC_COM *));
static CASE_COM *copy_case_command __P((CASE_COM *));
static WHILE_COM *copy_while_command __P((WHILE_COM *));
static IF_COM *copy_if_command __P((IF_COM *));
static GROUP_COM *copy_group_command PARAMS((GROUP_COM *));
static SUBSHELL_COM *copy_subshell_command PARAMS((SUBSHELL_COM *));
static COPROC_COM *copy_coproc_command PARAMS((COPROC_COM *));
static CASE_COM *copy_case_command PARAMS((CASE_COM *));
static WHILE_COM *copy_while_command PARAMS((WHILE_COM *));
static IF_COM *copy_if_command PARAMS((IF_COM *));
#if defined (DPAREN_ARITHMETIC)
static ARITH_COM *copy_arith_command __P((ARITH_COM *));
static ARITH_COM *copy_arith_command PARAMS((ARITH_COM *));
#endif
#if defined (COND_COMMAND)
static COND_COM *copy_cond_command __P((COND_COM *));
static COND_COM *copy_cond_command PARAMS((COND_COM *));
#endif
static SIMPLE_COM *copy_simple_command __P((SIMPLE_COM *));
static SIMPLE_COM *copy_simple_command PARAMS((SIMPLE_COM *));
WORD_DESC *
copy_word (w)
+10 -10
View File
@@ -1,6 +1,6 @@
/* dispose_cmd.h -- Functions appearing in dispose_cmd.c. */
/* Copyright (C) 1993-2009 Free Software Foundation, Inc.
/* Copyright (C) 1993-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -23,18 +23,18 @@
#include "stdc.h"
extern void dispose_command __P((COMMAND *));
extern void dispose_word_desc __P((WORD_DESC *));
extern void dispose_word __P((WORD_DESC *));
extern void dispose_words __P((WORD_LIST *));
extern void dispose_word_array __P((char **));
extern void dispose_redirects __P((REDIRECT *));
extern void dispose_command PARAMS((COMMAND *));
extern void dispose_word_desc PARAMS((WORD_DESC *));
extern void dispose_word PARAMS((WORD_DESC *));
extern void dispose_words PARAMS((WORD_LIST *));
extern void dispose_word_array PARAMS((char **));
extern void dispose_redirects PARAMS((REDIRECT *));
#if defined (COND_COMMAND)
extern void dispose_cond_node __P((COND_COM *));
extern void dispose_cond_node PARAMS((COND_COM *));
#endif
extern void dispose_function_def_contents __P((FUNCTION_DEF *));
extern void dispose_function_def __P((FUNCTION_DEF *));
extern void dispose_function_def_contents PARAMS((FUNCTION_DEF *));
extern void dispose_function_def PARAMS((FUNCTION_DEF *));
#endif /* !_DISPOSE_CMD_H_ */
+1 -1
View File
@@ -334,7 +334,7 @@ posix: bashref.texi
$(RM) POSIX
rbash: bashref.texi
$(SH) ./mkrbash
$(SHELL) ./mkrbash
cmp -s RBASH ../RBASH || mv RBASH ../RBASH
$(RM) RBASH
+2349 -2115
View File
File diff suppressed because it is too large Load Diff
+537 -219
View File
File diff suppressed because it is too large Load Diff
+626 -300
View File
File diff suppressed because it is too large Load Diff
+960 -653
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+8552 -8218
View File
File diff suppressed because it is too large Load Diff
+4 -3
View File
@@ -29,9 +29,10 @@ EENNVVIIRROONNMMEENNTT
EEDDIITTOORR Specifies the preferred editor. If EEDDIITTOORR is not set, bbaasshhbbuugg
attempts to locate a number of alternative editors, including
eemmaaccss, and defaults to vvii.
eemmaaccss. If bbaasshhbbuugg cannot locate any of the alternative editors,
it attempts to execute vvii.
HHOOMMEE Directory in which the failed bug report is saved if the mail
HHOOMMEE Directory in which the failed bug report is saved if the mail
fails.
TTMMPPDDIIRR Directory in which to create temporary files and directories.
@@ -48,4 +49,4 @@ AAUUTTHHOORRSS
GNU Bash-4.4 2016 February 15 BASHBUG(1)
GNU Bash 5.1 2020 August 1 BASHBUG(1)
+6 -4
View File
@@ -5,9 +5,9 @@
.\" Case Western Reserve University
.\" chet@po.cwru.edu
.\"
.\" Last Change: Mon Feb 15 14:42:40 EST 2016
.\" Last Change: Sun Aug 2 15:39:07 EDT 2020
.\"
.TH BASHBUG 1 "2016 February 15" "GNU Bash-4.4"
.TH BASHBUG 1 "2020 August 1" "GNU Bash 5.1"
.SH NAME
bashbug \- report a bug in bash
.SH SYNOPSIS
@@ -44,8 +44,10 @@ Specifies the preferred editor. If
is not set,
.B bashbug
attempts to locate a number of alternative editors, including
.BR emacs ,
and defaults to \fBvi\fP.
.BR emacs .
If
.B bashbug
cannot locate any of the alternative editors, it attempts to execute \fBvi\fP.
.TP
.B HOME
Directory in which the failed bug report is saved if the mail fails.
+19 -16
View File
@@ -1,10 +1,10 @@
%!PS-Adobe-3.0
%%Creator: groff version 1.22.3
%%CreationDate: Mon Mar 28 15:34:55 2016
%%Creator: groff version 1.22.4
%%CreationDate: Fri Aug 7 11:58:10 2020
%%DocumentNeededResources: font Times-Roman
%%+ font Times-Bold
%%+ font Times-Italic
%%DocumentSuppliedResources: procset grops 1.22 3
%%DocumentSuppliedResources: procset grops 1.22 4
%%Pages: 1
%%PageOrder: Ascend
%%DocumentMedia: Default 612 792 0 () ()
@@ -14,7 +14,7 @@
%%PageMedia: Default
%%EndDefaults
%%BeginProlog
%%BeginResource: procset grops 1.22 3
%%BeginResource: procset grops 1.22 4
%!PS-Adobe-3.0 Resource-ProcSet
/setpacking where{
pop
@@ -275,20 +275,23 @@ E(vironment v)-.4 E(ariables if the)-.25 E 2.5(ye)-.15 G(xist:)-2.65 E
F2(EDIT)108 300 Q(OR)-.18 E F0 .327(Speci\214es the preferred editor)144
312 R 2.827(.I)-.55 G(f)-2.827 E F4(EDIT)2.827 E(OR)-.162 E F0 .327
(is not set,)2.577 F F2(bashb)2.827 E(ug)-.2 E F0 .328
(attempts to locate a number of alter)2.827 F(-)-.2 E(nati)144 324 Q .3
-.15(ve e)-.25 H(ditors, including).15 E F2(emacs)2.5 E F0 2.5(,a)C
(nd def)-2.5 E(aults to)-.1 E F2(vi)2.5 E F0(.)A F2(HOME)108 340.8 Q F0
(Directory in which the f)144 352.8 Q(ailed b)-.1 E(ug report is sa)-.2
E -.15(ve)-.2 G 2.5(di).15 G 2.5(ft)-2.5 G(he mail f)-2.5 E(ails.)-.1 E
F2(TMPDIR)108 369.6 Q F0
(attempts to locate a number of alter)2.827 F(-)-.2 E(nati)144 324 Q
1.925 -.15(ve e)-.25 H 1.625(ditors, including).15 F F2(emacs)4.125 E F0
6.625(.I)C(f)-6.625 E F2(bashb)4.125 E(ug)-.2 E F0 1.625
(cannot locate an)4.125 F 4.125(yo)-.15 G 4.125(ft)-4.125 G 1.625
(he alternati)-4.125 F 1.925 -.15(ve e)-.25 H 1.625(ditors, it at-).15 F
(tempts to e)144 336 Q -.15(xe)-.15 G(cute).15 E F2(vi)2.5 E F0(.)A F2
(HOME)108 352.8 Q F0(Directory in which the f)144 364.8 Q(ailed b)-.1 E
(ug report is sa)-.2 E -.15(ve)-.2 G 2.5(di).15 G 2.5(ft)-2.5 G
(he mail f)-2.5 E(ails.)-.1 E F2(TMPDIR)108 381.6 Q F0
(Directory in which to create temporary \214les and directories.)144
381.6 Q F1(SEE ALSO)72 398.4 Q F3(bash)108 410.4 Q F0(\(1\))A F1 -.548
(AU)72 427.2 S(THORS).548 E F0(Brian F)108 439.2 Q(ox, Free Softw)-.15 E
(are F)-.1 E(oundation)-.15 E(bfox@gnu.or)108 451.2 Q(g)-.18 E
(Chet Rame)108 468 Q 1.3 -.65(y, C)-.15 H(ase W).65 E(estern Reserv)-.8
393.6 Q F1(SEE ALSO)72 410.4 Q F3(bash)108 422.4 Q F0(\(1\))A F1 -.548
(AU)72 439.2 S(THORS).548 E F0(Brian F)108 451.2 Q(ox, Free Softw)-.15 E
(are F)-.1 E(oundation)-.15 E(bfox@gnu.or)108 463.2 Q(g)-.18 E
(Chet Rame)108 480 Q 1.3 -.65(y, C)-.15 H(ase W).65 E(estern Reserv)-.8
E 2.5(eU)-.15 G(ni)-2.5 E -.15(ve)-.25 G(rsity).15 E(chet@po.cwru.edu)
108 480 Q(GNU Bash-4.4)72 768 Q(2016 February 15)138.46 E(1)193.45 E 0
Cg EP
108 492 Q(GNU Bash 5.1)72 768 Q(2020 August 1)145.395 E(1)199.555 E 0 Cg
EP
%%Trailer
end
%%EOF
BIN
View File
Binary file not shown.
+1756 -1645
View File
File diff suppressed because it is too large Load Diff
+960 -653
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+9666 -9265
View File
File diff suppressed because it is too large Load Diff
+520 -190
View File
File diff suppressed because it is too large Load Diff
+889 -726
View File
File diff suppressed because it is too large Load Diff
+2139 -1957
View File
File diff suppressed because it is too large Load Diff
+6 -2
View File
@@ -14,13 +14,17 @@ RREESSTTRRIICCTTEEDD SSHHEELLLL
+o changing directories with ccdd
+o setting or unsetting the values of SSHHEELLLL, PPAATTHH, EENNVV, or BBAASSHH__EENNVV
+o setting or unsetting the values of SSHHEELLLL, PPAATTHH, HHIISSTTFFIILLEE, EENNVV,
or BBAASSHH__EENNVV
+o specifying command names containing //
+o specifying a filename containing a // as an argument to the ..
+o specifying a filename containing a // as an argument to the ..
builtin command
+o specifying a filename containing a slash as an argument to the
hhiissttoorryy builtin command
+o specifying a filename containing a slash as an argument to the
--pp option to the hhaasshh builtin command
+40 -36
View File
@@ -1,9 +1,9 @@
%!PS-Adobe-3.0
%%Creator: groff version 1.22.3
%%CreationDate: Wed Jan 2 09:14:38 2019
%%Creator: groff version 1.22.4
%%CreationDate: Wed Nov 18 15:13:06 2020
%%DocumentNeededResources: font Times-Roman
%%+ font Times-Bold
%%DocumentSuppliedResources: procset grops 1.22 3
%%DocumentSuppliedResources: procset grops 1.22 4
%%Pages: 1
%%PageOrder: Ascend
%%DocumentMedia: Default 612 792 0 () ()
@@ -13,7 +13,7 @@
%%PageMedia: Default
%%EndDefaults
%%BeginProlog
%%BeginResource: procset grops 1.22 3
%%BeginResource: procset grops 1.22 4
%!PS-Adobe-3.0 Resource-ProcSet
/setpacking where{
pop
@@ -236,50 +236,54 @@ BP
(Commands Manual)2.5 E(RB)132.97 E(ASH\(1\))-.35 E/F1 10.95/Times-Bold@0
SF -.219(NA)72 84 S(ME).219 E F0(rbash \255 restricted bash, see)108 96
Q/F2 10/Times-Bold@0 SF(bash)2.5 E F0(\(1\))A F1(RESTRICTED SHELL)72
112.8 Q F0(If)108 124.8 Q F2(bash)4.397 E F0 1.897
(is started with the name)4.397 F F2(rbash)4.397 E F0 4.397(,o)C 4.397
(rt)-4.397 G(he)-4.397 E F2<ad72>4.397 E F0 1.896
(option is supplied at in)4.397 F -.2(vo)-.4 G 1.896
(cation, the shell becomes).2 F 3.445(restricted. A)108 136.8 R .945
(restricted shell is used to set up an en)3.445 F .946
(vironment more controlled than the standard shell.)-.4 F(It)5.946 E
(beha)108 148.8 Q -.15(ve)-.2 G 2.5(si).15 G(dentically to)-2.5 E F2
(bash)2.5 E F0(with the e)2.5 E(xception that the follo)-.15 E
112.8 Q F0(If)108 124.8 Q F2(bash)3.582 E F0 1.081
(is started with the name)3.581 F F2(rbash)3.581 E F0 3.581(,o)C 3.581
(rt)-3.581 G(he)-3.581 E F2<ad72>3.581 E F0 1.081
(option is supplied at in)3.581 F -.2(vo)-.4 G 1.081
(cation, the shell becomes re-).2 F 2.976(stricted. A)108 136.8 R .476
(restricted shell is used to set up an en)2.976 F .476
(vironment more controlled than the standard shell.)-.4 F .477(It be-)
5.477 F(ha)108 148.8 Q -.15(ve)-.2 G 2.5(si).15 G(dentically to)-2.5 E
F2(bash)2.5 E F0(with the e)2.5 E(xception that the follo)-.15 E
(wing are disallo)-.25 E(wed or not performed:)-.25 E<83>108 165.6 Q
(changing directories with)144 165.6 Q F2(cd)2.5 E F0<83>108 182.4 Q
(setting or unsetting the v)144 182.4 Q(alues of)-.25 E/F3 9
/Times-Bold@0 SF(SHELL)2.5 E/F4 9/Times-Roman@0 SF(,)A F3 -.666(PA)2.25
G(TH)-.189 E F4(,)A F3(ENV)2.25 E F4(,)A F0(or)2.25 E F3 -.27(BA)2.5 G
(SH_ENV).27 E F0<83>108 199.2 Q(specifying command names containing)144
199.2 Q F2(/)2.5 E F0<83>108 216 Q(specifying a \214lename containing a)
144 216 Q F2(/)2.5 E F0(as an ar)2.5 E(gument to the)-.18 E F2(.)2.5 E
F0 -.2(bu)5 G(iltin command).2 E<83>108 232.8 Q .45
(specifying a \214lename containing a slash as an ar)144 232.8 R .449
G(TH)-.189 E F4(,)A F3(HISTFILE)2.25 E F4(,)A F3(ENV)2.25 E F4(,)A F0
(or)2.25 E F3 -.27(BA)2.5 G(SH_ENV).27 E F0<83>108 199.2 Q
(specifying command names containing)144 199.2 Q F2(/)2.5 E F0<83>108
216 Q(specifying a \214lename containing a)144 216 Q F2(/)2.5 E F0
(as an ar)2.5 E(gument to the)-.18 E F2(.)2.5 E F0 -.2(bu)5 G
(iltin command).2 E<83>108 232.8 Q
(specifying a \214lename containing a slash as an ar)144 232.8 Q
(gument to the)-.18 E F2(history)2.5 E F0 -.2(bu)2.5 G(iltin command).2
E<83>108 249.6 Q .45
(specifying a \214lename containing a slash as an ar)144 249.6 R .449
(gument to the)-.18 F F2<ad70>2.949 E F0 .449(option to the)2.949 F F2
(hash)2.949 E F0 -.2(bu)2.949 G .449(iltin com-).2 F(mand)144 244.8 Q
<83>108 261.6 Q(importing function de\214nitions from the shell en)144
261.6 Q(vironment at startup)-.4 E<83>108 278.4 Q(parsing the v)144
278.4 Q(alue of)-.25 E F3(SHELLOPTS)2.5 E F0(from the shell en)2.25 E
(vironment at startup)-.4 E<83>108 295.2 Q(redirecting output using the\
>, >|, <>, >&, &>, and >> redirection operators)144 295.2 Q<83>108 312
Q(using the)144 312 Q F2(exec)2.5 E F0 -.2(bu)2.5 G
(hash)2.949 E F0 -.2(bu)2.949 G .449(iltin com-).2 F(mand)144 261.6 Q
<83>108 278.4 Q(importing function de\214nitions from the shell en)144
278.4 Q(vironment at startup)-.4 E<83>108 295.2 Q(parsing the v)144
295.2 Q(alue of)-.25 E F3(SHELLOPTS)2.5 E F0(from the shell en)2.25 E
(vironment at startup)-.4 E<83>108 312 Q(redirecting output using the >\
, >|, <>, >&, &>, and >> redirection operators)144 312 Q<83>108 328.8 Q
(using the)144 328.8 Q F2(exec)2.5 E F0 -.2(bu)2.5 G
(iltin command to replace the shell with another command).2 E<83>108
328.8 Q(adding or deleting b)144 328.8 Q(uiltin commands with the)-.2 E
345.6 Q(adding or deleting b)144 345.6 Q(uiltin commands with the)-.2 E
F2<ad66>2.5 E F0(and)2.5 E F2<ad64>2.5 E F0(options to the)2.5 E F2
(enable)2.5 E F0 -.2(bu)2.5 G(iltin command).2 E<83>108 345.6 Q
(using the)144 345.6 Q F2(enable)2.5 E F0 -.2(bu)2.5 G
(enable)2.5 E F0 -.2(bu)2.5 G(iltin command).2 E<83>108 362.4 Q
(using the)144 362.4 Q F2(enable)2.5 E F0 -.2(bu)2.5 G
(iltin command to enable disabled shell b).2 E(uiltins)-.2 E<83>108
362.4 Q(specifying the)144 362.4 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 379.2 Q
(turning of)144 379.2 Q 2.5(fr)-.25 G(estricted mode with)-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 396 Q 2.5(ys)-.15 G
(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 412.8 R -.15
(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 424.8 Q(wned to e)-.15 E -.15(xe)-.15 G(cute the script.).15 E
F1(SEE ALSO)72 441.6 Q F0(bash\(1\))108 453.6 Q(GNU Bash-4.0)72 768 Q
(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
%%Trailer
end
+6 -6
View File
@@ -1,11 +1,11 @@
@ignore
Copyright (C) 1988-2018 Free Software Foundation, Inc.
Copyright (C) 1988-2020 Free Software Foundation, Inc.
@end ignore
@set LASTCHANGE Fri Dec 7 09:49:07 EST 2018
@set LASTCHANGE Thu Oct 29 16:18:54 EDT 2020
@set EDITION 5.0
@set VERSION 5.0
@set EDITION 5.1
@set VERSION 5.1
@set UPDATED 7 December 2018
@set UPDATED-MONTH December 2018
@set UPDATED 29 October 2020
@set UPDATED-MONTH October 2020

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