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

Bash-4.3 distribution sources and documentation

This commit is contained in:
Chet Ramey 2014-02-26 09:36:43 -05:00
parent 4539d736f1
commit ac50fbac37
497 changed files with 129395 additions and 87598 deletions

View file

@ -390,6 +390,7 @@ tests/strip.tests Chet Ramey
tests/strip.right Chet Ramey
tests/tilde-tests Chet Ramey
tests/tilde.right Chet Ramey
tests/unicode1.sub Chet Ramey, John Kearney
tests/varenv.right Chet Ramey
tests/varenv.sh Chet Ramey
tests/misc/chld-trap.sh Chet Ramey
@ -460,3 +461,6 @@ lib/sh/zwrite.c Chet Ramey
tests/posix-ifs.sh Glenn Fowler
support/checkbashisms Julian Gilbey, Debian Linux team
lib/readline/colors.c Richard Stallman, David MacKenzie
lib/readline/parse-colors.c Richard Stallman, David MacKenzie

847
CHANGES
View file

@ -1,3 +1,850 @@
This document details the changes between this version, bash-4.3-release, and
the previous version, bash-4.3-rc2.
1. Changes to Bash
a. Only Posix-mode shells should exit on an assignment failure in the
temporary environment preceding a special builtin. This is how it's been
documented.
b. Fixed a bug that caused a failed special builtin to not exit a posix-mode
shell if the failing builtin was on the LHS of a && or ||.
c. Changed the handling of unquoted backslashes in regular expressions to be
closer to bash-4.2.
d. globstar (**) no longer traverses symbolic links that resolve to
directories. This eliminates some duplicate entries.
e. Fixed a bug that caused a SIGCHLD trap handler to not be able to change the
SIGCHLD disposition.
f. Fixed a bug that caused a crash when -x was enabled and a command
contained a printable multibyte (wide) character.
g. Fixed a bug that caused an interactive shell without line editing enabled
to read invalid data after receiving a SIGINT.
h. Fixed a bug that caused command word completion to fail if the directory in
$PATH where the completion would be found contained single or double quotes.
i. Fixed a bug that caused a shell with -v enabled to print commands in $()
multiple times.
2. Changes to Readline
a. Fixed a bug that caused `undo' to reference freed memory or null pointers.
3. New Features in Bash
a. The [[ -v ]] option now understands array references (foo[1]) and returns
success if the referenced element has a value.
------------------------------------------------------------------------------
This document details the changes between this version, bash-4.3-rc2, and the
previous version, bash-4.3-rc1.
1. Changes to Bash
a. Fixed a bug that left variables set by printf -v marked as invisible.
b. Fixed an off-by-one error in a job control warning message.
c. Fixed a bug that caused the shell to crash after declaring a nameref variable
without a value.
d. Fixed a bug that caused asynchronous commands to not set $? correctly.
e. Fixed a bug that caused out-of-order execution when executing aliases with
embedded newlines containing `.' commands.
f. Fixed a bug that caused error messages generated by expansion errors in
`for' commands to have the wrong line number.
g. Fixed a bug that caused the `wait' builtin to not be interruptible in an
interactive shell with job control enabled.
h. Fixed a bug that caused SIGINT and SIGQUIT to not be trappable in
asynchronous subshell commands.
i. Bash now requires that the value assigned to a nameref variable be a valid
shell identifier (variable name or array reference).
j. Converting an existing variable to a nameref variable now turns off the
-i/-l/-u/-c attributes.
k. Displaying a nameref variable with `declare -p' now displays the nameref
variable and its value rather than following the nameref chain.
l. Fixed a problem with interrupt handling that caused a second and subsequent
SIGINT to be ignored by interactive shells.
m. Fixed a bug that caused certain positional parameter and array expansions
to mishandle (discard) null positional parameters and array elements.
n. The shell no longer blocks receipt of signals while running trap handlers
for those signals, and allows most trap handlers to be run recursively
(running trap handlers while a trap handler is executing).
o. The shell now handles backslashes in regular expression arguments to the
[[ command's =~ operator slightly differently, resulting in more
consistent behavior.
2. Changes to Readline
a. Fixed a bug that could cause readline to crash and seg fault attempting to
expand an empty history entry.
b. Fixed a bug that caused a bad entry in the $LS_COLORS variable to abort all
color processing but leave color enabled.
c. Fixed a bug that caused display problems with multi-line prompts containing
invisible characters on multiple lines.
d. Fixed a bug that caused effects made by undoing changes to a history line to
be discarded.
3. New Features in Bash
4. New Features in Readline
a. When creating shared libraries on Mac OS X, the pathname written into the
library (install_name) no longer includes the minor version number.
------------------------------------------------------------------------------
This document details the changes between this version, bash-4.3-rc1, and the
previous version, bash-4.3-beta2.
1. Changes to Bash
a. Fixed a bug in bash completion that caused a tilde to be expanded even if
the `direxpand' option was not enabled.
b. Fixed a potential bug that could cause corrupted input in interactive shells
running without line editing and with `ignoreeof' enabled.
c. Fixed a bug that could cause failures when opening pipes back to shells
created to run process substitutions.
d. Fixed a bug that caused an assignment to TEXTDOMAIN to require TEXTDOMAINDIR
to be set in order to actually change the current text domain.
e. Changed the way redirections are printed to avoid confusion when the target
of an output redirection is a process substitution beginning with `>'.
2. Changes to Readline
a. Shared library building is now supported on Mac OS X 10.9 (Darwin 13).
3. New Features in Bash
a. `cd' has a new `-@' option to browse a file's extended attributes on
systems that support O_XATTR.
4. New Features in Readline
a. There are additional default key bindings for MinGW32
------------------------------------------------------------------------------
This document details the changes between this version, bash-4.3-beta2, and the
previous version, bash-4.3-beta.
1. Changes to Bash
a. Fixed a bug that caused assignment to an unset variable using a negative
subscript to result in a segmentation fault.
b. Fixed a bug that caused assignment to a string variable using a negative
subscript to use the incorrect index.
c. Fixed a bug that caused some strings to be interpreted as invalid
extended globbing expressions when used with the help builtin.
d. Fixed a bug that caused an attempt to trap a signal whose disposition
cannot be changed to reference uninitialized memory.
e. Command completion now skips assignment statements preceding a command
name and completes the command.
f. Fixed a bug that caused `compgen -f' in a non-interactive shell to dump
core under certain circumstances.
g. Fixed a bug that caused the `read -N' to misbehave when the input stream
contains 0xff.
2. Changes to Readline
a. Changed message when an incremental search fails to include "failed" in
the prompt and display the entire search string instead of just the last
matching portion.
b. Fixed a bug that caused an arrow key typed to an incremental search prompt
to process the key sequence incorrectly.
c. Additional key bindings for arrow keys on MinGW.
3. New Features in Bash
a. The help builtin now attempts substring matching (as it did through
bash-4.2) if exact string matching fails.
b. The fc builtin now interprets -0 as the current command line.
c. Completing directory names containing shell variables now adds a trailing
slash if the expanded result is a directory.
4. New Features in Readline
a. rl_change_environment: new application-settable variable that controls
whether or not Readline modifies the environment (currently readline
modifies only LINES and COLUMNS).
------------------------------------------------------------------------------
This document details the changes between this version, bash-4.3-beta, and the
previous version, bash-4.3-alpha.
1. Changes to Bash
a. Fixed a bug in the prompt directory name "trimming" code that caused
memory corruption and garbled the results.
b. Fixed a bug that caused single quotes that resulted from $'...' quoting
in the replacement portion of a double-quoted ${word/pat/rep} expansion
to be treated as quote characters.
c. Fixed a bug that caused assignment statements preceding a command word to
result in assignment statements following a declaration command to not be
expanded like assignment statements.
d. Fixed a bug with variable search order in the presence of local variables
with the same name as variables in the temporary environment supplied to
a shell function.
e. Fixed a bug that caused constructs like 1<(2) to be interpreted as process
substitutions even in an arithmetic context.
f. Fixed several cases where `invisible' variables (variables with attributes
but no values, which are technically unset) were treated incorrectly.
g. Fixed a bug that caused group commands in pipelines that were not the
last element to not run the EXIT trap.
h. Fixed a bug that caused `unset -n' to not unset a nameref variable in
certain cases.
i. Fixed the nameref circular reference checking to be less strict and only
disallow a nameref variable with the same value as its name at the global
scope.
j. Fixed a bug that caused trap handlers to be executed recursively,
corrupting internal data structures.
k. Fixed a bug that could result in bash not compiling if certain options were
not enabled.
l. Fixed a bug that caused the arithmetic expansion code to attempt variable
assignments when operator precedence prohibited them.
m. Word expansions like ${foo##bar} now understand indirect variable references.
n. Fixed a bug that caused `declare -fp name' to not display a function
definition.
o. Fixed a bug that caused asynchronous child processes to modify the stdin
file pointer when bash was using it to read a script, which modified the
parent's value as well.
2. Changes to Readline
a. Fixed a bug in vi mode that caused the arrow keys to set the saved last
vi-mode command to the wrong value.
b. Fixed a bug that caused double-quoted strings to be scanned incorrectly
when being used as the value of a readline variable assignment.
c. Fixed a bug with vi mode that prevented `.' from repeating a command
entered on a previous line (command).
d. Fixed a bug that could cause completion to core dump if it was interrupted
by a signal.
e. Readline now sends the meta-key enable string to the terminal if the
terminal has been successfully initialized.
f. Readline now calls the signal hook after resizing the terminal when it
receives a SIGWINCH.
g. Fixed a bug that could cause the history list code to perform an out-of-
bounds array reference if the history list is empty.
3. New Features in Bash
a. Shells started to run process substitutions now run any trap set on EXIT.
b. There is now a configure-time option to enable the globasciiranges option
by default.
c. The read builtin now checks its first variable argument for validity before
trying to read any input.
------------------------------------------------------------------------------
This document details the changes between this version, bash-4.3-alpha,
and the previous version, bash-4.2-release.
1. Changes to Bash
a. Fixed several bugs concerning incomplete bracket expressions in filename
generation (globbing) patterns.
b. Fixed a bug with single quotes and WORD in ${param op WORD} when running
in Posix mode.
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.
e. Fixed a bug that caused the RHS of an assignment statement to undergo
word splitting when it contained an unquoted $@.
f. Fixed bugs that caused the shell to not react to a SIGINT sent while
waiting for a child process to exit.
g. Bash doesn't try to run things in a signal handler context when it gets a
signal (SIGINT/SIGHUP/etc) while reading input using readline but still
be responsive to terminating signals.
h. Fixed a bug that caused bash to go into an infinite loop if a filename
to be matched contained an invalid multibyte character.
i. Fixed a bug that caused PS4 to end up being truncated if it is longer
than 128 bytes.
j. Fixed a bug that caused brace expansion to not skip over double-quoted
command substitution.
k. System-specific updates for: DJGPP, HP/UX, Mac OS X
l. Fixed a bug in displaying commands that caused redirections to be associated
with the wrong part of the command.
m. Fixed the coproc cleanup to unset the appropriate shell variables when a
coproc terminates.
n. Fixed a bug that caused `fc' to dump core due to incorrect calculation of
the last history entry.
o. Added workarounds for FreeBSD's implementation of faccessat/eaccess and
`test -x'.
p. Fixed a bug that caused the shell to not match patterns containing
control-A.
q. Fixed a bug that could result in doubled error messages when the `printf'
builtin got a write error.
r. Fixed a bug that caused the shell to not correctly expand words containing
multiple consecutive quoted empty strings (""""""aa).
s. Fixed a bug that caused the shell to not correctly parse multi-line
process substitutions containing comments and quoted strings.
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,
in an effort to make foo=( [ind1]=bar [ind2]=baz ) identical to
foo[ind1]=bar foo[ind2]=baz.
v. Bash now reports an error if `read -a name' is used when `name' is an
existing associative array.
w. Fixed a bug that allowed an attempted assignment to a readonly variable
in an arithmetic expression to not return failure.
x. Fixed several bugs that caused completion functions to be invoked even when
the cursor was before the first word in the command.
y. Fixed a bug that caused parsing a command substitution to overwrite the
parsing state associated with the complete input line.
z. Fixed several bugs with the built-in snprintf replacement and field widths
and floating point.
aa. Fixed a bug that caused incorrect offset calculations and input buffer
corruption when reading files longer than 2^31 bytes.
bb. Fixed several bugs where bash performed arithmetic evaluation in contexts
where evaluation is suppressed.
cc. Fixed a bug that caused bash to close FIFOs used for process substitution
too early when a shell function was executing, but protect against using
all file descriptors when the shell functions are invoked inside loops.
dd. Added checks for printable (and non-printable) multibyte characters for
use in error messages.
ee. Fixed a bug that caused ^O (operate-and-get-next) to not work correctly
at the end of the history list.
ff. Fixed a bug that caused command-oriented history to incorrectly combine
here documents into one line.
gg. Fixed a bug that caused importing SHELLOPTS from the environment into a
Posix-mode shell to print an error message and refuse to parse it.
hh. Fixed a bug that caused the shell to delete an extra history entry when
using `history -s'.
ii. Fixed a bug that caused floating-point exceptions and overflow errors
for the / and % arithmetic operators when using INTMAX_MIN and -1.
jj. Fixed a bug that caused parsing errors when reading an arithmetic for
loop inside a command substitution.
kk. Fixed a bug that caused a readonly function to be unset when unset was
called without the -f or -v option.
ll. Fixed several bugs in the code that quotes characters special to regular
expressions when used in a quoted string on the RHS of the =~ operator
to the [[ command.
mm. Fixed a bug that caused redirections to fail because the file descriptor
limit was set to a value less than 10.
nn. Fixed a bug that caused the `read' builtin to execute code in a signal
handler context if read timed out.
oo. Fixed a bug that caused extended globbing patterns to not match files
beginning with `.' correctly when a `.' was explicitly supplied in the
pattern.
pp. Fixed a bug that caused key sequences longer than two characters to not
work when used with `bind -x'.
qq. Fixed a bug that resulted in redefined functions having the wrong source
file names in BASH_SOURCE.
rr. Fixed a bug that caused the read builtin to assign null strings to variables
when using `read -N', which caused core dumps when referenced
ss. Fixed a bug that caused `bash -m script' to not enable job control while
running the script.
tt. Fixed a bug that caused `printf -v var' to dump core when used with the
%b format code.
uu. Fixed a bug that caused the shell to exit with the wrong status if -e was
active and the shell exited on a substitution error.
vv. Fixed a bug that caused the shell to seg fault if an array variable with
the same name as an existing associative array was implicitly created by
an assignment (declare a[n]=b).
ww. Fixed a bug that caused a redirection to misbehave if the number specified
for a file descriptor overflows an intmax_t.
xx. Fixed several bugs with the handling of valid and invalid unicode character
values when used with the \u and \U escape sequences to printf and $'...'.
yy. Fixed a bug that caused tildes to not be escaped in expanded filenames,
making them subject to later expansion.
zz. When using the pattern substitution word expansion, bash now runs the
replacement string through quote removal, since it allows quotes in that
string to act as escape characters. This is not backwards compatible, so
it can be disabled by setting the bash compatibility mode to 4.2.
aaa. Fixed the rest of the cases where the shell runs non-allowed code in a
signal handler context.
bbb. Fixed a bug that caused spurious DEL characters (\177) to appear in
double-quoted expansion where the RHS is evaluated to the empty string.
ccc. Fixed a bug that caused the use of the shell's internal random number
generator for temporary file names to perturb the random number
sequence.
ddd. Fixed several bugs that caused `declare -g' to not set the right global
variables or to misbehave when declaring global indexed arrays.
eee. Fixed a logic bug that caused extended globbing in a multibyte locale to
cause failures when using the pattern substititution word expansions.
fff. Fixed a bug that caused the `lastpipe' option to corrupt the file
descriptor used to read the script.
ggg. Fixed a bug that causes the shell to delete DEL characters in the
expanded value of variables used in the same quoted string as variables
that expand to nothing.
hhh. Fixed a bug that caused the shell to assign the wrong value from an
assignment like (( x=7 )) when `x' was an existing array variable.
iii. Fixed a bug that caused the shell to misbehave when generating sequences
and the boundary values overflow an intmax_t.
jjj. Fixed a bug caused expansion errors if an expansion of "$@" appeared
next to another expansion (e.g.. "${@}${x}").
kkk. Fixed a potential buffer overflow bug when performing /dev/fd expansion.
lll. Fixed a bug that resulted in an extra semicolon being added to compound
assignments when they were added to the history list.
mmm. Fixed a bug that caused mapfile to read one extra line from the input.
nnn. Fixed a bug that caused the mail checking code to use uninitialized
values.
ooo. Fixed a bug that prevented history timestamps from being saved if the
history comment character is unset.
ppp. Fixed a bug that caused the case-modifying expansions to not work with
multibyte characters.
qqq. Fixed a bug that caused the edit-and-execute bindable readline command
to see the wrong data if invoked in the middle of a multi-line quoted
string.
rrr. Fixed a bug that resulted in the shell returning the wrong exit status
for a background command on systems that recycle PIDs very quickly.
sss. Fixed a bug that caused asynchronous group commands to not run any EXIT
trap defined in the body of the command.
ttt. Fixed a bug that caused `eval "... ; return"' to not clean up properly.
uuu. Fixed a bug that caused the shell to dump core if `read' reads an escaped
IFS whitespace character.
vvv. Fixed a bug that caused BASH_COMMAND to be set to an incorrect value when
executing a (...) subshell.
www. Fixed a couple of pointer aliasing bugs with the token string in arithmetic
evaluation.
xxx. Fixed a bug with parsing multi-line command substitutions when reading
the `do' keyword followed by whitespace.
yyy. Fixed a bug that caused the shell to seg fault if the time given to the
printf %(...)T format overflowed the value accepted by localtime(3).
zzz. Fixed a problem with displaying help topics in two columns when the
translated text contained multibyte characters.
aaaa. Fixed a bug with the extended globbing pattern matcher where a `*' was
followed by a negated extended glob pattern.
bbbb. Fixed a race condition with short-lived coproc creation and reaping that
caused the child process to be reaped before the various coproc shell
variables were initialized.
cccc. Fixed a bug where turning off `errexit' in command substitution subshells
was not reflected in $SHELLOPTS.
dddd. Partially fixed an inconsistency in how the shell treated shell
functions run from an EXIT trap.
eeee. Fixed a bug in how the shell invalidated FIFOs used for process
substitution when executing a pipeline (once rather than in every child).
ffff. Fixed a bug that occurred when expanding a special variable ($@, $*)
within double quotes and the expansion resulted in an empty string.
gggg. Fixed bugs with executing a SIGCHLD trap handler to make sure that it's
executed once per exited child.
hhhh. Fixed a bug that caused `declare' and `test' to find variables that
had been given attributes but not assigned values. Such variables are
not set.
iiii. Fixed a bug that caused commands in process substitutions to not look in
the local temporary environment when performing word expansions.
jjjj. Fixed several problems with globstar expansions (**/**) returning null
filenames and multiple instances of the same pathname.
kkkk. Fixed an oversight that did not allow the exit status of `coproc' to
be inverted using `!'.
llll. Fixed a bug that caused the -e option to be re-enabled using `set -e'
even when executing in a context where -e is ignored.
mmmm. Fixed a (mostly theoretical) bug with input lines longer than SIZE_MAX.
nnnn. Fixed a bug that could result in double evaluation of command
substitutions when they appear in failed redirections.
oooo. Fixed a bug that could cause seg faults during `mapfile' callbacks if
the callback unsets the array variable mapfile is using.
pppp. Fixed several problems with variable assignments using ${var:=value}
when the variable assignment is supposed to have side effects.
qqqq. Fixed a bug that caused a failure of an assignment statement preceding a
builtin caused the next invocation of a special builtin to exit the shell.
rrrr. Fixed several problems with IFS when it appears in the temporary environment
and is used in redirections.
ssss. Fixed a problem that caused IFS changes using ${IFS:=value} to modify
how preceding expansions were split.
tttt. Fixed a problem that caused subshells to not run an EXIT trap they set.
uuuu. Fixed a problem that caused shells started in posix mode to attempt to
import shell functions with invalid names from the environment. We now
print a warning.
vvvv. Worked around a kernel problem that caused SIGCHLD to interrupt open(2)
on a FIFO used for process substitution, even if the SIGCHLD handler was
installed with the SA_RESTART flag.
wwww. Fixed a problem that resulted in inconsistent expansion of $* and ${a[*]}.
xxxx. Fixed a problem that caused `read -t' to crash when interrupted by
SIGINT.
yyyy. Fixed a problem that caused pattern removal to fail randomly because the
pattern matcher read beyond the end of a string.
zzzz. Fixed a bug that caused core dumps when shell functions tried to create
local shadow copies of special variables like GROUPS.
aaaaa. Fixed a bug that caused SIGTERM to be occasionally lost by children of
interactive shells when it arrived before the child process reset the
handler from SIG_DFL.
bbbbb. Fixed a bug that caused redirections like <&n- to leave file descriptor
n closed if executed with a builtin command.
ccccc. Fixed a bug that caused incorrect completion quoting when completing a
word containing a globbing character with `show-all-if-ambiguous' set.
ddddd. Fixed a bug that caused printf's %q format specifier not to quote a
tilde even if it appeared in a location where it would be subject to
tilde expansion.
2. Changes to Readline
a. Fixed a bug that did not allow the `dd', `cc', or `yy' vi editing mode
commands to work on the entire line.
b. Fixed a bug that caused redisplay problems with prompts longer than 128
characters and history searches.
c. Fixed a bug that caused readline to try and run code to modify its idea
of the screen size in a signal handler context upon receiving a SIGWINCH.
d. Fixed a bug that caused the `meta' key to be enabled beyond the duration
of an individual call top readline().
e. Added a workaround for a wcwidth bug in Mac OS X that caused readline's
redisplay to mishandle zero-width combining characters.
f. Fixed a bug that caused readline to `forget' part of a key sequence when
a multiple-key sequence caused it to break out of an incremental search.
g. Fixed bugs that caused readline to execute code in a signal handler
context if interrupted while reading from the file system during completion.
h. Fixed a bug that caused readline to `forget' part of a key sequence when
reading an unbound multi-character key sequence.
i. Fixed a bug that caused Readline's signal handlers to be installed beyond
the bounds of a single call to readline().
j. Fixed a bug that caused the `.' command to not redo the most recent `R'
command in vi mode.
k. Fixed a bug that caused ignoring case in completion matches to result in
readline using the wrong match.
l. Paren matching now works in vi insert mode.
m. Fix menu-completion to make show-all-if-ambiguous and menu-complete-display-prefix
work together.
n. Fixed a bug that didn't allow the `cc', `dd', or `yy' commands to be redone
in vi editing mode.
o. Fixed a bug that caused the filename comparison code to not compare
multibyte characters correctly when using case-sensitive or case-mapping
comparisons.
p. Fixed the input reading loop to call the input hook function only when there
is no terminal input available.
q. Fixed a bug that caused binding a macro to a multi-character key sequence
where the sequence and macro value share a common prefix to not perform
the macro replacement.
r. Fixed several redisplay errors with multibyte characters and prompts
containing invisible characters when using horizontal scrolling.
s. Fixed a bug that caused redisplay errors when trying to overwrite
existing characters using multibyte characters.
3. New Features in Bash
a. The `helptopic' completion action now maps to all the help topics, not just
the shell builtins.
b. The `help' builtin no longer does prefix substring matching, so `help read'
does not match `readonly'.
c. The shell can be compiled to not display a message about processes that
terminate due to SIGTERM.
d. Non-interactive shells now react to the setting of checkwinsize and set
LINES and COLUMNS after a foreground job exits.
e. There is a new shell option, `globasciiranges', which, when set to on,
forces globbing range comparisons to use character ordering as if they
were run in the C locale.
f. There is a new shell option, `direxpand', which makes filename completion
expand variables in directory names in the way bash-4.1 did.
g. In Posix mode, the `command' builtin does not change whether or not a
builtin it shadows is treated as an assignment builtin.
h. The `return' and `exit' builtins accept negative exit status arguments.
i. The word completion code checks whether or not a filename containing a
shell variable expands to a directory name and appends `/' to the word
as appropriate. The same code expands shell variables in command names
when performing command completion.
j. In Posix mode, it is now an error to attempt to define a shell function
with the same name as a Posix special builtin.
k. When compiled for strict Posix conformance, history expansion is disabled
by default.
l. The history expansion character (!) does not cause history expansion when
followed by the closing quote in a double-quoted string.
m. `complete' and its siblings compgen/compopt now takes a new `-o noquote'
option to inhibit quoting of the completions.
n. Setting HISTSIZE to a value less than zero causes the history list to be
unlimited (setting it 0 zero disables the history list).
o. Setting HISTFILESIZE to a value less than zero causes the history file size
to be unlimited (setting it to 0 causes the history file to be truncated
to zero size).
p. The `read' builtin now skips NUL bytes in the input.
q. There is a new `bind -X' option to print all key sequences bound to Unix
commands.
r. When in Posix mode, `read' is interruptible by a trapped signal. After
running the trap handler, read returns 128+signal and throws away any
partially-read input.
s. The command completion code skips whitespace and assignment statements
before looking for the command name word to be completed.
t. The build process has a new mechanism for constructing separate help files
that better reflects the current set of compilation options.
u. The -nt and -ot options to test now work with files with nanosecond
timestamp resolution.
v. The shell saves the command history in any shell for which history is
enabled and HISTFILE is set, not just interactive shells.
w. The shell has `nameref' variables and new -n(/+n) options to declare and
unset to use them, and a `test -R' option to test for them.
x. The shell now allows assigning, referencing, and unsetting elements of
indexed arrays using negative subscripts (a[-1]=2, echo ${a[-1]}) which
count back from the last element of the array.
y. The {x}<word redirection feature now allows words like {array[ind]} and
can use variables with special meanings to the shell (e.g., BASH_XTRACEFD).
z. There is a new CHILD_MAX special shell variable; its value controls the
number of exited child statues the shell remembers.
aa. There is a new configuration option (--enable-direxpand-default) that
causes the `direxpand' shell option to be enabled by default.
bb. Bash does not do anything special to ensure that the file descriptor
assigned to X in {x}<foo remains open after the block containing it
completes.
cc. The `wait' builtin has a new `-n' option to wait for the next child to
change status.
dd. The `printf' %(...)T format specifier now uses the current time if no
argument is supplied.
ee. There is a new variable, BASH_COMPAT, that controls the current shell
compatibility level.
ff. The `popd' builtin now treats additional arguments as errors.
gg. The brace expansion code now treats a failed sequence expansion as a
simple string and will continue to expand brace terms in the remainder
of the word.
4. New Features in Readline
a. Readline is now more responsive to SIGHUP and other fatal signals when
reading input from the terminal or performing word completion but no
longer attempts to run any not-allowable functions from a signal handler
context.
b. There are new bindable commands to search the history for the string of
characters between the beginning of the line and the point
(history-substring-search-forward, history-substring-search-backward)
c. Readline allows quoted strings as the values of variables when setting
them with `set'. As a side effect, trailing spaces and tabs are ignored
when setting a string variable's value.
d. The history library creates a backup of the history file when writing it
and restores the backup on a write error.
e. New application-settable variable: rl_filename_stat_hook: a function called
with a filename before using it in a call to stat(2). Bash uses it to
expand shell variables so things like $HOME/Downloads have a slash
appended.
f. New bindable function `print-last-kbd-macro', prints the most-recently-
defined keyboard macro in a reusable format.
g. New user-settable variable `colored-stats', enables use of colored text
to denote file types when displaying possible completions (colored analog
of visible-stats).
h. New user-settable variable `keyseq-timout', acts as an inter-character
timeout when reading input or incremental search strings.
i. New application-callable function: rl_clear_history. Clears the history list
and frees all readline-associated private data.
j. New user-settable variable, show-mode-in-prompt, adds a characters to the
beginning of the prompt indicating the current editing mode.
k. New application-settable variable: rl_input_available_hook; function to be
called when readline needs to check whether there is data available on its
input source. The default hook checks rl_instream.
l. Readline calls an application-set event hook (rl_signal_event_hook) after
it gets a signal while reading input (read returns -1/EINTR but readline
does not handle the signal immediately) to allow the application to handle
or otherwise note it. Not currently called for SIGHUP or SIGTERM.
m. If the user-settable variable `history-size' is set to a value less than
0, the history list size is unlimited.
------------------------------------------------------------------------------
This document details the changes between this version, bash-4.2-release,
and the previous version, bash-4.2-rc2.

64
COMPAT
View file

@ -2,11 +2,13 @@ Compatibility with previous versions
====================================
This document details the incompatibilities between this version of bash,
bash-4.1, and the previous widely-available versions, bash-2.x (which is
still the `standard' version for a few Linux distributions) and bash-3.x.
These were discovered by users of bash-2.x and 3.x, so this list is not
comprehensive. Some of these incompatibilities occur between the current
version and versions 2.0 and above.
bash-4.3, and the previous widely-available versions, bash-3.x (which is
still the `standard' version for Mac OS X), 4.0/4.1 (which are still
standard on a few Linux distributions), and bash-4.2, the current
widely-available version. These were discovered by users of bash-2.x
through 4.x, so this list is not comprehensive. Some of these
incompatibilities occur between the current version and versions 2.0 and
above.
1. Bash uses a new quoting syntax, $"...", to do locale-specific
string translation. Users who have relied on the (undocumented)
@ -334,30 +336,58 @@ version and versions 2.0 and above.
behavior (ASCII collating and strcmp(3)) by setting one of the
`compatNN' shopt options, where NN is less than 41.
45. Command substitutions now remove the caller's trap strings when trap is
45. Bash-4.1 conforms to the current Posix specification for `set -u':
expansions of $@ and $* when there are no positional parameters do not
cause the shell to exit.
46. Bash-4.1 implements the current Posix specification for `set -e' and
exits when any command fails, not just a simple command or pipeline.
47. Command substitutions now remove the caller's trap strings when trap is
run to set a new trap in the subshell. Previous to bash-4.2, the old
trap strings persisted even though the actual signal handlers were reset.
46. When in Posix mode, a single quote is not treated specially in a
48. When in Posix mode, a single quote is not treated specially in a
double-quoted ${...} expansion, unless the expansion operator is
# or % or the new `//', `^', or `,' expansions. In particular, it
does not define a new quoting context. This is from Posix interpretation
221.
47. Posix mode shells no longer exit if a variable assignment error occurs
49. Posix mode shells no longer exit if a variable assignment error occurs
with an assignment preceding a command that is not a special builtin.
50. Bash-4.2 attempts to preserve what the user typed when performing word
completion, instead of, for instance, expanding shell variable
references to their value.
51. When in Posix mode, bash-4.2 exits if the filename supplied as an argument
to `.' is not found and the shell is not interactive.
52. When compiled for strict Posix compatibility, bash-4.3 does not enable
history expansion by default in interactive shells, since it results in
a non-conforming environment.
53. Bash-4.3 runs the replacement string in the pattern substitution word
expansion through quote removal. The code already treats quote
characters in the replacement string as special; if it treats them as
special, then quote removal should remove them.
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, and
compat41 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 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).
Bash-4.3 introduces 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.
compat31 set
- the < and > operators to the [[ command do not consider the current
@ -378,11 +408,15 @@ compat40 set
compat41 set
- interrupting a command list such as "a ; b ; c" causes the execution
of the entire list to be aborted (in versions before bash-4.0,
of the entire list to be aborted (in versions before bash-4.1,
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
compat42 set
- the replacement string in double-quoted pattern substitution is not
run through quote removal, as in previous versions
-------------------------------------------------------------------------------
Copying and distribution of this file, with or without modification,

File diff suppressed because it is too large Load diff

25
INSTALL
View file

@ -47,8 +47,8 @@ out how `configure' could check whether or not to do them, and mail
diffs or instructions to <bash-maintainers@gnu.org> so they can be
considered for the next release.
The file `configure.in' is used to create `configure' by a program
called Autoconf. You only need `configure.in' if you want to change it
The file `configure.ac' is used to create `configure' by a program
called Autoconf. You only need `configure.ac' if you want to change it
or regenerate `configure' using a newer version of Autoconf. If you do
this, make sure you are using Autoconf version 2.50 or newer.
@ -252,9 +252,9 @@ The `minimal-config' option can be used to disable all of the following
options, but it is processed first, so individual options may be
enabled using `enable-FEATURE'.
All of the following options except for `disabled-builtins' and
`xpg-echo-default' are enabled by default, unless the operating system
does not provide the necessary support.
All of the following options except for `disabled-builtins',
`directpand-default', and `xpg-echo-default' are enabled by default,
unless the operating system does not provide the necessary support.
`--enable-alias'
Allow alias expansion and include the `alias' and `unalias'
@ -308,6 +308,11 @@ does not provide the necessary support.
`--enable-debugger'
Include support for the bash debugger (distributed separately).
`--enable-direxpand-default'
Cause the `direxpand' shell option (*note The Shopt Builtin::) to
be enabled by default when the shell starts. It is normally
disabled by default.
`--enable-directory-stack'
Include support for a `csh'-like directory stack and the `pushd',
`popd', and `dirs' builtins (*note The Directory Stack::).
@ -330,6 +335,12 @@ does not provide the necessary support.
Set the default value of the EXTGLOB shell option described above
under *note The Shopt Builtin:: to be enabled.
`--enable-glob-asciirange-default'
Set the default value of the GLOBASCIIRANGES shell option described
above under *note The Shopt Builtin:: to be enabled. This
controls the behavior of character ranges when used in pattern
matching bracket expressions.
`--enable-help-builtin'
Include the `help' builtin, which displays help on shell builtins
and variables (*note Bash Builtins::).
@ -363,8 +374,8 @@ does not provide the necessary support.
`--enable-prompt-string-decoding'
Turn on the interpretation of a number of backslash-escaped
characters in the `$PS1', `$PS2', `$PS3', and `$PS4' prompt
strings. See *note Printing a Prompt::, for a complete list of
prompt string escape sequences.
strings. See *note Controlling the Prompt::, for a complete list
of prompt string escape sequences.
`--enable-readline'
Include support for command-line editing and history with the Bash

338
MANIFEST
View file

@ -10,14 +10,14 @@ builtins d
cross-build d
doc d
examples d
examples/obashdb d
#examples/obashdb d
examples/complete d
examples/functions d
examples/scripts d
examples/scripts.v2 d
examples/scripts.noah d
#examples/scripts.v2 d
#examples/scripts.noah d
examples/startup-files d
examples/startup-files/apple d
#examples/startup-files/apple d
examples/misc d
examples/loadables d
examples/loadables/perl d
@ -33,6 +33,7 @@ lib/readline/examples d
lib/sh d
lib/termcap d
lib/tilde d
m4 d
po d
support d
tests d
@ -51,7 +52,7 @@ README f
RBASH f
AUTHORS f
Y2K f
configure.in f
configure.ac f
configure f 755
Makefile.in f
config-top.h f
@ -169,6 +170,7 @@ builtins/exec.def f
builtins/exit.def f
builtins/fc.def f
builtins/fg_bg.def f
builtins/gen-helpfiles.c f
builtins/getopt.c f
builtins/getopt.h f
builtins/getopts.def f
@ -223,6 +225,7 @@ include/posixwait.h f
include/shmbchar.h f
include/shmbutil.h f
include/shtty.h f
include/stat-time.h f
include/stdc.h f
include/systimes.h f
include/typemax.h f
@ -338,6 +341,8 @@ lib/readline/mbutil.c f
lib/readline/misc.c f
lib/readline/nls.c f
lib/readline/shell.c f
lib/readline/colors.c f
lib/readline/parse-colors.c f
lib/readline/savestring.c f
lib/readline/tilde.c f
lib/readline/tilde.h f
@ -361,6 +366,8 @@ lib/readline/posixstat.h f
lib/readline/ansi_stdlib.h f
lib/readline/rlstdc.h f
lib/readline/rlprivate.h f
lib/readline/colors.h f
lib/readline/parse-colors.h f
lib/readline/xmalloc.h f
lib/readline/doc/Makefile f
lib/readline/doc/version.texi f
@ -378,6 +385,7 @@ lib/readline/examples/fileman.c f
lib/readline/examples/manexamp.c f
lib/readline/examples/histexamp.c f
lib/readline/examples/rltest.c f
lib/readline/examples/rl-callbacktest.c f
lib/readline/examples/rl.c f
lib/readline/examples/rlcat.c f
lib/readline/examples/Inputrc f
@ -420,6 +428,7 @@ lib/sh/spell.c f
lib/sh/strcasecmp.c f
lib/sh/strcasestr.c f
lib/sh/strchrnul.c f
lib/sh/strdup.c f
lib/sh/strerror.c f
lib/sh/strftime.c f
lib/sh/stringlist.c f
@ -443,6 +452,7 @@ lib/sh/ufuncs.c f
lib/sh/unicode.c f
lib/sh/vprint.c f
lib/sh/wcsdup.c f
lib/sh/wcsnwidth.c f
lib/sh/wcswidth.c f
lib/sh/winsize.c f
lib/sh/zcatfd.c f
@ -461,6 +471,8 @@ lib/tilde/Makefile.in f
lib/tilde/tilde.c f
lib/tilde/tilde.h f
lib/tilde/shell.c f
m4/stat-time.m4 f
m4/timespec.m4 f
po/LINGUAS f
po/Makefile.in.in f
po/Makevars f
@ -484,8 +496,12 @@ po/ca.gmo f
po/ca.po f
po/cs.gmo f
po/cs.po f
po/da.gmo f
po/da.po f
po/de.gmo f
po/de.po f
po/el.gmo f
po/el.po f
po/eo.gmo f
po/eo.po f
po/es.gmo f
@ -498,10 +514,16 @@ po/fr.gmo f
po/fr.po f
po/ga.gmo f
po/ga.po f
po/gl.gmo f
po/gl.po f
po/hr.gmo f
po/hr.po f
po/hu.gmo f
po/hu.po f
po/id.gmo f
po/id.po f
po/it.gmo f
po/it.po f
po/ja.gmo f
po/ja.po f
po/lt.gmo f
@ -518,6 +540,10 @@ po/ru.gmo f
po/ru.po f
po/sk.gmo f
po/sk.po f
po/sl.gmo f
po/sr.po f
po/sr.gmo f
po/sl.po f
po/sv.gmo f
po/sv.po f
po/tr.gmo f
@ -543,7 +569,6 @@ CWRU/PLATFORMS f
CWRU/README f
CWRU/changelog f
CWRU/sh-redir-hack f
CWRU/mh-folder-comp f
doc/FAQ f
doc/Makefile.in f
doc/bash.1 f
@ -561,6 +586,28 @@ doc/htmlpost.sh f 755
doc/infopost.sh f 755
doc/fdl.texi f
doc/fdl.txt f
#
doc/article.ps f
doc/rose94.ps f
doc/bash.ps f
doc/bashbug.ps f
doc/builtins.ps f
doc/rbash.ps f
doc/bashref.ps f
doc/bashref.dvi f
doc/bash.0 f
doc/bashbug.0 f
doc/builtins.0 f
doc/rbash.0 f
doc/article.txt f
doc/bash.html f
doc/bashref.html f
doc/article.pdf f
doc/bash.pdf f
doc/bashref.pdf f
doc/rose94.pdf f
doc/aosa-bash.pdf f
#
support/Makefile.in f
support/bashversion.c f
support/checkbashisms f 755
@ -593,16 +640,17 @@ support/shobj-conf f 755
support/rlvers.sh f 755
examples/INDEX.txt f
examples/INDEX.html f
examples/obashdb/PERMISSION f
examples/obashdb/README f
examples/obashdb/bashdb f
examples/obashdb/bashdb.el f
#examples/obashdb/PERMISSION f
#examples/obashdb/README f
#examples/obashdb/bashdb f
#examples/obashdb/bashdb.el f
examples/complete/bash_completion f
examples/complete/cdfunc f
examples/complete/complete-examples f
examples/complete/complete.ianmac f
examples/complete/complete2.ianmac f
examples/complete/complete.freebsd f
examples/complete/complete.gnu-longopt f
#examples/complete/complete.ianmac f
#examples/complete/complete2.ianmac f
#examples/complete/complete.freebsd f
#examples/complete/complete.gnu-longopt f
examples/complete/bashcc-1.0.1.tar.gz f
examples/loadables/README f
examples/loadables/template.c f
@ -614,11 +662,11 @@ examples/loadables/realpath.c f
examples/loadables/sleep.c f
examples/loadables/strftime.c f
examples/loadables/truefalse.c f
examples/loadables/getconf.h f
examples/loadables/getconf.c f
#examples/loadables/getconf.h f
#examples/loadables/getconf.c f
examples/loadables/finfo.c f
examples/loadables/cat.c f
examples/loadables/cut.c f
#examples/loadables/cut.c f
examples/loadables/logname.c f
examples/loadables/basename.c f
examples/loadables/dirname.c f
@ -641,87 +689,91 @@ examples/loadables/perl/Makefile.in f
examples/loadables/perl/README f
examples/loadables/perl/bperl.c f
examples/loadables/perl/iperl.c f
#examples/loadables/sprintf.c f
#examples/loadables/xtitle.c f
examples/functions/array-stuff f
examples/functions/array-to-string f
examples/functions/autoload f
examples/functions/autoload.v2 f
examples/functions/autoload.v3 f
examples/functions/basename f
examples/functions/basename2 f
examples/functions/coproc.bash f
examples/functions/coshell.README f
examples/functions/coshell.bash f
#examples/functions/basename2 f
#examples/functions/coproc.bash f
#examples/functions/coshell.README f
#examples/functions/coshell.bash f
examples/functions/csh-compat f
examples/functions/dirfuncs f
#examples/functions/dirfuncs f
examples/functions/dirname f
examples/functions/emptydir f
#examples/functions/emptydir f
examples/functions/exitstat f
examples/functions/external f
examples/functions/fact f
examples/functions/fstty f
examples/functions/func f
examples/functions/gethtml f
examples/functions/getoptx.bash f
#examples/functions/gethtml f
#examples/functions/getoptx.bash f
examples/functions/inetaddr f
examples/functions/inpath f
examples/functions/isnum.bash f
#examples/functions/isnum.bash f
examples/functions/isnum2 f
examples/functions/isvalidip f
examples/functions/jdate.bash f
examples/functions/jj.bash f
examples/functions/keep f
#examples/functions/jdate.bash f
#examples/functions/jj.bash f
#examples/functions/keep f
examples/functions/ksh-cd f
examples/functions/ksh-compat-test f
examples/functions/kshenv f
examples/functions/login f
examples/functions/lowercase f
examples/functions/manpage f
examples/functions/mhfold f
#examples/functions/lowercase f
#examples/functions/manpage f
#examples/functions/mhfold f
#examples/functions/newdirstack.bsh f
examples/functions/notify.bash f
examples/functions/pathfuncs f
examples/functions/recurse f
examples/functions/repeat2 f
examples/functions/repeat3 f
#examples/functions/pathfuncs f
#examples/functions/recurse f
#examples/functions/repeat2 f
#examples/functions/repeat3 f
examples/functions/seq f
examples/functions/seq2 f
examples/functions/shcat f
examples/functions/shcat2 f
examples/functions/sort-pos-params f
#examples/functions/sqroot f
examples/functions/substr f
examples/functions/substr2 f
examples/functions/term f
#examples/functions/term f
examples/functions/whatis f
examples/functions/whence f
examples/functions/which f
examples/functions/xalias.bash f
examples/functions/xfind.bash f
examples/scripts/adventure.sh f
examples/scripts/bash-hexdump.sh f
examples/scripts/bcsh.sh f
#examples/functions/xalias.bash f
#examples/functions/xfind.bash f
#examples/scripts/adventure.sh f
#examples/scripts/bash-hexdump.sh f
#examples/scripts/bcsh.sh f
examples/scripts/cat.sh f
examples/scripts/center f
examples/scripts/dd-ex.sh f
examples/scripts/fixfiles.bash f
examples/scripts/hanoi.bash f
#examples/scripts/dd-ex.sh f
#examples/scripts/fixfiles.bash f
#examples/scripts/hanoi.bash f
examples/scripts/inpath f
examples/scripts/krand.bash f
examples/scripts/line-input.bash f
examples/scripts/nohup.bash f
examples/scripts/precedence f
examples/scripts/randomcard.bash f
examples/scripts/scrollbar f
examples/scripts/scrollbar2 f
examples/scripts/self-repro f
examples/scripts/showperm.bash f
#examples/scripts/krand.bash f
#examples/scripts/line-input.bash f
#examples/scripts/nohup.bash f
#examples/scripts/precedence f
#examples/scripts/randomcard.bash f
#examples/scripts/scrollbar f
#examples/scripts/scrollbar2 f
#examples/scripts/self-repro f
#examples/scripts/showperm.bash f
examples/scripts/shprompt f
examples/scripts/spin.bash f
examples/scripts/timeout f
examples/scripts/timeout2 f
examples/scripts/timeout3 f
examples/scripts/vtree2 f
examples/scripts/vtree3 f
examples/scripts/vtree3a f
examples/scripts/websrv.sh f
#examples/scripts/timeout f
#examples/scripts/timeout2 f
#examples/scripts/timeout3 f
#examples/scripts/vtree2 f
#examples/scripts/vtree3 f
#examples/scripts/vtree3a f
#examples/scripts/websrv.sh f
examples/scripts/xterm_title f
examples/scripts/zprintf f
examples/startup-files/README f
@ -730,14 +782,14 @@ examples/startup-files/Bash_aliases f
examples/startup-files/Bash_profile f
examples/startup-files/bash-profile f
examples/startup-files/bashrc f
examples/startup-files/apple/README f
examples/startup-files/apple/aliases f
examples/startup-files/apple/bash.defaults f
examples/startup-files/apple/environment f
examples/startup-files/apple/login f
examples/startup-files/apple/logout f
examples/startup-files/apple/rc f
examples/misc/suncmd.termcap f
#examples/startup-files/apple/README f
#examples/startup-files/apple/aliases f
#examples/startup-files/apple/bash.defaults f
#examples/startup-files/apple/environment f
#examples/startup-files/apple/login f
#examples/startup-files/apple/logout f
#examples/startup-files/apple/rc f
#examples/misc/suncmd.termcap f
examples/misc/aliasconv.sh f
examples/misc/aliasconv.bash f
examples/misc/cshtobash f
@ -747,6 +799,8 @@ tests/alias.tests f
tests/alias1.sub f
tests/alias.right f
tests/appendop.tests f
tests/appendop1.sub f
tests/appendop2.sub f
tests/appendop.right f
tests/arith-for.tests f
tests/arith-for.right f
@ -756,6 +810,8 @@ tests/arith1.sub f
tests/arith2.sub f
tests/arith3.sub f
tests/arith4.sub f
tests/arith5.sub f
tests/arith6.sub f
tests/array.tests f
tests/array.right f
tests/array1.sub f
@ -768,6 +824,12 @@ tests/array7.sub f
tests/array8.sub f
tests/array9.sub f
tests/array10.sub f
tests/array11.sub f
tests/array12.sub f
tests/array13.sub f
tests/array14.sub f
tests/array15.sub f
tests/array16.sub f
tests/array-at-star f
tests/array2.right f
tests/assoc.tests f
@ -778,6 +840,7 @@ tests/assoc3.sub f
tests/assoc4.sub f
tests/assoc5.sub f
tests/assoc6.sub f
tests/assoc7.sub f
tests/braces.tests f
tests/braces.right f
tests/builtins.tests f
@ -785,14 +848,17 @@ tests/builtins.right f
tests/builtins1.sub f
tests/builtins2.sub f
tests/builtins3.sub f
tests/builtins4.sub f
tests/source1.sub f
tests/source2.sub f
tests/source3.sub f
tests/source4.sub f
tests/source5.sub f
tests/source6.sub f
tests/source7.sub f
tests/case.tests f
tests/case.right f
tests/case1.sub f
tests/casemod.tests f
tests/casemod.right f
tests/comsub.tests f
@ -813,7 +879,9 @@ tests/comsub-posix2.sub f
tests/comsub-posix3.sub f
tests/cond.tests f
tests/cond.right f
tests/cond-regexp.sub f
tests/cond-regexp1.sub f
tests/cond-regexp2.sub f
tests/cond-regexp3.sub f
tests/coproc.tests f
tests/coproc.right f
tests/cprint.tests f
@ -825,14 +893,20 @@ tests/dbg-support2.right f
tests/dbg-support2.tests f
tests/dbg-support3.sub f
tests/dollar-at-star f
tests/dollar-at-star1.sub f
tests/dollar-at1.sub f
tests/dollar-at2.sub f
tests/dollar-at3.sub f
tests/dollar-at4.sub f
tests/dollar-at5.sub f
tests/dollar-at6.sub f
tests/dollar-star1.sub f
tests/dollar-star2.sub f
tests/dollar-star3.sub f
tests/dollar-star4.sub f
tests/dollar-star5.sub f
tests/dollar-star6.sub f
tests/dollar-star7.sub f
tests/dollar.right f
tests/dstack.tests f
tests/dstack.right f
@ -840,6 +914,9 @@ tests/dstack2.tests f
tests/dstack2.right f
tests/errors.tests f
tests/errors.right f
tests/errors1.sub f
tests/errors2.sub f
tests/errors3.sub f
tests/execscript f
tests/exec.right f
tests/exec1.sub f 755
@ -857,9 +934,12 @@ tests/exp1.sub f
tests/exp2.sub f
tests/exp3.sub f
tests/exp4.sub f
tests/exp5.sub f
tests/exp6.sub f
tests/extglob.tests f
tests/extglob.right f
tests/extglob1.sub f
tests/extglob1a.sub f
tests/extglob2.tests f
tests/extglob2.right f
tests/extglob3.tests f
@ -885,9 +965,12 @@ tests/glob.right f
tests/globstar.tests f
tests/globstar.right f
tests/globstar1.sub f
tests/globstar2.sub f
tests/heredoc.tests f
tests/heredoc.right f
tests/heredoc1.sub f
tests/heredoc2.sub f
tests/heredoc3.sub f
tests/herestr.tests f
tests/herestr.right f
tests/histexp.tests f
@ -910,6 +993,7 @@ tests/intl2.sub f
tests/intl.right f
tests/iquote.tests f
tests/iquote.right f
tests/iquote1.sub f
tests/invert.tests f
tests/invert.right f
tests/jobs.tests f
@ -917,6 +1001,7 @@ tests/jobs1.sub f
tests/jobs2.sub f
tests/jobs3.sub f
tests/jobs4.sub f
tests/jobs5.sub f
tests/jobs.right f
tests/lastpipe.right f
tests/lastpipe.tests f
@ -927,6 +1012,16 @@ tests/mapfile.tests f
tests/mapfile1.sub f
tests/more-exp.tests f
tests/more-exp.right f
tests/nameref.tests f
tests/nameref1.sub f
tests/nameref2.sub f
tests/nameref3.sub f
tests/nameref4.sub f
tests/nameref5.sub f
tests/nameref6.sub f
tests/nameref7.sub f
tests/nameref8.sub f
tests/nameref.right f
tests/new-exp.tests f
tests/new-exp1.sub f
tests/new-exp2.sub f
@ -936,10 +1031,12 @@ tests/new-exp5.sub f
tests/new-exp6.sub f
tests/new-exp7.sub f
tests/new-exp8.sub f
tests/new-exp9.sub f
tests/new-exp.right f
tests/nquote.tests f
tests/nquote.right f
tests/nquote1.sub f
tests/nquote2.sub f
tests/nquote1.tests f
tests/nquote1.right f
tests/nquote2.tests f
@ -969,8 +1066,10 @@ tests/printf.right f
tests/printf1.sub f
tests/printf2.sub f
tests/printf3.sub f
tests/printf4.sub f
tests/quote.tests f
tests/quote.right f
tests/quote1.sub f
tests/read.tests f
tests/read.right f
tests/read1.sub f
@ -993,8 +1092,10 @@ tests/redir6.sub f
tests/redir7.sub f
tests/redir8.sub f
tests/redir9.sub f
tests/redir10.sub f
tests/rhs-exp.tests f
tests/rhs-exp.right f
tests/rhs-exp1.sub f
tests/rsh.tests f
tests/rsh.right f
tests/run-all f
@ -1044,6 +1145,7 @@ tests/run-jobs f
tests/run-lastpipe f
tests/run-mapfile f
tests/run-more-exp f
tests/run-nameref f
tests/run-new-exp f
tests/run-nquote f
tests/run-nquote1 f
@ -1077,6 +1179,8 @@ tests/run-vredir f
tests/set-e.tests f
tests/set-e1.sub f
tests/set-e2.sub f
tests/set-e3.sub f
tests/set-e3a.sub f
tests/set-e.right f
tests/set-x.tests f
tests/set-x1.sub f
@ -1097,15 +1201,25 @@ tests/trap1.sub f 755
tests/trap2.sub f 755
tests/trap2a.sub f 755
tests/trap3.sub f
tests/trap4.sub f
tests/trap5.sub f
tests/type.tests f
tests/type.right f
tests/type1.sub f
tests/type2.sub f
tests/type3.sub f
tests/type4.sub f
tests/unicode1.sub f
tests/unicode2.sub f
tests/unicode3.sub f
tests/varenv.right f
tests/varenv.sh f
tests/varenv1.sub f
tests/varenv2.sub f
tests/varenv3.sub f
tests/varenv4.sub f
tests/varenv5.sub f
tests/varenv6.sub f
tests/version f
tests/version.mini f
tests/vredir.tests f
@ -1129,45 +1243,45 @@ tests/misc/sigint-4.sh f
tests/misc/test-minus-e.1 f
tests/misc/test-minus-e.2 f
tests/misc/wait-bg.tests f
examples/scripts.v2/PERMISSION f
examples/scripts.v2/README f
examples/scripts.v2/arc2tarz f
examples/scripts.v2/bashrand f
examples/scripts.v2/cal2day.bash f
examples/scripts.v2/cdhist.bash f
examples/scripts.v2/corename f
examples/scripts.v2/fman f
examples/scripts.v2/frcp f
examples/scripts.v2/lowercase f
examples/scripts.v2/ncp f
examples/scripts.v2/newext f
examples/scripts.v2/nmv f
examples/scripts.v2/pages f
examples/scripts.v2/pf f
examples/scripts.v2/ren f
examples/scripts.v2/rename f
examples/scripts.v2/repeat f
examples/scripts.v2/untar f
examples/scripts.v2/uudec f
examples/scripts.v2/uuenc f
examples/scripts.v2/vtree f
examples/scripts.v2/where f
examples/scripts.v2/pmtop f
examples/scripts.v2/shprof f
examples/scripts.noah/PERMISSION f
examples/scripts.noah/README f
examples/scripts.noah/aref.bash f
examples/scripts.noah/bash.sub.bash f
examples/scripts.noah/bash_version.bash f
examples/scripts.noah/meta.bash f
examples/scripts.noah/mktmp.bash f
examples/scripts.noah/number.bash f
examples/scripts.noah/prompt.bash f
examples/scripts.noah/remap_keys.bash f
examples/scripts.noah/require.bash f
examples/scripts.noah/send_mail.bash f
examples/scripts.noah/shcat.bash f
examples/scripts.noah/source.bash f
examples/scripts.noah/string.bash f
examples/scripts.noah/stty.bash f
examples/scripts.noah/y_or_n_p.bash f
#examples/scripts.v2/PERMISSION f
#examples/scripts.v2/README f
#examples/scripts.v2/arc2tarz f
#examples/scripts.v2/bashrand f
#examples/scripts.v2/cal2day.bash f
#examples/scripts.v2/cdhist.bash f
#examples/scripts.v2/corename f
#examples/scripts.v2/fman f
#examples/scripts.v2/frcp f
#examples/scripts.v2/lowercase f
#examples/scripts.v2/ncp f
#examples/scripts.v2/newext f
#examples/scripts.v2/nmv f
#examples/scripts.v2/pages f
#examples/scripts.v2/pf f
#examples/scripts.v2/ren f
#examples/scripts.v2/rename f
#examples/scripts.v2/repeat f
#examples/scripts.v2/untar f
#examples/scripts.v2/uudec f
#examples/scripts.v2/uuenc f
#examples/scripts.v2/vtree f
#examples/scripts.v2/where f
#examples/scripts.v2/pmtop f
#examples/scripts.v2/shprof f
#examples/scripts.noah/PERMISSION f
#examples/scripts.noah/README f
#examples/scripts.noah/aref.bash f
#examples/scripts.noah/bash.sub.bash f
#examples/scripts.noah/bash_version.bash f
#examples/scripts.noah/meta.bash f
#examples/scripts.noah/mktmp.bash f
#examples/scripts.noah/number.bash f
#examples/scripts.noah/prompt.bash f
#examples/scripts.noah/remap_keys.bash f
#examples/scripts.noah/require.bash f
#examples/scripts.noah/send_mail.bash f
#examples/scripts.noah/shcat.bash f
#examples/scripts.noah/source.bash f
#examples/scripts.noah/string.bash f
#examples/scripts.noah/stty.bash f
#examples/scripts.noah/y_or_n_p.bash f

View file

@ -1,6 +1,6 @@
# Makefile for bash-4.2, version 4.4
# Makefile for bash-4.3, version 4.11
#
# Copyright (C) 1996-2010 Free Software Foundation, Inc.
# Copyright (C) 1996-2012 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -26,6 +26,8 @@ PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_VERSION = @PACKAGE_VERSION@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
# Include some boilerplate Gnu makefile definitions.
prefix = @prefix@
@ -40,6 +42,8 @@ includedir = @includedir@
datadir = @datadir@
localedir = @localedir@
docdir = @docdir@
mandir = @mandir@
manpfx = man
@ -186,7 +190,8 @@ SH_ABSSRC = ${topdir}/${SH_LIBSRC}
SHLIB_SOURCE = ${SH_LIBSRC}/clktck.c ${SH_LIBSRC}/getcwd.c \
${SH_LIBSRC}/getenv.c ${SH_LIBSRC}/oslib.c \
${SH_LIBSRC}/setlinebuf.c ${SH_LIBSRC}/strchrnul.c \
${SH_LIBSRC}/strcasecmp.c ${SH_LIBSRC}/strerror.c \
${SH_LIBSRC}/strcasecmp.c ${SH_LIBSRC}/strdup.c \
${SH_LIBSRC}/strerror.c \
${SH_LIBSRC}/strtod.c ${SH_LIBSRC}/strtol.c \
${SH_LIBSRC}/strtoul.c ${SH_LIBSRC}/vprint.c \
${SH_LIBSRC}/itos.c ${SH_LIBSRC}/rename.c \
@ -215,7 +220,8 @@ SHLIB_SOURCE = ${SH_LIBSRC}/clktck.c ${SH_LIBSRC}/getcwd.c \
${SH_LIBSRC}/ufuncs.c ${SH_LIBSRC}/dprintf.c \
${SH_LIBSRC}/input_avail.c ${SH_LIBSRC}/mbscasecmp.c \
${SH_LIBSRC}/fnxform.c ${SH_LIBSRC}/unicode.c \
${SH_LIBSRC}/wcswidth.c ${SH_LIBSRC}/shmbchar.c
${SH_LIBSRC}/wcswidth.c ${SH_LIBSRC}/wcsnwidth.c \
${SH_LIBSRC}/shmbchar.c
SHLIB_LIB = -lsh
SHLIB_LIBNAME = libsh.a
@ -244,6 +250,7 @@ READLINE_SOURCE = $(RL_LIBSRC)/rldefs.h $(RL_LIBSRC)/rlconf.h \
$(RL_LIBSRC)/posixstat.h $(RL_LIBSRC)/tilde.h \
$(RL_LIBSRC)/rlstdc.h ${RL_LIBSRC}/xmalloc.h \
$(RL_LIBSRC)/rlshell.h ${RL_LIBSRC}/rlprivate.h \
$(RL_LIBSRC)/colors.h $(RL_LIBSRC)/parse-colors.h \
$(RL_LIBSRC)/funmap.c $(RL_LIBSRC)/emacs_keymap.c \
$(RL_LIBSRC)/search.c $(RL_LIBSRC)/vi_keymap.c \
$(RL_LIBSRC)/keymaps.c $(RL_LIBSRC)/parens.c \
@ -257,6 +264,7 @@ READLINE_SOURCE = $(RL_LIBSRC)/rldefs.h $(RL_LIBSRC)/rlconf.h \
$(RL_LIBSRC)/terminal.c $(RL_LIBSRC)/nls.c \
$(RL_LIBSRC)/input.c $(RL_LIBSRC)/xmalloc.c \
$(RL_LIBSRC)/shell.c $(RL_LIBSRC)/savestring.c \
$(RL_LIBSRC)/colors.c $(RL_LIBSRC)/parse-colors.c \
$(RL_LIBSRC)/misc.c $(RL_LIBSRC)/mbutil.c $(RL_LIBSRC)/compat.c \
$(RL_LIBSRC)/histexpand.c $(RL_LIBSRC)/history.c \
$(RL_LIBSRC)/histsearch.c $(RL_LIBSRC)/histfile.c
@ -274,7 +282,8 @@ READLINE_OBJ = $(RL_LIBDIR)/readline.o $(RL_LIBDIR)/funmap.o \
$(RL_LIBDIR)/shell.o $(RL_LIBDIR)/savestring.o \
$(RL_LIBDIR)/mbutil.o $(RL_LIBDIR)/compat.o \
$(RL_LIBDIR)/history.o $(RL_LIBDIR)/histexpand.o \
$(RL_LIBDIR)/histsearch.o $(RL_LIBDIR)/histfile.o
$(RL_LIBDIR)/histsearch.o $(RL_LIBDIR)/histfile.o \
$(RL_LIBDIR)/colors.o $(RL_LIBDIR)/parse-colors.o
HIST_LIBSRC = $(LIBSRC)/readline
HIST_LIBDIR = @HIST_LIBDIR@
@ -530,6 +539,10 @@ CREATED_MAKEFILES = Makefile builtins/Makefile doc/Makefile \
examples/loadables/perl/Makefile support/Makefile \
lib/intl/Makefile po/Makefile po/Makefile.in
OTHER_DOCS = $(srcdir)/CHANGES $(srcdir)/COMPAT $(srcdir)/NEWS $(srcdir)/POSIX \
$(srcdir)/RBASH $(srcdir)/README
OTHER_INSTALLED_DOCS = CHANGES COMPAT NEWS POSIX RBASH README
# Keep GNU Make from exporting the entire environment for small machines.
.NOEXPORT:
@ -572,30 +585,34 @@ version.h: $(SOURCES) config.h Makefile patchlevel.h
&& mv newversion.h version.h
bashversion$(EXEEXT): patchlevel.h conftypes.h version.h buildversion.o $(SUPPORT_SRC)bashversion.c
$(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) -o $@ $(SUPPORT_SRC)bashversion.c buildversion.o ${LIBS_FOR_BUILD}
$(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
$(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) -DBUILDTOOL -c -o $@ $(srcdir)/version.c
# old rules
GRAM_H = parser-built
y.tab.o: y.tab.c ${GRAM_H} command.h ${BASHINCDIR}/stdc.h input.h
y.tab.o: y.tab.h y.tab.c ${GRAM_H} command.h ${BASHINCDIR}/stdc.h input.h
${GRAM_H}: y.tab.h
@-if test -f y.tab.h ; then \
cmp -s $@ y.tab.h 2>/dev/null || cp -p y.tab.h $@; \
fi
y.tab.c y.tab.h: parse.y
y.tab.c: parse.y
# -if test -f y.tab.h; then mv -f y.tab.h old-y.tab.h; fi
$(YACC) -d $(srcdir)/parse.y
touch parser-built
# -if cmp -s old-y.tab.h y.tab.h; then mv old-y.tab.h y.tab.h; else cp -p y.tab.h ${GRAM_H}; fi
# experimental new rules - work with GNU make but not BSD (or OSF) make
#y.tab.o: y.tab.c y.tab.h
#y.tab.c y.tab.h: parse.y command.h ${BASHINCDIR}/stdc.h input.h
# -if test -f y.tab.h; then mv -f y.tab.h old-y.tab.h; fi
# $(YACC) -d $(srcdir)/parse.y
# -if cmp -s old-y.tab.h y.tab.h; then mv old-y.tab.h y.tab.h; fi
y.tab.h: y.tab.c
@true
# Subdirs will often times want version.h, so they'll change back up to
# the top level and try to create it. This causes parallel build issues
# so just force top level sanity before we descend.
$(LIBDEP): .build
#$(LIBDEP): version.h
$(READLINE_LIBRARY): config.h $(READLINE_SOURCE)
@echo making $@ in ${RL_LIBDIR}
@ -648,11 +665,11 @@ mksignames.o: $(SUPPORT_SRC)mksignames.c
mksignames$(EXEEXT): mksignames.o buildsignames.o
$(RM) $@
$(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) -o $@ mksignames.o buildsignames.o ${LIBS_FOR_BUILD}
$(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
$(RM) $@
${CC_FOR_BUILD} ${CCFLAGS_FOR_BUILD} -o $@ ${srcdir}/mksyntax.c ${LIBS_FOR_BUILD}
${CC_FOR_BUILD} ${CCFLAGS_FOR_BUILD} ${LDFLAGS_FOR_BUILD} -o $@ ${srcdir}/mksyntax.c ${LIBS_FOR_BUILD}
# make a list of signals for the local system -- this is done when we're
# *not* cross-compiling
@ -668,8 +685,8 @@ syntax.c: mksyntax${EXEEXT} $(srcdir)/syntax.h
$(RM) $@
./mksyntax$(EXEEXT) -o $@
$(BUILTINS_LIBRARY): $(BUILTIN_DEFS) $(BUILTIN_C_SRC) config.h ${BASHINCDIR}/memalloc.h version.h
@(cd $(DEFDIR) && $(MAKE) $(MFLAGS) DEBUG=${DEBUG} libbuiltins.a ) || exit 1
$(BUILTINS_LIBRARY): $(BUILTIN_DEFS) $(BUILTIN_C_SRC) config.h ${BASHINCDIR}/memalloc.h $(DEFDIR)/builtext.h version.h
@(cd $(DEFDIR) && $(MAKE) $(MFLAGS) DEBUG=${DEBUG} targets ) || exit 1
# these require special rules to circumvent make builtin rules
${DEFDIR}/common.o: $(BUILTIN_SRCDIR)/common.c
@ -710,7 +727,7 @@ pathnames.h: Makefile $(srcdir)/pathnames.h.in
@${RM} pathnames.tmp
# comment out for distribution
$(srcdir)/configure: $(srcdir)/configure.in $(srcdir)/aclocal.m4 $(srcdir)/config.h.in
$(srcdir)/configure: $(srcdir)/configure.ac $(srcdir)/aclocal.m4 $(srcdir)/config.h.in
cd $(srcdir) && autoconf
# for chet
@ -731,6 +748,7 @@ info dvi ps: force
force:
# unused
TAGS: $(SOURCES) $(BUILTIN_C_SRC) $(LIBRARY_SOURCE)
etags $(SOURCES) $(BUILTIN_C_SRC) $(LIBRARY_SOURCE)
@ -743,11 +761,13 @@ installdirs:
@${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(bindir)
@${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(man1dir)
@${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(infodir)
@${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(docdir)
-( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
install: .made installdirs
$(INSTALL_PROGRAM) $(INSTALLMODE) $(Program) $(DESTDIR)$(bindir)/$(Program)
$(INSTALL_SCRIPT) $(INSTALLMODE2) bashbug $(DESTDIR)$(bindir)/bashbug
$(INSTALL_DATA) $(OTHER_DOCS) $(DESTDIR)$(docdir)
-( cd $(DOCDIR) ; $(MAKE) $(MFLAGS) \
man1dir=$(man1dir) man1ext=$(man1ext) \
man3dir=$(man3dir) man3ext=$(man3ext) \
@ -762,6 +782,7 @@ install-strip:
uninstall: .made
$(RM) $(DESTDIR)$(bindir)/$(Program) $(DESTDIR)$(bindir)/bashbug
-( cd $(DESTDIR)$(docdir) && ${RM} ${OTHER_INSTALLED_DOCS} )
-( cd $(DOCDIR) ; $(MAKE) $(MFLAGS) \
man1dir=$(man1dir) man1ext=$(man1ext) \
man3dir=$(man3dir) man3ext=$(man3ext) \
@ -827,16 +848,16 @@ maybe-clean:
fi
recho$(EXEEXT): $(SUPPORT_SRC)recho.c
@$(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) -o $@ $(SUPPORT_SRC)recho.c ${LIBS_FOR_BUILD}
@$(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) ${LDFLAGS_FOR_BUILD} -o $@ $(SUPPORT_SRC)recho.c ${LIBS_FOR_BUILD}
zecho$(EXEEXT): $(SUPPORT_SRC)zecho.c
@$(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) -o $@ $(SUPPORT_SRC)zecho.c ${LIBS_FOR_BUILD}
@$(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) ${LDFLAGS_FOR_BUILD} -o $@ $(SUPPORT_SRC)zecho.c ${LIBS_FOR_BUILD}
printenv$(EXEEXT): $(SUPPORT_SRC)printenv.c
@$(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) -o $@ $(SUPPORT_SRC)printenv.c ${LIBS_FOR_BUILD}
@$(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) ${LDFLAGS_FOR_BUILD} -o $@ $(SUPPORT_SRC)printenv.c ${LIBS_FOR_BUILD}
xcase$(EXEEXT): $(SUPPORT_SRC)xcase.c
@$(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) -o $@ $(SUPPORT_SRC)xcase.c ${LIBS_FOR_BUILD}
@$(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) ${LDFLAGS_FOR_BUILD} -o $@ $(SUPPORT_SRC)xcase.c ${LIBS_FOR_BUILD}
test tests check: force $(Program) $(TESTS_SUPPORT)
@-test -d tests || mkdir tests
@ -1014,6 +1035,7 @@ sig.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array
sig.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
sig.o: make_cmd.h subst.h sig.h pathnames.h externs.h
sig.o: jobs.h siglist.h trap.h $(DEFSRC)/common.h bashline.h bashhist.h
sig.o: ${DEFDIR}/builtext.h
siglist.o: config.h bashtypes.h siglist.h trap.h
stringlib.o: bashtypes.h ${BASHINCDIR}/chartypes.h
stringlib.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
@ -1056,6 +1078,7 @@ 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: version.h $(DEFDIR)/builtext.h
version.o: conftypes.h patchlevel.h version.h
xmalloc.o: config.h bashtypes.h ${BASHINCDIR}/ansi_stdlib.h error.h
@ -1120,6 +1143,7 @@ pcomplete.o: ${BASHINCDIR}/stdc.h hashlib.h pcomplete.h shell.h syntax.h
pcomplete.o: bashjmp.h command.h general.h xmalloc.h error.h variables.h arrayfunc.h conftypes.h quit.h
pcomplete.o: unwind_prot.h dispose_cmd.h make_cmd.h subst.h sig.h pathnames.h
pcomplete.o: externs.h ${BASHINCDIR}/maxpath.h execute_cmd.h
pcomplete.o: ${DEFDIR}/builtext.h
# library support files
@ -1139,6 +1163,7 @@ bashline.o: make_cmd.h subst.h sig.h pathnames.h externs.h
bashline.o: builtins.h bashhist.h bashline.h execute_cmd.h findcmd.h pathexp.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
bracecomp.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
bracecomp.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h
bracecomp.o: command.h ${BASHINCDIR}/stdc.h error.h
@ -1383,7 +1408,7 @@ builtins/shopt.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h
builtins/shopt.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h
builtins/shopt.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h unwind_prot.h variables.h arrayfunc.h conftypes.h ${BASHINCDIR}/maxpath.h
builtins/shopt.o: $(DEFSRC)/common.h $(DEFSRC)/bashgetopt.h pathnames.h
builtins/shopt.o: bashhist.h
builtins/shopt.o: bashhist.h bashline.h
builtins/source.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
builtins/source.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/source.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h

184
NEWS
View file

@ -1,3 +1,187 @@
This is a terse description of the new features added to bash-4.3 since
the release of bash-4.2. As always, the manual page (doc/bash.1) is
the place to look for complete descriptions.
1. New Features in Bash
a. The `helptopic' completion action now maps to all the help topics, not just
the shell builtins.
b. The `help' builtin no longer does prefix substring matching first, so
`help read' does not match `readonly', but will do it if exact string
matching fails.
c. The shell can be compiled to not display a message about processes that
terminate due to SIGTERM.
d. Non-interactive shells now react to the setting of checkwinsize and set
LINES and COLUMNS after a foreground job exits.
e. There is a new shell option, `globasciiranges', which, when set to on,
forces globbing range comparisons to use character ordering as if they
were run in the C locale.
f. There is a new shell option, `direxpand', which makes filename completion
expand variables in directory names in the way bash-4.1 did.
g. In Posix mode, the `command' builtin does not change whether or not a
builtin it shadows is treated as an assignment builtin.
h. The `return' and `exit' builtins accept negative exit status arguments.
i. The word completion code checks whether or not a filename containing a
shell variable expands to a directory name and appends `/' to the word
as appropriate. The same code expands shell variables in command names
when performing command completion.
j. In Posix mode, it is now an error to attempt to define a shell function
with the same name as a Posix special builtin.
k. When compiled for strict Posix conformance, history expansion is disabled
by default.
l. The history expansion character (!) does not cause history expansion when
followed by the closing quote in a double-quoted string.
m. `complete' and its siblings compgen/compopt now takes a new `-o noquote'
option to inhibit quoting of the completions.
n. Setting HISTSIZE to a value less than zero causes the history list to be
unlimited (setting it 0 zero disables the history list).
o. Setting HISTFILESIZE to a value less than zero causes the history file size
to be unlimited (setting it to 0 causes the history file to be truncated
to zero size).
p. The `read' builtin now skips NUL bytes in the input.
q. There is a new `bind -X' option to print all key sequences bound to Unix
commands.
r. When in Posix mode, `read' is interruptible by a trapped signal. After
running the trap handler, read returns 128+signal and throws away any
partially-read input.
s. The command completion code skips whitespace and assignment statements
before looking for the command name word to be completed.
t. The build process has a new mechanism for constructing separate help files
that better reflects the current set of compilation options.
u. The -nt and -ot options to test now work with files with nanosecond
timestamp resolution.
v. The shell saves the command history in any shell for which history is
enabled and HISTFILE is set, not just interactive shells.
w. The shell has `nameref' variables and new -n(/+n) options to declare and
unset to use them, and a `test -R' option to test for them.
x. The shell now allows assigning, referencing, and unsetting elements of
indexed arrays using negative subscripts (a[-1]=2, echo ${a[-1]}) which
count back from the last element of the array.
y. The {x}<word redirection feature now allows words like {array[ind]} and
can use variables with special meanings to the shell (e.g., BASH_XTRACEFD).
z. There is a new CHILD_MAX special shell variable; its value controls the
number of exited child statues the shell remembers.
aa. There is a new configuration option (--enable-direxpand-default) that
causes the `direxpand' shell option to be enabled by default.
bb. Bash does not do anything special to ensure that the file descriptor
assigned to X in {x}<foo remains open after the block containing it
completes.
cc. The `wait' builtin has a new `-n' option to wait for the next child to
change status.
dd. The `printf' %(...)T format specifier now uses the current time if no
argument is supplied.
ee. There is a new variable, BASH_COMPAT, that controls the current shell
compatibility level.
ff. The `popd' builtin now treats additional arguments as errors.
gg. The brace expansion code now treats a failed sequence expansion as a
simple string and will continue to expand brace terms in the remainder
of the word.
hh. Shells started to run process substitutions now run any trap set on EXIT.
ii. The fc builtin now interprets -0 as the current command line.
jj. Completing directory names containing shell variables now adds a trailing
slash if the expanded result is a directory.
kk. `cd' has a new `-@' option to browse a file's extended attributes on
systems that support O_XATTR.
ll. The test/[/[[ `-v variable' binary operator now understands array
references.
2. New Features in Readline
a. Readline is now more responsive to SIGHUP and other fatal signals when
reading input from the terminal or performing word completion but no
longer attempts to run any not-allowable functions from a signal handler
context.
b. There are new bindable commands to search the history for the string of
characters between the beginning of the line and the point
(history-substring-search-forward, history-substring-search-backward)
c. Readline allows quoted strings as the values of variables when setting
them with `set'. As a side effect, trailing spaces and tabs are ignored
when setting a string variable's value.
d. The history library creates a backup of the history file when writing it
and restores the backup on a write error.
e. New application-settable variable: rl_filename_stat_hook: a function called
with a filename before using it in a call to stat(2). Bash uses it to
expand shell variables so things like $HOME/Downloads have a slash
appended.
f. New bindable function `print-last-kbd-macro', prints the most-recently-
defined keyboard macro in a reusable format.
g. New user-settable variable `colored-stats', enables use of colored text
to denote file types when displaying possible completions (colored analog
of visible-stats).
h. New user-settable variable `keyseq-timout', acts as an inter-character
timeout when reading input or incremental search strings.
i. New application-callable function: rl_clear_history. Clears the history list
and frees all readline-associated private data.
j. New user-settable variable, show-mode-in-prompt, adds a characters to the
beginning of the prompt indicating the current editing mode.
k. New application-settable variable: rl_input_available_hook; function to be
called when readline detects there is data available on its input file
descriptor.
l. Readline calls an application-set event hook (rl_event_hook) after it gets
a signal while reading input (read returns -1/EINTR but readline does not
handle the signal immediately) to allow the application to handle or
otherwise note it.
m. If the user-settable variable `history-size' is set to a value less than
0, the history list size is unlimited.
n. New application-settable variable: rl_signal_event_hook; function that is
called when readline is reading terminal input and read(2) is interrupted
by a signal. Currently not called for SIGHUP or SIGTERM.
o. rl_change_environment: new application-settable variable that controls
whether or not Readline modifies the environment (currently readline
modifies only LINES and COLUMNS).
-------------------------------------------------------------------------------
This is a terse description of the new features added to bash-4.2 since
the release of bash-4.1. As always, the manual page (doc/bash.1) is
the place to look for complete descriptions.

3
NOTES
View file

@ -6,7 +6,7 @@ Platform-Specific Configuration and Operation Notes
alpha running OSF/1, Linux, or NetBSD (malloc needs 8-byte alignment;
bash malloc has 8-byte alignment now, but I have no alphas to test on)
next running NeXT/OS
next running NeXT/OS; machines running Openstep
all machines running SunOS YP code: SunOS4, SunOS5, HP/UX, if you
have problems with username completion or tilde expansion for
@ -20,6 +20,7 @@ Platform-Specific Configuration and Operation Notes
sparc SVR4, SVR4.2 (ICL reference port)
DG/UX
Cray
Haiku OS
NetBSD/sparc (malloc needs 8-byte alignment; bash malloc has 8-byte
alignment now, but I have no NetBSD machines to test on)

93
POSIX
View file

@ -40,147 +40,164 @@ The following list is what's changed when `POSIX mode' is in effect:
8. Tilde expansion is only performed on assignments preceding a
command name, rather than on all assignment statements on the line.
9. The default history file is `~/.sh_history' (this is the default
9. The `command' builtin does not prevent builtins that take
assignment statements as arguments from expanding them as
assignment statements; when not in POSIX mode, assignment builtins
lose their assignment statement expansion properties when preceded
by `command'.
10. The default history file is `~/.sh_history' (this is the default
value of `$HISTFILE').
10. The output of `kill -l' prints all the signal names on a single
11. The output of `kill -l' prints all the signal names on a single
line, separated by spaces, without the `SIG' prefix.
11. The `kill' builtin does not accept signal names with a `SIG'
12. The `kill' builtin does not accept signal names with a `SIG'
prefix.
12. Non-interactive shells exit if FILENAME in `.' FILENAME is not
13. Non-interactive shells exit if FILENAME in `.' FILENAME is not
found.
13. Non-interactive shells exit if a syntax error in an arithmetic
14. Non-interactive shells exit if a syntax error in an arithmetic
expansion results in an invalid expression.
14. Non-interactive shells exit if there is a syntax error in a script
15. Non-interactive shells exit if there is a syntax error in a script
read with the `.' or `source' builtins, or in a string processed by
the `eval' builtin.
15. Redirection operators do not perform filename expansion on the word
16. Redirection operators do not perform filename expansion on the word
in the redirection unless the shell is interactive.
16. Redirection operators do not perform word splitting on the word in
17. Redirection operators do not perform word splitting on the word in
the redirection.
17. Function names must be valid shell `name's. That is, they may not
18. Function names must be valid shell `name's. That is, they may not
contain characters other than letters, digits, and underscores, and
may not start with a digit. Declaring a function with an invalid
name causes a fatal syntax error in non-interactive shells.
18. POSIX special builtins are found before shell functions during
19. Function names may not be the same as one of the POSIX special
builtins.
20. POSIX special builtins are found before shell functions during
command lookup.
19. The `time' reserved word may be used by itself as a command. When
21. 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.
20. When parsing and expanding a ${...} expansion that appears within
22. 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.
21. The parser does not recognize `time' as a reserved word if the next
23. The parser does not recognize `time' as a reserved word if the next
token begins with a `-'.
22. If a POSIX special builtin returns an error status, a
24. 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
25. 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 exists with an error status if a variable
26. 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 iteration
27. A non-interactive shell exits with an error status if the iteration
variable in a `for' statement or the selection variable in a
`select' statement is a readonly variable.
26. Process substitution is not available.
28. Process substitution is not available.
27. Assignment statements preceding POSIX special builtins persist in
29. While variable indirection is available, it may not be applied to
the `#' and `?' special parameters.
30. Assignment statements preceding POSIX special builtins persist in
the shell environment after the builtin completes.
28. Assignment statements preceding shell function calls persist in the
31. Assignment statements preceding shell function calls persist in the
shell environment after the function returns, as if a POSIX
special builtin command had been executed.
29. The `export' and `readonly' builtin commands display their output
32. The `export' and `readonly' builtin commands display their output
in the format required by POSIX.
30. The `trap' builtin displays signal names without the leading `SIG'.
33. The `trap' builtin displays signal names without the leading `SIG'.
31. The `trap' builtin doesn't check the first argument for a possible
34. 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.
32. The `.' and `source' builtins do not search the current directory
35. The `.' and `source' builtins do not search the current directory
for the filename argument if it is not found by searching `PATH'.
33. Subshells spawned to execute command substitutions inherit the
36. Subshells spawned to execute command substitutions inherit the
value of the `-e' option from the parent shell. When not in POSIX
mode, Bash clears the `-e' option in such subshells.
34. Alias expansion is always enabled, even in non-interactive shells.
37. Alias expansion is always enabled, even in non-interactive shells.
35. When the `alias' builtin displays alias definitions, it does not
38. When the `alias' builtin displays alias definitions, it does not
display them with a leading `alias ' unless the `-p' option is
supplied.
36. When the `set' builtin is invoked without options, it does not
39. When the `set' builtin is invoked without options, it does not
display shell function names and definitions.
37. When the `set' builtin is invoked without options, it displays
40. When the `set' builtin is invoked without options, it displays
variable values without quotes, unless they contain shell
metacharacters, even if the result contains nonprinting characters.
38. When the `cd' builtin is invoked in LOGICAL mode, and the pathname
41. When the `cd' builtin is invoked in LOGICAL mode, and the pathname
constructed from `$PWD' and the directory name supplied as an
argument does not refer to an existing directory, `cd' will fail
instead of falling back to PHYSICAL mode.
39. The `pwd' builtin verifies that the value it prints is the same as
42. The `pwd' builtin verifies that the value it prints is the same as
the current directory, even if it is not asked to check the file
system with the `-P' option.
40. When listing the history, the `fc' builtin does not include an
43. When listing the history, the `fc' builtin does not include an
indication of whether or not a history entry has been modified.
41. The default editor used by `fc' is `ed'.
44. The default editor used by `fc' is `ed'.
42. The `type' and `command' builtins will not report a non-executable
45. The `type' and `command' builtins will not report a non-executable
file as having been found, though the shell will attempt to
execute such a file if it is the only so-named file found in
`$PATH'.
43. The `vi' editing mode will invoke the `vi' editor directly when
46. The `vi' editing mode will invoke the `vi' editor directly when
the `v' command is run, instead of checking `$VISUAL' and
`$EDITOR'.
44. When the `xpg_echo' option is enabled, Bash does not attempt to
47. When the `xpg_echo' option is enabled, Bash does not attempt to
interpret any arguments to `echo' as options. Each argument is
displayed, after escape characters are converted.
45. The `ulimit' builtin uses a block size of 512 bytes for the `-c'
48. The `ulimit' builtin uses a block size of 512 bytes for the `-c'
and `-f' options.
46. The arrival of `SIGCHLD' when a trap is set on `SIGCHLD' does not
49. The arrival of `SIGCHLD' when a trap is set on `SIGCHLD' does not
interrupt the `wait' builtin and cause it to return immediately.
The trap command is run once for each child that exits.
50. The `read' builtin may be interrupted by a signal for which a trap
has been set. If Bash receives a trapped signal while executing
`read', the trap handler executes and `read' returns an exit
status greater than 128.
There is other POSIX behavior that Bash does not implement by default
even when in POSIX mode. Specifically:

9
README
View file

@ -1,7 +1,7 @@
Introduction
============
This is GNU Bash, version 4.2. Bash is the GNU Project's Bourne
This is GNU Bash, version 4.3. 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.0 and
bash-4.1. For details, see the file COMPAT. The NEWS file tersely
of Bash and previous widely-distributed versions, bash-4.1 and
bash-4.2. 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
@ -79,6 +79,9 @@ please send mail to bug-bash@gnu.org with the following information:
The `bashbug' program includes much of this automatically.
Questions and requests for help with bash and bash programming may be
sent to the help-bash@gnu.org mailing list.
If you would like to contact the Bash maintainers directly, send mail
to bash-maintainers@gnu.org.

34
aclocal.m4 vendored
View file

@ -1698,7 +1698,6 @@ AC_CHECK_FUNC(mbscmp, AC_DEFINE(HAVE_MBSCMP))
AC_CHECK_FUNC(mbsnrtowcs, AC_DEFINE(HAVE_MBSNRTOWCS))
AC_CHECK_FUNC(mbsrtowcs, AC_DEFINE(HAVE_MBSRTOWCS))
AC_REPLACE_FUNCS(mbschr)
AC_CHECK_FUNC(wcrtomb, AC_DEFINE(HAVE_WCRTOMB))
@ -1763,6 +1762,33 @@ if test $bash_cv_type_wint_t = yes; then
AC_DEFINE(HAVE_WINT_T, 1, [systems should define this type here])
fi
dnl check for broken wcwidth
AC_CACHE_CHECK([for wcwidth broken with unicode combining characters],
bash_cv_wcwidth_broken,
[AC_TRY_RUN([
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <locale.h>
#include <wchar.h>
main(c, v)
int c;
char **v;
{
int w;
setlocale(LC_ALL, "en_US.UTF-8");
w = wcwidth (0x0301);
exit (w == 0); /* exit 0 if wcwidth broken */
}
],
bash_cv_wcwidth_broken=yes, bash_cv_wcwdith_broken=no, bash_cv_wcwidth_broken=no)])
if test "$bash_cv_wcwidth_broken" = yes; then
AC_DEFINE(WCWIDTH_BROKEN, 1, [wcwidth is usually not broken])
fi
if test "$am_cv_func_iconv" = yes; then
OLDLIBS="$LIBS"
LIBS="$LIBS $LIBICONV"
@ -3098,7 +3124,7 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
found_so=
found_a=
if test $use_additional = yes; then
if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
if test "X$prefer_shared" = "Xyes" && test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
found_dir="$additional_libdir"
found_so="$additional_libdir/lib$name.$shlibext"
if test -f "$additional_libdir/lib$name.la"; then
@ -3120,7 +3146,7 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
case "$x" in
-L*)
dir=`echo "X$x" | sed -e 's/^X-L//'`
if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
if test "X$prefer_shared" = "Xyes" && test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
found_dir="$dir"
found_so="$dir/lib$name.$shlibext"
if test -f "$dir/lib$name.la"; then
@ -4123,7 +4149,7 @@ main()
AC_DEFUN(BASH_STRUCT_WEXITSTATUS_OFFSET,
[AC_MSG_CHECKING(for offset of exit status in return status from wait)
AC_CACHE_VAL(bash_cv_wexitstatus_offset,
[AC_RUN_IFELSE([
[AC_TRY_RUN([
#include <stdlib.h>
#include <unistd.h>

View file

@ -110,7 +110,7 @@ add_alias (name, value)
alias_t *temp;
int n;
if (!aliases)
if (aliases == 0)
{
initialize_aliases ();
temp = (alias_t *)NULL;

46
array.c
View file

@ -58,7 +58,11 @@ static char *array_to_string_internal __P((ARRAY_ELEMENT *, ARRAY_ELEMENT *, cha
static ARRAY *lastarray = 0;
static ARRAY_ELEMENT *lastref = 0;
#define IS_LASTREF(a) ((a) == lastarray)
#define IS_LASTREF(a) (lastarray && (a) == lastarray)
#define LASTREF_START(a, i) \
(IS_LASTREF(a) && i >= element_index(lastref)) ? lastref \
: element_forw(a->head)
#define INVALIDATE_LASTREF(a) \
do { \
@ -610,7 +614,7 @@ ARRAY *a;
arrayind_t i;
char *v;
{
register ARRAY_ELEMENT *new, *ae;
register ARRAY_ELEMENT *new, *ae, *start;
if (a == 0)
return(-1);
@ -627,10 +631,17 @@ char *v;
SET_LASTREF(a, new);
return(0);
}
#if OPTIMIZE_SEQUENTIAL_ARRAY_ASSIGNMENT
/*
* Otherwise we search for the spot to insert it.
* Otherwise we search for the spot to insert it. The lastref
* handle optimizes the case of sequential or almost-sequential
* assignments that are not at the end of the array.
*/
for (ae = element_forw(a->head); ae != a->head; ae = element_forw(ae)) {
start = LASTREF_START(a, i);
#else
start = element_forw(ae->head);
#endif
for (ae = start; ae != a->head; ae = element_forw(ae)) {
if (element_index(ae) == i) {
/*
* Replacing an existing element.
@ -647,6 +658,7 @@ char *v;
return(0);
}
}
array_dispose_element(new);
INVALIDATE_LASTREF(a);
return (-1); /* problem */
}
@ -660,18 +672,28 @@ array_remove(a, i)
ARRAY *a;
arrayind_t i;
{
register ARRAY_ELEMENT *ae;
register ARRAY_ELEMENT *ae, *start;
if (a == 0 || array_empty(a))
return((ARRAY_ELEMENT *) NULL);
for (ae = element_forw(a->head); ae != a->head; ae = element_forw(ae))
start = LASTREF_START(a, i);
for (ae = start; ae != a->head; ae = element_forw(ae))
if (element_index(ae) == i) {
ae->next->prev = ae->prev;
ae->prev->next = ae->next;
a->num_elements--;
if (i == array_max_index(a))
a->max_index = element_index(ae->prev);
#if 0
INVALIDATE_LASTREF(a);
#else
if (ae->next != a->head)
SET_LASTREF(a, ae->next);
else if (ae->prev != a->head)
SET_LASTREF(a, ae->prev);
else
INVALIDATE_LASTREF(a);
#endif
return(ae);
}
return((ARRAY_ELEMENT *) NULL);
@ -685,18 +707,14 @@ array_reference(a, i)
ARRAY *a;
arrayind_t i;
{
register ARRAY_ELEMENT *ae;
register ARRAY_ELEMENT *ae, *start;
if (a == 0 || array_empty(a))
return((char *) NULL);
if (i > array_max_index(a))
return((char *)NULL);
/* Keep roving pointer into array to optimize sequential access */
if (lastref && IS_LASTREF(a))
ae = (i >= element_index(lastref)) ? lastref : element_forw(a->head);
else
ae = element_forw(a->head);
for ( ; ae != a->head; ae = element_forw(ae))
return((char *)NULL); /* Keep roving pointer into array to optimize sequential access */
start = LASTREF_START(a, i);
for (ae = start; ae != a->head; ae = element_forw(ae))
if (element_index(ae) == i) {
SET_LASTREF(a, ae);
return(element_value(ae));

View file

@ -1,6 +1,6 @@
/* arrayfunc.c -- High-level array functions used by other parts of the shell. */
/* Copyright (C) 2001-2010 Free Software Foundation, Inc.
/* Copyright (C) 2001-2011 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -41,6 +41,7 @@ extern int last_command_exit_value;
extern int array_needs_making;
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 char *quote_assign __P((const char *));
static void quote_array_assignment_chars __P((WORD_LIST *));
@ -117,8 +118,8 @@ convert_var_to_assoc (var)
return var;
}
static SHELL_VAR *
bind_array_var_internal (entry, ind, key, value, flags)
char *
make_array_variable_value (entry, ind, key, value, flags)
SHELL_VAR *entry;
arrayind_t ind;
char *key;
@ -155,6 +156,21 @@ bind_array_var_internal (entry, ind, key, value, flags)
else
newval = make_variable_value (entry, value, flags);
return newval;
}
static SHELL_VAR *
bind_array_var_internal (entry, ind, key, value, flags)
SHELL_VAR *entry;
arrayind_t ind;
char *key;
char *value;
int flags;
{
char *newval;
newval = make_array_variable_value (entry, ind, key, value, flags);
if (entry->assign_func)
(*entry->assign_func) (entry, newval, ind, key);
else if (assoc_p (entry))
@ -182,7 +198,7 @@ bind_array_variable (name, ind, value, flags)
{
SHELL_VAR *entry;
entry = var_lookup (name, shell_variables);
entry = find_shell_variable (name);
if (entry == (SHELL_VAR *) 0)
entry = make_new_array_variable (name);
@ -237,8 +253,7 @@ assign_array_element (name, value, flags)
char *name, *value;
int flags;
{
char *sub, *vname, *akey;
arrayind_t ind;
char *sub, *vname;
int sublen;
SHELL_VAR *entry;
@ -255,6 +270,24 @@ assign_array_element (name, value, flags)
}
entry = find_variable (vname);
entry = assign_array_element_internal (entry, name, vname, sub, sublen, value, flags);
free (vname);
return entry;
}
static SHELL_VAR *
assign_array_element_internal (entry, name, vname, sub, sublen, value, flags)
SHELL_VAR *entry;
char *name; /* only used for error messages */
char *vname;
char *sub;
int sublen;
char *value;
int flags;
{
char *akey;
arrayind_t ind;
if (entry && assoc_p (entry))
{
@ -263,25 +296,26 @@ assign_array_element (name, value, flags)
sub[sublen-1] = ']';
if (akey == 0 || *akey == 0)
{
free (vname);
err_badarraysub (name);
FREE (akey);
return ((SHELL_VAR *)NULL);
}
entry = bind_assoc_variable (entry, vname, akey, value, flags);
}
else
{
ind = array_expand_index (sub, sublen);
ind = array_expand_index (entry, sub, sublen);
/* negative subscripts to indexed arrays count back from end */
if (entry && ind < 0)
ind = (array_p (entry) ? array_max_index (array_cell (entry)) : 0) + 1 + ind;
if (ind < 0)
{
free (vname);
err_badarraysub (name);
return ((SHELL_VAR *)NULL);
}
entry = bind_array_variable (vname, ind, value, flags);
}
free (vname);
return (entry);
}
@ -299,6 +333,14 @@ find_or_make_array_variable (name, flags)
SHELL_VAR *var;
var = find_variable (name);
if (var == 0)
{
/* See if we have a nameref pointing to a variable that hasn't been
created yet. */
var = find_variable_last_nameref (name);
if (var && nameref_p (var))
var = (flags & 2) ? make_new_assoc_variable (nameref_cell (var)) : make_new_array_variable (nameref_cell (var));
}
if (var == 0)
var = (flags & 2) ? make_new_assoc_variable (name) : make_new_array_variable (name);
@ -310,6 +352,7 @@ find_or_make_array_variable (name, flags)
}
else if ((flags & 2) && array_p (var))
{
last_command_exit_value = 1;
report_error (_("%s: cannot convert indexed to associative array"), name);
return ((SHELL_VAR *)NULL);
}
@ -370,10 +413,13 @@ expand_compound_array_assignment (var, value, flags)
int flags;
{
WORD_LIST *list, *nlist;
WORD_LIST *hd, *tl, *t, *n;
char *val;
int ni;
/* I don't believe this condition is ever true any more. */
/* This condition is true when invoked from the declare builtin with a
command like
declare -a d='([1]="" [2]="bdef" [5]="hello world" "test")' */
if (*value == '(') /*)*/
{
ni = 1;
@ -390,8 +436,17 @@ expand_compound_array_assignment (var, value, flags)
(ksh93 seems to do this). */
list = parse_string_to_word_list (val, 1, "array assign");
if (var && assoc_p (var))
{
if (val != value)
free (val);
return list;
}
/* If we're using [subscript]=value, we need to quote each [ and ] to
prevent unwanted filename expansion. */
prevent unwanted filename expansion. This doesn't need to be done
for associative array expansion, since that uses a different expansion
function (see assign_compound_array_list below). */
if (list)
quote_array_assignment_chars (list);
@ -418,7 +473,7 @@ assign_compound_array_list (var, nlist, flags)
HASH_TABLE *h;
WORD_LIST *list;
char *w, *val, *nval;
int len, iflags;
int len, iflags, free_val;
arrayind_t ind, last_ind;
char *akey;
@ -448,7 +503,10 @@ assign_compound_array_list (var, nlist, flags)
/* We have a word of the form [ind]=value */
if ((list->word->flags & W_ASSIGNMENT) && w[0] == '[')
{
len = skipsubscript (w, 0, (var && assoc_p (var) != 0));
/* Don't have to handle embedded quotes specially any more, since
associative array subscripts have not been expanded yet (see
above). */
len = skipsubscript (w, 0, 0);
/* XXX - changes for `+=' */
if (w[len] != ']' || (w[len+1] != '=' && (w[len+1] != '+' || w[len+2] != '=')))
@ -476,6 +534,7 @@ assign_compound_array_list (var, nlist, flags)
if (ALL_ELEMENT_SUB (w[1]) && len == 2)
{
last_command_exit_value = 1;
if (assoc_p (var))
report_error (_("%s: invalid associative array key"), w);
else
@ -485,7 +544,10 @@ assign_compound_array_list (var, nlist, flags)
if (array_p (var))
{
ind = array_expand_index (w + 1, len);
ind = array_expand_index (var, w + 1, len);
/* negative subscripts to indexed arrays count back from end */
if (ind < 0)
ind = array_max_index (array_cell (var)) + 1 + ind;
if (ind < 0)
{
err_badarraysub (w);
@ -496,10 +558,15 @@ assign_compound_array_list (var, nlist, flags)
}
else if (assoc_p (var))
{
akey = substring (w, 1, len);
/* This is not performed above, see expand_compound_array_assignment */
w[len] = '\0'; /*[*/
akey = expand_assignment_string_to_string (w+1, 0);
w[len] = ']';
/* And we need to expand the value also, see below */
if (akey == 0 || *akey == 0)
{
err_badarraysub (w);
FREE (akey);
continue;
}
}
@ -511,10 +578,11 @@ assign_compound_array_list (var, nlist, flags)
val = w + len + 3;
}
else
val = w + len + 2;
val = w + len + 2;
}
else if (assoc_p (var))
{
last_command_exit_value = 1;
report_error (_("%s: %s: must use subscript when assigning associative array"), var->name, w);
continue;
}
@ -524,10 +592,21 @@ assign_compound_array_list (var, nlist, flags)
val = w;
}
free_val = 0;
/* See above; we need to expand the value here */
if (assoc_p (var))
{
val = expand_assignment_string_to_string (val, 0);
free_val = 1;
}
if (integer_p (var))
this_command_name = (char *)NULL; /* no command name for errors */
bind_array_var_internal (var, ind, akey, val, iflags);
last_ind++;
if (free_val)
free (val);
}
}
@ -611,12 +690,17 @@ quote_array_assignment_chars (list)
{
if (l->word == 0 || l->word->word == 0 || l->word->word[0] == '\0')
continue; /* should not happen, but just in case... */
/* Don't bother if it doesn't look like [ind]=value */
/* Don't bother if it hasn't been recognized as an assignment or
doesn't look like [ind]=value */
if ((l->word->flags & W_ASSIGNMENT) == 0)
continue;
if (l->word->word[0] != '[' || mbschr (l->word->word, '=') == 0) /* ] */
continue;
nword = quote_assign (l->word->word);
free (l->word->word);
l->word->word = nword;
l->word->flags |= W_NOGLOB; /* XXX - W_NOSPLIT also? */
}
}
@ -655,6 +739,7 @@ unbind_array_element (var, sub)
if (akey == 0 || *akey == 0)
{
builtin_error ("[%s]: %s", sub, _(bash_badsub_errmsg));
FREE (akey);
return -1;
}
assoc_remove (assoc_cell (var), akey);
@ -662,7 +747,10 @@ unbind_array_element (var, sub)
}
else
{
ind = array_expand_index (sub, len+1);
ind = array_expand_index (var, sub, len+1);
/* negative subscripts to indexed arrays count back from end */
if (ind < 0)
ind = array_max_index (array_cell (var)) + 1 + ind;
if (ind < 0)
{
builtin_error ("[%s]: %s", sub, _(bash_badsub_errmsg));
@ -752,7 +840,8 @@ valid_array_reference (name)
/* Expand the array index beginning at S and extending LEN characters. */
arrayind_t
array_expand_index (s, len)
array_expand_index (var, s, len)
SHELL_VAR *var;
char *s;
int len;
{
@ -840,7 +929,11 @@ array_variable_part (s, subp, lenp)
var = find_variable (t);
free (t);
#if 0
return (var == 0 || invisible_p (var)) ? (SHELL_VAR *)0 : var;
#else
return var; /* now return invisible variables; caller must handle */
#endif
}
#define INDEX_ERROR() \
@ -889,6 +982,7 @@ array_value_internal (s, quoted, flags, rtype, indp)
return ((char *)NULL); /* error message already printed */
/* [ */
akey = 0;
if (ALL_ELEMENT_SUB (t[0]) && t[1] == ']')
{
if (rtype)
@ -918,11 +1012,11 @@ array_value_internal (s, quoted, flags, rtype, indp)
if (t[0] == '*' && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)))
{
temp = string_list_dollar_star (l);
retval = quote_string (temp);
retval = quote_string (temp); /* XXX - leak here */
free (temp);
}
else /* ${name[@]} or unquoted ${name[*]} */
retval = string_list_dollar_at (l, quoted);
retval = string_list_dollar_at (l, quoted); /* XXX - leak here */
dispose_words (l);
}
@ -934,7 +1028,7 @@ array_value_internal (s, quoted, flags, rtype, indp)
{
if ((flags & AV_USEIND) == 0 || indp == 0)
{
ind = array_expand_index (t, len);
ind = array_expand_index (var, t, len);
if (ind < 0)
{
/* negative subscripts to indexed arrays count back from end */
@ -955,11 +1049,17 @@ array_value_internal (s, quoted, flags, rtype, indp)
akey = expand_assignment_string_to_string (t, 0); /* [ */
t[len - 1] = ']';
if (akey == 0 || *akey == 0)
INDEX_ERROR();
{
FREE (akey);
INDEX_ERROR();
}
}
if (var == 0 || value_cell (var) == 0) /* XXX - check invisible_p(var) ? */
return ((char *)NULL);
{
FREE (akey);
return ((char *)NULL);
}
if (array_p (var) == 0 && assoc_p (var) == 0)
return (ind == 0 ? value_cell (var) : (char *)NULL);
else if (assoc_p (var))

View file

@ -33,6 +33,8 @@
extern SHELL_VAR *convert_var_to_array __P((SHELL_VAR *));
extern SHELL_VAR *convert_var_to_assoc __P((SHELL_VAR *));
extern char *make_array_variable_value __P((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));
@ -54,7 +56,7 @@ extern int skipsubscript __P((const char *, int, int));
extern void print_array_assignment __P((SHELL_VAR *, int));
extern void print_assoc_assignment __P((SHELL_VAR *, int));
extern arrayind_t array_expand_index __P((char *, int));
extern arrayind_t array_expand_index __P((SHELL_VAR *, char *, int));
extern int valid_array_reference __P((char *));
extern char *array_value __P((char *, int, int, int *, arrayind_t *));
extern char *get_array_value __P((char *, int, int *, arrayind_t *));
@ -64,6 +66,12 @@ extern char *array_keys __P((char *, int));
extern char *array_variable_name __P((char *, char **, int *));
extern SHELL_VAR *array_variable_part __P((char *, char **, int *));
#else
#define AV_ALLOWALL 0
#define AV_QUOTED 0
#define AV_USEIND 0
#endif
#endif /* !_ARRAYFUNC_H_ */

31
assoc.c
View file

@ -7,7 +7,7 @@
* chet@ins.cwru.edu
*/
/* Copyright (C) 2008,2009 Free Software Foundation, Inc.
/* Copyright (C) 2008,2009,2011 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -65,7 +65,7 @@ assoc_flush (hash)
{
hash_flush (hash, 0);
}
int
assoc_insert (hash, key, value)
HASH_TABLE *hash;
@ -87,6 +87,29 @@ assoc_insert (hash, key, value)
return (0);
}
/* Like assoc_insert, but returns b->data instead of freeing it */
PTR_T
assoc_replace (hash, key, value)
HASH_TABLE *hash;
char *key;
char *value;
{
BUCKET_CONTENTS *b;
PTR_T t;
b = hash_search (key, hash, HASH_CREATE);
if (b == 0)
return (PTR_T)0;
/* If we are overwriting an existing element's value, we're not going to
use the key. Nothing in the array assignment code path frees the key
string, so we can free it here to avoid a memory leak. */
if (b->key != key)
free (key);
t = b->data;
b->data = value ? savestring (value) : (char *)0;
return t;
}
void
assoc_remove (hash, string)
HASH_TABLE *hash;
@ -510,7 +533,7 @@ assoc_to_string (h, sep, quoted)
return (savestring (""));
result = NULL;
list = NULL;
l = list = NULL;
/* This might be better implemented directly, but it's simple to implement
by converting to a word list first, possibly quoting the data, then
using list_string */
@ -528,6 +551,8 @@ assoc_to_string (h, sep, quoted)
l = REVERSE_LIST(list, WORD_LIST *);
result = l ? string_list_internal (l, sep) : savestring ("");
dispose_words (l);
return result;
}

View file

@ -38,6 +38,7 @@ extern void assoc_dispose __P((HASH_TABLE *));
extern void assoc_flush __P((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 char *assoc_reference __P((HASH_TABLE *, char *));

View file

@ -1,6 +1,6 @@
/* bashhist.c -- bash interface to the GNU history library. */
/* Copyright (C) 1993-2010 Free Software Foundation, Inc.
/* Copyright (C) 1993-2012 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -24,7 +24,7 @@
#if defined (HAVE_UNISTD_H)
# ifdef _MINIX
# include <sys/types.h>
# include <sys/types.h>
# endif
# include <unistd.h>
#endif
@ -351,6 +351,7 @@ void
save_history ()
{
char *hf;
int r;
hf = get_string_value ("HISTFILE");
if (hf && *hf && file_exists (hf))
@ -360,9 +361,9 @@ save_history ()
using_history ();
if (history_lines_this_session <= where_history () || force_append_history)
append_history (history_lines_this_session, hf);
r = append_history (history_lines_this_session, hf);
else
write_history (hf);
r = write_history (hf);
sv_histsize ("HISTFILESIZE");
}
}
@ -648,8 +649,11 @@ hc_erasedups (line)
commenting out the rest of the command when the entire command is saved as
a single history entry (when COMMAND_ORIENTED_HISTORY is enabled). If
LITERAL_HISTORY is set, we're saving lines in the history with embedded
newlines, so it's OK to save comment lines. We also make sure to save
multiple-line quoted strings or other constructs. */
newlines, so it's OK to save comment lines. If we're collecting the body
of a here-document, we should act as if literal_history is enabled, because
we want to save the entire contents of the here-document as it was
entered. We also make sure to save multiple-line quoted strings or other
constructs. */
void
maybe_add_history (line)
char *line;
@ -662,7 +666,7 @@ maybe_add_history (line)
if (current_command_line_count > 1)
{
if (current_command_first_line_saved &&
(literal_history || dstack.delimiter_depth != 0 || shell_comment (line) == 0))
((parser_state & PST_HEREDOC) || literal_history || dstack.delimiter_depth != 0 || shell_comment (line) == 0))
bash_add_history (line);
return;
}
@ -735,7 +739,17 @@ bash_add_history (line)
add_it = 1;
if (command_oriented_history && current_command_line_count > 1)
{
chars_to_add = literal_history ? "\n" : history_delimiting_chars (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
contains the here-doc specifier). parse.y:history_delimiting_chars()
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')
chars_to_add = "";
else
chars_to_add = literal_history ? "\n" : history_delimiting_chars (line);
using_history ();
current = previous_history ();

View file

@ -1,6 +1,6 @@
/* bashline.c -- Bash's interface to the readline library. */
/* Copyright (C) 1987-2011 Free Software Foundation, Inc.
/* Copyright (C) 1987-2013 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -37,6 +37,8 @@
# include <netdb.h>
#endif
#include <signal.h>
#include <stdio.h>
#include "chartypes.h"
#include "bashansi.h"
@ -51,6 +53,7 @@
#include "findcmd.h"
#include "pathexp.h"
#include "shmbutil.h"
#include "trap.h"
#include "builtins/common.h"
@ -83,7 +86,11 @@ extern int bash_brace_completion __P((int, int));
#endif /* BRACE_COMPLETION */
/* To avoid including curses.h/term.h/termcap.h and that whole mess. */
#ifdef _MINIX
extern int tputs __P((const char *string, int nlines, void (*outx)(int)));
#else
extern int tputs __P((const char *string, int nlines, int (*outx)(int)));
#endif
/* Forward declarations */
@ -114,15 +121,21 @@ static int bash_backward_kill_shellword __P((int, int));
/* Helper functions for Readline. */
static char *restore_tilde __P((char *, char *));
static char *maybe_restore_tilde __P((char *, char *));
static char *bash_filename_rewrite_hook __P((char *, int));
static void bash_directory_expansion __P((char **));
static int bash_filename_stat_hook __P((char **));
static int bash_command_name_stat_hook __P((char **));
static int bash_directory_completion_hook __P((char **));
static int filename_completion_ignore __P((char **));
static int bash_push_line __P((void));
static int executable_completion __P((const char *, int));
static rl_icppfunc_t *save_directory_hook __P((void));
static void reset_directory_hook __P((rl_icppfunc_t *));
static void restore_directory_hook __P((rl_icppfunc_t));
static void cleanup_expansion_error __P((void));
static void maybe_make_readline_line __P((char *));
@ -151,9 +164,14 @@ static int return_zero __P((const char *));
static char *bash_dequote_filename __P((char *, int));
static char *quote_word_break_chars __P((char *));
static void set_filename_bstab __P((const char *));
static char *bash_quote_filename __P((char *, int, char *));
#ifdef _MINIX
static void putx __P((int));
#else
static int putx __P((int));
#endif
static int bash_execute_unix_command __P((int, int));
static void init_unix_command_map __P((void));
static int isolate_sequence __P((char *, int, int, int *));
@ -164,10 +182,12 @@ static int set_saved_history __P((void));
static int posix_edit_macros __P((int, int));
#endif
static int bash_event_hook __P((void));
#if defined (PROGRAMMABLE_COMPLETION)
static int find_cmd_start __P((int));
static int find_cmd_end __P((int));
static char *find_cmd_name __P((int));
static char *find_cmd_name __P((int, int *, int *));
static char *prog_complete_return __P((const char *, int));
static char **prog_complete_matches;
@ -247,8 +267,20 @@ int force_fignore = 1;
int dircomplete_spelling = 0;
/* Expand directory names during word/filename completion. */
#if DIRCOMPLETE_EXPAND_DEFAULT
int dircomplete_expand = 1;
int dircomplete_expand_relpath = 1;
#else
int dircomplete_expand = 0;
int dircomplete_expand_relpath = 0;
#endif
/* When non-zero, perform `normal' shell quoting on completed filenames
even when the completed name contains a directory name with a shell
variable referene, so dollar signs in a filename get quoted appropriately.
Set to zero to remove dollar sign (and braces or parens as needed) from
the set of characters that will be quoted. */
int complete_fullquote = 1;
static char *bash_completer_word_break_characters = " \t\n\"'@><=;|&(:";
static char *bash_nohostname_word_break_characters = " \t\n\"'><=;|&(:";
@ -256,6 +288,7 @@ static char *bash_nohostname_word_break_characters = " \t\n\"'><=;|&(:";
static const char *default_filename_quote_characters = " \t\n\\\"'@<>=;|&()#$`?*[!:{~"; /*}*/
static char *custom_filename_quote_characters = 0;
static char filename_bstab[256];
static rl_hook_func_t *old_rl_startup_hook = (rl_hook_func_t *)NULL;
@ -515,6 +548,8 @@ initialize_readline ()
rl_filename_rewrite_hook = bash_filename_rewrite_hook;
rl_filename_stat_hook = bash_filename_stat_hook;
/* Tell the filename completer we want a chance to ignore some names. */
rl_ignore_some_completions_function = filename_completion_ignore;
@ -540,6 +575,7 @@ initialize_readline ()
/* characters that need to be quoted when appearing in filenames. */
rl_filename_quote_characters = default_filename_quote_characters;
set_filename_bstab (rl_filename_quote_characters);
rl_filename_quoting_function = bash_quote_filename;
rl_filename_dequoting_function = bash_dequote_filename;
@ -563,6 +599,18 @@ bashline_reinitialize ()
bash_readline_initialized = 0;
}
void
bashline_set_event_hook ()
{
rl_signal_event_hook = bash_event_hook;
}
void
bashline_reset_event_hook ()
{
rl_signal_event_hook = 0;
}
/* On Sun systems at least, rl_attempted_completion_function can end up
getting set to NULL, and rl_completion_entry_function set to do command
word completion if Bash is interrupted while trying to complete a command
@ -576,8 +624,12 @@ bashline_reset ()
rl_completion_entry_function = NULL;
rl_ignore_some_completions_function = filename_completion_ignore;
rl_filename_quote_characters = default_filename_quote_characters;
set_filename_bstab (rl_filename_quote_characters);
set_directory_hook ();
rl_filename_stat_hook = bash_filename_stat_hook;
bashline_reset_event_hook ();
}
/* Contains the line to push into readline. */
@ -772,7 +824,7 @@ clear_hostname_list ()
}
/* Return a NULL terminated list of hostnames which begin with TEXT.
Initialize the hostname list the first time if neccessary.
Initialize the hostname list the first time if necessary.
The array is malloc ()'ed, but not the individual strings. */
static char **
hostnames_matching (text)
@ -823,12 +875,25 @@ hostnames_matching (text)
/* The equivalent of the Korn shell C-o operate-and-get-next-history-line
editing command. */
static int saved_history_line_to_use = -1;
static int last_saved_history_line = -1;
#define HISTORY_FULL() (history_is_stifled () && history_length >= history_max_entries)
static int
set_saved_history ()
{
/* XXX - compensate for assumption that history was `shuffled' if it was
actually not. */
if (HISTORY_FULL () &&
hist_last_line_added == 0 &&
saved_history_line_to_use < history_length - 1)
saved_history_line_to_use++;
if (saved_history_line_to_use >= 0)
rl_get_previous_history (history_length - saved_history_line_to_use, 0);
{
rl_get_previous_history (history_length - saved_history_line_to_use, 0);
last_saved_history_line = saved_history_line_to_use;
}
saved_history_line_to_use = -1;
rl_startup_hook = old_rl_startup_hook;
return (0);
@ -846,8 +911,7 @@ operate_and_get_next (count, c)
/* Find the current line, and find the next line to use. */
where = where_history ();
if ((history_is_stifled () && (history_length >= history_max_entries)) ||
(where >= history_length - 1))
if (HISTORY_FULL () || (where >= history_length - 1))
saved_history_line_to_use = where;
else
saved_history_line_to_use = where + 1;
@ -895,7 +959,9 @@ edit_and_execute_command (count, c, editing_mode, edit_command)
/* This breaks down when using command-oriented history and are not
finished with the command, so we should not ignore the last command */
using_history ();
current_command_line_count++; /* for rl_newline above */
bash_add_history (rl_line_buffer);
current_command_line_count = 0; /* for dummy history entry */
bash_add_history ("");
history_lines_this_session++;
using_history ();
@ -1192,7 +1258,11 @@ bash_backward_kill_shellword (count, key)
#define COMMAND_SEPARATORS ";|&{(`"
/* )} */
#define COMMAND_SEPARATORS_PLUS_WS ";|&{(` \t"
/* )} */
/* check for redirections and other character combinations that are not
command separators */
static int
check_redir (ti)
int ti;
@ -1207,8 +1277,19 @@ check_redir (ti)
if ((this_char == '&' && (prev_char == '<' || prev_char == '>')) ||
(this_char == '|' && prev_char == '>'))
return (1);
else if ((this_char == '{' && prev_char == '$') || /* } */
(char_is_quoted (rl_line_buffer, ti)))
else if (this_char == '{' && prev_char == '$') /*}*/
return (1);
#if 0 /* Not yet */
else if (this_char == '(' && prev_char == '$') /*)*/
return (1);
else if (this_char == '(' && prev_char == '<') /*)*/
return (1);
#if defined (EXTENDED_GLOB)
else if (extended_glob && this_char == '(' && prev_char == '!') /*)*/
return (1);
#endif
#endif
else if (char_is_quoted (rl_line_buffer, ti))
return (1);
return (0);
}
@ -1226,7 +1307,10 @@ find_cmd_start (start)
register int s, os;
os = 0;
while (((s = skip_to_delim (rl_line_buffer, os, COMMAND_SEPARATORS, SD_NOJMP|SD_NOSKIPCMD)) <= start) &&
/* Flags == SD_NOJMP only because we want to skip over command substitutions
in assignment statements. Have to test whether this affects `standalone'
command substitutions as individual words. */
while (((s = skip_to_delim (rl_line_buffer, os, COMMAND_SEPARATORS, SD_NOJMP/*|SD_NOSKIPCMD*/)) <= start) &&
rl_line_buffer[s])
os = s+1;
return os;
@ -1243,8 +1327,9 @@ find_cmd_end (end)
}
static char *
find_cmd_name (start)
find_cmd_name (start, sp, ep)
int start;
int *sp, *ep;
{
char *name;
register int s, e;
@ -1257,6 +1342,11 @@ find_cmd_name (start)
name = substring (rl_line_buffer, s, e);
if (sp)
*sp = s;
if (ep)
*ep = e;
return (name);
}
@ -1286,13 +1376,18 @@ attempt_shell_completion (text, start, end)
{
int in_command_position, ti, saveti, qc, dflags;
char **matches, *command_separator_chars;
#if defined (PROGRAMMABLE_COMPLETION)
int have_progcomps, was_assignment;
#endif
command_separator_chars = COMMAND_SEPARATORS;
matches = (char **)NULL;
rl_ignore_some_completions_function = filename_completion_ignore;
rl_filename_quote_characters = default_filename_quote_characters;
set_filename_bstab (rl_filename_quote_characters);
set_directory_hook ();
rl_filename_stat_hook = bash_filename_stat_hook;
/* Determine if this could be a command word. It is if it appears at
the start of the line (ignoring preceding whitespace), or if it
@ -1323,6 +1418,8 @@ attempt_shell_completion (text, start, end)
are prompting at the top level. */
if (current_prompt_string == ps1_prompt)
in_command_position++;
else if (parser_in_command_position ())
in_command_position++;
}
else if (member (rl_line_buffer[ti], command_separator_chars))
{
@ -1356,11 +1453,11 @@ attempt_shell_completion (text, start, end)
#if defined (PROGRAMMABLE_COMPLETION)
/* Attempt programmable completion. */
have_progcomps = prog_completion_enabled && (progcomp_size () > 0);
if (matches == 0 && (in_command_position == 0 || text[0] == '\0') &&
prog_completion_enabled && (progcomp_size () > 0) &&
current_prompt_string == ps1_prompt)
{
int s, e, foundcs;
int s, e, s1, e1, os, foundcs;
char *n;
/* XXX - don't free the members */
@ -1368,13 +1465,62 @@ attempt_shell_completion (text, start, end)
free (prog_complete_matches);
prog_complete_matches = (char **)NULL;
s = find_cmd_start (start);
os = start;
n = 0;
s = find_cmd_start (os);
e = find_cmd_end (end);
n = find_cmd_name (s);
if (e == 0 && e == s && text[0] == '\0')
do
{
/* Skip over assignment statements preceding a command name. If we
don't find a command name at all, we can perform command name
completion. If we find a partial command name, we should perform
command name completion on it. */
FREE (n);
n = find_cmd_name (s, &s1, &e1);
s = e1 + 1;
}
while (was_assignment = assignment (n, 0));
s = s1; /* reset to index where name begins */
/* s == index of where command name begins (reset above)
e == end of current command, may be end of line
s1 = index of where command name begins
e1 == index of where command name ends
start == index of where word to be completed begins
end == index of where word to be completed ends
if (s == start) we are doing command word completion for sure
if (e1 == end) we are at the end of the command name and completing it */
if (start == 0 && end == 0 && e != 0 && text[0] == '\0') /* beginning of non-empty line */
foundcs = 0;
else if (start == end && start == s1 && e != 0 && e1 > end) /* beginning of command name, leading whitespace */
foundcs = 0;
else if (e == 0 && e == s && text[0] == '\0' && have_progcomps) /* beginning of empty line */
prog_complete_matches = programmable_completions ("_EmptycmD_", text, s, e, &foundcs);
else if (e > s && assignment (n, 0) == 0)
prog_complete_matches = programmable_completions (n, text, s, e, &foundcs);
else if (start == end && text[0] == '\0' && s1 > start && whitespace (rl_line_buffer[start]))
foundcs = 0; /* whitespace before command name */
else if (e > s && was_assignment == 0 && e1 == end && rl_line_buffer[e] == 0 && whitespace (rl_line_buffer[e-1]) == 0)
{
/* not assignment statement, but still want to perform command
completion if we are composing command word. */
foundcs = 0;
in_command_position = s == start && STREQ (n, text); /* XXX */
}
else if (e > s && was_assignment == 0 && have_progcomps)
{
prog_complete_matches = programmable_completions (n, text, s, e, &foundcs);
/* command completion if programmable completion fails */
in_command_position = s == start && STREQ (n, text); /* XXX */
}
else if (s >= e && n[0] == '\0' && text[0] == '\0' && start > 0)
{
foundcs = 0; /* empty command name following assignments */
in_command_position = was_assignment;
}
else if (s == start && e == end && STREQ (n, text) && start > 0)
{
foundcs = 0; /* partial command name following assignments */
in_command_position = 1;
}
else
foundcs = 0;
FREE (n);
@ -1414,7 +1560,7 @@ bash_default_completion (text, start, end, qc, compflags)
const char *text;
int start, end, qc, compflags;
{
char **matches;
char **matches, *t;
matches = (char **)NULL;
@ -1424,7 +1570,19 @@ bash_default_completion (text, start, end, qc, compflags)
if (qc != '\'' && text[1] == '(') /* ) */
matches = rl_completion_matches (text, command_subst_completion_function);
else
matches = rl_completion_matches (text, variable_completion_function);
{
matches = rl_completion_matches (text, variable_completion_function);
if (matches && matches[0] && matches[1] == 0)
{
t = savestring (matches[0]);
bash_filename_stat_hook (&t);
/* doesn't use test_for_directory because that performs tilde
expansion */
if (file_isdir (t))
rl_completion_append_character = '/';
free (t);
}
}
}
/* If the word starts in `~', and there is no slash in the word, then
@ -1500,11 +1658,55 @@ bash_default_completion (text, start, end, qc, compflags)
strvec_dispose (matches);
matches = (char **)0;
}
else if (matches && matches[1] && rl_completion_type == '!')
{
rl_completion_suppress_append = 1;
rl_filename_completion_desired = 0;
}
}
return (matches);
}
static int
bash_command_name_stat_hook (name)
char **name;
{
char *cname, *result;
/* If it's not something we're going to look up in $PATH, just call the
normal filename stat hook. */
if (absolute_program (*name))
return (bash_filename_stat_hook (name));
cname = *name;
/* XXX - we could do something here with converting aliases, builtins,
and functions into something that came out as executable, but we don't. */
result = search_for_command (cname, 0);
if (result)
{
*name = result;
return 1;
}
return 0;
}
static int
executable_completion (filename, searching_path)
const char *filename;
int searching_path;
{
char *f;
int r;
f = savestring (filename);
bash_directory_completion_hook (&f);
r = searching_path ? executable_file (f) : executable_or_directory (f);
free (f);
return r;
}
/* This is the function to call when the word to complete is in a position
where a command word can be found. It grovels $PATH, looking for commands
that match. It also scans aliases, function names, and the shell_builtin
@ -1518,6 +1720,7 @@ command_word_completion_function (hint_text, state)
static char *path = (char *)NULL;
static char *val = (char *)NULL;
static char *filename_hint = (char *)NULL;
static char *fnhint = (char *)NULL;
static char *dequoted_hint = (char *)NULL;
static char *directory_part = (char *)NULL;
static char **glob_matches = (char **)NULL;
@ -1528,12 +1731,14 @@ command_word_completion_function (hint_text, state)
#if defined (ALIAS)
static alias_t **alias_list = (alias_t **)NULL;
#endif /* ALIAS */
char *temp;
char *temp, *cval;
/* We have to map over the possibilities for command words. If we have
no state, then make one just for that purpose. */
if (state == 0)
{
rl_filename_stat_hook = bash_command_name_stat_hook;
if (dequoted_hint && dequoted_hint != hint)
free (dequoted_hint);
if (hint)
@ -1595,7 +1800,7 @@ command_word_completion_function (hint_text, state)
if (filename_hint)
free (filename_hint);
filename_hint = savestring (hint);
fnhint = filename_hint = savestring (hint);
istate = 0;
@ -1606,7 +1811,7 @@ command_word_completion_function (hint_text, state)
}
else
{
if (dircomplete_expand && dot_or_dotdot (filename_hint))
if (dircomplete_expand && path_dot_or_dotdot (filename_hint))
{
dircomplete_expand = 0;
set_directory_hook ();
@ -1742,9 +1947,9 @@ globword:
{
if (executable_or_directory (val))
{
if (*hint_text == '~')
if (*hint_text == '~' && directory_part)
{
temp = restore_tilde (val, directory_part);
temp = maybe_restore_tilde (val, directory_part);
free (val);
val = temp;
}
@ -1803,15 +2008,25 @@ globword:
if (current_path[0] == '.' && current_path[1] == '\0')
dot_in_path = 1;
if (fnhint && fnhint != filename_hint)
free (fnhint);
if (filename_hint)
free (filename_hint);
filename_hint = sh_makepath (current_path, hint, 0);
/* Need a quoted version (though it doesn't matter much in most
cases) because rl_filename_completion_function dequotes the
filename it gets, assuming that it's been quoted as part of
the input line buffer. */
if (strpbrk (filename_hint, "\"'\\"))
fnhint = sh_backslash_quote (filename_hint, filename_bstab, 0);
else
fnhint = filename_hint;
free (current_path); /* XXX */
}
inner:
val = rl_filename_completion_function (filename_hint, istate);
val = rl_filename_completion_function (fnhint, istate);
if (mapping_over == 4 && dircomplete_expand)
set_directory_hook ();
@ -1840,7 +2055,7 @@ globword:
/* If we performed tilde expansion, restore the original
filename. */
if (*hint_text == '~')
temp = restore_tilde (val, directory_part);
temp = maybe_restore_tilde (val, directory_part);
else
temp = savestring (val);
freetemp = 1;
@ -1863,19 +2078,38 @@ globword:
freetemp = match = 0;
}
#if 0
/* If we have found a match, and it is an executable file or a
directory name, return it. */
if (match && executable_or_directory (val))
#else
/* If we have found a match, and it is an executable file, return it.
We don't return directory names when searching $PATH, since the
bash execution code won't find executables in directories which
appear in directories in $PATH when they're specified using
relative pathnames. */
if (match && (searching_path ? executable_file (val) : executable_or_directory (val)))
#endif
relative pathnames. */
#if 0
/* If we're not searching $PATH and we have a relative pathname, we
need to re-canonicalize it before testing whether or not it's an
executable or a directory so the shell treats .. relative to $PWD
according to the physical/logical option. The shell already
canonicalizes the directory name in order to tell readline where
to look, so not doing it here will be inconsistent. */
/* XXX -- currently not used -- will introduce more inconsistency,
since shell does not canonicalize ../foo before passing it to
shell_execve(). */
if (match && searching_path == 0 && *val == '.')
{
char *t, *t1;
t = get_working_directory ("command-word-completion");
t1 = make_absolute (val, t);
free (t);
cval = sh_canonpath (t1, PATH_CHECKDOTDOT|PATH_CHECKEXISTS);
}
else
#endif
cval = val;
if (match && executable_completion ((searching_path ? val : cval), searching_path))
{
if (cval != val)
free (cval);
free (val);
val = ""; /* So it won't be NULL. */
return (temp);
@ -1884,6 +2118,8 @@ globword:
{
if (freetemp)
free (temp);
if (cval != val)
free (cval);
free (val);
goto inner;
}
@ -1952,7 +2188,7 @@ command_subst_completion_function (text, state)
rl_completion_suppress_append = 1;
}
if (!matches || !matches[cmd_index])
if (matches == 0 || matches[cmd_index] == 0)
{
rl_filename_quoting_desired = 0; /* disable quoting */
return ((char *)NULL);
@ -2676,6 +2912,20 @@ restore_tilde (val, directory_part)
return (ret);
}
static char *
maybe_restore_tilde (val, directory_part)
char *val, *directory_part;
{
rl_icppfunc_t *save;
char *ret;
save = (dircomplete_expand == 0) ? save_directory_hook () : (rl_icppfunc_t *)0;
ret = restore_tilde (val, directory_part);
if (save)
restore_directory_hook (save);
return ret;
}
/* Simulate the expansions that will be performed by
rl_filename_completion_function. This must be called with the address of
a pointer to malloc'd memory. */
@ -2687,8 +2937,11 @@ bash_directory_expansion (dirname)
d = savestring (*dirname);
if (rl_directory_rewrite_hook)
(*rl_directory_rewrite_hook) (&d);
if ((rl_directory_rewrite_hook) && (*rl_directory_rewrite_hook) (&d))
{
free (*dirname);
*dirname = d;
}
else if (rl_directory_completion_hook && (*rl_directory_completion_hook) (&d))
{
free (*dirname);
@ -2763,6 +3016,83 @@ restore_directory_hook (hookf)
rl_directory_rewrite_hook = hookf;
}
/* Expand a filename before the readline completion code passes it to stat(2).
The filename will already have had tilde expansion performed. */
static int
bash_filename_stat_hook (dirname)
char **dirname;
{
char *local_dirname, *new_dirname, *t;
int should_expand_dirname, return_value;
WORD_LIST *wl;
struct stat sb;
local_dirname = *dirname;
should_expand_dirname = return_value = 0;
if (t = mbschr (local_dirname, '$'))
should_expand_dirname = '$';
else if (t = mbschr (local_dirname, '`')) /* XXX */
should_expand_dirname = '`';
#if defined (HAVE_LSTAT)
if (should_expand_dirname && lstat (local_dirname, &sb) == 0)
#else
if (should_expand_dirname && stat (local_dirname, &sb) == 0)
#endif
should_expand_dirname = 0;
if (should_expand_dirname)
{
new_dirname = savestring (local_dirname);
wl = expand_prompt_string (new_dirname, 0, W_NOCOMSUB); /* does the right thing */
if (wl)
{
free (new_dirname);
new_dirname = string_list (wl);
/* Tell the completer we actually expanded something and change
*dirname only if we expanded to something non-null -- stat
behaves unpredictably when passed null or empty strings */
if (new_dirname && *new_dirname)
{
free (local_dirname); /* XXX */
local_dirname = *dirname = new_dirname;
return_value = STREQ (local_dirname, *dirname) == 0;
}
else
free (new_dirname);
dispose_words (wl);
}
else
free (new_dirname);
}
/* This is very similar to the code in bash_directory_completion_hook below,
but without spelling correction and not worrying about whether or not
we change relative pathnames. */
if (no_symbolic_links == 0 && (local_dirname[0] != '.' || local_dirname[1]))
{
char *temp1, *temp2;
t = get_working_directory ("symlink-hook");
temp1 = make_absolute (local_dirname, t);
free (t);
temp2 = sh_canonpath (temp1, PATH_CHECKDOTDOT|PATH_CHECKEXISTS);
/* If we can't canonicalize, bail. */
if (temp2 == 0)
{
free (temp1);
return return_value;
}
free (local_dirname);
*dirname = temp2;
free (temp1);
}
return (return_value);
}
/* Handle symbolic link references and other directory name
expansions while hacking completion. This should return 1 if it modifies
the DIRNAME argument, 0 otherwise. It should make sure not to modify
@ -2792,6 +3122,8 @@ bash_directory_completion_hook (dirname)
else
nextch = 0;
}
else if (local_dirname[0] == '~')
should_expand_dirname = '~';
else
{
t = mbschr (local_dirname, '`');
@ -2836,6 +3168,7 @@ bash_directory_completion_hook (dirname)
}
custom_filename_quote_characters[j] = '\0';
rl_filename_quote_characters = custom_filename_quote_characters;
set_filename_bstab (rl_filename_quote_characters);
}
}
else
@ -2886,8 +3219,10 @@ bash_directory_completion_hook (dirname)
free (t);
temp2 = sh_canonpath (temp1, PATH_CHECKDOTDOT|PATH_CHECKEXISTS);
/* Try spelling correction if initial canonicalization fails. */
if (temp2 == 0 && dircomplete_spelling)
/* Try spelling correction if initial canonicalization fails. Make
sure we are set to replace the directory name with the results so
subsequent directory checks don't fail. */
if (temp2 == 0 && dircomplete_spelling && dircomplete_expand)
{
temp2 = dirspell (temp1);
if (temp2)
@ -3486,6 +3821,20 @@ quote_word_break_chars (text)
return ret;
}
/* Use characters in STRING to populate the table of characters that should
be backslash-quoted. The table will be used for sh_backslash_quote from
this file. */
static void
set_filename_bstab (string)
const char *string;
{
const char *s;
memset (filename_bstab, 0, sizeof (filename_bstab));
for (s = string; s && *s; s++)
filename_bstab[*s] = 1;
}
/* Quote a filename using double quotes, single quotes, or backslashes
depending on the value of completion_quoting_style. If we're
completing using backslashes, we need to quote some additional
@ -3551,7 +3900,7 @@ bash_quote_filename (s, rtype, qcp)
rtext = sh_single_quote (mtext);
break;
case COMPLETE_BSQUOTE:
rtext = sh_backslash_quote (mtext);
rtext = sh_backslash_quote (mtext, complete_fullquote ? 0 : filename_bstab, 0);
break;
}
@ -3569,9 +3918,17 @@ bash_quote_filename (s, rtype, qcp)
/* Leave the opening quote intact. The readline completion code takes
care of avoiding doubled opening quotes. */
rlen = strlen (rtext);
ret = (char *)xmalloc (rlen + 1);
strcpy (ret, rtext);
if (rtext)
{
rlen = strlen (rtext);
ret = (char *)xmalloc (rlen + 1);
strcpy (ret, rtext);
}
else
{
ret = (char *)xmalloc (rlen = 1);
ret[0] = '\0';
}
/* If there are multiple matches, cut off the closing quote. */
if (rtype == MULT_MATCH && cs != COMPLETE_BSQUOTE)
@ -3583,14 +3940,19 @@ bash_quote_filename (s, rtype, qcp)
/* Support for binding readline key sequences to Unix commands. */
static Keymap cmd_xmap;
#ifdef _MINIX
static void
#else
static int
#endif
putx(c)
int c;
{
int x;
x = putc (c, rl_outstream);
return (x);
#ifndef _MINIX
return x;
#endif
}
static int
@ -3600,6 +3962,8 @@ bash_execute_unix_command (count, key)
{
Keymap ckmap; /* current keymap */
Keymap xkmap; /* unix command executing keymap */
rl_command_func_t *func;
int type;
register int i, r;
intmax_t mi;
sh_parser_state_t ps;
@ -3608,34 +3972,15 @@ bash_execute_unix_command (count, key)
char ibuf[INT_STRLEN_BOUND(int) + 1];
/* First, we need to find the right command to execute. This is tricky,
because we might have already indirected into another keymap. */
ckmap = rl_get_keymap ();
if (ckmap != rl_executing_keymap)
because we might have already indirected into another keymap, so we
have to walk cmd_xmap using the entire key sequence. */
cmd = (char *)rl_function_of_keyseq (rl_executing_keyseq, cmd_xmap, &type);
if (cmd == 0 || type != ISMACR)
{
/* bogus. we have to search. only handle one level of indirection. */
for (i = 0; i < KEYMAP_SIZE; i++)
{
if (ckmap[i].type == ISKMAP && (Keymap)ckmap[i].function == rl_executing_keymap)
break;
}
if (i < KEYMAP_SIZE)
xkmap = (Keymap)cmd_xmap[i].function;
else
{
rl_crlf ();
internal_error (_("bash_execute_unix_command: cannot find keymap for command"));
rl_forced_update_display ();
return 1;
}
}
else
xkmap = cmd_xmap;
cmd = (char *)xkmap[key].function;
if (cmd == 0)
{
rl_ding ();
rl_crlf ();
internal_error (_("bash_execute_unix_command: cannot find keymap for command"));
rl_forced_update_display ();
return 1;
}
@ -3690,6 +4035,18 @@ bash_execute_unix_command (count, key)
return 0;
}
int
print_unix_command_map ()
{
Keymap save;
save = rl_get_keymap ();
rl_set_keymap (cmd_xmap);
rl_macro_dumper (1);
rl_set_keymap (save);
return 0;
}
static void
init_unix_command_map ()
{
@ -3773,12 +4130,16 @@ bind_keyseq_to_unix_command (line)
if (line[i] != ':')
{
builtin_error (_("%s: missing colon separator"), line);
FREE (kseq);
return -1;
}
i = isolate_sequence (line, i + 1, 0, &kstart);
if (i < 0)
return -1;
{
FREE (kseq);
return -1;
}
/* Create the value string containing the command to execute. */
value = substring (line, kstart, i);
@ -3789,7 +4150,8 @@ bind_keyseq_to_unix_command (line)
/* and bind the key sequence in the current keymap to a function that
understands how to execute from CMD_XMAP */
rl_bind_keyseq_in_map (kseq, bash_execute_unix_command, kmap);
free (kseq);
return 0;
}
@ -3829,4 +4191,22 @@ bash_dequote_text (text)
dtxt = bash_dequote_filename ((char *)text, qc);
return (dtxt);
}
/* This event hook is designed to be called after readline receives a signal
that interrupts read(2). It gives reasonable responsiveness to interrupts
and fatal signals without executing too much code in a signal handler
context. */
static int
bash_event_hook ()
{
/* If we're going to longjmp to top_level, make sure we clean up readline.
check_signals will call QUIT, which will eventually longjmp to top_level,
calling run_interrupt_trap along the way. */
if (interrupt_state)
rl_cleanup_after_signal ();
bashline_reset_event_hook ();
check_signals_and_traps (); /* XXX */
return 0;
}
#endif /* READLINE */

View file

@ -37,6 +37,7 @@ extern void bashline_set_event_hook __P((void));
extern void bashline_reset_event_hook __P((void));
extern int bind_keyseq_to_unix_command __P((char *));
extern int print_unix_command_map __P((void));
extern char **bash_default_completion __P((const char *, int, int, int, int));

View file

@ -75,8 +75,8 @@ really_munge_braces (array, real_start, real_end, gcd_zero)
if (real_start == real_end)
{
x = array[real_start] ? sh_backslash_quote (array[real_start] + gcd_zero)
: sh_backslash_quote (array[0]);
x = array[real_start] ? sh_backslash_quote (array[real_start] + gcd_zero, 0, 0)
: sh_backslash_quote (array[0], 0, 0);
return x;
}
@ -115,7 +115,7 @@ really_munge_braces (array, real_start, real_end, gcd_zero)
if (start == end)
{
x = savestring (array[start] + gcd_zero);
subterm = sh_backslash_quote (x);
subterm = sh_backslash_quote (x, 0, 0);
free (x);
}
else
@ -126,7 +126,7 @@ really_munge_braces (array, real_start, real_end, gcd_zero)
x = (char *)xmalloc (tlen + 1);
strncpy (x, array[start] + gcd_zero, tlen);
x[tlen] = '\0';
subterm = sh_backslash_quote (x);
subterm = sh_backslash_quote (x, 0, 0);
free (x);
result_size += strlen (subterm) + 1;
result = (char *)xrealloc (result, result_size);

202
braces.c
View file

@ -1,6 +1,6 @@
/* braces.c -- code for doing word expansion in curly braces. */
/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
/* Copyright (C) 1987-2012 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -31,22 +31,32 @@
# include <unistd.h>
#endif
#include <errno.h>
#include "bashansi.h"
#include "bashintl.h"
#if defined (SHELL)
# include "shell.h"
#endif /* SHELL */
#include "typemax.h" /* INTMAX_MIN, INTMAX_MAX */
#include "general.h"
#include "shmbutil.h"
#include "chartypes.h"
#ifndef errno
extern int errno;
#endif
#define brace_whitespace(c) (!(c) || (c) == ' ' || (c) == '\t' || (c) == '\n')
#define BRACE_SEQ_SPECIFIER ".."
extern int asprintf __P((char **, const char *, ...)) __attribute__((__format__ (printf, 2, 3)));
extern int last_command_exit_value;
/* Basic idea:
Segregate the text into 3 sections: preamble (stuff before an open brace),
@ -63,7 +73,7 @@ static const int brace_arg_separator = ',';
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, int, int, int));
static char **mkseq __P((intmax_t, intmax_t, intmax_t, int, int));
static char **array_concat __P((char **, char **));
#else
static int brace_gobbler ();
@ -136,7 +146,8 @@ brace_expand (text)
#endif /* !CSH_BRACE_COMPAT */
preamble = (char *)xmalloc (i + 1);
strncpy (preamble, text, i);
if (i > 0)
strncpy (preamble, text, i);
preamble[i] = '\0';
result = (char **)xmalloc (2 * sizeof (char *));
@ -171,6 +182,7 @@ brace_expand (text)
if (text[j] == brace_arg_separator)
{ /* { */
strvec_dispose (result);
last_command_exit_value = 1;
report_error ("no closing `%c' in %s", '}', text);
throw_to_top_level ();
}
@ -218,6 +230,19 @@ brace_expand (text)
tack = expand_seqterm (amble, alen);
if (tack)
goto add_tack;
else if (text[i + 1])
{
/* If the sequence expansion fails (e.g., because the integers
overflow), but there is more in the string, try and process
the rest of the string, which may contain additional brace
expansions. Treat the unexpanded sequence term as a simple
string (including the braces). */
tack = strvec_create (2);
tack[0] = savestring (text+start-1);
tack[0][i-start+2] = '\0';
tack[1] = (char *)0;
goto add_tack;
}
else
{
free (amble);
@ -232,13 +257,18 @@ brace_expand (text)
add_tack:
result = array_concat (result, tack);
free (amble);
strvec_dispose (tack);
if (tack != result)
strvec_dispose (tack);
postamble = text + i + 1;
tack = brace_expand (postamble);
result = array_concat (result, tack);
strvec_dispose (tack);
if (postamble && *postamble)
{
tack = brace_expand (postamble);
result = array_concat (result, tack);
if (tack != result)
strvec_dispose (tack);
}
return (result);
}
@ -253,7 +283,7 @@ expand_amble (text, tlen, flags)
size_t tlen;
int flags;
{
char **result, **partial;
char **result, **partial, **tresult;
char *tem;
int start, i, c;
@ -285,7 +315,16 @@ expand_amble (text, tlen, flags)
lr = strvec_len (result);
lp = strvec_len (partial);
result = strvec_resize (result, lp + lr + 1);
tresult = strvec_mresize (result, lp + lr + 1);
if (tresult == 0)
{
internal_error (_("brace expansion: cannot allocate memory for %s"), tem);
strvec_dispose (result);
result = (char **)NULL;
return result;
}
else
result = tresult;
for (j = 0; j < lp; j++)
result[lr + j] = partial[j];
@ -305,25 +344,75 @@ 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;
int incr, type, width;
intmax_t start, end, incr;
int type, width;
{
intmax_t n;
int i;
intmax_t n, prevn;
int i, j, nelem;
char **result, *t;
i = abs (end - start) + 1;
result = strvec_create (i + 1);
if (incr == 0)
incr = 1;
if (start > end && incr > 0)
incr = -incr;
else if (start < end && incr < 0)
incr = -incr;
{
if (incr == INTMAX_MIN) /* Don't use -INTMAX_MIN */
return ((char **)NULL);
incr = -incr;
}
/* Check that end-start will not overflow INTMAX_MIN, INTMAX_MAX. The +3
and -2, not strictly necessary, are there because of the way the number
of elements and value passed to strvec_create() are calculated below. */
if (SUBOVERFLOW (end, start, INTMAX_MIN+3, INTMAX_MAX-2))
return ((char **)NULL);
prevn = sh_imaxabs (end - start);
/* Need to check this way in case INT_MAX == INTMAX_MAX */
if (INT_MAX == INTMAX_MAX && (ADDOVERFLOW (prevn, 2, INT_MIN, INT_MAX)))
return ((char **)NULL);
/* Make sure the assignment to nelem below doesn't end up <= 0 due to
intmax_t overflow */
else if (ADDOVERFLOW ((prevn/sh_imaxabs(incr)), 1, INTMAX_MIN, INTMAX_MAX))
return ((char **)NULL);
/* XXX - TOFIX: potentially allocating a lot of extra memory if
imaxabs(incr) != 1 */
/* Instead of a simple nelem = prevn + 1, something like:
nelem = (prevn / imaxabs(incr)) + 1;
would work */
nelem = (prevn / sh_imaxabs(incr)) + 1;
if (nelem > INT_MAX - 2) /* Don't overflow int */
return ((char **)NULL);
result = strvec_mcreate (nelem + 1);
if (result == 0)
{
internal_error (_("brace expansion: failed to allocate memory for %d elements"), nelem);
return ((char **)NULL);
}
/* Make sure we go through the loop at least once, so {3..3} prints `3' */
i = 0;
@ -334,7 +423,7 @@ mkseq (start, end, incr, type, width)
QUIT; /* XXX - memory leak here */
#endif
if (type == ST_INT)
result[i++] = itos (n);
result[i++] = t = itos (n);
else if (type == ST_ZINT)
{
int len, arg;
@ -344,12 +433,33 @@ mkseq (start, end, incr, type, width)
}
else
{
t = (char *)xmalloc (2);
t[0] = n;
t[1] = '\0';
if (t = (char *)malloc (2))
{
t[0] = n;
t[1] = '\0';
}
result[i++] = t;
}
/* We failed to allocate memory for this number, so we bail. */
if (t == 0)
{
char *p, lbuf[INT_STRLEN_BOUND(intmax_t) + 1];
/* Easier to do this than mess around with various intmax_t printf
formats (%ld? %lld? %jd?) and PRIdMAX. */
p = inttostr (n, lbuf, sizeof (lbuf));
internal_error (_("brace expansion: failed to allocate memory for `%s'"), p);
strvec_dispose (result);
return ((char **)NULL);
}
/* Handle overflow and underflow of n+incr */
if (ADDOVERFLOW (n, incr, INTMAX_MIN, INTMAX_MAX))
break;
n += incr;
if ((incr < 0 && n < end) || (incr > 0 && n > end))
break;
}
@ -365,8 +475,8 @@ expand_seqterm (text, tlen)
size_t tlen;
{
char *t, *lhs, *rhs;
int i, lhs_t, rhs_t, incr, lhs_l, rhs_l, width;
intmax_t lhs_v, rhs_v;
int i, lhs_t, rhs_t, lhs_l, rhs_l, width;
intmax_t lhs_v, rhs_v, incr;
intmax_t tl, tr;
char **result, *ep, *oep;
@ -396,8 +506,9 @@ expand_seqterm (text, tlen)
if (ISDIGIT (rhs[0]) || ((rhs[0] == '+' || rhs[0] == '-') && ISDIGIT (rhs[1])))
{
rhs_t = ST_INT;
errno = 0;
tr = strtoimax (rhs, &ep, 10);
if (ep && *ep != 0 && *ep != '.')
if (errno == ERANGE || (ep && *ep != 0 && *ep != '.'))
rhs_t = ST_BAD; /* invalid */
}
else if (ISALPHA (rhs[0]) && (rhs[1] == 0 || rhs[1] == '.'))
@ -415,10 +526,11 @@ expand_seqterm (text, tlen)
if (rhs_t != ST_BAD)
{
oep = ep;
errno = 0;
if (ep && *ep == '.' && ep[1] == '.' && ep[2])
incr = strtoimax (ep + 2, &ep, 10);
if (*ep != 0)
rhs_t = ST_BAD; /* invalid incr */
if (*ep != 0 || errno == ERANGE)
rhs_t = ST_BAD; /* invalid incr or overflow */
tlen -= ep - oep;
}
@ -535,6 +647,11 @@ brace_gobbler (text, tlen, indx, satisfy)
{
if (c == quoted)
quoted = 0;
#if defined (SHELL)
/* The shell allows quoted command substitutions */
if (quoted == '"' && c == '$' && text[i+1] == '(') /*)*/
goto comsub;
#endif
ADVANCE_CHAR (text, tlen, i);
continue;
}
@ -550,6 +667,7 @@ brace_gobbler (text, tlen, indx, satisfy)
/* Pass new-style command and process substitutions through unchanged. */
if ((c == '$' || c == '<' || c == '>') && text[i+1] == '(') /* ) */
{
comsub:
si = i + 2;
t = extract_command_subst (text, &si, 0);
i = si;
@ -594,6 +712,20 @@ brace_gobbler (text, tlen, indx, satisfy)
return (c);
}
/* Return 1 if ARR has any non-empty-string members. Used to short-circuit
in array_concat() below. */
static int
degenerate_array (arr)
char **arr;
{
register int i;
for (i = 0; arr[i]; i++)
if (arr[i][0] != '\0')
return 0;
return 1;
}
/* Return a new array of strings which is the result of appending each
string in ARR2 to each string in ARR1. The resultant array is
len (arr1) * len (arr2) long. For convenience, ARR1 (and its contents)
@ -607,10 +739,22 @@ array_concat (arr1, arr2)
register char **result;
if (arr1 == 0)
return (strvec_copy (arr2));
return (arr2); /* XXX - see if we can get away without copying? */
if (arr2 == 0)
return (strvec_copy (arr1));
return (arr1); /* XXX - caller expects us to free arr1 */
/* We can only short-circuit if the array consists of a single null element;
otherwise we need to replicate the contents of the other array and
prefix (or append, below) an empty element to each one. */
if (arr1[0] && arr1[0][0] == 0 && arr1[1] == 0)
{
strvec_dispose (arr1);
return (arr2); /* XXX - use flags to see if we can avoid copying here */
}
if (arr2[0] && arr2[0][0] == 0 && arr2[1] == 0)
return (arr1); /* XXX - rather than copying and freeing it */
len1 = strvec_len (arr1);
len2 = strvec_len (arr2);

View file

@ -50,7 +50,7 @@ struct builtin {
sh_builtin_func_t *function; /* The address of the invoked function. */
int flags; /* One of the #defines above. */
char * const *long_doc; /* NULL terminated array of strings. */
const char *short_doc; /* Short version of documenation. */
const char *short_doc; /* Short version of documentation. */
char *handle; /* for future use */
};

View file

@ -1,6 +1,6 @@
# This Makefile for building libbuiltins.a is in -*- text -*- for Emacs.
#
# Copyright (C) 1996-2009 Free Software Foundation, Inc.
# Copyright (C) 1996-2009 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -67,8 +67,8 @@ LIBS = @LIBS@
LDFLAGS = @LDFLAGS@ $(LOCAL_LDFLAGS) $(CFLAGS)
LDFLAGS_FOR_BUILD = @LDFLAGS_FOR_BUILD@ $(LOCAL_LDFLAGS) $(CFLAGS_FOR_BUILD)
LOCAL_LDFLAGS = @LOCAL_LDFLAGS@
#LIBS_FOR_BUILD = @LIBS_FOR_BUILD@
LIBS_FOR_BUILD = $(LIBS)
LIBS_FOR_BUILD = @LIBS_FOR_BUILD@
#LIBS_FOR_BUILD = $(LIBS)
BASHINCDIR = ${topdir}/include
@ -85,6 +85,8 @@ LIBINTL_H = @LIBINTL_H@
HELPDIR = @HELPDIR@
MKDIRS = ${topdir}/support/mkdirs
HELPFILES_TARGET = @HELPFILES_TARGET@
INCLUDES = -I. -I.. @RL_INCLUDE@ -I$(topdir) -I$(BASHINCDIR) -I$(topdir)/lib -I$(srcdir) ${INTL_INC}
BASE_CCFLAGS = ${PROFILE_FLAGS} $(DEFS) $(LOCAL_DEFS) $(SYSTEM_FLAGS) \
@ -153,15 +155,33 @@ OFILES = builtins.o \
suspend.o test.o times.o trap.o type.o ulimit.o umask.o \
wait.o getopts.o shopt.o printf.o getopt.o bashgetopt.o complete.o
CREATED_FILES = builtext.h builtins.c psize.aux pipesize.h
CREATED_FILES = builtext.h builtins.c psize.aux pipesize.h tmpbuiltins.c \
tmpbuiltins.h
CREATED_OBJECTS = tmpbuiltins.o gen-helpfiles.o mkbuiltins.o
all: $(MKBUILTINS) libbuiltins.a
all: $(MKBUILTINS) libbuiltins.a $(HELPFILES_TARGET)
targets: libbuiltins.a $(HELPFILES_TARGET)
libbuiltins.a: $(MKBUILTINS) $(OFILES) builtins.o
$(RM) $@
$(AR) $(ARFLAGS) $@ $(OFILES)
-$(RANLIB) $@
tmpbuiltins.c: $(MKBUILTINS) $(DEFSRC)
./$(MKBUILTINS) -externfile tmpbuiltins.h -structfile $@ \
-noproduction -nofunctions \
$(DIRECTDEFINE) $(HELPSTRINGS) $(DEFSRC)
tmpbuiltins.h: tmpbuiltins.c
gen-helpfiles.o: ../config.h
gen-helpfiles.o: gen-helpfiles.c
$(RM) $@
$(CC_FOR_BUILD) -c $(CCFLAGS_FOR_BUILD) $<
gen-helpfiles: tmpbuiltins.o gen-helpfiles.o
$(CC_FOR_BUILD) ${CCFLAGS_FOR_BUILD} $(LDFLAGS_FOR_BUILD) -o $@ gen-helpfiles.o tmpbuiltins.o $(LIBS_FOR_BUILD)
builtext.h builtins.c: $(MKBUILTINS) $(DEFSRC)
@-if test -f builtins.c; then mv -f builtins.c old-builtins.c; fi
@-if test -f builtext.h; then mv -f builtext.h old-builtext.h; fi
@ -178,8 +198,8 @@ builtext.h builtins.c: $(MKBUILTINS) $(DEFSRC)
$(RM) old-builtins.c; \
fi
helpdoc: $(MKBUILTINS) $(DEFSRC)
./$(MKBUILTINS) ${HELPDIRDEFINE} -noproduction $(DIRECTDEFINE) $(DEFSRC)
helpdoc: gen-helpfiles
./gen-helpfiles ${HELPDIRDEFINE}
install-help:
@-if test -n "${HELPDIR}" && test -d helpfiles ; then \
@ -207,15 +227,20 @@ common.o: common.c
bashgetopt.o: bashgetopt.c
getopt.o: getopt.c
evalstring.o: evalstring.c
evalfile.o: evalfile.c
evalfile.o: evalfile.c
tmpbuiltins.o: tmpbuiltins.c
gen-helpfiles.o: gen-helpfiles.c
ulimit.o: pipesize.h
pipesize.h: psize.aux
$(SHELL) $(srcdir)/psize.sh > $@
# Technically this is wrong; the pipe size should be for the target system,
# not the build host.
psize.aux: psize.c
$(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) -o $@ $(srcdir)/psize.c
$(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) ${LDFLAGS_FOR_BUILD} -o $@ $(srcdir)/psize.c
documentation: builtins.texi
@ -223,7 +248,8 @@ builtins.texi: $(MKBUILTINS)
./$(MKBUILTINS) -documentonly $(DEFSRC)
clean:
$(RM) $(OFILES) $(CREATED_FILES) $(MKBUILTINS) mkbuiltins.o libbuiltins.a
$(RM) $(OFILES) $(CREATED_FILES) libbuiltins.a
$(RM) $(MKBUILTINS) gen-helpfiles $(CREATED_OBJECTS)
-test -d helpfiles && $(RM) -r helpfiles
mostlyclean:
@ -547,7 +573,7 @@ shopt.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
shopt.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
shopt.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
shopt.o: $(srcdir)/common.h $(srcdir)/bashgetopt.h ../pathnames.h
shopt.o: $(topdir)/bashhist.h
shopt.o: $(topdir)/bashhist.h $(topdir)/bashline.h
source.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
source.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/findcmd.h
source.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h

View file

@ -25,7 +25,7 @@ $PRODUCES bind.c
$BUILTIN bind
$DEPENDS_ON READLINE
$FUNCTION bind_builtin
$SHORT_DOC bind [-lpvsPVS] [-m keymap] [-f filename] [-q name] [-u name] [-r keyseq] [-x keyseq:shell-command] [keyseq:readline-function or readline-command]
$SHORT_DOC bind [-lpsvPSVX] [-m keymap] [-f filename] [-q name] [-u name] [-r keyseq] [-x keyseq:shell-command] [keyseq:readline-function or readline-command]
Set Readline key bindings and variables.
Bind a key sequence to a Readline function or a macro, or set a
@ -54,6 +54,8 @@ Options:
-f filename Read key bindings from FILENAME.
-x keyseq:shell-command Cause SHELL-COMMAND to be executed when
KEYSEQ is entered.
-X List key sequences bound with -x and associated commands
in a form that can be reused as input.
Exit Status:
bind returns 0 unless an unrecognized option is given or an error occurs.
@ -104,6 +106,7 @@ extern int no_line_editing;
#define SSFLAG 0x0400
#define UFLAG 0x0800
#define XFLAG 0x1000
#define XXFLAG 0x2000
int
bind_builtin (list)
@ -138,7 +141,7 @@ bind_builtin (list)
rl_outstream = stdout;
reset_internal_getopt ();
while ((opt = internal_getopt (list, "lvpVPsSf:q:u:m:r:x:")) != EOF)
while ((opt = internal_getopt (list, "lvpVPsSXf:q:u:m:r:x:")) != EOF)
{
switch (opt)
{
@ -187,6 +190,9 @@ bind_builtin (list)
flags |= XFLAG;
cmd_seq = list_optarg;
break;
case 'X':
flags |= XXFLAG;
break;
default:
builtin_usage ();
BIND_RETURN (EX_USAGE);
@ -201,7 +207,7 @@ bind_builtin (list)
if ((flags & MFLAG) && map_name)
{
kmap = rl_get_keymap_by_name (map_name);
if (!kmap)
if (kmap == 0)
{
builtin_error (_("`%s': invalid keymap name"), map_name);
BIND_RETURN (EXECUTION_FAILURE);
@ -265,6 +271,9 @@ bind_builtin (list)
if (flags & XFLAG)
return_code = bind_keyseq_to_unix_command (cmd_seq);
if (flags & XXFLAG)
return_code = print_unix_command_map ();
/* Process the rest of the arguments as binding specifications. */
while (list)
{

View file

@ -2,6 +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.
This file is part of GNU Bash, the Bourne Again SHell.
@ -121,7 +122,7 @@ caller_builtin (list)
{
sh_invalidnum (list->word->word);
builtin_usage ();
return (EXECUTION_FAILURE);
return (EX_USAGE);
}
return (EXECUTION_SUCCESS);

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-2010 Free Software Foundation, Inc.
Copyright (C) 1987-2013 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -31,9 +31,10 @@ $PRODUCES cd.c
#include "../bashtypes.h"
#include "posixdir.h"
#include "posixstat.h"
#ifndef _MINIX
#if defined (HAVE_SYS_PARAM_H)
#include <sys/param.h>
#endif
#include <fcntl.h>
#include <stdio.h>
@ -60,7 +61,10 @@ 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));
static int change_to_directory __P((char *, int, int));
static int cdxattr __P((char *, char **));
static void resetxattr __P((void));
/* Change this to 1 to get cd spelling correction by default. */
int cdspelling = 0;
@ -68,10 +72,12 @@ int cdspelling = 0;
int cdable_vars;
static int eflag; /* file scope so bindpwd() can see it */
static int xattrflag; /* O_XATTR support for openat */
static int xattrfd = -1;
$BUILTIN cd
$FUNCTION cd_builtin
$SHORT_DOC cd [-L|[-P [-e]]] [dir]
$SHORT_DOC cd [-L|[-P [-e]] [-@]] [dir]
Change the shell working directory.
Change the current directory to DIR. The default DIR is the value of the
@ -87,13 +93,21 @@ the word is assumed to be a variable name. If that variable has a value,
its value is used for DIR.
Options:
-L force symbolic links to be followed
-L force symbolic links to be followed: resolve symbolic links in
DIR after processing instances of `..'
-P use the physical directory structure without following symbolic
links
links: resolve symbolic links in DIR before processing instances
of `..'
-e if the -P option is supplied, and the current working directory
cannot be determined successfully, exit with a non-zero status
#if defined (O_XATTR)
-@ on systems that support it, present a file with extended attributes
as a directory containing the file attributes
#endif
The default is to follow symbolic links, as if `-L' were specified.
`..' is processed by removing the immediately previous pathname component
back to a slash or the beginning of DIR.
Exit Status:
Returns 0 if the directory is changed, and if $PWD is set successfully when
@ -173,6 +187,66 @@ resetpwd (caller)
return (tdir);
}
static int
cdxattr (dir, ndirp)
char *dir; /* don't assume we can always free DIR */
char **ndirp; /* return new constructed directory name */
{
#if defined (O_XATTR)
int apfd, fd, r, e;
char buf[11+40+40]; /* construct new `fake' path for pwd */
apfd = openat (AT_FDCWD, dir, O_RDONLY|O_NONBLOCK);
if (apfd < 0)
return -1;
fd = openat (apfd, ".", O_XATTR);
e = errno;
close (apfd); /* ignore close error for now */
errno = e;
if (fd < 0)
return -1;
r = fchdir (fd); /* assume fchdir exists everywhere with O_XATTR */
if (r < 0)
{
close (fd);
return -1;
}
/* NFSv4 and ZFS extended attribute directories do not have names which are
visible in the standard Unix directory tree structure. To ensure we have
a valid name for $PWD, we synthesize one under /proc, but to keep that
path valid, we need to keep the file descriptor open as long as we are in
this directory. This imposes a certain structure on /proc. */
if (ndirp)
{
sprintf (buf, "/proc/%d/fd/%d", getpid(), fd);
*ndirp = savestring (buf);
}
if (xattrfd >= 0)
close (xattrfd);
xattrfd = fd;
return r;
#else
return -1;
#endif
}
/* Clean up the O_XATTR baggage. Currently only closes xattrfd */
static void
resetxattr ()
{
#if defined (O_XATTR)
if (xattrfd >= 0)
{
close (xattrfd);
xattrfd = -1;
}
#else
xattrfd = -1; /* not strictly necessary */
#endif
}
#define LCD_DOVARS 0x001
#define LCD_DOSPELL 0x002
#define LCD_PRINTPATH 0x004
@ -199,8 +273,13 @@ cd_builtin (list)
eflag = 0;
no_symlinks = no_symbolic_links;
xattrflag = 0;
reset_internal_getopt ();
while ((opt = internal_getopt (list, "LP")) != -1)
#if defined (O_XATTR)
while ((opt = internal_getopt (list, "eLP@")) != -1)
#else
while ((opt = internal_getopt (list, "eLP")) != -1)
#endif
{
switch (opt)
{
@ -213,9 +292,14 @@ cd_builtin (list)
case 'e':
eflag = 1;
break;
#if defined (O_XATTR)
case '@':
xattrflag = 1;
break;
#endif
default:
builtin_usage ();
return (EXECUTION_FAILURE);
return (EX_USAGE);
}
}
list = loptend;
@ -237,6 +321,13 @@ cd_builtin (list)
}
lflag = 0;
}
#if defined (CD_COMPLAINS)
else if (list->next)
{
builtin_error (_("too many arguments"));
return (EXECUTION_FAILURE);
}
#endif
else if (list->word->word[0] == '-' && list->word->word[1] == '\0')
{
/* This is `cd -', equivalent to `cd $OLDPWD' */
@ -268,7 +359,7 @@ cd_builtin (list)
temp = sh_makepath (path, dirname, MP_DOTILDE);
free (path);
if (change_to_directory (temp, no_symlinks))
if (change_to_directory (temp, no_symlinks, xattrflag))
{
/* POSIX.2 says that if a nonempty directory from CDPATH
is used to find the directory to change to, the new
@ -290,7 +381,8 @@ cd_builtin (list)
free (temp);
}
#if 0 /* changed for bash-4.2 Posix cd description steps 5-6 */
#if 0
/* changed for bash-4.2 Posix cd description steps 5-6 */
/* POSIX.2 says that if `.' does not appear in $CDPATH, we don't
try the current directory, so we just punt now with an error
message if POSIXLY_CORRECT is non-zero. The check for cdpath[0]
@ -308,7 +400,7 @@ cd_builtin (list)
/* When we get here, DIRNAME is the directory to change to. If we
chdir successfully, just return. */
if (change_to_directory (dirname, no_symlinks))
if (change_to_directory (dirname, no_symlinks, xattrflag))
{
if (lflag & LCD_PRINTPATH)
printf ("%s\n", dirname);
@ -321,7 +413,7 @@ cd_builtin (list)
if (lflag & LCD_DOVARS)
{
temp = get_string_value (dirname);
if (temp && change_to_directory (temp, no_symlinks))
if (temp && change_to_directory (temp, no_symlinks, xattrflag))
{
printf ("%s\n", temp);
return (bindpwd (no_symlinks));
@ -334,9 +426,10 @@ cd_builtin (list)
if (lflag & LCD_DOSPELL)
{
temp = dirspell (dirname);
if (temp && change_to_directory (temp, no_symlinks))
if (temp && change_to_directory (temp, no_symlinks, xattrflag))
{
printf ("%s\n", temp);
free (temp);
return (bindpwd (no_symlinks));
}
else
@ -391,7 +484,7 @@ pwd_builtin (list)
break;
default:
builtin_usage ();
return (EXECUTION_FAILURE);
return (EX_USAGE);
}
}
list = loptend;
@ -405,7 +498,11 @@ pwd_builtin (list)
the file system has changed state underneath bash). */
if ((tcwd && directory == 0) ||
(posixly_correct && same_file (".", tcwd, (struct stat *)0, (struct stat *)0) == 0))
directory = resetpwd ("pwd");
{
if (directory && directory != tcwd)
free (directory);
directory = resetpwd ("pwd");
}
#undef tcwd
@ -431,11 +528,11 @@ pwd_builtin (list)
to the working directory. Return 1 on success, 0 on failure. */
static int
change_to_directory (newdir, nolinks)
change_to_directory (newdir, nolinks, xattr)
char *newdir;
int nolinks;
int nolinks, xattr;
{
char *t, *tdir;
char *t, *tdir, *ndir;
int err, canon_failed, r, ndlen, dlen;
tdir = (char *)NULL;
@ -484,8 +581,34 @@ change_to_directory (newdir, nolinks)
return (0);
}
#if defined (O_XATTR)
if (xattrflag)
{
r = cdxattr (nolinks ? newdir : tdir, &ndir);
if (r >= 0)
{
canon_failed = 0;
free (tdir);
tdir = ndir;
}
else
{
err = errno;
free (tdir);
errno = err;
return (0); /* no xattr */
}
}
else
#endif
{
r = chdir (nolinks ? newdir : tdir);
if (r >= 0)
resetxattr ();
}
/* If the chdir succeeds, update the_current_working_directory. */
if (chdir (nolinks ? newdir : tdir) == 0)
if (r == 0)
{
/* If canonicalization failed, but the chdir succeeded, reset the
shell's idea of the_current_working_directory. */
@ -494,6 +617,8 @@ change_to_directory (newdir, nolinks)
t = resetpwd ("cd");
if (t == 0)
set_working_directory (tdir);
else
free (t);
}
else
set_working_directory (tdir);

View file

@ -500,7 +500,7 @@ get_exitstat (list)
if (arg == 0 || legal_number (arg, &sval) == 0)
{
sh_neednumarg (list->word->word ? list->word->word : "`'");
return 255;
return EX_BADUSAGE;
}
no_args (list->next);
@ -628,7 +628,7 @@ get_job_by_name (name, flags)
if (this_shell_builtin)
builtin_error (_("%s: ambiguous job spec"), name);
else
report_error (_("%s: ambiguous job spec"), name);
internal_error (_("%s: ambiguous job spec"), name);
return (DUP_JOB);
}
else

View file

@ -145,6 +145,8 @@ extern void set_bashopts __P((void));
extern void parse_bashopts __P((char *));
extern void initialize_bashopts __P((int));
extern void set_compatibility_opts __P((void));
/* Functions from type.def */
extern int describe_command __P((char *, int));
@ -153,6 +155,7 @@ 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));
/* Functions from pushd.def */
@ -163,6 +166,7 @@ extern WORD_LIST *get_directory_stack __P((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((void));
extern int parse_string __P((char *, const char *, int, char **));

View file

@ -1,7 +1,7 @@
This file is complete.def, from which is created complete.c.
It implements the builtins "complete", "compgen", and "compopt" in Bash.
Copyright (C) 1999-2010 Free Software Foundation, Inc.
Copyright (C) 1999-2011 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -112,7 +112,7 @@ static const struct _compacts {
{ "export", CA_EXPORT, 'e' },
{ "file", CA_FILE, 'f' },
{ "function", CA_FUNCTION, 0 },
{ "helptopic", CA_BUILTIN, 0 }, /* for now */
{ "helptopic", CA_HELPTOPIC, 0 },
{ "hostname", CA_HOSTNAME, 0 },
{ "group", CA_GROUP, 'g' },
{ "job", CA_JOB, 'j' },
@ -129,7 +129,7 @@ static const struct _compacts {
};
/* This should be a STRING_INT_ALIST */
const static struct _compopt {
static const struct _compopt {
const char * const optname;
int optflag;
} compopts[] = {
@ -137,6 +137,7 @@ const static struct _compopt {
{ "default", COPT_DEFAULT },
{ "dirnames", COPT_DIRNAMES },
{ "filenames",COPT_FILENAMES},
{ "noquote", COPT_NOQUOTE },
{ "nospace", COPT_NOSPACE },
{ "plusdirs", COPT_PLUSDIRS },
{ (char *)NULL, 0 },
@ -728,6 +729,7 @@ compgen_builtin (list)
if ((sl == 0 || sl->list_len == 0) && (copts & COPT_DEFAULT))
{
matches = rl_completion_matches (word, rl_filename_completion_function);
strlist_dispose (sl);
sl = completions_to_stringlist (matches);
strvec_dispose (matches);
}

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-2010 Free Software Foundation, Inc.
Copyright (C) 1987-2012 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 [-aAfFgilrtux] [-p] [name[=value] ...]
$SHORT_DOC declare [-aAfFgilnrtux] [-p] [name[=value] ...]
Set variable values and attributes.
Declare variables and give them attributes. If no NAMEs are given,
@ -41,6 +41,7 @@ Options which set attributes:
-A to make NAMEs associative arrays (if supported)
-i to make NAMEs have the `integer' attribute
-l to convert NAMEs to lower case on assignment
-n make NAME a reference to the variable named by its value
-r to make NAMEs readonly
-t to make NAMEs have the `trace' attribute
-u to convert NAMEs to upper case on assignment
@ -55,7 +56,8 @@ When used in a function, `declare' makes NAMEs local, as with the `local'
command. The `-g' option suppresses this behavior.
Exit Status:
Returns success unless an invalid option is supplied or an error occurs.
Returns success unless an invalid option is supplied or a variable
assignment error occurs.
$END
$BUILTIN typeset
@ -110,8 +112,8 @@ Local variables can only be used within a function; they are visible
only to the function where they are defined and its children.
Exit Status:
Returns success unless an invalid option is supplied, an error occurs,
or the shell is not executing a function.
Returns success unless an invalid option is supplied, a variable
assignment error occurs, or the shell is not executing a function.
$END
int
local_builtin (list)
@ -127,9 +129,9 @@ local_builtin (list)
}
#if defined (ARRAY_VARS)
# define DECLARE_OPTS "+acfgilprtuxAF"
# define DECLARE_OPTS "+acfgilnprtuxAF"
#else
# define DECLARE_OPTS "+cfgilprtuxF"
# define DECLARE_OPTS "+cfgilnprtuxF"
#endif
/* The workhorse function. */
@ -139,12 +141,13 @@ declare_internal (list, local_var)
int local_var;
{
int flags_on, flags_off, *flags;
int any_failed, assign_error, pflag, nodefs, opt, mkglobal;
int any_failed, assign_error, pflag, nodefs, opt, mkglobal, onref, offref;
char *t, *subscript_start;
SHELL_VAR *var;
SHELL_VAR *var, *refvar, *v;
FUNCTION_DEF *shell_fn;
flags_on = flags_off = any_failed = assign_error = pflag = nodefs = mkglobal = 0;
refvar = (SHELL_VAR *)NULL;
reset_internal_getopt ();
while ((opt = internal_getopt (list, DECLARE_OPTS)) != EOF)
{
@ -186,6 +189,9 @@ declare_internal (list, local_var)
case 'i':
*flags |= att_integer;
break;
case 'n':
*flags |= att_nameref;
break;
case 'r':
*flags |= att_readonly;
break;
@ -258,7 +264,10 @@ declare_internal (list, local_var)
{
for (any_failed = 0; list; list = list->next)
{
pflag = show_name_attributes (list->word->word, nodefs);
if (flags_on & att_function)
pflag = show_func_attributes (list->word->word, nodefs);
else
pflag = show_name_attributes (list->word->word, nodefs);
if (pflag)
{
sh_notfound (list->word->word);
@ -296,6 +305,28 @@ declare_internal (list, local_var)
else
value = "";
/* Do some lexical error checking on the LHS and RHS of the assignment
that is specific to nameref variables. */
if (flags_on & att_nameref)
{
#if defined (ARRAY_VARIABLES)
if (valid_array_reference (name))
{
builtin_error (_("%s: reference variable cannot be an array"), name);
assign_error++;
NEXT_VARIABLE ();
}
else
#endif
/* disallow self references at global scope */
if (STREQ (name, value) && variable_context == 0)
{
builtin_error (_("%s: nameref variable self references not allowed"), name);
assign_error++;
NEXT_VARIABLE ();
}
}
#if defined (ARRAY_VARS)
compound_array_assign = simple_array_assign = 0;
subscript_start = (char *)NULL;
@ -334,16 +365,17 @@ declare_internal (list, local_var)
/* XXX - this has consequences when we're making a local copy of a
variable that was in the temporary environment. Watch out
for this. */
refvar = (SHELL_VAR *)NULL;
if (variable_context && mkglobal == 0 && ((flags_on & att_function) == 0))
{
#if defined (ARRAY_VARS)
if (flags_on & att_assoc)
var = make_local_assoc_variable (name);
else if ((flags_on & att_array) || making_array_special)
var = make_local_array_variable (name);
var = make_local_array_variable (name, making_array_special);
else
#endif
var = make_local_variable (name);
var = make_local_variable (name); /* sets att_invisible for new vars */
if (var == 0)
{
any_failed++;
@ -415,6 +447,33 @@ declare_internal (list, local_var)
else /* declare -[aAirx] name [name...] */
{
/* Non-null if we just created or fetched a local variable. */
/* Here's what ksh93 seems to do. If we are modifying an existing
nameref variable, we don't follow the nameref chain past the last
nameref, and we set the nameref variable's value so future
references to that variable will return the value of the variable
we're assigning right now. */
if (var == 0 && (flags_on & att_nameref))
{
/* See if we are trying to modify an existing nameref variable */
var = mkglobal ? find_global_variable_last_nameref (name) : find_variable_last_nameref (name);
if (var && nameref_p (var) == 0)
var = 0;
}
/* However, if we're turning off the nameref attribute on an existing
nameref variable, we first follow the nameref chain to the end,
modify the value of the variable this nameref variable references,
*CHANGING ITS VALUE AS A SIDE EFFECT* then turn off the nameref
flag *LEAVING THE NAMEREF VARIABLE'S VALUE UNCHANGED* */
else if (var == 0 && (flags_off & att_nameref))
{
/* See if we are trying to modify an existing nameref variable */
refvar = mkglobal ? find_global_variable_last_nameref (name) : find_variable_last_nameref (name);
if (refvar && nameref_p (refvar) == 0)
refvar = 0;
if (refvar)
var = mkglobal ? find_global_variable (nameref_cell (refvar)) : find_variable (nameref_cell (refvar));
}
if (var == 0)
var = mkglobal ? find_global_variable (name) : find_variable (name);
@ -422,20 +481,40 @@ declare_internal (list, local_var)
{
#if defined (ARRAY_VARS)
if (flags_on & att_assoc)
var = make_new_assoc_variable (name);
{
var = make_new_assoc_variable (name);
if (offset == 0)
VSETATTR (var, att_invisible);
}
else if ((flags_on & att_array) || making_array_special)
var = make_new_array_variable (name);
{
var = make_new_array_variable (name);
if (offset == 0)
VSETATTR (var, att_invisible);
}
else
#endif
if (offset)
var = bind_variable (name, "", 0);
var = mkglobal ? bind_global_variable (name, "", 0) : bind_variable (name, "", 0);
else
{
var = bind_variable (name, (char *)NULL, 0);
var = mkglobal ? bind_global_variable (name, (char *)NULL, 0) : bind_variable (name, (char *)NULL, 0);
VSETATTR (var, att_invisible);
}
}
/* Can't take an existing array variable and make it a nameref */
else if ((array_p (var) || assoc_p (var)) && (flags_on & att_nameref))
{
builtin_error (_("%s: reference variable cannot be an array"), name);
assign_error++;
NEXT_VARIABLE ();
}
else if (flags_on & att_nameref)
{
/* ksh93 compat: turning on nameref attribute turns off -ilu */
VUNSETATTR (var, att_integer|att_uppercase|att_lowercase|att_capcase);
}
/* Cannot use declare +r to turn off readonly attribute. */
if (readonly_p (var) && (flags_off & att_readonly))
@ -501,6 +580,25 @@ declare_internal (list, local_var)
var = convert_var_to_array (var);
#endif /* ARRAY_VARS */
/* XXX - we note that we are turning on nameref attribute and defer
setting it until the assignment has been made so we don't do an
inadvertent nameref lookup. Might have to do the same thing for
flags_off&att_nameref. */
/* XXX - ksh93 makes it an error to set a readonly nameref variable
using a single typeset command. */
onref = (flags_on & att_nameref);
flags_on &= ~att_nameref;
#if defined (ARRAY_VARS)
if (array_p (var) || assoc_p (var)
|| (offset && compound_array_assign)
|| simple_array_assign)
onref = 0; /* array variables may not be namerefs */
#endif
/* ksh93 seems to do this */
offref = (flags_off & att_nameref);
flags_off &= ~att_nameref;
VSETATTR (var, flags_on);
VUNSETATTR (var, flags_off);
@ -516,6 +614,8 @@ declare_internal (list, local_var)
if (var == 0) /* some kind of assignment error */
{
assign_error++;
flags_on |= onref;
flags_off |= offref;
NEXT_VARIABLE ();
}
}
@ -532,7 +632,19 @@ declare_internal (list, local_var)
/* bind_variable_value duplicates the essential internals of
bind_variable() */
if (offset)
bind_variable_value (var, value, aflags);
{
if (onref)
aflags |= ASS_NAMEREF;
v = bind_variable_value (var, value, aflags);
if (v == 0 && onref)
{
sh_invalidid (value);
assign_error++;
/* XXX - unset this variable? or leave it as normal var? */
delete_var (var->name, mkglobal ? global_variables : shell_variables);
NEXT_VARIABLE ();
}
}
/* If we found this variable in the temporary environment, as with
`var=value declare -x var', make sure it is treated identically
@ -562,6 +674,17 @@ declare_internal (list, local_var)
}
}
/* Turn on nameref attribute we deferred above. */
/* XXX - should we turn on the noassign attribute for consistency with
ksh93 when we turn on the nameref attribute? */
VSETATTR (var, onref);
flags_on |= onref;
VUNSETATTR (var, offref);
flags_off |= offref;
/* Yuck. ksh93 compatibility */
if (refvar)
VUNSETATTR (refvar, flags_off);
stupidly_hack_special_variables (name);
NEXT_VARIABLE ();

View file

@ -38,7 +38,8 @@ $DEPENDS_ON V9_ECHO
$SHORT_DOC echo [-neE] [arg ...]
Write arguments to the standard output.
Display the ARGs on the standard output followed by a newline.
Display the ARGs, separated by a single space character and followed by a
newline, on the standard output.
Options:
-n do not append a newline
@ -50,6 +51,7 @@ Options:
\b backspace
\c suppress further output
\e escape character
\E escape character
\f form feed
\n new line
\r carriage return

View file

@ -53,6 +53,5 @@ eval_builtin (list)
return (EX_USAGE);
list = loptend; /* skip over possible `--' */
/* Note that parse_and_execute () frees the string it is passed. */
return (list ? parse_and_execute (string_list (list), "eval", SEVAL_NOHIST) : EXECUTION_SUCCESS);
return (list ? evalstring (string_list (list), "eval", SEVAL_NOHIST) : EXECUTION_SUCCESS);
}

View file

@ -109,11 +109,16 @@ _evalfile (filename, flags)
GET_ARRAY_FROM_VAR ("BASH_ARGC", bash_argc_v, bash_argc_a);
# endif
#endif
fd = open (filename, O_RDONLY);
if (fd < 0 || (fstat (fd, &finfo) == -1))
{
i = errno;
if (fd >= 0)
close (fd);
errno = i;
file_error_and_exit:
if (((flags & FEVAL_ENOENTOK) == 0) || errno != ENOENT)
file_error (filename);
@ -133,11 +138,13 @@ file_error_and_exit:
if (S_ISDIR (finfo.st_mode))
{
(*errfunc) (_("%s: is a directory"), filename);
close (fd);
return ((flags & FEVAL_BUILTIN) ? EXECUTION_FAILURE : -1);
}
else if ((flags & FEVAL_REGFILE) && S_ISREG (finfo.st_mode) == 0)
{
(*errfunc) (_("%s: not a regular file"), filename);
close (fd);
return ((flags & FEVAL_BUILTIN) ? EXECUTION_FAILURE : -1);
}
@ -146,6 +153,7 @@ file_error_and_exit:
if (file_size != finfo.st_size || file_size + 1 < file_size)
{
(*errfunc) (_("%s: file is too large"), filename);
close (fd);
return ((flags & FEVAL_BUILTIN) ? EXECUTION_FAILURE : -1);
}
@ -251,7 +259,7 @@ file_error_and_exit:
if (flags & FEVAL_BUILTIN)
result = EXECUTION_SUCCESS;
return_val = setjmp (return_catch);
return_val = setjmp_nosigs (return_catch);
/* If `return' was seen outside of a function, but in the script, then
force parse_and_execute () to clean up. */

View file

@ -1,6 +1,6 @@
/* evalstring.c - evaluate a string as one or more shell commands. */
/* Copyright (C) 1996-2010 Free Software Foundation, Inc.
/* Copyright (C) 1996-2012 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -61,7 +61,7 @@ extern int errno;
#define IS_BUILTIN(s) (builtin_address_internal(s, 0) != (struct builtin *)NULL)
extern int indirection_level, subshell_environment;
extern int line_number;
extern int line_number, line_number_for_err_trap;
extern int current_token, shell_eof_token;
extern int last_command_exit_value;
extern int running_trap;
@ -69,7 +69,9 @@ extern int loop_level;
extern int executing_list;
extern int comsub_ignore_return;
extern int posixly_correct;
extern int return_catch_flag, return_catch_value;
extern sh_builtin_func_t *this_shell_builtin;
extern char *the_printed_command_except_trap;
int parse_and_execute_level = 0;
@ -86,6 +88,14 @@ set_history_remembering ()
}
#endif
static void
restore_lastcom (x)
char *x;
{
FREE (the_printed_command_except_trap);
the_printed_command_except_trap = x;
}
/* How to force parse_and_execute () to clean up after itself. */
void
parse_and_execute_cleanup ()
@ -108,7 +118,7 @@ parse_prologue (string, flags, tag)
int flags;
char *tag;
{
char *orig_string;
char *orig_string, *lastcom;
int x;
orig_string = string;
@ -118,6 +128,7 @@ parse_prologue (string, flags, tag)
unwind_protect_jmp_buf (top_level);
unwind_protect_int (indirection_level);
unwind_protect_int (line_number);
unwind_protect_int (line_number_for_err_trap);
unwind_protect_int (loop_level);
unwind_protect_int (executing_list);
unwind_protect_int (comsub_ignore_return);
@ -140,8 +151,17 @@ parse_prologue (string, flags, tag)
x = get_current_prompt_level ();
add_unwind_protect (set_current_prompt_level, x);
}
if (the_printed_command_except_trap)
{
lastcom = savestring (the_printed_command_except_trap);
add_unwind_protect (restore_lastcom, lastcom);
}
add_unwind_protect (pop_stream, (char *)NULL);
if (parser_expanding_alias ())
add_unwind_protect (parser_restore_alias, (char *)NULL);
if (orig_string && ((flags & SEVAL_NOFREE) == 0))
add_unwind_protect (xfree, orig_string);
end_unwind_frame ();
@ -175,6 +195,7 @@ parse_and_execute (string, from_file, flags)
int code, lreset;
volatile int should_jump_to_top_level, last_result;
COMMAND *volatile command;
volatile sigset_t pe_sigmask;
parse_prologue (string, flags, PE_TAG);
@ -182,11 +203,21 @@ parse_and_execute (string, from_file, flags)
lreset = flags & SEVAL_RESETLINE;
#if defined (HAVE_POSIX_SIGNALS)
/* If we longjmp and are going to go on, use this to restore signal mask */
sigemptyset (&pe_sigmask);
sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &pe_sigmask);
#endif
/* Reset the line number if the caller wants us to. If we don't reset the
line number, we have to subtract one, because we will add one just
before executing the next command (resetting the line number sets it to
0; the first line number is 1). */
push_stream (lreset);
if (parser_expanding_alias ())
/* push current shell_input_line */
parser_save_alias ();
if (lreset == 0)
line_number--;
@ -209,15 +240,28 @@ parse_and_execute (string, from_file, flags)
/* Provide a location for functions which `longjmp (top_level)' to
jump to. This prevents errors in substitution from restarting
the reader loop directly, for example. */
code = setjmp (top_level);
code = setjmp_nosigs (top_level);
if (code)
{
should_jump_to_top_level = 0;
switch (code)
{
case FORCE_EOF:
case ERREXIT:
/* variable_context -> 0 is what eval.c:reader_loop() does in
these circumstances. Don't bother with cleanup here because
we don't want to run the function execution cleanup stuff
that will cause pop_context and other functions to run.
XXX - change that if we want the function context to be
unwound. */
if (exit_immediately_on_error && variable_context)
{
discard_unwind_frame ("pe_dispose");
variable_context = 0; /* not in a function */
}
should_jump_to_top_level = 1;
goto out;
case FORCE_EOF:
case EXITPROG:
if (command)
run_unwind_frame ("pe_dispose");
@ -239,6 +283,9 @@ parse_and_execute (string, from_file, flags)
{
#if 0
dispose_command (command); /* pe_dispose does this */
#endif
#if defined (HAVE_POSIX_SIGNALS)
sigprocmask (SIG_SETMASK, &pe_sigmask, (sigset_t *)NULL);
#endif
continue;
}
@ -308,7 +355,8 @@ parse_and_execute (string, from_file, flags)
command->value.Simple->words == 0 &&
command->value.Simple->redirects &&
command->value.Simple->redirects->next == 0 &&
command->value.Simple->redirects->instruction == r_input_direction)
command->value.Simple->redirects->instruction == r_input_direction &&
command->value.Simple->redirects->redirector.dest == 0)
{
int r;
r = cat_file (command->value.Simple->redirects);
@ -317,7 +365,6 @@ parse_and_execute (string, from_file, flags)
else
last_result = execute_command_internal
(command, 0, NO_PIPE, NO_PIPE, bitmap);
dispose_command (command);
dispose_fd_bitmap (bitmap);
discard_unwind_frame ("pe_dispose");
@ -377,15 +424,26 @@ parse_string (string, from_file, flags, endp)
volatile int should_jump_to_top_level;
COMMAND *volatile command, *oglobal;
char *ostring;
volatile sigset_t ps_sigmask;
parse_prologue (string, flags, PS_TAG);
#if defined (HAVE_POSIX_SIGNALS)
/* If we longjmp and are going to go on, use this to restore signal mask */
sigemptyset (&ps_sigmask);
sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &ps_sigmask);
#endif
/* itrace("parse_string: `%s'", string); */
/* Reset the line number if the caller wants us to. If we don't reset the
line number, we have to subtract one, because we will add one just
before executing the next command (resetting the line number sets it to
0; the first line number is 1). */
push_stream (0);
if (parser_expanding_alias ())
/* push current shell_input_line */
parser_save_alias ();
code = should_jump_to_top_level = 0;
oglobal = global_command;
ostring = string;
@ -402,7 +460,7 @@ parse_string (string, from_file, flags, endp)
/* Provide a location for functions which `longjmp (top_level)' to
jump to. */
code = setjmp (top_level);
code = setjmp_nosigs (top_level);
if (code)
{
@ -424,6 +482,9 @@ itrace("parse_string: longjmp executed: code = %d", code);
goto out;
default:
#if defined (HAVE_POSIX_SIGNALS)
sigprocmask (SIG_SETMASK, &ps_sigmask, (sigset_t *)NULL);
#endif
command_error ("parse_string", CMDERR_BADJUMP, code, 0);
break;
}
@ -506,3 +567,49 @@ cat_file (r)
return (rval);
}
int
evalstring (string, from_file, flags)
char *string;
const char *from_file;
int flags;
{
volatile int r, rflag, rcatch;
rcatch = 0;
rflag = return_catch_flag;
/* If we are in a place where `return' is valid, we have to catch
`eval "... return"' and make sure parse_and_execute cleans up. Then
we can trampoline to the previous saved return_catch location. */
if (rflag)
{
begin_unwind_frame ("evalstring");
unwind_protect_int (return_catch_flag);
unwind_protect_jmp_buf (return_catch);
return_catch_flag++; /* increment so we have a counter */
rcatch = setjmp_nosigs (return_catch);
}
if (rcatch)
{
parse_and_execute_cleanup ();
r = return_catch_value;
}
else
/* Note that parse_and_execute () frees the string it is passed. */
r = parse_and_execute (string, from_file, flags);
if (rflag)
{
run_unwind_frame ("evalstring");
if (rcatch && return_catch_flag)
{
return_catch_value = r;
longjmp (return_catch, 1);
}
}
return (r);
}

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-2010 Free Software Foundation, Inc.
Copyright (C) 1987-2012 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -144,7 +144,7 @@ exec_builtin (list)
args = strvec_from_word_list (list, 1, 0, (int *)NULL);
/* A command with a slash anywhere in its name is not looked up in $PATH. */
command = absolute_program (args[0]) ? args[0] : search_for_command (args[0]);
command = absolute_program (args[0]) ? args[0] : search_for_command (args[0], 1);
if (command == 0)
{

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-2010 Free Software Foundation, Inc.
Copyright (C) 1987-2011 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -52,7 +52,7 @@ $END
#include <config.h>
#if defined (HISTORY)
#ifndef _MINIX
#if defined (HAVE_SYS_PARAM_H)
# include <sys/param.h>
#endif
#include "../bashtypes.h"
@ -85,7 +85,7 @@ $END
extern int errno;
#endif /* !errno */
extern int current_command_line_count, saved_command_line_count;
extern int current_command_line_count;
extern int literal_history;
extern int posixly_correct;
extern int subshell_environment, interactive_shell;
@ -173,7 +173,7 @@ fc_builtin (list)
register int i;
register char *sep;
int numbering, reverse, listing, execute;
int histbeg, histend, last_hist, retval, opt, rh;
int histbeg, histend, last_hist, retval, opt, rh, real_last;
FILE *stream;
REPL *rlist, *rl;
char *ename, *command, *newcom, *fcedit;
@ -303,6 +303,14 @@ fc_builtin (list)
rh = remember_on_history || ((subshell_environment & SUBSHELL_COMSUB) && enable_history_list);
last_hist = i - rh - hist_last_line_added;
/* Make sure that real_last is calculated the same way here and in
fc_gethnum. The return value from fc_gethnum is treated specially if
it is == real_last and we are listing commands. */
real_last = i;
/* back up from the end to the last non-null history entry */
while (hlist[real_last] == 0 && real_last > 0)
real_last--;
/* XXX */
if (i == last_hist && hlist[last_hist] == 0)
while (last_hist >= 0 && hlist[last_hist] == 0)
@ -320,6 +328,8 @@ fc_builtin (list)
if (list)
histend = fc_gethnum (list->word->word, hlist);
else if (histbeg == real_last)
histend = listing ? real_last : histbeg;
else
histend = listing ? last_hist : histbeg;
}
@ -475,7 +485,7 @@ fc_gethnum (command, hlist)
HIST_ENTRY **hlist;
{
int sign, n, clen, rh;
register int i, j, last_hist;
register int i, j, last_hist, real_last;
register char *s;
sign = 1;
@ -503,12 +513,17 @@ fc_gethnum (command, hlist)
if (last_hist < 0)
return (-1);
real_last = i;
i = last_hist;
/* No specification defaults to most recent command. */
if (command == NULL)
return (i);
/* back up from the end to the last non-null history entry */
while (hlist[real_last] == 0 && real_last > 0)
real_last--;
/* Otherwise, there is a specification. It can be a number relative to
the current position, or an absolute history number. */
s = command;
@ -533,7 +548,7 @@ fc_gethnum (command, hlist)
return (n < 0 ? 0 : n);
}
else if (n == 0)
return (i);
return ((sign == -1) ? real_last : i);
else
{
n -= history_base;

197
builtins/gen-helpfiles.c Normal file
View file

@ -0,0 +1,197 @@
/* gen-helpfiles - create files containing builtin help text */
/* Copyright (C) 2012 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Bash is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Bash. If not, see <http://www.gnu.org/licenses/>.
*/
/* This links with a specially-generated version of builtins.c and takes
the long_doc members of each struct builtin element and writes those to
the file named by the `handle' member of the struct builtin element. */
#if !defined (CROSS_COMPILING)
# include <config.h>
#else /* CROSS_COMPILING */
/* A conservative set of defines based on POSIX/SUS3/XPG6 */
# define HAVE_UNISTD_H
# define HAVE_STRING_H
# define HAVE_STDLIB_H
# define HAVE_RENAME
#endif /* CROSS_COMPILING */
#if defined (HAVE_UNISTD_H)
# ifdef _MINIX
# include <sys/types.h>
# endif
# include <unistd.h>
#endif
#ifndef _MINIX
# include "../bashtypes.h"
# if defined (HAVE_SYS_FILE_H)
# include <sys/file.h>
# endif
#endif
#include "posixstat.h"
#include "filecntl.h"
#include "../bashansi.h"
#include <stdio.h>
#include <errno.h>
#include "stdc.h"
#include "../builtins.h"
#include "tmpbuiltins.h"
#if defined (USING_BASH_MALLOC)
#undef xmalloc
#undef xrealloc
#undef xfree
#undef free /* defined in xmalloc.h */
#endif
#ifndef errno
extern int errno;
#endif
#if !defined (__STDC__) && !defined (strcpy)
extern char *strcpy ();
#endif /* !__STDC__ && !strcpy */
#define whitespace(c) (((c) == ' ') || ((c) == '\t'))
/* Flag values that builtins can have. */
#define BUILTIN_FLAG_SPECIAL 0x01
#define BUILTIN_FLAG_ASSIGNMENT 0x02
#define BUILTIN_FLAG_POSIX_BUILTIN 0x04
#define BASE_INDENT 4
/* Non-zero means to produce separate help files for each builtin, named by
the builtin name, in `./helpfiles'. */
int separate_helpfiles = 0;
/* Non-zero means to create single C strings for each `longdoc', with
embedded newlines, for ease of translation. */
int single_longdoc_strings = 1;
/* The name of a directory into which the separate external help files will
eventually be installed. */
char *helpfile_directory;
/* Forward declarations. */
int write_helpfiles __P((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. */
int
main (argc, argv)
int argc;
char **argv;
{
int arg_index = 1;
while (arg_index < argc && argv[arg_index][0] == '-')
{
char *arg = argv[arg_index++];
if (strcmp (arg, "-noproduction") == 0)
;
else if (strcmp (arg, "-H") == 0)
helpfile_directory = argv[arg_index++];
else if (strcmp (arg, "-S") == 0)
single_longdoc_strings = 0;
else
{
fprintf (stderr, "%s: Unknown flag %s.\n", argv[0], arg);
exit (2);
}
}
write_helpfiles(shell_builtins);
exit (0);
}
/* Write DOCUMENTATION to STREAM, perhaps surrounding it with double-quotes
and quoting special characters in the string. Handle special things for
internationalization (gettext) and the single-string vs. multiple-strings
issues. */
void
write_documentation (stream, documentation, indentation)
FILE *stream;
char *documentation;
int indentation;
{
if (stream == 0)
return;
if (documentation)
fprintf (stream, "%*s%s\n", indentation, " ", documentation);
}
int
write_helpfiles (builtins)
struct builtin *builtins;
{
char *helpfile, *bname, *fname;
FILE *helpfp;
int i, hdlen;
struct builtin b;
i = mkdir ("helpfiles", 0777);
if (i < 0 && errno != EEXIST)
{
fprintf (stderr, "write_helpfiles: helpfiles: cannot create directory\n");
return -1;
}
hdlen = strlen ("helpfiles/");
for (i = 0; i < num_shell_builtins; i++)
{
b = builtins[i];
fname = (char *)b.handle;
helpfile = (char *)malloc (hdlen + strlen (fname) + 1);
if (helpfile == 0)
{
fprintf (stderr, "gen-helpfiles: cannot allocate memory\n");
exit (1);
}
sprintf (helpfile, "helpfiles/%s", fname);
helpfp = fopen (helpfile, "w");
if (helpfp == 0)
{
fprintf (stderr, "write_helpfiles: cannot open %s\n", helpfile);
free (helpfile);
continue;
}
write_documentation (helpfp, b.long_doc[0], 4);
fflush (helpfp);
fclose (helpfp);
free (helpfile);
}
return 0;
}

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-2010 Free Software Foundation, Inc.
Copyright (C) 1987-2013 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -31,7 +31,7 @@ no arguments are given, information about remembered commands is displayed.
Options:
-d forget the remembered location of each NAME
-l display in a format that may be reused as input
-p pathname use PATHNAME is the full pathname of NAME
-p pathname use PATHNAME as the full pathname of NAME
-r forget all remembered locations
-t print the remembered location of each NAME, preceding
each location with the corresponding NAME if multiple
@ -276,6 +276,7 @@ list_hashed_filename_targets (list, fmt)
printf ("%s\t", l->word->word);
printf ("%s\n", target);
}
free (target);
}
return (all_found ? EXECUTION_SUCCESS : EXECUTION_FAILURE);

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-2009 Free Software Foundation, Inc.
Copyright (C) 1987-2013 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -92,7 +92,7 @@ help_builtin (list)
{
register int i;
char *pattern, *name;
int plen, match_found, sflag, dflag, mflag;
int plen, match_found, sflag, dflag, mflag, m, pass, this_found;
dflag = sflag = mflag = 0;
reset_internal_getopt ();
@ -137,29 +137,43 @@ help_builtin (list)
pattern = list->word->word;
plen = strlen (pattern);
for (i = 0; name = shell_builtins[i].name; i++)
for (pass = 1, this_found = 0; pass < 3; pass++)
{
QUIT;
if ((strncmp (pattern, name, plen) == 0) ||
(strmatch (pattern, name, FNMATCH_EXTFLAG) != FNM_NOMATCH))
for (i = 0; name = shell_builtins[i].name; i++)
{
match_found++;
if (dflag)
{
show_desc (name, i);
continue;
}
else if (mflag)
{
show_manpage (name, i);
continue;
}
QUIT;
printf ("%s: %s\n", name, _(shell_builtins[i].short_doc));
/* First pass: look for exact string or pattern matches.
Second pass: look for prefix matches like bash-4.2 */
if (pass == 1)
m = (strcmp (pattern, name) == 0) ||
(strmatch (pattern, name, FNMATCH_EXTFLAG) != FNM_NOMATCH);
else
m = strncmp (pattern, name, plen) == 0;
if (sflag == 0)
show_longdoc (i);
if (m)
{
this_found = 1;
match_found++;
if (dflag)
{
show_desc (name, i);
continue;
}
else if (mflag)
{
show_manpage (name, i);
continue;
}
printf ("%s: %s\n", name, _(shell_builtins[i].short_doc));
if (sflag == 0)
show_longdoc (i);
}
}
if (pass == 1 && this_found == 1)
break;
}
}
@ -209,7 +223,7 @@ show_longdoc (i)
zcatfd (fd, 1, doc[0]);
close (fd);
}
else
else if (doc)
for (j = 0; doc[j]; j++)
printf ("%*s%s\n", BASE_INDENT, " ", _(doc[j]));
}
@ -326,6 +340,140 @@ show_manpage (name, i)
free (line);
}
static void
dispcolumn (i, buf, bufsize, width, height)
int i;
char *buf;
size_t bufsize;
int width, height;
{
int j;
int displen;
char *helpdoc;
/* first column */
helpdoc = _(shell_builtins[i].short_doc);
buf[0] = (shell_builtins[i].flags & BUILTIN_ENABLED) ? ' ' : '*';
strncpy (buf + 1, helpdoc, width - 2);
buf[width - 2] = '>'; /* indicate truncation */
buf[width - 1] = '\0';
printf ("%s", buf);
if (((i << 1) >= num_shell_builtins) || (i+height >= num_shell_builtins))
{
printf ("\n");
return;
}
displen = strlen (buf);
/* two spaces */
for (j = displen; j < width; j++)
putc (' ', stdout);
/* second column */
helpdoc = _(shell_builtins[i+height].short_doc);
buf[0] = (shell_builtins[i+height].flags & BUILTIN_ENABLED) ? ' ' : '*';
strncpy (buf + 1, helpdoc, width - 3);
buf[width - 3] = '>'; /* indicate truncation */
buf[width - 2] = '\0';
printf ("%s\n", buf);
}
#if defined (HANDLE_MULTIBYTE)
static void
wdispcolumn (i, buf, bufsize, width, height)
int i;
char *buf;
size_t bufsize;
int width, height;
{
int j;
int displen;
char *helpdoc;
wchar_t *wcstr;
size_t slen, n;
int wclen;
/* first column */
helpdoc = _(shell_builtins[i].short_doc);
wcstr = 0;
slen = mbstowcs ((wchar_t *)0, helpdoc, 0);
if (slen == -1)
{
dispcolumn (i, buf, bufsize, width, height);
return;
}
/* No bigger than the passed max width */
if (slen >= width)
slen = width - 2;
wcstr = (wchar_t *)xmalloc (sizeof (wchar_t) * (width + 2));
n = mbstowcs (wcstr+1, helpdoc, slen + 1);
wcstr[n+1] = L'\0';
/* Turn tabs and newlines into spaces for column display, since wcwidth
returns -1 for them */
for (j = 1; j < n; j++)
if (wcstr[j] == L'\n' || wcstr[j] == L'\t')
wcstr[j] = L' ';
displen = wcsnwidth (wcstr+1, slen, width - 2) + 1; /* +1 for ' ' or '*' */
wcstr[0] = (shell_builtins[i].flags & BUILTIN_ENABLED) ? L' ' : L'*';
/* This assumes each wide char takes up one column position when displayed */
wcstr[width - 2] = L'>'; /* indicate truncation */
wcstr[width - 1] = L'\0';
printf ("%ls", wcstr);
if (((i << 1) >= num_shell_builtins) || (i+height >= num_shell_builtins))
{
printf ("\n");
return;
}
/* at least one space */
for (j = displen; j < width; j++)
putc (' ', stdout);
/* second column */
helpdoc = _(shell_builtins[i+height].short_doc);
slen = mbstowcs ((wchar_t *)0, helpdoc, 0);
if (slen == -1)
{
/* for now */
printf ("%c%s\n", (shell_builtins[i+height].flags & BUILTIN_ENABLED) ? ' ' : '*', helpdoc);
return;
}
/* Reuse wcstr since it is already width wide chars long */
if (slen >= width)
slen = width - 2;
n = mbstowcs (wcstr+1, helpdoc, slen + 1);
wcstr[n+1] = L'\0'; /* make sure null-terminated */
/* Turn tabs and newlines into spaces for column display */
for (j = 1; j < n; j++)
if (wcstr[j] == L'\n' || wcstr[j] == L'\t')
wcstr[j] = L' ';
displen = wcsnwidth (wcstr+1, slen, width - 2);
wcstr[0] = (shell_builtins[i+height].flags & BUILTIN_ENABLED) ? L' ' : L'*';
/* This assumes each wide char takes up one column position when displayed */
wcstr[width - 3] = L'>'; /* indicate truncation */
wcstr[width - 2] = L'\0';
printf ("%ls\n", wcstr);
free (wcstr);
}
#endif /* HANDLE_MULTIBYTE */
static void
show_builtin_command_help ()
{
@ -358,28 +506,12 @@ A star (*) next to a name means that the command is disabled.\n\
{
QUIT;
/* first column */
blurb[0] = (shell_builtins[i].flags & BUILTIN_ENABLED) ? ' ' : '*';
strncpy (blurb + 1, _(shell_builtins[i].short_doc), width - 2);
blurb[width - 2] = '>'; /* indicate truncation */
blurb[width - 1] = '\0';
printf ("%s", blurb);
if (((i << 1) >= num_shell_builtins) || (i+height >= num_shell_builtins))
{
printf ("\n");
break;
}
/* two spaces */
for (j = strlen (blurb); j < width; j++)
putc (' ', stdout);
/* second column */
blurb[0] = (shell_builtins[i+height].flags & BUILTIN_ENABLED) ? ' ' : '*';
strncpy (blurb + 1, _(shell_builtins[i+height].short_doc), width - 3);
blurb[width - 3] = '>'; /* indicate truncation */
blurb[width - 2] = '\0';
printf ("%s\n", blurb);
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1)
wdispcolumn (i, blurb, sizeof (blurb), width, height);
else
#endif
dispcolumn (i, blurb, sizeof (blurb), width, height);
}
}
#endif /* HELP_BUILTIN */

View file

@ -324,9 +324,10 @@ push_history (list)
If you don't want history -s to remove the compound command from the
history, change #if 0 to #if 1 below. */
#if 0
if (hist_last_line_pushed == 0 && hist_last_line_added && bash_delete_last_history () == 0)
if (remember_on_history && hist_last_line_pushed == 0 &&
hist_last_line_added && bash_delete_last_history () == 0)
#else
if (hist_last_line_pushed == 0 &&
if (remember_on_history && hist_last_line_pushed == 0 &&
(hist_last_line_added ||
(current_command_line_count > 0 && current_command_first_line_saved && command_oriented_history))
&& bash_delete_last_history () == 0)

View file

@ -31,7 +31,7 @@ Without options, the status of all active jobs is displayed.
Options:
-l lists process IDs in addition to the normal information
-n list only processes that have changed status since the last
-n lists only processes that have changed status since the last
notification
-p lists process IDs only
-r restrict output to running jobs

View file

@ -57,6 +57,8 @@ $END
#include "../bashansi.h"
#include "../bashintl.h"
#include <signal.h>
#include "../shell.h"
#include "../trap.h"
#include "../jobs.h"
@ -92,7 +94,7 @@ kill_builtin (list)
if (list == 0)
{
builtin_usage ();
return (EXECUTION_FAILURE);
return (EX_USAGE);
}
any_succeeded = listing = saw_signal = 0;
@ -137,7 +139,7 @@ kill_builtin (list)
else if (ISOPTION (word, '?'))
{
builtin_usage ();
return (EXECUTION_SUCCESS);
return (EX_USAGE);
}
/* If this is a signal specification then process it. We only process
the first one seen; other arguments may signify process groups (e.g,
@ -166,7 +168,7 @@ kill_builtin (list)
if (list == 0)
{
builtin_usage ();
return (EXECUTION_FAILURE);
return (EX_USAGE);
}
while (list)

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-2010 Free Software Foundation, Inc.
Copyright (C) 2008-2012 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -125,7 +125,7 @@ run_callback (callback, curindex, curline)
#endif
snprintf (execstr, execlen, "%s %d %s", callback, curindex, qline);
free (qline);
return parse_and_execute (execstr, NULL, flags);
return evalstring (execstr, NULL, flags);
}
static void
@ -172,6 +172,8 @@ mapfile (fd, line_count_goal, origin, nskip, callback_quantum, callback, array_n
builtin_error (_("%s: not an indexed array"), array_name);
return (EXECUTION_FAILURE);
}
else if (invisible_p (entry))
VUNSETATTR (entry, att_invisible); /* no longer invisible */
if (flags & MAPF_CLEARARRAY)
array_flush (array_cell (entry));
@ -193,7 +195,6 @@ mapfile (fd, line_count_goal, origin, nskip, callback_quantum, callback, array_n
line_length = 0;
/* Reset the buffer for bash own stream */
interrupt_immediately++;
for (array_index = origin, line_count = 1;
zgetline (fd, &line, &line_length, unbuffered_read) != -1;
array_index++)
@ -212,6 +213,8 @@ mapfile (fd, line_count_goal, origin, nskip, callback_quantum, callback, array_n
zsyncfd (fd);
}
/* XXX - bad things can happen if the callback modifies ENTRY, e.g.,
unsetting it or changing it to a non-indexed-array type. */
bind_array_element (entry, array_index, line, 0);
/* Have we exceeded # of lines to store? */
@ -225,7 +228,6 @@ mapfile (fd, line_count_goal, origin, nskip, callback_quantum, callback, array_n
if (unbuffered_read == 0)
zsyncfd (fd);
interrupt_immediately--;
return EXECUTION_SUCCESS;
}

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-2010 Free Software Foundation, Inc.
/* Copyright (C) 1987-2011 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -85,6 +85,10 @@ int only_documentation = 0;
/* Non-zero means to not do any productions. */
int inhibit_production = 0;
/* Non-zero means to not add functions (xxx_builtin) to the members of the
produced `struct builtin []' */
int inhibit_functions = 0;
/* Non-zero means to produce separate help files for each builtin, named by
the builtin name, in `./helpfiles'. */
int separate_helpfiles = 0;
@ -198,7 +202,7 @@ void remove_trailing_whitespace ();
/* 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;
@ -222,6 +226,8 @@ main (argc, argv)
struct_filename = argv[arg_index++];
else if (strcmp (arg, "-noproduction") == 0)
inhibit_production = 1;
else if (strcmp (arg, "-nofunctions") == 0)
inhibit_functions = 1;
else if (strcmp (arg, "-document") == 0)
documentation_file = fopen (documentation_filename, "w");
else if (strcmp (arg, "-D") == 0)
@ -322,10 +328,13 @@ main (argc, argv)
fclose (externfile);
}
#if 0
/* This is now done by a different program */
if (separate_helpfiles)
{
write_helpfiles (saved_builtins);
}
#endif
if (documentation_file)
{
@ -390,7 +399,7 @@ copy_string_array (array)
return (copy);
}
/* Add ELEMENT to ARRAY, growing the array if neccessary. */
/* Add ELEMENT to ARRAY, growing the array if necessary. */
void
array_add (element, array)
char *element;
@ -519,6 +528,7 @@ extract_info (filename, structfile, externfile)
if (nr == 0)
{
fprintf (stderr, "mkbuiltins: %s: skipping zero-length file\n", filename);
free (buffer);
return;
}
@ -537,7 +547,7 @@ extract_info (filename, structfile, externfile)
{
array_add (&buffer[i], defs->lines);
while (buffer[i] != '\n' && i < file_size)
while (i < file_size && buffer[i] != '\n')
i++;
buffer[i++] = '\0';
}
@ -1092,7 +1102,7 @@ char *structfile_header[] = {
"/* This file is manufactured by ./mkbuiltins, and should not be",
" edited by hand. See the source to mkbuiltins for details. */",
"",
"/* Copyright (C) 1987-2009 Free Software Foundation, Inc.",
"/* Copyright (C) 1987-2012 Free Software Foundation, Inc.",
"",
" This file is part of GNU Bash, the Bourne Again SHell.",
"",
@ -1138,7 +1148,7 @@ char *structfile_footer[] = {
(char *)NULL
};
/* Write out any neccessary opening information for
/* Write out any necessary opening information for
STRUCTFILE and EXTERNFILE. */
void
write_file_headers (structfile, externfile)
@ -1224,7 +1234,7 @@ write_builtins (defs, structfile, externfile)
{
fprintf (structfile, " { \"%s\", ", builtin->name);
if (builtin->function)
if (builtin->function && inhibit_functions == 0)
fprintf (structfile, "%s, ", builtin->function);
else
fprintf (structfile, "(sh_builtin_func_t *)0x0, ");
@ -1236,9 +1246,15 @@ write_builtins (defs, structfile, externfile)
(builtin->flags & BUILTIN_FLAG_POSIX_BUILTIN) ? " | POSIX_BUILTIN" : "",
document_name (builtin));
fprintf
(structfile, " N_(\"%s\"), (char *)NULL },\n",
builtin->shortdoc ? builtin->shortdoc : builtin->name);
if (inhibit_functions)
fprintf
(structfile, " N_(\"%s\"), \"%s\" },\n",
builtin->shortdoc ? builtin->shortdoc : builtin->name,
document_name (builtin));
else
fprintf
(structfile, " N_(\"%s\"), (char *)NULL },\n",
builtin->shortdoc ? builtin->shortdoc : builtin->name);
}
@ -1247,7 +1263,7 @@ write_builtins (defs, structfile, externfile)
long documentation strings. */
save_builtin (builtin);
/* Write out the matching #endif, if neccessary. */
/* Write out the matching #endif, if necessary. */
if (builtin->dependencies)
{
if (externfile)
@ -1308,6 +1324,26 @@ write_longdocs (stream, builtins)
}
}
void
write_dummy_declarations (stream, builtins)
FILE *stream;
ARRAY *builtins;
{
register int i;
BUILTIN_DESC *builtin;
for (i = 0; structfile_header[i]; i++)
fprintf (stream, "%s\n", structfile_header[i]);
for (i = 0; i < builtins->sindex; i++)
{
builtin = (BUILTIN_DESC *)builtins->array[i];
/* How to guarantee that no builtin is written more than once? */
fprintf (stream, "int %s () { return (0); }\n", builtin->function);
}
}
/* Write an #ifdef string saying what needs to be defined (or not defined)
in order to allow compilation of the code that will follow.
STREAM is the stream to write the information to,
@ -1407,7 +1443,7 @@ write_documentation (stream, documentation, indentation, flags)
base_indent = (string_array && single_longdoc_strings && filename_p == 0) ? BASE_INDENT : 0;
for (i = 0, texinfo = (flags & TEXINFO); line = documentation[i]; i++)
for (i = 0, texinfo = (flags & TEXINFO); documentation && (line = documentation[i]); i++)
{
/* Allow #ifdef's to be written out verbatim, but don't put them into
separate help files. */

View file

@ -35,14 +35,19 @@ sequences, which are converted and copied to the standard output; and
format specifications, each of which causes printing of the next successive
argument.
In addition to the standard format specifications described in printf(1)
and printf(3), printf interprets:
In addition to the standard format specifications described in printf(1),
printf interprets:
%b expand backslash escape sequences in the corresponding argument
%q quote the argument in a way that can be reused as shell input
%(fmt)T output the date-time string resulting from using FMT as a format
string for strftime(3)
The format is re-used as necessary to consume all of the arguments. If
there are fewer arguments than the format requires, extra format
specifications behave as if a zero value or null string, as appropriate,
had been supplied.
Exit Status:
Returns success unless an invalid option is given or a write or assignment
error occurs.
@ -158,7 +163,8 @@ extern int errno;
else if (vbuf) \
vbuf[0] = 0; \
terminate_immediately--; \
fflush (stdout); \
if (ferror (stdout) == 0) \
fflush (stdout); \
if (ferror (stdout)) \
{ \
sh_wrerror (); \
@ -460,7 +466,8 @@ printf_builtin (list)
timefmt[2] = '\0';
}
/* argument is seconds since the epoch with special -1 and -2 */
arg = getintmax ();
/* default argument is equivalent to -1; special case */
arg = garglist ? getintmax () : -1;
if (arg == -1)
secs = NOW; /* roughly date +%s */
else if (arg == -2)
@ -471,7 +478,12 @@ printf_builtin (list)
sv_tz ("TZ"); /* XXX -- just make sure */
#endif
tm = localtime (&secs);
n = strftime (timebuf, sizeof (timebuf), timefmt, tm);
if (tm == 0)
{
secs = 0;
tm = localtime (&secs);
}
n = tm ? strftime (timebuf, sizeof (timebuf), timefmt, tm) : 0;
free (timefmt);
if (n == 0)
timebuf[0] = '\0';
@ -483,8 +495,11 @@ printf_builtin (list)
n = printstr (start, timebuf, strlen (timebuf), fieldwidth, precision); /* XXX - %s for now */
if (n < 0)
{
sh_wrerror ();
clearerr (stdout);
if (ferror (stdout) == 0)
{
sh_wrerror ();
clearerr (stdout);
}
PRETURN (EXECUTION_FAILURE);
}
break;
@ -524,8 +539,11 @@ printf_builtin (list)
r = printstr (start, xp, rlen, fieldwidth, precision);
if (r < 0)
{
sh_wrerror ();
clearerr (stdout);
if (ferror (stdout) == 0)
{
sh_wrerror ();
clearerr (stdout);
}
retval = EXECUTION_FAILURE;
}
free (xp);
@ -548,7 +566,7 @@ printf_builtin (list)
else if (ansic_shouldquote (p))
xp = ansic_quote (p, 0, (int *)0);
else
xp = sh_backslash_quote (p);
xp = sh_backslash_quote (p, 0, 1);
if (xp)
{
/* Use printstr to get fieldwidth and precision right. */
@ -647,8 +665,7 @@ printf_builtin (list)
if (ferror (stdout))
{
sh_wrerror ();
clearerr (stdout);
/* PRETURN will print error message. */
PRETURN (EXECUTION_FAILURE);
}
}
@ -681,12 +698,9 @@ printstr (fmt, string, len, fieldwidth, precision)
#endif
int padlen, nc, ljust, i;
int fw, pr; /* fieldwidth and precision */
intmax_t mfw, mpr;
#if 0
if (string == 0 || *string == '\0')
#else
if (string == 0 || len == 0)
#endif
return 0;
#if 0
@ -697,6 +711,8 @@ printstr (fmt, string, len, fieldwidth, precision)
ljust = fw = 0;
pr = -1;
mfw = 0;
mpr = -1;
/* skip flags */
while (strchr (SKIP1, *fmt))
@ -706,7 +722,7 @@ printstr (fmt, string, len, fieldwidth, precision)
fmt++;
}
/* get fieldwidth, if present */
/* get fieldwidth, if present. rely on caller to clamp fieldwidth at INT_MAX */
if (*fmt == '*')
{
fmt++;
@ -719,9 +735,11 @@ printstr (fmt, string, len, fieldwidth, precision)
}
else if (DIGIT (*fmt))
{
fw = *fmt++ - '0';
mfw = *fmt++ - '0';
while (DIGIT (*fmt))
fw = (fw * 10) + (*fmt++ - '0');
mfw = (mfw * 10) + (*fmt++ - '0');
/* Error if fieldwidth > INT_MAX here? */
fw = (mfw < 0 || mfw > INT_MAX) ? INT_MAX : mfw;
}
/* get precision, if present */
@ -735,9 +753,11 @@ printstr (fmt, string, len, fieldwidth, precision)
}
else if (DIGIT (*fmt))
{
pr = *fmt++ - '0';
mpr = *fmt++ - '0';
while (DIGIT (*fmt))
pr = (pr * 10) + (*fmt++ - '0');
mpr = (mpr * 10) + (*fmt++ - '0');
/* Error if precision > INT_MAX here? */
pr = (mpr < 0 || mpr > INT_MAX) ? INT_MAX : mpr;
}
}
@ -745,7 +765,7 @@ printstr (fmt, string, len, fieldwidth, precision)
/* If we remove this, get rid of `s'. */
if (*fmt != 'b' && *fmt != 'q')
{
internal_error ("format parsing problem: %s", s);
internal_error (_("format parsing problem: %s"), s);
fw = pr = 0;
}
#endif
@ -861,7 +881,7 @@ tescape (estart, cp, lenp, sawc)
*cp = '\\';
return 0;
}
if (uvalue <= UCHAR_MAX)
if (uvalue <= 0x7f) /* <= 0x7f translates directly */
*cp = uvalue;
else
{
@ -1089,6 +1109,9 @@ getint ()
ret = getintmax ();
if (garglist == 0)
return ret;
if (ret > INT_MAX)
{
printf_erange (garglist->word->word);
@ -1229,12 +1252,19 @@ bind_printf_variable (name, value, flags)
char *value;
int flags;
{
SHELL_VAR *v;
#if defined (ARRAY_VARS)
if (valid_array_reference (name) == 0)
return (bind_variable (name, value, flags));
v = bind_variable (name, value, flags);
else
return (assign_array_element (name, value, flags));
v = assign_array_element (name, value, flags);
#else /* !ARRAY_VARS */
return bind_variable (name, value, flags);
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;
}

View file

@ -27,7 +27,7 @@ echo ""
#
# Try to avoid tempfile races. We can't really check for the file's
# existance before we run psize.aux, because `test -e' is not portable,
# existence before we run psize.aux, because `test -e' is not portable,
# `test -h' (test for symlinks) is not portable, and `test -f' only
# checks for regular files. If we used mktemp(1), we're ahead of the
# game.

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-2009 Free Software Foundation, Inc.
Copyright (C) 1987-2013 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -115,7 +115,7 @@ $END
#if defined (PUSHD_AND_POPD)
#include <stdio.h>
#ifndef _MINIX
#if defined (HAVE_SYS_PARAM_H)
# include <sys/param.h>
#endif
@ -228,7 +228,7 @@ pushd_builtin (list)
{
sh_invalidnum (list->word->word);
builtin_usage ();
return (EXECUTION_FAILURE);
return (EX_USAGE);
}
if (direction == '-')
@ -245,7 +245,7 @@ pushd_builtin (list)
{
sh_invalidopt (list->word->word);
builtin_usage ();
return (EXECUTION_FAILURE);
return (EX_USAGE);
}
else
break;
@ -339,7 +339,7 @@ popd_builtin (list)
{
sh_invalidnum (list->word->word);
builtin_usage ();
return (EXECUTION_FAILURE);
return (EX_USAGE);
}
which_word = list->word->word;
}
@ -347,7 +347,13 @@ popd_builtin (list)
{
sh_invalidopt (list->word->word);
builtin_usage ();
return (EXECUTION_FAILURE);
return (EX_USAGE);
}
else if (*list->word->word)
{
builtin_error (_("%s: invalid argument"), list->word->word);
builtin_usage ();
return (EX_USAGE);
}
else
break;
@ -426,7 +432,7 @@ dirs_builtin (list)
{
sh_invalidnum (list->word->word);
builtin_usage ();
return (EXECUTION_FAILURE);
return (EX_USAGE);
}
sign = (*list->word->word == '+') ? 1 : -1;
desired_index = get_dirstack_index (i, sign, &index_flag);
@ -435,7 +441,7 @@ dirs_builtin (list)
{
sh_invalidopt (list->word->word);
builtin_usage ();
return (EXECUTION_FAILURE);
return (EX_USAGE);
}
}

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-2010 Free Software Foundation, Inc.
Copyright (C) 1987-2012 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -51,15 +51,17 @@ Options:
-r do not allow backslashes to escape any characters
-s do not echo input coming from a terminal
-t timeout time out and return failure if a complete line of input is
not read withint TIMEOUT seconds. The value of the TMOUT
not read within TIMEOUT seconds. The value of the TMOUT
variable is the default timeout. TIMEOUT may be a
fractional number. If TIMEOUT is 0, read returns success only
if input is available on the specified file descriptor. The
fractional number. If TIMEOUT is 0, read returns immediately,
without trying to read any data, returning success only if
input is available on the specified file descriptor. The
exit status is greater than 128 if the timeout is exceeded
-u fd read from file descriptor FD instead of the standard input
Exit Status:
The return code is zero, unless end-of-file is encountered, read times out,
The return code is zero, unless end-of-file is encountered, read times out
(in which case it's greater than 128), a variable assignment error occurs,
or an invalid file descriptor is supplied as the argument to -u.
$END
@ -101,10 +103,17 @@ $END
# include "input.h"
#endif
#include "shmbutil.h"
#if !defined(errno)
extern int errno;
#endif
extern void run_pending_traps __P((void));
extern int posixly_correct;
extern int trapped_signal_received;
struct ttsave
{
int fd;
@ -127,15 +136,26 @@ static void ttyrestore __P((struct ttsave *));
static sighandler sigalrm __P((int));
static void reset_alarm __P((void));
static procenv_t alrmbuf;
/* Try this to see what the rest of the shell can do with the information. */
procenv_t alrmbuf;
int sigalrm_seen;
static int reading;
static SigHandler *old_alrm;
static unsigned char delim;
/* In all cases, SIGALRM just sets a flag that we check periodically. This
avoids problems with the semi-tricky stuff we do with the xfree of
input_string at the top of the unwind-protect list (see below). */
/* Set a flag that CHECK_ALRM can check. This relies on zread calling
trap.c:check_signals_and_traps(), which knows about sigalrm_seen and
alrmbuf. */
static sighandler
sigalrm (s)
int s;
{
longjmp (alrmbuf, 1);
sigalrm_seen = 1;
}
static void
@ -158,7 +178,7 @@ read_builtin (list)
register char *varname;
int size, i, nr, pass_next, saw_escape, eof, opt, retval, code, print_ps2;
int input_is_tty, input_is_pipe, unbuffered_read, skip_ctlesc, skip_ctlnul;
int raw, edit, nchars, silent, have_timeout, ignore_delim, fd;
int raw, edit, nchars, silent, have_timeout, ignore_delim, fd, lastsig, t_errno;
unsigned int tmsec, tmusec;
long ival, uval;
intmax_t intval;
@ -199,6 +219,9 @@ read_builtin (list)
#endif
USE_VAR(list);
USE_VAR(ps2);
USE_VAR(lastsig);
sigalrm_seen = reading = 0;
i = 0; /* Index into the string that we are reading. */
raw = edit = 0; /* Not reading raw input by default. */
@ -306,6 +329,18 @@ read_builtin (list)
return (input_avail (fd) ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
#endif
/* Convenience: check early whether or not the first of possibly several
variable names is a valid identifier, and bail early if so. */
#if defined (ARRAY_VARS)
if (list && legal_identifier (list->word->word) == 0 && valid_array_reference (list->word->word) == 0)
#else
if (list && legal_identifier (list->word->word) == 0)
#endif
{
sh_invalidid (list->word->word);
return (EXECUTION_FAILURE);
}
/* If we're asked to ignore the delimiter, make sure we do. */
if (ignore_delim)
delim = -1;
@ -380,14 +415,15 @@ read_builtin (list)
if (tmsec > 0 || tmusec > 0)
{
code = setjmp (alrmbuf);
code = setjmp_nosigs (alrmbuf);
if (code)
{
sigalrm_seen = 0;
/* Tricky. The top of the unwind-protect stack is the free of
input_string. We want to run all the rest and use input_string,
so we have to save input_string temporarily, run the unwind-
protects, then restore input_string so we can use it later. */
protects, then restore input_string so we can use it later */
orig_input_string = 0;
input_string[i] = '\0'; /* make sure it's terminated */
if (i == 0)
{
@ -464,10 +500,12 @@ read_builtin (list)
/* 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);
interrupt_immediately++;
terminate_immediately++;
unbuffered_read = (nchars > 0) || (delim != '\n') || input_is_pipe;
CHECK_ALRM;
if ((nchars > 0) && (input_is_tty == 0) && ignore_delim) /* read -N */
unbuffered_read = 2;
else if ((nchars > 0) || (delim != '\n') || input_is_pipe)
unbuffered_read = 1;
if (prompt && edit == 0)
{
@ -482,6 +520,8 @@ read_builtin (list)
ps2 = 0;
for (print_ps2 = eof = retval = 0;;)
{
CHECK_ALRM;
#if defined (READLINE)
if (edit)
{
@ -492,7 +532,9 @@ read_builtin (list)
}
if (rlbuf == 0)
{
reading = 1;
rlbuf = edit_line (prompt ? prompt : "", itext);
reading = 0;
rlind = 0;
}
if (rlbuf == 0)
@ -515,26 +557,58 @@ read_builtin (list)
print_ps2 = 0;
}
if (unbuffered_read)
retval = zread (fd, &c, 1);
#if 0
if (posixly_correct == 0)
interrupt_immediately++;
#endif
reading = 1;
if (unbuffered_read == 2)
retval = posixly_correct ? zreadintr (fd, &c, 1) : zreadn (fd, &c, nchars - nr);
else if (unbuffered_read)
retval = posixly_correct ? zreadintr (fd, &c, 1) : zread (fd, &c, 1);
else
retval = zreadc (fd, &c);
retval = posixly_correct ? zreadcintr (fd, &c) : zreadc (fd, &c);
reading = 0;
#if 0
if (posixly_correct == 0)
interrupt_immediately--;
#endif
if (retval <= 0)
{
if (retval < 0 && errno == EINTR)
{
lastsig = LASTSIG();
if (lastsig == 0)
lastsig = trapped_signal_received;
run_pending_traps (); /* because interrupt_immediately is not set */
}
else
lastsig = 0;
CHECK_TERMSIG;
eof = 1;
break;
}
CHECK_ALRM;
#if defined (READLINE)
}
#endif
CHECK_ALRM;
if (i + 4 >= size) /* XXX was i + 2; use i + 4 for multibyte/read_mbchar */
{
input_string = (char *)xrealloc (input_string, size += 128);
remove_unwind_protect ();
add_unwind_protect (xfree, input_string);
char *t;
t = (char *)xrealloc (input_string, size += 128);
/* Only need to change unwind-protect if input_string changes */
if (t != input_string)
{
input_string = t;
remove_unwind_protect ();
add_unwind_protect (xfree, input_string);
}
}
/* If the next character is to be accepted verbatim, a backslash
@ -565,9 +639,12 @@ read_builtin (list)
continue;
}
if ((unsigned char)c == delim)
if (ignore_delim == 0 && (unsigned char)c == delim)
break;
if (c == '\0' && delim != '\0')
continue; /* skip NUL bytes in input */
if ((skip_ctlesc == 0 && c == CTLESC) || (skip_ctlnul == 0 && c == CTLNUL))
{
saw_escape++;
@ -576,9 +653,10 @@ read_builtin (list)
add_char:
input_string[i++] = c;
CHECK_ALRM;
#if defined (HANDLE_MULTIBYTE)
if (nchars > 0 && MB_CUR_MAX > 1)
if (nchars > 0 && MB_CUR_MAX > 1 && is_basic (c) == 0)
{
input_string[i] = '\0'; /* for simplicity and debugging */
i += read_mbchar (fd, input_string, i, c, unbuffered_read);
@ -591,15 +669,16 @@ add_char:
break;
}
input_string[i] = '\0';
CHECK_ALRM;
#if 1
if (retval < 0)
{
builtin_error (_("read error: %d: %s"), fd, strerror (errno));
t_errno = errno;
if (errno != EINTR)
builtin_error (_("read error: %d: %s"), fd, strerror (errno));
run_unwind_frame ("read_builtin");
return (EXECUTION_FAILURE);
return ((t_errno != EINTR) ? EXECUTION_FAILURE : 128+lastsig);
}
#endif
if (tmsec > 0 || tmusec > 0)
reset_alarm ();
@ -631,9 +710,6 @@ add_char:
assign_vars:
interrupt_immediately--;
terminate_immediately--;
#if defined (ARRAY_VARS)
/* If -a was given, take the string read, break it into a list of words,
an assign them to `arrayname' in turn. */
@ -658,6 +734,8 @@ assign_vars:
xfree (input_string);
return EXECUTION_FAILURE; /* existing associative array */
}
else if (invisible_p (var))
VUNSETATTR (var, att_invisible);
array_flush (array_cell (var));
alist = list_string (input_string, ifs_chars, 0);
@ -703,7 +781,7 @@ assign_vars:
var = bind_variable ("REPLY", input_string, 0);
VUNSETATTR (var, att_invisible);
free (input_string);
xfree (input_string);
return (retval);
}
@ -829,6 +907,7 @@ bind_read_variable (name, value)
char *name, *value;
{
SHELL_VAR *v;
#if defined (ARRAY_VARS)
if (valid_array_reference (name) == 0)
v = bind_variable (name, value, 0);
@ -867,6 +946,7 @@ read_mbchar (fd, string, ind, ch, unbuffered)
if (ret == (size_t)-2)
{
ps = ps_back;
/* We don't want to be interrupted during a multibyte char read */
if (unbuffered)
r = zread (fd, &c, 1);
else
@ -947,7 +1027,9 @@ edit_line (p, itext)
rl_startup_hook = set_itext;
deftext = itext;
}
ret = readline (p);
rl_attempted_completion_function = old_attempted_completion_function;
old_attempted_completion_function = (rl_completion_func_t *)NULL;

View file

@ -60,9 +60,11 @@ int
return_builtin (list)
WORD_LIST *list;
{
#if 0
if (no_options (list))
return (EX_USAGE);
list = loptend; /* skip over possible `--' */
#endif
return_catch_value = get_exitstat (list);

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-2009 Free Software Foundation, Inc.
Copyright (C) 1987-2012 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -96,12 +96,16 @@ Options:
interactive-comments
allow comments to appear in interactive commands
keyword same as -k
#if defined (JOB_CONTROL)
monitor same as -m
#endif
noclobber same as -C
noexec same as -n
noglob same as -f
nolog currently accepted but ignored
#if defined (JOB_CONTROL)
notify same as -b
#endif
nounset same as -u
onecmd same as -t
physical same as -P
@ -135,7 +139,7 @@ Options:
-H Enable ! style history substitution. This flag is on
by default when the shell is interactive.
#endif /* BANG_HISTORY */
-P If set, do not follow symbolic links when executing commands
-P If set, do not resolve symbolic links when executing commands
such as cd which change the current directory.
-T If set, the DEBUG trap is inherited by shell functions.
-- Assign any remaining arguments to the positional parameters.
@ -205,7 +209,9 @@ const struct {
{ "ignoreeof", '\0', &ignoreeof, set_ignoreeof, (setopt_get_func_t *)NULL },
{ "interactive-comments", '\0', &interactive_comments, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL },
{ "keyword", 'k', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL },
#if defined (JOB_CONTROL)
{ "monitor", 'm', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL },
#endif
{ "noclobber", 'C', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL },
{ "noexec", 'n', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL },
{ "noglob", 'f', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL },
@ -718,7 +724,7 @@ set_builtin (list)
$BUILTIN unset
$FUNCTION unset_builtin
$SHORT_DOC unset [-f] [-v] [name ...]
$SHORT_DOC unset [-f] [-v] [-n] [name ...]
Unset values and attributes of shell variables and functions.
For each NAME, remove the corresponding variable or function.
@ -726,6 +732,8 @@ For each NAME, remove the corresponding variable or function.
Options:
-f treat each NAME as a shell function
-v treat each NAME as a shell variable
-n treat each NAME as a name reference and unset the variable itself
rather than the variable it references
Without options, unset first tries to unset a variable, and if that fails,
tries to unset a function.
@ -742,13 +750,13 @@ int
unset_builtin (list)
WORD_LIST *list;
{
int unset_function, unset_variable, unset_array, opt, any_failed;
int unset_function, unset_variable, unset_array, opt, nameref, any_failed;
char *name;
unset_function = unset_variable = unset_array = any_failed = 0;
unset_function = unset_variable = unset_array = nameref = any_failed = 0;
reset_internal_getopt ();
while ((opt = internal_getopt (list, "fv")) != -1)
while ((opt = internal_getopt (list, "fnv")) != -1)
{
switch (opt)
{
@ -758,6 +766,9 @@ unset_builtin (list)
case 'v':
unset_variable = 1;
break;
case 'n':
nameref = 1;
break;
default:
builtin_usage ();
return (EX_USAGE);
@ -771,6 +782,8 @@ unset_builtin (list)
builtin_error (_("cannot simultaneously unset a function and a variable"));
return (EXECUTION_FAILURE);
}
else if (unset_function && nameref)
nameref = 0;
while (list)
{
@ -791,6 +804,8 @@ unset_builtin (list)
unset_array++;
}
#endif
/* Get error checking out of the way first. The low-level functions
just perform the unset, relying on the caller to verify. */
/* Bash allows functions with names which are not valid identifiers
to be created when not in posix mode, so check only when in posix
@ -801,19 +816,32 @@ unset_builtin (list)
NEXT_VARIABLE ();
}
var = unset_function ? find_function (name) : find_variable (name);
/* Only search for functions here if -f supplied. */
var = unset_function ? find_function (name)
: (nameref ? find_variable_last_nameref (name) : find_variable (name));
if (var && !unset_function && non_unsettable_p (var))
/* Some variables (but not functions yet) cannot be unset, period. */
if (var && unset_function == 0 && non_unsettable_p (var))
{
builtin_error (_("%s: cannot unset"), name);
NEXT_VARIABLE ();
}
/* Posix.2 says try variables first, then functions. If we would
find a function after unsuccessfully searching for a variable,
note that we're acting on a function now as if -f were
supplied. The readonly check below takes care of it. */
if (var == 0 && unset_variable == 0 && unset_function == 0)
{
if (var = find_function (name))
unset_function = 1;
}
/* Posix.2 says that unsetting readonly variables is an error. */
if (var && readonly_p (var))
{
builtin_error (_("%s: cannot unset: readonly %s"),
name, unset_function ? "function" : "variable");
var->name, unset_function ? "function" : "variable");
NEXT_VARIABLE ();
}
@ -823,7 +851,7 @@ unset_builtin (list)
{
if (array_p (var) == 0 && assoc_p (var) == 0)
{
builtin_error (_("%s: not an array variable"), name);
builtin_error (_("%s: not an array variable"), var->name);
NEXT_VARIABLE ();
}
else
@ -835,13 +863,13 @@ unset_builtin (list)
}
else
#endif /* ARRAY_VARS */
tem = unset_function ? unbind_func (name) : unbind_variable (name);
tem = unset_function ? unbind_func (name) : (nameref ? unbind_nameref (name) : unbind_variable (name));
/* This is what Posix.2 draft 11+ says. ``If neither -f nor -v
/* This is what Posix.2 says: ``If neither -f nor -v
is specified, the name refers to a variable; if a variable by
that name does not exist, a function by that name, if any,
shall be unset.'' */
if (tem == -1 && !unset_function && !unset_variable)
if (tem == -1 && unset_function == 0 && unset_variable == 0)
tem = unbind_func (name);
/* SUSv3, POSIX.1-2001 say: ``Unsetting a variable or function that

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-2010 Free Software Foundation, Inc.
Copyright (C) 1987-2012 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -93,7 +93,8 @@ Options:
-a refer to indexed array variables
-A refer to associative array variables
-f refer to shell functions
-p display a list of all readonly variables and functions
-p display a list of all readonly variables or functions, depending on
whether or not the -f option is given
An argument of `--' disables further option processing.
@ -368,6 +369,9 @@ show_var_attributes (var, pattr, nodefs)
if (integer_p (var))
flags[i++] = 'i';
if (nameref_p (var))
flags[i++] = 'n';
if (readonly_p (var))
flags[i++] = 'r';
@ -451,7 +455,11 @@ show_name_attributes (name, nodefs)
{
SHELL_VAR *var;
var = find_variable_internal (name, 1);
#if 0
var = find_variable_tempenv (name);
#else
var = find_variable_noref (name);
#endif
if (var && invisible_p (var) == 0)
{
@ -462,12 +470,30 @@ show_name_attributes (name, nodefs)
return (1);
}
int
show_func_attributes (name, nodefs)
char *name;
int nodefs;
{
SHELL_VAR *var;
var = find_function (name);
if (var)
{
show_var_attributes (var, READONLY_OR_EXPORT, nodefs);
return (0);
}
else
return (1);
}
void
set_var_attribute (name, attribute, undo)
char *name;
int attribute, undo;
{
SHELL_VAR *var, *tv;
SHELL_VAR *var, *tv, *v;
char *tvalue;
if (undo)
@ -484,7 +510,18 @@ set_var_attribute (name, attribute, undo)
var = bind_variable (tv->name, tvalue, 0);
var->attributes |= tv->attributes & ~att_tempvar;
VSETATTR (tv, att_propagate);
/* This avoids an error message when propagating a read-only var
later on. */
if (var->context == 0 && (attribute & att_readonly))
{
/* Don't bother to set the `propagate to the global variables
table' flag if we've just bound the variable in that table */
v = find_global_variable (tv->name);
if (v != var)
VSETATTR (tv, att_propagate);
}
else
VSETATTR (tv, att_propagate);
if (var->context != 0)
VSETATTR (var, att_propagate);
SETVARATTR (tv, attribute, undo); /* XXX */
@ -495,7 +532,7 @@ set_var_attribute (name, attribute, undo)
}
else
{
var = find_variable_internal (name, 0);
var = find_variable_notempenv (name);
if (var == 0)
{
var = bind_variable (name, (char *)NULL, 0);

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-2010 Free Software Foundation, Inc.
Copyright (C) 1994-2012 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -88,6 +88,7 @@ extern int gnu_error_format;
extern int check_jobs_at_exit;
extern int autocd;
extern int glob_star;
extern int glob_asciirange;
extern int lastpipe_opt;
#if defined (EXTENDED_GLOB)
@ -99,6 +100,7 @@ extern int hist_verify, history_reediting, perform_hostname_completion;
extern int no_empty_command_completion;
extern int force_fignore;
extern int dircomplete_spelling, dircomplete_expand;
extern int complete_fullquote;
extern int enable_hostname_completion __P((int));
#endif
@ -134,6 +136,7 @@ static int shopt_compat31;
static int shopt_compat32;
static int shopt_compat40;
static int shopt_compat41;
static int shopt_compat42;
typedef int shopt_set_func_t __P((char *, int));
@ -157,7 +160,9 @@ static struct {
{ "compat32", &shopt_compat32, set_compatibility_level },
{ "compat40", &shopt_compat40, set_compatibility_level },
{ "compat41", &shopt_compat41, set_compatibility_level },
{ "compat42", &shopt_compat41, set_compatibility_level },
#if defined (READLINE)
{ "complete_fullquote", &complete_fullquote, (shopt_set_func_t *)NULL},
{ "direxpand", &dircomplete_expand, shopt_set_complete_direxpand },
{ "dirspell", &dircomplete_spelling, (shopt_set_func_t *)NULL },
#endif
@ -176,6 +181,7 @@ static struct {
{ "force_fignore", &force_fignore, (shopt_set_func_t *)NULL },
#endif
{ "globstar", &glob_star, (shopt_set_func_t *)NULL },
{ "globasciiranges", &glob_asciirange, (shopt_set_func_t *)NULL },
{ "gnu_errfmt", &gnu_error_format, (shopt_set_func_t *)NULL },
#if defined (HISTORY)
{ "histappend", &force_append_history, (shopt_set_func_t *)NULL },
@ -298,10 +304,12 @@ reset_shopt_options ()
allow_null_glob_expansion = glob_dot_filenames = 0;
cdable_vars = mail_warning = 0;
no_exit_on_failed_exec = print_shift_error = 0;
check_hashed_filenames = cdspelling = expand_aliases = check_window_size = 0;
check_hashed_filenames = cdspelling = expand_aliases = 0;
source_uses_path = promptvars = 1;
check_window_size = CHECKWINSIZE_DEFAULT;
#if defined (EXTENDED_GLOB)
extended_glob = 0;
#endif
@ -521,16 +529,18 @@ set_compatibility_level (option_name, mode)
char *option_name;
int mode;
{
/* Need to change logic here as we add more compatibility levels */
int ind;
/* First, check option_name so we can turn off other compat options when
one is set. */
if (mode && option_name[6] == '3' && option_name[7] == '1')
shopt_compat32 = shopt_compat40 = 0;
else if (mode && option_name[6] == '3' && option_name[7] == '2')
shopt_compat31 = shopt_compat40 = 0;
else if (mode && option_name[6] == '4' && option_name[7] == '0')
shopt_compat31 = shopt_compat32 = 0;
/* If we're setting something, redo some of the work we did above in
toggle_shopt(). Unset everything and reset the appropriate option
based on OPTION_NAME. */
if (mode)
{
shopt_compat31 = shopt_compat32 = 0;
shopt_compat40 = shopt_compat41 = shopt_compat42 = 0;
ind = find_shopt (option_name);
*shopt_vars[ind].value = mode;
}
/* Then set shell_compatibility_level based on what remains */
if (shopt_compat31)
@ -539,11 +549,39 @@ set_compatibility_level (option_name, mode)
shell_compatibility_level = 32;
else if (shopt_compat40)
shell_compatibility_level = 40;
else if (shopt_compat41)
shell_compatibility_level = 41;
else if (shopt_compat42)
shell_compatibility_level = 42;
else
shell_compatibility_level = DEFAULT_COMPAT_LEVEL;
return 0;
}
/* Set and unset the various compatibility options from the value of
shell_compatibility_level; used by sv_shcompat */
void
set_compatibility_opts ()
{
shopt_compat31 = shopt_compat32 = shopt_compat40 = shopt_compat41 = shopt_compat42 = 0;
switch (shell_compatibility_level)
{
case DEFAULT_COMPAT_LEVEL:
break;
case 42:
shopt_compat42 = 1; break;
case 41:
shopt_compat41 = 1; break;
case 40:
shopt_compat40 = 1; break;
case 32:
shopt_compat32 = 1; break;
case 31:
shopt_compat31 = 1; break;
}
}
#if defined (READLINE)
static int
shopt_set_complete_direxpand (option_name, mode)

View file

@ -84,6 +84,7 @@ Other operators:
-o OPTION True if the shell option OPTION is enabled.
-v VAR True if the shell variable VAR is set
-R VAR True if the shell variable VAR is set and is a name reference.
! EXPR True if expr is false.
EXPR1 -a EXPR2 True if both expr1 AND expr2 are true.
EXPR1 -o EXPR2 True if either expr1 OR expr2 is true.

View file

@ -1,7 +1,7 @@
This file is type.def, from which is created type.c.
It implements the builtin "type" in Bash.
Copyright (C) 1987-2009 Free Software Foundation, Inc.
Copyright (C) 1987-2011 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -353,7 +353,7 @@ describe_command (command, dflags)
user_command_matches (command, FS_EXEC_ONLY, found_file);
/* XXX - should that be FS_EXEC_PREFERRED? */
if (!full_path)
if (full_path == 0)
break;
/* If we found the command as itself by looking through $PATH, it
@ -375,7 +375,9 @@ describe_command (command, dflags)
else if (dflags & (CDESC_REUSABLE|CDESC_PATH_ONLY|CDESC_SHORTDESC))
{
f = MP_DOCWD | ((dflags & CDESC_ABSPATH) ? MP_RMDOT : 0);
full_path = sh_makepath ((char *)NULL, full_path, f);
x = sh_makepath ((char *)NULL, full_path, f);
free (full_path);
full_path = x;
}
}
/* If we require a full path and don't have one, make one */

View file

@ -23,7 +23,7 @@ $PRODUCES ulimit.c
$BUILTIN ulimit
$FUNCTION ulimit_builtin
$DEPENDS_ON !_MINIX
$SHORT_DOC ulimit [-SHacdefilmnpqrstuvx] [limit]
$SHORT_DOC ulimit [-SHabcdefilmnpqrstuvxT] [limit]
Modify shell resource limits.
Provides control over the resources available to the shell and processes
@ -50,6 +50,9 @@ Options:
-u the maximum number of user processes
-v the size of virtual memory
-x the maximum number of file locks
-T the maximum number of threads
Not all options are available on all platforms.
If LIMIT is given, it is the new value of the specified resource; the
special LIMIT values `soft', `hard', and `unlimited' stand for the
@ -70,7 +73,7 @@ $END
#include <config.h>
#include "../bashtypes.h"
#ifndef _MINIX
#if defined (HAVE_SYS_PARAM_H)
# include <sys/param.h>
#endif
@ -167,6 +170,10 @@ extern int errno;
# define RLIMIT_MAXUPROC 260
#endif
#if !defined (RLIMIT_PTHREAD) && defined (RLIMIT_NTHR)
# define RLIMIT_PTHREAD RLIMIT_NTHR
#endif
#if !defined (RLIM_INFINITY)
# define RLIM_INFINITY 0x7fffffff
#endif

View file

@ -61,10 +61,6 @@ $END
#include "common.h"
#include "bashgetopt.h"
#ifdef __LCC__
#define mode_t int
#endif
/* **************************************************************** */
/* */
/* UMASK Builtin and Helpers */

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-2009 Free Software Foundation, Inc.
Copyright (C) 1987-2013 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -22,33 +22,36 @@ $BUILTIN wait
$FUNCTION wait_builtin
$DEPENDS_ON JOB_CONTROL
$PRODUCES wait.c
$SHORT_DOC wait [id]
$SHORT_DOC wait [-n] [id ...]
Wait for job completion and return exit status.
Waits for the process identified by ID, which may be a process ID or a
Waits for each process identified by an ID, which may be a process ID or a
job specification, and reports its termination status. If ID is not
given, waits for all currently active child processes, and the return
status is zero. If ID is a a job specification, waits for all processes
in the job's pipeline.
in that job's pipeline.
If the -n option is supplied, waits for the next job to terminate and
returns its exit status.
Exit Status:
Returns the status of ID; fails if ID is invalid or an invalid option is
given.
Returns the status of the last ID; fails if ID is invalid or an invalid
option is given.
$END
$BUILTIN wait
$FUNCTION wait_builtin
$DEPENDS_ON !JOB_CONTROL
$SHORT_DOC wait [pid]
$SHORT_DOC wait [pid ...]
Wait for process completion and return exit status.
Waits for the specified process and reports its termination status. If
PID is not given, all currently active child processes are waited for,
and the return code is zero. PID must be a process ID.
Waits for each process specified by a PID and reports its termination status.
If PID is not given, waits for all currently active child processes,
and the return status is zero. PID must be a process ID.
Exit Status:
Returns the status of ID; fails if ID is invalid or an invalid option is
given.
Returns the status of the last PID; fails if PID is invalid or an invalid
option is given.
$END
#include <config.h>
@ -82,6 +85,7 @@ procenv_t wait_intr_buf;
do \
{ \
interrupt_immediately = old_interrupt_immediately;\
wait_signal_received = 0; \
return (s);\
} \
while (0)
@ -90,17 +94,33 @@ int
wait_builtin (list)
WORD_LIST *list;
{
int status, code;
int status, code, opt, nflag;
volatile int old_interrupt_immediately;
USE_VAR(list);
if (no_options (list))
return (EX_USAGE);
nflag = 0;
reset_internal_getopt ();
while ((opt = internal_getopt (list, "n")) != -1)
{
switch (opt)
{
#if defined (JOB_CONTROL)
case 'n':
nflag = 1;
break;
#endif
default:
builtin_usage ();
return (EX_USAGE);
}
}
list = loptend;
old_interrupt_immediately = interrupt_immediately;
#if 0
interrupt_immediately++;
#endif
/* 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
@ -120,6 +140,16 @@ wait_builtin (list)
/* We support jobs or pids.
wait <pid-or-job> [pid-or-job ...] */
#if defined (JOB_CONTROL)
if (nflag)
{
status = wait_for_any_job ();
if (status < 0)
status = 127;
WAIT_RETURN (status);
}
#endif
/* But wait without any arguments means to wait for all of the shell's
currently active background processes. */
if (list == 0)

View file

@ -76,7 +76,7 @@ enum command_type { cm_for, cm_case, cm_while, cm_if, cm_simple, cm_select,
#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_GLOBEXP 0x000008 /* This word is the result of a glob expansion. */
#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. */
@ -96,8 +96,11 @@ enum command_type { cm_for, cm_case, cm_while, cm_if, cm_simple, cm_select,
#define W_NOPROCSUB 0x100000 /* don't perform process substitution */
#define W_HASCTLESC 0x200000 /* word contains literal CTLESC characters */
#define W_ASSIGNASSOC 0x400000 /* word looks like associative array assignment */
#define W_ARRAYIND 0x800000 /* word is an array index being expanded */
#define W_ASSNGLOBAL 0x1000000 /* word is a global assignment to declare (declare/typeset -g) */
#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_ASSIGNINT 0x8000000 /* word is an integer assignment to declare */
/* Possible values for subshell_environment */
#define SUBSHELL_ASYNC 0x01 /* subshell caused by `command &' */
@ -296,7 +299,7 @@ typedef struct arith_com {
} ARITH_COM;
#endif /* DPAREN_ARITHMETIC */
/* The conditional command, [[...]]. This is a binary tree -- we slippped
/* The conditional command, [[...]]. This is a binary tree -- we slipped
a recursive-descent parser into the YACC grammar to parse it. */
#define COND_AND 1
#define COND_OR 2
@ -355,6 +358,7 @@ typedef struct coproc {
int c_wsave;
int c_flags;
int c_status;
int c_lock;
} Coproc;
typedef struct coproc_com {

View file

@ -46,6 +46,11 @@
when a job like `cat jobs.c | exit 1' terminates due to a SIGPIPE. */
#define DONT_REPORT_SIGPIPE
/* Define DONT_REPORT_SIGTERM if you don't want to see `Terminates' message
when a job exits due to SIGTERM, since that's the default signal sent
by the kill builtin. */
/* #define DONT_REPORT_SIGTERM */
/* Define DONT_REPORT_BROKEN_PIPE_WRITE_ERRORS if you don't want builtins
like `echo' and `printf' to report errors when output does not succeed
due to EPIPE. */
@ -54,7 +59,7 @@
/* The default value of the PATH variable. */
#ifndef DEFAULT_PATH_VALUE
#define DEFAULT_PATH_VALUE \
"/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:."
"/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:."
#endif
/* The value for PATH when invoking `command -p'. This is only used when
@ -109,3 +114,21 @@
/* Define if you want to include code in shell.c to support wordexp(3) */
/* #define WORDEXP_OPTION */
/* Define as 1 if you want to enable code that implements multiple coprocs */
#ifndef MULTIPLE_COPROCS
# define MULTIPLE_COPROCS 0
#endif
/* Define to 0 if you want the checkwinsize option off by default, 1 if you
want it on. */
#define CHECKWINSIZE_DEFAULT 0
/* Define to 1 if you want to optimize for sequential array assignment when
using indexed arrays, 0 if you want bash-4.2 behavior, which favors
random access but is O(N) for each array assignment. */
#define OPTIMIZE_SEQUENTIAL_ARRAY_ASSIGNMENT 1
/* Define to 1 if you want to be able to export indexed arrays to processes
using the foo=([0]=one [1]=two) and so on */
/* #define ARRAY_EXPORT 1 */

View file

@ -1,6 +1,6 @@
/* config.h -- Configuration file for bash. */
/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
/* Copyright (C) 1987-2009,2011-2012 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -160,9 +160,6 @@
memory contents on malloc() and free(). */
#undef MEMSCRAMBLE
/* Define AFS if you are using Transarc's AFS. */
#undef AFS
/* Define for case-modifying variable attributes; variables modified on
assignment */
#undef CASEMOD_ATTRS
@ -170,6 +167,15 @@
/* Define for case-modifying word expansions */
#undef CASEMOD_EXPANSIONS
/* Define to make the `direxpand' shopt option enabled by default. */
#undef DIRCOMPLETE_EXPAND_DEFAULT
/* Define to make the `globasciiranges' shopt option enabled by default. */
#undef GLOBASCII_DEFAULT
/* Define AFS if you are using Transarc's AFS. */
#undef AFS
#undef ENABLE_NLS
/* End of configuration settings controllable by autoconf. */
@ -420,6 +426,16 @@
#undef WEXITSTATUS_OFFSET
#undef HAVE_STRUCT_TIMESPEC
#undef TIME_H_DEFINES_STRUCT_TIMESPEC
#undef SYS_TIME_H_DEFINES_STRUCT_TIMESPEC
#undef PTHREAD_H_DEFINES_STRUCT_TIMESPEC
#undef TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC
#undef HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC
#undef HAVE_STRUCT_STAT_ST_ATIMENSEC
#undef HAVE_STRUCT_STAT_ST_ATIM_ST__TIM_TV_NSEC
/* Characteristics of definitions in the system header files. */
#undef HAVE_GETPW_DECLS
@ -428,6 +444,9 @@
#undef HAVE_LIBC_FNM_EXTMATCH
/* Define if you have <linux/audit.h> and it defines AUDIT_USER_TTY */
#undef HAVE_DECL_AUDIT_USER_TTY
#undef HAVE_DECL_CONFSTR
#undef HAVE_DECL_PRINTF
@ -625,6 +644,9 @@
/* Define if you have the iconv function. */
#undef HAVE_ICONV
/* Define if you have the imaxdiv function. */
#undef HAVE_IMAXDIV
/* Define if you have the inet_aton function. */
#undef HAVE_INET_ATON
@ -637,12 +659,6 @@
/* Define if you have the isgraph function. */
#undef HAVE_ISGRAPH
/* Define if you have the isinf function in libc */
#undef HAVE_ISINF_IN_LIBC
/* Define if you have the isnan function in libc */
#undef HAVE_ISNAN_IN_LIBC
/* Define if you have the isprint function. */
#undef HAVE_ISPRINT
@ -887,6 +903,9 @@
/* Define if you have the wcwidth function. */
#undef HAVE_WCWIDTH
/* and if it works */
#undef WCWIDTH_BROKEN
/* Presence of certain system include files. */
/* Define if you have the <arpa/inet.h> header file. */
@ -946,6 +965,9 @@
/* Define if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define if you have the <stdbool.h> header file. */
#undef HAVE_STDBOOL_H
/* Define if you have the <stddef.h> header file. */
#undef HAVE_STDDEF_H
@ -1034,6 +1056,8 @@
#undef HAVE_LIBSOCKET
/* Are we running the GNU C library, version 2.1 or later? */
#undef GLIBC21
/* Define if on MINIX. */
#undef _MINIX

24174
configure vendored

File diff suppressed because it is too large Load diff

1212
configure.ac Normal file

File diff suppressed because it is too large Load diff

207
doc/FAQ
View file

@ -1,4 +1,4 @@
This is the Bash FAQ, version 4.12, for Bash version 4.2.
This is the Bash FAQ, version 4.13, for Bash version 4.3.
This document contains a set of frequently-asked questions concerning
Bash, the GNU Bourne-Again Shell. Bash is a freely-available command
@ -36,8 +36,8 @@ A10) What is the bash `posix mode'?
Section B: The latest version
B1) What's new in version 4.2?
B2) Are there any user-visible incompatibilities between bash-4.2 and
B1) What's new in version 4.3?
B2) Are there any user-visible incompatibilities between bash-4.3 and
previous bash versions?
Section C: Differences from other Unix shells
@ -144,26 +144,26 @@ of Case Western Reserve University.
A2) What's the latest version?
The latest version is 4.2, first made available on 14 February, 2011.
The latest version is 4.3, first made available on xx December, 2013.
A3) Where can I get it?
Bash is the GNU project's shell, and so is available from the
master GNU archive site, ftp.gnu.org, and its mirrors. The
latest version is also available for FTP from ftp.cwru.edu.
The following URLs tell how to get version 4.2:
The following URLs tell how to get version 4.3:
ftp://ftp.gnu.org/pub/gnu/bash/bash-4.2.tar.gz
ftp://ftp.cwru.edu/pub/bash/bash-4.2.tar.gz
ftp://ftp.gnu.org/pub/gnu/bash/bash-4.3.tar.gz
ftp://ftp.cwru.edu/pub/bash/bash-4.3.tar.gz
Formatted versions of the documentation are available with the URLs:
ftp://ftp.gnu.org/pub/gnu/bash/bash-doc-4.2.tar.gz
ftp://ftp.cwru.edu/pub/bash/bash-doc-4.2.tar.gz
ftp://ftp.gnu.org/pub/gnu/bash/bash-doc-4.3.tar.gz
ftp://ftp.cwru.edu/pub/bash/bash-doc-4.3.tar.gz
Any patches for the current version are available with the URL:
ftp://ftp.cwru.edu/pub/bash/bash-4.2-patches/
ftp://ftp.cwru.edu/pub/bash/bash-4.3-patches/
A4) On what machines will bash run?
@ -219,7 +219,8 @@ Mark began to work with bash-2.05, but I don't know the current status.
Bash-3.0 compiles and runs with no modifications under Microsoft's Services
for Unix (SFU), once known as Interix. I do not anticipate any problems
with building bash-4.2, but will gladly accept any patches that are needed.
with building bash-4.2 and later, but will gladly accept any patches that
are needed.
A6) How can I build bash with gcc?
@ -388,14 +389,130 @@ They are also listed in a section in the Bash Reference Manual
Section B: The latest version
B1) What's new in version 4.2?
B1) What's new in version 4.3?
Bash-4.2 is the second revision to the fourth major release of bash.
Bash-4.3 is the third revision to the fourth major release of bash.
Bash-4.2 contains the following new features (see the manual page for
complete descriptions and the CHANGES and NEWS files in the bash-4.2
Bash-4.3 contains the following new features (see the manual page for
complete descriptions and the CHANGES and NEWS files in the bash-4.3
distribution):
o The `helptopic' completion action now maps to all the help topics, not just
the shell builtins.
o The `help' builtin no longer does prefix substring matching first, so
`help read' does not match `readonly', but will do it if exact string
matching fails.
o The shell can be compiled to not display a message about processes that
terminate due to SIGTERM.
o Non-interactive shells now react to the setting of checkwinsize and set
LINES and COLUMNS after a foreground job exits.
o There is a new shell option, `globasciiranges', which, when set to on,
forces globbing range comparisons to use character ordering as if they
were run in the C locale.
o There is a new shell option, `direxpand', which makes filename completion
expand variables in directory names in the way bash-4.1 did.
o In Posix mode, the `command' builtin does not change whether or not a
builtin it shadows is treated as an assignment builtin.
o The `return' and `exit' builtins accept negative exit status arguments.
o The word completion code checks whether or not a filename containing a
shell variable expands to a directory name and appends `/' to the word
as appropriate. The same code expands shell variables in command names
when performing command completion.
o In Posix mode, it is now an error to attempt to define a shell function
with the same name as a Posix special builtin.
o When compiled for strict Posix conformance, history expansion is disabled
by default.
o The history expansion character (!) does not cause history expansion when
followed by the closing quote in a double-quoted string.
o `complete' and its siblings compgen/compopt now takes a new `-o noquote'
option to inhibit quoting of the completions.
o Setting HISTSIZE to a value less than zero causes the history list to be
unlimited (setting it 0 zero disables the history list).
o Setting HISTFILESIZE to a value less than zero causes the history file size
to be unlimited (setting it to 0 causes the history file to be truncated
to zero size).
o The `read' builtin now skips NUL bytes in the input.
o There is a new `bind -X' option to print all key sequences bound to Unix
commands.
o When in Posix mode, `read' is interruptible by a trapped signal. After
running the trap handler, read returns 128+signal and throws away any
partially-read input.
o The command completion code skips whitespace and assignment statements
before looking for the command name word to be completed.
o The build process has a new mechanism for constructing separate help files
that better reflects the current set of compilation options.
o The -nt and -ot options to test now work with files with nanosecond
timestamp resolution.
o The shell saves the command history in any shell for which history is
enabled and HISTFILE is set, not just interactive shells.
o The shell has `nameref' variables and new -n(/+n) options to declare and
unset to use them, and a `test -R' option to test for them.
o The shell now allows assigning, referencing, and unsetting elements of
indexed arrays using negative subscripts (a[-1]=2, echo ${a[-1]}) which
count back from the last element of the array.
o The {x}<word redirection feature now allows words like {array[ind]} and
can use variables with special meanings to the shell (e.g., BASH_XTRACEFD).
o There is a new CHILD_MAX special shell variable; its value controls the
number of exited child statues the shell remembers.
o There is a new configuration option (--enable-direxpand-default) that
causes the `direxpand' shell option to be enabled by default.
o Bash does not do anything special to ensure that the file descriptor
assigned to X in {x}<foo remains open after the block containing it
completes.
o The `wait' builtin has a new `-n' option to wait for the next child to
change status.
o The `printf' %(...)T format specifier now uses the current time if no
argument is supplied.
o There is a new variable, BASH_COMPAT, that controls the current shell
compatibility level.
o The `popd' builtin now treats additional arguments as errors.
o The brace expansion code now treats a failed sequence expansion as a
simple string and will continue to expand brace terms in the remainder
of the word.
o Shells started to run process substitutions now run any trap set on EXIT.
o The fc builtin now interprets -0 as the current command line.
o Completing directory names containing shell variables now adds a trailing
slash if the expanded result is a directory.
A short feature history dating back to Bash-2.0:
Bash-4.2 contained the following new features:
o `exec -a foo' now sets $0 to `foo' in an executable shell script without a
leading #!.
@ -973,10 +1090,10 @@ grammar tighter and smaller (66 reduce-reduce conflicts gone)
lots of code now smaller and faster
test suite greatly expanded
B2) Are there any user-visible incompatibilities between bash-4.2 and
B2) Are there any user-visible incompatibilities between bash-4.3 and
previous bash versions?
There are a few incompatibilities between version 4.2 and previous
There are a few incompatibilities between version 4.3 and previous
versions. They are detailed in the file COMPAT in the bash distribution.
That file is not meant to be all-encompassing; send mail to
bash-maintainers@gnu.org (or bug-bash@gnu.org if you would like
@ -1026,14 +1143,14 @@ Things bash has that sh does not:
auto-export of variables in initial environment
command search finds functions before builtins
bash return builtin will exit a file sourced with `.'
builtins: cd -/-L/-P, exec -l/-c/-a, echo -e/-E, hash -d/-l/-p/-t.
builtins: cd -/-L/-P/-@, exec -l/-c/-a, echo -e/-E, hash -d/-l/-p/-t.
export -n/-f/-p/name=value, pwd -L/-P,
read -e/-p/-a/-t/-n/-d/-s/-u/-i/-N,
readonly -a/-f/name=value, trap -l, set +o,
set -b/-m/-o option/-h/-p/-B/-C/-H/-P,
unset -f/-v, ulimit -i/-m/-p/-q/-u/-x,
unset -f/-n/-v, ulimit -i/-m/-p/-q/-u/-x,
type -a/-p/-t/-f/-P, suspend -f, kill -n,
test -o optname/s1 == s2/s1 < s2/s1 > s2/-nt/-ot/-ef/-O/-G/-S
test -o optname/s1 == s2/s1 < s2/s1 > s2/-nt/-ot/-ef/-O/-G/-S/-R
bash reads ~/.bashrc for interactive shells, $ENV for non-interactive
bash restricted shell mode is more extensive
bash allows functions and variables with the same name
@ -1188,18 +1305,20 @@ Implementation differences:
C3) Which new features in ksh-93 are not in bash, and which are?
This list is current through ksh93t+ (05/05/2009)
This list is current through ksh93v (10/08/2013)
New things in ksh-93 not in bash-4.2:
floating point arithmetic and variables
math library functions
New things in ksh-93 not in bash-4.3:
floating point arithmetic, variables, and constants
math library functions, including user-defined math functions
${!name[sub]} name of subscript for associative array
`.' is allowed in variable names to create a hierarchical namespace
more extensive compound assignment syntax
discipline functions
KEYBD trap
variables: .sh.edchar, .sh.edmode, .sh.edcol, .sh.edtext, .sh.version,
.sh.name, .sh.subscript, .sh.value, .sh.match, HISTEDIT
.sh.name, .sh.subscript, .sh.value, .sh.match, HISTEDIT,
.sh.sig, .sh.stats, .sh.siginfo, .sh.pwdfd, .sh.op_astbin,
.sh.pool
backreferences in pattern matching (\N)
`&' operator in pattern lists for matching (match all instead of any)
exit statuses between 0 and 255
@ -1208,17 +1327,20 @@ New things in ksh-93 not in bash-4.2:
no scoping for local variables in `POSIX' functions
$'' \C[.collating-element.] escape sequence
-C/-I invocation options
print -f (bash uses printf)
print -f (bash uses printf) and rest of print builtin options
printf %(type)q, %#q
`fc' has been renamed to `hist'
`.' can execute shell functions
getopts -a
printf %B, %H, %P, %R, %Z modifiers, output base for %d, `=' flag
read -n/-N differ/-v
read -n/-N differ/-v/-S
set -o showme/-o multiline (bash default)
set -K
kill -Q/-q/-L
trap -a
`sleep' and `getconf' builtins (bash has loadable versions)
typeset -n and `nameref' variables
[[ -R name ]] (checks whether or not name is a nameref)
typeset -C/-S/-T/-X/-h/-s
typeset -C/-S/-T/-X/-h/-s/-c/-M
experimental `type' definitions (a la typedef) using typeset
array expansions ${array[sub1..sub2]} and ${!array[sub1..sub2]}
associative array assignments using `;' as element separator
@ -1226,8 +1348,12 @@ New things in ksh-93 not in bash-4.2:
new '${ ' form of command substitution, executed in current shell
new >;/<>;/<#pat/<##pat/<#/># redirections
brace expansion printf-like formats
CHLD trap triggered by SIGSTOP and SIGCONT
~{fd} expansion, which replaces fd with the corresponding path name
$"string" expanded when referenced rather than when first parsed
job "pools", which allow a collection of jobs to be managed as a unit
New things in ksh-93 present in bash-4.2:
New things in ksh-93 present in bash-4.3:
associative arrays
[n]<&word- and [n]>&word- redirections (combination dup and close)
for (( expr1; expr2; expr3 )) ; do list; done - arithmetic for command
@ -1266,6 +1392,8 @@ New things in ksh-93 present in bash-4.2:
redirection operators preceded with {varname} to store fd number in varname
DEBUG can force skipping following command
[[ -v var ]] operator (checks whether or not var is set)
typeset -n and `nameref' variables
process substitutions work without /dev/fd
Section D: Why does bash do some things differently than other Unix shells?
@ -1854,6 +1982,18 @@ compat40 set
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)
compat41 set
- interrupting a command list such as "a ; b ; c" causes the execution
of the entire list to be aborted (in versions before bash-4.1,
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
compat42 set
- the replacement string in double-quoted pattern substitution is not
run through quote removal, as in previous versions
Section F: Things to watch out for on certain Unix versions
F1) Why can't I use command line editing in my `cmdtool'?
@ -2095,7 +2235,7 @@ before `eval' is executed. In versions of bash later than bash-2.0,
does the same thing.
This is not the same thing as ksh93 `nameref' variables, though the syntax
is similar. I may add namerefs in a future bash version.
is similar. Namerefs are available bash version 4.3, and work as in ksh93.
G4) How can I make the bash `time' reserved word print timing output that
looks like the output from my system's /usr/bin/time?
@ -2255,16 +2395,15 @@ a module system like zsh's, using dynamic loading like builtins
a bash programmer's guide with a chapter on creating loadable builtins
a better loadable interface to perl with access to the shell builtins and
variables (contributions gratefully accepted)
ksh93-like `nameref' variables
ksh93-like `xx.yy' variables (including some of the .sh.* variables) and
associated disipline functions
Some of the new ksh93 pattern matching operators, like backreferencing
H5) When will the next release appear?
The next version will appear sometime in 2010. Never make predictions.
The next version will appear sometime in 2015. Never make predictions.
This document is Copyright 1995-2010 by Chester Ramey.
This document is Copyright 1995-2014 by Chester Ramey.
Permission is hereby granted, without written agreement and
without license or royalty fees, to use, copy, and distribute

View file

@ -1,6 +1,6 @@
# This Makefile is for the Bash/documentation directory -*- text -*-.
#
# Copyright (C) 2003-2009 Free Software Foundation, Inc.
# Copyright (C) 2003-2013 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -23,6 +23,8 @@ PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_VERSION = @PACKAGE_VERSION@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
#
SHELL = @MAKE_SHELL@
RM = rm -f
@ -38,6 +40,8 @@ datarootdir = @datarootdir@
infodir = @infodir@
docdir = @docdir@
# set this to a directory name to have the HTML files installed
htmldir = @htmldir@
@ -166,6 +170,8 @@ bashref.dvi: $(BASHREF_FILES) $(HSUSER) $(RLUSER)
bashref.info: $(BASHREF_FILES) $(HSUSER) $(RLUSER)
$(MAKEINFO) --no-split -I$(TEXINPUTDIR) $(srcdir)/bashref.texi
# can also use:
# $(MAKEINFO) --html --no-split -I$(TEXINPUTDIR) $(srcdir)/bashref.texi
bashref.html: $(BASHREF_FILES) $(HSUSER) $(RLUSER)
$(TEXI2HTML) -menu -monolithic -I $(TEXINPUTDIR) $(srcdir)/bashref.texi
@ -191,6 +197,9 @@ bashref.pdf: bashref.dvi
bash.pdf: bash.ps
rose94.pdf: rose94.ps
OTHER_DOCS = $(srcdir)/FAQ $(srcdir)/INTRO
OTHER_INSTALLED_DOCS = FAQ INTRO
$(MAN2HTML): ${topdir}/support/man2html.c
-( cd ${BUILD_DIR}/support ; ${MAKE} ${MFLAGS} man2html)
@ -218,6 +227,7 @@ maybe-clean:
installdirs:
-$(SHELL) $(SUPPORT_SRCDIR)/mkinstalldirs $(DESTDIR)$(man1dir)
-$(SHELL) $(SUPPORT_SRCDIR)/mkinstalldirs $(DESTDIR)$(infodir)
-$(SHELL) $(SUPPORT_SRCDIR)/mkinstalldirs $(DESTDIR)$(docdir)
-if test -n "$(htmldir)" ; then \
$(SHELL) $(SUPPORT_SRCDIR)/mkinstalldirs $(DESTDIR)$(htmldir) ; \
fi
@ -225,6 +235,7 @@ installdirs:
install: info installdirs bash.info
-$(INSTALL_DATA) $(srcdir)/bash.1 $(DESTDIR)$(man1dir)/bash${man1ext}
-$(INSTALL_DATA) $(srcdir)/bashbug.1 $(DESTDIR)$(man1dir)/bashbug${man1ext}
-$(INSTALL_DATA) $(OTHER_DOCS) $(DESTDIR)$(docdir)
# uncomment the next lines to install the builtins man page
# sed 's:bash\.1:man1/&:' $(srcdir)/builtins.1 > $${TMPDIR:-/var/tmp}/builtins.1
# -$(INSTALL_DATA) $${TMPDIR:-/var/tmp}/builtins.1 $(DESTDIR)$(man1dir)/bash_builtins${man1ext}
@ -252,6 +263,7 @@ uninstall:
-$(RM) $(DESTDIR)$(man1dir)/bash${man1ext} $(DESTDIR)$(man1dir)/bashbug${man1ext}
-$(RM) $(DESTDIR)$(man1dir)/bash_builtins${man1ext}
$(RM) $(DESTDIR)$(infodir)/bash.info
-( cd $(DESTDIR)$(docdir) && $(RM) $(OTHER_INSTALLED_DOCS) )
-if test -n "$(htmldir)" ; then \
$(RM) $(DESTDIR)$(htmldir)/bash.html ; \
$(RM) $(DESTDIR)$(htmldir)/bashref.html ; \

BIN
doc/aosa-bash.pdf Normal file

Binary file not shown.

View file

@ -179,7 +179,7 @@ variable expansion semantics, redirection, and quoting as the
Bourne shell. Where differences appear between the POSIX.2
standard and traditional sh behavior, Bash follows POSIX.
.PP
The Korn Shell (\fBksh\fP) is a descendent of the Bourne shell written
The Korn Shell (\fBksh\fP) is a descendant of the Bourne shell written
at AT&T Bell Laboratories by David Korn\(dg. It provides a number of
useful features that POSIX and Bash have adopted. Many of the
interactive facilities in POSIX.2 have their roots in the ksh:
@ -491,7 +491,7 @@ some bindings, and begin to use them almost immediately.
.PP
Bash implements the
.B bind
builtin for more dyamic control of readline than the startup file
builtin for more dynamic control of readline than the startup file
permits.
.B Bind
is used in several ways. In
@ -544,7 +544,7 @@ and
builtins to manipulate the history list.
The value of
.B $HISTFILE
specifes the file where Bash writes the command history on exit and
specifies the file where Bash writes the command history on exit and
reads it on startup.
.B $HISTSIZE
is used to limit the number of commands saved in the history.

Binary file not shown.

View file

@ -1,17 +1,22 @@
%!PS-Adobe-3.0
%%Creator: groff version 1.16.1
%%CreationDate: Mon Nov 19 13:06:55 2001
%%Creator: groff version 1.19.2
%%CreationDate: Tue Oct 22 11:07:52 2013
%%DocumentNeededResources: font Times-Bold
%%+ font Times-Italic
%%+ font Times-Roman
%%+ font Courier
%%DocumentSuppliedResources: procset grops 1.16 1
%%DocumentSuppliedResources: procset grops 1.19 2
%%Pages: 11
%%PageOrder: Ascend
%%DocumentMedia: Default 612 792 0 () ()
%%Orientation: Portrait
%%EndComments
%%BeginDefaults
%%PageMedia: Default
%%EndDefaults
%%BeginProlog
%%BeginResource: procset grops 1.16 1
%%BeginResource: procset grops 1.19 2
%!PS-Adobe-3.0 Resource-ProcSet
/setpacking where{
pop
currentpacking
@ -79,7 +84,7 @@ LS{
/EP{
level0 restore
showpage
}bind def
}def
/DA{
newpath arcn stroke
}bind def
@ -109,11 +114,26 @@ TM setmatrix
/ST/stroke load def
/MT/moveto load def
/CL/closepath load def
/FL{
currentgray exch setgray fill setgray
/Fr{
setrgbcolor fill
}bind def
/BL/fill load def
/setcmykcolor where{
pop
/Fk{
setcmykcolor fill
}bind def
}if
/Fg{
setgray fill
}bind def
/FL/fill load def
/LW/setlinewidth load def
/Cr/setrgbcolor load def
/setcmykcolor where{
pop
/Ck/setcmykcolor load def
}if
/Cg/setgray load def
/RE{
findfont
dup maxlength 1 index/FontName known not{1 add}if dict begin
@ -155,9 +175,9 @@ newpath
/CNT countdictstack def
userdict begin
/showpage{}def
/setpagedevice{}def
}bind def
/PEND{
clear
countdictstack CNT sub{end}repeat
level1 restore
}bind def
@ -167,13 +187,18 @@ pop
setpacking
}if
%%EndResource
%%EndProlog
%%BeginSetup
%%BeginFeature: *PageSize Default
<< /PageSize [ 612 792 ] /ImagingBBox null >> setpagedevice
%%EndFeature
%%IncludeResource: font Times-Bold
%%IncludeResource: font Times-Italic
%%IncludeResource: font Times-Roman
%%IncludeResource: font Courier
grops begin/DEFS 1 dict def DEFS begin/u{.001 mul}bind def end/RES 72
def/PL 792 def/LS false def/ENC0[/asciicircum/asciitilde/Scaron/Zcaron
/scaron/zcaron/Ydieresis/trademark/quotesingle/.notdef/.notdef/.notdef
/scaron/zcaron/Ydieresis/trademark/quotesingle/Euro/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/space/exclam/quotedbl/numbersign/dollar/percent
@ -201,256 +226,254 @@ def/PL 792 def/LS false def/ENC0[/asciicircum/asciitilde/Scaron/Zcaron
/ugrave/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis]def
/Courier@0 ENC0/Courier RE/Times-Roman@0 ENC0/Times-Roman RE
/Times-Italic@0 ENC0/Times-Italic RE/Times-Bold@0 ENC0/Times-Bold RE
%%EndProlog
%%EndSetup
%%Page: 1 1
%%BeginPageSetup
BP
%%EndPageSetup
/F0 12/Times-Bold@0 SF(Bash \255 The GNU shell*)227.904 123 Q/F1 10
/Times-Italic@0 SF(Chet Rame)263.85 147 Q(y)-.3 E(Case W)221.72 159 Q
(estern Reserve Univer)-.92 E(sity)-.1 E -.15(ch)250.425 171 S
(et@po.cwru.edu).15 E/F2 10/Times-Bold@0 SF 2.5(1. Intr)72 207 R
(oduction)-.18 E(Bash)97 222.6 Q/F3 10/Times-Roman@0 SF .904
/Times-Italic@0 SF(Chet Rame)263.85 159 Q(y)-.3 E(Case W)221.72 171 Q
(estern Reserve Univer)-.92 E(sity)-.1 E -.15(ch)250.425 183 S
(et@po.cwru.edu).15 E/F2 10/Times-Bold@0 SF 2.5(1. Intr)72 219 R
(oduction)-.18 E(Bash)97 234.6 Q/F3 10/Times-Roman@0 SF .904
(is the shell, or command language interpreter)3.404 F 3.404(,t)-.4 G
.904(hat will appear in the GNU operating system.)-3.404 F 1.075
(The name is an acron)72 234.6 R 1.075(ym for the \231Bourne-Ag)-.15 F
(The name is an acron)72 246.6 R 1.075(ym for the \231Bourne-Ag)-.15 F
1.075(ain SHell\232, a pun on Ste)-.05 F 1.375 -.15(ve B)-.25 H 1.075
(ourne, the author of the direct).15 F .206(ancestor of the current)72
246.6 R/F4 8/Times-Roman@0 SF(UNIX)2.706 E F3 2.706<ae73>C(hell)-2.706 E
258.6 R/F4 8/Times-Roman@0 SF(UNIX)2.706 E F3 2.706<ae73>C(hell)-2.706 E
F1(/bin/sh)2.706 E F3 2.706(,w)C .205(hich appeared in the Se)-2.706 F
-.15(ve)-.25 G .205(nth Edition Bell Labs Research v).15 F(er)-.15 E(-)
-.2 E(sion of)72 258.6 Q/F5 9/Times-Roman@0 SF(UNIX)2.5 E F3(.)A .387
(Bash is an)97 274.2 R F2(sh)2.887 E F3 .387
-.2 E(sion of)72 270.6 Q/F5 9/Times-Roman@0 SF(UNIX)2.5 E F3(.)A .387
(Bash is an)97 286.2 R F2(sh)2.887 E F3 .387
(\255compatible shell that incorporates useful features from the K)B
.388(orn shell \()-.35 F F2(ksh)A F3 2.888(\)a)C .388(nd the C)-2.888 F
.023(shell \()72 286.2 R F2(csh)A F3 .023
.023(shell \()72 298.2 R F2(csh)A F3 .023
(\), described later in this article.)B .022
(It is ultimately intended to be a conformant implementation of the)
5.022 F 3.568(IEEE POSIX Shell and Utilities speci\214cation \(IEEE W)72
298.2 R 3.568(orking Group 1003.2\).)-.8 F 3.569(It of)8.569 F 3.569
(fers functional)-.25 F(impro)72 310.2 Q -.15(ve)-.15 G(ments o).15 E
310.2 R 3.568(orking Group 1003.2\).)-.8 F 3.569(It of)8.569 F 3.569
(fers functional)-.25 F(impro)72 322.2 Q -.15(ve)-.15 G(ments o).15 E
-.15(ve)-.15 G 2.5(rs).15 G 2.5(hf)-2.5 G(or both interacti)-2.5 E .3
-.15(ve a)-.25 H(nd programming use.).15 E .697
(While the GNU operating system will most lik)97 325.8 R .697
(While the GNU operating system will most lik)97 337.8 R .697
(ely include a v)-.1 F .697(ersion of the Berk)-.15 F(ele)-.1 E 3.197
(ys)-.15 G .696(hell csh, Bash)-3.197 F .015(will be the def)72 337.8 R
(ys)-.15 G .696(hell csh, Bash)-3.197 F .015(will be the def)72 349.8 R
.015(ault shell.)-.1 F(Lik)5.015 E 2.515(eo)-.1 G .015(ther GNU softw)
-2.515 F .016(are, Bash is quite portable.)-.1 F .016
(It currently runs on nearly e)5.016 F -.15(ve)-.25 G(ry).15 E -.15(ve)
72 349.8 S .523(rsion of).15 F F4(UNIX)3.023 E F3 .523(and a fe)3.023 F
72 361.8 S .523(rsion of).15 F F4(UNIX)3.023 E F3 .523(and a fe)3.023 F
3.023(wo)-.25 G .523
(ther operating systems \255 an independently-supported port e)-3.023 F
.523(xists for OS/2, and)-.15 F .706
(there are rumors of ports to DOS and W)72 361.8 R(indo)-.4 E .706
(there are rumors of ports to DOS and W)72 373.8 R(indo)-.4 E .706
(ws NT)-.25 F 5.706(.P)-.74 G .706(orts to)-5.706 F F5(UNIX)3.206 E F3
(-lik)A 3.206(es)-.1 G .706(ystems such as QNX and Minix)-3.206 F
(are part of the distrib)72 373.8 Q(ution.)-.2 E .405
(The original author of Bash w)97 389.4 R .405(as Brian F)-.1 F .405
(are part of the distrib)72 385.8 Q(ution.)-.2 E .405
(The original author of Bash w)97 401.4 R .405(as Brian F)-.1 F .405
(ox, an emplo)-.15 F .405(yee of the Free Softw)-.1 F .405(are F)-.1 F
2.905(oundation. The)-.15 F(cur)2.905 E(-)-.2 E(rent de)72 401.4 Q -.15
2.905(oundation. The)-.15 F(cur)2.905 E(-)-.2 E(rent de)72 413.4 Q -.15
(ve)-.25 G(loper and maintainer is Chet Rame).15 E 1.3 -.65(y, a v)-.15
H(olunteer who w).45 E(orks at Case W)-.1 E(estern Reserv)-.8 E 2.5(eU)
-.15 G(ni)-2.5 E -.15(ve)-.25 G(rsity).15 E(.)-.65 E F2 2.5(2. What')72
425.4 R 2.5(sP)-.37 G(OSIX, anyway?)-2.5 E F1(POSIX)97 441 Q F3 .343
437.4 R 2.5(sP)-.37 G(OSIX, anyway?)-2.5 E F1(POSIX)97 453 Q F3 .343
(is a name originally coined by Richard Stallman for a f)2.843 F .343
(amily of open system standards based)-.1 F(on)72 453 Q F5(UNIX)3.24 E
(amily of open system standards based)-.1 F(on)72 465 Q F5(UNIX)3.24 E
F3 5.74(.T)C .74(here are a number of aspects of)-5.74 F F5(UNIX)3.24 E
F3 .74(under consideration for standardization, from the basic)3.24 F
.192(system services at the system call and C library le)72 465 R -.15
.192(system services at the system call and C library le)72 477 R -.15
(ve)-.25 G 2.692(lt).15 G 2.692(oa)-2.692 G .192
(pplications and tools to system administration and)-2.692 F 2.5
(management. Each)72 477 R(area of standardization is assigned to a w)
(management. Each)72 489 R(area of standardization is assigned to a w)
2.5 E(orking group in the 1003 series.)-.1 E 2.814
(The POSIX Shell and Utilities standard has been de)97 492.6 R -.15(ve)
(The POSIX Shell and Utilities standard has been de)97 504.6 R -.15(ve)
-.25 G 2.814(loped by IEEE W).15 F 2.813(orking Group 1003.2)-.8 F .254
(\(POSIX.2\).\210 It concentrates on the command interpreter interf)72
504.6 R .253(ace and utility programs commonly e)-.1 F -.15(xe)-.15 G
(cuted).15 E 1.112(from the command line or by other programs.)72 516.6
516.6 R .253(ace and utility programs commonly e)-.1 F -.15(xe)-.15 G
(cuted).15 E 1.112(from the command line or by other programs.)72 528.6
R 1.112(An initial v)6.112 F 1.113
(ersion of the standard has been appro)-.15 F -.15(ve)-.15 G 3.613(da)
.15 G(nd)-3.613 E .365(published by the IEEE, and w)72 528.6 R .365
.15 G(nd)-3.613 E .365(published by the IEEE, and w)72 540.6 R .365
(ork is currently underw)-.1 F .365(ay to update it.)-.1 F .365
(There are four primary areas of w)5.365 F(ork)-.1 E
(in the 1003.2 standard:)72 540.6 Q 21.5<8341>72 556.2 S .835
(in the 1003.2 standard:)72 552.6 Q 21.5<8341>72 568.2 S .835
(spects of the shell')-21.5 F 3.335(ss)-.55 G .835
(yntax and command language.)-3.335 F 3.335(An)5.835 G .835
(umber of special b)-3.335 F .835(uiltins such as)-.2 F F2(cd)3.335 E F3
(and)3.335 E F2(exec)97 568.2 Q F3 .545(are being speci\214ed as part o\
(and)3.335 E F2(exec)97 580.2 Q F3 .545(are being speci\214ed as part o\
f the shell, since their functionality usually cannot be implemented)
3.046 F(by a separate e)97 580.2 Q -.15(xe)-.15 G(cutable;).15 E 21.5
<8341>72 595.8 S .926
3.046 F(by a separate e)97 592.2 Q -.15(xe)-.15 G(cutable;).15 E 21.5
<8341>72 607.8 S .926
(set of utilities to be called by shell scripts and applications.)
-18.074 F .927(Examples are programs lik)5.927 F(e)-.1 E F1 .927
(sed, tr)3.427 F(,)-1.11 E F3(and)97 607.8 Q F1(awk.)2.797 E F3 .297
(sed, tr)3.427 F(,)-1.11 E F3(and)97 619.8 Q F1(awk.)2.797 E F3 .297
(Utilities commonly implemented as shell b)5.297 F .296
(uiltins are described in this section, such as)-.2 F F2(test)2.796 E F3
(and)97 619.8 Q F2(kill)3.422 E F3 5.922(.A)C 3.422(ne)-5.922 G .922
(and)97 631.8 Q F2(kill)3.422 E F3 5.922(.A)C 3.422(ne)-5.922 G .922
(xpansion of this section')-3.572 F 3.423(ss)-.55 G .923
(cope, termed the User Portability Extension, or UPE, has)-3.423 F
(standardized interacti)97 631.8 Q .3 -.15(ve p)-.25 H(rograms such as)
.15 E F1(vi)2.5 E F3(and)2.5 E F1(mailx;)2.5 E F3 21.5<8341>72 647.4 S
(standardized interacti)97 643.8 Q .3 -.15(ve p)-.25 H(rograms such as)
.15 E F1(vi)2.5 E F3(and)2.5 E F1(mailx;)2.5 E F3 21.5<8341>72 659.4 S
.288(group of functional interf)-18.712 F .287(aces to services pro)-.1
F .287(vided by the shell, such as the traditional)-.15 F/F6 10
/Courier@0 SF(system\(\))2.787 E F3 3.289(Cl)97 659.4 S .789
/Courier@0 SF(system\(\))2.787 E F3 3.289(Cl)97 671.4 S .789
(ibrary function.)-3.289 F .789(There are functions to perform shell w)
5.789 F .789(ord e)-.1 F .79(xpansions, perform \214lename e)-.15 F
(xpan-)-.15 E .324(sion \()97 671.4 R F1(globbing)A F3 .324
(\), obtain v)B .323(alues of POSIX.2 system con\214guration v)-.25 F
.323(ariables, retrie)-.25 F .623 -.15(ve v)-.25 H .323(alues of en)-.1
F(viron-)-.4 E(ment v)97 683.4 Q(ariables \()-.25 E F6(getenv\(\))A F3
(\), and other services;).833 E .32 LW 144 691.4 72 691.4 DL F4
(*An earlier v)72 703.2 Q
(xpan-)-.15 E 3.624(sion \()97 683.4 R F1(globbing)A F3 3.624
(\), obtain v)B 3.624(alues of POSIX.2 system con\214guration v)-.25 F
3.623(ariables, retrie)-.25 F 3.923 -.15(ve v)-.25 H 3.623(alues of)-.1
F .32 LW 144 691.4 72 691.4 DL F4(*An earlier v)72 703.2 Q
(ersion of this article appeared in The Linux Journal.)-.12 E(\210IEEE,)
72 715 Q/F7 8/Times-Italic@0 SF 1.231(IEEE Standar)3.231 F 3.231(df)
-.296 G 1.231(or Information T)-3.231 F(ec)-.736 E(hnolo)-.12 E 1.231
(gy -- P)-.08 F 1.231(ortable Oper)-.64 F 1.232
(ating System Interface \(POSIX\) P)-.12 F 1.232(art 2:)-.64 F
(Shell and Utilities)72 725 Q F4 2(,1)C(992.)-2 E EP
(Shell and Utilities)72 725 Q F4 2(,1)C(992.)-2 E 0 Cg EP
%%Page: 2 2
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Times-Roman@0 SF(-2-)282.17 48 Q 21.5<8341>72 84 S
(suite of \231de)-19 E -.15(ve)-.25 G(lopment\232 utilities such as).15
E/F1 10/Times-Italic@0 SF(c89)2.5 E F0(\(the POSIX.2 v)2.5 E(ersion of)
-.15 E F1(cc)2.5 E F0(\), and)A F1(yacc.)2.5 E F0 .483
(Bash is concerned with the aspects of the shell')97 99.6 R 2.983(sb)
/F0 10/Times-Roman@0 SF(-2-)282.17 48 Q(en)97 84 Q(vironment v)-.4 E
(ariables \()-.25 E/F1 10/Courier@0 SF(getenv\(\))A F0
(\), and other services;).833 E 21.5<8341>72 99.6 S(suite of \231de)-19
E -.15(ve)-.25 G(lopment\232 utilities such as).15 E/F2 10
/Times-Italic@0 SF(c89)2.5 E F0(\(the POSIX.2 v)2.5 E(ersion of)-.15 E
F2(cc)2.5 E F0(\), and)A F2(yacc.)2.5 E F0 .483
(Bash is concerned with the aspects of the shell')97 115.2 R 2.983(sb)
-.55 G(eha)-2.983 E .484(vior de\214ned by POSIX.2.)-.2 F .484
(The shell command)5.484 F 1.439
(language has of course been standardized, including the basic \215o)72
111.6 R 3.938(wc)-.25 G 1.438(ontrol and program e)-3.938 F -.15(xe)-.15
127.2 R 3.938(wc)-.25 G 1.438(ontrol and program e)-3.938 F -.15(xe)-.15
G 1.438(cution con-).15 F 1.284
(structs, I/O redirection and pipelining, ar)72 123.6 R 1.284
(structs, I/O redirection and pipelining, ar)72 139.2 R 1.284
(gument handling, v)-.18 F 1.284(ariable e)-.25 F 1.284
(xpansion, and quoting.)-.15 F(The)6.285 E F1(special)3.785 E F0 -.2(bu)
72 135.6 S .676
(xpansion, and quoting.)-.15 F(The)6.285 E F2(special)3.785 E F0 -.2(bu)
72 151.2 S .676
(iltins, which must be implemented as part of the shell to pro).2 F .676
(vide the desired functionality)-.15 F 3.176(,a)-.65 G .676
(re speci\214ed)-3.176 F .7(as being part of the shell; e)72 147.6 R .7
(xamples of these are)-.15 F/F2 10/Times-Bold@0 SF -2.3 -.15(ev a)3.201
H(l).15 E F0(and)3.201 E F2(export)3.201 E F0 5.701(.O)C .701
(re speci\214ed)-3.176 F .7(as being part of the shell; e)72 163.2 R .7
(xamples of these are)-.15 F/F3 10/Times-Bold@0 SF -2.3 -.15(ev a)3.201
H(l).15 E F0(and)3.201 E F3(export)3.201 E F0 5.701(.O)C .701
(ther utilities appear in the sections of)-5.701 F .256(POSIX.2 not de)
72 159.6 R -.2(vo)-.25 G .256(ted to the shell which are commonly \(and\
72 175.2 R -.2(vo)-.25 G .256(ted to the shell which are commonly \(and\
in some cases must be\) implemented as b).2 F(uiltin)-.2 E .213
(commands, such as)72 171.6 R F2 -.18(re)2.713 G(ad).18 E F0(and)2.713 E
F2(test)2.713 E F0 5.213(.P)C .213
(commands, such as)72 187.2 R F3 -.18(re)2.713 G(ad).18 E F0(and)2.713 E
F3(test)2.713 E F0 5.213(.P)C .213
(OSIX.2 also speci\214es aspects of the shell')-5.213 F 2.713(si)-.55 G
(nteracti)-2.713 E .513 -.15(ve b)-.25 H(eha).15 E .214(vior as part)-.2
F .598(of the UPE, including job control and command line editing.)72
183.6 R .598(Interestingly enough, only)5.598 F F1(vi)3.098 E F0 .598
(-style line edit-)B(ing commands ha)72 195.6 Q .3 -.15(ve b)-.2 H
(een standardized;).15 E F1(emacs)2.5 E F0
199.2 R .598(Interestingly enough, only)5.598 F F2(vi)3.098 E F0 .598
(-style line edit-)B(ing commands ha)72 211.2 Q .3 -.15(ve b)-.2 H
(een standardized;).15 E F2(emacs)2.5 E F0
(editing commands were left out due to objections.)2.5 E 1.128
(While POSIX.2 includes much of what the shell has traditionally pro)97
211.2 R 1.129(vided, some important things)-.15 F(ha)72 223.2 Q .344
226.8 R 1.129(vided, some important things)-.15 F(ha)72 238.8 Q .344
-.15(ve b)-.2 H .044(een omitted as being \231be).15 F .044
(yond its scope.)-.15 F 5.043<9a54>-.7 G .043
(here is, for instance, no mention of a dif)-5.043 F .043
(ference between a)-.25 F F1(lo)72 235.2 Q(gin)-.1 E F0 1.445
(ference between a)-.25 F F2(lo)72 250.8 Q(gin)-.1 E F0 1.445
(shell and an)3.945 F 3.945(yo)-.15 G 1.445(ther interacti)-3.945 F
1.745 -.15(ve s)-.25 H 1.446
(hell \(since POSIX.2 does not specify a login program\).).15 F 1.446
(No \214x)6.446 F(ed)-.15 E(startup \214les are de\214ned, either \255 \
the standard does not mention)72 247.2 Q F1(.pr)2.5 E(o\214le)-.45 E F0
(.)A F2 2.5(3. Basic)72 271.2 R(Bash featur)2.5 E(es)-.18 E F0 1.448
(Since the Bourne shell pro)97 286.8 R 1.448
the standard does not mention)72 262.8 Q F2(.pr)2.5 E(o\214le)-.45 E F0
(.)A F3 2.5(3. Basic)72 286.8 R(Bash featur)2.5 E(es)-.18 E F0 1.448
(Since the Bourne shell pro)97 302.4 R 1.448
(vides Bash with most of its philosophical underpinnings, Bash inherits)
-.15 F .64(most of its features and functionality from sh.)72 298.8 R
-.15 F .64(most of its features and functionality from sh.)72 314.4 R
.641(Bash implements all of the traditional sh \215o)5.641 F 3.141(wc)
-.25 G .641(ontrol con-)-3.141 F .8(structs \()72 310.8 R F1(for)A F0(,)
A F1(if)3.3 E F0(,)A F1(while)3.3 E F0 3.3(,e)C 3.3(tc.\). All)-3.3 F
-.25 G .641(ontrol con-)-3.141 F .8(structs \()72 326.4 R F2(for)A F0(,)
A F2(if)3.3 E F0(,)A F2(while)3.3 E F0 3.3(,e)C 3.3(tc.\). All)-3.3 F
.799(of the Bourne shell b)3.3 F .799
(uiltins, including those not speci\214ed in the POSIX.2)-.2 F .536
(standard, appear in Bash.)72 322.8 R(Shell)5.536 E F1(functions)3.036 E
(standard, appear in Bash.)72 338.4 R(Shell)5.536 E F2(functions)3.036 E
F0 3.036(,i)C .536(ntroduced in the SVR2 v)-3.036 F .537
(ersion of the Bourne shell, are similar)-.15 F .779
(to shell scripts, b)72 334.8 R .779
(to shell scripts, b)72 350.4 R .779
(ut are de\214ned using a special syntax and are e)-.2 F -.15(xe)-.15 G
.779(cuted in the same process as the calling).15 F 2.841(shell. Bash)72
346.8 R .341(has shell functions which beha)2.841 F .641 -.15(ve i)-.2 H
362.4 R .341(has shell functions which beha)2.841 F .641 -.15(ve i)-.2 H
2.841(naf).15 G .341(ashion upw)-2.941 F .342
(ard-compatible with sh functions.)-.1 F .342(There are)5.342 F 1.447
(certain shell v)72 358.8 R 1.446
(certain shell v)72 374.4 R 1.446
(ariables that Bash interprets in the same w)-.25 F 1.446
(ay as sh, such as)-.1 F F2(PS1)3.946 E F0(,)A F2(IFS)3.946 E F0 3.946
(,a)C(nd)-3.946 E F2 -.74(PA)3.946 G(TH)-.21 E F0 6.446(.B)C(ash)-6.446
E 1.423(implements essentially the same grammar)72 370.8 R 3.924(,p)-.4
(ay as sh, such as)-.1 F F3(PS1)3.946 E F0(,)A F3(IFS)3.946 E F0 3.946
(,a)C(nd)-3.946 E F3 -.74(PA)3.946 G(TH)-.21 E F0 6.446(.B)C(ash)-6.446
E 1.423(implements essentially the same grammar)72 386.4 R 3.924(,p)-.4
G 1.424(arameter and v)-3.924 F 1.424(ariable e)-.25 F 1.424
(xpansion semantics, redirection, and)-.15 F 1.06
(quoting as the Bourne shell.)72 382.8 R 1.06(Where dif)6.06 F 1.06
(quoting as the Bourne shell.)72 398.4 R 1.06(Where dif)6.06 F 1.06
(ferences appear between the POSIX.2 standard and traditional sh)-.25 F
(beha)72 394.8 Q(vior)-.2 E 2.5(,B)-.4 G(ash follo)-2.5 E(ws POSIX.)-.25
E 1.608(The K)97 410.4 R 1.608(orn Shell \()-.35 F F2(ksh)A F0 4.108
(\)i)C 4.108(sad)-4.108 G 1.608
(escendent of the Bourne shell written at A)-4.108 F 1.609
(T&T Bell Laboratories by)-1.11 F(Da)72 422.4 Q 1.059(vid K)-.2 F 3.559
(orn\207. It)-.35 F(pro)3.559 E 1.059
(beha)72 410.4 Q(vior)-.2 E 2.5(,B)-.4 G(ash follo)-2.5 E(ws POSIX.)-.25
E 1.608(The K)97 426 R 1.608(orn Shell \()-.35 F F3(ksh)A F0 4.108(\)i)C
4.108(sad)-4.108 G 1.608(escendant of the Bourne shell written at A)
-4.108 F 1.609(T&T Bell Laboratories by)-1.11 F(Da)72 438 Q 1.059(vid K)
-.2 F 3.559(orn\207. It)-.35 F(pro)3.559 E 1.059
(vides a number of useful features that POSIX and Bash ha)-.15 F 1.359
-.15(ve a)-.2 H 3.558(dopted. Man).15 F 3.558(yo)-.15 G 3.558(ft)-3.558
G(he)-3.558 E(interacti)72 434.4 Q 1.312 -.15(ve f)-.25 H 1.012
G(he)-3.558 E(interacti)72 450 Q 1.312 -.15(ve f)-.25 H 1.012
(acilities in POSIX.2 ha).05 F 1.312 -.15(ve t)-.2 H 1.012
(heir roots in the ksh: for e).15 F 1.013
(xample, the POSIX and ksh job control)-.15 F -.1(fa)72 446.4 S .513
(xample, the POSIX and ksh job control)-.15 F -.1(fa)72 462 S .513
(cilities are nearly identical. Bash includes features from the K).1 F
.513(orn Shell for both interacti)-.35 F .813 -.15(ve u)-.25 H .513
(se and shell).15 F 3.905(programming. F)72 458.4 R 1.405
(se and shell).15 F 3.905(programming. F)72 474 R 1.405
(or programming, Bash pro)-.15 F 1.405(vides v)-.15 F 1.405
(ariables such as)-.25 F F2(RANDOM)3.905 E F0(and)3.905 E F2(REPL)3.905
E(Y)-.92 E F0 3.905(,t)C(he)-3.905 E F2(typeset)3.905 E F0 -.2(bu)72
470.4 S .398(iltin, the ability to remo).2 F .698 -.15(ve s)-.15 H .398
(ariables such as)-.25 F F3(RANDOM)3.905 E F0(and)3.905 E F3(REPL)3.905
E(Y)-.92 E F0 3.905(,t)C(he)-3.905 E F3(typeset)3.905 E F0 -.2(bu)72 486
S .398(iltin, the ability to remo).2 F .698 -.15(ve s)-.15 H .398
(ubstrings from v).15 F .398
(ariables based on patterns, and shell arithmetic.)-.25 F F2(RANDOM)
5.397 E F0 -.15(ex)72 482.4 S .489
(ariables based on patterns, and shell arithmetic.)-.25 F F3(RANDOM)
5.397 E F0 -.15(ex)72 498 S .489
(pands to a random number each time it is referenced; assigning a v).15
F .49(alue to)-.25 F F2(RANDOM)2.99 E F0 .49(seeds the random)2.99 F
.055(number generator)72 494.4 R(.)-.55 E F2(REPL)5.055 E(Y)-.92 E F0
.054(is the def)2.554 F .054(ault v)-.1 F .054(ariable used by the)-.25
F F2 -.18(re)2.554 G(ad).18 E F0 -.2(bu)2.554 G .054(iltin when no v).2
F .054(ariable names are sup-)-.25 F .742(plied as ar)72 506.4 R 3.243
(guments. The)-.18 F F2(typeset)3.243 E F0 -.2(bu)3.243 G .743
F .49(alue to)-.25 F F3(RANDOM)2.99 E F0 .49(seeds the random)2.99 F
.055(number generator)72 510 R(.)-.55 E F3(REPL)5.055 E(Y)-.92 E F0 .054
(is the def)2.554 F .054(ault v)-.1 F .054(ariable used by the)-.25 F F3
-.18(re)2.554 G(ad).18 E F0 -.2(bu)2.554 G .054(iltin when no v).2 F
.054(ariable names are sup-)-.25 F .742(plied as ar)72 522 R 3.243
(guments. The)-.18 F F3(typeset)3.243 E F0 -.2(bu)3.243 G .743
(iltin is used to de\214ne v).2 F .743(ariables and gi)-.25 F 1.043 -.15
(ve t)-.25 H .743(hem attrib).15 F .743(utes such as)-.2 F F2 -.18(re)
3.243 G(ad-).18 E(only)72 518.4 Q F0 5.512(.B)C .512
(ash arithmetic allo)-5.512 F .512(ws the e)-.25 F -.25(va)-.25 G .511
(luation of an e).25 F .511
(xpression and the substitution of the result.)-.15 F .511(Shell v)5.511
F(ari-)-.25 E .222
(ables may be used as operands, and the result of an e)72 530.4 R .222
(ve t)-.25 H .743(hem attrib).15 F .743(utes such as)-.2 F F3 -.18(re)
3.243 G(ad-).18 E(only)72 534 Q F0 5.512(.B)C .512(ash arithmetic allo)
-5.512 F .512(ws the e)-.25 F -.25(va)-.25 G .511(luation of an e).25 F
.511(xpression and the substitution of the result.)-.15 F .511(Shell v)
5.511 F(ari-)-.25 E .222
(ables may be used as operands, and the result of an e)72 546 R .222
(xpression may be assigned to a v)-.15 F 2.722(ariable. Nearly)-.25 F
.222(all of)2.722 F(the operators from the C language are a)72 542.4 Q
-.25(va)-.2 G(ilable, with the same precedence rules:).25 E/F3 10
/Courier@0 SF 6($e)97 560.4 S(cho $\(\(3 + 5 * 32\)\))-6 E(163)97 572.4
Q F0 -.15(Fo)72 594 S 3.24(ri).15 G(nteracti)-3.24 E 1.04 -.15(ve u)-.25
H .74(se, Bash implements ksh-style aliases and b).15 F .74
(uiltins such as)-.2 F F2(fc)3.24 E F0 .74(\(discussed belo)3.24 F .74
(w\) and)-.25 F F2(jobs)3.24 E F0(.)A .291(Bash aliases allo)72 606 R
2.791(was)-.25 G .291(tring to be substituted for a command name.)-2.791
F(The)5.291 E 2.791(yc)-.15 G .291(an be used to create a mnemonic)
-2.791 F .568(for a)72 618 R/F4 9/Times-Roman@0 SF(UNIX)3.068 E F0 .568
(command name \()3.068 F F3 .568(alias del=rm)B F0 .568(\), to e)B .567
.222(all of)2.722 F(the operators from the C language are a)72 558 Q
-.25(va)-.2 G(ilable, with the same precedence rules:).25 E F1 6($e)97
576 S(cho $\(\(3 + 5 * 32\)\))-6 E(163)97 588 Q F0 -.15(Fo)72 609.6 S
3.24(ri).15 G(nteracti)-3.24 E 1.04 -.15(ve u)-.25 H .74
(se, Bash implements ksh-style aliases and b).15 F .74(uiltins such as)
-.2 F F3(fc)3.24 E F0 .74(\(discussed belo)3.24 F .74(w\) and)-.25 F F3
(jobs)3.24 E F0(.)A .291(Bash aliases allo)72 621.6 R 2.791(was)-.25 G
.291(tring to be substituted for a command name.)-2.791 F(The)5.291 E
2.791(yc)-.15 G .291(an be used to create a mnemonic)-2.791 F .568
(for a)72 633.6 R/F4 9/Times-Roman@0 SF(UNIX)3.068 E F0 .568
(command name \()3.068 F F1 .568(alias del=rm)B F0 .568(\), to e)B .567
(xpand a single w)-.15 F .567(ord to a comple)-.1 F 3.067(xc)-.15 G .567
(ommand \()-3.067 F F3(alias)A .255
(news='xterm -g 80x45 -title trn -e trn -e -S1 -N &')72 630 R F0 .255
(\), or to ensure that a command)B(is in)72 642 Q -.2(vo)-.4 G -.1(ke).2
G 2.5(dw).1 G(ith a basic set of options \()-2.5 E F3
(alias ls="/bin/ls -F")A F0(\).)A .293(The C shell \()97 657.6 R F2(csh)
(ommand \()-3.067 F F1(alias)A .255
(news='xterm -g 80x45 -title trn -e trn -e -S1 -N &')72 645.6 R F0 .255
(\), or to ensure that a command)B(is in)72 657.6 Q -.2(vo)-.4 G -.1(ke)
.2 G 2.5(dw).1 G(ith a basic set of options \()-2.5 E F1
(alias ls="/bin/ls -F")A F0(\).)A .293(The C shell \()97 673.2 R F3(csh)
A F0 .293(\)\207, originally written by Bill Jo)B 2.792(yw)-.1 G .292
(hile at Berk)-2.792 F(ele)-.1 E 1.592 -.65(y, i)-.15 H 2.792(sw).65 G
.292(idely used and quite popular)-2.792 F 1.499(for its interacti)72
669.6 R 1.799 -.15(ve f)-.25 H 3.999(acilities. Bash).05 F 1.499
685.2 R 1.799 -.15(ve f)-.25 H 3.999(acilities. Bash).05 F 1.499
(includes a csh-compatible history e)3.999 F 1.5
(xpansion mechanism \(\231! history\232\),)-.15 F .019(brace e)72 681.6
R .018(xpansion, access to a stack of directories via the)-.15 F F2
(pushd)2.518 E F0(,)A F2(popd)2.518 E F0 2.518(,a)C(nd)-2.518 E F2(dirs)
(xpansion mechanism \(\231! history\232\),)-.15 F .019(brace e)72 697.2
R .018(xpansion, access to a stack of directories via the)-.15 F F3
(pushd)2.518 E F0(,)A F3(popd)2.518 E F0 2.518(,a)C(nd)-2.518 E F3(dirs)
2.518 E F0 -.2(bu)2.518 G .018(iltins, and tilde e).2 F(xpansion,)-.15 E
1.293(to generate users' home directories.)72 693.6 R -.35(Ti)6.294 G
1.293(to generate users' home directories.)72 709.2 R -.35(Ti)6.294 G
1.294(lde e).35 F 1.294(xpansion has also been adopted by both the K)
-.15 F 1.294(orn Shell and)-.35 F .32 LW 144 708.2 72 708.2 DL/F5 8
/Times-Roman@0 SF(\207Morris Bolsk)72 720 Q 2(ya)-.12 G(nd Da)-2 E
-.15 F 1.294(orn Shell and)-.35 F .32 LW 144 717.2 72 717.2 DL/F5 8
/Times-Roman@0 SF(\207Morris Bolsk)72 727.2 Q 2(ya)-.12 G(nd Da)-2 E
(vid K)-.16 E(orn,)-.28 E/F6 8/Times-Italic@0 SF(The K)2 E
(ornShell Command and Pr)-.32 E -.08(og)-.36 G -.12(ra).08 G
(mming Langua).12 E -.08(ge)-.08 G F5 2(,P).08 G(rentice Hall, 1989.)-2
E EP
E 0 Cg EP
%%Page: 3 3
%%BeginPageSetup
BP
@ -520,10 +543,10 @@ tput of the command contained within the parentheses, with)-.15 F .664
(xpansion, the ability to de\214ne a v)-.15 F(ariable)-.25 E .283
(and a function with the same name, local v)72 398.4 R .282
(ariables in shell functions, the ability to enable and disable indi-)
-.25 F .547(vidual b)72 410.4 R .547
(uiltins or write a function to replace a b)-.2 F .547
(uiltin, or a means to e)-.2 F .547
(xport a shell function to a child pro-)-.15 F(cess.)72 422.4 Q .32
-.25 F 1.532(vidual b)72 410.4 R 1.532
(uiltins or write a function to replace a b)-.2 F 1.533
(uiltin, or a means to e)-.2 F 1.533(xport a shell function to a child)
-.15 F(process.)72 422.4 Q .32
(Bash has closed a long-standing shell security hole by not using the)97
438 R F1($IFS)2.82 E F0 -.25(va)2.82 G .32(riable to split each w).25 F
(ord)-.1 E 1.254(read by the shell, b)72 450 R 1.254
@ -580,11 +603,11 @@ E F1($ENV)2.842 E F0 2.841(,i)C 2.841(fs)-2.841 G .341
(on out here.)-.1 F(Interestingly)5.158 E 2.658(,t)-.65 G .158(he ne)
-2.658 F .159(xt release of ksh will change to reading)-.15 F F1($ENV)
2.659 E .32 LW 144 705.2 72 705.2 DL/F4 8/Times-Roman@0 SF .559
(\207Bill Jo)72 717 R 1.599 -.52(y, A)-.08 H 2.559(nI).52 G .559
(\207Bill Jo)72 715.2 R 1.599 -.52(y, A)-.08 H 2.559(nI).52 G .559
(ntroduction to the C Shell,)-2.559 F/F5 8/Times-Italic@0 SF .558
(UNIX User')2.558 F 2.558(sS)-.32 G .558(upplementary Documents)-2.558 F
F4 2.558(,U)C(ni)-2.558 E -.12(ve)-.2 G .558(rsity of California at).12
F(Berk)72 727 Q(ele)-.08 E 1.04 -.52(y, 1)-.12 H(986.).52 E EP
F(Berk)72 725.2 Q(ele)-.08 E 1.04 -.52(y, 1)-.12 H(986.).52 E 0 Cg EP
%%Page: 4 4
%%BeginPageSetup
BP
@ -696,7 +719,7 @@ R -.15(ey)-.1 G 1.196(map to which subsequent k).15 F 1.496 -.15(ey b)
-3.031 G -.15(ve)-3.281 G 3.031(nw).15 G .531
(hat happens when readline w)-3.031 F .531(ants to ring the terminal')
-.1 F 3.03(sb)-.55 G 3.03(ell. All)-3.03 F .53(of these v)3.03 F
(ariables)-.25 E EP
(ariables)-.25 E 0 Cg EP
%%Page: 5 5
%%BeginPageSetup
BP
@ -724,9 +747,9 @@ S(repare to type a quoted word -- insert open and close double)-6 E 6
249.6 Q($endif)97 261.6 Q F0 .322(There is a readline command to re-rea\
d the \214le, so users can edit the \214le, change some bindings, and b\
e)72 283.2 R(gin)-.15 E(to use them almost immediately)72 295.2 Q(.)-.65
E .851(Bash implements the)97 310.8 R F1(bind)3.351 E F0 -.2(bu)3.351 G
.851(iltin for more dyamic control of readline than the startup \214le \
permits.).2 F F1(Bind)72 322.8 Q F0 .25(is used in se)2.75 F -.15(ve)
E .518(Bash implements the)97 310.8 R F1(bind)3.018 E F0 -.2(bu)3.018 G
.518(iltin for more dynamic control of readline than the startup \214le\
permits.).2 F F1(Bind)72 322.8 Q F0 .25(is used in se)2.75 F -.15(ve)
-.25 G .25(ral w).15 F 2.75(ays. In)-.1 F/F3 10/Times-Italic@0 SF(list)
2.75 E F0 .25(mode, it can display the current k)2.75 F .55 -.15(ey b)
-.1 H .25(indings, list all the readline edit-).15 F .149(ing directi)72
@ -781,11 +804,11 @@ lly quite good at determining what type of completion to attempt.)72
(and the readline library)72 570 R 5.077(.B)-.65 G .077(ash pro)-5.077 F
.077(vides v)-.15 F .077(ariables \()-.25 F F1($HISTFILE)A F0(,)A F1
($HISTSIZE)2.577 E F0 2.577(,a)C(nd)-2.577 E F1($HISTCONTR)2.577 E(OL)
-.3 E F0 2.577(\)a)C(nd)-2.577 E(the)72 582 Q F1(history)2.89 E F0(and)
2.89 E F1(fc)2.89 E F0 -.2(bu)2.89 G .39
(iltins to manipulate the history list.).2 F .391(The v)5.391 F .391
(alue of)-.25 F F1($HISTFILE)2.891 E F0 .391(specifes the \214le where)
2.891 F .49(Bash writes the command history on e)72 594 R .489
-.3 E F0 2.577(\)a)C(nd)-2.577 E(the)72 582 Q F1(history)2.759 E F0(and)
2.759 E F1(fc)2.759 E F0 -.2(bu)2.759 G .259
(iltins to manipulate the history list.).2 F .26(The v)5.259 F .26
(alue of)-.25 F F1($HISTFILE)2.76 E F0 .26(speci\214es the \214le where)
2.76 F .49(Bash writes the command history on e)72 594 R .489
(xit and reads it on startup.)-.15 F F1($HISTSIZE)5.489 E F0 .489
(is used to limit the number)2.989 F .642(of commands sa)72 606 R -.15
(ve)-.2 G 3.142(di).15 G 3.142(nt)-3.142 G .642(he history)-3.142 F(.)
@ -820,7 +843,7 @@ or a string typed by the user)72 690 R(.)-.55 E(Finally)72 702 Q 2.535
-.15(xe)-.15 G 1.022(cution of pre).15 F 1.022(vious commands v)-.25 F
1.022(ery similar to csh \(\231bang history\232, so)-.15 F
(called because the e)72 726 Q
(xclamation point introduces a history substitution\):)-.15 E EP
(xclamation point introduces a history substitution\):)-.15 E 0 Cg EP
%%Page: 6 6
%%BeginPageSetup
BP
@ -903,7 +926,7 @@ e)-.15 F .104(when opened.)72 648 R .103
(xpansion. Process)-.15 F .103(substitution can be used to com-)2.603 F
(pare the outputs of tw)72 660 Q 2.5(od)-.1 G(if)-2.5 E(ferent v)-.25 E
(ersions of an application as part of a re)-.15 E(gression test:)-.15 E
F1 6($c)97 678 S(mp <\(old_prog\) <\(new_prog\))-6 E EP
F1 6($c)97 678 S(mp <\(old_prog\) <\(new_prog\))-6 E 0 Cg EP
%%Page: 7 7
%%BeginPageSetup
BP
@ -998,7 +1021,7 @@ G .367
E(/usr/local/bin)97 624 Q 6($/)97 636 S(bin/pwd)-6 E
(/net/share/sun4/local/bin)97 648 Q 6($c)97 660 S 6(d.)-6 G(.)-6 E 6($p)
97 672 S(wd)-6 E(/usr/local)97 684 Q 6($/)97 696 S(bin/pwd)-6 E
(/net/share/sun4/local)97 708 Q 6($c)97 720 S 6(d.)-6 G(.)-6 E EP
(/net/share/sun4/local)97 708 Q 6($c)97 720 S 6(d.)-6 G(.)-6 E 0 Cg EP
%%Page: 8 8
%%BeginPageSetup
BP
@ -1097,7 +1120,7 @@ such)-2.931 F .136
(nting the use of these sequences in earlier v).15 F .559(ersions, b)
-.15 F .559(ut the readline redisplay algorithm assumed)-.2 F
(each character occupied ph)72 720 Q(ysical screen space and w)-.05 E
(ould wrap lines prematurely)-.1 E(.)-.65 E EP
(ould wrap lines prematurely)-.1 E(.)-.65 E 0 Cg EP
%%Page: 9 9
%%BeginPageSetup
BP
@ -1244,7 +1267,7 @@ F F1(HISTIGNORE)4.286 E F0 4.285(,w)C 1.785(hich w)-4.285 F 1.785
(mentation to be printed by the)72 697.2 R F1(help)3.851 E F0 1.351
(command \(possibly present in the shared object as well\).)3.851 F
1.351(It w)6.351 F(ould)-.1 E(manage the details of e)72 709.2 Q
(xtending the internal table of b)-.15 E(uiltins.)-.2 E EP
(xtending the internal table of b)-.15 E(uiltins.)-.2 E 0 Cg EP
%%Page: 10 10
%%BeginPageSetup
BP
@ -1256,14 +1279,14 @@ BP
(command, which prints)3.292 F 1.412(the v)72 96 R 1.412
(alues of system con\214guration v)-.25 F 1.411
(ariables de\214ned by POSIX.2, and a)-.25 F F1(diso)3.911 E(wn)-.1 E F0
-.2(bu)3.911 G 1.411(iltin, which causes a).2 F 1.347
(shell running with job control acti)72 108 R 1.647 -.15(ve t)-.25 H
3.847<6f99>.15 G(for)-3.847 E 1.347
(get about\232 one or more background jobs in its internal jobs)-.18 F
3.465(table. Using)72 120 R F1(getconf)3.465 E F0 3.465(,f)C .965(or e)
-3.465 F .965(xample, a user could retrie)-.15 F 1.264 -.15(ve a v)-.25
H .964(alue for)-.1 F F1($P)3.464 E -.95(AT)-.74 G(H).95 E F0 .964
(guaranteed to \214nd all of the)3.464 F .884
-.2(bu)3.911 G 1.411(iltin, which causes a).2 F .547
(shell running with job control acti)72 108 R .847 -.15(ve t)-.25 H
3.047<6f99>.15 G(for)-3.047 E .547
(get about\232 one or more background jobs in its internal jobs ta-)-.18
F 3.866(ble. Using)72 120 R F1(getconf)3.866 E F0 3.866(,f)C 1.366(or e)
-3.866 F 1.366(xample, a user could retrie)-.15 F 1.666 -.15(ve a v)-.25
H 1.365(alue for)-.1 F F1($P)3.865 E -.95(AT)-.74 G(H).95 E F0 1.365
(guaranteed to \214nd all of the)3.865 F .884
(POSIX standard utilities, or \214nd out ho)72 132 R 3.385(wl)-.25 G
.885
(ong \214lenames may be in the \214le system containing a speci\214ed)
@ -1368,7 +1391,7 @@ E F0(for more information.)2.5 E .694(Bash is also distrib)97 656.4 R
-.15(ve)-.25 G .948(ral Linux distrib).15 F .948
(utions \(more about the dif)-.2 F .948
(ference in a moment\), and as contrib)-.25 F(uted)-.2 E .32 LW 144
676.4 72 676.4 DL/F5 8/Times-Roman@0 SF .781
678.2 72 678.2 DL/F5 8/Times-Roman@0 SF .781
(\207S. R. Bourne, \231UNIX T)72 688.2 R .781(ime-Sharing System:)-.28 F
.781(The UNIX Shell\232,)4.781 F/F6 8/Times-Italic@0 SF .78
(Bell System T)2.78 F(ec)-.736 E .78(hnical J)-.12 F(ournal)-.2 E F5
@ -1377,7 +1400,8 @@ E F0(for more information.)2.5 E .694(Bash is also distrib)97 656.4 R
(f, \231Rc \255 A Shell for Plan 9 and)-.2 F/F7 7/Times-Roman@0 SF(UNIX)
2.432 E F5(systems\232,)2.432 E F6(Pr)2.432 E .432
(oc. of the Summer 1990 EUUG Confer)-.36 F(ence)-.296 E F5 2.432(,L)C
(on-)-2.432 E(don, July)72 720 Q 2(,1)-.52 G(990, pp. 21-33.)-2 E EP
(on-)-2.432 E(don, July)72 720 Q 2(,1)-.52 G(990, pp. 21-33.)-2 E 0 Cg
EP
%%Page: 11 11
%%BeginPageSetup
BP
@ -1410,9 +1434,9 @@ F .8(It is suf)5.8 F .8(\214ciently portable to run on nearly e)-.25 F
(ral thousand re).15 F 1.515(gular users, and their feedback has)-.15 F
(helped to mak)72 235.2 Q 2.5(ei)-.1 G 2.5(ta)-2.5 G 2.5(sg)-2.5 G
(ood as it is today \255 a testament to the bene\214ts of free softw)
-2.5 E(are.)-.1 E .32 LW 144 708.2 72 708.2 DL/F4 8/Times-Roman@0 SF
-2.5 E(are.)-.1 E .32 LW 144 710 72 710 DL/F4 8/Times-Roman@0 SF
(*BSD/386 is a trademark of Berk)72 720 Q(ele)-.08 E 2(yS)-.12 G(oftw)-2
E(are Design, Inc.)-.08 E EP
E(are Design, Inc.)-.08 E 0 Cg EP
%%Trailer
end
%%EOF

3479
doc/bash.0

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

Binary file not shown.

15096
doc/bash.ps

File diff suppressed because it is too large Load diff

Binary file not shown.

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

Binary file not shown.

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,13 @@
.\" This is a hack to force bash builtins into the whatis database
.\" and to get the list of builtins to come up with the man command.
.TH BASH_BUILTINS 1 "2004 Apr 20" "GNU Bash-4.0"
.\"
.\" File Name macro. This used to be `.PN', for Path Name,
.\" but Sun doesn't seem to like that very much.
.\"
.de FN
\fI\|\\$1\|\fP
..
.TH BASH_BUILTINS 1 "2004 Apr 20" "GNU Bash-4.2"
.SH NAME
bash, :, ., [, alias, bg, bind, break, builtin, caller,
cd, command, compgen, complete,

File diff suppressed because it is too large Load diff

View file

@ -18,7 +18,7 @@ RREESSTTRRIICCTTEEDD SSHHEELLLL
+o specifying command names containing //
+o specifying a file name 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

View file

@ -1,12 +1,12 @@
%!PS-Adobe-3.0
%%Creator: groff version 1.19.2
%%CreationDate: Tue Dec 28 14:30:24 2010
%%CreationDate: Mon Feb 24 08:28:31 2014
%%DocumentNeededResources: font Times-Roman
%%+ font Times-Bold
%%DocumentSuppliedResources: procset grops 1.19 2
%%Pages: 1
%%PageOrder: Ascend
%%DocumentMedia: Default 595 842 0 () ()
%%DocumentMedia: Default 612 792 0 () ()
%%Orientation: Portrait
%%EndComments
%%BeginDefaults
@ -188,16 +188,16 @@ setpacking
%%EndProlog
%%BeginSetup
%%BeginFeature: *PageSize Default
<< /PageSize [ 595 842 ] /ImagingBBox null >> setpagedevice
<< /PageSize [ 612 792 ] /ImagingBBox null >> setpagedevice
%%EndFeature
%%IncludeResource: font Times-Roman
%%IncludeResource: font Times-Bold
grops begin/DEFS 1 dict def DEFS begin/u{.001 mul}bind def end/RES 72
def/PL 841.89 def/LS false def/ENC0[/asciicircum/asciitilde/Scaron
/Zcaron/scaron/zcaron/Ydieresis/trademark/quotesingle/Euro/.notdef
def/PL 792 def/LS false def/ENC0[/asciicircum/asciitilde/Scaron/Zcaron
/scaron/zcaron/Ydieresis/trademark/quotesingle/Euro/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/space/exclam/quotedbl/numbersign/dollar/percent
/.notdef/.notdef/space/exclam/quotedbl/numbersign/dollar/percent
/ampersand/quoteright/parenleft/parenright/asterisk/plus/comma/hyphen
/period/slash/zero/one/two/three/four/five/six/seven/eight/nine/colon
/semicolon/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O
@ -245,7 +245,7 @@ E F0(\(1\))A F1(RESTRICTED SHELL)72 112.8 Q F0(If)108 124.8 Q F2(bash)
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 32.5<8373>108 199.2 S
(pecifying command names containing)-32.5 E F2(/)2.5 E F0 32.5<8373>108
216 S(pecifying a \214le name containing a)-32.5 E F2(/)2.5 E F0
216 S(pecifying a \214lename containing a)-32.5 E 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 32.5<8373>108 232.8 S .45
(pecifying a \214lename containing a slash as an ar)-32.5 F .449

File diff suppressed because it is too large Load diff

View file

@ -1,10 +1,10 @@
@ignore
Copyright (C) 1988-2011 Free Software Foundation, Inc.
Copyright (C) 1988-2014 Free Software Foundation, Inc.
@end ignore
@set LASTCHANGE Tue Dec 28 13:41:22 EST 2010
@set LASTCHANGE Sun Feb 2 16:22:00 EST 2014
@set EDITION 4.2
@set VERSION 4.2
@set UPDATED 28 December 2010
@set UPDATED-MONTH December 2010
@set EDITION 4.3
@set VERSION 4.3
@set UPDATED 2 February 2014
@set UPDATED-MONTH February 2014

30
error.c
View file

@ -340,6 +340,36 @@ parser_error (lineno, format, va_alist)
}
#ifdef DEBUG
/* This assumes ASCII and is suitable only for debugging */
char *
strescape (str)
const char *str;
{
char *r, *result;
unsigned char *s;
r = result = (char *)xmalloc (strlen (str) * 2 + 1);
for (s = (unsigned char *)str; s && *s; s++)
{
if (*s < ' ')
{
*r++ = '^';
*r++ = *s+64;
}
else if (*s == 127)
{
*r++ = '^';
*r++ = '?';
}
else
*r++ = *s;
}
*r = '\0';
return result;
}
void
#if defined (PREFER_STDARG)
itrace (const char *format, ...)

View file

@ -51,6 +51,7 @@ extern void internal_error __P((const char *, ...)) __attribute__((__format__ (
extern void internal_warning __P((const char *, ...)) __attribute__((__format__ (printf, 1, 2)));
/* Debugging functions, not enabled in released version. */
extern char *strescape __P((const char *));
extern void itrace __P((const char *, ...)) __attribute__ ((__format__ (printf, 1, 2)));
extern void trace __P((const char *, ...)) __attribute__ ((__format__ (printf, 1, 2)));
@ -59,7 +60,7 @@ extern void command_error __P((const char *, int, int, int));
extern char *command_errstr __P((int));
/* Specific errror message functions that eventually call report_error or
/* Specific error message functions that eventually call report_error or
internal_error. */
extern void err_badarraysub __P((const char *));

20
eval.c
View file

@ -1,6 +1,6 @@
/* eval.c -- reading and evaluating commands. */
/* Copyright (C) 1996-2009 Free Software Foundation, Inc.
/* Copyright (C) 1996-2011 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -54,6 +54,10 @@ extern int need_here_doc;
extern int current_command_number, current_command_line_count, line_number;
extern int expand_aliases;
#if defined (HAVE_POSIX_SIGNALS)
extern sigset_t top_level_mask;
#endif
static void send_pwd_to_eterm __P((void));
static sighandler alrm_catcher __P((int));
@ -75,12 +79,13 @@ reader_loop ()
{
int code;
code = setjmp (top_level);
code = setjmp_nosigs (top_level);
#if defined (PROCESS_SUBSTITUTION)
unlink_fifo_list ();
#endif /* PROCESS_SUBSTITUTION */
/* XXX - why do we set this every time through the loop? */
if (interactive_shell && signal_is_ignored (SIGINT) == 0)
set_signal_handler (SIGINT, sigint_sighandler);
@ -90,7 +95,7 @@ reader_loop ()
switch (code)
{
/* Some kind of throw to top_level has occured. */
/* Some kind of throw to top_level has occurred. */
case FORCE_EOF:
case ERREXIT:
case EXITPROG:
@ -118,6 +123,9 @@ reader_loop ()
dispose_command (current_command);
current_command = (COMMAND *)NULL;
}
#if defined (HAVE_POSIX_SIGNALS)
sigprocmask (SIG_SETMASK, &top_level_mask, (sigset_t *)NULL);
#endif
break;
default:
@ -190,12 +198,14 @@ alrm_catcher(i)
static void
send_pwd_to_eterm ()
{
char *pwd;
char *pwd, *f;
f = 0;
pwd = get_string_value ("PWD");
if (pwd == 0)
pwd = get_working_directory ("eterm");
f = pwd = get_working_directory ("eterm");
fprintf (stderr, "\032/%s\n", pwd);
free (f);
}
/* Call the YACC-generated parser and return the status of the parse.

View file

@ -143,7 +143,7 @@
</tr>
<tr>
<td>./functions/keep</td>
<td>Try to keep some programs in the forground and running.</td>
<td>Try to keep some programs in the foreground and running.</td>
</tr>
<tr>
<td>./functions/ksh-cd</td>
@ -641,6 +641,10 @@
<td>Bourne shell cshell-emulator.</td>
<td>csh</td>
</tr>
<tr>
<td>./scripts/bash-hexdump.sh</td>
<td>hexdump(1) in bash</td>
<td>hexdump -C, hd</td>
<tr>
<td>./scripts/cat.sh</td>
<td>Readline-based pager.</td>

View file

@ -32,7 +32,7 @@ Path Description X-Ref
./functions/isvalidip Test user input for valid IP Addresses.
./functions/jdate.bash Julian date conversion.
./functions/jj.bash Look for running jobs.
./functions/keep Try to keep some programs in the forground and running.
./functions/keep Try to keep some programs in the foreground and running.
./functions/ksh-cd ksh-like 'cd': cd [-LP] [dir [change]]. ksh
./functions/ksh-compat-test ksh-like arithmetic test replacements. ksh
./functions/kshenv Functions and aliases to provide the beginnings of a ksh environment for bash. ksh
@ -151,6 +151,7 @@ Path Description X-Ref
./scripts Example scripts
./scripts/adventure.sh Text adventure game in bash!
./scripts/bash-hexdump.sh hexdump(1) in bash
./scripts/bcsh.sh Bourne shell cshell-emulator. csh
./scripts/cat.sh Readline-based pager. cat, readline pager
./scripts/center Center - center a group of lines.

76
examples/complete/cdfunc Normal file
View file

@ -0,0 +1,76 @@
# cdfunc - example completion function for cd
#
# based on the cd completion function from the bash_completion package
#
# Chet Ramey <chet.ramey@case.edu>
#
# Copyright 2011 Chester Ramey
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# TThis program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
_comp_cd()
{
local IFS=$' \t\n' # normalize IFS
local cur _skipdot _cdpath
local i j k
# Tilde expansion, with side effect of expanding tilde to full pathname
case "$2" in
\~*) eval cur="$2" ;;
*) cur=$2 ;;
esac
# no cdpath or absolute pathname -- straight directory completion
if [[ -z "${CDPATH:-}" ]] || [[ "$cur" == @(./*|../*|/*) ]]; then
# compgen prints paths one per line; could also use while loop
IFS=$'\n'
COMPREPLY=( $(compgen -d -- "$cur") )
IFS=$' \t\n'
# CDPATH+directories in the current directory if not in CDPATH
else
IFS=$'\n'
_skipdot=false
# preprocess CDPATH to convert null directory names to .
_cdpath=${CDPATH/#:/.:}
_cdpath=${_cdpath//::/:.:}
_cdpath=${_cdpath/%:/:.}
for i in ${_cdpath//:/$'\n'}; do
if [[ $i -ef . ]]; then _skipdot=true; fi
k="${#COMPREPLY[@]}"
for j in $( compgen -d -- "$i/$cur" ); do
COMPREPLY[k++]=${j#$i/} # cut off directory
done
done
$_skipdot || COMPREPLY+=( $(compgen -d -- "$cur") )
IFS=$' \t\n'
fi
# variable names if appropriate shell option set and no completions
if shopt -q cdable_vars && [[ ${#COMPREPLY[@]} -eq 0 ]]; then
COMPREPLY=( $(compgen -v -- "$cur") )
fi
# append slash to passed directory name that is the only completion.
# readline will not do this if we complete from CDPATH
if [[ ${#COMPREPLY[@]} -eq 1 ]]; then
i=${COMPREPLY[0]} # shorthand
if [[ "$cur" == "$i" ]] && [[ "$i" != "*/" ]]; then
COMPREPLY[0]+=/
fi
fi
return 0
}
complete -o filenames -o nospace -o bashdefault -F _comp_cd cd

View file

@ -1,6 +1,23 @@
#
# Completion examples
#
# Chet Ramey <chet.ramey@case.edu>
#
# Copyright 2002 Chester Ramey
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# TThis program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# This encapsulates the default bash completion code

View file

@ -1,3 +1,22 @@
#
# Chet Ramey <chet.ramey@case.edu>
#
# Copyright 1999 Chester Ramey
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# TThis program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# usage: reverse arrayname
reverse()
{

View file

@ -2,6 +2,24 @@
# A function that works as a front end for both stty and the `bind'
# builtin, so the tty driver and readline see the same changes
#
#
# Chet Ramey <chet.ramey@case.edu>
#
# Copyright 2011 Chester Ramey
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# TThis program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# Convert between the stty ^H control character form and the readline \C-H

View file

@ -3,8 +3,24 @@
#
# usage: func name [name ...]
#
# Chet Ramey
# chet@ins.CWRU.Edu
# Chet Ramey <chet.ramey@case.edu>
#
# Copyright 1991 Chester Ramey
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# TThis program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
func()
{
local status=0

View file

@ -1,3 +1,22 @@
#
# Chet Ramey <chet.ramey@case.edu>
#
# Copyright 2002 Chester Ramey
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# TThis program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# inet2hex - Internet address conversion, dotted-decimal to hex
#

View file

@ -1,3 +1,22 @@
#
# Chet Ramey <chet.ramey@case.edu>
#
# Copyright 1998 Chester Ramey
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# TThis program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
isnum2()
{
case "$1" in

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