Imported from ../bash-2.05b.tar.gz.
This commit is contained in:
parent
f73dda092b
commit
7117c2d221
362 changed files with 34387 additions and 15063 deletions
45
AUTHORS
45
AUTHORS
|
|
@ -406,3 +406,48 @@ tests/misc/sigint.t3.sh Chet Ramey
|
|||
tests/misc/sigint.t4.sh Chet Ramey
|
||||
tests/misc/test-minus-e.1 Chet Ramey
|
||||
tests/misc/test-minus-e.2 Chet Ramey
|
||||
lib/sh/Makefile.in Chet Ramey
|
||||
lib/sh/clktck.c Chet Ramey
|
||||
lib/sh/clock.c Chet Ramey
|
||||
lib/sh/fmtullong.c Chet Ramey
|
||||
lib/sh/fmtulong.c Chet Ramey
|
||||
lib/sh/getcwd.c Chet Ramey, Roland McGrath
|
||||
lib/sh/getenv.c Chet Ramey, Brian Fox
|
||||
lib/sh/inet_aton.c Chet Ramey, Ulrich Drepper, Paul Vixie
|
||||
lib/sh/itos.c Chet Ramey
|
||||
lib/sh/mailstat.c Chet Ramey
|
||||
lib/sh/makepath.c Chet Ramey
|
||||
lib/sh/mktime.c Chet Ramey, Paul Eggert
|
||||
lib/sh/netconn.c Chet Ramey
|
||||
lib/sh/netopen.c Chet Ramey
|
||||
lib/sh/oslib.c Chet Ramey, Brian Fox
|
||||
lib/sh/pathcanon.c Chet Ramey
|
||||
lib/sh/pathphys.c Chet Ramey
|
||||
lib/sh/rename.c Chet Ramey
|
||||
lib/sh/setlinebuf.c Chet Ramey, Brian Fox
|
||||
lib/sh/shquote.c Chet Ramey
|
||||
lib/sh/shtty.c Chet Ramey
|
||||
lib/sh/snprintf.c Chet Ramey, Unknown
|
||||
lib/sh/spell.c Chet Ramey
|
||||
lib/sh/strcasecmp.c Chet Ramey, Brian Fox
|
||||
lib/sh/strerror.c Chet Ramey, Brian Fox
|
||||
lib/sh/strftime.c Arnold Robbins
|
||||
lib/sh/strindex.c Chet Ramey
|
||||
lib/sh/stringlist.c Chet Ramey
|
||||
lib/sh/stringvec.c Chet Ramey
|
||||
lib/sh/strpbrk.c Roland McGrath
|
||||
lib/sh/strtod.c Chet Ramey, Roland McGrath
|
||||
lib/sh/strtoimax.c Chet Ramey, Paul Eggert
|
||||
lib/sh/strtol.c Chet Ramey, Paul Eggert
|
||||
lib/sh/strtoll.c Chet Ramey, Paul Eggert
|
||||
lib/sh/strtoul.c Chet Ramey, Paul Eggert
|
||||
lib/sh/strtoull.c Chet Ramey, Paul Eggert
|
||||
lib/sh/strtoumax.c Chet Ramey, Paul Eggert
|
||||
lib/sh/strtrans.c Chet Ramey
|
||||
lib/sh/times.c Chet Ramey, Brian Fox
|
||||
lib/sh/timeval.c Chet Ramey
|
||||
lib/sh/tmpfile.c Chet Ramey
|
||||
lib/sh/vprint.c Chet Ramey, Brian Fox
|
||||
lib/sh/xstrchr.c Chet Ramey, Mitsuru Chinen
|
||||
lib/sh/zread.c Chet Ramey
|
||||
lib/sh/zwrite.c Chet Ramey
|
||||
|
|
|
|||
461
CHANGES
461
CHANGES
|
|
@ -1,3 +1,464 @@
|
|||
This document details the changes between this version, bash-2.05b-release,
|
||||
and the previous version, bash-2.05b-beta2.
|
||||
|
||||
1. Changes to Bash
|
||||
|
||||
a. Fixed an off-by-one error in the function that translates job
|
||||
specifications.
|
||||
|
||||
b. Note that we're running under Emacs and disable line editing if
|
||||
$EMACS == `t'.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
This document details the changes between this version, bash-2.05b-beta2,
|
||||
and the previous version, bash-2.05b-beta1.
|
||||
|
||||
1. Changes to Bash
|
||||
|
||||
a. Fixed the /= and %= arithmetic operators to catch division by zero.
|
||||
|
||||
b. Added putenv, setenv, unsetenv to getenv replacement for completeness.
|
||||
|
||||
c. Fixed a bug that could cause the -O expand_aliases invocation option
|
||||
to not take effect.
|
||||
|
||||
d. Fixed a problem with process substitution that resulted in incorrect
|
||||
behavior when the number of process substitutions in an individual
|
||||
command approached 64.
|
||||
|
||||
2. Changes to Readline
|
||||
|
||||
a. Fixed a problem with backward-char-search when on a system with support
|
||||
for multibyte characters when running in a locale without any multibyte
|
||||
characters.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
This document details the changes between this version, bash-2.05b-beta1,
|
||||
and the previous version, bash-2.05b-alpha1.
|
||||
|
||||
1. Changes to Bash
|
||||
|
||||
a. Fixed a problem when parsing a POSIX.2 character class name while
|
||||
evaluating a bracket expression containing multibyte characters.
|
||||
|
||||
b. Changed the help text for `bind' to make it clear that any command
|
||||
that may be placed in ~/.inputrc is a valid argument to `bind'.
|
||||
|
||||
c. Added `help' builtin entries for `((', `[[', and arithmetic for.
|
||||
|
||||
d. malloc updated again:
|
||||
o slightly better overflow and underflow detection by putting the
|
||||
chunk size at the beginning and end of the chunk and making
|
||||
sure they match in free/realloc
|
||||
o partial page allocated to make things page-aligned no longer
|
||||
completely wasted
|
||||
o block coalescing now enabled by default
|
||||
o splitting and coalescing enabled for 32-byte chunks, the most
|
||||
common size requested
|
||||
o fixed a problem that resulted in spurious underflow messages and
|
||||
aborts
|
||||
o bin sizes are precomputed and stored in an array rather than
|
||||
being computed at run time
|
||||
o malloc will return memory blocks back to the system if the block
|
||||
being freed is at the top of the heap and of sufficient size to
|
||||
make it worthwhile
|
||||
o malloc/free/realloc now inline memset instead of calling the
|
||||
libc function; uses Duff's device for good performance
|
||||
|
||||
e. Check for getservent(); make the service name completion code dependent
|
||||
on its presence.
|
||||
|
||||
f. Changed the readline callback that executes a command bound to a key
|
||||
sequence to not save the executed command on the history list and to
|
||||
save and restore the parsing state.
|
||||
|
||||
g. Changes to lib/sh/snprintf.c: fixed some bugs in the `g' and `G'
|
||||
floating point format display; implemented the "'" flag character
|
||||
that turns on thousands' grouping; fixed behavior on systems where
|
||||
MB_CUR_MAX does not evaluate to a constant.
|
||||
|
||||
h. The `unset' builtin no longer returns a failure status when asked to
|
||||
unset a previously-unset variable or function.
|
||||
|
||||
i. Changes to the build system to make it easier to cross-compile bash
|
||||
for different systems.
|
||||
|
||||
j. Added `,' to the characters that are backslash-escaped during filename
|
||||
completion, to avoid problems with complete-into-braces and RCS filenames
|
||||
containing commas.
|
||||
|
||||
k. Some changes to the multibyte character support code to avoid many calls
|
||||
to strlen().
|
||||
|
||||
l. Bash now correctly honors setting LANG to some value when LC_ALL does not
|
||||
already have a value.
|
||||
|
||||
m. Fixed a bug that could cause SIGSEGV when processing nested traps with
|
||||
trap handlers.
|
||||
|
||||
n. The `source/.' builtin now restores the positional parameters when it
|
||||
returns unless they were changed using the `set' builtin during the file's
|
||||
execution.
|
||||
|
||||
o. Fixed a bug that caused a syntax error when a command was terminated by
|
||||
EOF.
|
||||
|
||||
2. New Features in Bash
|
||||
|
||||
a. There is now support for placing the long help text into separate files
|
||||
installed into ${datadir}/bash. Not enabled by default; can be turned
|
||||
on with `--enable-separate-helpfiles' option to configure.
|
||||
|
||||
b. All builtins that take operands accept a `--' pseudo-option, except
|
||||
`echo'.
|
||||
|
||||
c. The `echo' builtin now accepts \0xxx (zero to three octal digits following
|
||||
the `0') in addition to \xxx (one to three octal digits) for SUSv3/XPG6/
|
||||
POSIX.1-2001 compliance.
|
||||
|
||||
3. Changes to Readline
|
||||
|
||||
a. Fixed a small problem in _rl_insert_char with multibyte characters.
|
||||
|
||||
b. Fixes from IBM for line wrapping problems when using multibyte characters.
|
||||
|
||||
c. Fixed a problem which caused the display to be messed up when the last
|
||||
line of a multi-line prompt (possibly containing invisible characters)
|
||||
was longer than the screen width.
|
||||
|
||||
d. Fixed a problem with the vi-mode `r' command that ocurred on systems with
|
||||
support for multibyte characters when running in a locale without any
|
||||
multibyte characters.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
This document details the changes between this version, bash-2.05b-alpha1,
|
||||
and the previous version, bash-2.05a-release.
|
||||
|
||||
1. Changes to Bash
|
||||
|
||||
a. Some changes to work around inlining differences between compilers.
|
||||
|
||||
b. Added more prototypes for internal shell typedefs, to catch argument
|
||||
passing errors when using pointers to functions.
|
||||
|
||||
c. The `cd' builtin now fails in posix mode when a valid directory cannot be
|
||||
constructed from a relative pathname argument and the $PWD using pathname
|
||||
canonicalization, and the -P option has not been supplied. Previously,
|
||||
the shell would attempt to use what the user typed, leading to weird
|
||||
values for $PWD and discrepancies between the value of $PWD and the
|
||||
actual working directory.
|
||||
|
||||
d. The `cd' builtin now resets $PWD when canonicalization fails but a chdir
|
||||
to the pathname passed as an argument succeeds (when not in posix mode).
|
||||
|
||||
e. The `fc' builtin has been fixed, as POSIX requires, to use the closest
|
||||
history position in range when given an out-of-range argument.
|
||||
|
||||
f. The history file loading code was changed to allow lines to be saved in
|
||||
the history list from the shell startup files.
|
||||
|
||||
g. `history -s args' now works bettern in compound commands.
|
||||
|
||||
h. The tilde expansion code was fixed to better recognize when it's being
|
||||
invoked in an assignment context, which enables expansion after `='
|
||||
and `:'.
|
||||
|
||||
i. Fixed the command name completion code so a slash is no longer appended
|
||||
to a single match if there happens to be a directory with that name in
|
||||
$PWD.
|
||||
|
||||
j. Fixed compound array assignment to no longer perform alias expansion, to
|
||||
allow reserved words as array members, and to not produce extra output
|
||||
when the `-v' option had been enabled.
|
||||
|
||||
k. Fixed the programmable completion code to better handle newlines in lists
|
||||
of possible completions (e.g., `complete -W').
|
||||
|
||||
l. Removed the reserved words from the `bash-builtins' manual page.
|
||||
|
||||
m. Parser error reporting now attempts to do a better job of identifying the
|
||||
token in error rather than doing straight textual analysis.
|
||||
|
||||
n. Fixes for Inf/NaN, locales, wide/multibyte characters and zero-length
|
||||
arguments in the library snprintf(3) replacement.
|
||||
|
||||
o. `read -e' no longer does command name completion on the first word on
|
||||
the line being read.
|
||||
|
||||
p. `select' now returns failure if the read of the user's selection fails.
|
||||
|
||||
q. Fixed a bug that could cause a core dump when setting $PIPESTATUS.
|
||||
|
||||
r. Fixes to not allocate so many job slots when the shell is running a loop
|
||||
with job control enabled in a subshell of an interactive shell.
|
||||
|
||||
s. Fixed a bug in the trap code that caused traps to be inherited by
|
||||
command substitutions in some cases.
|
||||
|
||||
t. Fixed a bug that could cause alias expansion to inappropriately expand
|
||||
the word following the alias.
|
||||
|
||||
u. Fixed a bug in the `kill' builtin that mishandled negative pid arguments.
|
||||
|
||||
v. The parser is less lenient when parsing assignment statements where the
|
||||
characters before the `=' don't comprise a valid identifier.
|
||||
|
||||
w. The arithmetic expression evaluation code now honors the setting of the
|
||||
`-u' option when expanding variable names.
|
||||
|
||||
x. Fixed the arithmetic evaluation code to allow array subscripts to be
|
||||
assigned (`let b[7]=42') and auto-incremented and auto-decremented
|
||||
(e.g., b[7]++).
|
||||
|
||||
y. Reimplemented the existing prompt string date and time expansions using
|
||||
strftime(3), which changed the output of \@ in some locales.
|
||||
|
||||
z. Fixed a bug that could cause a core dump when a special shell variable
|
||||
(like RANDOM) was converted to an array with a variable assignment.
|
||||
|
||||
aa. Fixed a bug that would reset the handler for a signal the user had
|
||||
trapped to a function that would exit the shell when setting the exit
|
||||
trap in a non-interactive shell.
|
||||
|
||||
bb. Changed the execve(2) wrapper code to check whether or not a failing
|
||||
command is a directory before looking at whether a `#!' interpreter
|
||||
failed for some reason.
|
||||
|
||||
cc. Fixed a bug in the command printing code so it no longer inserts a `;'
|
||||
after a newline, which produces a syntax error when reused as input.
|
||||
|
||||
dd. The code that expands $PS4 no longer inherits the `-x' flag.
|
||||
|
||||
ee. The bash-specific completion functions may now take advantage of the
|
||||
double-TAB and M-? features of the standard readline completion
|
||||
functions.
|
||||
|
||||
ff. The mail checking code no longer prints a message if the checked file's
|
||||
size has not increased, even if the access time is less than the modification time.
|
||||
|
||||
gg. Rewrote the variable symbol table code: there is now a stack of
|
||||
contexts, each possibly including a separate symbol table; there can
|
||||
be more than one temporary environment supplied to nested invocations
|
||||
of `./source'; the temporary environments no longer require so much
|
||||
special-case code; shell functions now handle the temporary environment
|
||||
and local variables more consistently; function scope exit is faster now
|
||||
that the entire symbol table does not have to be traversed to dispose of
|
||||
local variables; it is now easier to push vars from the temporary
|
||||
environment to the shell's variable table in posix mode; some duplicated
|
||||
code has been removed.
|
||||
|
||||
hh. Regularized the error message printing code; builtin_error is now called
|
||||
more consistently, and common error message strings are handled by small
|
||||
functions. This should make eventual message translation easier.
|
||||
|
||||
ii. Error messages now include the line number in a script when the shell
|
||||
is not interactive.
|
||||
|
||||
jj. Array subscript expansion now takes place even when the array variable is
|
||||
unset, so side effects will take place.
|
||||
|
||||
kk. Fixed a bug in the SICGHLD child-reaping code so that it won't find
|
||||
jobs already marked as terminated if the OS reuses pids quickly enough.
|
||||
|
||||
ll. Fixed a bug that could cause a signal to not interrupt the `wait'
|
||||
builtin while it was waiting for a background process to terminate.
|
||||
|
||||
mm. A couple of changes to make it easier for multiple shells to share history
|
||||
files using `history -n', `history -r', and `history -w'.
|
||||
|
||||
nn. The `getopts' builtin always increments OPTIND to point to the next
|
||||
option to be handled when an option is returned, whether it's valid
|
||||
or not, as POSIX 1003.x-2001 requires.
|
||||
|
||||
oo. Changed some parts of the expansion code to avoid allocating and
|
||||
immediately freeing memory without using the results for anything.
|
||||
|
||||
pp. The shell now keeps track of $IFS internally, updating its internal map
|
||||
each time the variable is assigned a new value (or at local scope exit).
|
||||
This saves thousands of hash lookups for IFS, which, while individually
|
||||
cheap, add up.
|
||||
|
||||
qq. Rewrote the hash table code: searching and insertion are much faster now,
|
||||
and it uses a better string hashing function; augmented the function
|
||||
interface to simplify other parts of the code and remove duplicated code
|
||||
|
||||
rr. The shell now uses a simple, generic `object cache' for allocating and
|
||||
caching words and word lists, which were the major users of
|
||||
malloc/free.
|
||||
|
||||
ss. Fixed the assignment statement parsing code to allow whitespace and
|
||||
newlines in subscripts when performing array element assignment.
|
||||
|
||||
tt. The shell now issues many fewer calls to sigprocmask and other signal
|
||||
masking system calls.
|
||||
|
||||
uu. Fixed the `test' and conditional command file comparison operators to
|
||||
work right when one file has a non-positive timestamp and the other
|
||||
does not exist.
|
||||
|
||||
vv. Fixed some cases where the special characters '\001' and '\177' in the
|
||||
values of variables or positional parameters caused incorrect expansion
|
||||
results.
|
||||
|
||||
2. Changes to Readline
|
||||
|
||||
a. Fixed output of comment-begin character when listing variable values.
|
||||
|
||||
b. Added some default key bindings for common escape sequences produced by
|
||||
HOME and END keys.
|
||||
|
||||
c. Fixed the mark handling code to be more emacs-compatible.
|
||||
|
||||
d. A bug was fixed in the code that prints possible completions to keep it
|
||||
from printing empty strings in certain circumstances.
|
||||
|
||||
e. Change the key sequence printing code to print ESC as M\- if ESC is a
|
||||
meta-prefix character -- it's easier for users to understand than \e.
|
||||
|
||||
f. Fixed unstifle_history() to return values that match the documentation.
|
||||
|
||||
g. Fixed the event loop (rl_event_hook) to handle the case where the input
|
||||
file descriptor is invalidated.
|
||||
|
||||
h. Fixed the prompt display code to work better when the application has a
|
||||
custom redisplay function.
|
||||
|
||||
i. Changes to make reading and writing the history file a little faster, and
|
||||
to cope with huge history files without calling abort(3) from xmalloc.
|
||||
|
||||
j. The vi-mode `S' and `s' commands are now undone correctly.
|
||||
|
||||
3. New Features in Bash
|
||||
|
||||
a. If set, TMOUT is the default timeout for the `read' builtin.
|
||||
|
||||
b. `type' has two new options: `-f' suppresses shell function lookup, and
|
||||
`-P' forces a $PATH search.
|
||||
|
||||
c. New code to handle multibyte characters.
|
||||
|
||||
d. `select' was changed to be more ksh-compatible, in that the menu is
|
||||
reprinted each time through the loop only if REPLY is set to NULL.
|
||||
The previous behavior is available as a compile-time option.
|
||||
|
||||
e. `complete -d' and `complete -o dirnames' now force a slash to be
|
||||
appended to names which are symlinks to directories.
|
||||
|
||||
f. There is now a bindable edit-and-execute-command readline command,
|
||||
like the vi-mode `v' command, bound to C-xC-e in emacs mode.
|
||||
|
||||
g. Added support for ksh93-like [:word:] character class in pattern matching.
|
||||
|
||||
h. The $'...' quoting construct now expands \cX to Control-X.
|
||||
|
||||
i. A new \D{...} prompt expansion; passes the `...' to strftime and inserts
|
||||
the result into the expanded prompt.
|
||||
|
||||
j. The shell now performs arithmetic in the largest integer size the
|
||||
machine supports (intmax_t), instead of long.
|
||||
|
||||
k. If a numeric argument is supplied to one of the bash globbing completion
|
||||
functions, a `*' is appended to the word before expansion is attempted.
|
||||
|
||||
l. The bash globbing completion functions now allow completions to be listed
|
||||
with double tabs or if `show-all-if-ambiguous' is set.
|
||||
|
||||
m. New `-o nospace' option for `complete' and `compgen' builtins; suppresses
|
||||
readline's appending a space to the completed word.
|
||||
|
||||
n. New `here-string' redirection operator: <<< word.
|
||||
|
||||
o. When displaying variables, function attributes and definitions are shown
|
||||
separately, allowing them to be re-used as input (attempting to re-use
|
||||
the old output would result in syntax errors).
|
||||
|
||||
p. There is a new configuration option `--enable-mem-scramble', controls
|
||||
bash malloc behavior of writing garbage characters into memory at
|
||||
allocation and free time.
|
||||
|
||||
q. The `complete' and `compgen' builtins now have a new `-s/-A service'
|
||||
option to complete on names from /etc/services.
|
||||
|
||||
r. `read' has a new `-u fd' option to read from a specified file descriptor.
|
||||
|
||||
s. Fix the completion code so that expansion errors in a directory name
|
||||
don't cause a longjmp back to the command loop.
|
||||
|
||||
t. Fixed word completion inside command substitution to work a little more
|
||||
intuitively.
|
||||
|
||||
u. The `printf' %q format specifier now uses $'...' quoting to print the
|
||||
argument if it contains non-printing characters.
|
||||
|
||||
v. The `declare' and `typeset' builtins have a new `-t' option. When applied
|
||||
to functions, it causes the DEBUG trap to be inherited by the named
|
||||
function. Currently has no effect on variables.
|
||||
|
||||
w. The DEBUG trap is now run *before* simple commands, ((...)) commands,
|
||||
[[...]] conditional commands, and for ((...)) loops.
|
||||
|
||||
x. The expansion of $LINENO inside a shell function is only relative to the
|
||||
function start if the shell is interactive -- if the shell is running a
|
||||
script, $LINENO expands to the line number in the script. This is as
|
||||
POSIX-2001 requires.
|
||||
|
||||
y. The bash debugger in examples/bashdb has been modified to work with the
|
||||
new DEBUG trap semantics, the command set has been made more gdb-like,
|
||||
and the changes to $LINENO make debugging functions work better. Code
|
||||
from Gary Vaughan.
|
||||
|
||||
z. New [n]<&word- and [n]>&word- redirections from ksh93 -- move fds (dup
|
||||
and close).
|
||||
|
||||
aa. There is a new `-l' invocation option, equivalent to `--login'.
|
||||
|
||||
bb. The `hash' builtin has a new `-l' option to list contents in a reusable
|
||||
format, and a `-d' option to remove a name from the hash table.
|
||||
|
||||
4. New Features in Readline
|
||||
|
||||
a. Support for key `subsequences': allows, e.g., ESC and ESC-a to both
|
||||
be bound to readline functions. Now the arrow keys may be used in vi
|
||||
insert mode.
|
||||
|
||||
b. When listing completions, and the number of lines displayed is more than
|
||||
the screen length, readline uses an internal pager to display the results.
|
||||
This is controlled by the `page-completions' variable (default on).
|
||||
|
||||
c. New code to handle editing and displaying multibyte characters.
|
||||
|
||||
d. The behavior introduced in bash-2.05a of deciding whether or not to
|
||||
append a slash to a completed name that is a symlink to a directory has
|
||||
been made optional, controlled by the `mark-symlinked-directories'
|
||||
variable (default is the 2.05a behavior).
|
||||
|
||||
e. The `insert-comment' command now acts as a toggle if given a numeric
|
||||
argument: if the first characters on the line don't specify a
|
||||
comment, insert one; if they do, delete the comment text
|
||||
|
||||
f. New application-settable completion variable:
|
||||
rl_completion_mark_symlink_dirs, allows an application's completion
|
||||
function to temporarily override the user's preference for appending
|
||||
slashes to names which are symlinks to directories.
|
||||
|
||||
g. New function available to application completion functions:
|
||||
rl_completion_mode, to tell how the completion function was invoked
|
||||
and decide which argument to supply to rl_complete_internal (to list
|
||||
completions, etc.).
|
||||
|
||||
h. Readline now has an overwrite mode, toggled by the `overwrite-mode'
|
||||
bindable command, which could be bound to `Insert'.
|
||||
|
||||
i. New application-settable completion variable:
|
||||
rl_completion_suppress_append, inhibits appending of
|
||||
rl_completion_append_character to completed words.
|
||||
|
||||
j. New key bindings when reading an incremental search string: ^W yanks
|
||||
the currently-matched word out of the current line into the search
|
||||
string; ^Y yanks the rest of the current line into the search string,
|
||||
DEL or ^H deletes characters from the search string.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
This document details the changes between this version, bash-2.05a-release,
|
||||
and the previous version, bash-2.05a-rc1.
|
||||
|
||||
|
|
|
|||
9
COMPAT
9
COMPAT
|
|
@ -1,5 +1,5 @@
|
|||
This document details the incompatibilites between this version of bash,
|
||||
bash-2.05a, and the previous widely-available version, bash-1.14 (which
|
||||
bash-2.05b, and the previous widely-available version, bash-1.14 (which
|
||||
is still the `standard' version for many Linux distributions). These
|
||||
were discovered by users of bash-2.x, so this list is not comprehensive.
|
||||
Some of these incompatibilities occur between the current version and
|
||||
|
|
@ -64,7 +64,7 @@ versions 2.0 and above.
|
|||
|
||||
"\C-\\": self-insert
|
||||
|
||||
6. A number of people complained above having to use ESC to terminate an
|
||||
6. A number of people complained about having to use ESC to terminate an
|
||||
incremental search, and asked for an alternate mechanism. Bash-2.03
|
||||
uses the value of the settable readline variable `isearch-terminators'
|
||||
to decide which characters should terminate an incremental search. If
|
||||
|
|
@ -146,6 +146,11 @@ versions 2.0 and above.
|
|||
AaBb...Zz
|
||||
|
||||
so a range specification like [A-Z] will match every letter except `z'.
|
||||
Other locales collate like
|
||||
|
||||
aAbBcC...zZ
|
||||
|
||||
which means that [A-Z] matches every letter except `a'.
|
||||
|
||||
The portable way to specify upper case letters is [:upper:] instead of
|
||||
A-Z; lower case may be specified as [:lower:] instead of a-z.
|
||||
|
|
|
|||
3318
CWRU/changelog
3318
CWRU/changelog
File diff suppressed because it is too large
Load diff
|
|
@ -1,4 +1,23 @@
|
|||
#! /bin/sh
|
||||
#
|
||||
# bison -- just call yacc
|
||||
#
|
||||
|
||||
# Copyright (C) 1996-2002 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
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This 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 USA.
|
||||
|
||||
if [ "$1" = '-y' ]; then
|
||||
shift
|
||||
|
|
|
|||
|
|
@ -2,6 +2,24 @@
|
|||
* If necessary, link with lib/sh/libsh.a
|
||||
*/
|
||||
|
||||
/* Copyright (C) 1998-2002 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 2, 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; see the file COPYING. If not, write to the Free Software
|
||||
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,24 @@
|
|||
* the -E flag to LOCAL_LDFLAGS.
|
||||
*/
|
||||
|
||||
/* Copyright (C) 1998-2002 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 2, 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; see the file COPYING. If not, write to the Free Software
|
||||
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
|
||||
#if !defined (__HPUX10_DLFCN_H__)
|
||||
|
||||
#define __HPUX10_DLFCN_H__
|
||||
|
|
|
|||
|
|
@ -1,3 +1,23 @@
|
|||
/* open-files -- report files a process has open */
|
||||
|
||||
/* Copyright (C) 1989-2002 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 2, 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; see the file COPYING. If not, write to the Free Software
|
||||
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/file.h>
|
||||
|
|
@ -13,4 +33,3 @@ main()
|
|||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
main()
|
||||
{
|
||||
fprintf(stderr, "%d\n", getpid());
|
||||
exit(0);
|
||||
}
|
||||
|
|
@ -1,3 +1,23 @@
|
|||
/* sigs - print signal dispositions for a process */
|
||||
|
||||
/* Copyright (C) 1990-2002 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 2, 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; see the file COPYING. If not, write to the Free Software
|
||||
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,28 @@
|
|||
/*
|
||||
* sigstat - print out useful information about signal arguments
|
||||
*
|
||||
* Chet Ramey
|
||||
* chet@po.cwru.edu
|
||||
*/
|
||||
|
||||
/* Copyright (C) 1991-2002 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 2, 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; see the file COPYING. If not, write to the Free Software
|
||||
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
|
|
|
|||
5
INSTALL
5
INSTALL
|
|
@ -210,7 +210,7 @@ the Bash `configure' recognizes.
|
|||
`--with-installed-readline[=PREFIX]'
|
||||
Define this to make Bash link with a locally-installed version of
|
||||
Readline rather than the version in `lib/readline'. This works
|
||||
only with Readline 4.2 and later versions. If PREFIX is `yes' or
|
||||
only with Readline 4.3 and later versions. If PREFIX is `yes' or
|
||||
not supplied, `configure' uses the values of the make variables
|
||||
`includedir' and `libdir', which are subdirectories of `prefix' by
|
||||
default, to find the installed version of Readline if it is not in
|
||||
|
|
@ -236,7 +236,8 @@ and linked, rather than changing run-time features.
|
|||
Enable support for large files
|
||||
(http://www.sas.com/standards/large_file/x_open.20Mar96.html) if
|
||||
the operating system requires special compiler options to build
|
||||
programs which can access large files.
|
||||
programs which can access large files. This is enabled by
|
||||
default, if the operating system provides large file support.
|
||||
|
||||
`--enable-profiling'
|
||||
This builds a Bash binary that produces profiling information to be
|
||||
|
|
|
|||
62
MANIFEST
62
MANIFEST
|
|
@ -11,6 +11,7 @@ cross-build d
|
|||
doc d
|
||||
examples d
|
||||
examples/bashdb d
|
||||
examples/obashdb d
|
||||
examples/complete d
|
||||
examples/functions d
|
||||
examples/scripts d
|
||||
|
|
@ -44,7 +45,9 @@ INSTALL f
|
|||
MANIFEST f
|
||||
NEWS f
|
||||
NOTES f
|
||||
POSIX f
|
||||
README f
|
||||
RBASH f
|
||||
AUTHORS f
|
||||
Y2K f
|
||||
configure.in f
|
||||
|
|
@ -206,21 +209,27 @@ include/chartypes.h f
|
|||
include/filecntl.h f
|
||||
include/maxpath.h f
|
||||
include/memalloc.h f
|
||||
include/ocache.h f
|
||||
include/posixdir.h f
|
||||
include/posixjmp.h f
|
||||
include/posixstat.h f
|
||||
include/posixtime.h f
|
||||
include/posixwait.h f
|
||||
include/shmbutil.h f
|
||||
include/shtty.h f
|
||||
include/stdc.h f
|
||||
include/systimes.h f
|
||||
include/typemax.h f
|
||||
include/unionwait.h f
|
||||
lib/glob/Makefile.in f
|
||||
lib/glob/sm_loop.c f
|
||||
lib/glob/smatch.c f
|
||||
lib/glob/strmatch.c f
|
||||
lib/glob/strmatch.h f
|
||||
lib/glob/glob.c f
|
||||
lib/glob/glob.h f
|
||||
lib/glob/glob_loop.c f
|
||||
lib/glob/xmbsrtowcs.c f
|
||||
lib/glob/collsyms.h f
|
||||
lib/glob/doc/Makefile f
|
||||
lib/glob/doc/glob.texi f
|
||||
|
|
@ -231,11 +240,13 @@ lib/malloc/imalloc.h f
|
|||
lib/malloc/mstats.h f
|
||||
lib/malloc/shmalloc.h f
|
||||
lib/malloc/table.h f
|
||||
lib/malloc/watch.h f
|
||||
lib/malloc/alloca.c f
|
||||
lib/malloc/malloc.c f
|
||||
lib/malloc/stats.c f
|
||||
lib/malloc/table.c f
|
||||
lib/malloc/trace.c f
|
||||
lib/malloc/watch.c f
|
||||
lib/malloc/xmalloc.c f
|
||||
lib/malloc/xleaktrace f 755
|
||||
lib/malloc/stub.c f
|
||||
|
|
@ -269,10 +280,13 @@ lib/readline/bind.c f
|
|||
lib/readline/display.c f
|
||||
lib/readline/signals.c f
|
||||
lib/readline/kill.c f
|
||||
lib/readline/text.c f
|
||||
lib/readline/undo.c f
|
||||
lib/readline/macro.c f
|
||||
lib/readline/input.c f
|
||||
lib/readline/callback.c f
|
||||
lib/readline/mbutil.c f
|
||||
lib/readline/misc.c f
|
||||
lib/readline/nls.c f
|
||||
lib/readline/shell.c f
|
||||
lib/readline/savestring.c f
|
||||
|
|
@ -280,6 +294,7 @@ lib/readline/tilde.c f
|
|||
lib/readline/tilde.h f
|
||||
lib/readline/rldefs.h f
|
||||
lib/readline/rlconf.h f
|
||||
lib/readline/rlmbutil.h f
|
||||
lib/readline/rlshell.h f
|
||||
lib/readline/rltty.h f
|
||||
lib/readline/rltypedefs.h f
|
||||
|
|
@ -313,18 +328,23 @@ lib/readline/examples/manexamp.c f
|
|||
lib/readline/examples/histexamp.c f
|
||||
lib/readline/examples/rltest.c f
|
||||
lib/readline/examples/rl.c f
|
||||
lib/readline/examples/rlcat.c f
|
||||
lib/readline/examples/Inputrc f
|
||||
lib/sh/Makefile.in f
|
||||
lib/sh/clktck.c f
|
||||
lib/sh/clock.c f
|
||||
lib/sh/fmtullong.c f
|
||||
lib/sh/fmtulong.c f
|
||||
lib/sh/fmtumax.c f
|
||||
lib/sh/getcwd.c f
|
||||
lib/sh/getenv.c f
|
||||
lib/sh/inet_aton.c f
|
||||
lib/sh/itos.c f
|
||||
lib/sh/mailstat.c f
|
||||
lib/sh/makepath.c f
|
||||
lib/sh/memset.c f
|
||||
lib/sh/mktime.c f
|
||||
lib/sh/netconn.c f
|
||||
lib/sh/netopen.c f
|
||||
lib/sh/oslib.c f
|
||||
lib/sh/pathcanon.c f
|
||||
|
|
@ -337,6 +357,7 @@ lib/sh/snprintf.c f
|
|||
lib/sh/spell.c f
|
||||
lib/sh/strcasecmp.c f
|
||||
lib/sh/strerror.c f
|
||||
lib/sh/strftime.c f
|
||||
lib/sh/strindex.c f
|
||||
lib/sh/stringlist.c f
|
||||
lib/sh/stringvec.c f
|
||||
|
|
@ -353,6 +374,8 @@ lib/sh/times.c f
|
|||
lib/sh/timeval.c f
|
||||
lib/sh/tmpfile.c f
|
||||
lib/sh/vprint.c f
|
||||
lib/sh/xstrchr.c f
|
||||
lib/sh/zcatfd.c f
|
||||
lib/sh/zread.c f
|
||||
lib/sh/zwrite.c f
|
||||
lib/termcap/Makefile.in f
|
||||
|
|
@ -385,14 +408,12 @@ lib/tilde/tilde.h f
|
|||
lib/tilde/shell.c f
|
||||
CWRU/misc/open-files.c f
|
||||
CWRU/misc/sigs.c f
|
||||
CWRU/misc/pid.c f
|
||||
CWRU/misc/sigstat.c f
|
||||
CWRU/misc/bison f
|
||||
CWRU/misc/errlist.c f
|
||||
CWRU/misc/hpux10-dlfcn.h f
|
||||
CWRU/PLATFORMS f
|
||||
CWRU/README f
|
||||
CWRU/POSIX.NOTES f
|
||||
CWRU/changelog f
|
||||
CWRU/sh-redir-hack f
|
||||
CWRU/mh-folder-comp f
|
||||
|
|
@ -435,10 +456,13 @@ support/xenix-link.sh f 755
|
|||
support/shobj-conf f 755
|
||||
support/rlvers.sh f 755
|
||||
examples/bashdb/PERMISSION f
|
||||
examples/bashdb/README f
|
||||
examples/bashdb/bashdb f
|
||||
examples/bashdb/bashdb.fns f
|
||||
examples/bashdb/bashdb.pre f
|
||||
examples/bashdb/bashdb.el f
|
||||
examples/obashdb/PERMISSION f
|
||||
examples/obashdb/README f
|
||||
examples/obashdb/bashdb f
|
||||
examples/obashdb/bashdb.fns f
|
||||
examples/obashdb/bashdb.pre f
|
||||
examples/complete/complete-examples f
|
||||
examples/complete/complete.ianmac f
|
||||
examples/complete/complete2.ianmac f
|
||||
|
|
@ -504,6 +528,7 @@ examples/functions/inetaddr f
|
|||
examples/functions/inpath 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
|
||||
|
|
@ -547,6 +572,7 @@ 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
|
||||
|
|
@ -639,17 +665,15 @@ tests/glob1.sub f
|
|||
tests/glob.right f
|
||||
tests/heredoc.tests f
|
||||
tests/heredoc.right f
|
||||
tests/herestr.tests f
|
||||
tests/herestr.right f
|
||||
tests/histexp.tests f
|
||||
tests/histexp.right f
|
||||
tests/history.tests f
|
||||
tests/history.right f
|
||||
tests/history.list f
|
||||
tests/ifs-1.test f
|
||||
tests/ifs-2.test f
|
||||
tests/ifs-3.test f
|
||||
tests/ifs-1.right f
|
||||
tests/ifs-2.right f
|
||||
tests/ifs-3.right f
|
||||
tests/ifs.tests f
|
||||
tests/ifs.right f
|
||||
tests/input-line.sh f
|
||||
tests/input-line.sub f
|
||||
tests/input.right f
|
||||
|
|
@ -669,6 +693,12 @@ tests/new-exp3.sub f
|
|||
tests/new-exp.right f
|
||||
tests/nquote.tests f
|
||||
tests/nquote.right f
|
||||
tests/nquote1.tests f
|
||||
tests/nquote1.right f
|
||||
tests/nquote2.tests f
|
||||
tests/nquote2.right f
|
||||
tests/nquote3.tests f
|
||||
tests/nquote3.right f
|
||||
tests/posix2.tests f
|
||||
tests/posix2.right f
|
||||
tests/posixpat.tests f
|
||||
|
|
@ -684,6 +714,7 @@ tests/read.right f
|
|||
tests/read1.sub f
|
||||
tests/read2.sub f
|
||||
tests/read3.sub f
|
||||
tests/read4.sub f
|
||||
tests/redir.tests f
|
||||
tests/redir.right f
|
||||
tests/redir1.sub f
|
||||
|
|
@ -693,6 +724,7 @@ tests/redir3.in1 f
|
|||
tests/redir3.in2 f
|
||||
tests/redir4.sub f
|
||||
tests/redir4.in1 f
|
||||
tests/redir5.sub f
|
||||
tests/rhs-exp.tests f
|
||||
tests/rhs-exp.right f
|
||||
tests/rsh.tests f
|
||||
|
|
@ -718,15 +750,19 @@ tests/run-func f
|
|||
tests/run-getopts f
|
||||
tests/run-glob-test f
|
||||
tests/run-heredoc f
|
||||
tests/run-herestr f
|
||||
tests/run-histexpand f
|
||||
tests/run-history f
|
||||
tests/run-ifs-tests f
|
||||
tests/run-ifs f
|
||||
tests/run-input-test f
|
||||
tests/run-invert f
|
||||
tests/run-jobs f
|
||||
tests/run-more-exp f
|
||||
tests/run-new-exp f
|
||||
tests/run-nquote f
|
||||
tests/run-nquote1 f
|
||||
tests/run-nquote2 f
|
||||
tests/run-nquote3 f
|
||||
tests/run-posix2 f
|
||||
tests/run-posixpat f
|
||||
tests/run-precedence f
|
||||
|
|
@ -764,6 +800,7 @@ tests/type.right f
|
|||
tests/varenv.right f
|
||||
tests/varenv.sh f
|
||||
tests/varenv1.sub f
|
||||
tests/varenv2.sub f
|
||||
tests/version f
|
||||
tests/version.mini f
|
||||
tests/misc/dev-tcp.tests f
|
||||
|
|
@ -794,6 +831,7 @@ 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
|
||||
|
|
|
|||
111
Makefile.in
111
Makefile.in
|
|
@ -1,6 +1,6 @@
|
|||
# Makefile for bash-2.05a, version 2.128
|
||||
# Makefile for bash-2.05b, version 2.142
|
||||
#
|
||||
# Copyright (C) 1996 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1996-2002 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
|
||||
|
|
@ -27,6 +27,7 @@ bindir = @bindir@
|
|||
libdir = @libdir@
|
||||
infodir = @infodir@
|
||||
includedir = @includedir@
|
||||
datadir = @datadir@
|
||||
|
||||
mandir = @mandir@
|
||||
manpfx = man
|
||||
|
|
@ -59,6 +60,7 @@ RANLIB = @RANLIB@
|
|||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALLMODE= -m 0755
|
||||
INSTALLMODE2 = -m 0555
|
||||
|
|
@ -86,7 +88,7 @@ VERSOBJ = bashversion.$(OBJEXT)
|
|||
Program = bash$(EXEEXT)
|
||||
Version = @BASHVERS@
|
||||
PatchLevel = `$(BUILD_DIR)/$(VERSPROG) -p`
|
||||
RELSTATUS = release
|
||||
RELSTATUS = @RELSTATUS@
|
||||
|
||||
Machine = @host_cpu@
|
||||
OS = @host_os@
|
||||
|
|
@ -94,8 +96,8 @@ VENDOR = @host_vendor@
|
|||
MACHTYPE = @host@
|
||||
|
||||
# comment out for release
|
||||
#DEBUG = -DDEBUG
|
||||
#MALLOC_DEBUG = -DMALLOC_DEBUG
|
||||
DEBUG = @DEBUG@
|
||||
MALLOC_DEBUG = @MALLOC_DEBUG@
|
||||
|
||||
THIS_SH = $(BUILD_DIR)/$(Program)
|
||||
|
||||
|
|
@ -103,26 +105,30 @@ THIS_SH = $(BUILD_DIR)/$(Program)
|
|||
# with gprof, or nothing (the default).
|
||||
PROFILE_FLAGS= @PROFILE_FLAGS@
|
||||
|
||||
# The GNU coding standards don't recognize the possibility that
|
||||
# other information besides optimization and debugging might be
|
||||
# passed to cc. A different name should have been used.
|
||||
CFLAGS = @CFLAGS@
|
||||
CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CPPFLAGS_FOR_BUILD = @CPPFLAGS_FOR_BUILD@
|
||||
LOCAL_CFLAGS = @LOCAL_CFLAGS@ ${DEBUG}
|
||||
DEFS = @DEFS@
|
||||
LOCAL_DEFS = @LOCAL_DEFS@
|
||||
|
||||
LOCAL_LIBS = @LOCAL_LIBS@
|
||||
LIBS = $(BUILTINS_LIB) $(LIBRARIES) @LIBS@
|
||||
LDFLAGS = @LDFLAGS@ $(STATIC_LD) $(LOCAL_LDFLAGS) $(PROFILE_FLAGS) $(CFLAGS)
|
||||
STATIC_LD = @STATIC_LD@
|
||||
LOCAL_LDFLAGS = @LOCAL_LDFLAGS@
|
||||
|
||||
SYSTEM_FLAGS = -DPROGRAM='"$(Program)"' -DCONF_HOSTTYPE='"$(Machine)"' -DCONF_OSTYPE='"$(OS)"' -DCONF_MACHTYPE='"$(MACHTYPE)"' -DCONF_VENDOR='"$(VENDOR)"'
|
||||
|
||||
CCFLAGS_FOR_BUILD = $(PROFILE_FLAGS) $(SYSTEM_FLAGS) $(LOCAL_DEFS) \
|
||||
$(DEFS) $(LOCAL_CFLAGS) $(CPPFLAGS) $(INCLUDES)
|
||||
BASE_CCFLAGS = $(PROFILE_FLAGS) $(SYSTEM_FLAGS) $(LOCAL_DEFS) \
|
||||
$(DEFS) $(LOCAL_CFLAGS) $(INCLUDES)
|
||||
|
||||
CCFLAGS = $(CCFLAGS_FOR_BUILD) $(CFLAGS)
|
||||
CCFLAGS = $(BASE_CCFLAGS) $(CPPFLAGS) $(CFLAGS)
|
||||
|
||||
CCFLAGS_FOR_BUILD = $(BASE_CCFLAGS) $(CPPFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD)
|
||||
|
||||
LDFLAGS = @LDFLAGS@ $(STATIC_LD) $(LOCAL_LDFLAGS) $(PROFILE_FLAGS) $(CFLAGS)
|
||||
LDFLAGS_FOR_BUILD = $(LDFLAGS)
|
||||
|
||||
INCLUDES = -I. @RL_INCLUDE@ -I$(srcdir) -I$(BASHINCDIR) -I$(LIBSRC)
|
||||
|
||||
|
|
@ -130,7 +136,7 @@ GCC_LINT_FLAGS = -Wall -Wshadow -Wpointer-arith -Wcast-qual \
|
|||
-Wcast-align -Wstrict-prototypes -Wconversion \
|
||||
-Wmissing-prototypes -Wtraditional -Wredundant-decls -pedantic
|
||||
|
||||
GCC_LINT_CFLAGS = $(CCFLAGS_FOR_BUILD) $(GCC_LINT_FLAGS)
|
||||
GCC_LINT_CFLAGS = $(BASE_CCFLAGS) $(CPPFLAGS) $(GCC_LINT_FLAGS)
|
||||
|
||||
#
|
||||
# Support libraries
|
||||
|
|
@ -169,7 +175,11 @@ SHLIB_SOURCE = ${SH_LIBSRC}/clktck.c ${SH_LIBSRC}/getcwd.c \
|
|||
${SH_LIBSRC}/snprintf.c ${SH_LIBSRC}/mailstat.c \
|
||||
${SH_LIBSRC}/fmtulong.c ${SH_LIBSRC}/fmtullong.c \
|
||||
${SH_LIBSRC}/strtoll.c ${SH_LIBSRC}/strtoull.c \
|
||||
${SH_LIBSRC}/strtoimax.c ${SH_LIBSRC}/strtoumax.c
|
||||
${SH_LIBSRC}/strtoimax.c ${SH_LIBSRC}/strtoumax.c \
|
||||
${SH_LIBSRC}/fmtumax.c ${SH_LIBSRC}/netconn.c \
|
||||
${SH_LIBSRC}/mktime.c ${SH_LIBSRC}/strftime.c \
|
||||
${SH_LIBSRC}/memset.c ${SH_LIBSRC}/xstrchr.c \
|
||||
${SH_LIBSRC}/zcatfd.c
|
||||
|
||||
SHLIB_LIB = -lsh
|
||||
SHLIB_LIBNAME = libsh.a
|
||||
|
|
@ -206,12 +216,12 @@ READLINE_SOURCE = $(RL_LIBSRC)/rldefs.h $(RL_LIBSRC)/rlconf.h \
|
|||
$(RL_LIBSRC)/rltty.c $(RL_LIBSRC)/complete.c \
|
||||
$(RL_LIBSRC)/bind.c $(RL_LIBSRC)/isearch.c \
|
||||
$(RL_LIBSRC)/display.c $(RL_LIBSRC)/signals.c \
|
||||
$(RL_LIBSRC)/util.c $(RL_LIBSRC)/kill.c \
|
||||
$(RL_LIBSRC)/util.c $(RL_LIBSRC)/kill.c $(RL_LIBSRC)/text.c \
|
||||
$(RL_LIBSRC)/undo.c $(RL_LIBSRC)/macro.c \
|
||||
$(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)/compat.c \
|
||||
$(RL_LIBSRC)/misc.c $(RL_LIBSRC)/compat.c \
|
||||
$(RL_LIBSRC)/histexpand.c $(RL_LIBSRC)/history.c \
|
||||
$(RL_LIBSRC)/histsearch.c $(RL_LIBSRC)/histfile.c
|
||||
|
||||
|
|
@ -271,8 +281,11 @@ GLOB_LDFLAGS = -L$(GLOB_LIBDIR)
|
|||
GLOB_DEP = $(GLOB_LIBRARY)
|
||||
|
||||
GLOB_SOURCE = $(GLOB_LIBSRC)/glob.c $(GLOB_LIBSRC)/strmatch.c \
|
||||
$(GLOB_LIBSRC)/smatch.c $(GLOB_LIBSRC)/xmbsrtowcs.c \
|
||||
$(GLOB_LIBSRC)/glob_loop.c $(GLOB_LIBSRC)/sm_loop.c \
|
||||
$(GLOB_LIBSRC)/glob.h $(GLOB_LIBSRC)/strmatch.h
|
||||
GLOB_OBJ = $(GLOB_LIBDIR)/glob.o $(GLOB_LIBDIR)/strmatch.o
|
||||
GLOB_OBJ = $(GLOB_LIBDIR)/glob.o $(GLOB_LIBDIR)/strmatch.o \
|
||||
$(GLOB_LIBDIR)/smatch.o $(GLOB_LIBDIR)/xmbsrtowcs.o
|
||||
|
||||
# The source, object and documentation for the GNU Tilde library.
|
||||
TILDE_LIBSRC = $(LIBSRC)/tilde
|
||||
|
|
@ -299,7 +312,7 @@ ALLOC_ABSSRC = ${topdir}/$(ALLOC_LIBDIR)
|
|||
|
||||
MALLOC_SRC = @MALLOC_SRC@
|
||||
MALLOC_OTHERSRC = ${ALLOC_LIBSRC}/trace.c ${ALLOC_LIBSRC}/stats.c \
|
||||
${ALLOC_LIBSRC}/table.c
|
||||
${ALLOC_LIBSRC}/table.c ${ALLOC_LIBSRC}/watch.c
|
||||
MALLOC_SOURCE = ${ALLOC_LIBSRC}/${MALLOC_SRC} ${MALLOC_OTHERSRC}
|
||||
MALLOC_CFLAGS = -DRCHECK -Dbotch=programming_error ${MALLOC_DEBUG}
|
||||
|
||||
|
|
@ -309,7 +322,8 @@ MALLOC_LDFLAGS = @MALLOC_LDFLAGS@
|
|||
MALLOC_DEP = @MALLOC_DEP@
|
||||
|
||||
ALLOC_HEADERS = $(ALLOC_LIBSRC)/getpagesize.h $(ALLOC_LIBSRC)/shmalloc.h \
|
||||
$(ALLOC_LIBSRC)/imalloc.h $(ALLOC_LIBSRC)/mstats.h
|
||||
$(ALLOC_LIBSRC)/imalloc.h $(ALLOC_LIBSRC)/mstats.h \
|
||||
$(ALLOC_LIBSRC)/table.h $(ALLOC_LIBSRC)/watch.h
|
||||
|
||||
$(MALLOC_LIBRARY): ${MALLOC_SOURCE} ${ALLOC_HEADERS} config.h
|
||||
@(cd $(ALLOC_LIBDIR) && \
|
||||
|
|
@ -323,7 +337,8 @@ BASHINCFILES = $(BASHINCDIR)/posixstat.h $(BASHINCDIR)/ansi_stdlib.h \
|
|||
$(BASHINCDIR)/posixjmp.h $(BASHINCDIR)/posixwait.h \
|
||||
$(BASHINCDIR)/posixtime.h $(BASHINCDIR)/systimes.h \
|
||||
$(BASHINCDIR)/unionwait.h $(BASHINCDIR)/maxpath.h \
|
||||
$(BASHINCDIR)/shtty.h $(BASHINCDIR)/typemax.h
|
||||
$(BASHINCDIR)/shtty.h $(BASHINCDIR)/typemax.h \
|
||||
$(BASHINCDIR)/ocache.h
|
||||
|
||||
LIBRARIES = $(SHLIB_LIB) $(READLINE_LIB) $(HISTORY_LIB) $(TERMCAP_LIB) $(GLOB_LIB) \
|
||||
$(TILDE_LIB) $(MALLOC_LIB) $(LOCAL_LIBS)
|
||||
|
|
@ -436,7 +451,8 @@ TESTS_SUPPORT = recho$(EXEEXT) zecho$(EXEEXT) printenv$(EXEEXT)
|
|||
CREATED_SUPPORT = signames.h recho$(EXEEXT) zecho$(EXEEXT) printenv$(EXEEXT) \
|
||||
tests/recho$(EXEEXT) tests/zecho$(EXEEXT) \
|
||||
tests/printenv$(EXEEXT) mksignames$(EXEEXT) lsignames.h \
|
||||
mksyntax${EXEEXT} syntax.c $(VERSPROG) $(VERSOBJ)
|
||||
mksyntax${EXEEXT} syntax.c $(VERSPROG) $(VERSOBJ) \
|
||||
buildversion.o
|
||||
CREATED_CONFIGURE = config.h config.cache config.status config.log \
|
||||
stamp-h
|
||||
CREATED_MAKEFILES = Makefile builtins/Makefile doc/Makefile \
|
||||
|
|
@ -486,8 +502,11 @@ version.h: $(SOURCES) config.h Makefile
|
|||
$(SHELL) $(SUPPORT_SRC)mkversion.sh -b -S ${topdir} -s $(RELSTATUS) -d $(Version) -o newversion.h \
|
||||
&& mv newversion.h version.h
|
||||
|
||||
bashversion$(EXEEXT): patchlevel.h conftypes.h version.h version.o $(SUPPORT_SRC)bashversion.c
|
||||
$(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) $(CPPFLAGS) -o $@ $(SUPPORT_SRC)bashversion.c version.o
|
||||
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
|
||||
|
||||
buildversion.o: version.h conftypes.h patchlevel.h $(srcdir)/version.c
|
||||
$(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) -c -o $@ $(srcdir)/version.c
|
||||
|
||||
# old rules
|
||||
GRAM_H = parser-built
|
||||
|
|
@ -540,10 +559,10 @@ $(SHLIB_LIBRARY): config.h ${SHLIB_SOURCE}
|
|||
$(MAKE) $(MFLAGS) DEBUG=${DEBUG} ${SHLIB_LIBNAME}) || exit 1
|
||||
|
||||
mksignames$(EXEEXT): $(SUPPORT_SRC)mksignames.c
|
||||
$(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) $(CPPFLAGS) -o $@ $(SUPPORT_SRC)mksignames.c
|
||||
$(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) -o $@ $(SUPPORT_SRC)mksignames.c
|
||||
|
||||
mksyntax$(EXEEXT): ${srcdir}/mksyntax.c config.h syntax.h ${BASHINCDIR}/chartypes.h
|
||||
${CC_FOR_BUILD} ${CCFLAGS_FOR_BUILD} ${CPPFLAGS} -o $@ ${srcdir}/mksyntax.c
|
||||
${CC_FOR_BUILD} ${CCFLAGS_FOR_BUILD} -o $@ ${srcdir}/mksyntax.c
|
||||
|
||||
# make a list of signals for the local system -- this is done when we're
|
||||
# *not* cross-compiling
|
||||
|
|
@ -628,11 +647,12 @@ installdirs:
|
|||
|
||||
install: .made installdirs
|
||||
$(INSTALL_PROGRAM) $(INSTALLMODE) $(Program) $(DESTDIR)$(bindir)/$(Program)
|
||||
$(INSTALL_PROGRAM) $(INSTALLMODE2) bashbug $(DESTDIR)$(bindir)/bashbug
|
||||
$(INSTALL_SCRIPT) $(INSTALLMODE2) bashbug $(DESTDIR)$(bindir)/bashbug
|
||||
-( cd $(DOCDIR) ; $(MAKE) $(MFLAGS) \
|
||||
man1dir=$(man1dir) man1ext=$(man1ext) \
|
||||
man3dir=$(man3dir) man3ext=$(man3ext) \
|
||||
infodir=$(infodir) htmldir=$(htmldir) DESTDIR=$(DESTDIR) $@ )
|
||||
-( cd $(DEFDIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
|
||||
|
||||
install-strip:
|
||||
$(MAKE) $(MFLAGS) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' \
|
||||
|
|
@ -646,7 +666,8 @@ uninstall: .made
|
|||
man3dir=$(man3dir) man3ext=$(man3ext) \
|
||||
infodir=$(infodir) htmldir=$(htmldir) DESTDIR=$(DESTDIR) $@ )
|
||||
|
||||
.PHONY: basic-clean clean realclean maintainer-clean distclean mostlyclean
|
||||
.PHONY: basic-clean clean realclean maintainer-clean distclean mostlyclean maybe-clean
|
||||
|
||||
basic-clean:
|
||||
$(RM) $(OBJECTS) $(Program) bashbug
|
||||
$(RM) .build .made version.h
|
||||
|
|
@ -654,6 +675,7 @@ basic-clean:
|
|||
clean: basic-clean
|
||||
( cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ )
|
||||
( cd builtins && $(MAKE) $(MFLAGS) $@ )
|
||||
-( cd $(SDIR) && $(MAKE) $(MFLAGS) $@ )
|
||||
-(cd $(RL_LIBDIR) && $(MAKE) $(MFLAGS) $@)
|
||||
-(cd $(HIST_LIBDIR) && test -f Makefile && $(MAKE) $(MFLAGS) $@)
|
||||
-(cd $(TERM_LIBDIR) && $(MAKE) $(MFLAGS) $@)
|
||||
|
|
@ -666,6 +688,7 @@ clean: basic-clean
|
|||
mostlyclean: basic-clean
|
||||
( cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ )
|
||||
( cd builtins && $(MAKE) $(MFLAGS) $@ )
|
||||
-( cd $(SDIR) && $(MAKE) $(MFLAGS) $@ )
|
||||
-(cd $(RL_LIBDIR) && $(MAKE) $(MFLAGS) $@)
|
||||
-(cd $(HIST_LIBDIR) && test -f Makefile && $(MAKE) $(MFLAGS) $@)
|
||||
-(cd $(TERM_LIBDIR) && $(MAKE) $(MFLAGS) $@)
|
||||
|
|
@ -674,9 +697,10 @@ mostlyclean: basic-clean
|
|||
-(cd $(ALLOC_LIBDIR) && $(MAKE) $(MFLAGS) $@)
|
||||
-(cd $(SH_LIBDIR) && $(MAKE) $(MFLAGS) $@)
|
||||
|
||||
distclean: basic-clean
|
||||
distclean: basic-clean maybe-clean
|
||||
( cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ )
|
||||
( cd builtins && $(MAKE) $(MFLAGS) $@ )
|
||||
-( cd $(SDIR) && $(MAKE) $(MFLAGS) $@ )
|
||||
-(cd $(RL_LIBDIR) && $(MAKE) $(MFLAGS) $@)
|
||||
-(cd $(HIST_LIBDIR) && test -f Makefile && $(MAKE) $(MFLAGS) $@)
|
||||
-(cd $(TERM_LIBDIR) && $(MAKE) $(MFLAGS) $@)
|
||||
|
|
@ -693,6 +717,7 @@ maintainer-clean: basic-clean
|
|||
$(RM) y.tab.c y.tab.h parser-built tags TAGS
|
||||
( cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ )
|
||||
( cd builtins && $(MAKE) $(MFLAGS) $@ )
|
||||
( cd $(SDIR) && $(MAKE) $(MFLAGS) $@ )
|
||||
-(cd $(RL_LIBDIR) && $(MAKE) $(MFLAGS) $@)
|
||||
-(cd $(HIST_LIBDIR) && test -f Makefile && $(MAKE) $(MFLAGS) $@)
|
||||
-(cd $(TERM_LIBDIR) && $(MAKE) $(MFLAGS) $@)
|
||||
|
|
@ -703,14 +728,19 @@ maintainer-clean: basic-clean
|
|||
$(RM) $(CREATED_CONFIGURE) $(CREATED_MAKEFILES)
|
||||
$(RM) $(CREATED_SUPPORT) Makefile
|
||||
|
||||
maybe-clean:
|
||||
-if test "X$(topdir)" != "X$(BUILD_DIR)" ; then \
|
||||
$(RM) parser-built y.tab.c y.tab.h ; \
|
||||
fi
|
||||
|
||||
recho$(EXEEXT): $(SUPPORT_SRC)recho.c
|
||||
@$(CC) $(CCFLAGS) -o $@ $(SUPPORT_SRC)recho.c
|
||||
@$(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) -o $@ $(SUPPORT_SRC)recho.c
|
||||
|
||||
zecho$(EXEEXT): $(SUPPORT_SRC)zecho.c
|
||||
@$(CC) $(CCFLAGS) -o $@ $(SUPPORT_SRC)zecho.c
|
||||
@$(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) -o $@ $(SUPPORT_SRC)zecho.c
|
||||
|
||||
printenv$(EXEEXT): $(SUPPORT_SRC)printenv.c
|
||||
@$(CC) $(CCFLAGS) -o $@ $(SUPPORT_SRC)printenv.c
|
||||
@$(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) -o $@ $(SUPPORT_SRC)printenv.c
|
||||
|
||||
test tests check: force $(Program) $(TESTS_SUPPORT)
|
||||
@-test -d tests || mkdir tests
|
||||
|
|
@ -766,6 +796,7 @@ dispose_cmd.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h comm
|
|||
dispose_cmd.o: error.h general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
|
||||
dispose_cmd.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
|
||||
dispose_cmd.o: make_cmd.h subst.h sig.h pathnames.h externs.h
|
||||
dispose_cmd.o: ${BASHINCDIR}/ocache.h
|
||||
error.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h flags.h ${BASHINCDIR}/stdc.h error.h
|
||||
error.o: command.h general.h xmalloc.h externs.h input.h bashhist.h
|
||||
eval.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h trap.h flags.h ${DEFSRC}/common.h
|
||||
|
|
@ -810,7 +841,7 @@ general.o: ${BASHINCDIR}/chartypes.h
|
|||
hashcmd.o: config.h ${BASHINCDIR}/posixstat.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
|
||||
hashcmd.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
|
||||
hashcmd.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashcmd.h
|
||||
hashcmd.o: execute_cmd.h findcmd.h ${BASHINCDIR}/stdc.h
|
||||
hashcmd.o: execute_cmd.h findcmd.h ${BASHINCDIR}/stdc.h hashlib.h
|
||||
hashlib.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
|
||||
hashlib.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
|
||||
hashlib.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
|
||||
|
|
@ -838,7 +869,8 @@ mailcheck.o: execute_cmd.h mailcheck.h
|
|||
make_cmd.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h bashansi.h
|
||||
make_cmd.o: command.h ${BASHINCDIR}/stdc.h general.h xmalloc.h error.h flags.h make_cmd.h
|
||||
make_cmd.o: variables.h arrayfunc.h conftypes.h array.h hashlib.h subst.h input.h externs.h
|
||||
make_cmd.o: jobs.h quit.h siglist.h syntax.h
|
||||
make_cmd.o: jobs.h quit.h siglist.h syntax.h dispose_cmd.h
|
||||
make_cmd.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/ocache.h
|
||||
y.tab.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/memalloc.h
|
||||
y.tab.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
|
||||
y.tab.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
|
||||
|
|
@ -853,6 +885,7 @@ pathexp.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
|
|||
pathexp.o: make_cmd.h subst.h sig.h pathnames.h externs.h
|
||||
pathexp.o: pathexp.h flags.h
|
||||
pathexp.o: $(GLOB_LIBSRC)/glob.h $(GLOB_LIBSRC)/strmatch.h
|
||||
pathexp.o: ${BASHINCDIR}/shmbutil.h
|
||||
print_cmd.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
|
||||
print_cmd.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
|
||||
print_cmd.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
|
||||
|
|
@ -894,6 +927,7 @@ subst.o: flags.h jobs.h siglist.h execute_cmd.h ${BASHINCDIR}/filecntl.h trap.h
|
|||
subst.o: mailcheck.h input.h $(DEFSRC)/getopt.h $(DEFSRC)/common.h
|
||||
subst.o: bashline.h bashhist.h ${GLOB_LIBSRC}/strmatch.h
|
||||
subst.o: ${BASHINCDIR}/chartypes.h
|
||||
subst.o: ${BASHINCDIR}/shmbutil.h
|
||||
test.o: bashtypes.h ${BASHINCDIR}/posixstat.h ${BASHINCDIR}/filecntl.h
|
||||
test.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
|
||||
test.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
|
||||
|
|
@ -949,11 +983,13 @@ arrayfunc.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h
|
|||
arrayfunc.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
|
||||
arrayfunc.o: make_cmd.h subst.h sig.h pathnames.h externs.h
|
||||
arrayfunc.o: $(DEFSRC)/common.h
|
||||
arrayfunc.o: ${BASHINCDIR}/shmbutil.h
|
||||
braces.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
|
||||
braces.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
|
||||
braces.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
|
||||
braces.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
|
||||
braces.o: make_cmd.h subst.h sig.h pathnames.h externs.h
|
||||
braces.o: ${BASHINCDIR}/shmbutil.h
|
||||
alias.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h command.h ${BASHINCDIR}/stdc.h
|
||||
alias.o: general.h xmalloc.h bashtypes.h externs.h alias.h
|
||||
alias.o: pcomplete.h
|
||||
|
|
@ -988,7 +1024,7 @@ bashline.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
|
|||
bashline.o: make_cmd.h subst.h sig.h pathnames.h externs.h
|
||||
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
|
||||
bashline.o: pcomplete.h ${BASHINCDIR}/chartypes.h input.h
|
||||
bracecomp.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
|
||||
bracecomp.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
|
||||
bracecomp.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
|
||||
|
|
@ -1074,7 +1110,7 @@ builtins/break.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h
|
|||
builtins/break.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
|
||||
builtins/break.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
|
||||
builtins/builtin.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
|
||||
builtins/builtin.o: quit.h $(DEFSRC)/common.h
|
||||
builtins/builtin.o: quit.h $(DEFSRC)/common.h $(DEFSRC)/bashgetopt.h
|
||||
builtins/builtin.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
|
||||
builtins/builtin.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
|
||||
builtins/cd.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
|
||||
|
|
@ -1088,6 +1124,7 @@ builtins/command.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/std
|
|||
builtins/declare.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
|
||||
builtins/declare.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
|
||||
builtins/declare.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
|
||||
builtins/declare.o: $(DEFSRC)/bashgetopt.h
|
||||
builtins/echo.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
|
||||
builtins/echo.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
|
||||
builtins/echo.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
|
||||
|
|
@ -1114,7 +1151,7 @@ builtins/fc.o: flags.h unwind_prot.h variables.h arrayfunc.h conftypes.h shell.h
|
|||
builtins/fc.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h quit.h
|
||||
builtins/fc.o: $(DEFSRC)/bashgetopt.h bashhist.h
|
||||
builtins/fc.o: ${BASHINCDIR}/chartypes.h
|
||||
builtins/fg_bg.o: bashtypes.h
|
||||
builtins/fg_bg.o: bashtypes.h $(DEFSRC)/bashgetopt.h
|
||||
builtins/fg_bg.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
|
||||
builtins/fg_bg.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
|
||||
builtins/fg_bg.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
|
||||
|
|
@ -1180,7 +1217,7 @@ builtins/shopt.o: $(DEFSRC)/common.h $(DEFSRC)/bashgetopt.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
|
||||
builtins/source.o: findcmd.h
|
||||
builtins/source.o: findcmd.h $(DEFSRC)/bashgetopt.h
|
||||
builtins/suspend.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
|
||||
builtins/suspend.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
|
||||
builtins/suspend.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
|
||||
|
|
|
|||
147
NEWS
147
NEWS
|
|
@ -1,3 +1,150 @@
|
|||
This is a terse description of the new features added to bash-2.05b since
|
||||
the release of bash-2.05a. As always, the manual page (doc/bash.1) is
|
||||
the place to look for complete descriptions.
|
||||
|
||||
1. New Features in Bash
|
||||
|
||||
a. If set, TMOUT is the default timeout for the `read' builtin.
|
||||
|
||||
b. `type' has two new options: `-f' suppresses shell function lookup, and
|
||||
`-P' forces a $PATH search.
|
||||
|
||||
c. New code to handle multibyte characters.
|
||||
|
||||
d. `select' was changed to be more ksh-compatible, in that the menu is
|
||||
reprinted each time through the loop only if REPLY is set to NULL.
|
||||
The previous behavior is available as a compile-time option.
|
||||
|
||||
e. `complete -d' and `complete -o dirnames' now force a slash to be
|
||||
appended to names which are symlinks to directories.
|
||||
|
||||
f. There is now a bindable edit-and-execute-command readline command,
|
||||
like the vi-mode `v' command, bound to C-xC-e in emacs mode.
|
||||
|
||||
g. Added support for ksh93-like [:word:] character class in pattern matching.
|
||||
|
||||
h. The $'...' quoting construct now expands \cX to Control-X.
|
||||
|
||||
i. A new \D{...} prompt expansion; passes the `...' to strftime and inserts
|
||||
the result into the expanded prompt.
|
||||
|
||||
j. The shell now performs arithmetic in the largest integer size the
|
||||
machine supports (intmax_t), instead of long.
|
||||
|
||||
k. If a numeric argument is supplied to one of the bash globbing completion
|
||||
functions, a `*' is appended to the word before expansion is attempted.
|
||||
|
||||
l. The bash globbing completion functions now allow completions to be listed
|
||||
with double tabs or if `show-all-if-ambiguous' is set.
|
||||
|
||||
m. New `-o nospace' option for `complete' and `compgen' builtins; suppresses
|
||||
readline's appending a space to the completed word.
|
||||
|
||||
n. New `here-string' redirection operator: <<< word.
|
||||
|
||||
o. When displaying variables, function attributes and definitions are shown
|
||||
separately, allowing them to be re-used as input (attempting to re-use
|
||||
the old output would result in syntax errors).
|
||||
|
||||
p. There is a new configuration option `--enable-mem-scramble', controls
|
||||
bash malloc behavior of writing garbage characters into memory at
|
||||
allocation and free time.
|
||||
|
||||
q. The `complete' and `compgen' builtins now have a new `-s/-A service'
|
||||
option to complete on names from /etc/services.
|
||||
|
||||
r. `read' has a new `-u fd' option to read from a specified file descriptor.
|
||||
|
||||
s. Fix the completion code so that expansion errors in a directory name
|
||||
don't cause a longjmp back to the command loop.
|
||||
|
||||
t. Fixed word completion inside command substitution to work a little more
|
||||
intuitively.
|
||||
|
||||
u. The `printf' %q format specifier now uses $'...' quoting to print the
|
||||
argument if it contains non-printing characters.
|
||||
|
||||
v. The `declare' and `typeset' builtins have a new `-t' option. When applied
|
||||
to functions, it causes the DEBUG trap to be inherited by the named
|
||||
function. Currently has no effect on variables.
|
||||
|
||||
w. The DEBUG trap is now run *before* simple commands, ((...)) commands,
|
||||
[[...]] conditional commands, and for ((...)) loops.
|
||||
|
||||
x. The expansion of $LINENO inside a shell function is only relative to the
|
||||
function start if the shell is interactive -- if the shell is running a
|
||||
script, $LINENO expands to the line number in the script. This is as
|
||||
POSIX-2001 requires.
|
||||
|
||||
y. The bash debugger in examples/bashdb has been modified to work with the
|
||||
new DEBUG trap semantics, the command set has been made more gdb-like,
|
||||
and the changes to $LINENO make debugging functions work better. Code
|
||||
from Gary Vaughan.
|
||||
|
||||
z. New [n]<&word- and [n]>&word- redirections from ksh93 -- move fds (dup
|
||||
and close).
|
||||
|
||||
aa. There is a new `-l' invocation option, equivalent to `--login'.
|
||||
|
||||
bb. The `hash' builtin has a new `-l' option to list contents in a reusable
|
||||
format, and a `-d' option to remove a name from the hash table.
|
||||
|
||||
cc. There is now support for placing the long help text into separate files
|
||||
installed into ${datadir}/bash. Not enabled by default; can be turned
|
||||
on with `--enable-separate-helpfiles' option to configure.
|
||||
|
||||
dd. All builtins that take operands accept a `--' pseudo-option, except
|
||||
`echo'.
|
||||
|
||||
ee. The `echo' builtin now accepts \0xxx (zero to three octal digits following
|
||||
the `0') in addition to \xxx (one to three octal digits) for SUSv3/XPG6/
|
||||
POSIX.1-2001 compliance.
|
||||
|
||||
|
||||
2. New Features in Readline
|
||||
|
||||
a. Support for key `subsequences': allows, e.g., ESC and ESC-a to both
|
||||
be bound to readline functions. Now the arrow keys may be used in vi
|
||||
insert mode.
|
||||
|
||||
b. When listing completions, and the number of lines displayed is more than
|
||||
the screen length, readline uses an internal pager to display the results.
|
||||
This is controlled by the `page-completions' variable (default on).
|
||||
|
||||
c. New code to handle editing and displaying multibyte characters.
|
||||
|
||||
d. The behavior introduced in bash-2.05a of deciding whether or not to
|
||||
append a slash to a completed name that is a symlink to a directory has
|
||||
been made optional, controlled by the `mark-symlinked-directories'
|
||||
variable (default is the 2.05a behavior).
|
||||
|
||||
e. The `insert-comment' command now acts as a toggle if given a numeric
|
||||
argument: if the first characters on the line don't specify a
|
||||
comment, insert one; if they do, delete the comment text
|
||||
|
||||
f. New application-settable completion variable:
|
||||
rl_completion_mark_symlink_dirs, allows an application's completion
|
||||
function to temporarily override the user's preference for appending
|
||||
slashes to names which are symlinks to directories.
|
||||
|
||||
g. New function available to application completion functions:
|
||||
rl_completion_mode, to tell how the completion function was invoked
|
||||
and decide which argument to supply to rl_complete_internal (to list
|
||||
completions, etc.).
|
||||
|
||||
h. Readline now has an overwrite mode, toggled by the `overwrite-mode'
|
||||
bindable command, which could be bound to `Insert'.
|
||||
|
||||
i. New application-settable completion variable:
|
||||
rl_completion_suppress_append, inhibits appending of
|
||||
rl_completion_append_character to completed words.
|
||||
|
||||
j. New key bindings when reading an incremental search string: ^W yanks
|
||||
the currently-matched word out of the current line into the search
|
||||
string; ^Y yanks the rest of the current line into the search string,
|
||||
DEL or ^H deletes characters from the search string.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
This is a terse description of the new features added to bash-2.05a since
|
||||
the release of bash-2.05. As always, the manual page (doc/bash.1) is
|
||||
the place to look for complete descriptions.
|
||||
|
|
|
|||
10
NOTES
10
NOTES
|
|
@ -30,11 +30,6 @@ Platform-Specific Configuration and Operation Notes
|
|||
leak caused by using the bash malloc because closedir(3) needs to read
|
||||
freed memory to find the file descriptor to close
|
||||
|
||||
If you are using GNU libc, especially on a linux system
|
||||
|
||||
(Configuring --without-gnu-malloc will still result in lib/malloc/libmalloc.a
|
||||
being built and linked against, but there is only a stub file in the archive.)
|
||||
|
||||
2. Configure using shlicc2 on BSD/OS 2.1 and BSD/OS 3.x to use loadable
|
||||
builtins
|
||||
|
||||
|
|
@ -234,7 +229,7 @@ being built and linked against, but there is only a stub file in the archive.)
|
|||
|
||||
If you want to completely remove any dependence on /usr, perhaps
|
||||
to put a copy of bash in /sbin and have it available when /usr is
|
||||
not mounted, force the build process to use the shared ld.so library
|
||||
not mounted, force the build process to use the shared dl.so library
|
||||
in /etc/lib.
|
||||
|
||||
For gcc, this would be something like
|
||||
|
|
@ -326,3 +321,6 @@ being built and linked against, but there is only a stub file in the archive.)
|
|||
want it).
|
||||
|
||||
5. make; make install; enjoy
|
||||
|
||||
15. Configure with `CC=xlc' if you don't have gcc on AIX 4.2 and later
|
||||
versions. `xlc' running in `cc' mode has trouble compiling error.c.
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@ Starting Bash with the `--posix' command-line option or executing `set
|
|||
to the POSIX 1003.2 standard by changing the behavior to match that
|
||||
specified by POSIX in areas where the Bash default differs.
|
||||
|
||||
When invoked as `sh', Bash enters POSIX mode after reading the startup
|
||||
files.
|
||||
|
||||
The following list is what's changed when `POSIX mode' is in effect:
|
||||
|
||||
1. When a command in the hash table no longer exists, Bash will
|
||||
|
|
@ -112,6 +115,14 @@ The following list is what's changed when `POSIX mode' is in effect:
|
|||
30. When the `set' builtin is invoked without options, it does not
|
||||
display shell function names and definitions.
|
||||
|
||||
31. 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.
|
||||
|
||||
32. 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.
|
||||
|
||||
There is other POSIX 1003.2 behavior that Bash does not implement.
|
||||
Specifically:
|
||||
49
RBASH
Normal file
49
RBASH
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
The Restricted Shell
|
||||
====================
|
||||
|
||||
If Bash is started with the name `rbash', or the `--restricted' or `-r'
|
||||
option is supplied at invocation, the shell becomes restricted. A
|
||||
restricted shell is used to set up an environment more controlled than
|
||||
the standard shell. A restricted shell behaves identically to `bash'
|
||||
with the exception that the following are disallowed or not performed:
|
||||
|
||||
* Changing directories with the `cd' builtin.
|
||||
|
||||
* Setting or unsetting the values of the `SHELL', `PATH', `ENV', or
|
||||
`BASH_ENV' variables.
|
||||
|
||||
* Specifying command names containing slashes.
|
||||
|
||||
* Specifying a filename containing a slash as an argument to the `.'
|
||||
builtin command.
|
||||
|
||||
* Specifying a filename containing a slash as an argument to the `-p'
|
||||
option to the `hash' builtin command.
|
||||
|
||||
* Importing function definitions from the shell environment at
|
||||
startup.
|
||||
|
||||
* Parsing the value of `SHELLOPTS' from the shell environment at
|
||||
startup.
|
||||
|
||||
* Redirecting output using the `>', `>|', `<>', `>&', `&>', and `>>'
|
||||
redirection operators.
|
||||
|
||||
* Using the `exec' builtin to replace the shell with another command.
|
||||
|
||||
* Adding or deleting builtin commands with the `-f' and `-d' options
|
||||
to the `enable' builtin.
|
||||
|
||||
* Using the `enable' builtin command to enable disabled shell
|
||||
builtins.
|
||||
|
||||
* Specifying the `-p' option to the `command' builtin.
|
||||
|
||||
* Turning off restricted mode with `set +r' or `set +o restricted'.
|
||||
|
||||
These restrictions are enforced after any startup files are read.
|
||||
|
||||
When a command that is found to be a shell script is executed (*note
|
||||
Shell Scripts::), `rbash' turns off any restrictions in the shell
|
||||
spawned to execute the script.
|
||||
|
||||
8
README
8
README
|
|
@ -1,7 +1,7 @@
|
|||
Introduction
|
||||
============
|
||||
|
||||
This is GNU Bash, version 2.05a. Bash is the GNU Project's Bourne
|
||||
This is GNU Bash, version 2.05b. Bash is the GNU Project's Bourne
|
||||
Again SHell, a complete implementation of the POSIX.2 shell spec,
|
||||
but also with interactive command line editing, job control on
|
||||
architectures that support it, csh-like features such as history
|
||||
|
|
@ -67,9 +67,9 @@ built at the same time as bash. If bash fails to build, try building
|
|||
bashbug directly with `make bashbug'. If you cannot build `bashbug',
|
||||
please send mail to bug-bash@gnu.org with the following information:
|
||||
|
||||
* the version number and release status of Bash (e.g., 2.01-release)
|
||||
* the machine and OS that it is running on (look at the file
|
||||
`.made' in the bash build directory)
|
||||
* the version number and release status of Bash (e.g., 2.05a-release)
|
||||
* the machine and OS that it is running on (you may run
|
||||
`bashversion -l' from the bash build directory for this information)
|
||||
* a list of the compilation flags or the contents of `config.h', if
|
||||
appropriate
|
||||
* a description of the bug
|
||||
|
|
|
|||
116
aclocal.m4
vendored
116
aclocal.m4
vendored
|
|
@ -605,6 +605,66 @@ AC_DEFINE(CAN_REDEFINE_GETENV)
|
|||
fi
|
||||
])
|
||||
|
||||
# We should check for putenv before calling this
|
||||
AC_DEFUN(BASH_FUNC_STD_PUTENV,
|
||||
[
|
||||
AC_REQUIRE([AC_HEADER_STDC])
|
||||
AC_REQUIRE([AC_C_PROTOTYPES])
|
||||
AC_CACHE_CHECK([for standard-conformant putenv declaration], bash_cv_std_putenv,
|
||||
[AC_TRY_LINK([
|
||||
#if STDC_HEADERS
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#endif
|
||||
#ifndef __STDC__
|
||||
# ifndef const
|
||||
# define const
|
||||
# endif
|
||||
#endif
|
||||
#ifdef PROTOTYPES
|
||||
extern int putenv (char *);
|
||||
#else
|
||||
extern int putenv ();
|
||||
#endif
|
||||
],
|
||||
[return (putenv == 0);],
|
||||
bash_cv_std_putenv=yes, bash_cv_std_putenv=no
|
||||
)])
|
||||
if test $bash_cv_std_putenv = yes; then
|
||||
AC_DEFINE(HAVE_STD_PUTENV)
|
||||
fi
|
||||
])
|
||||
|
||||
# We should check for unsetenv before calling this
|
||||
AC_DEFUN(BASH_FUNC_STD_UNSETENV,
|
||||
[
|
||||
AC_REQUIRE([AC_HEADER_STDC])
|
||||
AC_REQUIRE([AC_C_PROTOTYPES])
|
||||
AC_CACHE_CHECK([for standard-conformant unsetenv declaration], bash_cv_std_unsetenv,
|
||||
[AC_TRY_LINK([
|
||||
#if STDC_HEADERS
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#endif
|
||||
#ifndef __STDC__
|
||||
# ifndef const
|
||||
# define const
|
||||
# endif
|
||||
#endif
|
||||
#ifdef PROTOTYPES
|
||||
extern int unsetenv (const char *);
|
||||
#else
|
||||
extern int unsetenv ();
|
||||
#endif
|
||||
],
|
||||
[return (unsetenv == 0);],
|
||||
bash_cv_std_unsetenv=yes, bash_cv_std_unsetenv=no
|
||||
)])
|
||||
if test $bash_cv_std_unsetenv = yes; then
|
||||
AC_DEFINE(HAVE_STD_UNSETENV)
|
||||
fi
|
||||
])
|
||||
|
||||
AC_DEFUN(BASH_FUNC_ULIMIT_MAXFDS,
|
||||
[AC_MSG_CHECKING(whether ulimit can substitute for getdtablesize)
|
||||
AC_CACHE_VAL(bash_cv_ulimit_maxfds,
|
||||
|
|
@ -922,7 +982,7 @@ _bash_needmsg=
|
|||
fi
|
||||
AC_CACHE_VAL(bash_cv_termcap_lib,
|
||||
[AC_CHECK_LIB(termcap, tgetent, bash_cv_termcap_lib=libtermcap,
|
||||
[AC_CHECK_LIB(tinfo, tgetent, bash_cv_termcal_lib=libtinfo,
|
||||
[AC_CHECK_LIB(tinfo, tgetent, bash_cv_termcap_lib=libtinfo,
|
||||
[AC_CHECK_LIB(curses, tgetent, bash_cv_termcap_lib=libcurses,
|
||||
[AC_CHECK_LIB(ncurses, tgetent, bash_cv_termcap_lib=libncurses,
|
||||
bash_cv_termcap_lib=gnutermcap)])])])])
|
||||
|
|
@ -1378,10 +1438,10 @@ AC_DEFUN(BASH_SYS_DEFAULT_MAIL_DIR,
|
|||
AC_CACHE_VAL(bash_cv_mail_dir,
|
||||
[if test -d /var/mail; then
|
||||
bash_cv_mail_dir=/var/mail
|
||||
elif test -d /usr/mail; then
|
||||
bash_cv_mail_dir=/usr/mail
|
||||
elif test -d /var/spool/mail; then
|
||||
bash_cv_mail_dir=/var/spool/mail
|
||||
elif test -d /usr/mail; then
|
||||
bash_cv_mail_dir=/usr/mail
|
||||
elif test -d /usr/spool/mail; then
|
||||
bash_cv_mail_dir=/usr/spool/mail
|
||||
else
|
||||
|
|
@ -1389,17 +1449,7 @@ AC_CACHE_VAL(bash_cv_mail_dir,
|
|||
fi
|
||||
])
|
||||
AC_MSG_RESULT($bash_cv_mail_dir)
|
||||
if test $bash_cv_mail_dir = "/var/mail"; then
|
||||
AC_DEFINE(DEFAULT_MAIL_DIRECTORY, "/var/mail")
|
||||
elif test $bash_cv_mail_dir = "/usr/mail"; then
|
||||
AC_DEFINE(DEFAULT_MAIL_DIRECTORY, "/usr/mail")
|
||||
elif test $bash_cv_mail_dir = "/var/spool/mail"; then
|
||||
AC_DEFINE(DEFAULT_MAIL_DIRECTORY, "/var/spool/mail")
|
||||
elif test $bash_cv_mail_dir = "/usr/spool/mail"; then
|
||||
AC_DEFINE(DEFAULT_MAIL_DIRECTORY, "/usr/spool/mail")
|
||||
else
|
||||
AC_DEFINE(DEFAULT_MAIL_DIRECTORY, "unknown")
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED(DEFAULT_MAIL_DIRECTORY, "$bash_cv_mail_dir")
|
||||
])
|
||||
|
||||
AC_DEFUN(BASH_HAVE_TIOCGWINSZ,
|
||||
|
|
@ -1593,6 +1643,42 @@ AC_DEFINE(UNUSABLE_RT_SIGNALS)
|
|||
fi
|
||||
])
|
||||
|
||||
dnl
|
||||
dnl check for availability of multibyte characters and functions
|
||||
dnl
|
||||
AC_DEFUN(BASH_CHECK_MULTIBYTE,
|
||||
[
|
||||
AC_CHECK_HEADERS(wctype.h)
|
||||
AC_CHECK_HEADERS(wchar.h)
|
||||
AC_CHECK_HEADERS(langinfo.h)
|
||||
|
||||
AC_CHECK_FUNC(mbsrtowcs, AC_DEFINE(HAVE_MBSRTOWCS))
|
||||
AC_CHECK_FUNC(wcwidth, AC_DEFINE(HAVE_WCWIDTH))
|
||||
|
||||
AC_CACHE_CHECK([for mbstate_t], bash_cv_have_mbstate_t,
|
||||
[AC_TRY_RUN([
|
||||
#include <wchar.h>
|
||||
int
|
||||
main ()
|
||||
{
|
||||
mbstate_t ps;
|
||||
return 0;
|
||||
}], bash_cv_have_mbstate_t=yes, bash_cv_have_mbstate_t=no)])
|
||||
if test $bash_cv_have_mbstate_t = yes; then
|
||||
AC_DEFINE(HAVE_MBSTATE_T)
|
||||
fi
|
||||
|
||||
AC_CACHE_CHECK([for nl_langinfo and CODESET], bash_cv_langinfo_codeset,
|
||||
[AC_TRY_LINK(
|
||||
[#include <langinfo.h>],
|
||||
[char* cs = nl_langinfo(CODESET);],
|
||||
bash_cv_langinfo_codeset=yes, bash_cv_langinfo_codeset=no)])
|
||||
if test $bash_cv_langinfo_codeset = yes; then
|
||||
AC_DEFINE(HAVE_LANGINFO_CODESET)
|
||||
fi
|
||||
|
||||
])
|
||||
|
||||
dnl need: prefix exec_prefix libdir includedir CC TERMCAP_LIB
|
||||
dnl require:
|
||||
dnl AC_PROG_CC
|
||||
|
|
@ -1655,7 +1741,7 @@ RL_MINOR=0
|
|||
case "$ac_cv_rl_version" in
|
||||
2*|3*|4*|5*|6*|7*|8*|9*)
|
||||
RL_MAJOR=`echo $ac_cv_rl_version | sed 's:\..*$::'`
|
||||
RL_MINOR=`echo $ac_cv_rl_version | sed -e 's:^.*\.::' -e 's:[a-zA-Z]*$::'`
|
||||
RL_MINOR=`echo $ac_cv_rl_version | sed -e 's:^.*\.::' -e 's:[[a-zA-Z]]*$::'`
|
||||
;;
|
||||
esac
|
||||
|
||||
|
|
|
|||
47
alias.c
47
alias.c
|
|
@ -1,7 +1,7 @@
|
|||
/* alias.c -- Not a full alias, but just the kind that we use in the
|
||||
shell. Csh style alias is somewhere else (`over there, in a box'). */
|
||||
|
||||
/* Copyright (C) 1987,1991 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -42,6 +42,8 @@
|
|||
# include "pcomplete.h"
|
||||
#endif
|
||||
|
||||
#define ALIAS_HASH_BUCKETS 16 /* must be power of two */
|
||||
|
||||
typedef int sh_alias_map_func_t __P((alias_t *));
|
||||
|
||||
static void free_alias_data __P((PTR_T));
|
||||
|
|
@ -66,7 +68,7 @@ void
|
|||
initialize_aliases ()
|
||||
{
|
||||
if (!aliases)
|
||||
aliases = make_hash_table (0);
|
||||
aliases = hash_create (ALIAS_HASH_BUCKETS);
|
||||
}
|
||||
|
||||
/* Scan the list of aliases looking for one with NAME. Return NULL
|
||||
|
|
@ -80,7 +82,7 @@ find_alias (name)
|
|||
if (aliases == 0)
|
||||
return ((alias_t *)NULL);
|
||||
|
||||
al = find_hash_item (name, aliases);
|
||||
al = hash_search (name, aliases, 0);
|
||||
return (al ? (alias_t *)al->data : (alias_t *)NULL);
|
||||
}
|
||||
|
||||
|
|
@ -120,6 +122,7 @@ add_alias (name, value)
|
|||
{
|
||||
free (temp->value);
|
||||
temp->value = savestring (value);
|
||||
temp->flags &= ~AL_EXPANDNEXT;
|
||||
n = value[strlen (value) - 1];
|
||||
if (n == ' ' || n == '\t')
|
||||
temp->flags |= AL_EXPANDNEXT;
|
||||
|
|
@ -135,8 +138,8 @@ add_alias (name, value)
|
|||
if (n == ' ' || n == '\t')
|
||||
temp->flags |= AL_EXPANDNEXT;
|
||||
|
||||
elt = add_hash_item (savestring (name), aliases);
|
||||
elt->data = (char *)temp;
|
||||
elt = hash_insert (savestring (name), aliases, HASH_NOSRCH);
|
||||
elt->data = temp;
|
||||
#if defined (PROGRAMMABLE_COMPLETION)
|
||||
set_itemlist_dirty (&it_aliases);
|
||||
#endif
|
||||
|
|
@ -168,7 +171,7 @@ remove_alias (name)
|
|||
if (aliases == 0)
|
||||
return (-1);
|
||||
|
||||
elt = remove_hash_item (name, aliases);
|
||||
elt = hash_remove (name, aliases, 0);
|
||||
if (elt)
|
||||
{
|
||||
free_alias_data (elt->data);
|
||||
|
|
@ -189,8 +192,8 @@ delete_all_aliases ()
|
|||
if (aliases == 0)
|
||||
return;
|
||||
|
||||
flush_hash_table (aliases, free_alias_data);
|
||||
dispose_hash_table (aliases);
|
||||
hash_flush (aliases, free_alias_data);
|
||||
hash_dispose (aliases);
|
||||
aliases = (HASH_TABLE *)NULL;
|
||||
#if defined (PROGRAMMABLE_COMPLETION)
|
||||
set_itemlist_dirty (&it_aliases);
|
||||
|
|
@ -206,30 +209,24 @@ map_over_aliases (function)
|
|||
register int i;
|
||||
register BUCKET_CONTENTS *tlist;
|
||||
alias_t *alias, **list;
|
||||
int list_index, list_size;
|
||||
int list_index;
|
||||
|
||||
list = (alias_t **)NULL;
|
||||
for (i = list_index = list_size = 0; i < aliases->nbuckets; i++)
|
||||
i = HASH_ENTRIES (aliases);
|
||||
if (i == 0)
|
||||
return ((alias_t **)NULL);
|
||||
|
||||
list = (alias_t **)xmalloc ((i + 1) * sizeof (alias_t *));
|
||||
for (i = list_index = 0; i < aliases->nbuckets; i++)
|
||||
{
|
||||
tlist = get_hash_bucket (i, aliases);
|
||||
|
||||
while (tlist)
|
||||
for (tlist = hash_items (i, aliases); tlist; tlist = tlist->next)
|
||||
{
|
||||
alias = (alias_t *)tlist->data;
|
||||
|
||||
if (!function || (*function) (alias))
|
||||
{
|
||||
if (list_index + 1 >= list_size)
|
||||
{
|
||||
list_size += 20;
|
||||
list = (alias_t **)xrealloc (list,
|
||||
list_size * sizeof (alias_t *));
|
||||
}
|
||||
|
||||
list[list_index++] = alias;
|
||||
list[list_index] = (alias_t *)NULL;
|
||||
}
|
||||
tlist = tlist->next;
|
||||
}
|
||||
}
|
||||
return (list);
|
||||
|
|
@ -239,7 +236,7 @@ static void
|
|||
sort_aliases (array)
|
||||
alias_t **array;
|
||||
{
|
||||
qsort (array, array_len ((char **)array), sizeof (alias_t *), (QSFUNC *)qsort_alias_compare);
|
||||
qsort (array, strvec_len ((char **)array), sizeof (alias_t *), (QSFUNC *)qsort_alias_compare);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -260,7 +257,7 @@ all_aliases ()
|
|||
{
|
||||
alias_t **list;
|
||||
|
||||
if (!aliases)
|
||||
if (aliases == 0 || HASH_ENTRIES (aliases) == 0)
|
||||
return ((alias_t **)NULL);
|
||||
|
||||
list = map_over_aliases ((sh_alias_map_func_t *)NULL);
|
||||
|
|
@ -529,7 +526,7 @@ alias_expand (string)
|
|||
/* If there is a backslash-escaped character quoted in TOKEN,
|
||||
then we don't do alias expansion. This should check for all
|
||||
other quoting characters, too. */
|
||||
if (strchr (token, '\\'))
|
||||
if (xstrchr (token, '\\'))
|
||||
expand_this_token = 0;
|
||||
|
||||
/* If we should be expanding here, if we are expanding all words, or if
|
||||
|
|
|
|||
51
array.h
51
array.h
|
|
@ -24,13 +24,13 @@
|
|||
|
||||
#include "stdc.h"
|
||||
|
||||
typedef long arrayind_t;
|
||||
typedef intmax_t arrayind_t;
|
||||
|
||||
enum atype {array_indexed, array_assoc};
|
||||
|
||||
typedef struct array {
|
||||
enum atype type;
|
||||
arrayind_t max_index, num_elements, max_size;
|
||||
arrayind_t max_index, num_elements;
|
||||
struct array_element *head;
|
||||
} ARRAY;
|
||||
|
||||
|
|
@ -42,36 +42,43 @@ typedef struct array_element {
|
|||
|
||||
typedef int sh_ae_map_func_t __P((ARRAY_ELEMENT *));
|
||||
|
||||
char *array_reference __P((ARRAY *, arrayind_t));
|
||||
/* Basic operations on entire arrays */
|
||||
extern ARRAY *array_create __P((void));
|
||||
extern void array_flush __P((ARRAY *));
|
||||
extern void array_dispose __P((ARRAY *));
|
||||
extern ARRAY *array_copy __P((ARRAY *));
|
||||
extern ARRAY *array_slice __P((ARRAY *, ARRAY_ELEMENT *, ARRAY_ELEMENT *));
|
||||
extern void array_walk __P((ARRAY *, sh_ae_map_func_t *));
|
||||
|
||||
extern int array_add_element __P((ARRAY *, arrayind_t, char *));
|
||||
extern ARRAY_ELEMENT *array_delete_element __P((ARRAY *, arrayind_t));
|
||||
extern ARRAY_ELEMENT *array_shift __P((ARRAY *, int, int));
|
||||
extern int array_rshift __P((ARRAY *, int, char *));
|
||||
extern ARRAY *array_quote __P((ARRAY *));
|
||||
|
||||
extern ARRAY_ELEMENT *new_array_element __P((arrayind_t, char *));
|
||||
extern void destroy_array_element __P((ARRAY_ELEMENT *));
|
||||
extern char *array_subrange __P((ARRAY *, arrayind_t, arrayind_t, int));
|
||||
extern char *array_patsub __P((ARRAY *, char *, char *, int));
|
||||
|
||||
extern ARRAY *new_array __P((void));
|
||||
extern void empty_array __P((ARRAY *));
|
||||
extern void dispose_array __P((ARRAY *));
|
||||
extern ARRAY *dup_array __P((ARRAY *));
|
||||
extern ARRAY *dup_array_subrange __P((ARRAY *, ARRAY_ELEMENT *, ARRAY_ELEMENT *));
|
||||
extern ARRAY_ELEMENT *copy_array_element __P((ARRAY_ELEMENT *));
|
||||
/* Basic operations on array elements. */
|
||||
extern ARRAY_ELEMENT *array_create_element __P((arrayind_t, char *));
|
||||
extern ARRAY_ELEMENT *array_copy_element __P((ARRAY_ELEMENT *));
|
||||
extern void array_dispose_element __P((ARRAY_ELEMENT *));
|
||||
|
||||
extern int array_insert __P((ARRAY *, arrayind_t, char *));
|
||||
extern ARRAY_ELEMENT *array_remove __P((ARRAY *, arrayind_t));
|
||||
extern char *array_reference __P((ARRAY *, arrayind_t));
|
||||
|
||||
/* Converting to and from arrays */
|
||||
extern WORD_LIST *array_to_word_list __P((ARRAY *));
|
||||
extern ARRAY *word_list_to_array __P((WORD_LIST *));
|
||||
extern ARRAY *assign_word_list __P((ARRAY *, WORD_LIST *));
|
||||
extern ARRAY *array_from_word_list __P((WORD_LIST *));
|
||||
extern ARRAY *array_assign_list __P((ARRAY *, WORD_LIST *));
|
||||
|
||||
extern char **array_to_argv __P((ARRAY *));
|
||||
|
||||
extern char *array_to_assignment_string __P((ARRAY *));
|
||||
extern char *quoted_array_assignment_string __P((ARRAY *));
|
||||
extern char *array_to_assign __P((ARRAY *, int));
|
||||
extern char *array_to_string __P((ARRAY *, char *, int));
|
||||
extern ARRAY *string_to_array __P((char *, char *));
|
||||
extern ARRAY *array_from_string __P((char *, char *));
|
||||
|
||||
extern char *array_subrange __P((ARRAY *, arrayind_t, arrayind_t, int));
|
||||
extern char *array_pat_subst __P((ARRAY *, char *, char *, int));
|
||||
|
||||
extern ARRAY *array_quote __P((ARRAY *));
|
||||
/* Flags for array_shift */
|
||||
#define AS_DISPOSE 0x01
|
||||
|
||||
#define array_num_elements(a) ((a)->num_elements)
|
||||
#define array_max_index(a) ((a)->max_index)
|
||||
|
|
|
|||
166
arrayfunc.c
166
arrayfunc.c
|
|
@ -1,6 +1,6 @@
|
|||
/* arrayfunc.c -- High-level array functions used by other parts of the shell. */
|
||||
|
||||
/* Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 2001-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -28,13 +28,16 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include "shell.h"
|
||||
|
||||
#include "shmbutil.h"
|
||||
|
||||
#include "builtins/common.h"
|
||||
|
||||
extern char *this_command_name;
|
||||
extern int last_command_exit_value;
|
||||
|
||||
static void quote_array_assignment_chars __P((WORD_LIST *));
|
||||
static char *array_value_internal __P((char *, int, int));
|
||||
static char *array_value_internal __P((char *, int, int, int *));
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
|
|
@ -52,11 +55,15 @@ convert_var_to_array (var)
|
|||
ARRAY *array;
|
||||
|
||||
oldval = value_cell (var);
|
||||
array = new_array ();
|
||||
array_add_element (array, 0, oldval);
|
||||
array = array_create ();
|
||||
array_insert (array, 0, oldval);
|
||||
|
||||
FREE (value_cell (var));
|
||||
var->value = (char *)array;
|
||||
var_setarray (var, array);
|
||||
|
||||
/* these aren't valid anymore */
|
||||
var->dynamic_value = (sh_var_value_func_t *)NULL;
|
||||
var->assign_func = (sh_var_assign_func_t *)NULL;
|
||||
|
||||
INVALIDATE_EXPORTSTR (var);
|
||||
|
||||
|
|
@ -89,7 +96,7 @@ bind_array_variable (name, ind, value)
|
|||
else if (readonly_p (entry) || noassign_p (entry))
|
||||
{
|
||||
if (readonly_p (entry))
|
||||
report_error ("%s: readonly variable", name);
|
||||
err_readonly (name);
|
||||
return (entry);
|
||||
}
|
||||
else if (array_p (entry) == 0)
|
||||
|
|
@ -98,9 +105,9 @@ bind_array_variable (name, ind, value)
|
|||
/* ENTRY is an array variable, and ARRAY points to the value. */
|
||||
newval = make_variable_value (entry, value);
|
||||
if (entry->assign_func)
|
||||
(*entry->assign_func) (entry, ind, newval);
|
||||
(*entry->assign_func) (entry, newval, ind);
|
||||
else
|
||||
array_add_element (array_cell (entry), ind, newval);
|
||||
array_insert (array_cell (entry), ind, newval);
|
||||
FREE (newval);
|
||||
|
||||
return (entry);
|
||||
|
|
@ -125,7 +132,7 @@ assign_array_element (name, value)
|
|||
if ((ALL_ELEMENT_SUB (sub[0]) && sub[1] == ']') || (sublen <= 1))
|
||||
{
|
||||
free (vname);
|
||||
report_error ("%s: bad array subscript", name);
|
||||
err_badarraysub (name);
|
||||
return ((SHELL_VAR *)NULL);
|
||||
}
|
||||
|
||||
|
|
@ -133,7 +140,7 @@ assign_array_element (name, value)
|
|||
if (ind < 0)
|
||||
{
|
||||
free (vname);
|
||||
report_error ("%s: bad array subscript", name);
|
||||
err_badarraysub (name);
|
||||
return ((SHELL_VAR *)NULL);
|
||||
}
|
||||
|
||||
|
|
@ -162,7 +169,7 @@ find_or_make_array_variable (name, check_flags)
|
|||
else if (check_flags && (readonly_p (var) || noassign_p (var)))
|
||||
{
|
||||
if (readonly_p (var))
|
||||
report_error ("%s: readonly variable", name);
|
||||
err_readonly (name);
|
||||
return ((SHELL_VAR *)NULL);
|
||||
}
|
||||
else if (array_p (var) == 0)
|
||||
|
|
@ -199,9 +206,9 @@ assign_array_var_from_word_list (var, list)
|
|||
|
||||
for (a = array_cell (var), l = list, i = 0; l; l = l->next, i++)
|
||||
if (var->assign_func)
|
||||
(*var->assign_func) (var, i, l->word->word);
|
||||
(*var->assign_func) (var, l->word->word, i);
|
||||
else
|
||||
array_add_element (a, i, l->word->word);
|
||||
array_insert (a, i, l->word->word);
|
||||
return var;
|
||||
}
|
||||
|
||||
|
|
@ -222,7 +229,7 @@ assign_array_var_from_string (var, value)
|
|||
return var;
|
||||
|
||||
/* If this is called from declare_builtin, value[0] == '(' and
|
||||
strchr(value, ')') != 0. In this case, we need to extract
|
||||
xstrchr(value, ')') != 0. In this case, we need to extract
|
||||
the value from between the parens before going on. */
|
||||
if (*value == '(') /*)*/
|
||||
{
|
||||
|
|
@ -259,7 +266,7 @@ assign_array_var_from_string (var, value)
|
|||
/* Now that we are ready to assign values to the array, kill the existing
|
||||
value. */
|
||||
if (a)
|
||||
empty_array (a);
|
||||
array_flush (a);
|
||||
|
||||
for (last_ind = 0, list = nlist; list; list = list->next)
|
||||
{
|
||||
|
|
@ -274,9 +281,9 @@ assign_array_var_from_string (var, value)
|
|||
{
|
||||
nval = make_variable_value (var, w);
|
||||
if (var->assign_func)
|
||||
(*var->assign_func) (var, last_ind, nval);
|
||||
(*var->assign_func) (var, nval, last_ind);
|
||||
else
|
||||
array_add_element (a, last_ind, nval);
|
||||
array_insert (a, last_ind, nval);
|
||||
FREE (nval);
|
||||
last_ind++;
|
||||
continue;
|
||||
|
|
@ -284,7 +291,7 @@ assign_array_var_from_string (var, value)
|
|||
|
||||
if (len == 1)
|
||||
{
|
||||
report_error ("%s: bad array subscript", w);
|
||||
err_badarraysub (w);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -297,7 +304,7 @@ assign_array_var_from_string (var, value)
|
|||
ind = array_expand_index (w + 1, len);
|
||||
if (ind < 0)
|
||||
{
|
||||
report_error ("%s: bad array subscript", w);
|
||||
err_badarraysub (w);
|
||||
continue;
|
||||
}
|
||||
last_ind = ind;
|
||||
|
|
@ -313,9 +320,9 @@ assign_array_var_from_string (var, value)
|
|||
this_command_name = (char *)NULL; /* no command name for errors */
|
||||
nval = make_variable_value (var, val);
|
||||
if (var->assign_func)
|
||||
(*var->assign_func) (var, ind, nval);
|
||||
(*var->assign_func) (var, nval, ind);
|
||||
else
|
||||
array_add_element (a, ind, nval);
|
||||
array_insert (a, ind, nval);
|
||||
FREE (nval);
|
||||
last_ind++;
|
||||
}
|
||||
|
|
@ -340,7 +347,7 @@ 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 */
|
||||
if (l->word->word[0] != '[' || strchr (l->word->word, '=') == 0) /* ] */
|
||||
if (l->word->word[0] != '[' || xstrchr (l->word->word, '=') == 0) /* ] */
|
||||
continue;
|
||||
s = nword = (char *)xmalloc (strlen (l->word->word) * 2 + 1);
|
||||
saw_eq = 0;
|
||||
|
|
@ -366,14 +373,56 @@ skipsubscript (s, i)
|
|||
int i;
|
||||
{
|
||||
int count, c;
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
mbstate_t state, state_bak;
|
||||
size_t slength, mblength;
|
||||
size_t mb_cur_max;
|
||||
#endif
|
||||
|
||||
for (count = 1; count && (c = s[++i]); )
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
memset (&state, '\0', sizeof (mbstate_t));
|
||||
slength = strlen (s + i);
|
||||
mb_cur_max = MB_CUR_MAX;
|
||||
#endif
|
||||
|
||||
count = 1;
|
||||
while (count)
|
||||
{
|
||||
if (c == '[')
|
||||
/* Advance one (possibly multibyte) character in S starting at I. */
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
if (mb_cur_max > 1)
|
||||
{
|
||||
state_bak = state;
|
||||
mblength = mbrlen (s + i, slength, &state);
|
||||
|
||||
if (mblength == (size_t)-2 || mblength == (size_t)-1)
|
||||
{
|
||||
state = state_bak;
|
||||
i++;
|
||||
slength--;
|
||||
}
|
||||
else if (mblength == 0)
|
||||
return i;
|
||||
else
|
||||
{
|
||||
i += mblength;
|
||||
slength -= mblength;
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
++i;
|
||||
|
||||
c = s[i];
|
||||
|
||||
if (c == 0)
|
||||
break;
|
||||
else if (c == '[')
|
||||
count++;
|
||||
else if (c == ']')
|
||||
count--;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
|
|
@ -399,7 +448,7 @@ unbind_array_element (var, sub)
|
|||
|
||||
if (ALL_ELEMENT_SUB (sub[0]) && sub[1] == 0)
|
||||
{
|
||||
makunbound (var->name, shell_variables);
|
||||
unbind_variable (var->name);
|
||||
return (0);
|
||||
}
|
||||
ind = array_expand_index (sub, len+1);
|
||||
|
|
@ -408,9 +457,9 @@ unbind_array_element (var, sub)
|
|||
builtin_error ("[%s]: bad array subscript", sub);
|
||||
return -1;
|
||||
}
|
||||
ae = array_delete_element (array_cell (var), ind);
|
||||
ae = array_remove (array_cell (var), ind);
|
||||
if (ae)
|
||||
destroy_array_element (ae);
|
||||
array_dispose_element (ae);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -423,10 +472,7 @@ print_array_assignment (var, quoted)
|
|||
{
|
||||
char *vstr;
|
||||
|
||||
if (quoted)
|
||||
vstr = quoted_array_assignment_string (array_cell (var));
|
||||
else
|
||||
vstr = array_to_assignment_string (array_cell (var));
|
||||
vstr = array_to_assign (array_cell (var), quoted);
|
||||
|
||||
if (vstr == 0)
|
||||
printf ("%s=%s\n", var->name, quoted ? "'()'" : "()");
|
||||
|
|
@ -451,7 +497,7 @@ valid_array_reference (name)
|
|||
char *t;
|
||||
int r, len;
|
||||
|
||||
t = strchr (name, '['); /* ] */
|
||||
t = xstrchr (name, '['); /* ] */
|
||||
if (t)
|
||||
{
|
||||
*t = '\0';
|
||||
|
|
@ -509,14 +555,14 @@ array_variable_name (s, subp, lenp)
|
|||
char *t, *ret;
|
||||
int ind, ni;
|
||||
|
||||
t = strchr (s, '[');
|
||||
t = xstrchr (s, '[');
|
||||
if (t == 0)
|
||||
return ((char *)NULL);
|
||||
ind = t - s;
|
||||
ni = skipsubscript (s, ind);
|
||||
if (ni <= ind + 1 || s[ni] != ']')
|
||||
{
|
||||
report_error ("%s: bad array subscript", s);
|
||||
err_badarraysub (s);
|
||||
return ((char *)NULL);
|
||||
}
|
||||
|
||||
|
|
@ -554,11 +600,13 @@ array_variable_part (s, subp, lenp)
|
|||
|
||||
/* Return a string containing the elements in the array and subscript
|
||||
described by S. If the subscript is * or @, obeys quoting rules akin
|
||||
to the expansion of $* and $@ including double quoting. */
|
||||
to the expansion of $* and $@ including double quoting. If RTYPE
|
||||
is non-null it gets 1 if the array reference is name[@] or name[*]
|
||||
and 0 otherwise. */
|
||||
static char *
|
||||
array_value_internal (s, quoted, allow_all)
|
||||
array_value_internal (s, quoted, allow_all, rtype)
|
||||
char *s;
|
||||
int quoted, allow_all;
|
||||
int quoted, allow_all, *rtype;
|
||||
{
|
||||
int len;
|
||||
arrayind_t ind;
|
||||
|
|
@ -568,22 +616,27 @@ array_value_internal (s, quoted, allow_all)
|
|||
|
||||
var = array_variable_part (s, &t, &len);
|
||||
|
||||
/* Expand the index, even if the variable doesn't exist, in case side
|
||||
effects are needed, like ${w[i++]} where w is unset. */
|
||||
#if 0
|
||||
if (var == 0)
|
||||
return (char *)NULL;
|
||||
#endif
|
||||
|
||||
/* [ */
|
||||
if (ALL_ELEMENT_SUB (t[0]) && t[1] == ']')
|
||||
{
|
||||
if (rtype)
|
||||
*rtype = 1;
|
||||
if (allow_all == 0)
|
||||
{
|
||||
report_error ("%s: bad array subscript", s);
|
||||
err_badarraysub (s);
|
||||
return ((char *)NULL);
|
||||
}
|
||||
else if (var == 0)
|
||||
return ((char *)NULL);
|
||||
else if (array_p (var) == 0)
|
||||
{
|
||||
l = (WORD_LIST *)NULL;
|
||||
l = add_string_to_list (value_cell (var), l);
|
||||
}
|
||||
l = add_string_to_list (value_cell (var), (WORD_LIST *)NULL);
|
||||
else
|
||||
{
|
||||
l = array_to_word_list (array_cell (var));
|
||||
|
|
@ -604,17 +657,26 @@ array_value_internal (s, quoted, allow_all)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (rtype)
|
||||
*rtype = 0;
|
||||
ind = array_expand_index (t, len);
|
||||
if (ind < 0)
|
||||
{
|
||||
report_error ("%s: bad array subscript", var->name);
|
||||
if (var)
|
||||
err_badarraysub (var->name);
|
||||
else
|
||||
{
|
||||
t[-1] = '\0';
|
||||
err_badarraysub (s);
|
||||
t[-1] = '['; /* ] */
|
||||
}
|
||||
return ((char *)NULL);
|
||||
}
|
||||
if (var == 0)
|
||||
return ((char *)NULL);
|
||||
if (array_p (var) == 0)
|
||||
return (ind == 0 ? savestring (value_cell (var)) : (char *)NULL);
|
||||
return (ind == 0 ? value_cell (var) : (char *)NULL);
|
||||
retval = array_reference (array_cell (var), ind);
|
||||
if (retval)
|
||||
retval = quote_escapes (retval);
|
||||
}
|
||||
|
||||
return retval;
|
||||
|
|
@ -623,11 +685,11 @@ array_value_internal (s, quoted, allow_all)
|
|||
/* Return a string containing the elements described by the array and
|
||||
subscript contained in S, obeying quoting for subscripts * and @. */
|
||||
char *
|
||||
array_value (s, quoted)
|
||||
array_value (s, quoted, rtype)
|
||||
char *s;
|
||||
int quoted;
|
||||
int quoted, *rtype;
|
||||
{
|
||||
return (array_value_internal (s, quoted, 1));
|
||||
return (array_value_internal (s, quoted, 1, rtype));
|
||||
}
|
||||
|
||||
/* Return the value of the array indexing expression S as a single string.
|
||||
|
|
@ -635,11 +697,11 @@ array_value (s, quoted)
|
|||
by other parts of the shell such as the arithmetic expression evaluator
|
||||
in expr.c. */
|
||||
char *
|
||||
get_array_value (s, allow_all)
|
||||
get_array_value (s, allow_all, rtype)
|
||||
char *s;
|
||||
int allow_all;
|
||||
int allow_all, *rtype;
|
||||
{
|
||||
return (array_value_internal (s, 0, allow_all));
|
||||
return (array_value_internal (s, 0, allow_all, rtype));
|
||||
}
|
||||
|
||||
#endif /* ARRAY_VARS */
|
||||
|
|
|
|||
|
|
@ -42,8 +42,8 @@ extern void print_array_assignment __P((SHELL_VAR *, int));
|
|||
|
||||
extern arrayind_t array_expand_index __P((char *, int));
|
||||
extern int valid_array_reference __P((char *));
|
||||
extern char *array_value __P((char *, int));
|
||||
extern char *get_array_value __P((char *, int));
|
||||
extern char *array_value __P((char *, int, int *));
|
||||
extern char *get_array_value __P((char *, int, int *));
|
||||
|
||||
extern char *array_variable_name __P((char *, char **, int *));
|
||||
extern SHELL_VAR *array_variable_part __P((char *, char **, int *));
|
||||
|
|
|
|||
123
bashhist.c
123
bashhist.c
|
|
@ -57,6 +57,8 @@ extern int errno;
|
|||
#endif
|
||||
|
||||
static int histignore_item_func __P((struct ign *));
|
||||
static int check_history_control __P((char *));
|
||||
static void really_add_history __P((char *));
|
||||
|
||||
static struct ignorevar histignore =
|
||||
{
|
||||
|
|
@ -87,8 +89,8 @@ int history_lines_in_file;
|
|||
int history_expansion_inhibited;
|
||||
#endif
|
||||
|
||||
/* By default, every line is saved in the history individually. I.e.,
|
||||
if the user enters:
|
||||
/* With the old default, every line was saved in the history individually.
|
||||
I.e., if the user enters:
|
||||
bash$ for i in a b c
|
||||
> do
|
||||
> echo $i
|
||||
|
|
@ -114,9 +116,16 @@ int history_expansion_inhibited;
|
|||
11 history
|
||||
The user can then recall the whole command all at once instead
|
||||
of just being able to recall one line at a time.
|
||||
|
||||
This is now enabled by default.
|
||||
*/
|
||||
int command_oriented_history = 1;
|
||||
|
||||
/* Set to 1 if the first line of a possibly-multi-line command was saved
|
||||
in the history list. Managed by maybe_add_history(), but global so
|
||||
the history-manipluating builtins can see it. */
|
||||
int current_command_first_line_saved = 0;
|
||||
|
||||
/* Non-zero means to store newlines in the history list when using
|
||||
command_oriented_history rather than trying to use semicolons. */
|
||||
int literal_history;
|
||||
|
|
@ -493,26 +502,61 @@ filter_comments (line)
|
|||
}
|
||||
#endif
|
||||
|
||||
/* Add LINE to the history list depending on the value of HISTORY_CONTROL. */
|
||||
/* Check LINE against what HISTCONTROL says to do. Returns 1 if the line
|
||||
should be saved; 0 if it should be discarded. */
|
||||
static int
|
||||
check_history_control (line)
|
||||
char *line;
|
||||
{
|
||||
HIST_ENTRY *temp;
|
||||
int r;
|
||||
|
||||
switch (history_control)
|
||||
{
|
||||
case 0: /* nothing */
|
||||
return 1;
|
||||
case 1: /* ignorespace */
|
||||
return (*line != ' ');
|
||||
case 3: /* ignoreboth */
|
||||
if (*line == ' ')
|
||||
return 0;
|
||||
/* FALLTHROUGH if case == 3 (`ignoreboth') */
|
||||
case 2: /* ignoredups */
|
||||
using_history ();
|
||||
temp = previous_history ();
|
||||
|
||||
r = (temp == 0 || STREQ (temp->line, line) == 0);
|
||||
|
||||
using_history ();
|
||||
return r;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Add LINE to the history list, handling possibly multi-line compound
|
||||
commands. We note whether or not we save the first line of each command
|
||||
(which is usually the entire command and history entry), and don't add
|
||||
the second and subsequent lines of a multi-line compound command if we
|
||||
didn't save the first line. We don't usually save shell comment lines in
|
||||
compound commands in the history, because they could have the effect of
|
||||
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. */
|
||||
void
|
||||
maybe_add_history (line)
|
||||
char *line;
|
||||
{
|
||||
static int first_line_saved = 0;
|
||||
HIST_ENTRY *temp;
|
||||
|
||||
hist_last_line_added = 0;
|
||||
|
||||
/* Don't use the value of history_control to affect the second
|
||||
and subsequent lines of a multi-line command (old code did
|
||||
this only when command_oriented_history is enabled). */
|
||||
#if 0
|
||||
if (command_oriented_history && current_command_line_count > 1)
|
||||
#else
|
||||
if (current_command_line_count > 1)
|
||||
#endif
|
||||
{
|
||||
if (first_line_saved &&
|
||||
if (current_command_first_line_saved &&
|
||||
(literal_history || dstack.delimiter_depth != 0 || shell_comment (line) == 0))
|
||||
bash_add_history (line);
|
||||
return;
|
||||
|
|
@ -520,36 +564,29 @@ maybe_add_history (line)
|
|||
|
||||
/* This is the first line of a (possible multi-line) command. Note whether
|
||||
or not we should save the first line and remember it. */
|
||||
first_line_saved = 0;
|
||||
|
||||
switch (history_control)
|
||||
{
|
||||
case 0:
|
||||
first_line_saved = 1;
|
||||
break;
|
||||
case 1:
|
||||
if (*line != ' ')
|
||||
first_line_saved = 1;
|
||||
break;
|
||||
case 3:
|
||||
if (*line == ' ')
|
||||
break;
|
||||
/* FALLTHROUGH if case == 3 (`ignoreboth') */
|
||||
case 2:
|
||||
using_history ();
|
||||
temp = previous_history ();
|
||||
|
||||
if (temp == 0 || STREQ (temp->line, line) == 0)
|
||||
first_line_saved = 1;
|
||||
|
||||
using_history ();
|
||||
break;
|
||||
current_command_first_line_saved = check_add_history (line, 0);
|
||||
}
|
||||
|
||||
if (first_line_saved && history_should_ignore (line) == 0)
|
||||
bash_add_history (line);
|
||||
/* Just check LINE against HISTCONTROL and HISTIGNORE and add it to the
|
||||
history if it's OK. Used by `history -s' as well as maybe_add_history().
|
||||
Returns 1 if the line was saved in the history, 0 otherwise. */
|
||||
int
|
||||
check_add_history (line, force)
|
||||
char *line;
|
||||
int force;
|
||||
{
|
||||
if (check_history_control (line) && history_should_ignore (line) == 0)
|
||||
{
|
||||
if (force)
|
||||
{
|
||||
really_add_history (line);
|
||||
using_history ();
|
||||
}
|
||||
else
|
||||
first_line_saved = 0;
|
||||
bash_add_history (line);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Add a line to the history list.
|
||||
|
|
@ -607,13 +644,19 @@ bash_add_history (line)
|
|||
}
|
||||
|
||||
if (add_it)
|
||||
really_add_history (line);
|
||||
|
||||
using_history ();
|
||||
}
|
||||
|
||||
static void
|
||||
really_add_history (line)
|
||||
char *line;
|
||||
{
|
||||
hist_last_line_added = 1;
|
||||
add_history (line);
|
||||
history_lines_this_session++;
|
||||
}
|
||||
using_history ();
|
||||
}
|
||||
|
||||
int
|
||||
history_number ()
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ extern int history_lines_in_file;
|
|||
extern int history_expansion;
|
||||
extern int history_control;
|
||||
extern int command_oriented_history;
|
||||
extern int current_command_first_line_saved;
|
||||
extern int hist_last_line_added;
|
||||
|
||||
# if defined (BANG_HISTORY)
|
||||
|
|
@ -46,6 +47,7 @@ extern int maybe_save_shell_history __P((void));
|
|||
extern char *pre_process_line __P((char *, int, int));
|
||||
extern void maybe_add_history __P((char *));
|
||||
extern void bash_add_history __P((char *));
|
||||
extern int check_add_history __P((char *, int));
|
||||
extern int history_number __P((void));
|
||||
|
||||
extern void setup_history_ignore __P((char *));
|
||||
|
|
|
|||
317
bashline.c
317
bashline.c
|
|
@ -1,6 +1,6 @@
|
|||
/* bashline.c -- Bash's interface to the readline library. */
|
||||
|
||||
/* Copyright (C) 1987,1991 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -33,10 +33,15 @@
|
|||
# include <grp.h>
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_NETDB_H)
|
||||
# include <netdb.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include "chartypes.h"
|
||||
#include "bashansi.h"
|
||||
#include "shell.h"
|
||||
#include "input.h"
|
||||
#include "builtins.h"
|
||||
#include "bashhist.h"
|
||||
#include "bashline.h"
|
||||
|
|
@ -58,6 +63,14 @@
|
|||
# include "pcomplete.h"
|
||||
#endif
|
||||
|
||||
/* These should agree with the defines for emacs_mode and vi_mode in
|
||||
rldefs.h, even though that's not a public readline header file. */
|
||||
#ifndef EMACS_EDITING_MODE
|
||||
# define NO_EDITING_MODE -1
|
||||
# define EMACS_EDITING_MODE 1
|
||||
# define VI_EDITING_MODE 0
|
||||
#endif
|
||||
|
||||
#if defined (BRACE_COMPLETION)
|
||||
extern int bash_brace_completion __P((int, int));
|
||||
#endif /* BRACE_COMPLETION */
|
||||
|
|
@ -170,13 +183,16 @@ static int bash_possible_command_completions __P((int, int));
|
|||
|
||||
static char *glob_complete_word __P((const char *, int));
|
||||
static int bash_glob_completion_internal __P((int));
|
||||
static int bash_glob_complete_word __P((int, int));
|
||||
static int bash_glob_expand_word __P((int, int));
|
||||
static int bash_glob_list_expansions __P((int, int));
|
||||
#endif /* SPECIFIC_COMPLETION_FUNCTIONS */
|
||||
|
||||
static int edit_and_execute_command __P((int, int, int, char *));
|
||||
#if defined (VI_MODE)
|
||||
static int vi_edit_and_execute_command __P((int, int));
|
||||
#endif
|
||||
static int emacs_edit_and_execute_command __P((int, int));
|
||||
|
||||
/* Non-zero once initalize_readline () has been called. */
|
||||
int bash_readline_initialized = 0;
|
||||
|
|
@ -275,6 +291,7 @@ initialize_readline ()
|
|||
|
||||
rl_add_defun ("operate-and-get-next", operate_and_get_next, -1);
|
||||
rl_add_defun ("display-shell-version", display_shell_version, -1);
|
||||
rl_add_defun ("edit-and-execute-command", emacs_edit_and_execute_command, -1);
|
||||
|
||||
#if defined (BRACE_COMPLETION)
|
||||
rl_add_defun ("complete-into-braces", bash_brace_completion, -1);
|
||||
|
|
@ -291,6 +308,7 @@ initialize_readline ()
|
|||
rl_add_defun ("possible-variable-completions", bash_possible_variable_completions, -1);
|
||||
rl_add_defun ("complete-command", bash_complete_command, -1);
|
||||
rl_add_defun ("possible-command-completions", bash_possible_command_completions, -1);
|
||||
rl_add_defun ("glob-complete-word", bash_glob_complete_word, -1);
|
||||
rl_add_defun ("glob-expand-word", bash_glob_expand_word, -1);
|
||||
rl_add_defun ("glob-list-expansions", bash_glob_list_expansions, -1);
|
||||
#endif
|
||||
|
|
@ -341,6 +359,7 @@ initialize_readline ()
|
|||
rl_bind_key_in_map ('!', bash_complete_command, emacs_meta_keymap);
|
||||
rl_bind_key_in_map ('!', bash_possible_command_completions, emacs_ctlx_keymap);
|
||||
|
||||
rl_bind_key_in_map ('g', bash_glob_complete_word, emacs_meta_keymap);
|
||||
rl_bind_key_in_map ('*', bash_glob_expand_word, emacs_ctlx_keymap);
|
||||
rl_bind_key_in_map ('g', bash_glob_list_expansions, emacs_ctlx_keymap);
|
||||
|
||||
|
|
@ -358,6 +377,8 @@ initialize_readline ()
|
|||
/* Tell the filename completer we want a chance to ignore some names. */
|
||||
rl_ignore_some_completions_function = filename_completion_ignore;
|
||||
|
||||
/* Bind C-xC-e to invoke emacs and run result as commands. */
|
||||
rl_bind_key_in_map (CTRL ('E'), emacs_edit_and_execute_command, emacs_ctlx_keymap);
|
||||
#if defined (VI_MODE)
|
||||
rl_bind_key_in_map ('v', vi_edit_and_execute_command, vi_movement_keymap);
|
||||
# if defined (ALIAS)
|
||||
|
|
@ -378,8 +399,14 @@ initialize_readline ()
|
|||
rl_filename_dequoting_function = bash_dequote_filename;
|
||||
rl_char_is_quoted_p = char_is_quoted;
|
||||
|
||||
#if 0
|
||||
/* This is superfluous and makes it impossible to use tab completion in
|
||||
vi mode even when explicitly binding it in ~/.inputrc. sv_strict_posix()
|
||||
should already have called posix_readline_initialize() when
|
||||
posixly_correct was set. */
|
||||
if (posixly_correct)
|
||||
posix_readline_initialize (1);
|
||||
#endif
|
||||
|
||||
bash_readline_initialized = 1;
|
||||
}
|
||||
|
|
@ -491,13 +518,10 @@ static void
|
|||
add_host_name (name)
|
||||
char *name;
|
||||
{
|
||||
size_t size;
|
||||
|
||||
if (hostname_list_length + 2 > hostname_list_size)
|
||||
{
|
||||
hostname_list_size = (hostname_list_size + 32) - (hostname_list_size % 32);
|
||||
size = hostname_list_size * sizeof (char *);
|
||||
hostname_list = (char **)xrealloc (hostname_list, size);
|
||||
hostname_list = strvec_resize (hostname_list, hostname_list_size);
|
||||
}
|
||||
|
||||
hostname_list[hostname_list_length++] = savestring (name);
|
||||
|
|
@ -613,7 +637,7 @@ hostnames_matching (text)
|
|||
what is desired. */
|
||||
if (*text == '\0')
|
||||
{
|
||||
result = alloc_array (1 + hostname_list_length);
|
||||
result = strvec_create (1 + hostname_list_length);
|
||||
for (i = 0; i < hostname_list_length; i++)
|
||||
result[i] = hostname_list[i];
|
||||
result[i] = (char *)NULL;
|
||||
|
|
@ -632,7 +656,7 @@ hostnames_matching (text)
|
|||
if (nmatch >= (rsize - 1))
|
||||
{
|
||||
rsize = (rsize + 16) - (rsize % 16);
|
||||
result = (char **)xrealloc (result, rsize * sizeof (char *));
|
||||
result = strvec_resize (result, rsize);
|
||||
}
|
||||
|
||||
result[nmatch++] = hostname_list[i];
|
||||
|
|
@ -680,16 +704,17 @@ operate_and_get_next (count, c)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if defined (VI_MODE)
|
||||
/* This vi mode command causes VI_EDIT_COMMAND to be run on the current
|
||||
command being entered (if no explicit argument is given), otherwise on
|
||||
a command from the history file. */
|
||||
|
||||
#define VI_EDIT_COMMAND "fc -e ${VISUAL:-${EDITOR:-vi}}"
|
||||
#define EMACS_EDIT_COMMAND "fc -e ${VISUAL:-${EDITOR:-emacs}}"
|
||||
|
||||
static int
|
||||
vi_edit_and_execute_command (count, c)
|
||||
int count, c;
|
||||
edit_and_execute_command (count, c, editing_mode, edit_command)
|
||||
int count, c, editing_mode;
|
||||
char *edit_command;
|
||||
{
|
||||
char *command;
|
||||
int r, cclc, rrs;
|
||||
|
|
@ -702,8 +727,8 @@ vi_edit_and_execute_command (count, c)
|
|||
|
||||
if (rl_explicit_arg)
|
||||
{
|
||||
command = (char *)xmalloc (strlen (VI_EDIT_COMMAND) + 8);
|
||||
sprintf (command, "%s %d", VI_EDIT_COMMAND, count);
|
||||
command = (char *)xmalloc (strlen (edit_command) + 8);
|
||||
sprintf (command, "%s %d", edit_command, count);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -716,9 +741,13 @@ vi_edit_and_execute_command (count, c)
|
|||
bash_add_history ("");
|
||||
history_lines_this_session++;
|
||||
using_history ();
|
||||
command = savestring (VI_EDIT_COMMAND);
|
||||
command = savestring (edit_command);
|
||||
}
|
||||
r = parse_and_execute (command, "v", SEVAL_NOHIST);
|
||||
|
||||
/* Now, POSIX.1-2001 and SUSv3 say that the commands executed from the
|
||||
temporary file should be placed into the history. We don't do that
|
||||
yet. */
|
||||
r = parse_and_execute (command, (editing_mode == VI_EDITING_MODE) ? "v" : "C-xC-e", SEVAL_NOHIST);
|
||||
|
||||
current_command_line_count = cclc;
|
||||
|
||||
|
|
@ -734,8 +763,23 @@ vi_edit_and_execute_command (count, c)
|
|||
|
||||
return r;
|
||||
}
|
||||
|
||||
#if defined (VI_MODE)
|
||||
static int
|
||||
vi_edit_and_execute_command (count, c)
|
||||
int count, c;
|
||||
{
|
||||
return (edit_and_execute_command (count, c, VI_EDITING_MODE, VI_EDIT_COMMAND));
|
||||
}
|
||||
#endif /* VI_MODE */
|
||||
|
||||
static int
|
||||
emacs_edit_and_execute_command (count, c)
|
||||
int count, c;
|
||||
{
|
||||
return (edit_and_execute_command (count, c, EMACS_EDITING_MODE, EMACS_EDIT_COMMAND));
|
||||
}
|
||||
|
||||
#if defined (ALIAS)
|
||||
static int
|
||||
posix_edit_macros (count, key)
|
||||
|
|
@ -927,7 +971,7 @@ attempt_shell_completion (text, start, end)
|
|||
#if defined (PROGRAMMABLE_COMPLETION)
|
||||
/* Attempt programmable completion. */
|
||||
if (!matches && in_command_position == 0 && prog_completion_enabled &&
|
||||
(num_progcomps () > 0) && current_prompt_string == ps1_prompt)
|
||||
(progcomp_size () > 0) && current_prompt_string == ps1_prompt)
|
||||
{
|
||||
int s, e, foundcs;
|
||||
char *n;
|
||||
|
|
@ -955,6 +999,9 @@ attempt_shell_completion (text, start, end)
|
|||
sure that readline knows it. */
|
||||
if (foundcs & COPT_FILENAMES)
|
||||
rl_filename_completion_desired = 1;
|
||||
/* If the user doesn't want a space appended, tell readline. */
|
||||
if (foundcs & COPT_NOSPACE)
|
||||
rl_completion_suppress_append = 1;
|
||||
/* Turn what the programmable completion code returns into what
|
||||
readline wants. I should have made compute_lcd_of_matches
|
||||
external... */
|
||||
|
|
@ -977,7 +1024,7 @@ attempt_shell_completion (text, start, end)
|
|||
|
||||
/* If the word starts in `~', and there is no slash in the word, then
|
||||
try completing this word as a username. */
|
||||
if (!matches && *text == '~' && !strchr (text, '/'))
|
||||
if (!matches && *text == '~' && !xstrchr (text, '/'))
|
||||
matches = rl_completion_matches (text, rl_username_completion_function);
|
||||
|
||||
/* Another one. Why not? If the word starts in '@', then look through
|
||||
|
|
@ -1005,6 +1052,25 @@ attempt_shell_completion (text, start, end)
|
|||
filenames and leave directories in the match list. */
|
||||
if (matches == (char **)NULL)
|
||||
rl_ignore_some_completions_function = bash_ignore_filenames;
|
||||
else if (matches[1] == 0 && *matches[0] != '/')
|
||||
/* Turn off rl_filename_completion_desired so readline doesn't
|
||||
append a slash if there is a directory with the same name
|
||||
in the current directory, or other filename-specific things.
|
||||
If the name begins with a slash, we're either completing a
|
||||
full pathname or a directory pathname, and readline won't be
|
||||
looking in the current directory anyway, so there's no
|
||||
conflict. */
|
||||
rl_filename_completion_desired = 0;
|
||||
else if (matches[0] && matches[1] && STREQ (matches[0], matches[1]) && *matches[0] != '/')
|
||||
/* There are multiple instances of the same match (duplicate
|
||||
completions haven't yet been removed). In this case, all of
|
||||
the matches will be the same, and the duplicate removal code
|
||||
will distill them all down to one. We turn off
|
||||
rl_filename_completion_desired for the same reason as above.
|
||||
Remember: we only care if there's eventually a single unique
|
||||
completion. If there are multiple completions this won't
|
||||
make a difference and the problem won't occur. */
|
||||
rl_filename_completion_desired = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1015,9 +1081,9 @@ attempt_shell_completion (text, start, end)
|
|||
matches = rl_completion_matches (text, glob_complete_word);
|
||||
/* A glob expression that matches more than one filename is problematic.
|
||||
If we match more than one filename, punt. */
|
||||
if (matches && matches[1])
|
||||
if (matches && matches[1] && rl_completion_type == TAB)
|
||||
{
|
||||
free_array (matches);
|
||||
strvec_dispose (matches);
|
||||
matches = (char **)0;
|
||||
}
|
||||
}
|
||||
|
|
@ -1064,7 +1130,7 @@ command_word_completion_function (hint_text, state)
|
|||
/* Perform tilde expansion on what's passed, so we don't end up
|
||||
passing filenames with tildes directly to stat(). */
|
||||
if (*hint_text == '~')
|
||||
hint = bash_tilde_expand (hint_text);
|
||||
hint = bash_tilde_expand (hint_text, 0);
|
||||
else
|
||||
hint = savestring (hint_text);
|
||||
hint_len = strlen (hint);
|
||||
|
|
@ -1195,7 +1261,7 @@ command_word_completion_function (hint_text, state)
|
|||
{
|
||||
char *t;
|
||||
|
||||
t = bash_tilde_expand (current_path);
|
||||
t = bash_tilde_expand (current_path, 0);
|
||||
free (current_path);
|
||||
current_path = t;
|
||||
}
|
||||
|
|
@ -1203,8 +1269,7 @@ command_word_completion_function (hint_text, state)
|
|||
if (filename_hint)
|
||||
free (filename_hint);
|
||||
|
||||
filename_hint = (char *)xmalloc (2 + strlen (current_path) + hint_len);
|
||||
sprintf (filename_hint, "%s/%s", current_path, hint);
|
||||
filename_hint = sh_makepath (current_path, hint, 0);
|
||||
|
||||
free (current_path);
|
||||
}
|
||||
|
|
@ -1304,8 +1369,31 @@ command_subst_completion_function (text, state)
|
|||
filename_text = savestring (text);
|
||||
if (matches)
|
||||
free (matches);
|
||||
|
||||
/*
|
||||
* At this point we can entertain the idea of re-parsing
|
||||
* `filename_text' into a (possibly incomplete) command name and
|
||||
* arguments, and doing completion based on that. This is
|
||||
* currently very rudimentary, but it is a small improvement.
|
||||
*/
|
||||
for (value = filename_text + strlen (filename_text) - 1; value > filename_text; value--)
|
||||
if (whitespace (*value) || member (*value, COMMAND_SEPARATORS))
|
||||
break;
|
||||
if (value <= filename_text)
|
||||
matches = rl_completion_matches (filename_text, command_word_completion_function);
|
||||
cmd_index = 0;
|
||||
else
|
||||
{
|
||||
value++;
|
||||
start_len += value - filename_text;
|
||||
if (whitespace (value[-1]))
|
||||
matches = rl_completion_matches (value, rl_filename_completion_function);
|
||||
else
|
||||
matches = rl_completion_matches (value, command_word_completion_function);
|
||||
}
|
||||
|
||||
/* If there is more than one match, rl_completion_matches has already
|
||||
put the lcd in matches[0]. Skip over it. */
|
||||
cmd_index = matches && matches[0] && matches[1];
|
||||
}
|
||||
|
||||
if (!matches || !matches[cmd_index])
|
||||
|
|
@ -1359,7 +1447,7 @@ variable_completion_function (text, state)
|
|||
|
||||
namelen = strlen (varname);
|
||||
if (varlist)
|
||||
free_array (varlist);
|
||||
strvec_dispose (varlist);
|
||||
|
||||
varlist = all_variables_matching_prefix (varname);
|
||||
varlist_index = 0;
|
||||
|
|
@ -1432,6 +1520,67 @@ hostname_completion_function (text, state)
|
|||
return ((char *)NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* A completion function for service names from /etc/services (or wherever).
|
||||
*/
|
||||
char *
|
||||
bash_servicename_completion_function (text, state)
|
||||
const char *text;
|
||||
int state;
|
||||
{
|
||||
#if defined (__WIN32__) || defined (__OPENNT) || !defined (HAVE_GETSERVENT)
|
||||
return ((char *)NULL);
|
||||
#else
|
||||
static char *sname = (char *)NULL;
|
||||
static struct servent *srvent;
|
||||
static int snamelen, firstc;
|
||||
char *value;
|
||||
char **alist, *aentry;
|
||||
int afound;
|
||||
|
||||
if (state == 0)
|
||||
{
|
||||
FREE (sname);
|
||||
firstc = *text;
|
||||
|
||||
sname = savestring (text);
|
||||
snamelen = strlen (sname);
|
||||
setservent (0);
|
||||
}
|
||||
|
||||
while (srvent = getservent ())
|
||||
{
|
||||
afound = 0;
|
||||
if (snamelen == 0 || (STREQN (sname, srvent->s_name, snamelen)))
|
||||
break;
|
||||
/* Not primary, check aliases */
|
||||
for (alist = srvent->s_aliases; aentry = *alist; alist++)
|
||||
{
|
||||
if (STREQN (sname, aentry, snamelen))
|
||||
{
|
||||
afound = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (afound)
|
||||
break;
|
||||
}
|
||||
|
||||
if (srvent == 0)
|
||||
{
|
||||
endservent ();
|
||||
return ((char *)NULL);
|
||||
}
|
||||
|
||||
value = afound ? savestring (aentry) : savestring (srvent->s_name);
|
||||
return value;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* A completion function for group names from /etc/group (or wherever).
|
||||
*/
|
||||
char *
|
||||
bash_groupname_completion_function (text, state)
|
||||
const char *text;
|
||||
|
|
@ -1516,7 +1665,7 @@ maybe_make_readline_line (new_line)
|
|||
|
||||
rl_add_undo (UNDO_BEGIN, 0, 0, 0);
|
||||
rl_delete_text (0, rl_point);
|
||||
rl_point = rl_end = 0;
|
||||
rl_point = rl_end = rl_mark = 0;
|
||||
rl_insert_text (new_line);
|
||||
rl_add_undo (UNDO_END, 0, 0, 0);
|
||||
}
|
||||
|
|
@ -1777,9 +1926,9 @@ _ignore_completion_names (names, name_func)
|
|||
filenames. The pointers are copied back to NAMES when done. */
|
||||
for (nidx = 1; names[nidx]; nidx++)
|
||||
;
|
||||
newnames = alloc_array (nidx + 1);
|
||||
newnames = strvec_create (nidx + 1);
|
||||
#ifdef NO_FORCE_FIGNORE
|
||||
oldnames = alloc_array (nidx - 1);
|
||||
oldnames = strvec_create (nidx - 1);
|
||||
oidx = 0;
|
||||
#endif
|
||||
|
||||
|
|
@ -1887,7 +2036,7 @@ test_for_directory (name)
|
|||
struct stat finfo;
|
||||
char *fn;
|
||||
|
||||
fn = bash_tilde_expand (name);
|
||||
fn = bash_tilde_expand (name, 0);
|
||||
if (stat (fn, &finfo) != 0)
|
||||
{
|
||||
free (fn);
|
||||
|
|
@ -1935,13 +2084,13 @@ bash_directory_completion_hook (dirname)
|
|||
local_dirname = *dirname;
|
||||
|
||||
#if 0
|
||||
should_expand_dirname = strchr (local_dirname, '$') || strchr (local_dirname, '`');
|
||||
should_expand_dirname = xstrchr (local_dirname, '$') || xstrchr (local_dirname, '`');
|
||||
#else
|
||||
if (strchr (local_dirname, '$'))
|
||||
if (xstrchr (local_dirname, '$'))
|
||||
should_expand_dirname = 1;
|
||||
else
|
||||
{
|
||||
t = strchr (local_dirname, '`');
|
||||
t = xstrchr (local_dirname, '`');
|
||||
if (t && unclosed_pair (local_dirname, strlen (local_dirname), "`") == 0)
|
||||
should_expand_dirname = 1;
|
||||
}
|
||||
|
|
@ -1950,7 +2099,7 @@ bash_directory_completion_hook (dirname)
|
|||
if (should_expand_dirname)
|
||||
{
|
||||
new_dirname = savestring (local_dirname);
|
||||
wl = expand_string (new_dirname, 0);
|
||||
wl = expand_prompt_string (new_dirname, 0); /* does the right thing */
|
||||
if (wl)
|
||||
{
|
||||
*dirname = string_list (wl);
|
||||
|
|
@ -2016,11 +2165,7 @@ build_history_completion_array ()
|
|||
/* First, clear out the current dynamic history completion list. */
|
||||
if (harry_size)
|
||||
{
|
||||
for (i = 0; history_completion_array[i]; i++)
|
||||
free (history_completion_array[i]);
|
||||
|
||||
free (history_completion_array);
|
||||
|
||||
strvec_dispose (history_completion_array);
|
||||
history_completion_array = (char **)NULL;
|
||||
harry_size = 0;
|
||||
harry_len = 0;
|
||||
|
|
@ -2040,11 +2185,7 @@ build_history_completion_array ()
|
|||
for (j = 0; tokens && tokens[j]; j++)
|
||||
{
|
||||
if (harry_len + 2 > harry_size)
|
||||
{
|
||||
harry_size += 10;
|
||||
history_completion_array = (char **)xrealloc
|
||||
(history_completion_array, harry_size * sizeof (char *));
|
||||
}
|
||||
history_completion_array = strvec_resize (history_completion_array, harry_size += 10);
|
||||
|
||||
history_completion_array[harry_len++] = tokens[j];
|
||||
history_completion_array[harry_len] = (char *)NULL;
|
||||
|
|
@ -2053,7 +2194,7 @@ build_history_completion_array ()
|
|||
}
|
||||
|
||||
/* Sort the complete list of tokens. */
|
||||
qsort (history_completion_array, harry_len, sizeof (char *), (QSFUNC *)qsort_string_compare);
|
||||
qsort (history_completion_array, harry_len, sizeof (char *), (QSFUNC *)strvec_strcmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2097,6 +2238,7 @@ dynamic_complete_history (count, key)
|
|||
rl_completion_entry_function = history_completion_generator;
|
||||
rl_attempted_completion_function = (rl_completion_func_t *)NULL;
|
||||
|
||||
/* XXX - use rl_completion_mode here? */
|
||||
if (rl_last_func == dynamic_complete_history)
|
||||
r = rl_complete_internal ('?');
|
||||
else
|
||||
|
|
@ -2112,7 +2254,7 @@ static int
|
|||
bash_complete_username (ignore, ignore2)
|
||||
int ignore, ignore2;
|
||||
{
|
||||
return bash_complete_username_internal (TAB);
|
||||
return bash_complete_username_internal (rl_completion_mode (bash_complete_username));
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -2133,7 +2275,7 @@ static int
|
|||
bash_complete_filename (ignore, ignore2)
|
||||
int ignore, ignore2;
|
||||
{
|
||||
return bash_complete_filename_internal (TAB);
|
||||
return bash_complete_filename_internal (rl_completion_mode (bash_complete_filename));
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -2176,7 +2318,7 @@ static int
|
|||
bash_complete_hostname (ignore, ignore2)
|
||||
int ignore, ignore2;
|
||||
{
|
||||
return bash_complete_hostname_internal (TAB);
|
||||
return bash_complete_hostname_internal (rl_completion_mode (bash_complete_hostname));
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -2190,7 +2332,7 @@ static int
|
|||
bash_complete_variable (ignore, ignore2)
|
||||
int ignore, ignore2;
|
||||
{
|
||||
return bash_complete_variable_internal (TAB);
|
||||
return bash_complete_variable_internal (rl_completion_mode (bash_complete_variable));
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -2204,7 +2346,7 @@ static int
|
|||
bash_complete_command (ignore, ignore2)
|
||||
int ignore, ignore2;
|
||||
{
|
||||
return bash_complete_command_internal (TAB);
|
||||
return bash_complete_command_internal (rl_completion_mode (bash_complete_command));
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -2235,6 +2377,9 @@ bash_complete_command_internal (what_to_do)
|
|||
return bash_specific_completion (what_to_do, command_word_completion_function);
|
||||
}
|
||||
|
||||
static char *globtext;
|
||||
static char *globorig;
|
||||
|
||||
static char *
|
||||
glob_complete_word (text, state)
|
||||
const char *text;
|
||||
|
|
@ -2242,14 +2387,30 @@ glob_complete_word (text, state)
|
|||
{
|
||||
static char **matches = (char **)NULL;
|
||||
static int ind;
|
||||
int glen;
|
||||
char *ret;
|
||||
|
||||
if (state == 0)
|
||||
{
|
||||
rl_filename_completion_desired = 1;
|
||||
if (matches)
|
||||
free (matches);
|
||||
matches = shell_glob_filename (text);
|
||||
FREE (matches);
|
||||
if (globorig != globtext)
|
||||
FREE (globorig);
|
||||
FREE (globtext);
|
||||
|
||||
if (rl_explicit_arg)
|
||||
{
|
||||
globorig = savestring (text);
|
||||
glen = strlen (text);
|
||||
globtext = (char *)xmalloc (glen + 2);
|
||||
strcpy (globtext, text);
|
||||
globtext[glen] = '*';
|
||||
globtext[glen+1] = '\0';
|
||||
}
|
||||
else
|
||||
globtext = globorig = savestring (text);
|
||||
|
||||
matches = shell_glob_filename (globtext);
|
||||
if (GLOB_FAILED (matches))
|
||||
matches = (char **)NULL;
|
||||
ind = 0;
|
||||
|
|
@ -2267,6 +2428,37 @@ bash_glob_completion_internal (what_to_do)
|
|||
return bash_specific_completion (what_to_do, glob_complete_word);
|
||||
}
|
||||
|
||||
/* A special quoting function so we don't end up quoting globbing characters
|
||||
in the word if there are no matches or multiple matches. */
|
||||
static char *
|
||||
bash_glob_quote_filename (s, rtype, qcp)
|
||||
char *s;
|
||||
int rtype;
|
||||
char *qcp;
|
||||
{
|
||||
if (globorig && qcp && *qcp == '\0' && STREQ (s, globorig))
|
||||
return (savestring (s));
|
||||
else
|
||||
return (bash_quote_filename (s, rtype, qcp));
|
||||
}
|
||||
|
||||
static int
|
||||
bash_glob_complete_word (count, key)
|
||||
int count, key;
|
||||
{
|
||||
int r;
|
||||
rl_quote_func_t *orig_quoting_function;
|
||||
|
||||
rl_explicit_arg = 1; /* force `*' append */
|
||||
orig_quoting_function = rl_filename_quoting_function;
|
||||
rl_filename_quoting_function = bash_glob_quote_filename;
|
||||
|
||||
r = bash_glob_completion_internal (rl_completion_mode (bash_glob_complete_word));
|
||||
|
||||
rl_filename_quoting_function = orig_quoting_function;
|
||||
return r;
|
||||
}
|
||||
|
||||
static int
|
||||
bash_glob_expand_word (count, key)
|
||||
int count, key;
|
||||
|
|
@ -2372,7 +2564,7 @@ quote_word_break_chars (text)
|
|||
}
|
||||
/* OK, we have an unquoted character. Check its presence in
|
||||
rl_completer_word_break_characters. */
|
||||
if (strchr (rl_completer_word_break_characters, *s))
|
||||
if (xstrchr (rl_completer_word_break_characters, *s))
|
||||
*r++ = '\\';
|
||||
*r++ = *s;
|
||||
}
|
||||
|
|
@ -2384,7 +2576,8 @@ quote_word_break_chars (text)
|
|||
depending on the value of completion_quoting_style. If we're
|
||||
completing using backslashes, we need to quote some additional
|
||||
characters (those that readline treats as word breaks), so we call
|
||||
quote_word_break_chars on the result. */
|
||||
quote_word_break_chars on the result. This returns newly-allocated
|
||||
memory. */
|
||||
static char *
|
||||
bash_quote_filename (s, rtype, qcp)
|
||||
char *s;
|
||||
|
|
@ -2405,7 +2598,7 @@ bash_quote_filename (s, rtype, qcp)
|
|||
|
||||
mtext = s;
|
||||
if (mtext[0] == '~' && rtype == SINGLE_MATCH)
|
||||
mtext = bash_tilde_expand (s);
|
||||
mtext = bash_tilde_expand (s, 0);
|
||||
|
||||
cs = completion_quoting_style;
|
||||
/* Might need to modify the default completion style based on *qcp,
|
||||
|
|
@ -2414,7 +2607,7 @@ bash_quote_filename (s, rtype, qcp)
|
|||
the word being completed contains newlines, since those are not
|
||||
quoted correctly using backslashes (a backslash-newline pair is
|
||||
special to the shell parser). */
|
||||
if (*qcp == '\0' && cs == COMPLETE_BSQUOTE && strchr (mtext, '\n'))
|
||||
if (*qcp == '\0' && cs == COMPLETE_BSQUOTE && xstrchr (mtext, '\n'))
|
||||
cs = COMPLETE_SQUOTE;
|
||||
else if (*qcp == '"')
|
||||
cs = COMPLETE_DQUOTE;
|
||||
|
|
@ -2422,11 +2615,11 @@ bash_quote_filename (s, rtype, qcp)
|
|||
cs = COMPLETE_SQUOTE;
|
||||
#if defined (BANG_HISTORY)
|
||||
else if (*qcp == '\0' && history_expansion && cs == COMPLETE_DQUOTE &&
|
||||
history_expansion_inhibited == 0 && strchr (mtext, '!'))
|
||||
history_expansion_inhibited == 0 && xstrchr (mtext, '!'))
|
||||
cs = COMPLETE_BSQUOTE;
|
||||
|
||||
if (*qcp == '"' && history_expansion && cs == COMPLETE_DQUOTE &&
|
||||
history_expansion_inhibited == 0 && strchr (mtext, '!'))
|
||||
history_expansion_inhibited == 0 && xstrchr (mtext, '!'))
|
||||
{
|
||||
cs = COMPLETE_BSQUOTE;
|
||||
*qcp = '\0';
|
||||
|
|
@ -2483,6 +2676,8 @@ bash_execute_unix_command (count, key)
|
|||
Keymap xkmap; /* unix command executing keymap */
|
||||
register int i;
|
||||
char *cmd;
|
||||
int old_line_count;
|
||||
int *ts;
|
||||
|
||||
/* First, we need to find the right command to execute. This is tricky,
|
||||
because we might have already indirected into another keymap. */
|
||||
|
|
@ -2518,8 +2713,14 @@ bash_execute_unix_command (count, key)
|
|||
|
||||
rl_crlf (); /* move to a new line */
|
||||
|
||||
old_line_count = current_command_line_count;
|
||||
ts = save_token_state ();
|
||||
|
||||
cmd = savestring (cmd);
|
||||
parse_and_execute (cmd, "bash_execute_unix_command", 0);
|
||||
parse_and_execute (cmd, "bash_execute_unix_command", SEVAL_NOHIST);
|
||||
|
||||
current_command_line_count = old_line_count;
|
||||
restore_token_state (ts);
|
||||
|
||||
/* and restore the readline buffer and display after command execution. */
|
||||
rl_forced_update_display ();
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ extern int bind_keyseq_to_unix_command __P((char *));
|
|||
/* Used by programmable completion code. */
|
||||
extern char *command_word_completion_function __P((const char *, int));
|
||||
extern char *bash_groupname_completion_function __P((const char *, int));
|
||||
extern char *bash_servicename_completion_function __P((const char *, int));
|
||||
|
||||
extern char **get_hostname_list __P((void));
|
||||
extern void clear_hostname_list __P((void));
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* bashtypes.h -- <sys/types.h> with special handling for crays. */
|
||||
/* bashtypes.h -- Bash system types. */
|
||||
|
||||
/* Copyright (C) 1993 Free Software Foundation, Inc.
|
||||
|
||||
|
|
@ -31,4 +31,8 @@
|
|||
# undef word
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_INTTYPES_H)
|
||||
# include <inttypes.h>
|
||||
#endif
|
||||
|
||||
#endif /* _BASHTYPES_H_ */
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ hack_braces_completion (names)
|
|||
register int i;
|
||||
char *temp;
|
||||
|
||||
temp = really_munge_braces (names, 1, array_len (names), 0);
|
||||
temp = really_munge_braces (names, 1, strvec_len (names), 0);
|
||||
|
||||
for (i = 0; names[i]; ++i)
|
||||
{
|
||||
|
|
|
|||
87
braces.c
87
braces.c
|
|
@ -1,6 +1,6 @@
|
|||
/* braces.c -- code for doing word expansion in curly braces. */
|
||||
|
||||
/* Copyright (C) 1987,1991 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -38,6 +38,8 @@
|
|||
#endif /* SHELL */
|
||||
|
||||
#include "general.h"
|
||||
#include "shmbutil.h"
|
||||
|
||||
#define brace_whitespace(c) (!(c) || (c) == ' ' || (c) == '\t' || (c) == '\n')
|
||||
|
||||
/* Basic idea:
|
||||
|
|
@ -53,8 +55,8 @@
|
|||
int brace_arg_separator = ',';
|
||||
|
||||
#if defined (__P)
|
||||
static int brace_gobbler __P((char *, int *, int));
|
||||
static char **expand_amble __P((char *));
|
||||
static int brace_gobbler __P((char *, size_t, int *, int));
|
||||
static char **expand_amble __P((char *, size_t));
|
||||
static char **array_concat __P((char **, char **));
|
||||
#else
|
||||
static int brace_gobbler ();
|
||||
|
|
@ -68,13 +70,18 @@ brace_expand (text)
|
|||
char *text;
|
||||
{
|
||||
register int start;
|
||||
size_t tlen;
|
||||
char *preamble, *postamble, *amble;
|
||||
size_t alen;
|
||||
char **tack, **result;
|
||||
int i, j, c;
|
||||
|
||||
DECLARE_MBSTATE;
|
||||
|
||||
/* Find the text of the preamble. */
|
||||
tlen = strlen (text);
|
||||
i = 0;
|
||||
c = brace_gobbler (text, &i, '{');
|
||||
c = brace_gobbler (text, tlen, &i, '{');
|
||||
|
||||
preamble = (char *)xmalloc (i + 1);
|
||||
strncpy (preamble, text, i);
|
||||
|
|
@ -91,7 +98,7 @@ brace_expand (text)
|
|||
|
||||
/* Find the amble. This is the stuff inside this set of braces. */
|
||||
start = ++i;
|
||||
c = brace_gobbler (text, &i, '}');
|
||||
c = brace_gobbler (text, tlen, &i, '}');
|
||||
|
||||
/* What if there isn't a matching close brace? */
|
||||
if (c == 0)
|
||||
|
|
@ -99,20 +106,23 @@ brace_expand (text)
|
|||
#if defined (NOTDEF)
|
||||
/* Well, if we found an unquoted BRACE_ARG_SEPARATOR between START
|
||||
and I, then this should be an error. Otherwise, it isn't. */
|
||||
for (j = start; j < i; j++)
|
||||
j = start;
|
||||
while (j < i)
|
||||
{
|
||||
if (text[j] == '\\')
|
||||
{
|
||||
j++;
|
||||
ADVANCE_CHAR (text, tlen, j);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (text[j] == brace_arg_separator)
|
||||
{
|
||||
free_array (result);
|
||||
strvec_dispose (result);
|
||||
report_error ("missing `}'");
|
||||
throw_to_top_level ();
|
||||
}
|
||||
ADVANCE_CHAR (text, tlen, j);
|
||||
}
|
||||
#endif
|
||||
free (preamble); /* Same as result[0]; see initialization. */
|
||||
|
|
@ -122,24 +132,33 @@ brace_expand (text)
|
|||
|
||||
#if defined (SHELL)
|
||||
amble = substring (text, start, i);
|
||||
alen = i - start;
|
||||
#else
|
||||
amble = (char *)xmalloc (1 + (i - start));
|
||||
strncpy (amble, &text[start], (i - start));
|
||||
amble[i - start] = '\0';
|
||||
alen = i - start;
|
||||
amble[alen] = '\0';
|
||||
#endif
|
||||
|
||||
#if defined (SHELL)
|
||||
INITIALIZE_MBSTATE;
|
||||
|
||||
/* If the amble does not contain an unquoted BRACE_ARG_SEPARATOR, then
|
||||
just return without doing any expansion. */
|
||||
for (j = 0; amble[j]; j++)
|
||||
j = 0;
|
||||
while (amble[j])
|
||||
{
|
||||
if (amble[j] == '\\')
|
||||
{
|
||||
j++;
|
||||
ADVANCE_CHAR (amble, alen, j);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (amble[j] == brace_arg_separator)
|
||||
break;
|
||||
|
||||
ADVANCE_CHAR (amble, alen, j);
|
||||
}
|
||||
|
||||
if (!amble[j])
|
||||
|
|
@ -153,14 +172,14 @@ brace_expand (text)
|
|||
|
||||
postamble = &text[i + 1];
|
||||
|
||||
tack = expand_amble (amble);
|
||||
tack = expand_amble (amble, alen);
|
||||
result = array_concat (result, tack);
|
||||
free (amble);
|
||||
free_array (tack);
|
||||
strvec_dispose (tack);
|
||||
|
||||
tack = brace_expand (postamble);
|
||||
result = array_concat (result, tack);
|
||||
free_array (tack);
|
||||
strvec_dispose (tack);
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
|
@ -170,18 +189,23 @@ brace_expand (text)
|
|||
expand each slot which needs it, until there are no more slots which
|
||||
need it. */
|
||||
static char **
|
||||
expand_amble (text)
|
||||
expand_amble (text, tlen)
|
||||
char *text;
|
||||
size_t tlen;
|
||||
{
|
||||
char **result, **partial;
|
||||
char *tem;
|
||||
int start, i, c;
|
||||
|
||||
DECLARE_MBSTATE;
|
||||
|
||||
result = (char **)NULL;
|
||||
|
||||
for (start = 0, i = 0, c = 1; c; start = ++i)
|
||||
start = i = 0;
|
||||
c = 1;
|
||||
while (c)
|
||||
{
|
||||
c = brace_gobbler (text, &i, brace_arg_separator);
|
||||
c = brace_gobbler (text, tlen, &i, brace_arg_separator);
|
||||
#if defined (SHELL)
|
||||
tem = substring (text, start, i);
|
||||
#else
|
||||
|
|
@ -196,11 +220,11 @@ expand_amble (text)
|
|||
result = partial;
|
||||
else
|
||||
{
|
||||
register int lr = array_len (result);
|
||||
register int lp = array_len (partial);
|
||||
register int lr = strvec_len (result);
|
||||
register int lp = strvec_len (partial);
|
||||
register int j;
|
||||
|
||||
result = (char **)xrealloc (result, (1 + lp + lr) * sizeof (char *));
|
||||
result = strvec_resize (result, lp + lr + 1);
|
||||
|
||||
for (j = 0; j < lp; j++)
|
||||
result[lr + j] = partial[j];
|
||||
|
|
@ -209,6 +233,8 @@ expand_amble (text)
|
|||
free (partial);
|
||||
}
|
||||
free (tem);
|
||||
ADVANCE_CHAR (text, tlen, i);
|
||||
start = i;
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
|
@ -218,8 +244,9 @@ expand_amble (text)
|
|||
quoting. Return the character that caused us to stop searching;
|
||||
this is either the same as SATISFY, or 0. */
|
||||
static int
|
||||
brace_gobbler (text, indx, satisfy)
|
||||
brace_gobbler (text, tlen, indx, satisfy)
|
||||
char *text;
|
||||
size_t tlen;
|
||||
int *indx;
|
||||
int satisfy;
|
||||
{
|
||||
|
|
@ -228,14 +255,17 @@ brace_gobbler (text, indx, satisfy)
|
|||
int si;
|
||||
char *t;
|
||||
#endif
|
||||
DECLARE_MBSTATE;
|
||||
|
||||
level = quoted = pass_next = 0;
|
||||
|
||||
for (i = *indx; c = text[i]; i++)
|
||||
i = *indx;
|
||||
while (c = text[i])
|
||||
{
|
||||
if (pass_next)
|
||||
{
|
||||
pass_next = 0;
|
||||
ADVANCE_CHAR (text, tlen, i);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -244,6 +274,7 @@ brace_gobbler (text, indx, satisfy)
|
|||
if (c == '\\' && (quoted == 0 || quoted == '"' || quoted == '`'))
|
||||
{
|
||||
pass_next = 1;
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -251,12 +282,14 @@ brace_gobbler (text, indx, satisfy)
|
|||
{
|
||||
if (c == quoted)
|
||||
quoted = 0;
|
||||
ADVANCE_CHAR (text, tlen, i);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c == '"' || c == '\'' || c == '`')
|
||||
{
|
||||
quoted = c;
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -268,6 +301,7 @@ brace_gobbler (text, indx, satisfy)
|
|||
t = extract_command_subst (text, &si);
|
||||
i = si;
|
||||
free (t);
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -280,7 +314,10 @@ brace_gobbler (text, indx, satisfy)
|
|||
if (c == '{' &&
|
||||
((!i || brace_whitespace (text[i - 1])) &&
|
||||
(brace_whitespace (text[i + 1]) || text[i + 1] == '}')))
|
||||
{
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
#if defined (SHELL)
|
||||
/* If this is being compiled as part of bash, ignore the `{'
|
||||
in a `${}' construct */
|
||||
|
|
@ -293,6 +330,8 @@ brace_gobbler (text, indx, satisfy)
|
|||
level++;
|
||||
else if (c == '}' && level)
|
||||
level--;
|
||||
|
||||
ADVANCE_CHAR (text, tlen, i);
|
||||
}
|
||||
|
||||
*indx = i;
|
||||
|
|
@ -312,13 +351,13 @@ array_concat (arr1, arr2)
|
|||
register char **result;
|
||||
|
||||
if (arr1 == 0)
|
||||
return (copy_array (arr2));
|
||||
return (strvec_copy (arr2));
|
||||
|
||||
if (arr2 == 0)
|
||||
return (copy_array (arr1));
|
||||
return (strvec_copy (arr1));
|
||||
|
||||
len1 = array_len (arr1);
|
||||
len2 = array_len (arr2);
|
||||
len1 = strvec_len (arr1);
|
||||
len2 = strvec_len (arr2);
|
||||
|
||||
result = (char **)xmalloc ((1 + (len1 * len2)) * sizeof (char *));
|
||||
|
||||
|
|
|
|||
|
|
@ -46,8 +46,8 @@ struct builtin {
|
|||
char *name; /* The name that the user types. */
|
||||
sh_builtin_func_t *function; /* The address of the invoked function. */
|
||||
int flags; /* One of the #defines above. */
|
||||
char **long_doc; /* NULL terminated array of strings. */
|
||||
char *short_doc; /* Short version of documenation. */
|
||||
char * const *long_doc; /* NULL terminated array of strings. */
|
||||
const char *short_doc; /* Short version of documenation. */
|
||||
char *handle; /* for future use */
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -28,32 +28,52 @@ CP = cp
|
|||
|
||||
EXEEXT = @EXEEXT@
|
||||
|
||||
prefix = @prefix@
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = .:@srcdir@
|
||||
topdir = @top_srcdir@
|
||||
includedir = @includedir@
|
||||
datadir = @datadir@
|
||||
|
||||
# Support an alternate destination root directory for package building
|
||||
DESTDIR =
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
BUILD_DIR = @BUILD_DIR@
|
||||
|
||||
PROFILE_FLAGS = @PROFILE_FLAGS@
|
||||
CFLAGS = @CFLAGS@
|
||||
LOCAL_CFLAGS = @LOCAL_CFLAGS@ ${DEBUG}
|
||||
CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CPPFLAGS_FOR_BUILD = @CPPFLAGS_FOR_BUILD@
|
||||
LOCAL_CFLAGS = @LOCAL_CFLAGS@ ${DEBUG}
|
||||
DEFS = @DEFS@
|
||||
LOCAL_DEFS = @LOCAL_DEFS@
|
||||
LDFLAGS = @LDFLAGS@ $(LOCAL_LDFLAGS) $(CFLAGS)
|
||||
LOCAL_LDFLAGS = @LOCAL_LDFLAGS@
|
||||
|
||||
LIBS = @LIBS@
|
||||
LDFLAGS = @LDFLAGS@ $(LOCAL_LDFLAGS) $(CFLAGS)
|
||||
LDFLAGS_FOR_BUILD = $(LDFLAGS)
|
||||
LOCAL_LDFLAGS = @LOCAL_LDFLAGS@
|
||||
#LIBS_FOR_BUILD = @LIBS_FOR_BUILD@
|
||||
LIBS_FOR_BUILD = $(LIBS)
|
||||
|
||||
BASHINCDIR = ${topdir}/include
|
||||
|
||||
RL_INCLUDEDIR = @RL_INCLUDEDIR@
|
||||
|
||||
HELPDIR = @HELPDIR@
|
||||
MKDIRS = ${topdir}/support/mkdirs
|
||||
|
||||
INCLUDES = -I. -I.. @RL_INCLUDE@ -I$(topdir) -I$(BASHINCDIR) -I$(topdir)/lib -I$(srcdir)
|
||||
|
||||
CCFLAGS_FOR_BUILD = ${PROFILE_FLAGS} $(DEFS) $(LOCAL_DEFS) $(SYSTEM_FLAGS) \
|
||||
$(CPPFLAGS) ${INCLUDES} $(LOCAL_CFLAGS)
|
||||
BASE_CCFLAGS = ${PROFILE_FLAGS} $(DEFS) $(LOCAL_DEFS) $(SYSTEM_FLAGS) \
|
||||
${INCLUDES} $(LOCAL_CFLAGS)
|
||||
|
||||
CCFLAGS = $(CCFLAGS_FOR_BUILD) $(CFLAGS)
|
||||
CCFLAGS = $(BASE_CCFLAGS) $(CPPFLAGS) $(CFLAGS)
|
||||
|
||||
CCFLAGS_FOR_BUILD = $(BASE_CCFLAGS) $(CPPFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD)
|
||||
|
||||
GCC_LINT_FLAGS = -Wall -Wshadow -Wpointer-arith -Wcast-qual \
|
||||
-Wcast-align -Wstrict-prototypes -Wconversion \
|
||||
|
|
@ -61,6 +81,7 @@ GCC_LINT_FLAGS = -Wall -Wshadow -Wpointer-arith -Wcast-qual \
|
|||
|
||||
MKBUILTINS = mkbuiltins$(EXEEXT)
|
||||
DIRECTDEFINE = -D $(srcdir)
|
||||
HELPDIRDEFINE = @HELPDIRDEFINE@
|
||||
|
||||
# xxx this is bad style
|
||||
RL_LIBSRC = $(topdir)/lib/readline
|
||||
|
|
@ -124,7 +145,7 @@ 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
|
||||
./$(MKBUILTINS) -externfile builtext.h -structfile builtins.c \
|
||||
-noproduction $(DIRECTDEFINE) $(DEFSRC)
|
||||
-noproduction $(DIRECTDEFINE) $(HELPDIRDEFINE) $(DEFSRC)
|
||||
@-if cmp -s old-builtext.h builtext.h 2>/dev/null; then \
|
||||
mv old-builtext.h builtext.h; \
|
||||
else \
|
||||
|
|
@ -136,13 +157,28 @@ builtext.h builtins.c: $(MKBUILTINS) $(DEFSRC)
|
|||
$(RM) old-builtins.c; \
|
||||
fi
|
||||
|
||||
helpdoc: $(MKBUILTINS) $(DEFSRC)
|
||||
./$(MKBUILTINS) ${HELPDIRDEFINE} -noproduction $(DIRECTDEFINE) $(DEFSRC)
|
||||
|
||||
install-help:
|
||||
@-if test -n "${HELPDIR}" && test -d helpfiles ; then \
|
||||
test -d ${HELPDIR} || ${SHELL} ${MKDIRS} $(DESTDIR)$(HELPDIR) ;\
|
||||
( cd helpfiles ; \
|
||||
for f in *; do \
|
||||
echo installing $$f; \
|
||||
${INSTALL_DATA} $$f $(DESTDIR)$(HELPDIR); \
|
||||
done; ) ; \
|
||||
fi
|
||||
|
||||
install: @HELPINSTALL@
|
||||
|
||||
mkbuiltins.o: ../config.h
|
||||
mkbuiltins.o: mkbuiltins.c
|
||||
$(RM) $@
|
||||
$(CC_FOR_BUILD) -c $(CCFLAGS_FOR_BUILD) $<
|
||||
|
||||
mkbuiltins$(EXEEXT): mkbuiltins.o
|
||||
$(CC_FOR_BUILD) $(PROFILE_FLAGS) $(LDFLAGS) -o $(MKBUILTINS) mkbuiltins.o $(LIBS)
|
||||
$(CC_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $(MKBUILTINS) mkbuiltins.o $(LIBS_FOR_BUILD)
|
||||
|
||||
# rules for deficient makes, like SunOS
|
||||
mkbuiltins.o: mkbuiltins.c
|
||||
|
|
@ -163,13 +199,12 @@ psize.aux: psize.c
|
|||
|
||||
documentation: builtins.texi
|
||||
|
||||
$(OFILES): $(MKBUILTINS) ../config.h
|
||||
|
||||
builtins.texi: $(MKBUILTINS)
|
||||
./$(MKBUILTINS) -documentonly $(DEFSRC)
|
||||
|
||||
clean:
|
||||
$(RM) $(OFILES) $(CREATED_FILES) $(MKBUILTINS) mkbuiltins.o libbuiltins.a
|
||||
-test -d helpfiles && $(RM) -r helpfiles
|
||||
|
||||
mostlyclean:
|
||||
$(RM) $(OFILES) libbuiltins.a
|
||||
|
|
@ -177,6 +212,8 @@ mostlyclean:
|
|||
distclean maintainer-clean: clean
|
||||
$(RM) Makefile
|
||||
|
||||
$(OFILES): $(MKBUILTINS) ../config.h
|
||||
|
||||
alias.o: alias.def
|
||||
bind.o: bind.def
|
||||
break.o: break.def
|
||||
|
|
@ -293,6 +330,7 @@ builtin.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/e
|
|||
builtin.o: $(topdir)/quit.h $(srcdir)/common.h $(BASHINCDIR)/maxpath.h
|
||||
builtin.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
|
||||
builtin.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
|
||||
builtin.o: $(srcdir)/bashgetopt.h
|
||||
cd.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
|
||||
cd.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/quit.h $(topdir)/dispose_cmd.h
|
||||
cd.o: $(topdir)/make_cmd.h $(topdir)/subst.h $(topdir)/externs.h
|
||||
|
|
@ -308,7 +346,7 @@ declare.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
|
|||
declare.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
|
||||
declare.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
|
||||
declare.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
|
||||
declare.o: $(topdir)/arrayfunc.h
|
||||
declare.o: $(topdir)/arrayfunc.h $(srcdir)/bashgetopt.h
|
||||
echo.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
|
||||
echo.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/subst.h $(topdir)/externs.h
|
||||
echo.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
|
||||
|
|
@ -351,7 +389,7 @@ fc.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
|
|||
fc.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/shell.h $(topdir)/syntax.h
|
||||
fc.o: $(topdir)/flags.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
|
||||
fc.o: $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h $(BASHINCDIR)/chartypes.h
|
||||
fg_bg.o: $(topdir)/bashtypes.h
|
||||
fg_bg.o: $(topdir)/bashtypes.h $(srcdir)/bashgetopt.h
|
||||
fg_bg.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
|
||||
fg_bg.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
|
||||
fg_bg.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
|
||||
|
|
@ -373,7 +411,7 @@ help.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
|
|||
help.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
|
||||
help.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
|
||||
help.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
|
||||
help.o: ${srcdir}/common.h ../version.h
|
||||
help.o: ${srcdir}/common.h
|
||||
history.o: $(topdir)/bashtypes.h
|
||||
history.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
|
||||
history.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
|
||||
|
|
@ -449,6 +487,7 @@ source.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/fi
|
|||
source.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
|
||||
source.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
|
||||
source.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
|
||||
source.o: $(srcdir)/bashgetopt.h
|
||||
suspend.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
|
||||
suspend.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
|
||||
suspend.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is alias.def, from which is created alias.c
|
||||
It implements the builtins "alias" and "unalias" in Bash.
|
||||
|
||||
Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -120,7 +120,7 @@ alias_builtin (list)
|
|||
print_alias (t);
|
||||
else
|
||||
{
|
||||
builtin_error ("`%s' not found", name);
|
||||
sh_notfound (name);
|
||||
any_failed++;
|
||||
}
|
||||
}
|
||||
|
|
@ -180,7 +180,7 @@ unalias_builtin (list)
|
|||
remove_alias (alias->name);
|
||||
else
|
||||
{
|
||||
builtin_error ("`%s': not an alias", list->word->word);
|
||||
sh_notfound (list->word->word);
|
||||
aflag++;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* bashgetopt.c -- `getopt' for use by the builtins. */
|
||||
|
||||
/* Copyright (C) 1992 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1992-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -31,12 +31,14 @@ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
|||
#include "../shell.h"
|
||||
#include "common.h"
|
||||
|
||||
#define ERR(S, C) builtin_error("%s%c", (S), (C))
|
||||
#define ISOPT(s) (((*(s) == '-') || (plus && *(s) == '+')) && (s)[1])
|
||||
#define NOTOPT(s) (((*(s) != '-') && (!plus || *(s) != '+')) || (s)[1] == '\0')
|
||||
|
||||
static int sp;
|
||||
|
||||
char *list_optarg;
|
||||
int list_optopt;
|
||||
int list_opttype;
|
||||
|
||||
static WORD_LIST *lhead = (WORD_LIST *)NULL;
|
||||
WORD_LIST *lcurrent = (WORD_LIST *)NULL;
|
||||
|
|
@ -50,12 +52,11 @@ char *opts;
|
|||
register int c;
|
||||
register char *cp;
|
||||
int plus; /* nonzero means to handle +option */
|
||||
static char errstr[3] = { '-', '\0', '\0' };
|
||||
|
||||
if (*opts == '+') {
|
||||
plus = 1;
|
||||
plus = *opts == '+';
|
||||
if (plus)
|
||||
opts++;
|
||||
} else
|
||||
plus = 0;
|
||||
|
||||
if (list == 0) {
|
||||
list_optarg = (char *)NULL;
|
||||
|
|
@ -71,8 +72,7 @@ char *opts;
|
|||
}
|
||||
|
||||
if (sp == 1) {
|
||||
if (lcurrent == 0 ||
|
||||
(lcurrent->word->word[0] != '-' || lcurrent->word->word[1] == '\0')) {
|
||||
if (lcurrent == 0 || NOTOPT(lcurrent->word->word)) {
|
||||
lhead = (WORD_LIST *)NULL;
|
||||
loptend = lcurrent;
|
||||
return(-1);
|
||||
|
|
@ -83,12 +83,14 @@ char *opts;
|
|||
loptend = lcurrent->next;
|
||||
return(-1);
|
||||
}
|
||||
errstr[0] = list_opttype = lcurrent->word->word[0];
|
||||
}
|
||||
|
||||
list_optopt = c = lcurrent->word->word[sp];
|
||||
|
||||
if (c == ':' || (cp = strchr(opts, c)) == NULL) {
|
||||
ERR("illegal option: -", c);
|
||||
errstr[1] = c;
|
||||
sh_invalidopt (errstr);
|
||||
if (lcurrent->word->word[++sp] == '\0') {
|
||||
lcurrent = lcurrent->next;
|
||||
sp = 1;
|
||||
|
|
@ -108,7 +110,11 @@ char *opts;
|
|||
lcurrent = lcurrent->next;
|
||||
/* If the specifier is `;', don't set optarg if the next
|
||||
argument looks like another option. */
|
||||
#if 0
|
||||
} else if (lcurrent->next && (*cp == ':' || lcurrent->next->word->word[0] != '-')) {
|
||||
#else
|
||||
} else if (lcurrent->next && (*cp == ':' || NOTOPT(lcurrent->next->word->word))) {
|
||||
#endif
|
||||
lcurrent = lcurrent->next;
|
||||
list_optarg = lcurrent->word->word;
|
||||
lcurrent = lcurrent->next;
|
||||
|
|
@ -116,14 +122,15 @@ char *opts;
|
|||
list_optarg = (char *)NULL;
|
||||
lcurrent = lcurrent->next;
|
||||
} else { /* lcurrent->next == NULL */
|
||||
ERR("option requires an argument: -", c);
|
||||
errstr[1] = c;
|
||||
sh_needarg (errstr);
|
||||
sp = 1;
|
||||
list_optarg = (char *)NULL;
|
||||
return('?');
|
||||
}
|
||||
sp = 1;
|
||||
} else if (*cp == '#') {
|
||||
/* optional numeric argument */
|
||||
/* option requires a numeric argument */
|
||||
if (lcurrent->word->word[sp+1]) {
|
||||
if (DIGIT(lcurrent->word->word[sp+1])) {
|
||||
list_optarg = lcurrent->word->word + sp + 1;
|
||||
|
|
@ -131,12 +138,17 @@ char *opts;
|
|||
} else
|
||||
list_optarg = (char *)NULL;
|
||||
} else {
|
||||
if (lcurrent->next && legal_number(lcurrent->next->word->word, (long *)0)) {
|
||||
if (lcurrent->next && legal_number(lcurrent->next->word->word, (intmax_t *)0)) {
|
||||
lcurrent = lcurrent->next;
|
||||
list_optarg = lcurrent->word->word;
|
||||
lcurrent = lcurrent->next;
|
||||
} else
|
||||
} else {
|
||||
errstr[1] = c;
|
||||
sh_neednumarg (errstr);
|
||||
sp = 1;
|
||||
list_optarg = (char *)NULL;
|
||||
return ('?');
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
|
@ -161,16 +173,3 @@ reset_internal_getopt ()
|
|||
lhead = lcurrent = loptend = (WORD_LIST *)NULL;
|
||||
sp = 1;
|
||||
}
|
||||
|
||||
#ifdef INCLUDE_UNUSED
|
||||
void
|
||||
report_bad_option ()
|
||||
{
|
||||
char s[3];
|
||||
|
||||
s[0] = '-';
|
||||
s[1] = list_optopt;
|
||||
s[2] = '\0';
|
||||
bad_option (s);
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -28,12 +28,12 @@
|
|||
extern char *list_optarg;
|
||||
|
||||
extern int list_optopt;
|
||||
extern int list_opttype;
|
||||
|
||||
extern WORD_LIST *lcurrent;
|
||||
extern WORD_LIST *loptend;
|
||||
|
||||
extern int internal_getopt __P((WORD_LIST *, char *));
|
||||
extern void reset_internal_getopt __P((void));
|
||||
extern void report_bad_option __P((void));
|
||||
|
||||
#endif /* !__BASH_GETOPT_H */
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is bind.def, from which is created bind.c.
|
||||
It implements the builtin "bind" in Bash.
|
||||
|
||||
Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -26,11 +26,12 @@ $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]
|
||||
Bind a key sequence to a Readline function, or to a macro. The
|
||||
syntax is equivalent to that found in ~/.inputrc, but must be
|
||||
passed as a single argument: bind '"\C-x\C-r": re-read-init-file'.
|
||||
Arguments we accept:
|
||||
$SHORT_DOC bind [-lpvsPVS] [-m keymap] [-f filename] [-q name] [-u name] [-r keyseq] [-x keyseq:shell-command] [keyseq:readline-function or readline-command]
|
||||
Bind a key sequence to a Readline function or a macro, or set
|
||||
a Readline variable. The non-option argument syntax is equivalent
|
||||
to that found in ~/.inputrc, but must be passed as a single argument:
|
||||
bind '"\C-x\C-r": re-read-init-file'.
|
||||
bind accepts the following options:
|
||||
-m keymap Use `keymap' as the keymap for the duration of this
|
||||
command. Acceptable keymap names are emacs,
|
||||
emacs-standard, emacs-meta, emacs-ctlx, vi, vi-move,
|
||||
|
|
@ -40,8 +41,8 @@ Arguments we accept:
|
|||
-p List functions and bindings in a form that can be
|
||||
reused as input.
|
||||
-r keyseq Remove the binding for KEYSEQ.
|
||||
-x keyseq:shell-command Cause SHELL-COMMAND to be executed when KEYSEQ
|
||||
is entered.
|
||||
-x keyseq:shell-command Cause SHELL-COMMAND to be executed when
|
||||
KEYSEQ is entered.
|
||||
-f filename Read key bindings from FILENAME.
|
||||
-q function-name Query about which keys invoke the named function.
|
||||
-u function-name Unbind all keys which are bound to the named function.
|
||||
|
|
@ -49,8 +50,8 @@ Arguments we accept:
|
|||
-v List variable names and values in a form that can
|
||||
be reused as input.
|
||||
-S List key sequences that invoke macros and their values
|
||||
-s List key sequences that invoke macros and their values in
|
||||
a form that can be reused as input.
|
||||
-s List key sequences that invoke macros and their values
|
||||
in a form that can be reused as input.
|
||||
$END
|
||||
|
||||
#if defined (READLINE)
|
||||
|
|
@ -227,7 +228,7 @@ bind_builtin (list)
|
|||
{
|
||||
if (rl_read_init_file (initfile) != 0)
|
||||
{
|
||||
builtin_error ("cannot read %s: %s", initfile, strerror (errno));
|
||||
builtin_error ("%s: cannot read: %s", initfile, strerror (errno));
|
||||
BIND_RETURN (EXECUTION_FAILURE);
|
||||
}
|
||||
}
|
||||
|
|
@ -242,7 +243,7 @@ bind_builtin (list)
|
|||
{
|
||||
if (rl_set_key (remove_seq, (rl_command_func_t *)NULL, rl_get_keymap ()) != 0)
|
||||
{
|
||||
builtin_error ("cannot unbind %s", remove_seq);
|
||||
builtin_error ("`%s': cannot unbind", remove_seq);
|
||||
BIND_RETURN (EXECUTION_FAILURE);
|
||||
}
|
||||
}
|
||||
|
|
@ -277,7 +278,7 @@ query_bindings (name)
|
|||
function = rl_named_function (name);
|
||||
if (function == 0)
|
||||
{
|
||||
builtin_error ("unknown function name `%s'", name);
|
||||
builtin_error ("`%s': unknown function name", name);
|
||||
return EXECUTION_FAILURE;
|
||||
}
|
||||
|
||||
|
|
@ -294,7 +295,7 @@ query_bindings (name)
|
|||
printf ("\"%s\"%s", keyseqs[j], keyseqs[j + 1] ? ", " : ".\n");
|
||||
if (keyseqs[j])
|
||||
printf ("...\n");
|
||||
free_array (keyseqs);
|
||||
strvec_dispose (keyseqs);
|
||||
return EXECUTION_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
@ -307,7 +308,7 @@ unbind_command (name)
|
|||
function = rl_named_function (name);
|
||||
if (function == 0)
|
||||
{
|
||||
builtin_error ("unknown function name `%s'", name);
|
||||
builtin_error ("`%s': unknown function name", name);
|
||||
return EXECUTION_FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is break.def, from which is created break.c.
|
||||
It implements the builtins "break" and "continue" in Bash.
|
||||
|
||||
Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -59,7 +59,7 @@ int
|
|||
break_builtin (list)
|
||||
WORD_LIST *list;
|
||||
{
|
||||
long newbreak;
|
||||
intmax_t newbreak;
|
||||
|
||||
if (check_loop_level () == 0)
|
||||
return (EXECUTION_SUCCESS);
|
||||
|
|
@ -68,7 +68,7 @@ break_builtin (list)
|
|||
|
||||
if (newbreak <= 0)
|
||||
{
|
||||
builtin_error ("loop count must be > 0");
|
||||
sh_erange (list->word->word, "loop count");
|
||||
breaking = loop_level;
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
|
@ -94,7 +94,7 @@ int
|
|||
continue_builtin (list)
|
||||
WORD_LIST *list;
|
||||
{
|
||||
long newcont;
|
||||
intmax_t newcont;
|
||||
|
||||
if (check_loop_level () == 0)
|
||||
return (EXECUTION_SUCCESS);
|
||||
|
|
@ -103,7 +103,7 @@ continue_builtin (list)
|
|||
|
||||
if (newcont <= 0)
|
||||
{
|
||||
builtin_error ("loop count must be > 0");
|
||||
sh_erange (list->word->word, "loop count");
|
||||
breaking = loop_level;
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is builtin.def, from which is created builtin.c.
|
||||
It implements the builtin "builtin" in Bash.
|
||||
|
||||
Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -39,6 +39,7 @@ $END
|
|||
|
||||
#include "../shell.h"
|
||||
#include "common.h"
|
||||
#include "bashgetopt.h"
|
||||
|
||||
extern char *this_command_name;
|
||||
|
||||
|
|
@ -51,10 +52,14 @@ builtin_builtin (list)
|
|||
sh_builtin_func_t *function;
|
||||
register char *command;
|
||||
|
||||
if (!list)
|
||||
if (no_options (list))
|
||||
return (EX_USAGE);
|
||||
list = loptend; /* skip over possible `--' */
|
||||
|
||||
if (list == 0)
|
||||
return (EXECUTION_SUCCESS);
|
||||
|
||||
command = (list->word->word);
|
||||
command = list->word->word;
|
||||
#if defined (DISABLED_BUILTINS)
|
||||
function = builtin_address (command);
|
||||
#else /* !DISABLED_BUILTINS */
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ int cdable_vars;
|
|||
|
||||
$BUILTIN cd
|
||||
$FUNCTION cd_builtin
|
||||
$SHORT_DOC cd [-PL] [dir]
|
||||
$SHORT_DOC cd [-L|-P] [dir]
|
||||
Change the current directory to DIR. The variable $HOME is the
|
||||
default DIR. The variable CDPATH defines the search path for
|
||||
the directory containing DIR. Alternative directory names in CDPATH
|
||||
|
|
@ -118,6 +118,19 @@ bindpwd (no_symlinks)
|
|||
return (EXECUTION_SUCCESS);
|
||||
}
|
||||
|
||||
/* Call get_working_directory to reset the value of
|
||||
the_current_working_directory () */
|
||||
static char *
|
||||
resetpwd ()
|
||||
{
|
||||
char *tdir;
|
||||
|
||||
FREE (the_current_working_directory);
|
||||
the_current_working_directory = (char *)NULL;
|
||||
tdir = get_working_directory ("cd");
|
||||
return (tdir);
|
||||
}
|
||||
|
||||
#define LCD_DOVARS 0x001
|
||||
#define LCD_DOSPELL 0x002
|
||||
#define LCD_PRINTPATH 0x004
|
||||
|
|
@ -137,7 +150,7 @@ cd_builtin (list)
|
|||
#if defined (RESTRICTED_SHELL)
|
||||
if (restricted)
|
||||
{
|
||||
builtin_error ("restricted");
|
||||
sh_restricted ((char *)NULL);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
#endif /* RESTRICTED_SHELL */
|
||||
|
|
@ -350,7 +363,7 @@ change_to_directory (newdir, nolinks)
|
|||
int nolinks;
|
||||
{
|
||||
char *t, *tdir;
|
||||
int err;
|
||||
int err, canon_failed;
|
||||
|
||||
tdir = (char *)NULL;
|
||||
|
||||
|
|
@ -370,19 +383,37 @@ change_to_directory (newdir, nolinks)
|
|||
|
||||
/* Use the canonicalized version of NEWDIR, or, if canonicalization
|
||||
failed, use the non-canonical form. */
|
||||
canon_failed = 0;
|
||||
if (tdir && *tdir)
|
||||
free (t);
|
||||
else
|
||||
{
|
||||
FREE (tdir);
|
||||
tdir = t;
|
||||
canon_failed = 1;
|
||||
}
|
||||
|
||||
/* In POSIX mode, if we're resolving symlinks logically and sh_canonpath
|
||||
returns NULL (because it checks the path, it will return NULL if the
|
||||
resolved path doesn't exist), fail immediately. */
|
||||
if (posixly_correct && nolinks == 0 && canon_failed)
|
||||
{
|
||||
errno = ENOENT;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* If the chdir succeeds, update the_current_working_directory. */
|
||||
if (chdir (nolinks ? newdir : tdir) == 0)
|
||||
{
|
||||
/* If canonicalization failed, but the chdir succeeded, reset the
|
||||
shell's idea of the_current_working_directory. */
|
||||
if (canon_failed)
|
||||
resetpwd ();
|
||||
else
|
||||
{
|
||||
FREE (the_current_working_directory);
|
||||
the_current_working_directory = tdir;
|
||||
}
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
|
@ -400,9 +431,7 @@ change_to_directory (newdir, nolinks)
|
|||
verbatim. If we succeed, reinitialize the_current_working_directory. */
|
||||
if (chdir (newdir) == 0)
|
||||
{
|
||||
FREE (the_current_working_directory);
|
||||
the_current_working_directory = (char *)NULL;
|
||||
tdir = get_working_directory ("cd");
|
||||
tdir = resetpwd ();
|
||||
FREE (tdir);
|
||||
|
||||
return (1);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is colon.def, from which is created colon.c.
|
||||
It implements the builtin ":" in Bash.
|
||||
|
||||
Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -22,21 +22,19 @@ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
|||
$PRODUCES colon.c
|
||||
|
||||
$BUILTIN :
|
||||
$DOCNAME colon_builtin
|
||||
$DOCNAME colon
|
||||
$FUNCTION colon_builtin
|
||||
$SHORT_DOC :
|
||||
No effect; the command does nothing. A zero exit code is returned.
|
||||
$END
|
||||
|
||||
$BUILTIN true
|
||||
$DOCNAME true_builtin
|
||||
$FUNCTION colon_builtin
|
||||
$SHORT_DOC true
|
||||
Return a successful result.
|
||||
$END
|
||||
|
||||
$BUILTIN false
|
||||
$DOCNAME false_builtin
|
||||
$FUNCTION false_builtin
|
||||
$SHORT_DOC false
|
||||
Return an unsuccessful result.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is command.def, from which is created command.c.
|
||||
It implements the builtin "command" in Bash.
|
||||
|
||||
Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -78,10 +78,10 @@ command_builtin (list)
|
|||
use_standard_path = 1;
|
||||
break;
|
||||
case 'V':
|
||||
verbose = 2;
|
||||
verbose = CDESC_SHORTDESC; /* look in common.h for constants */
|
||||
break;
|
||||
case 'v':
|
||||
verbose = 4;
|
||||
verbose = CDESC_REUSABLE; /* ditto */
|
||||
break;
|
||||
default:
|
||||
builtin_usage ();
|
||||
|
|
@ -99,10 +99,10 @@ command_builtin (list)
|
|||
|
||||
for (any_found = 0; list; list = list->next)
|
||||
{
|
||||
found = describe_command (list->word->word, verbose, 0);
|
||||
found = describe_command (list->word->word, verbose);
|
||||
|
||||
if (found == 0)
|
||||
builtin_error ("%s: not found", list->word->word);
|
||||
sh_notfound (list->word->word);
|
||||
|
||||
any_found += found;
|
||||
}
|
||||
|
|
@ -112,7 +112,7 @@ command_builtin (list)
|
|||
#if defined (RESTRICTED_SHELL)
|
||||
if (use_standard_path && restricted)
|
||||
{
|
||||
builtin_error ("restricted: cannot use -p");
|
||||
sh_restricted ("-p");
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -36,10 +36,8 @@
|
|||
#if defined (PREFER_STDARG)
|
||||
# include <stdarg.h>
|
||||
#else
|
||||
# if defined (PREFER_VARARGS)
|
||||
# include <varargs.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "../bashansi.h"
|
||||
|
||||
|
|
@ -64,8 +62,7 @@
|
|||
extern int errno;
|
||||
#endif /* !errno */
|
||||
|
||||
extern int no_symbolic_links;
|
||||
extern int indirection_level, startup_state, subshell_environment;
|
||||
extern int indirection_level, subshell_environment;
|
||||
extern int line_number;
|
||||
extern int last_command_exit_value;
|
||||
extern int running_trap;
|
||||
|
|
@ -86,7 +83,6 @@ sh_builtin_func_t *this_shell_builtin = (sh_builtin_func_t *)NULL;
|
|||
/* This is a lot like report_error (), but it is for shell builtins
|
||||
instead of shell control structures, and it won't ever exit the
|
||||
shell. */
|
||||
#if defined (USE_VARARGS)
|
||||
void
|
||||
#if defined (PREFER_STDARG)
|
||||
builtin_error (const char *format, ...)
|
||||
|
|
@ -102,32 +98,18 @@ builtin_error (format, va_alist)
|
|||
name = get_name_for_error ();
|
||||
fprintf (stderr, "%s: ", name);
|
||||
|
||||
if (interactive_shell == 0)
|
||||
fprintf (stderr, "line %d: ", executing_line_number ());
|
||||
|
||||
if (this_command_name && *this_command_name)
|
||||
fprintf (stderr, "%s: ", this_command_name);
|
||||
|
||||
#if defined (PREFER_STDARG)
|
||||
va_start (args, format);
|
||||
#else
|
||||
va_start (args);
|
||||
#endif
|
||||
SH_VA_START (args, format);
|
||||
|
||||
vfprintf (stderr, format, args);
|
||||
va_end (args);
|
||||
fprintf (stderr, "\n");
|
||||
}
|
||||
#else /* !USE_VARARGS */
|
||||
void
|
||||
builtin_error (format, arg1, arg2, arg3, arg4, arg5)
|
||||
char *format, *arg1, *arg2, *arg3, *arg4, *arg5;
|
||||
{
|
||||
if (this_command_name && *this_command_name)
|
||||
fprintf (stderr, "%s: ", this_command_name);
|
||||
|
||||
fprintf (stderr, format, arg1, arg2, arg3, arg4, arg5);
|
||||
fprintf (stderr, "\n");
|
||||
fflush (stderr);
|
||||
}
|
||||
#endif /* !USE_VARARGS */
|
||||
|
||||
/* Print a usage summary for the currently-executing builtin command. */
|
||||
void
|
||||
|
|
@ -152,15 +134,6 @@ no_args (list)
|
|||
}
|
||||
}
|
||||
|
||||
/* Function called when one of the builtin commands detects a bad
|
||||
option. */
|
||||
void
|
||||
bad_option (s)
|
||||
char *s;
|
||||
{
|
||||
builtin_error ("unknown option: %s", s);
|
||||
}
|
||||
|
||||
/* Check that no options were given to the currently-executing builtin,
|
||||
and return 0 if there were options. */
|
||||
int
|
||||
|
|
@ -176,6 +149,119 @@ no_options (list)
|
|||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
sh_needarg (s)
|
||||
char *s;
|
||||
{
|
||||
builtin_error ("%s: option requires an argument", s);
|
||||
}
|
||||
|
||||
void
|
||||
sh_neednumarg (s)
|
||||
char *s;
|
||||
{
|
||||
builtin_error ("%s: numeric argument required", s);
|
||||
}
|
||||
|
||||
void
|
||||
sh_notfound (s)
|
||||
char *s;
|
||||
{
|
||||
builtin_error ("%s: not found", s);
|
||||
}
|
||||
|
||||
/* Function called when one of the builtin commands detects an invalid
|
||||
option. */
|
||||
void
|
||||
sh_invalidopt (s)
|
||||
char *s;
|
||||
{
|
||||
builtin_error ("%s: invalid option", s);
|
||||
}
|
||||
|
||||
void
|
||||
sh_invalidoptname (s)
|
||||
char *s;
|
||||
{
|
||||
builtin_error ("%s: invalid option name", s);
|
||||
}
|
||||
|
||||
void
|
||||
sh_invalidid (s)
|
||||
char *s;
|
||||
{
|
||||
builtin_error ("`%s': not a valid identifier", s);
|
||||
}
|
||||
|
||||
void
|
||||
sh_invalidnum (s)
|
||||
char *s;
|
||||
{
|
||||
builtin_error ("%s: invalid number", s);
|
||||
}
|
||||
|
||||
void
|
||||
sh_invalidsig (s)
|
||||
char *s;
|
||||
{
|
||||
builtin_error ("%s: invalid signal specification", s);
|
||||
}
|
||||
|
||||
void
|
||||
sh_badpid (s)
|
||||
char *s;
|
||||
{
|
||||
builtin_error ("`%s': not a pid or valid job spec", s);
|
||||
}
|
||||
|
||||
void
|
||||
sh_readonly (s)
|
||||
const char *s;
|
||||
{
|
||||
builtin_error ("%s: readonly variable", s);
|
||||
}
|
||||
|
||||
void
|
||||
sh_erange (s, desc)
|
||||
char *s, *desc;
|
||||
{
|
||||
if (s)
|
||||
builtin_error ("%s: %s out of range", s, desc ? desc : "argument");
|
||||
else
|
||||
builtin_error ("%s out of range", desc ? desc : "argument");
|
||||
}
|
||||
|
||||
#if defined (JOB_CONTROL)
|
||||
void
|
||||
sh_badjob (s)
|
||||
char *s;
|
||||
{
|
||||
builtin_error ("%s: no such job", s);
|
||||
}
|
||||
|
||||
void
|
||||
sh_nojobs (s)
|
||||
char *s;
|
||||
{
|
||||
if (s)
|
||||
builtin_error ("%s: no job control");
|
||||
else
|
||||
builtin_error ("no job control");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (RESTRICTED_SHELL)
|
||||
void
|
||||
sh_restricted (s)
|
||||
char *s;
|
||||
{
|
||||
if (s)
|
||||
builtin_error ("%s: restricted", s);
|
||||
else
|
||||
builtin_error ("restricted");
|
||||
}
|
||||
#endif
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Shell positional parameter manipulation */
|
||||
|
|
@ -192,7 +278,7 @@ make_builtin_argv (list, ip)
|
|||
{
|
||||
char **argv;
|
||||
|
||||
argv = word_list_to_argv (list, 0, 1, ip);
|
||||
argv = strvec_from_word_list (list, 0, 1, ip);
|
||||
argv[0] = this_command_name;
|
||||
return argv;
|
||||
}
|
||||
|
|
@ -235,67 +321,6 @@ remember_args (list, destructive)
|
|||
set_dollar_vars_changed ();
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Pushing and Popping variable contexts */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
static WORD_LIST **dollar_arg_stack = (WORD_LIST **)NULL;
|
||||
static int dollar_arg_stack_slots;
|
||||
static int dollar_arg_stack_index;
|
||||
|
||||
void
|
||||
push_context ()
|
||||
{
|
||||
push_dollar_vars ();
|
||||
variable_context++;
|
||||
}
|
||||
|
||||
void
|
||||
pop_context ()
|
||||
{
|
||||
pop_dollar_vars ();
|
||||
kill_all_local_variables ();
|
||||
variable_context--;
|
||||
}
|
||||
|
||||
/* Save the existing positional parameters on a stack. */
|
||||
void
|
||||
push_dollar_vars ()
|
||||
{
|
||||
if (dollar_arg_stack_index + 2 > dollar_arg_stack_slots)
|
||||
{
|
||||
dollar_arg_stack = (WORD_LIST **)
|
||||
xrealloc (dollar_arg_stack, (dollar_arg_stack_slots += 10)
|
||||
* sizeof (WORD_LIST **));
|
||||
}
|
||||
dollar_arg_stack[dollar_arg_stack_index++] = list_rest_of_args ();
|
||||
dollar_arg_stack[dollar_arg_stack_index] = (WORD_LIST *)NULL;
|
||||
}
|
||||
|
||||
/* Restore the positional parameters from our stack. */
|
||||
void
|
||||
pop_dollar_vars ()
|
||||
{
|
||||
if (!dollar_arg_stack || dollar_arg_stack_index == 0)
|
||||
return;
|
||||
|
||||
remember_args (dollar_arg_stack[--dollar_arg_stack_index], 1);
|
||||
dispose_words (dollar_arg_stack[dollar_arg_stack_index]);
|
||||
dollar_arg_stack[dollar_arg_stack_index] = (WORD_LIST *)NULL;
|
||||
}
|
||||
|
||||
void
|
||||
dispose_saved_dollar_vars ()
|
||||
{
|
||||
if (!dollar_arg_stack || dollar_arg_stack_index == 0)
|
||||
return;
|
||||
|
||||
dispose_words (dollar_arg_stack[dollar_arg_stack_index]);
|
||||
dollar_arg_stack[dollar_arg_stack_index] = (WORD_LIST *)NULL;
|
||||
}
|
||||
|
||||
static int changed_dollar_vars;
|
||||
|
||||
/* Have the dollar variables been reset to new values since we last
|
||||
|
|
@ -315,7 +340,12 @@ set_dollar_vars_unchanged ()
|
|||
void
|
||||
set_dollar_vars_changed ()
|
||||
{
|
||||
changed_dollar_vars = 1;
|
||||
if (variable_context)
|
||||
changed_dollar_vars |= ARGS_FUNC;
|
||||
else if (this_shell_builtin == set_builtin)
|
||||
changed_dollar_vars |= ARGS_SETBLTIN;
|
||||
else
|
||||
changed_dollar_vars |= ARGS_INVOC;
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
|
@ -330,21 +360,24 @@ set_dollar_vars_changed ()
|
|||
follow. If FATAL is true, call throw_to_top_level, which exits the
|
||||
shell; if not, call jump_to_top_level (DISCARD), which aborts the
|
||||
current command. */
|
||||
long
|
||||
intmax_t
|
||||
get_numeric_arg (list, fatal)
|
||||
WORD_LIST *list;
|
||||
int fatal;
|
||||
{
|
||||
long count = 1;
|
||||
intmax_t count = 1;
|
||||
|
||||
if (list && list->word && ISOPTION (list->word->word, '-'))
|
||||
list = list->next;
|
||||
|
||||
if (list)
|
||||
{
|
||||
register char *arg;
|
||||
|
||||
arg = list->word->word;
|
||||
if (!arg || (legal_number (arg, &count) == 0))
|
||||
if (arg == 0 || (legal_number (arg, &count) == 0))
|
||||
{
|
||||
builtin_error ("bad non-numeric arg `%s'", list->word->word);
|
||||
sh_neednumarg (list->word->word);
|
||||
if (fatal)
|
||||
throw_to_top_level ();
|
||||
else
|
||||
|
|
@ -362,13 +395,19 @@ get_exitstat (list)
|
|||
WORD_LIST *list;
|
||||
{
|
||||
int status;
|
||||
long sval;
|
||||
intmax_t sval;
|
||||
char *arg;
|
||||
|
||||
if (list && list->word && ISOPTION (list->word->word, '-'))
|
||||
list = list->next;
|
||||
|
||||
if (list == 0)
|
||||
return (last_command_exit_value);
|
||||
|
||||
arg = list->word->word;
|
||||
if (arg == 0 || legal_number (arg, &sval) == 0)
|
||||
{
|
||||
builtin_error ("bad non-numeric arg `%s'", list->word->word);
|
||||
sh_neednumarg (list->word->word ? list->word->word : "`'");
|
||||
return 255;
|
||||
}
|
||||
no_args (list->next);
|
||||
|
|
@ -460,13 +499,65 @@ set_working_directory (name)
|
|||
/* **************************************************************** */
|
||||
|
||||
#if defined (JOB_CONTROL)
|
||||
int
|
||||
get_job_by_name (name, flags)
|
||||
const char *name;
|
||||
int flags;
|
||||
{
|
||||
register int i, wl, cl, match, job;
|
||||
register PROCESS *p;
|
||||
|
||||
job = NO_JOB;
|
||||
wl = strlen (name);
|
||||
for (i = job_slots - 1; i >= 0; i--)
|
||||
{
|
||||
if (jobs[i] == 0 || ((flags & JM_STOPPED) && JOBSTATE(i) != JSTOPPED))
|
||||
continue;
|
||||
|
||||
p = jobs[i]->pipe;
|
||||
do
|
||||
{
|
||||
if (flags & JM_EXACT)
|
||||
{
|
||||
cl = strlen (p->command);
|
||||
match = STREQN (p->command, name, cl);
|
||||
}
|
||||
else if (flags & JM_SUBSTRING)
|
||||
match = strindex (p->command, name) != (char *)0;
|
||||
else
|
||||
match = STREQN (p->command, name, wl);
|
||||
|
||||
if (match == 0)
|
||||
{
|
||||
p = p->next;
|
||||
continue;
|
||||
}
|
||||
else if (flags & JM_FIRSTMATCH)
|
||||
return i; /* return first match */
|
||||
else if (job != NO_JOB)
|
||||
{
|
||||
if (this_shell_builtin)
|
||||
builtin_error ("%s: ambiguous job spec", name);
|
||||
else
|
||||
report_error ("%s: ambiguous job spec", name);
|
||||
return (DUP_JOB);
|
||||
}
|
||||
else
|
||||
job = i;
|
||||
}
|
||||
while (p != jobs[i]->pipe);
|
||||
}
|
||||
|
||||
return (job);
|
||||
}
|
||||
|
||||
/* Return the job spec found in LIST. */
|
||||
int
|
||||
get_job_spec (list)
|
||||
WORD_LIST *list;
|
||||
{
|
||||
register char *word;
|
||||
int job, substring_search;
|
||||
int job, jflags;
|
||||
|
||||
if (list == 0)
|
||||
return (current_job);
|
||||
|
|
@ -482,10 +573,14 @@ get_job_spec (list)
|
|||
if (DIGIT (*word) && all_digits (word))
|
||||
{
|
||||
job = atoi (word);
|
||||
#if 0
|
||||
return (job >= job_slots ? NO_JOB : job - 1);
|
||||
#else
|
||||
return (job > job_slots ? NO_JOB : job - 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
substring_search = 0;
|
||||
jflags = 0;
|
||||
switch (*word)
|
||||
{
|
||||
case 0:
|
||||
|
|
@ -497,43 +592,12 @@ get_job_spec (list)
|
|||
return (previous_job);
|
||||
|
||||
case '?': /* Substring search requested. */
|
||||
substring_search++;
|
||||
jflags |= JM_SUBSTRING;
|
||||
word++;
|
||||
/* FALLTHROUGH */
|
||||
|
||||
default:
|
||||
{
|
||||
register int i, wl;
|
||||
|
||||
job = NO_JOB;
|
||||
wl = strlen (word);
|
||||
for (i = 0; i < job_slots; i++)
|
||||
{
|
||||
if (jobs[i])
|
||||
{
|
||||
register PROCESS *p;
|
||||
p = jobs[i]->pipe;
|
||||
do
|
||||
{
|
||||
if ((substring_search && strindex (p->command, word)) ||
|
||||
(STREQN (p->command, word, wl)))
|
||||
{
|
||||
if (job != NO_JOB)
|
||||
{
|
||||
builtin_error ("ambigious job spec: %s", word);
|
||||
return (DUP_JOB);
|
||||
}
|
||||
else
|
||||
job = i;
|
||||
}
|
||||
|
||||
p = p->next;
|
||||
}
|
||||
while (p != jobs[i]->pipe);
|
||||
}
|
||||
}
|
||||
return (job);
|
||||
}
|
||||
return get_job_by_name (word, jflags);
|
||||
}
|
||||
}
|
||||
#endif /* JOB_CONTROL */
|
||||
|
|
@ -546,7 +610,8 @@ display_signal_list (list, forcecols)
|
|||
register int i, column;
|
||||
char *name;
|
||||
int result;
|
||||
long signum;
|
||||
int signum;
|
||||
intmax_t lsignum;
|
||||
|
||||
result = EXECUTION_SUCCESS;
|
||||
if (!list)
|
||||
|
|
@ -581,20 +646,21 @@ display_signal_list (list, forcecols)
|
|||
/* List individual signal names or numbers. */
|
||||
while (list)
|
||||
{
|
||||
if (legal_number (list->word->word, &signum))
|
||||
if (legal_number (list->word->word, &lsignum))
|
||||
{
|
||||
/* This is specified by Posix.2 so that exit statuses can be
|
||||
mapped into signal numbers. */
|
||||
if (signum > 128)
|
||||
signum -= 128;
|
||||
if (signum < 0 || signum >= NSIG)
|
||||
if (lsignum > 128)
|
||||
lsignum -= 128;
|
||||
if (lsignum < 0 || lsignum >= NSIG)
|
||||
{
|
||||
builtin_error ("bad signal number: %s", list->word->word);
|
||||
sh_invalidsig (list->word->word);
|
||||
result = EXECUTION_FAILURE;
|
||||
list = list->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
signum = lsignum;
|
||||
name = signal_name (signum);
|
||||
if (STREQN (name, "SIGJUNK", 7) || STREQN (name, "Unknown", 7))
|
||||
{
|
||||
|
|
@ -614,12 +680,12 @@ display_signal_list (list, forcecols)
|
|||
signum = decode_signal (list->word->word);
|
||||
if (signum == NO_SIG)
|
||||
{
|
||||
builtin_error ("%s: not a signal specification", list->word->word);
|
||||
sh_invalidsig (list->word->word);
|
||||
result = EXECUTION_FAILURE;
|
||||
list = list->next;
|
||||
continue;
|
||||
}
|
||||
printf ("%ld\n", signum);
|
||||
printf ("%d\n", signum);
|
||||
}
|
||||
list = list->next;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* common.h -- extern declarations for functions defined in common.c. */
|
||||
|
||||
/* Copyright (C) 1993 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1993-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -26,30 +26,63 @@
|
|||
#define ISOPTION(s, c) (s[0] == '-' && !s[2] && s[1] == c)
|
||||
|
||||
/* Flag values for parse_and_execute () */
|
||||
#define SEVAL_NONINT 0x01
|
||||
#define SEVAL_INTERACT 0x02
|
||||
#define SEVAL_NOHIST 0x04
|
||||
#define SEVAL_NONINT 0x001
|
||||
#define SEVAL_INTERACT 0x002
|
||||
#define SEVAL_NOHIST 0x004
|
||||
#define SEVAL_NOFREE 0x008
|
||||
|
||||
/* Flags for describe_command, shared between type.def and command.def */
|
||||
#define CDESC_ALL 0x001 /* type -a */
|
||||
#define CDESC_SHORTDESC 0x002 /* command -V */
|
||||
#define CDESC_REUSABLE 0x004 /* command -v */
|
||||
#define CDESC_TYPE 0x008 /* type -t */
|
||||
#define CDESC_PATH_ONLY 0x010 /* type -p */
|
||||
#define CDESC_FORCE_PATH 0x020 /* type -ap or type -P */
|
||||
#define CDESC_NOFUNCS 0x040 /* type -f */
|
||||
|
||||
/* Flags for get_job_by_name */
|
||||
#define JM_PREFIX 0x01 /* prefix of job name */
|
||||
#define JM_SUBSTRING 0x02 /* substring of job name */
|
||||
#define JM_EXACT 0x04 /* match job name exactly */
|
||||
#define JM_STOPPED 0x08 /* match stopped jobs only */
|
||||
#define JM_FIRSTMATCH 0x10 /* return first matching job */
|
||||
|
||||
/* Flags for remember_args and value of changed_dollar_vars */
|
||||
#define ARGS_NONE 0x0
|
||||
#define ARGS_INVOC 0x01
|
||||
#define ARGS_FUNC 0x02
|
||||
#define ARGS_SETBLTIN 0x04
|
||||
|
||||
/* Functions from common.c */
|
||||
extern void builtin_error __P((const char *, ...)) __attribute__((__format__ (printf, 1, 2)));
|
||||
extern void builtin_usage __P((void));
|
||||
extern void no_args __P((WORD_LIST *));
|
||||
extern void bad_option __P((char *));
|
||||
extern int no_options __P((WORD_LIST *));
|
||||
|
||||
/* common error message functions */
|
||||
extern void sh_needarg __P((char *));
|
||||
extern void sh_neednumarg __P((char *));
|
||||
extern void sh_notfound __P((char *));
|
||||
extern void sh_invalidopt __P((char *));
|
||||
extern void sh_invalidoptname __P((char *));
|
||||
extern void sh_invalidid __P((char *));
|
||||
extern void sh_invalidnum __P((char *));
|
||||
extern void sh_invalidsig __P((char *));
|
||||
extern void sh_erange __P((char *, char *));
|
||||
extern void sh_badpid __P((char *));
|
||||
extern void sh_badjob __P((char *));
|
||||
extern void sh_readonly __P((const char *));
|
||||
extern void sh_nojobs __P((char *));
|
||||
extern void sh_restricted __P((char *));
|
||||
|
||||
extern char **make_builtin_argv __P((WORD_LIST *, int *));
|
||||
extern void remember_args __P((WORD_LIST *, int));
|
||||
|
||||
extern void push_context __P((void));
|
||||
extern void pop_context __P((void));
|
||||
extern void push_dollar_vars __P((void));
|
||||
extern void pop_dollar_vars __P((void));
|
||||
extern void dispose_saved_dollar_vars __P((void));
|
||||
extern int dollar_vars_changed __P((void));
|
||||
extern void set_dollar_vars_unchanged __P((void));
|
||||
extern void set_dollar_vars_changed __P((void));
|
||||
|
||||
extern long get_numeric_arg __P((WORD_LIST *, int));
|
||||
extern intmax_t get_numeric_arg __P((WORD_LIST *, int));
|
||||
extern int get_exitstat __P((WORD_LIST *));
|
||||
extern int read_octal __P((char *));
|
||||
|
||||
|
|
@ -59,6 +92,7 @@ extern char *get_working_directory __P((char *));
|
|||
extern void set_working_directory __P((char *));
|
||||
|
||||
#if defined (JOB_CONTROL)
|
||||
extern int get_job_by_name __P((const char *, int));
|
||||
extern int get_job_spec __P((WORD_LIST *));
|
||||
#endif
|
||||
extern int display_signal_list __P((WORD_LIST *, int));
|
||||
|
|
@ -96,7 +130,7 @@ extern int shopt_listopt __P((char *, int));
|
|||
extern int set_login_shell __P((int));
|
||||
|
||||
/* Functions from type.def */
|
||||
extern int describe_command __P((char *, int, int));
|
||||
extern int describe_command __P((char *, int));
|
||||
|
||||
/* Functions from setattr.def */
|
||||
extern int set_or_show_attributes __P((WORD_LIST *, int, int));
|
||||
|
|
@ -106,8 +140,8 @@ extern void set_var_attribute __P((char *, int, int));
|
|||
|
||||
/* Functions from pushd.def */
|
||||
extern char *get_dirstack_from_string __P((char *));
|
||||
extern char *get_dirstack_element __P((long, int));
|
||||
extern void set_dirstack_element __P((long, int, char *));
|
||||
extern char *get_dirstack_element __P((intmax_t, int));
|
||||
extern void set_dirstack_element __P((intmax_t, int, char *));
|
||||
extern WORD_LIST *get_directory_stack __P((void));
|
||||
|
||||
/* Functions from evalstring.c */
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is complete.def, from which is created complete.c.
|
||||
It implements the builtins "complete" and "compgen" in Bash.
|
||||
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ $PRODUCES complete.c
|
|||
$BUILTIN complete
|
||||
$DEPENDS_ON PROGRAMMABLE_COMPLETION
|
||||
$FUNCTION complete_builtin
|
||||
$SHORT_DOC complete [-abcdefgjkvu] [-pr] [-o option] [-A action] [-G globpat] [-W wordlist] [-P prefix] [-S suffix] [-X filterpat] [-F function] [-C command] [name ...]
|
||||
$SHORT_DOC complete [-abcdefgjksuv] [-pr] [-o option] [-A action] [-G globpat] [-W wordlist] [-P prefix] [-S suffix] [-X filterpat] [-F function] [-C command] [name ...]
|
||||
For each NAME, specify how arguments are to be completed.
|
||||
If the -p option is supplied, or if no options are supplied, existing
|
||||
completion specifications are printed in a way that allows them to be
|
||||
|
|
@ -62,11 +62,12 @@ static int build_actions __P((WORD_LIST *, int *, int *, unsigned long *, unsign
|
|||
|
||||
static int remove_cmd_completions __P((WORD_LIST *));
|
||||
|
||||
static void print_one_completion __P((char *, COMPSPEC *));
|
||||
static int print_one_completion __P((char *, COMPSPEC *));
|
||||
static int print_compitem __P((BUCKET_CONTENTS *));
|
||||
static void print_all_completions __P((void));
|
||||
static int print_cmd_completions __P((WORD_LIST *));
|
||||
|
||||
static char *Aarg, *Garg, *Warg, *Parg, *Sarg, *Xarg, *Farg, *Carg;
|
||||
static char *Garg, *Warg, *Parg, *Sarg, *Xarg, *Farg, *Carg;
|
||||
|
||||
static struct _compacts {
|
||||
char *actname;
|
||||
|
|
@ -90,6 +91,7 @@ static struct _compacts {
|
|||
{ "job", CA_JOB, 'j' },
|
||||
{ "keyword", CA_KEYWORD, 'k' },
|
||||
{ "running", CA_RUNNING, 0 },
|
||||
{ "service", CA_SERVICE, 's' },
|
||||
{ "setopt", CA_SETOPT, 0 },
|
||||
{ "shopt", CA_SHOPT, 0 },
|
||||
{ "signal", CA_SIGNAL, 0 },
|
||||
|
|
@ -99,6 +101,7 @@ static struct _compacts {
|
|||
{ (char *)NULL, 0, 0 },
|
||||
};
|
||||
|
||||
/* This should be a STRING_INT_ALIST */
|
||||
static struct _compopt {
|
||||
char *optname;
|
||||
int optflag;
|
||||
|
|
@ -106,6 +109,7 @@ static struct _compopt {
|
|||
{ "default", COPT_DEFAULT },
|
||||
{ "dirnames", COPT_DIRNAMES },
|
||||
{ "filenames",COPT_FILENAMES},
|
||||
{ "nospace", COPT_NOSPACE },
|
||||
{ (char *)NULL, 0 },
|
||||
};
|
||||
|
||||
|
|
@ -160,7 +164,7 @@ build_actions (list, pp, rp, actp, optp)
|
|||
opt_given = 0;
|
||||
|
||||
reset_internal_getopt ();
|
||||
while ((opt = internal_getopt (list, "abcdefgjko:pruvA:G:W:P:S:X:F:C:")) != -1)
|
||||
while ((opt = internal_getopt (list, "abcdefgjko:prsuvA:G:W:P:S:X:F:C:")) != -1)
|
||||
{
|
||||
opt_given = 1;
|
||||
switch (opt)
|
||||
|
|
@ -173,7 +177,7 @@ build_actions (list, pp, rp, actp, optp)
|
|||
}
|
||||
else
|
||||
{
|
||||
builtin_error ("illegal option: -r");
|
||||
sh_invalidopt ("-r");
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
}
|
||||
|
|
@ -186,7 +190,7 @@ build_actions (list, pp, rp, actp, optp)
|
|||
}
|
||||
else
|
||||
{
|
||||
builtin_error ("illegal option: -p");
|
||||
sh_invalidopt ("-p");
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
}
|
||||
|
|
@ -218,6 +222,9 @@ build_actions (list, pp, rp, actp, optp)
|
|||
case 'k':
|
||||
acts |= CA_KEYWORD;
|
||||
break;
|
||||
case 's':
|
||||
acts |= CA_SERVICE;
|
||||
break;
|
||||
case 'u':
|
||||
acts |= CA_USER;
|
||||
break;
|
||||
|
|
@ -228,7 +235,7 @@ build_actions (list, pp, rp, actp, optp)
|
|||
ind = find_compopt (list_optarg);
|
||||
if (ind < 0)
|
||||
{
|
||||
builtin_error ("%s: invalid option name", list_optarg);
|
||||
sh_invalidoptname (list_optarg);
|
||||
return (EX_USAGE);
|
||||
}
|
||||
copts |= compopts[ind].optflag;
|
||||
|
|
@ -282,7 +289,6 @@ complete_builtin (list)
|
|||
{
|
||||
int opt_given, pflag, rflag, rval;
|
||||
unsigned long acts, copts;
|
||||
char *cmd;
|
||||
COMPSPEC *cs;
|
||||
|
||||
if (list == 0)
|
||||
|
|
@ -293,7 +299,7 @@ complete_builtin (list)
|
|||
|
||||
opt_given = pflag = rflag = 0;
|
||||
acts = copts = (unsigned long)0L;
|
||||
Aarg = Garg = Warg = Parg = Sarg = Xarg = Farg = Carg = (char *)NULL;
|
||||
Garg = Warg = Parg = Sarg = Xarg = Farg = Carg = (char *)NULL;
|
||||
cs = (COMPSPEC *)NULL;
|
||||
|
||||
/* Build the actions from the arguments. Also sets the [A-Z]arg variables
|
||||
|
|
@ -321,7 +327,7 @@ complete_builtin (list)
|
|||
{
|
||||
if (list == 0)
|
||||
{
|
||||
clear_progcomps ();
|
||||
progcomp_flush ();
|
||||
return (EXECUTION_SUCCESS);
|
||||
}
|
||||
return (remove_cmd_completions (list));
|
||||
|
|
@ -335,7 +341,7 @@ complete_builtin (list)
|
|||
|
||||
/* If we get here, we need to build a compspec and add it for each
|
||||
remaining argument. */
|
||||
cs = alloc_compspec ();
|
||||
cs = compspec_create ();
|
||||
cs->actions = acts;
|
||||
cs->options = copts;
|
||||
|
||||
|
|
@ -350,8 +356,7 @@ complete_builtin (list)
|
|||
for (rval = EXECUTION_SUCCESS ; list; list = list->next)
|
||||
{
|
||||
/* Add CS as the compspec for the specified commands. */
|
||||
cmd = list->word->word;
|
||||
if (add_progcomp (cmd, cs) == 0)
|
||||
if (progcomp_insert (list->word->word, cs) == 0)
|
||||
rval = EXECUTION_FAILURE;
|
||||
}
|
||||
|
||||
|
|
@ -367,7 +372,7 @@ remove_cmd_completions (list)
|
|||
|
||||
for (ret = EXECUTION_SUCCESS, l = list; l; l = l->next)
|
||||
{
|
||||
if (remove_progcomp (l->word->word) == 0)
|
||||
if (progcomp_remove (l->word->word) == 0)
|
||||
{
|
||||
builtin_error ("%s: no completion specification", l->word->word);
|
||||
ret = EXECUTION_FAILURE;
|
||||
|
|
@ -410,7 +415,7 @@ remove_cmd_completions (list)
|
|||
printf ("-o %s ", f); \
|
||||
} while (0)
|
||||
|
||||
static void
|
||||
static int
|
||||
print_one_completion (cmd, cs)
|
||||
char *cmd;
|
||||
COMPSPEC *cs;
|
||||
|
|
@ -426,6 +431,7 @@ print_one_completion (cmd, cs)
|
|||
PRINTCOMPOPT (COPT_DEFAULT, "default");
|
||||
PRINTCOMPOPT (COPT_DIRNAMES, "dirnames");
|
||||
PRINTCOMPOPT (COPT_FILENAMES, "filenames");
|
||||
PRINTCOMPOPT (COPT_NOSPACE, "nospace");
|
||||
|
||||
acts = cs->actions;
|
||||
|
||||
|
|
@ -437,8 +443,9 @@ print_one_completion (cmd, cs)
|
|||
PRINTOPT (CA_EXPORT, "-e");
|
||||
PRINTOPT (CA_FILE, "-f");
|
||||
PRINTOPT (CA_GROUP, "-g");
|
||||
PRINTOPT (CA_KEYWORD, "-k");
|
||||
PRINTOPT (CA_JOB, "-j");
|
||||
PRINTOPT (CA_KEYWORD, "-k");
|
||||
PRINTOPT (CA_SERVICE, "-s");
|
||||
PRINTOPT (CA_USER, "-u");
|
||||
PRINTOPT (CA_VARIABLE, "-v");
|
||||
|
||||
|
|
@ -470,12 +477,27 @@ print_one_completion (cmd, cs)
|
|||
PRINTARG (cs->command, "-C");
|
||||
|
||||
printf ("%s\n", cmd);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
print_compitem (item)
|
||||
BUCKET_CONTENTS *item;
|
||||
{
|
||||
COMPSPEC *cs;
|
||||
char *cmd;
|
||||
|
||||
cmd = item->key;
|
||||
cs = (COMPSPEC *)item->data;
|
||||
|
||||
return (print_one_completion (cmd, cs));
|
||||
}
|
||||
|
||||
static void
|
||||
print_all_completions ()
|
||||
{
|
||||
print_all_compspecs (print_one_completion);
|
||||
progcomp_walk (print_compitem);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -488,7 +510,7 @@ print_cmd_completions (list)
|
|||
|
||||
for (ret = EXECUTION_SUCCESS, l = list; l; l = l->next)
|
||||
{
|
||||
cs = find_compspec (l->word->word);
|
||||
cs = progcomp_search (l->word->word);
|
||||
if (cs)
|
||||
print_one_completion (l->word->word, cs);
|
||||
else
|
||||
|
|
@ -503,7 +525,7 @@ print_cmd_completions (list)
|
|||
$BUILTIN compgen
|
||||
$DEPENDS_ON PROGRAMMABLE_COMPLETION
|
||||
$FUNCTION compgen_builtin
|
||||
$SHORT_DOC compgen [-abcdefgjkvu] [-o option] [-A action] [-G globpat] [-W wordlist] [-P prefix] [-S suffix] [-X filterpat] [-F function] [-C command] [word]
|
||||
$SHORT_DOC compgen [-abcdefgjksuv] [-o option] [-A action] [-G globpat] [-W wordlist] [-P prefix] [-S suffix] [-X filterpat] [-F function] [-C command] [word]
|
||||
Display the possible completions depending on the options. Intended
|
||||
to be used from within a shell function generating possible completions.
|
||||
If the optional WORD argument is supplied, matches against WORD are
|
||||
|
|
@ -524,7 +546,7 @@ compgen_builtin (list)
|
|||
return (EXECUTION_SUCCESS);
|
||||
|
||||
acts = copts = (unsigned long)0L;
|
||||
Aarg = Garg = Warg = Parg = Sarg = Xarg = Farg = Carg = (char *)NULL;
|
||||
Garg = Warg = Parg = Sarg = Xarg = Farg = Carg = (char *)NULL;
|
||||
cs = (COMPSPEC *)NULL;
|
||||
|
||||
/* Build the actions from the arguments. Also sets the [A-Z]arg variables
|
||||
|
|
@ -545,7 +567,7 @@ compgen_builtin (list)
|
|||
internal_warning ("compgen: -C option may not work as you expect");
|
||||
|
||||
/* If we get here, we need to build a compspec and evaluate it. */
|
||||
cs = alloc_compspec ();
|
||||
cs = compspec_create ();
|
||||
cs->actions = acts;
|
||||
cs->options = copts;
|
||||
cs->refcount = 1;
|
||||
|
|
@ -569,7 +591,7 @@ compgen_builtin (list)
|
|||
|
||||
matches = rl_completion_matches (word, rl_filename_completion_function);
|
||||
sl = completions_to_stringlist (matches);
|
||||
free_array (matches);
|
||||
strvec_dispose (matches);
|
||||
}
|
||||
|
||||
if (sl)
|
||||
|
|
@ -577,11 +599,11 @@ compgen_builtin (list)
|
|||
if (sl->list && sl->list_len)
|
||||
{
|
||||
rval = EXECUTION_SUCCESS;
|
||||
print_stringlist (sl, (char *)NULL);
|
||||
strlist_print (sl, (char *)NULL);
|
||||
}
|
||||
free_stringlist (sl);
|
||||
strlist_dispose (sl);
|
||||
}
|
||||
|
||||
free_compspec (cs);
|
||||
compspec_dispose (cs);
|
||||
return (rval);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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, 1989, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ $PRODUCES declare.c
|
|||
|
||||
$BUILTIN declare
|
||||
$FUNCTION declare_builtin
|
||||
$SHORT_DOC declare [-afFrxi] [-p] name[=value] ...
|
||||
$SHORT_DOC declare [-afFirtx] [-p] name[=value] ...
|
||||
Declare variables and/or give them attributes. If no NAMEs are
|
||||
given, then display the values of variables instead. The -p option
|
||||
will display the attributes and values of each NAME.
|
||||
|
|
@ -33,9 +33,10 @@ The flags are:
|
|||
-a to make NAMEs arrays (if supported)
|
||||
-f to select from among function names only
|
||||
-F to display function names without definitions
|
||||
-i to make NAMEs have the `integer' attribute
|
||||
-r to make NAMEs readonly
|
||||
-t to make NAMEs have the `trace' attribute
|
||||
-x to make NAMEs export
|
||||
-i to make NAMEs have the `integer' attribute set
|
||||
|
||||
Variables with the integer attribute have arithmetic evaluation (see
|
||||
`let') done when the variable is assigned to.
|
||||
|
|
@ -50,7 +51,7 @@ $END
|
|||
|
||||
$BUILTIN typeset
|
||||
$FUNCTION declare_builtin
|
||||
$SHORT_DOC typeset [-afFrxi] [-p] name[=value] ...
|
||||
$SHORT_DOC typeset [-afFirtx] [-p] name[=value] ...
|
||||
Obsolete. See `declare'.
|
||||
$END
|
||||
|
||||
|
|
@ -70,6 +71,7 @@ $END
|
|||
#include "../shell.h"
|
||||
#include "common.h"
|
||||
#include "builtext.h"
|
||||
#include "bashgetopt.h"
|
||||
|
||||
extern int array_needs_making;
|
||||
|
||||
|
|
@ -103,66 +105,70 @@ local_builtin (list)
|
|||
}
|
||||
}
|
||||
|
||||
#if defined (ARRAY_VARS)
|
||||
# define DECLARE_OPTS "+afiprtxF"
|
||||
#else
|
||||
# define DECLARE_OPTS "+fiprtxF"
|
||||
#endif
|
||||
|
||||
/* The workhorse function. */
|
||||
static int
|
||||
declare_internal (list, local_var)
|
||||
register WORD_LIST *list;
|
||||
int local_var;
|
||||
{
|
||||
int flags_on, flags_off, *flags, any_failed, assign_error, pflag, nodefs;
|
||||
int flags_on, flags_off, *flags, any_failed, assign_error, pflag, nodefs, opt;
|
||||
char *t, *subscript_start;
|
||||
SHELL_VAR *var;
|
||||
|
||||
flags_on = flags_off = any_failed = assign_error = pflag = nodefs = 0;
|
||||
while (list)
|
||||
reset_internal_getopt ();
|
||||
while ((opt = internal_getopt (list, DECLARE_OPTS)) != EOF)
|
||||
{
|
||||
t = list->word->word;
|
||||
if (t[0] == '-' && t[1] == '-' && t[2] == '\0')
|
||||
{
|
||||
list = list->next;
|
||||
break;
|
||||
}
|
||||
flags = list_opttype == '+' ? &flags_off : &flags_on;
|
||||
|
||||
if (*t != '+' && *t != '-')
|
||||
break;
|
||||
|
||||
flags = (*t++ == '+') ? &flags_off : &flags_on;
|
||||
|
||||
while (*t)
|
||||
switch (opt)
|
||||
{
|
||||
if (*t == 'p' && local_var == 0)
|
||||
pflag++, t++;
|
||||
else if (*t == 'F')
|
||||
{
|
||||
nodefs++;
|
||||
*flags |= att_function; t++;
|
||||
}
|
||||
else if (*t == 'f')
|
||||
*flags |= att_function, t++;
|
||||
else if (*t == 'x')
|
||||
*flags |= att_exported, t++, array_needs_making = 1;
|
||||
else if (*t == 'r')
|
||||
*flags |= att_readonly, t++;
|
||||
else if (*t == 'i')
|
||||
*flags |= att_integer, t++;
|
||||
case 'a':
|
||||
#if defined (ARRAY_VARS)
|
||||
else if (*t == 'a')
|
||||
*flags |= att_array, t++;
|
||||
*flags |= att_array;
|
||||
#endif
|
||||
else
|
||||
{
|
||||
builtin_error ("unknown option: `-%c'", *t);
|
||||
break;
|
||||
case 'p':
|
||||
if (local_var == 0)
|
||||
pflag++;
|
||||
break;
|
||||
case 'F':
|
||||
nodefs++;
|
||||
*flags |= att_function;
|
||||
break;
|
||||
case 'f':
|
||||
*flags |= att_function;
|
||||
break;
|
||||
case 'i':
|
||||
*flags |= att_integer;
|
||||
break;
|
||||
case 'r':
|
||||
*flags |= att_readonly;
|
||||
break;
|
||||
case 't':
|
||||
*flags |= att_trace;
|
||||
break;
|
||||
case 'x':
|
||||
*flags |= att_exported;
|
||||
array_needs_making = 1;
|
||||
break;
|
||||
default:
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
}
|
||||
}
|
||||
|
||||
list = list->next;
|
||||
}
|
||||
list = loptend;
|
||||
|
||||
/* If there are no more arguments left, then we just want to show
|
||||
some variables. */
|
||||
if (list == 0) /* declare -[afFirx] */
|
||||
if (list == 0) /* declare -[afFirtx] */
|
||||
{
|
||||
/* Show local variables defined at this context level if this is
|
||||
the `local' builtin. */
|
||||
|
|
@ -171,7 +177,7 @@ declare_internal (list, local_var)
|
|||
register SHELL_VAR **vlist;
|
||||
register int i;
|
||||
|
||||
vlist = map_over (variable_in_context, shell_variables);
|
||||
vlist = all_local_variables ();
|
||||
|
||||
if (vlist)
|
||||
{
|
||||
|
|
@ -193,14 +199,14 @@ declare_internal (list, local_var)
|
|||
return (EXECUTION_SUCCESS);
|
||||
}
|
||||
|
||||
if (pflag) /* declare -p [-afFirx] name [name...] */
|
||||
if (pflag) /* declare -p [-afFirtx] name [name...] */
|
||||
{
|
||||
for (any_failed = 0; list; list = list->next)
|
||||
{
|
||||
pflag = show_name_attributes (list->word->word, nodefs);
|
||||
if (pflag)
|
||||
{
|
||||
builtin_error ("%s: not found", list->word->word);
|
||||
sh_notfound (list->word->word);
|
||||
any_failed++;
|
||||
}
|
||||
}
|
||||
|
|
@ -244,7 +250,7 @@ declare_internal (list, local_var)
|
|||
|
||||
if (legal_identifier (name) == 0)
|
||||
{
|
||||
builtin_error ("`%s': not a valid identifier", name);
|
||||
sh_invalidid (name);
|
||||
assign_error++;
|
||||
NEXT_VARIABLE ();
|
||||
}
|
||||
|
|
@ -253,7 +259,10 @@ declare_internal (list, local_var)
|
|||
inside of a function. This means we should make local variables,
|
||||
not global ones. */
|
||||
|
||||
if (variable_context)
|
||||
/* XXX - this has consequences when we're making a local copy of a
|
||||
variable that was in the temporary environment. Watch out
|
||||
for this. */
|
||||
if (variable_context && ((flags_on & att_function) == 0))
|
||||
{
|
||||
#if defined (ARRAY_VARS)
|
||||
if ((flags_on & att_array) || making_array_special)
|
||||
|
|
@ -267,6 +276,8 @@ declare_internal (list, local_var)
|
|||
NEXT_VARIABLE ();
|
||||
}
|
||||
}
|
||||
else
|
||||
var = (SHELL_VAR *)NULL;
|
||||
|
||||
/* If we are declaring a function, then complain about it in some way.
|
||||
We don't let people make functions by saying `typeset -f foo=bar'. */
|
||||
|
|
@ -315,6 +326,8 @@ declare_internal (list, local_var)
|
|||
}
|
||||
else /* declare -[airx] name [name...] */
|
||||
{
|
||||
/* Non-null if we just created or fetched a local variable. */
|
||||
if (var == 0)
|
||||
var = find_variable (name);
|
||||
|
||||
if (var == 0)
|
||||
|
|
@ -330,7 +343,7 @@ declare_internal (list, local_var)
|
|||
/* Cannot use declare +r to turn off readonly attribute. */
|
||||
if (readonly_p (var) && (flags_off & att_readonly))
|
||||
{
|
||||
builtin_error ("%s: readonly variable", name);
|
||||
sh_readonly (name);
|
||||
any_failed++;
|
||||
NEXT_VARIABLE ();
|
||||
}
|
||||
|
|
@ -340,7 +353,7 @@ declare_internal (list, local_var)
|
|||
if ((readonly_p (var) || noassign_p (var)) && offset)
|
||||
{
|
||||
if (readonly_p (var))
|
||||
builtin_error ("%s: readonly variable", name);
|
||||
sh_readonly (name);
|
||||
assign_error++;
|
||||
NEXT_VARIABLE ();
|
||||
}
|
||||
|
|
@ -394,12 +407,27 @@ declare_internal (list, local_var)
|
|||
`var=value declare -x var', make sure it is treated identically
|
||||
to `var=value export var'. Do the same for `declare -r' and
|
||||
`readonly'. Preserve the attributes, except for att_tempvar. */
|
||||
/* XXX -- should this create a variable in the global scope, or
|
||||
modify the local variable flags? ksh93 has it modify the
|
||||
global scope.
|
||||
Need to handle case like in set_var_attribute where a temporary
|
||||
variable is in the same table as the function local vars. */
|
||||
if ((flags_on & (att_exported|att_readonly)) && tempvar_p (var))
|
||||
{
|
||||
SHELL_VAR *tv;
|
||||
tv = bind_variable (var->name, var->value ? var->value : "");
|
||||
tv->attributes = var->attributes & ~att_tempvar;
|
||||
dispose_variable (var);
|
||||
char *tvalue;
|
||||
|
||||
tv = find_tempenv_variable (var->name);
|
||||
if (tv)
|
||||
{
|
||||
tvalue = var_isset (var) ? savestring (value_cell (var)) : savestring ("");
|
||||
tv = bind_variable (var->name, tvalue);
|
||||
tv->attributes |= var->attributes & ~att_tempvar;
|
||||
if (tv->context > 0)
|
||||
VSETATTR (tv, att_propagate);
|
||||
free (tvalue);
|
||||
}
|
||||
VSETATTR (var, att_propagate);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is echo.def, from which is created echo.c.
|
||||
It implements the builtin "echo" in Bash.
|
||||
|
||||
Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is enable.def, from which is created enable.c.
|
||||
It implements the builtin "enable" in Bash.
|
||||
|
||||
Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -146,7 +146,7 @@ enable_builtin (list)
|
|||
/* Restricted shells cannot load new builtins. */
|
||||
if (restricted && (flags & (FFLAG|DFLAG)))
|
||||
{
|
||||
builtin_error ("restricted");
|
||||
sh_restricted ((char *)NULL);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
#endif
|
||||
|
|
@ -246,6 +246,13 @@ enable_shell_command (name, disable_p)
|
|||
|
||||
if (disable_p)
|
||||
b->flags &= ~BUILTIN_ENABLED;
|
||||
#if defined (RESTRICTED_SHELL)
|
||||
else if (restricted && ((b->flags & BUILTIN_ENABLED) == 0))
|
||||
{
|
||||
sh_restricted ((char *)NULL);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
#endif
|
||||
else
|
||||
b->flags |= BUILTIN_ENABLED;
|
||||
|
||||
|
|
@ -453,7 +460,7 @@ dyn_unload_builtin (name)
|
|||
using it drops to zero. */
|
||||
if (ref == 1 && local_dlclose (handle) != 0)
|
||||
{
|
||||
builtin_error ("cannot delete %s: %s", name, dlerror ());
|
||||
builtin_error ("%s: cannot delete: %s", name, dlerror ());
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is eval.def, from which is created eval.c.
|
||||
It implements the builtin "eval" in Bash.
|
||||
|
||||
Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -46,6 +46,7 @@ eval_builtin (list)
|
|||
{
|
||||
if (no_options (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);
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ maybe_execute_file (fname, force_noninteractive)
|
|||
char *filename;
|
||||
int result, flags;
|
||||
|
||||
filename = bash_tilde_expand (fname);
|
||||
filename = bash_tilde_expand (fname, 0);
|
||||
flags = FEVAL_ENOENTOK;
|
||||
if (force_noninteractive)
|
||||
flags |= FEVAL_NONINT;
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ parse_and_execute_cleanup ()
|
|||
(flags & SEVAL_NONINT) -> interactive = 0;
|
||||
(flags & SEVAL_INTERACT) -> interactive = 1;
|
||||
(flags & SEVAL_NOHIST) -> call bash_history_disable ()
|
||||
(flags & SEVAL_NOFREE) -> don't free STRING when finished
|
||||
*/
|
||||
|
||||
int
|
||||
|
|
@ -123,7 +124,7 @@ parse_and_execute (string, from_file, flags)
|
|||
}
|
||||
|
||||
add_unwind_protect (pop_stream, (char *)NULL);
|
||||
if (orig_string)
|
||||
if (orig_string && ((flags & SEVAL_NOFREE) == 0))
|
||||
add_unwind_protect (xfree, orig_string);
|
||||
end_unwind_frame ();
|
||||
|
||||
|
|
@ -320,23 +321,7 @@ cat_file (r)
|
|||
return -1;
|
||||
}
|
||||
|
||||
rval = 0;
|
||||
while (1)
|
||||
{
|
||||
nr = zread (fd, lbuf, sizeof(lbuf));
|
||||
if (nr == 0)
|
||||
break;
|
||||
else if (nr < 0)
|
||||
{
|
||||
rval = -1;
|
||||
break;
|
||||
}
|
||||
if (zwrite (1, lbuf, nr) < 0)
|
||||
{
|
||||
rval = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
rval = zcatfd (fd, 1, fn);
|
||||
|
||||
free (fn);
|
||||
close (fd);
|
||||
|
|
|
|||
|
|
@ -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, 1989, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -127,19 +127,19 @@ exec_builtin (list)
|
|||
#if defined (RESTRICTED_SHELL)
|
||||
if (restricted)
|
||||
{
|
||||
builtin_error ("restricted");
|
||||
sh_restricted ((char *)NULL);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
#endif /* RESTRICTED_SHELL */
|
||||
|
||||
args = word_list_to_argv (list, 1, 0, (int *)NULL);
|
||||
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]);
|
||||
|
||||
if (command == 0)
|
||||
{
|
||||
builtin_error ("%s: not found", args[0]);
|
||||
sh_notfound (args[0]);
|
||||
exit_value = EX_NOTFOUND; /* As per Posix.2, 3.14.6 */
|
||||
goto failed_exec;
|
||||
}
|
||||
|
|
@ -215,10 +215,10 @@ failed_exec:
|
|||
exit_shell (exit_value);
|
||||
|
||||
if (args)
|
||||
free_array (args);
|
||||
strvec_dispose (args);
|
||||
|
||||
initialize_traps ();
|
||||
reinitialize_signals ();
|
||||
initialize_signals (1);
|
||||
|
||||
#if defined (JOB_CONTROL)
|
||||
restart_job_control ();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is exit.def, from which is created exit.c.
|
||||
It implements the builtins "exit", and "logout" in Bash.
|
||||
|
||||
Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -119,7 +119,8 @@ exit_or_logout (list)
|
|||
|
||||
/* Get return value if present. This means that you can type
|
||||
`logout 5' to a shell, and it returns 5. */
|
||||
exit_value = list ? get_exitstat (list) : last_command_exit_value;
|
||||
|
||||
exit_value = get_exitstat (list);
|
||||
|
||||
/* Run our `~/.bash_logout' file if it exists, and this is a login shell. */
|
||||
if (login_shell && sourced_logout++ == 0 && subshell_environment == 0)
|
||||
|
|
|
|||
|
|
@ -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, 1989, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -239,8 +239,7 @@ fc_builtin (list)
|
|||
/* If we have a list of substitutions to do, then reverse it
|
||||
to get the replacements in the proper order. */
|
||||
|
||||
if (rlist && rlist->next)
|
||||
rlist = (REPL *)reverse_list ((GENERIC_LIST *) rlist);
|
||||
rlist = REVERSE_LIST (rlist, REPL *);
|
||||
|
||||
hlist = history_list ();
|
||||
|
||||
|
|
@ -313,10 +312,9 @@ fc_builtin (list)
|
|||
}
|
||||
|
||||
/* We print error messages for line specifications out of range. */
|
||||
if ((histbeg < 0) || (histend < 0) ||
|
||||
(histbeg > last_hist) || (histend > last_hist))
|
||||
if ((histbeg < 0) || (histend < 0))
|
||||
{
|
||||
builtin_error ("history specification out of range");
|
||||
sh_erange ((char *)NULL, "history specification");
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
|
|
@ -410,7 +408,7 @@ fc_number (list)
|
|||
s = list->word->word;
|
||||
if (*s == '-')
|
||||
s++;
|
||||
return (legal_number (s, (long *)NULL));
|
||||
return (legal_number (s, (intmax_t *)NULL));
|
||||
}
|
||||
|
||||
/* Return an absolute index into HLIST which corresponds to COMMAND. If
|
||||
|
|
@ -457,19 +455,20 @@ fc_gethnum (command, hlist)
|
|||
n = atoi (s);
|
||||
n *= sign;
|
||||
|
||||
/* Anything specified greater than the last history element that we
|
||||
deal with is an error. */
|
||||
if (n > i + history_base)
|
||||
return (-1);
|
||||
|
||||
/* If the value is negative or zero, then it is an offset from
|
||||
the current history item. */
|
||||
if (n < 0)
|
||||
return (i + n + 1);
|
||||
{
|
||||
n += i + 1;
|
||||
return (n < 0 ? 0 : n);
|
||||
}
|
||||
else if (n == 0)
|
||||
return (i);
|
||||
else
|
||||
return (n - history_base);
|
||||
{
|
||||
n -= history_base;
|
||||
return (i < n ? i : n);
|
||||
}
|
||||
}
|
||||
|
||||
clen = strlen (command);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is fg_bg.def, from which is created fg_bg.c.
|
||||
It implements the builtins "bg" and "fg" in Bash.
|
||||
|
||||
Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -42,6 +42,7 @@ $END
|
|||
#include "../shell.h"
|
||||
#include "../jobs.h"
|
||||
#include "common.h"
|
||||
#include "bashgetopt.h"
|
||||
|
||||
#if defined (JOB_CONTROL)
|
||||
extern char *this_command_name;
|
||||
|
|
@ -58,12 +59,13 @@ fg_builtin (list)
|
|||
|
||||
if (job_control == 0)
|
||||
{
|
||||
builtin_error ("no job control");
|
||||
sh_nojobs ((char *)NULL);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
if (no_options (list))
|
||||
return (EX_USAGE);
|
||||
list = loptend;
|
||||
|
||||
/* If the last arg on the line is '&', then start this job in the
|
||||
background. Else, fg the job. */
|
||||
|
|
@ -92,12 +94,13 @@ bg_builtin (list)
|
|||
{
|
||||
if (job_control == 0)
|
||||
{
|
||||
builtin_error ("no job control");
|
||||
sh_nojobs ((char *)NULL);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
if (no_options (list))
|
||||
return (EX_USAGE);
|
||||
list = loptend;
|
||||
|
||||
return (fg_bg (list, 0));
|
||||
}
|
||||
|
|
@ -117,7 +120,7 @@ fg_bg (list, foreground)
|
|||
if (job < 0 || job >= job_slots || jobs[job] == 0)
|
||||
{
|
||||
if (job != DUP_JOB)
|
||||
builtin_error ("%s: no such job", list ? list->word->word : "current");
|
||||
sh_badjob (list ? list->word->word : "current");
|
||||
|
||||
goto failure;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ int sh_opterr = 1;
|
|||
|
||||
int sh_optopt = '?';
|
||||
|
||||
/* Set to 1 when we see an illegal option; public so getopts can reset it. */
|
||||
/* Set to 1 when we see an invalid option; public so getopts can reset it. */
|
||||
int sh_badopt = 0;
|
||||
|
||||
/* Scan elements of ARGV (whose length is ARGC) for option characters
|
||||
|
|
@ -135,15 +135,6 @@ sh_getopt (argc, argv, optstring)
|
|||
nextchar = (char *)NULL;
|
||||
}
|
||||
|
||||
/* Do the increment of `sh_optind' we deferred because the last option
|
||||
was illegal. */
|
||||
if (sh_badopt && (nextchar == 0 || *nextchar == '\0'))
|
||||
{
|
||||
sh_badopt = 0;
|
||||
sh_optind++;
|
||||
nextchar = (char *)NULL;
|
||||
}
|
||||
|
||||
if (nextchar == 0 || *nextchar == '\0')
|
||||
{
|
||||
/* If we have done all the ARGV-elements, stop the scan. */
|
||||
|
|
@ -179,8 +170,13 @@ sh_getopt (argc, argv, optstring)
|
|||
|
||||
sh_optopt = c;
|
||||
|
||||
/* If the option is illegal, return an error, but defer updating sh_optind
|
||||
until the next call so $OPTIND is correct. */
|
||||
/* Increment `sh_optind' when we start to process its last character. */
|
||||
if (nextchar == 0 || *nextchar == '\0')
|
||||
{
|
||||
sh_optind++;
|
||||
nextchar = (char *)NULL;
|
||||
}
|
||||
|
||||
if (sh_badopt = (temp == NULL || c == ':'))
|
||||
{
|
||||
if (sh_opterr)
|
||||
|
|
@ -189,13 +185,6 @@ sh_getopt (argc, argv, optstring)
|
|||
return '?';
|
||||
}
|
||||
|
||||
/* Increment `sh_optind' when we start to process its last character. */
|
||||
if (nextchar == 0 || *nextchar == '\0')
|
||||
{
|
||||
sh_optind++;
|
||||
nextchar = (char *)NULL;
|
||||
}
|
||||
|
||||
if (temp[1] == ':')
|
||||
{
|
||||
if (nextchar && *nextchar)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is getopts.def, from which is created getopts.c.
|
||||
It implements the builtin "getopts" in Bash.
|
||||
|
||||
Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -39,11 +39,11 @@ getopts places that argument into the shell variable OPTARG.
|
|||
|
||||
getopts reports errors in one of two ways. If the first character
|
||||
of OPTSTRING is a colon, getopts uses silent error reporting. In
|
||||
this mode, no error messages are printed. If an illegal option is
|
||||
this mode, no error messages are printed. If an invalid option is
|
||||
seen, getopts places the option character found into OPTARG. If a
|
||||
required argument is not found, getopts places a ':' into NAME and
|
||||
sets OPTARG to the option character found. If getopts is not in
|
||||
silent mode, and an illegal option is seen, getopts places '?' into
|
||||
silent mode, and an invalid option is seen, getopts places '?' into
|
||||
NAME and unsets OPTARG. If a required option is not found, a '?'
|
||||
is placed in NAME, OPTARG is unset, and a diagnostic message is
|
||||
printed.
|
||||
|
|
@ -75,11 +75,14 @@ $END
|
|||
#include "getopt.h"
|
||||
|
||||
#define G_EOF -1
|
||||
#define G_ILLEGAL_OPT -2
|
||||
#define G_INVALID_OPT -2
|
||||
#define G_ARG_MISSING -3
|
||||
|
||||
extern char *this_command_name;
|
||||
|
||||
static int getopts_bind_variable __P((char *, char *));
|
||||
static int dogetopts __P((int, char **));
|
||||
|
||||
/* getopts_reset is magic code for when OPTIND is reset. N is the
|
||||
value that has just been assigned to OPTIND. */
|
||||
void
|
||||
|
|
@ -103,7 +106,7 @@ getopts_bind_variable (name, value)
|
|||
}
|
||||
else
|
||||
{
|
||||
builtin_error ("`%s': not a valid identifier", name);
|
||||
sh_invalidid (name);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
}
|
||||
|
|
@ -112,9 +115,9 @@ getopts_bind_variable (name, value)
|
|||
(identical to that of ksh-88). The special handling is enabled if
|
||||
the first character of the option string is a colon; this handling
|
||||
disables diagnostic messages concerning missing option arguments
|
||||
and illegal option characters. The handling is as follows.
|
||||
and invalid option characters. The handling is as follows.
|
||||
|
||||
ILLEGAL OPTIONS:
|
||||
INVALID OPTIONS:
|
||||
name -> "?"
|
||||
if (special_error) then
|
||||
OPTARG = option character found
|
||||
|
|
@ -193,7 +196,7 @@ dogetopts (argc, argv)
|
|||
;
|
||||
for (words = rest_of_args; words; words = words->next, i++)
|
||||
;
|
||||
v = alloc_array (i + 1);
|
||||
v = strvec_create (i + 1);
|
||||
for (i = 0; i < 10 && dollar_vars[i]; i++)
|
||||
v[i] = dollar_vars[i];
|
||||
for (words = rest_of_args; words; words = words->next, i++)
|
||||
|
|
@ -207,7 +210,8 @@ dogetopts (argc, argv)
|
|||
if (special_error)
|
||||
sh_opterr = old_opterr;
|
||||
|
||||
/* Set the OPTIND variable in any case, to handle "--" skipping. */
|
||||
/* Set the OPTIND variable in any case, to handle "--" skipping. It's
|
||||
highly unlikely that 14 digits will be too few. */
|
||||
if (sh_optind < 10)
|
||||
{
|
||||
numval[14] = sh_optind + '0';
|
||||
|
|
@ -228,13 +232,13 @@ dogetopts (argc, argv)
|
|||
|
||||
/* If an error occurred, decide which one it is and set the return
|
||||
code appropriately. In all cases, the option character in error
|
||||
is in OPTOPT. If an illegal option was encountered, OPTARG is
|
||||
is in OPTOPT. If an invalid option was encountered, OPTARG is
|
||||
NULL. If a required option argument was missing, OPTARG points
|
||||
to a NULL string (that is, sh_optarg[0] == 0). */
|
||||
if (ret == '?')
|
||||
{
|
||||
if (sh_optarg == NULL)
|
||||
ret = G_ILLEGAL_OPT;
|
||||
ret = G_INVALID_OPT;
|
||||
else if (sh_optarg[0] == '\0')
|
||||
ret = G_ARG_MISSING;
|
||||
}
|
||||
|
|
@ -245,9 +249,9 @@ dogetopts (argc, argv)
|
|||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
if (ret == G_ILLEGAL_OPT)
|
||||
if (ret == G_INVALID_OPT)
|
||||
{
|
||||
/* Illegal option encountered. */
|
||||
/* Invalid option encountered. */
|
||||
ret = getopts_bind_variable (name, "?");
|
||||
|
||||
if (special_error)
|
||||
|
|
@ -257,7 +261,7 @@ dogetopts (argc, argv)
|
|||
bind_variable ("OPTARG", strval);
|
||||
}
|
||||
else
|
||||
makunbound ("OPTARG", shell_variables);
|
||||
unbind_variable ("OPTARG");
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
|
@ -276,7 +280,7 @@ dogetopts (argc, argv)
|
|||
else
|
||||
{
|
||||
ret = getopts_bind_variable (name, "?");
|
||||
makunbound ("OPTARG", shell_variables);
|
||||
unbind_variable ("OPTARG");
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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, 1989, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -23,15 +23,17 @@ $PRODUCES hash.c
|
|||
|
||||
$BUILTIN hash
|
||||
$FUNCTION hash_builtin
|
||||
$SHORT_DOC hash [-r] [-p pathname] [-t] [name ...]
|
||||
$SHORT_DOC hash [-lr] [-p pathname] [-dt] [name ...]
|
||||
For each NAME, the full pathname of the command is determined and
|
||||
remembered. If the -p option is supplied, PATHNAME is used as the
|
||||
full pathname of NAME, and no path search is performed. The -r
|
||||
option causes the shell to forget all remembered locations.
|
||||
option causes the shell to forget all remembered locations. The -d
|
||||
option causes the shell to forget the remembered location of each NAME.
|
||||
If the -t option is supplied the full pathname to which each NAME
|
||||
corresponds is printed. If multiple NAME arguments are supplied with
|
||||
-t, the NAME is printed before the hashed full pathname. If no arguments
|
||||
are given, information about remembered commands is displayed.
|
||||
-t, the NAME is printed before the hashed full pathname. The -l option
|
||||
causes output to be displayed in a format that may be reused as input.
|
||||
If no arguments are given, information about remembered commands is displayed.
|
||||
$END
|
||||
|
||||
#include <config.h>
|
||||
|
|
@ -60,8 +62,10 @@ extern int dot_found_in_search;
|
|||
extern char *this_command_name;
|
||||
|
||||
static int add_hashed_command __P((char *, int));
|
||||
static int print_hashed_commands __P((void));
|
||||
static int list_hashed_filename_targets __P((WORD_LIST *));
|
||||
static int print_hash_info __P((BUCKET_CONTENTS *));
|
||||
static int print_portable_hash_info __P((BUCKET_CONTENTS *));
|
||||
static int print_hashed_commands __P((int));
|
||||
static int list_hashed_filename_targets __P((WORD_LIST *, int));
|
||||
|
||||
/* Print statistics on the current state of hashed commands. If LIST is
|
||||
not empty, then rehash (or hash in the first place) the specified
|
||||
|
|
@ -70,7 +74,7 @@ int
|
|||
hash_builtin (list)
|
||||
WORD_LIST *list;
|
||||
{
|
||||
int expunge_hash_table, list_targets, opt;
|
||||
int expunge_hash_table, list_targets, list_portably, delete, opt;
|
||||
char *w, *pathname;
|
||||
|
||||
if (hashing_enabled == 0)
|
||||
|
|
@ -79,19 +83,25 @@ hash_builtin (list)
|
|||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
expunge_hash_table = list_targets = 0;
|
||||
expunge_hash_table = list_targets = list_portably = delete = 0;
|
||||
pathname = (char *)NULL;
|
||||
reset_internal_getopt ();
|
||||
while ((opt = internal_getopt (list, "rp:t")) != -1)
|
||||
while ((opt = internal_getopt (list, "dlp:rt")) != -1)
|
||||
{
|
||||
switch (opt)
|
||||
{
|
||||
case 'r':
|
||||
expunge_hash_table = 1;
|
||||
case 'd':
|
||||
delete = 1;
|
||||
break;
|
||||
case 'l':
|
||||
list_portably = 1;
|
||||
break;
|
||||
case 'p':
|
||||
pathname = list_optarg;
|
||||
break;
|
||||
case 'r':
|
||||
expunge_hash_table = 1;
|
||||
break;
|
||||
case 't':
|
||||
list_targets = 1;
|
||||
break;
|
||||
|
|
@ -105,40 +115,38 @@ hash_builtin (list)
|
|||
/* hash -t requires at least one argument. */
|
||||
if (list == 0 && list_targets)
|
||||
{
|
||||
builtin_error("-t: argument required");
|
||||
sh_needarg ("-t");
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
/* We want hash -r to be silent, but hash -- to print hashing info. That
|
||||
is the reason for the test of expunge_hash_table. */
|
||||
/* We want hash -r to be silent, but hash -- to print hashing info, so
|
||||
we test expunge_hash_table. */
|
||||
if (list == 0 && expunge_hash_table == 0)
|
||||
{
|
||||
if (print_hashed_commands () == 0)
|
||||
if (print_hashed_commands (list_portably) == 0)
|
||||
printf ("%s: hash table empty\n", this_command_name);
|
||||
|
||||
return (EXECUTION_SUCCESS);
|
||||
}
|
||||
|
||||
if (expunge_hash_table)
|
||||
flush_hashed_filenames ();
|
||||
phash_flush ();
|
||||
|
||||
/* If someone runs `hash -r -t xyz' he will be disappointed. */
|
||||
if (list_targets)
|
||||
{
|
||||
return (list_hashed_filename_targets (list));
|
||||
}
|
||||
return (list_hashed_filename_targets (list, list_portably));
|
||||
|
||||
#if defined (RESTRICTED_SHELL)
|
||||
if (restricted && pathname && strchr (pathname, '/'))
|
||||
{
|
||||
builtin_error ("%s: restricted", pathname);
|
||||
sh_restricted (pathname);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
#endif
|
||||
|
||||
for (opt = EXECUTION_SUCCESS; list; list = list->next)
|
||||
{
|
||||
/* Add or rehash the specified commands. */
|
||||
/* Add, remove or rehash the specified commands. */
|
||||
w = list->word->word;
|
||||
if (pathname)
|
||||
{
|
||||
|
|
@ -152,10 +160,15 @@ hash_builtin (list)
|
|||
opt = EXECUTION_FAILURE;
|
||||
}
|
||||
else
|
||||
remember_filename (w, pathname, 0, 0);
|
||||
phash_insert (w, pathname, 0, 0);
|
||||
}
|
||||
else if (absolute_program (w))
|
||||
continue;
|
||||
else if (delete && phash_remove (w))
|
||||
{
|
||||
sh_notfound (w);
|
||||
opt = EXECUTION_FAILURE;
|
||||
}
|
||||
else if (add_hashed_command (w, 0))
|
||||
opt = EXECUTION_FAILURE;
|
||||
}
|
||||
|
|
@ -177,51 +190,52 @@ add_hashed_command (w, quiet)
|
|||
{
|
||||
full_path = find_user_command (w);
|
||||
if (full_path && executable_file (full_path))
|
||||
remember_filename (w, full_path, dot_found_in_search, 0);
|
||||
phash_insert (w, full_path, dot_found_in_search, 0);
|
||||
else
|
||||
{
|
||||
if (quiet == 0)
|
||||
builtin_error ("%s: not found", w);
|
||||
sh_notfound (w);
|
||||
rv++;
|
||||
}
|
||||
if (full_path)
|
||||
free (full_path);
|
||||
FREE (full_path);
|
||||
}
|
||||
return (rv);
|
||||
}
|
||||
|
||||
/* Print information about current hashed info. */
|
||||
static int
|
||||
print_hashed_commands ()
|
||||
print_hash_info (item)
|
||||
BUCKET_CONTENTS *item;
|
||||
{
|
||||
BUCKET_CONTENTS *item_list;
|
||||
int bucket, any_printed;
|
||||
|
||||
if (hashed_filenames == 0)
|
||||
return (0);
|
||||
|
||||
for (bucket = any_printed = 0; bucket < hashed_filenames->nbuckets; bucket++)
|
||||
{
|
||||
item_list = get_hash_bucket (bucket, hashed_filenames);
|
||||
if (item_list == 0)
|
||||
continue;
|
||||
|
||||
if (any_printed == 0)
|
||||
{
|
||||
printf ("hits\tcommand\n");
|
||||
any_printed++;
|
||||
}
|
||||
|
||||
for ( ; item_list; item_list = item_list->next)
|
||||
printf ("%4d\t%s\n", item_list->times_found, pathdata(item_list)->path);
|
||||
|
||||
}
|
||||
return (any_printed);
|
||||
printf ("%4d\t%s\n", item->times_found, pathdata(item)->path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
list_hashed_filename_targets (list)
|
||||
print_portable_hash_info (item)
|
||||
BUCKET_CONTENTS *item;
|
||||
{
|
||||
printf ("builtin hash -p %s %s\n", pathdata(item)->path, item->key);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
print_hashed_commands (fmt)
|
||||
int fmt;
|
||||
{
|
||||
if (hashed_filenames == 0 || HASH_ENTRIES (hashed_filenames) == 0)
|
||||
return (0);
|
||||
|
||||
if (fmt == 0)
|
||||
printf ("hits\tcommand\n");
|
||||
hash_walk (hashed_filenames, fmt ? print_portable_hash_info : print_hash_info);
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int
|
||||
list_hashed_filename_targets (list, fmt)
|
||||
WORD_LIST *list;
|
||||
int fmt;
|
||||
{
|
||||
int all_found, multiple;
|
||||
char *target;
|
||||
|
|
@ -232,17 +246,22 @@ list_hashed_filename_targets (list)
|
|||
|
||||
for (l = list; l; l = l->next)
|
||||
{
|
||||
target = find_hashed_filename (l->word->word);
|
||||
target = phash_search (l->word->word);
|
||||
if (target == 0)
|
||||
{
|
||||
all_found = 0;
|
||||
builtin_error ("%s: not found", l->word->word);
|
||||
sh_notfound (l->word->word);
|
||||
continue;
|
||||
}
|
||||
if (fmt)
|
||||
printf ("builtin hash -p %s %s\n", target, l->word->word);
|
||||
else
|
||||
{
|
||||
if (multiple)
|
||||
printf ("%s\t", l->word->word);
|
||||
printf ("%s\n", target);
|
||||
}
|
||||
}
|
||||
|
||||
return (all_found ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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, 1989, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -44,6 +44,10 @@ $END
|
|||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include <filecntl.h>
|
||||
|
||||
#include "../shell.h"
|
||||
#include "../builtins.h"
|
||||
#include "../pathexp.h"
|
||||
|
|
@ -53,7 +57,12 @@ $END
|
|||
#include <glob/strmatch.h>
|
||||
#include <glob/glob.h>
|
||||
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
static void show_builtin_command_help __P((void));
|
||||
static void show_longdoc __P((int));
|
||||
|
||||
/* Print out a list of the known functions in the shell, and what they do.
|
||||
If LIST is supplied, print out the list which matches for each pattern
|
||||
|
|
@ -62,7 +71,7 @@ int
|
|||
help_builtin (list)
|
||||
WORD_LIST *list;
|
||||
{
|
||||
register int i, j;
|
||||
register int i;
|
||||
char *pattern, *name;
|
||||
int plen, match_found, sflag;
|
||||
|
||||
|
|
@ -112,8 +121,7 @@ help_builtin (list)
|
|||
printf ("%s: %s\n", name, shell_builtins[i].short_doc);
|
||||
|
||||
if (sflag == 0)
|
||||
for (j = 0; shell_builtins[i].long_doc[j]; j++)
|
||||
printf (" %s\n", shell_builtins[i].long_doc[j]);
|
||||
show_longdoc (i);
|
||||
|
||||
match_found++;
|
||||
}
|
||||
|
|
@ -122,7 +130,7 @@ help_builtin (list)
|
|||
|
||||
if (match_found == 0)
|
||||
{
|
||||
builtin_error ("no help topics match `%s'. Try `help help'.", pattern);
|
||||
builtin_error ("no help topics match `%s'. Try `help help' or `man -k %s' or `info %s'.", pattern, pattern, pattern);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
|
|
@ -130,6 +138,35 @@ help_builtin (list)
|
|||
return (EXECUTION_SUCCESS);
|
||||
}
|
||||
|
||||
/* By convention, enforced by mkbuiltins.c, if separate help files are being
|
||||
used, the long_doc array contains one string -- the full pathname of the
|
||||
help file for this builtin. */
|
||||
static void
|
||||
show_longdoc (i)
|
||||
int i;
|
||||
{
|
||||
register int j;
|
||||
char * const *doc;
|
||||
int fd;
|
||||
|
||||
doc = shell_builtins[i].long_doc;
|
||||
|
||||
if (doc && doc[0] && *doc[0] == '/' && doc[1] == (char *)NULL)
|
||||
{
|
||||
fd = open (doc[0], O_RDONLY);
|
||||
if (fd == -1)
|
||||
{
|
||||
builtin_error ("%s: cannot open: %s", doc[0], strerror (errno));
|
||||
return;
|
||||
}
|
||||
zcatfd (fd, 1, doc[0]);
|
||||
close (fd);
|
||||
}
|
||||
else
|
||||
for (j = 0; doc[j]; j++)
|
||||
printf (" %s\n", doc[j]);
|
||||
}
|
||||
|
||||
static void
|
||||
show_builtin_command_help ()
|
||||
{
|
||||
|
|
@ -140,6 +177,7 @@ show_builtin_command_help ()
|
|||
"These shell commands are defined internally. Type `help' to see this list.\n\
|
||||
Type `help name' to find out more about the function `name'.\n\
|
||||
Use `info bash' to find out more about the shell in general.\n\
|
||||
Use `man -k' or `info' to find out more about commands not in this list.\n\
|
||||
\n\
|
||||
A star (*) next to a name means that the command is disabled.\n\
|
||||
\n");
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is history.def, from which is created history.c.
|
||||
It implements the builtin "history" in Bash.
|
||||
|
||||
Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -70,6 +70,8 @@ $END
|
|||
extern int errno;
|
||||
#endif
|
||||
|
||||
extern int current_command_line_count;
|
||||
|
||||
static void display_history __P((WORD_LIST *));
|
||||
static int delete_histent __P((int));
|
||||
static int delete_last_history __P((void));
|
||||
|
|
@ -89,9 +91,9 @@ int
|
|||
history_builtin (list)
|
||||
WORD_LIST *list;
|
||||
{
|
||||
int flags, opt, result;
|
||||
int flags, opt, result, old_history_lines;
|
||||
char *filename, *delete_arg;
|
||||
long delete_offset;
|
||||
intmax_t delete_offset;
|
||||
|
||||
flags = 0;
|
||||
reset_internal_getopt ();
|
||||
|
|
@ -168,7 +170,7 @@ history_builtin (list)
|
|||
|| (delete_offset < history_base)
|
||||
|| (delete_offset > (history_base + history_length)))
|
||||
{
|
||||
builtin_error ("%s: not a valid history position", delete_arg);
|
||||
sh_erange (delete_arg, "history position");
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
opt = delete_offset;
|
||||
|
|
@ -197,10 +199,12 @@ history_builtin (list)
|
|||
else if (flags & NFLAG) /* Read `new' history from file. */
|
||||
{
|
||||
/* Read all of the lines in the file that we haven't already read. */
|
||||
old_history_lines = history_lines_in_file;
|
||||
using_history ();
|
||||
result = read_history_range (filename, history_lines_in_file, -1);
|
||||
using_history ();
|
||||
history_lines_in_file = where_history ();
|
||||
history_lines_this_session += history_lines_in_file - old_history_lines;
|
||||
}
|
||||
|
||||
return (result ? EXECUTION_FAILURE : EXECUTION_SUCCESS);
|
||||
|
|
@ -215,7 +219,7 @@ display_history (list)
|
|||
WORD_LIST *list;
|
||||
{
|
||||
register int i;
|
||||
long limit;
|
||||
intmax_t limit;
|
||||
HIST_ENTRY **hlist;
|
||||
|
||||
if (list)
|
||||
|
|
@ -297,10 +301,28 @@ push_history (list)
|
|||
{
|
||||
char *s;
|
||||
|
||||
/* Delete the last history entry if it was a single entry added to the
|
||||
history list (generally the `history -s' itself), or if `history -s'
|
||||
is being used in a compound command and the compound command was
|
||||
added to the history as a single element (command-oriented history).
|
||||
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_added && delete_last_history () == 0)
|
||||
#else
|
||||
if ((hist_last_line_added || (current_command_line_count > 0 && current_command_first_line_saved && command_oriented_history))
|
||||
&& delete_last_history () == 0)
|
||||
#endif
|
||||
return;
|
||||
|
||||
s = string_list (list);
|
||||
maybe_add_history (s); /* Obeys HISTCONTROL setting. */
|
||||
/* Call check_add_history with FORCE set to 1 to skip the check against
|
||||
current_command_line_count. If history -s is used in a compound
|
||||
command, the above code will delete the compound command's history
|
||||
entry and this call will add the line to the history as a separate
|
||||
entry. Without FORCE=1, if current_command_line_count were > 1, the
|
||||
line would be appended to the entry before the just-deleted entry. */
|
||||
check_add_history (s, 1); /* obeys HISTCONTROL, HISTIGNORE */
|
||||
free (s);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is inlib.def, from which is created inlib.c.
|
||||
It implements the Apollo-specific builtin "inlib" in Bash.
|
||||
|
||||
Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -51,7 +51,7 @@ inlib_builtin (list)
|
|||
|
||||
if (!list)
|
||||
{
|
||||
builtin_error ("usage: inlib pathname [pathname...]");
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
}
|
||||
|
||||
|
|
@ -64,7 +64,7 @@ inlib_builtin (list)
|
|||
|
||||
if (status.all != status_$ok)
|
||||
{
|
||||
builtin_error ("inlib failed for %s", list->word->word);
|
||||
builtin_error ("%s: inlib failed", list->word->word);
|
||||
return_value = EXECUTION_FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is jobs.def, from which is created jobs.c.
|
||||
It implements the builtins "jobs" and "disown" in Bash.
|
||||
|
||||
Copyright (C) 1987, 1989, 1991, 1992 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -98,7 +98,7 @@ jobs_builtin (list)
|
|||
case 'x':
|
||||
if (form != JLIST_STANDARD)
|
||||
{
|
||||
builtin_error ("Other options not allowed with `-x'");
|
||||
builtin_error ("no other options allowed with `-x'");
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
execute++;
|
||||
|
|
@ -145,7 +145,7 @@ jobs_builtin (list)
|
|||
|
||||
if ((job == NO_JOB) || !jobs || !jobs[job])
|
||||
{
|
||||
builtin_error ("no such job %s", list->word->word);
|
||||
sh_badjob (list->word->word);
|
||||
any_failed++;
|
||||
}
|
||||
else if (job != DUP_JOB)
|
||||
|
|
@ -219,7 +219,7 @@ disown_builtin (list)
|
|||
{
|
||||
int opt, job, retval, nohup_only, running_jobs, all_jobs;
|
||||
sigset_t set, oset;
|
||||
long pid_value;
|
||||
intmax_t pid_value;
|
||||
|
||||
nohup_only = running_jobs = all_jobs = 0;
|
||||
reset_internal_getopt ();
|
||||
|
|
@ -263,7 +263,7 @@ disown_builtin (list)
|
|||
|
||||
if (job == NO_JOB || jobs == 0 || job < 0 || job >= job_slots || jobs[job] == 0)
|
||||
{
|
||||
builtin_error ("%s: no such job", list ? list->word->word : "current");
|
||||
sh_badjob (list ? list->word->word : "current");
|
||||
retval = EXECUTION_FAILURE;
|
||||
}
|
||||
else if (nohup_only)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is kill.def, from which is created kill.c.
|
||||
It implements the builtin "kill" in Bash.
|
||||
|
||||
Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -73,10 +73,10 @@ int
|
|||
kill_builtin (list)
|
||||
WORD_LIST *list;
|
||||
{
|
||||
int signal, any_succeeded, listing, saw_signal;
|
||||
int sig, any_succeeded, listing, saw_signal;
|
||||
char *sigspec, *word;
|
||||
pid_t pid;
|
||||
long pid_value;
|
||||
intmax_t pid_value;
|
||||
|
||||
if (list == 0)
|
||||
{
|
||||
|
|
@ -85,7 +85,7 @@ kill_builtin (list)
|
|||
}
|
||||
|
||||
any_succeeded = listing = saw_signal = 0;
|
||||
signal = SIGTERM;
|
||||
sig = SIGTERM;
|
||||
sigspec = "TERM";
|
||||
|
||||
/* Process options. */
|
||||
|
|
@ -105,14 +105,14 @@ kill_builtin (list)
|
|||
{
|
||||
sigspec = list->word->word;
|
||||
if (sigspec[0] == '0' && sigspec[1] == '\0')
|
||||
signal = 0;
|
||||
sig = 0;
|
||||
else
|
||||
signal = decode_signal (sigspec);
|
||||
sig = decode_signal (sigspec);
|
||||
list = list->next;
|
||||
}
|
||||
else
|
||||
{
|
||||
builtin_error ("%s requires an argument", word);
|
||||
sh_needarg (word);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
}
|
||||
|
|
@ -132,7 +132,7 @@ kill_builtin (list)
|
|||
else if ((*word == '-') && !saw_signal)
|
||||
{
|
||||
sigspec = word + 1;
|
||||
signal = decode_signal (sigspec);
|
||||
sig = decode_signal (sigspec);
|
||||
saw_signal++;
|
||||
list = list->next;
|
||||
}
|
||||
|
|
@ -144,9 +144,9 @@ kill_builtin (list)
|
|||
return (display_signal_list (list, 0));
|
||||
|
||||
/* OK, we are killing processes. */
|
||||
if (signal == NO_SIG)
|
||||
if (sig == NO_SIG)
|
||||
{
|
||||
builtin_error ("bad signal spec `%s'", sigspec);
|
||||
sh_invalidsig (sigspec);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
|
|
@ -163,12 +163,12 @@ kill_builtin (list)
|
|||
if (*word == '-')
|
||||
word++;
|
||||
|
||||
if (*word && legal_number (word, &pid_value) && (pid_value == (pid_t)pid_value))
|
||||
{
|
||||
/* Use the entire argument in case of minus sign presence. */
|
||||
if (*word && legal_number (list->word->word, &pid_value) && (pid_value == (pid_t)pid_value))
|
||||
{
|
||||
pid = (pid_t) pid_value;
|
||||
|
||||
if (kill_pid (pid, signal, 0) < 0)
|
||||
if ((pid < -1 ? kill_pid (-pid, sig, 1) : kill_pid (pid, sig, 0)) < 0)
|
||||
goto signal_error;
|
||||
else
|
||||
any_succeeded++;
|
||||
|
|
@ -190,7 +190,7 @@ kill_builtin (list)
|
|||
if (job < 0 || job >= job_slots || !jobs[job])
|
||||
{
|
||||
if (job != DUP_JOB)
|
||||
builtin_error ("%s: no such job", list->word->word);
|
||||
sh_badjob (list->word->word);
|
||||
UNBLOCK_CHILD (oset);
|
||||
CONTINUE_OR_FAIL;
|
||||
}
|
||||
|
|
@ -203,11 +203,11 @@ kill_builtin (list)
|
|||
|
||||
UNBLOCK_CHILD (oset);
|
||||
|
||||
if (kill_pid (pid, signal, 1) < 0)
|
||||
if (kill_pid (pid, sig, 1) < 0)
|
||||
{
|
||||
signal_error:
|
||||
if (errno == EINVAL)
|
||||
builtin_error ("Invalid signal %d", signal);
|
||||
sh_invalidsig (sigspec);
|
||||
else
|
||||
builtin_error ("(%ld) - %s", (long)pid, strerror (errno));
|
||||
CONTINUE_OR_FAIL;
|
||||
|
|
@ -217,7 +217,7 @@ kill_builtin (list)
|
|||
}
|
||||
else
|
||||
{
|
||||
builtin_error ("`%s': not a pid or valid job spec", list->word->word);
|
||||
sh_badpid (list->word->word);
|
||||
CONTINUE_OR_FAIL;
|
||||
}
|
||||
continue_killing:
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is let.def, from which is created let.c.
|
||||
It implements the builtin "let" in Bash.
|
||||
|
||||
Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -24,13 +24,16 @@ $FUNCTION let_builtin
|
|||
$PRODUCES let.c
|
||||
$SHORT_DOC let arg [arg ...]
|
||||
Each ARG is an arithmetic expression to be evaluated. Evaluation
|
||||
is done in long integers with no check for overflow, though division
|
||||
by 0 is trapped and flagged as an error. The following list of
|
||||
operators is grouped into levels of equal-precedence operators.
|
||||
is done in fixed-width integers with no check for overflow, though
|
||||
division by 0 is trapped and flagged as an error. The following
|
||||
list of operators is grouped into levels of equal-precedence operators.
|
||||
The levels are listed in order of decreasing precedence.
|
||||
|
||||
id++, id-- variable post-increment, post-decrement
|
||||
++id, --id variable pre-increment, pre-decrement
|
||||
-, + unary minus, plus
|
||||
!, ~ logical and bitwise negation
|
||||
** exponentiation
|
||||
*, /, % multiplication, division, remainder
|
||||
+, - addition, subtraction
|
||||
<<, >> left and right bitwise shifts
|
||||
|
|
@ -48,7 +51,7 @@ The levels are listed in order of decreasing precedence.
|
|||
&=, ^=, |= assignment
|
||||
|
||||
Shell variables are allowed as operands. The name of the variable
|
||||
is replaced by its value (coerced to a long integer) within
|
||||
is replaced by its value (coerced to a fixed-width integer) within
|
||||
an expression. The variable need not have its integer attribute
|
||||
turned on to be used in an expression.
|
||||
|
||||
|
|
@ -77,9 +80,13 @@ int
|
|||
let_builtin (list)
|
||||
WORD_LIST *list;
|
||||
{
|
||||
long ret;
|
||||
intmax_t ret;
|
||||
int expok;
|
||||
|
||||
/* Skip over leading `--' argument. */
|
||||
if (list && list->word && ISOPTION (list->word->word, '-'))
|
||||
list = list->next;
|
||||
|
||||
if (list == 0)
|
||||
{
|
||||
builtin_error ("expression expected");
|
||||
|
|
@ -102,7 +109,8 @@ exp_builtin (list)
|
|||
WORD_LIST *list;
|
||||
{
|
||||
char *exp;
|
||||
int ret, expok;
|
||||
intmax_t ret;
|
||||
int expok;
|
||||
|
||||
if (list == 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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, 1989, 1991 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -38,11 +38,16 @@ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
|||
|
||||
#include "../bashansi.h"
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "stdc.h"
|
||||
|
||||
#define DOCFILE "builtins.texi"
|
||||
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
static char *xmalloc (), *xrealloc ();
|
||||
|
||||
#if !defined (__STDC__) && !defined (strcpy)
|
||||
|
|
@ -66,9 +71,13 @@ int only_documentation = 0;
|
|||
/* Non-zero means to not do any productions. */
|
||||
int inhibit_production = 0;
|
||||
|
||||
#if !defined (OLDCODE)
|
||||
int no_long_document = 0;
|
||||
#endif /* !OLDCODE */
|
||||
/* Non-zero means to produce separate help files for each builtin, named by
|
||||
the builtin name, in `./helpfiles'. */
|
||||
int separate_helpfiles = 0;
|
||||
|
||||
/* The name of a directory into which the separate external help files will
|
||||
eventually be installed. */
|
||||
char *helpfile_directory;
|
||||
|
||||
/* The name of a directory to precede the filename when reporting
|
||||
errors. */
|
||||
|
|
@ -149,11 +158,16 @@ void write_documentation ();
|
|||
void write_longdocs ();
|
||||
void write_builtins ();
|
||||
|
||||
int write_helpfiles ();
|
||||
|
||||
void free_defs ();
|
||||
void add_documentation ();
|
||||
|
||||
void must_be_building ();
|
||||
void remove_trailing_whitespace ();
|
||||
|
||||
#define document_name(b) ((b)->docname ? (b)->docname : (b)->name)
|
||||
|
||||
|
||||
/* For each file mentioned on the command line, process it and
|
||||
write the information to STRUCTFILE and EXTERNFILE, while
|
||||
|
|
@ -204,10 +218,11 @@ main (argc, argv)
|
|||
only_documentation = 1;
|
||||
documentation_file = fopen (documentation_filename, "w");
|
||||
}
|
||||
#if !defined (OLDCODE)
|
||||
else if (strcmp (arg, "-nodocument") == 0)
|
||||
no_long_document = 1;
|
||||
#endif /* !OLDCODE */
|
||||
else if (strcmp (arg, "-H") == 0)
|
||||
{
|
||||
separate_helpfiles = 1;
|
||||
helpfile_directory = argv[arg_index++];
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (stderr, "%s: Unknown flag %s.\n", argv[0], arg);
|
||||
|
|
@ -278,6 +293,11 @@ main (argc, argv)
|
|||
fclose (externfile);
|
||||
}
|
||||
|
||||
if (separate_helpfiles)
|
||||
{
|
||||
write_helpfiles (saved_builtins);
|
||||
}
|
||||
|
||||
if (documentation_file)
|
||||
{
|
||||
fprintf (documentation_file, "@end ftable\n");
|
||||
|
|
@ -1038,6 +1058,7 @@ save_builtin (builtin)
|
|||
/* Flags that mean something to write_documentation (). */
|
||||
#define STRING_ARRAY 1
|
||||
#define TEXINFO 2
|
||||
#define PLAINTEXT 4
|
||||
|
||||
char *structfile_header[] = {
|
||||
"/* builtins.c -- the built in shell commands. */",
|
||||
|
|
@ -1045,7 +1066,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, 1991, 1992 Free Software Foundation, Inc.",
|
||||
"/* Copyright (C) 1987-2002 Free Software Foundation, Inc.",
|
||||
"",
|
||||
" This file is part of GNU Bash, the Bourne Again SHell.",
|
||||
"",
|
||||
|
|
@ -1165,8 +1186,8 @@ write_builtins (defs, structfile, externfile)
|
|||
fprintf (externfile, "extern int %s __P((WORD_LIST *));\n",
|
||||
builtin->function);
|
||||
|
||||
fprintf (externfile, "extern char *%s_doc[];\n",
|
||||
builtin->docname ? builtin->docname : builtin->name);
|
||||
fprintf (externfile, "extern char * const %s_doc[];\n",
|
||||
document_name (builtin));
|
||||
}
|
||||
|
||||
/* Write the structure definition. */
|
||||
|
|
@ -1183,16 +1204,18 @@ write_builtins (defs, structfile, externfile)
|
|||
"BUILTIN_ENABLED | STATIC_BUILTIN",
|
||||
(builtin->flags & BUILTIN_FLAG_SPECIAL) ? " | SPECIAL_BUILTIN" : "",
|
||||
(builtin->flags & BUILTIN_FLAG_ASSIGNMENT) ? " | ASSIGNMENT_BUILTIN" : "",
|
||||
builtin->docname ? builtin->docname : builtin->name);
|
||||
document_name (builtin));
|
||||
|
||||
fprintf
|
||||
(structfile, " \"%s\", (char *)NULL },\n",
|
||||
builtin->shortdoc ? builtin->shortdoc : builtin->name);
|
||||
|
||||
}
|
||||
|
||||
if (structfile || separate_helpfiles)
|
||||
/* Save away this builtin for later writing of the
|
||||
long documentation strings. */
|
||||
save_builtin (builtin);
|
||||
}
|
||||
|
||||
/* Write out the matching #endif, if neccessary. */
|
||||
if (builtin->dependencies)
|
||||
|
|
@ -1223,6 +1246,8 @@ write_longdocs (stream, builtins)
|
|||
{
|
||||
register int i;
|
||||
register BUILTIN_DESC *builtin;
|
||||
char *dname;
|
||||
char *sarray[2];
|
||||
|
||||
for (i = 0; i < builtins->sindex; i++)
|
||||
{
|
||||
|
|
@ -1232,8 +1257,19 @@ write_longdocs (stream, builtins)
|
|||
write_ifdefs (stream, builtin->dependencies->array);
|
||||
|
||||
/* Write the long documentation strings. */
|
||||
fprintf (stream, "char *%s_doc[] =",
|
||||
builtin->docname ? builtin->docname : builtin->name);
|
||||
dname = document_name (builtin);
|
||||
fprintf (stream, "char * const %s_doc[] =", dname);
|
||||
|
||||
if (separate_helpfiles)
|
||||
{
|
||||
int l = strlen (helpfile_directory) + strlen (dname) + 1;
|
||||
sarray[0] = (char *)xmalloc (l + 1);
|
||||
sprintf (sarray[0], "%s/%s", helpfile_directory, dname);
|
||||
sarray[1] = (char *)NULL;
|
||||
write_documentation (stream, sarray, 0, STRING_ARRAY);
|
||||
free (sarray[0]);
|
||||
}
|
||||
else
|
||||
write_documentation (stream, builtin->longdoc->array, 0, STRING_ARRAY);
|
||||
|
||||
if (builtin->dependencies)
|
||||
|
|
@ -1321,12 +1357,6 @@ write_documentation (stream, documentation, indentation, flags)
|
|||
if (string_array)
|
||||
fprintf (stream, " {\n#if defined (HELP_BUILTIN)\n");
|
||||
|
||||
#if !defined (OLDCODE)
|
||||
/* XXX -- clean me up; for experiment only */
|
||||
if (no_long_document)
|
||||
goto end_of_document;
|
||||
#endif /* !OLDCODE */
|
||||
|
||||
for (i = 0, texinfo = (flags & TEXINFO); line = documentation[i]; i++)
|
||||
{
|
||||
/* Allow #ifdef's to be written out verbatim. */
|
||||
|
|
@ -1384,14 +1414,52 @@ write_documentation (stream, documentation, indentation, flags)
|
|||
fprintf (stream, "%s\n", line);
|
||||
}
|
||||
|
||||
#if !defined (OLDCODE)
|
||||
end_of_document:
|
||||
#endif /* !OLDCODE */
|
||||
|
||||
if (string_array)
|
||||
fprintf (stream, "#endif /* HELP_BUILTIN */\n (char *)NULL\n};\n");
|
||||
}
|
||||
|
||||
int
|
||||
write_helpfiles (builtins)
|
||||
ARRAY *builtins;
|
||||
{
|
||||
char *helpfile, *bname;
|
||||
FILE *helpfp;
|
||||
int i, hdlen;
|
||||
BUILTIN_DESC *builtin;
|
||||
|
||||
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 < builtins->sindex; i++)
|
||||
{
|
||||
builtin = (BUILTIN_DESC *)builtins->array[i];
|
||||
|
||||
bname = document_name (builtin);
|
||||
helpfile = (char *)xmalloc (hdlen + strlen (bname) + 1);
|
||||
sprintf (helpfile, "helpfiles/%s", bname);
|
||||
|
||||
helpfp = fopen (helpfile, "w");
|
||||
if (helpfp == 0)
|
||||
{
|
||||
fprintf (stderr, "write_helpfiles: cannot open %s\n", helpfile);
|
||||
free (helpfile);
|
||||
continue;
|
||||
}
|
||||
|
||||
write_documentation (helpfp, builtin->longdoc->array, 4, PLAINTEXT);
|
||||
|
||||
fflush (helpfp);
|
||||
fclose (helpfp);
|
||||
free (helpfile);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_find_in_table (name, name_table)
|
||||
char *name, *name_table[];
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is printf.def, from which is created printf.c.
|
||||
It implements the builtin "printf" in Bash.
|
||||
|
||||
Copyright (C) 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1997-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -56,18 +56,17 @@ $END
|
|||
|
||||
#include "../bashansi.h"
|
||||
|
||||
#define NEED_STRTOIMAX_DECL
|
||||
|
||||
#include "../shell.h"
|
||||
#include "stdc.h"
|
||||
#include "bashgetopt.h"
|
||||
#include "common.h"
|
||||
|
||||
/* This should use the ISO C constant format strings; I'll do that later. */
|
||||
#if SIZEOF_LONG < SIZEOF_LONG_LONG
|
||||
# define INTMAX_CONV "ll"
|
||||
#if !defined (PRIdMAX)
|
||||
# if HAVE_LONG_LONG
|
||||
# define PRIdMAX "lld"
|
||||
# else
|
||||
# define INTMAX_CONV "l"
|
||||
# define PRIdMAX "ld"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined (errno)
|
||||
|
|
@ -104,25 +103,28 @@ extern int errno;
|
|||
#define SKIP1 "#'-+ 0"
|
||||
#define LENMODS "hjlLtz"
|
||||
|
||||
static void printf_erange __P((char *));
|
||||
static void printstr __P((char *, char *, int, int, int));
|
||||
static int tescape __P((char *, int, char *, int *));
|
||||
static char *bexpand __P((char *, int, int *, int *));
|
||||
static char *mklong __P((char *, char *));
|
||||
static char *mklong __P((char *, char *, size_t));
|
||||
static int getchr __P((void));
|
||||
static char *getstr __P((void));
|
||||
static int getint __P((void));
|
||||
static long getlong __P((void));
|
||||
static unsigned long getulong __P((void));
|
||||
#if defined (HAVE_LONG_LONG)
|
||||
static long long getllong __P((void));
|
||||
static unsigned long long getullong __P((void));
|
||||
#endif
|
||||
static intmax_t getintmax __P((void));
|
||||
static uintmax_t getuintmax __P((void));
|
||||
static double getdouble __P((void));
|
||||
|
||||
#if defined (HAVE_LONG_DOUBLE) && HAVE_DECL_STRTOLD
|
||||
static long double getldouble __P((void));
|
||||
typedef long double floatmax_t;
|
||||
# define FLOATMAX_CONV "L"
|
||||
# define strtofltmax strtold
|
||||
#else
|
||||
typedef double floatmax_t;
|
||||
# define FLOATMAX_CONV ""
|
||||
# define strtofltmax strtod
|
||||
#endif
|
||||
static floatmax_t getfloatmax __P((void));
|
||||
|
||||
static int asciicode __P((void));
|
||||
|
||||
static WORD_LIST *garglist;
|
||||
|
|
@ -138,18 +140,15 @@ printf_builtin (list)
|
|||
{
|
||||
int ch, fieldwidth, precision;
|
||||
int have_fieldwidth, have_precision;
|
||||
long tw;
|
||||
intmax_t tw;
|
||||
char convch, thisch, nextch, *format, *modstart, *fmt, *start;
|
||||
|
||||
conversion_error = 0;
|
||||
retval = EXECUTION_SUCCESS;
|
||||
reset_internal_getopt ();
|
||||
if (internal_getopt (list, "") != -1)
|
||||
{
|
||||
builtin_usage();
|
||||
|
||||
if (no_options (list))
|
||||
return (EX_USAGE);
|
||||
}
|
||||
list = loptend;
|
||||
list = loptend; /* skip over possible `--' */
|
||||
|
||||
if (list == 0)
|
||||
{
|
||||
|
|
@ -288,7 +287,7 @@ printf_builtin (list)
|
|||
bind_var_to_int (var, tw);
|
||||
else
|
||||
{
|
||||
builtin_error ("%s: invalid variable name", var);
|
||||
sh_invalidid (var);
|
||||
PRETURN (EXECUTION_FAILURE);
|
||||
}
|
||||
}
|
||||
|
|
@ -322,6 +321,9 @@ printf_builtin (list)
|
|||
char *p, *xp;
|
||||
|
||||
p = getstr ();
|
||||
if (ansic_shouldquote (p))
|
||||
xp = ansic_quote (p, 0, (int *)0);
|
||||
else
|
||||
xp = sh_backslash_quote (p);
|
||||
if (xp)
|
||||
{
|
||||
|
|
@ -336,31 +338,22 @@ printf_builtin (list)
|
|||
case 'i':
|
||||
{
|
||||
char *f;
|
||||
#if defined (HAVE_LONG_LONG)
|
||||
if (thisch == 'l' && nextch == 'l')
|
||||
{
|
||||
long long p;
|
||||
|
||||
p = getllong ();
|
||||
f = mklong (start, "ll");
|
||||
PF(f, p);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (thisch == 'j')
|
||||
{
|
||||
intmax_t p;
|
||||
|
||||
p = getintmax ();
|
||||
f = mklong (start, INTMAX_CONV);
|
||||
PF(f, p);
|
||||
}
|
||||
else
|
||||
{
|
||||
long p;
|
||||
intmax_t pp;
|
||||
|
||||
p = getlong ();
|
||||
f = mklong (start, "l");
|
||||
p = pp = getintmax ();
|
||||
if (p != pp)
|
||||
{
|
||||
f = mklong (start, PRIdMAX, sizeof (PRIdMAX) - 2);
|
||||
PF (f, pp);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Optimize the common case where the integer fits
|
||||
in "long". This also works around some long
|
||||
long and/or intmax_t library bugs in the common
|
||||
case, e.g. glibc 2.2 x86. */
|
||||
f = mklong (start, "l", 1);
|
||||
PF (f, p);
|
||||
}
|
||||
break;
|
||||
|
|
@ -372,31 +365,18 @@ printf_builtin (list)
|
|||
case 'X':
|
||||
{
|
||||
char *f;
|
||||
#if defined (HAVE_LONG_LONG)
|
||||
if (thisch == 'l' && nextch == 'l')
|
||||
{
|
||||
unsigned long long p;
|
||||
|
||||
p = getullong ();
|
||||
f = mklong (start, "ll");
|
||||
PF(f, p);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (thisch == 'j')
|
||||
{
|
||||
uintmax_t p;
|
||||
|
||||
p = getuintmax ();
|
||||
f = mklong (start, INTMAX_CONV);
|
||||
PF(f, p);
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned long p;
|
||||
uintmax_t pp;
|
||||
|
||||
p = getulong ();
|
||||
f = mklong (start, "l");
|
||||
p = pp = getuintmax ();
|
||||
if (p != pp)
|
||||
{
|
||||
f = mklong (start, PRIdMAX, sizeof (PRIdMAX) - 2);
|
||||
PF (f, pp);
|
||||
}
|
||||
else
|
||||
{
|
||||
f = mklong (start, "l", 1);
|
||||
PF (f, p);
|
||||
}
|
||||
break;
|
||||
|
|
@ -414,24 +394,11 @@ printf_builtin (list)
|
|||
#endif
|
||||
{
|
||||
char *f;
|
||||
#if defined (HAVE_LONG_DOUBLE) && HAVE_DECL_STRTOLD
|
||||
if (thisch == 'L')
|
||||
{
|
||||
long double p;
|
||||
floatmax_t p;
|
||||
|
||||
p = getldouble ();
|
||||
f = mklong (start, "L");
|
||||
p = getfloatmax ();
|
||||
f = mklong (start, FLOATMAX_CONV, sizeof(FLOATMAX_CONV) - 1);
|
||||
PF (f, p);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
double p;
|
||||
|
||||
p = getdouble ();
|
||||
f = mklong (start, "");
|
||||
PF (f, p);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -454,6 +421,13 @@ printf_builtin (list)
|
|||
PRETURN (retval);
|
||||
}
|
||||
|
||||
static void
|
||||
printf_erange (s)
|
||||
char *s;
|
||||
{
|
||||
builtin_error ("warning: %s: %s", s, strerror(ERANGE));
|
||||
}
|
||||
|
||||
/* We duplicate a lot of what printf(3) does here. */
|
||||
static void
|
||||
printstr (fmt, string, len, fieldwidth, precision)
|
||||
|
|
@ -605,16 +579,11 @@ tescape (estart, trans_squote, cp, sawc)
|
|||
/* %b octal constants are `\0' followed by one, two, or three
|
||||
octal digits... */
|
||||
case '0':
|
||||
for (temp = 3, evalue = 0; ISOCTAL (*p) && temp--; p++)
|
||||
evalue = (evalue * 8) + OCTVALUE (*p);
|
||||
*cp = evalue & 0xFF;
|
||||
break;
|
||||
|
||||
/* but, as an extension, the other echo-like octal escape
|
||||
sequences are supported as well. */
|
||||
case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7':
|
||||
for (temp = 2, evalue = c - '0'; ISOCTAL (*p) && temp--; p++)
|
||||
for (temp = 2+(c=='0'), evalue = c - '0'; ISOCTAL (*p) && temp--; p++)
|
||||
evalue = (evalue * 8) + OCTVALUE (*p);
|
||||
*cp = evalue & 0xFF;
|
||||
break;
|
||||
|
|
@ -706,14 +675,14 @@ bexpand (string, len, sawc, lenp)
|
|||
}
|
||||
|
||||
static char *
|
||||
mklong (str, modifiers)
|
||||
mklong (str, modifiers, mlen)
|
||||
char *str;
|
||||
char *modifiers;
|
||||
size_t mlen;
|
||||
{
|
||||
size_t len, slen, mlen;
|
||||
size_t len, slen;
|
||||
|
||||
slen = strlen (str);
|
||||
mlen = strlen (modifiers);
|
||||
len = slen + mlen + 1;
|
||||
|
||||
if (len > conv_bufsize)
|
||||
|
|
@ -759,152 +728,24 @@ getstr ()
|
|||
static int
|
||||
getint ()
|
||||
{
|
||||
long ret;
|
||||
intmax_t ret;
|
||||
|
||||
ret = getlong ();
|
||||
ret = getintmax ();
|
||||
|
||||
if (ret > INT_MAX)
|
||||
{
|
||||
builtin_error ("warning: %s: %s", garglist->word->word, strerror(ERANGE));
|
||||
printf_erange (garglist->word->word);
|
||||
ret = INT_MAX;
|
||||
}
|
||||
else if (ret < INT_MIN)
|
||||
{
|
||||
builtin_error ("warning: %s: %s", garglist->word->word, strerror(ERANGE));
|
||||
printf_erange (garglist->word->word);
|
||||
ret = INT_MIN;
|
||||
}
|
||||
|
||||
return ((int)ret);
|
||||
}
|
||||
|
||||
static long
|
||||
getlong ()
|
||||
{
|
||||
long ret;
|
||||
char *ep;
|
||||
|
||||
if (garglist == 0)
|
||||
return (0);
|
||||
|
||||
if (garglist->word->word[0] == '\'' || garglist->word->word[0] == '"')
|
||||
return asciicode ();
|
||||
|
||||
errno = 0;
|
||||
ret = strtol (garglist->word->word, &ep, 0);
|
||||
|
||||
if (*ep)
|
||||
{
|
||||
builtin_error ("%s: invalid number", garglist->word->word);
|
||||
/* POSIX.2 says ``...a diagnostic message shall be written to standard
|
||||
error, and the utility shall not exit with a zero exit status, but
|
||||
shall continue processing any remaining operands and shall write the
|
||||
value accumulated at the time the error was detected to standard
|
||||
output.'' Yecch. */
|
||||
ret = 0;
|
||||
conversion_error = 1;
|
||||
}
|
||||
else if (errno == ERANGE)
|
||||
builtin_error ("warning: %s: %s", garglist->word->word, strerror(ERANGE));
|
||||
|
||||
garglist = garglist->next;
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static unsigned long
|
||||
getulong ()
|
||||
{
|
||||
unsigned long ret;
|
||||
char *ep;
|
||||
|
||||
if (garglist == 0)
|
||||
return (0);
|
||||
|
||||
if (garglist->word->word[0] == '\'' || garglist->word->word[0] == '"')
|
||||
return asciicode ();
|
||||
|
||||
errno = 0;
|
||||
ret = strtoul (garglist->word->word, &ep, 0);
|
||||
|
||||
if (*ep)
|
||||
{
|
||||
builtin_error ("%s: invalid number", garglist->word->word);
|
||||
/* Same thing about POSIX.2 conversion error requirements as getlong(). */
|
||||
ret = 0;
|
||||
conversion_error = 1;
|
||||
}
|
||||
else if (errno == ERANGE)
|
||||
builtin_error ("warning: %s: %s", garglist->word->word, strerror(ERANGE));
|
||||
|
||||
garglist = garglist->next;
|
||||
return (ret);
|
||||
}
|
||||
|
||||
#if defined (HAVE_LONG_LONG)
|
||||
|
||||
static long long
|
||||
getllong ()
|
||||
{
|
||||
long long ret;
|
||||
char *ep;
|
||||
|
||||
if (garglist == 0)
|
||||
return (0);
|
||||
|
||||
if (garglist->word->word[0] == '\'' || garglist->word->word[0] == '"')
|
||||
return asciicode ();
|
||||
|
||||
errno = 0;
|
||||
ret = strtoll (garglist->word->word, &ep, 0);
|
||||
|
||||
if (*ep)
|
||||
{
|
||||
builtin_error ("%s: invalid number", garglist->word->word);
|
||||
/* POSIX.2 says ``...a diagnostic message shall be written to standard
|
||||
error, and the utility shall not exit with a zero exit status, but
|
||||
shall continue processing any remaining operands and shall write the
|
||||
value accumulated at the time the error was detected to standard
|
||||
output.'' Yecch. */
|
||||
ret = 0;
|
||||
conversion_error = 1;
|
||||
}
|
||||
else if (errno == ERANGE)
|
||||
builtin_error ("warning: %s: %s", garglist->word->word, strerror(ERANGE));
|
||||
|
||||
garglist = garglist->next;
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static unsigned long long
|
||||
getullong ()
|
||||
{
|
||||
unsigned long long ret;
|
||||
char *ep;
|
||||
|
||||
if (garglist == 0)
|
||||
return (0);
|
||||
|
||||
if (garglist->word->word[0] == '\'' || garglist->word->word[0] == '"')
|
||||
return asciicode ();
|
||||
|
||||
errno = 0;
|
||||
ret = strtoull (garglist->word->word, &ep, 0);
|
||||
|
||||
if (*ep)
|
||||
{
|
||||
builtin_error ("%s: invalid number", garglist->word->word);
|
||||
/* Same thing about POSIX.2 conversion error requirements as getlong(). */
|
||||
ret = 0;
|
||||
conversion_error = 1;
|
||||
}
|
||||
else if (errno == ERANGE)
|
||||
builtin_error ("warning: %s: %s", garglist->word->word, strerror(ERANGE));
|
||||
|
||||
garglist = garglist->next;
|
||||
return (ret);
|
||||
}
|
||||
|
||||
#endif /* HAVE_LONG_LONG */
|
||||
|
||||
static intmax_t
|
||||
getintmax ()
|
||||
{
|
||||
|
|
@ -922,7 +763,7 @@ getintmax ()
|
|||
|
||||
if (*ep)
|
||||
{
|
||||
builtin_error ("%s: invalid number", garglist->word->word);
|
||||
sh_invalidnum (garglist->word->word);
|
||||
/* POSIX.2 says ``...a diagnostic message shall be written to standard
|
||||
error, and the utility shall not exit with a zero exit status, but
|
||||
shall continue processing any remaining operands and shall write the
|
||||
|
|
@ -932,7 +773,7 @@ getintmax ()
|
|||
conversion_error = 1;
|
||||
}
|
||||
else if (errno == ERANGE)
|
||||
builtin_error ("warning: %s: %s", garglist->word->word, strerror(ERANGE));
|
||||
printf_erange (garglist->word->word);
|
||||
|
||||
garglist = garglist->next;
|
||||
return (ret);
|
||||
|
|
@ -955,22 +796,22 @@ getuintmax ()
|
|||
|
||||
if (*ep)
|
||||
{
|
||||
builtin_error ("%s: invalid number", garglist->word->word);
|
||||
/* Same thing about POSIX.2 conversion error requirements as getlong(). */
|
||||
sh_invalidnum (garglist->word->word);
|
||||
/* Same POSIX.2 conversion error requirements as getintmax(). */
|
||||
ret = 0;
|
||||
conversion_error = 1;
|
||||
}
|
||||
else if (errno == ERANGE)
|
||||
builtin_error ("warning: %s: %s", garglist->word->word, strerror(ERANGE));
|
||||
printf_erange (garglist->word->word);
|
||||
|
||||
garglist = garglist->next;
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static double
|
||||
getdouble ()
|
||||
static floatmax_t
|
||||
getfloatmax ()
|
||||
{
|
||||
double ret;
|
||||
floatmax_t ret;
|
||||
char *ep;
|
||||
|
||||
if (garglist == 0)
|
||||
|
|
@ -980,53 +821,22 @@ getdouble ()
|
|||
return asciicode ();
|
||||
|
||||
errno = 0;
|
||||
ret = strtod (garglist->word->word, &ep);
|
||||
ret = strtofltmax (garglist->word->word, &ep);
|
||||
|
||||
if (*ep)
|
||||
{
|
||||
builtin_error ("%s: invalid number", garglist->word->word);
|
||||
sh_invalidnum (garglist->word->word);
|
||||
/* Same thing about POSIX.2 conversion error requirements. */
|
||||
ret = 0;
|
||||
conversion_error = 1;
|
||||
}
|
||||
else if (errno == ERANGE)
|
||||
builtin_error ("warning: %s: %s", garglist->word->word, strerror(ERANGE));
|
||||
printf_erange (garglist->word->word);
|
||||
|
||||
garglist = garglist->next;
|
||||
return (ret);
|
||||
}
|
||||
|
||||
#if defined (HAVE_LONG_DOUBLE) && HAVE_DECL_STRTOLD
|
||||
static long double
|
||||
getldouble ()
|
||||
{
|
||||
long double ret;
|
||||
char *ep;
|
||||
|
||||
if (garglist == 0)
|
||||
return (0);
|
||||
|
||||
if (garglist->word->word[0] == '\'' || garglist->word->word[0] == '"')
|
||||
return (asciicode ());
|
||||
|
||||
errno = 0;
|
||||
ret = strtold (garglist->word->word, &ep);
|
||||
|
||||
if (*ep)
|
||||
{
|
||||
builtin_error ("%s: invalid number", garglist->word->word);
|
||||
/* Same thing about POSIX.2 conversion error requirements. */
|
||||
ret = 0;
|
||||
conversion_error = 1;
|
||||
}
|
||||
else if (errno == ERANGE)
|
||||
builtin_error ("warning: %s: %s", garglist->word->word, strerror(ERANGE));
|
||||
|
||||
garglist = garglist->next;
|
||||
return (ret);
|
||||
}
|
||||
#endif /* HAVE_LONG_DOUBLE && HAVE_DECL_STRTOLD */
|
||||
|
||||
/* NO check is needed for garglist here. */
|
||||
static int
|
||||
asciicode ()
|
||||
|
|
|
|||
|
|
@ -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, 1989, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -125,8 +125,6 @@ $END
|
|||
extern int errno;
|
||||
#endif /* !errno */
|
||||
|
||||
static char *m_badarg = "%s: bad argument";
|
||||
|
||||
/* The list of remembered directories. */
|
||||
static char **pushd_directory_list = (char **)NULL;
|
||||
|
||||
|
|
@ -141,7 +139,7 @@ static void clear_directory_stack __P((void));
|
|||
static int cd_to_string __P((char *));
|
||||
static int change_to_temp __P((char *));
|
||||
static void add_dirstack_element __P((char *));
|
||||
static int get_dirstack_index __P((long, int, int *));
|
||||
static int get_dirstack_index __P((intmax_t, int, int *));
|
||||
|
||||
#define NOCD 0x01
|
||||
#define ROTATE 0x02
|
||||
|
|
@ -154,9 +152,12 @@ pushd_builtin (list)
|
|||
{
|
||||
char *temp, *current_directory, *top;
|
||||
int j, flags;
|
||||
long num;
|
||||
intmax_t num;
|
||||
char direction;
|
||||
|
||||
if (list && list->word && ISOPTION (list->word->word, '-'))
|
||||
list = list->next;
|
||||
|
||||
/* If there is no argument list then switch current and
|
||||
top of list. */
|
||||
if (list == 0)
|
||||
|
|
@ -197,7 +198,7 @@ pushd_builtin (list)
|
|||
{
|
||||
if (legal_number (list->word->word + 1, &num) == 0)
|
||||
{
|
||||
builtin_error (m_badarg, list->word->word);
|
||||
sh_invalidnum (list->word->word);
|
||||
builtin_usage ();
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
|
@ -214,7 +215,7 @@ pushd_builtin (list)
|
|||
}
|
||||
else if (*list->word->word == '-')
|
||||
{
|
||||
bad_option (list->word->word);
|
||||
sh_invalidopt (list->word->word);
|
||||
builtin_usage ();
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
|
@ -287,7 +288,7 @@ popd_builtin (list)
|
|||
WORD_LIST *list;
|
||||
{
|
||||
register int i;
|
||||
long which;
|
||||
intmax_t which;
|
||||
int flags;
|
||||
char direction;
|
||||
char *which_word;
|
||||
|
|
@ -308,7 +309,7 @@ popd_builtin (list)
|
|||
{
|
||||
if (legal_number (list->word->word + 1, &which) == 0)
|
||||
{
|
||||
builtin_error (m_badarg, list->word->word);
|
||||
sh_invalidnum (list->word->word);
|
||||
builtin_usage ();
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
|
@ -316,7 +317,7 @@ popd_builtin (list)
|
|||
}
|
||||
else if (*list->word->word == '-')
|
||||
{
|
||||
bad_option (list->word->word);
|
||||
sh_invalidopt (list->word->word);
|
||||
builtin_usage ();
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
|
@ -364,7 +365,7 @@ dirs_builtin (list)
|
|||
WORD_LIST *list;
|
||||
{
|
||||
int flags, desired_index, index_flag, vflag;
|
||||
long i;
|
||||
intmax_t i;
|
||||
char *temp, *w;
|
||||
|
||||
for (flags = vflag = index_flag = 0, desired_index = -1, w = ""; list; list = list->next)
|
||||
|
|
@ -395,7 +396,7 @@ dirs_builtin (list)
|
|||
int sign;
|
||||
if (legal_number (w = list->word->word + 1, &i) == 0)
|
||||
{
|
||||
builtin_error (m_badarg, list->word->word);
|
||||
sh_invalidnum (list->word->word);
|
||||
builtin_usage ();
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
|
@ -404,7 +405,7 @@ dirs_builtin (list)
|
|||
}
|
||||
else
|
||||
{
|
||||
bad_option (list->word->word);
|
||||
sh_invalidopt (list->word->word);
|
||||
builtin_usage ();
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
|
@ -475,10 +476,8 @@ pushd_error (offset, arg)
|
|||
{
|
||||
if (offset == 0)
|
||||
builtin_error ("directory stack empty");
|
||||
else if (arg)
|
||||
builtin_error ("%s: bad directory stack index", arg);
|
||||
else
|
||||
builtin_error ("bad directory stack index");
|
||||
sh_erange (arg, "directory stack index");
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -525,19 +524,14 @@ static void
|
|||
add_dirstack_element (dir)
|
||||
char *dir;
|
||||
{
|
||||
int j;
|
||||
|
||||
if (directory_list_offset == directory_list_size)
|
||||
{
|
||||
j = (directory_list_size += 10) * sizeof (char *);
|
||||
pushd_directory_list = (char **)xrealloc (pushd_directory_list, j);
|
||||
}
|
||||
pushd_directory_list = strvec_resize (pushd_directory_list, directory_list_size += 10);
|
||||
pushd_directory_list[directory_list_offset++] = dir;
|
||||
}
|
||||
|
||||
static int
|
||||
get_dirstack_index (ind, sign, indexp)
|
||||
long ind;
|
||||
intmax_t ind;
|
||||
int sign, *indexp;
|
||||
{
|
||||
if (indexp)
|
||||
|
|
@ -565,7 +559,7 @@ get_dirstack_from_string (string)
|
|||
char *string;
|
||||
{
|
||||
int ind, sign, index_flag;
|
||||
long i;
|
||||
intmax_t i;
|
||||
|
||||
sign = 1;
|
||||
if (*string == '-' || *string == '+')
|
||||
|
|
@ -589,7 +583,7 @@ get_dirstack_from_string (string)
|
|||
#ifdef INCLUDE_UNUSED
|
||||
char *
|
||||
get_dirstack_element (ind, sign)
|
||||
long ind;
|
||||
intmax_t ind;
|
||||
int sign;
|
||||
{
|
||||
int i;
|
||||
|
|
@ -602,7 +596,7 @@ get_dirstack_element (ind, sign)
|
|||
|
||||
void
|
||||
set_dirstack_element (ind, sign, value)
|
||||
long ind;
|
||||
intmax_t ind;
|
||||
int sign;
|
||||
char *value;
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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, 1989, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -23,25 +23,28 @@ $PRODUCES read.c
|
|||
|
||||
$BUILTIN read
|
||||
$FUNCTION read_builtin
|
||||
$SHORT_DOC read [-ers] [-t timeout] [-p prompt] [-a array] [-n nchars] [-d delim] [name ...]
|
||||
One line is read from the standard input, and the first word is
|
||||
assigned to the first NAME, the second word to the second NAME, and so
|
||||
on, with leftover words assigned to the last NAME. Only the characters
|
||||
found in $IFS are recognized as word delimiters. If no NAMEs are supplied,
|
||||
the line read is stored in the REPLY variable. If the -r option is given,
|
||||
this signifies `raw' input, and backslash escaping is disabled. The
|
||||
-d option causes read to continue until the first character of DELIM is
|
||||
read, rather than newline. If the `-p' option is supplied, the string
|
||||
PROMPT is output without a trailing newline before attempting to read.
|
||||
If -a is supplied, the words read are assigned to sequential indices of
|
||||
ARRAY, starting at zero. If -e is supplied and the shell is interactive,
|
||||
readline is used to obtain the line. If -n is supplied with a non-zero
|
||||
NCHARS argument, read returns after NCHARS characters have been read.
|
||||
The -s option causes input coming from a terminal to not be echoed.
|
||||
$SHORT_DOC read [-ers] [-u fd] [-t timeout] [-p prompt] [-a array] [-n nchars] [-d delim] [name ...]
|
||||
One line is read from the standard input, or from file descriptor FD if the
|
||||
-u option is supplied, and the first word is assigned to the first NAME,
|
||||
the second word to the second NAME, and so on, with leftover words assigned
|
||||
to the last NAME. Only the characters found in $IFS are recognized as word
|
||||
delimiters. If no NAMEs are supplied, the line read is stored in the REPLY
|
||||
variable. If the -r option is given, this signifies `raw' input, and
|
||||
backslash escaping is disabled. The -d option causes read to continue
|
||||
until the first character of DELIM is read, rather than newline. If the -p
|
||||
option is supplied, the string PROMPT is output without a trailing newline
|
||||
before attempting to read. If -a is supplied, the words read are assigned
|
||||
to sequential indices of ARRAY, starting at zero. If -e is supplied and
|
||||
the shell is interactive, readline is used to obtain the line. If -n is
|
||||
supplied with a non-zero NCHARS argument, read returns after NCHARS
|
||||
characters have been read. The -s option causes input coming from a
|
||||
terminal to not be echoed.
|
||||
|
||||
The -t option causes read to time out and return failure if a complete line
|
||||
of input is not read within TIMEOUT seconds. The return code is zero,
|
||||
unless end-of-file is encountered or read times out.
|
||||
of input is not read within TIMEOUT seconds. If the TMOUT variable is set,
|
||||
its value is the default timeout. The return code is zero, unless end-of-file
|
||||
is encountered, read times out, or an invalid file descriptor is supplied as
|
||||
the argument to -u.
|
||||
$END
|
||||
|
||||
#include <config.h>
|
||||
|
|
@ -78,8 +81,6 @@ $END
|
|||
extern int errno;
|
||||
#endif
|
||||
|
||||
#define issep(c) (strchr (ifs_chars, (c)))
|
||||
|
||||
extern int interrupt_immediately;
|
||||
|
||||
#if defined (READLINE)
|
||||
|
|
@ -123,9 +124,9 @@ read_builtin (list)
|
|||
register char *varname;
|
||||
int size, i, pass_next, saw_escape, eof, opt, retval, code;
|
||||
int input_is_tty, input_is_pipe, unbuffered_read;
|
||||
int raw, edit, nchars, silent, have_timeout;
|
||||
int raw, edit, nchars, silent, have_timeout, fd;
|
||||
unsigned int tmout;
|
||||
long timeoutval, ncharsval;
|
||||
intmax_t intval;
|
||||
char c;
|
||||
char *input_string, *orig_input_string, *ifs_chars, *prompt, *arrayname;
|
||||
char *e, *t, *t1;
|
||||
|
|
@ -162,6 +163,7 @@ read_builtin (list)
|
|||
raw = edit = 0; /* Not reading raw input by default. */
|
||||
silent = 0;
|
||||
arrayname = prompt = (char *)NULL;
|
||||
fd = 0; /* file descriptor to read from */
|
||||
|
||||
#if defined (READLINE)
|
||||
rlbuf = (char *)0;
|
||||
|
|
@ -173,7 +175,7 @@ read_builtin (list)
|
|||
delim = '\n'; /* read until newline */
|
||||
|
||||
reset_internal_getopt ();
|
||||
while ((opt = internal_getopt (list, "erp:a:d:t:n:s")) != -1)
|
||||
while ((opt = internal_getopt (list, "ersa:d:n:p:t:u:")) != -1)
|
||||
{
|
||||
switch (opt)
|
||||
{
|
||||
|
|
@ -197,8 +199,8 @@ read_builtin (list)
|
|||
break;
|
||||
#endif
|
||||
case 't':
|
||||
code = legal_number (list_optarg, &timeoutval);
|
||||
if (code == 0 || timeoutval < 0 || timeoutval != (unsigned int)timeoutval)
|
||||
code = legal_number (list_optarg, &intval);
|
||||
if (code == 0 || intval < 0 || intval != (unsigned int)intval)
|
||||
{
|
||||
builtin_error ("%s: invalid timeout specification", list_optarg);
|
||||
return (EXECUTION_FAILURE);
|
||||
|
|
@ -206,18 +208,33 @@ read_builtin (list)
|
|||
else
|
||||
{
|
||||
have_timeout = 1;
|
||||
tmout = timeoutval;
|
||||
tmout = intval;
|
||||
}
|
||||
break;
|
||||
case 'n':
|
||||
code = legal_number (list_optarg, &ncharsval);
|
||||
if (code == 0 || ncharsval < 0 || ncharsval != (int)ncharsval)
|
||||
code = legal_number (list_optarg, &intval);
|
||||
if (code == 0 || intval < 0 || intval != (int)intval)
|
||||
{
|
||||
builtin_error ("%s: invalid number specification", list_optarg);
|
||||
sh_invalidnum (list_optarg);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
else
|
||||
nchars = ncharsval;
|
||||
nchars = intval;
|
||||
break;
|
||||
case 'u':
|
||||
code = legal_number (list_optarg, &intval);
|
||||
if (code == 0 || intval < 0 || intval != (int)intval)
|
||||
{
|
||||
builtin_error ("%s: invalid file descriptor specification", list_optarg);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
else
|
||||
fd = intval;
|
||||
if (sh_validfd (fd) == 0)
|
||||
{
|
||||
builtin_error ("%d: invalid file descriptor: %s", fd, strerror (errno));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
break;
|
||||
case 'd':
|
||||
delim = *list_optarg;
|
||||
|
|
@ -229,24 +246,32 @@ read_builtin (list)
|
|||
}
|
||||
list = loptend;
|
||||
|
||||
/* `read -t 0 var' returns failure immediately. */
|
||||
/* `read -t 0 var' returns failure immediately. XXX - should it test
|
||||
whether input is available with select/FIONREAD, and fail if those
|
||||
are unavailable? */
|
||||
if (have_timeout && tmout == 0)
|
||||
return (EXECUTION_FAILURE);
|
||||
|
||||
/* IF IFS is unset, we use the default of " \t\n". */
|
||||
var = find_variable ("IFS");
|
||||
ifs_chars = var ? value_cell (var) : " \t\n";
|
||||
if (ifs_chars == 0) /* XXX */
|
||||
ifs_chars = ""; /* XXX */
|
||||
ifs_chars = getifs ();
|
||||
if (ifs_chars == 0) /* XXX - shouldn't happen */
|
||||
ifs_chars = "";
|
||||
|
||||
input_string = (char *)xmalloc (size = 128);
|
||||
input_string = (char *)xmalloc (size = 112); /* XXX was 128 */
|
||||
|
||||
/* $TMOUT, if set, is the default timeout for read. */
|
||||
if (have_timeout == 0 && (e = get_string_value ("TMOUT")))
|
||||
{
|
||||
code = legal_number (e, &intval);
|
||||
if (code == 0 || intval < 0 || intval != (unsigned int)intval)
|
||||
tmout = 0;
|
||||
else
|
||||
tmout = intval;
|
||||
}
|
||||
|
||||
begin_unwind_frame ("read_builtin");
|
||||
#if defined (READLINE)
|
||||
add_unwind_protect (xfree, rlbuf);
|
||||
#endif
|
||||
|
||||
input_is_tty = isatty (0);
|
||||
input_is_tty = isatty (fd);
|
||||
if (input_is_tty == 0)
|
||||
#ifndef __CYGWIN__
|
||||
input_is_pipe = (lseek (0, 0L, SEEK_CUR) < 0) && (errno == ESPIPE);
|
||||
|
|
@ -262,6 +287,11 @@ read_builtin (list)
|
|||
edit = silent = 0;
|
||||
}
|
||||
|
||||
#if defined (READLINE)
|
||||
if (edit)
|
||||
add_unwind_protect (xfree, rlbuf);
|
||||
#endif
|
||||
|
||||
if (prompt && edit == 0)
|
||||
{
|
||||
fprintf (stderr, "%s", prompt);
|
||||
|
|
@ -275,7 +305,7 @@ read_builtin (list)
|
|||
{
|
||||
/* Turn off the timeout if stdin is a regular file (e.g. from
|
||||
input redirection). */
|
||||
if ((fstat (0, &tsb) < 0) || S_ISREG (tsb.st_mode))
|
||||
if ((fstat (fd, &tsb) < 0) || S_ISREG (tsb.st_mode))
|
||||
tmout = 0;
|
||||
}
|
||||
|
||||
|
|
@ -341,7 +371,7 @@ read_builtin (list)
|
|||
setmode (0, O_TEXT);
|
||||
#endif
|
||||
|
||||
for (eof = 0;;)
|
||||
for (eof = retval = 0;;)
|
||||
{
|
||||
#if defined (READLINE)
|
||||
if (edit)
|
||||
|
|
@ -368,9 +398,9 @@ read_builtin (list)
|
|||
#endif
|
||||
|
||||
if (unbuffered_read)
|
||||
retval = zread (0, &c, 1);
|
||||
retval = zread (fd, &c, 1);
|
||||
else
|
||||
retval = zreadc (0, &c);
|
||||
retval = zreadc (fd, &c);
|
||||
|
||||
if (retval <= 0)
|
||||
{
|
||||
|
|
@ -425,6 +455,14 @@ read_builtin (list)
|
|||
}
|
||||
input_string[i] = '\0';
|
||||
|
||||
#if 1
|
||||
if (retval < 0)
|
||||
{
|
||||
builtin_error ("read error: %d: %s", fd, strerror (errno));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (tmout > 0)
|
||||
reset_alarm ();
|
||||
|
||||
|
|
@ -447,7 +485,7 @@ read_builtin (list)
|
|||
ttrestore ();
|
||||
|
||||
if (unbuffered_read == 0)
|
||||
zsyncfd (0);
|
||||
zsyncfd (fd);
|
||||
|
||||
interrupt_immediately--;
|
||||
discard_unwind_frame ("read_builtin");
|
||||
|
|
@ -462,7 +500,7 @@ read_builtin (list)
|
|||
var = find_or_make_array_variable (arrayname, 1);
|
||||
if (var == 0)
|
||||
return EXECUTION_FAILURE; /* readonly or noassign */
|
||||
empty_array (array_cell (var));
|
||||
array_flush (array_cell (var));
|
||||
|
||||
alist = list_string (input_string, ifs_chars, 0);
|
||||
if (alist)
|
||||
|
|
@ -487,7 +525,7 @@ read_builtin (list)
|
|||
{
|
||||
#if 0
|
||||
orig_input_string = input_string;
|
||||
for (t = input_string; ifs_chars && *ifs_chars && spctabnl(*t) && issep(*t); t++)
|
||||
for (t = input_string; ifs_chars && *ifs_chars && spctabnl(*t) && isifs(*t); t++)
|
||||
;
|
||||
input_string = t;
|
||||
input_string = strip_trailing_ifs_whitespace (input_string, ifs_chars, saw_escape);
|
||||
|
|
@ -513,7 +551,7 @@ read_builtin (list)
|
|||
|
||||
/* Remove IFS white space at the beginning of the input string. If
|
||||
$IFS is null, no field splitting is performed. */
|
||||
for (t = input_string; ifs_chars && *ifs_chars && spctabnl(*t) && issep(*t); t++)
|
||||
for (t = input_string; ifs_chars && *ifs_chars && spctabnl(*t) && isifs(*t); t++)
|
||||
;
|
||||
input_string = t;
|
||||
|
||||
|
|
@ -526,7 +564,7 @@ read_builtin (list)
|
|||
if (legal_identifier (varname) == 0)
|
||||
#endif
|
||||
{
|
||||
builtin_error ("`%s': not a valid identifier", varname);
|
||||
sh_invalidid (varname);
|
||||
xfree (orig_input_string);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
|
@ -574,7 +612,7 @@ read_builtin (list)
|
|||
if (legal_identifier (list->word->word) == 0)
|
||||
#endif
|
||||
{
|
||||
builtin_error ("`%s': not a valid identifier", list->word->word);
|
||||
sh_invalidid (list->word->word);
|
||||
xfree (orig_input_string);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
|
@ -615,6 +653,8 @@ bind_read_variable (name, value)
|
|||
}
|
||||
|
||||
#if defined (READLINE)
|
||||
static rl_completion_func_t *old_attempted_completion_function;
|
||||
|
||||
static char *
|
||||
edit_line (p)
|
||||
char *p;
|
||||
|
|
@ -624,7 +664,10 @@ edit_line (p)
|
|||
|
||||
if (!bash_readline_initialized)
|
||||
initialize_readline ();
|
||||
old_attempted_completion_function = rl_attempted_completion_function;
|
||||
rl_attempted_completion_function = (rl_completion_func_t *)NULL;
|
||||
ret = readline (p);
|
||||
rl_attempted_completion_function = old_attempted_completion_function;
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
len = strlen (ret);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ This file is reserved.def, in which the shell reserved words are defined.
|
|||
It has no direct C file production, but defines builtins for the Bash
|
||||
builtin help command.
|
||||
|
||||
Copyright (C) 1987, 1989, 1991, 1992 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -28,6 +28,19 @@ assumed. For each element in WORDS, NAME is set to that element, and
|
|||
the COMMANDS are executed.
|
||||
$END
|
||||
|
||||
$BUILTIN for ((
|
||||
$DOCNAME arith_for
|
||||
$SHORT_DOC for (( exp1; exp2; exp3 )); do COMMANDS; done
|
||||
Equivalent to
|
||||
(( EXP1 ))
|
||||
while (( EXP2 )); do
|
||||
COMMANDS
|
||||
(( EXP3 ))
|
||||
done
|
||||
EXP1, EXP2, and EXP3 are arithmetic expressions. If any expression is
|
||||
omitted, it behaves as if it evaluates to 1.
|
||||
$END
|
||||
|
||||
$BUILTIN select
|
||||
$SHORT_DOC select NAME [in WORDS ... ;] do COMMANDS; done
|
||||
The WORDS are expanded, generating a list of words. The
|
||||
|
|
@ -40,7 +53,7 @@ to that word. If the line is empty, WORDS and the prompt are
|
|||
redisplayed. If EOF is read, the command completes. Any other
|
||||
value read causes NAME to be set to null. The line read is saved
|
||||
in the variable REPLY. COMMANDS are executed after each selection
|
||||
until a break or return command is executed.
|
||||
until a break command is executed.
|
||||
$END
|
||||
|
||||
$BUILTIN time
|
||||
|
|
@ -103,6 +116,31 @@ WORD, then the job whose name begins with WORD is used. Following the
|
|||
job specification with a `&' places the job in the background.
|
||||
$END
|
||||
|
||||
$BUILTIN (( ... ))
|
||||
$DOCNAME arith
|
||||
$SHORT_DOC (( expression ))
|
||||
The EXPRESSION is evaluated according to the rules for arithmetic
|
||||
evaluation. Equivalent to "let EXPRESSION".
|
||||
$END
|
||||
|
||||
$BUILTIN [[ ... ]]
|
||||
$DOCNAME conditional
|
||||
$SHORT_DOC [[ expression ]]
|
||||
Returns a status of 0 or 1 depending on the evaluation of the conditional
|
||||
expression EXPRESSION. Expressions are composed of the same primaries used
|
||||
by the `test' builtin, and may be combined using the following operators
|
||||
|
||||
( EXPRESSION ) Returns the value of EXPRESSION
|
||||
! EXPRESSION True if EXPRESSION is false; else false
|
||||
EXPR1 && EXPR2 True if both EXPR1 and EXPR2 are true; else false
|
||||
EXPR1 || EXPR2 True if either EXPR1 or EXPR2 is true; else false
|
||||
|
||||
When the `==' and `!=' operators are used, the string to the right of the
|
||||
operator is used as a pattern and pattern matching is performed. The
|
||||
&& and || operators do not evaluate EXPR2 if EXPR1 is sufficient to
|
||||
determine the expression's value.
|
||||
$END
|
||||
|
||||
$BUILTIN variables
|
||||
$DOCNAME variable_help
|
||||
$SHORT_DOC variables - Some variable names and meanings
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is return.def, from which is created return.c.
|
||||
It implements the builtin "return" in Bash.
|
||||
|
||||
Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -52,7 +52,7 @@ int
|
|||
return_builtin (list)
|
||||
WORD_LIST *list;
|
||||
{
|
||||
return_catch_value = list ? get_exitstat (list) : last_command_exit_value;
|
||||
return_catch_value = get_exitstat (list);
|
||||
|
||||
if (return_catch_flag)
|
||||
longjmp (return_catch, 1);
|
||||
|
|
|
|||
256
builtins/set.def
256
builtins/set.def
|
|
@ -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, 1989, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -49,7 +49,7 @@ $PRODUCES set.c
|
|||
# include "../bashhist.h"
|
||||
#endif
|
||||
|
||||
extern int noclobber, posixly_correct, ignoreeof, eof_encountered_limit;
|
||||
extern int posixly_correct, ignoreeof, eof_encountered_limit;
|
||||
#if defined (HISTORY)
|
||||
extern int dont_save_function_defs;
|
||||
#endif
|
||||
|
|
@ -65,8 +65,6 @@ $SHORT_DOC set [--abefhkmnptuvxBCHP] [-o option] [arg ...]
|
|||
-e Exit immediately if a command exits with a non-zero status.
|
||||
-f Disable file name generation (globbing).
|
||||
-h Remember the location of commands as they are looked up.
|
||||
-i Force the shell to be an "interactive" one. Interactive shells
|
||||
always read `~/.bashrc' on startup.
|
||||
-k All assignment arguments are placed in the environment for a
|
||||
command, not just those that precede the command name.
|
||||
-m Job control is enabled.
|
||||
|
|
@ -135,6 +133,9 @@ parameters and are assigned, in order, to $1, $2, .. $n. If no
|
|||
ARGs are given, all shell variables are printed.
|
||||
$END
|
||||
|
||||
typedef int setopt_set_func_t __P((int, char *));
|
||||
typedef int setopt_get_func_t __P((char *));
|
||||
|
||||
static void print_minus_o_option __P((char *, int, int));
|
||||
static void print_all_shell_variables __P((void));
|
||||
|
||||
|
|
@ -153,70 +154,66 @@ static int bash_set_history __P((int, char *));
|
|||
static char *on = "on";
|
||||
static char *off = "off";
|
||||
|
||||
/* An a-list used to match long options for set -o to the corresponding
|
||||
option letter. */
|
||||
/* A struct used to match long options for set -o to the corresponding
|
||||
option letter or internal variable. The functions can be called to
|
||||
dynamically generate values. */
|
||||
struct {
|
||||
char *name;
|
||||
int letter;
|
||||
} o_options[] = {
|
||||
{ "allexport", 'a' },
|
||||
#if defined (BRACE_EXPANSION)
|
||||
{ "braceexpand",'B' },
|
||||
#endif
|
||||
{ "errexit", 'e' },
|
||||
{ "hashall", 'h' },
|
||||
#if defined (BANG_HISTORY)
|
||||
{ "histexpand", 'H' },
|
||||
#endif /* BANG_HISTORY */
|
||||
{ "keyword", 'k' },
|
||||
{ "monitor", 'm' },
|
||||
{ "noclobber", 'C' },
|
||||
{ "noexec", 'n' },
|
||||
{ "noglob", 'f' },
|
||||
#if defined (JOB_CONTROL)
|
||||
{ "notify", 'b' },
|
||||
#endif /* JOB_CONTROL */
|
||||
{ "nounset", 'u' },
|
||||
{ "onecmd", 't' },
|
||||
{ "physical", 'P' },
|
||||
{ "privileged", 'p' },
|
||||
{ "verbose", 'v' },
|
||||
{ "xtrace", 'x' },
|
||||
{(char *)NULL, 0 },
|
||||
};
|
||||
|
||||
typedef int setopt_set_func_t __P((int, char *));
|
||||
typedef int setopt_get_func_t __P((char *));
|
||||
|
||||
struct {
|
||||
char *name;
|
||||
int *variable;
|
||||
setopt_set_func_t *set_func;
|
||||
setopt_get_func_t *get_func;
|
||||
} binary_o_options[] = {
|
||||
#if defined (HISTORY)
|
||||
{ "history", &remember_on_history, bash_set_history, (setopt_get_func_t *)NULL },
|
||||
} o_options[] = {
|
||||
{ "allexport", 'a', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL },
|
||||
#if defined (BRACE_EXPANSION)
|
||||
{ "braceexpand",'B', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL },
|
||||
#endif
|
||||
{ "ignoreeof", &ignoreeof, set_ignoreeof, (setopt_get_func_t *)NULL },
|
||||
{ "interactive-comments", &interactive_comments, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL },
|
||||
#if defined (HISTORY)
|
||||
{ "nolog", &dont_save_function_defs, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL },
|
||||
#endif
|
||||
{ "posix", &posixly_correct, set_posix_mode, (setopt_get_func_t *)NULL },
|
||||
#if defined (READLINE)
|
||||
{ "emacs", (int *)NULL, set_edit_mode, get_edit_mode },
|
||||
{ "vi", (int *)NULL, set_edit_mode, get_edit_mode },
|
||||
{ "emacs", '\0', (int *)NULL, set_edit_mode, get_edit_mode },
|
||||
#endif
|
||||
{ (char *)NULL, (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }
|
||||
{ "errexit", 'e', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL },
|
||||
{ "hashall", 'h', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL },
|
||||
#if defined (BANG_HISTORY)
|
||||
{ "histexpand", 'H', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL },
|
||||
#endif /* BANG_HISTORY */
|
||||
#if defined (HISTORY)
|
||||
{ "history", '\0', &remember_on_history, bash_set_history, (setopt_get_func_t *)NULL },
|
||||
#endif
|
||||
{ "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 },
|
||||
{ "monitor", 'm', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL },
|
||||
{ "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 },
|
||||
#if defined (HISTORY)
|
||||
{ "nolog", '\0', &dont_save_function_defs, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL },
|
||||
#endif
|
||||
#if defined (JOB_CONTROL)
|
||||
{ "notify", 'b', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL },
|
||||
#endif /* JOB_CONTROL */
|
||||
{ "nounset", 'u', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL },
|
||||
{ "onecmd", 't', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL },
|
||||
{ "physical", 'P', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL },
|
||||
{ "posix", '\0', &posixly_correct, set_posix_mode, (setopt_get_func_t *)NULL },
|
||||
{ "privileged", 'p', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL },
|
||||
{ "verbose", 'v', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL },
|
||||
#if defined (READLINE)
|
||||
{ "vi", '\0', (int *)NULL, set_edit_mode, get_edit_mode },
|
||||
#endif
|
||||
{ "xtrace", 'x', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL },
|
||||
{(char *)NULL, 0 , (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL },
|
||||
};
|
||||
|
||||
#define N_O_OPTIONS (sizeof (o_options) / sizeof (o_options[0]))
|
||||
|
||||
#define GET_BINARY_O_OPTION_VALUE(i, name) \
|
||||
((binary_o_options[i].get_func) ? (*binary_o_options[i].get_func) (name) \
|
||||
: (*binary_o_options[i].variable))
|
||||
((o_options[i].get_func) ? (*o_options[i].get_func) (name) \
|
||||
: (*o_options[i].variable))
|
||||
|
||||
#define SET_BINARY_O_OPTION_VALUE(i, onoff, name) \
|
||||
((binary_o_options[i].set_func) ? (*binary_o_options[i].set_func) (onoff, name) \
|
||||
: (*binary_o_options[i].variable = (onoff == FLAG_ON)))
|
||||
((o_options[i].set_func) ? (*o_options[i].set_func) (onoff, name) \
|
||||
: (*o_options[i].variable = (onoff == FLAG_ON)))
|
||||
|
||||
int
|
||||
minus_o_option_value (name)
|
||||
|
|
@ -228,16 +225,16 @@ minus_o_option_value (name)
|
|||
for (i = 0; o_options[i].name; i++)
|
||||
{
|
||||
if (STREQ (name, o_options[i].name))
|
||||
{
|
||||
if (o_options[i].letter)
|
||||
{
|
||||
on_or_off = find_flag (o_options[i].letter);
|
||||
return ((on_or_off == FLAG_UNKNOWN) ? -1 : *on_or_off);
|
||||
}
|
||||
}
|
||||
for (i = 0; binary_o_options[i].name; i++)
|
||||
{
|
||||
if (STREQ (name, binary_o_options[i].name))
|
||||
else
|
||||
return (GET_BINARY_O_OPTION_VALUE (i, name));
|
||||
}
|
||||
}
|
||||
|
||||
return (-1);
|
||||
}
|
||||
|
|
@ -262,19 +259,23 @@ list_minus_o_opts (mode, reusable)
|
|||
register int i;
|
||||
int *on_or_off, value;
|
||||
|
||||
for (value = i = 0; o_options[i].name; i++)
|
||||
for (i = 0; o_options[i].name; i++)
|
||||
{
|
||||
if (o_options[i].letter)
|
||||
{
|
||||
value = 0;
|
||||
on_or_off = find_flag (o_options[i].letter);
|
||||
if (on_or_off == FLAG_UNKNOWN)
|
||||
on_or_off = &value;
|
||||
if (mode == -1 || mode == *on_or_off)
|
||||
print_minus_o_option (o_options[i].name, *on_or_off, reusable);
|
||||
}
|
||||
for (i = 0; binary_o_options[i].name; i++)
|
||||
else
|
||||
{
|
||||
value = GET_BINARY_O_OPTION_VALUE (i, binary_o_options[i].name);
|
||||
value = GET_BINARY_O_OPTION_VALUE (i, o_options[i].name);
|
||||
if (mode == -1 || mode == value)
|
||||
print_minus_o_option (binary_o_options[i].name, value, reusable);
|
||||
print_minus_o_option (o_options[i].name, value, reusable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -282,16 +283,12 @@ char **
|
|||
get_minus_o_opts ()
|
||||
{
|
||||
char **ret;
|
||||
int n, i, ind;
|
||||
int i;
|
||||
|
||||
n = (sizeof (o_options) / sizeof (o_options[0])) +
|
||||
(sizeof (binary_o_options) / sizeof (binary_o_options[0]));
|
||||
ret = alloc_array (n + 1);
|
||||
for (i = ind = 0; o_options[i].name; i++)
|
||||
ret[ind++] = o_options[i].name;
|
||||
for (i = 0; binary_o_options[i].name; i++)
|
||||
ret[ind++] = binary_o_options[i].name;
|
||||
ret[ind] = (char *)NULL;
|
||||
ret = strvec_create (N_O_OPTIONS + 1);
|
||||
for (i = 0; o_options[i].name; i++)
|
||||
ret[i] = o_options[i].name;
|
||||
ret[i] = (char *)NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -386,38 +383,34 @@ set_minus_o_option (on_or_off, option_name)
|
|||
int on_or_off;
|
||||
char *option_name;
|
||||
{
|
||||
int option_char;
|
||||
register int i;
|
||||
|
||||
for (i = 0; binary_o_options[i].name; i++)
|
||||
for (i = 0; o_options[i].name; i++)
|
||||
{
|
||||
if (STREQ (option_name, binary_o_options[i].name))
|
||||
if (STREQ (option_name, o_options[i].name))
|
||||
{
|
||||
if (o_options[i].letter == 0)
|
||||
{
|
||||
SET_BINARY_O_OPTION_VALUE (i, on_or_off, option_name);
|
||||
return (EXECUTION_SUCCESS);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (change_flag (o_options[i].letter, on_or_off) == FLAG_ERROR)
|
||||
{
|
||||
sh_invalidoptname (option_name);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
else
|
||||
return (EXECUTION_SUCCESS);
|
||||
}
|
||||
|
||||
for (i = 0, option_char = -1; o_options[i].name; i++)
|
||||
{
|
||||
if (STREQ (option_name, o_options[i].name))
|
||||
{
|
||||
option_char = o_options[i].letter;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (option_char == -1)
|
||||
{
|
||||
builtin_error ("%s: unknown option name", option_name);
|
||||
|
||||
sh_invalidoptname (option_name);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
if (change_flag (option_char, on_or_off) == FLAG_ERROR)
|
||||
{
|
||||
bad_option (option_name);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
return (EXECUTION_SUCCESS);
|
||||
}
|
||||
|
||||
static void
|
||||
print_all_shell_variables ()
|
||||
|
|
@ -448,38 +441,41 @@ void
|
|||
set_shellopts ()
|
||||
{
|
||||
char *value;
|
||||
char tflag[N_O_OPTIONS];
|
||||
int vsize, i, vptr, *ip, exported;
|
||||
SHELL_VAR *v;
|
||||
|
||||
for (vsize = i = 0; o_options[i].name; i++)
|
||||
{
|
||||
tflag[i] = 0;
|
||||
if (o_options[i].letter)
|
||||
{
|
||||
ip = find_flag (o_options[i].letter);
|
||||
if (ip && *ip)
|
||||
{
|
||||
vsize += strlen (o_options[i].name) + 1;
|
||||
tflag[i] = 1;
|
||||
}
|
||||
}
|
||||
else if (GET_BINARY_O_OPTION_VALUE (i, o_options[i].name))
|
||||
{
|
||||
vsize += strlen (o_options[i].name) + 1;
|
||||
tflag[i] = 1;
|
||||
}
|
||||
}
|
||||
for (i = 0; binary_o_options[i].name; i++)
|
||||
if (GET_BINARY_O_OPTION_VALUE (i, binary_o_options[i].name))
|
||||
vsize += strlen (binary_o_options[i].name) + 1;
|
||||
|
||||
value = (char *)xmalloc (vsize + 1);
|
||||
|
||||
for (i = vptr = 0; o_options[i].name; i++)
|
||||
{
|
||||
ip = find_flag (o_options[i].letter);
|
||||
if (ip && *ip)
|
||||
if (tflag[i])
|
||||
{
|
||||
strcpy (value + vptr, o_options[i].name);
|
||||
vptr += strlen (o_options[i].name);
|
||||
value[vptr++] = ':';
|
||||
}
|
||||
}
|
||||
for (i = 0; binary_o_options[i].name; i++)
|
||||
if (GET_BINARY_O_OPTION_VALUE (i, binary_o_options[i].name))
|
||||
{
|
||||
strcpy (value + vptr, binary_o_options[i].name);
|
||||
vptr += strlen (binary_o_options[i].name);
|
||||
value[vptr++] = ':';
|
||||
}
|
||||
|
||||
if (vptr)
|
||||
vptr--; /* cut off trailing colon */
|
||||
value[vptr] = '\0';
|
||||
|
|
@ -571,6 +567,7 @@ set_builtin (list)
|
|||
int on_or_off, flag_name, force_assignment, opts_changed;
|
||||
WORD_LIST *l;
|
||||
register char *arg;
|
||||
char s[3];
|
||||
|
||||
if (list == 0)
|
||||
{
|
||||
|
|
@ -579,31 +576,16 @@ set_builtin (list)
|
|||
}
|
||||
|
||||
/* Check validity of flag arguments. */
|
||||
if (*list->word->word == '-' || *list->word->word == '+')
|
||||
reset_internal_getopt ();
|
||||
while ((flag_name = internal_getopt (list, optflags)) != -1)
|
||||
{
|
||||
for (l = list; l && (arg = l->word->word); l = l->next)
|
||||
switch (flag_name)
|
||||
{
|
||||
char c;
|
||||
|
||||
if (arg[0] != '-' && arg[0] != '+')
|
||||
break;
|
||||
|
||||
/* `-' or `--' signifies end of flag arguments. */
|
||||
if (arg[0] == '-' && (!arg[1] || (arg[1] == '-' && !arg[2])))
|
||||
break;
|
||||
|
||||
while (c = *++arg)
|
||||
{
|
||||
if (find_flag (c) == FLAG_UNKNOWN && c != 'o')
|
||||
{
|
||||
char s[2];
|
||||
s[0] = c; s[1] = '\0';
|
||||
bad_option (s);
|
||||
if (c == '?')
|
||||
case '?':
|
||||
builtin_usage ();
|
||||
return (c == '?' ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
|
||||
}
|
||||
}
|
||||
return (list_optopt == '?' ? EXECUTION_SUCCESS : EX_USAGE);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -678,11 +660,10 @@ set_builtin (list)
|
|||
}
|
||||
else if (change_flag (flag_name, on_or_off) == FLAG_ERROR)
|
||||
{
|
||||
char opt[3];
|
||||
opt[0] = on_or_off;
|
||||
opt[1] = flag_name;
|
||||
opt[2] = '\0';
|
||||
bad_option (opt);
|
||||
s[0] = on_or_off;
|
||||
s[1] = flag_name;
|
||||
s[2] = '\0';
|
||||
sh_invalidopt (s);
|
||||
builtin_usage ();
|
||||
set_shellopts ();
|
||||
return (EXECUTION_FAILURE);
|
||||
|
|
@ -777,7 +758,7 @@ unset_builtin (list)
|
|||
mode when unsetting a function. */
|
||||
if (((unset_function && posixly_correct) || !unset_function) && legal_identifier (name) == 0)
|
||||
{
|
||||
builtin_error ("`%s': not a valid identifier", name);
|
||||
sh_invalidid (name);
|
||||
NEXT_VARIABLE ();
|
||||
}
|
||||
|
||||
|
|
@ -807,22 +788,27 @@ unset_builtin (list)
|
|||
NEXT_VARIABLE ();
|
||||
}
|
||||
else
|
||||
{
|
||||
tem = unbind_array_element (var, t);
|
||||
if (tem == -1)
|
||||
any_failed++;
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif /* ARRAY_VARS */
|
||||
tem = makunbound (name, unset_function ? shell_functions : shell_variables);
|
||||
tem = unset_function ? unbind_func (name) : unbind_variable (name);
|
||||
|
||||
/* This is what Posix.2 draft 11+ 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)
|
||||
tem = makunbound (name, shell_functions);
|
||||
tem = unbind_func (name);
|
||||
|
||||
if (tem == -1)
|
||||
any_failed++;
|
||||
else if (!unset_function)
|
||||
/* SUSv3, POSIX.1-2001 say: ``Unsetting a variable or function that
|
||||
was not previously set shall not be considered an error.'' */
|
||||
|
||||
if (unset_function == 0)
|
||||
stupidly_hack_special_variables (name);
|
||||
|
||||
list = list->next;
|
||||
|
|
|
|||
|
|
@ -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, 1989, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -43,7 +43,7 @@ extern char *this_command_name;
|
|||
extern sh_builtin_func_t *this_shell_builtin;
|
||||
|
||||
#ifdef ARRAY_VARS
|
||||
extern int declare_builtin ();
|
||||
extern int declare_builtin __P((WORD_LIST *));
|
||||
#endif
|
||||
|
||||
#define READONLY_OR_EXPORT \
|
||||
|
|
@ -51,7 +51,7 @@ extern int declare_builtin ();
|
|||
|
||||
$BUILTIN export
|
||||
$FUNCTION export_builtin
|
||||
$SHORT_DOC export [-nf] [name ...] or export -p
|
||||
$SHORT_DOC export [-nf] [name[=value] ...] or export -p
|
||||
NAMEs are marked for automatic export to the environment of
|
||||
subsequently executed commands. If the -f option is given,
|
||||
the NAMEs refer to functions. If no NAMEs are given, or if `-p'
|
||||
|
|
@ -75,7 +75,7 @@ export_builtin (list)
|
|||
|
||||
$BUILTIN readonly
|
||||
$FUNCTION readonly_builtin
|
||||
$SHORT_DOC readonly [-anf] [name ...] or readonly -p
|
||||
$SHORT_DOC readonly [-anf] [name[=value] ...] or readonly -p
|
||||
The given NAMEs are marked readonly and the values of these NAMEs may
|
||||
not be changed by subsequent assignment. If the -f option is given,
|
||||
then functions corresponding to the NAMEs are so marked. If no
|
||||
|
|
@ -95,6 +95,12 @@ readonly_builtin (list)
|
|||
return (set_or_show_attributes (list, att_readonly, 0));
|
||||
}
|
||||
|
||||
#if defined (ARRAY_VARS)
|
||||
# define ATTROPTS "afnp"
|
||||
#else
|
||||
# define ATTROPTS "fnp"
|
||||
#endif
|
||||
|
||||
/* For each variable name in LIST, make that variable have the specified
|
||||
ATTRIBUTE. An arg of `-n' says to remove the attribute from the the
|
||||
remaining names in LIST. */
|
||||
|
|
@ -114,7 +120,7 @@ set_or_show_attributes (list, attribute, nodefs)
|
|||
undo = functions_only = arrays_only = any_failed = assign_error = 0;
|
||||
/* Read arguments from the front of the list. */
|
||||
reset_internal_getopt ();
|
||||
while ((opt = internal_getopt (list, "anfp")) != -1)
|
||||
while ((opt = internal_getopt (list, ATTROPTS)) != -1)
|
||||
{
|
||||
switch (opt)
|
||||
{
|
||||
|
|
@ -174,7 +180,7 @@ set_or_show_attributes (list, attribute, nodefs)
|
|||
|
||||
if (legal_identifier (name) == 0)
|
||||
{
|
||||
builtin_error ("`%s': not a valid identifier", name);
|
||||
sh_invalidid (name);
|
||||
if (assign)
|
||||
assign_error++;
|
||||
else
|
||||
|
|
@ -248,11 +254,7 @@ set_or_show_attributes (list, attribute, nodefs)
|
|||
if (arrays_only && array_p (var) == 0)
|
||||
continue;
|
||||
#endif
|
||||
#if 0
|
||||
if ((var->attributes & attribute) && invisible_p (var) == 0)
|
||||
#else
|
||||
if ((var->attributes & attribute))
|
||||
#endif
|
||||
show_var_attributes (var, READONLY_OR_EXPORT, nodefs);
|
||||
}
|
||||
free (variable_list);
|
||||
|
|
@ -275,7 +277,7 @@ show_var_attributes (var, pattr, nodefs)
|
|||
SHELL_VAR *var;
|
||||
int pattr, nodefs;
|
||||
{
|
||||
char flags[6], *x;
|
||||
char flags[8], *x;
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
|
|
@ -297,6 +299,9 @@ show_var_attributes (var, pattr, nodefs)
|
|||
if (readonly_p (var))
|
||||
flags[i++] = 'r';
|
||||
|
||||
if (trace_p (var))
|
||||
flags[i++] = 't';
|
||||
|
||||
if (exported_p (var))
|
||||
flags[i++] = 'x';
|
||||
}
|
||||
|
|
@ -313,6 +318,17 @@ show_var_attributes (var, pattr, nodefs)
|
|||
|
||||
flags[i] = '\0';
|
||||
|
||||
/* If we're printing functions with definitions, print the function def
|
||||
first, then the attributes, instead of printing output that can't be
|
||||
reused as input to recreate the current state. */
|
||||
if (function_p (var) && nodefs == 0 && (pattr == 0 || posixly_correct == 0))
|
||||
{
|
||||
printf ("%s\n", named_function_string (var->name, function_cell (var), 1));
|
||||
nodefs++;
|
||||
if (pattr == 0 && i == 1 && flags[0] == 'f')
|
||||
return 0; /* don't print `declare -f name' */
|
||||
}
|
||||
|
||||
if (pattr == 0 || posixly_correct == 0)
|
||||
printf ("declare -%s ", i ? flags : "-");
|
||||
else if (i)
|
||||
|
|
@ -325,7 +341,7 @@ show_var_attributes (var, pattr, nodefs)
|
|||
print_array_assignment (var, 1);
|
||||
else
|
||||
#endif
|
||||
/* force `readline' and `export' to not print out function definitions
|
||||
/* force `readonly' and `export' to not print out function definitions
|
||||
when in POSIX mode. */
|
||||
if (nodefs || (function_p (var) && pattr != 0 && posixly_correct))
|
||||
printf ("%s\n", var->name);
|
||||
|
|
@ -335,7 +351,7 @@ show_var_attributes (var, pattr, nodefs)
|
|||
printf ("%s\n", var->name);
|
||||
else
|
||||
{
|
||||
x = sh_double_quote (value_cell (var) ? value_cell (var) : "");
|
||||
x = sh_double_quote (var_isset (var) ? value_cell (var) : "");
|
||||
printf ("%s=%s\n", var->name, x);
|
||||
free (x);
|
||||
}
|
||||
|
|
@ -349,15 +365,11 @@ show_name_attributes (name, nodefs)
|
|||
{
|
||||
SHELL_VAR *var;
|
||||
|
||||
var = find_tempenv_variable (name);
|
||||
if (var == 0)
|
||||
var = find_variable (name);
|
||||
var = find_variable_internal (name, 1);
|
||||
|
||||
if (var && invisible_p (var) == 0)
|
||||
{
|
||||
show_var_attributes (var, READONLY_OR_EXPORT, nodefs);
|
||||
if (tempvar_p (var))
|
||||
dispose_variable (var);
|
||||
return (0);
|
||||
}
|
||||
else
|
||||
|
|
@ -370,24 +382,40 @@ set_var_attribute (name, attribute, undo)
|
|||
int attribute, undo;
|
||||
{
|
||||
SHELL_VAR *var, *tv;
|
||||
char *tvalue;
|
||||
|
||||
if (undo)
|
||||
var = find_variable (name);
|
||||
else
|
||||
{
|
||||
if (tv = find_tempenv_variable (name))
|
||||
tv = find_tempenv_variable (name);
|
||||
/* XXX -- need to handle case where tv is a temp variable in a
|
||||
function-scope context, since function_env has been merged into
|
||||
the local variables table. */
|
||||
if (tv && tempvar_p (tv))
|
||||
{
|
||||
var = bind_variable (tv->name, tv->value ? tv->value : "");
|
||||
dispose_variable (tv);
|
||||
tvalue = var_isset (tv) ? savestring (value_cell (tv)) : savestring ("");
|
||||
|
||||
var = bind_variable (tv->name, tvalue);
|
||||
var->attributes |= tv->attributes & ~att_tempvar;
|
||||
VSETATTR (tv, att_propagate);
|
||||
if (var->context != 0)
|
||||
VSETATTR (var, att_propagate);
|
||||
SETVARATTR (tv, attribute, undo); /* XXX */
|
||||
|
||||
free (tvalue);
|
||||
}
|
||||
else
|
||||
var = find_variable (name);
|
||||
|
||||
{
|
||||
var = find_variable_internal (name, 0);
|
||||
if (var == 0)
|
||||
{
|
||||
var = bind_variable (name, (char *)NULL);
|
||||
VSETATTR (var, att_invisible);
|
||||
}
|
||||
else if (var->context != 0)
|
||||
VSETATTR (var, att_propagate);
|
||||
}
|
||||
}
|
||||
|
||||
if (var)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is shift.def, from which is created shift.c.
|
||||
It implements the builtin "shift" in Bash.
|
||||
|
||||
Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -52,7 +52,7 @@ int
|
|||
shift_builtin (list)
|
||||
WORD_LIST *list;
|
||||
{
|
||||
long times;
|
||||
intmax_t times;
|
||||
register int count;
|
||||
WORD_LIST *temp;
|
||||
|
||||
|
|
@ -62,13 +62,13 @@ shift_builtin (list)
|
|||
return (EXECUTION_SUCCESS);
|
||||
else if (times < 0)
|
||||
{
|
||||
builtin_error ("shift count must be >= 0");
|
||||
sh_erange (list->word->word, "shift count");
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
else if (times > number_of_args ())
|
||||
{
|
||||
if (print_shift_error)
|
||||
builtin_error ("shift count must be <= $#");
|
||||
sh_erange (list->word->word, "shift count");
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is shopt.def, from which is created shopt.c.
|
||||
It implements the Bash `shopt' builtin.
|
||||
|
||||
Copyright (C) 1994 Free Software Foundation, Inc.
|
||||
Copyright (C) 1994-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -22,7 +22,6 @@ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
|||
$PRODUCES shopt.c
|
||||
|
||||
$BUILTIN shopt
|
||||
$DOCNAME shopt_builtin
|
||||
$FUNCTION shopt_builtin
|
||||
$SHORT_DOC shopt [-pqsu] [-o long-option] optname [optname...]
|
||||
Toggle the values of variables controlling optional behavior.
|
||||
|
|
@ -59,7 +58,7 @@ $END
|
|||
extern int allow_null_glob_expansion, glob_dot_filenames;
|
||||
extern int cdable_vars, mail_warning, source_uses_path;
|
||||
extern int no_exit_on_failed_exec, print_shift_error;
|
||||
extern int check_hashed_filenames, promptvars, interactive_comments;
|
||||
extern int check_hashed_filenames, promptvars;
|
||||
extern int cdspelling, expand_aliases;
|
||||
extern int check_window_size;
|
||||
extern int glob_ignore_case;
|
||||
|
|
@ -86,10 +85,11 @@ extern int prog_completion_enabled;
|
|||
#endif
|
||||
|
||||
#if defined (RESTRICTED_SHELL)
|
||||
extern int restricted_shell;
|
||||
extern char *shell_name;
|
||||
#endif
|
||||
|
||||
static void shopt_error __P((char *));
|
||||
|
||||
static int set_interactive_comments __P((int));
|
||||
|
||||
#if defined (RESTRICTED_SHELL)
|
||||
|
|
@ -268,7 +268,12 @@ find_shopt (name)
|
|||
return -1;
|
||||
}
|
||||
|
||||
#define SHOPT_ERROR(str) builtin_error ("%s: unknown shell option name", str)
|
||||
static void
|
||||
shopt_error (s)
|
||||
char *s;
|
||||
{
|
||||
builtin_error ("%s: invalid shell option name", s);
|
||||
}
|
||||
|
||||
static int
|
||||
toggle_shopts (mode, list, quiet)
|
||||
|
|
@ -284,7 +289,7 @@ toggle_shopts (mode, list, quiet)
|
|||
ind = find_shopt (l->word->word);
|
||||
if (ind < 0)
|
||||
{
|
||||
SHOPT_ERROR (l->word->word);
|
||||
shopt_error (l->word->word);
|
||||
rval = EXECUTION_FAILURE;
|
||||
}
|
||||
else
|
||||
|
|
@ -334,7 +339,7 @@ list_shopts (list, flags)
|
|||
i = find_shopt (l->word->word);
|
||||
if (i < 0)
|
||||
{
|
||||
SHOPT_ERROR (l->word->word);
|
||||
shopt_error (l->word->word);
|
||||
rval = EXECUTION_FAILURE;
|
||||
continue;
|
||||
}
|
||||
|
|
@ -383,7 +388,7 @@ list_shopt_o_options (list, flags)
|
|||
val = minus_o_option_value (l->word->word);
|
||||
if (val == -1)
|
||||
{
|
||||
builtin_error ("%s: unknown option name", l->word->word);
|
||||
sh_invalidoptname (l->word->word);
|
||||
rval = EXECUTION_FAILURE;
|
||||
continue;
|
||||
}
|
||||
|
|
@ -470,7 +475,7 @@ get_shopt_options ()
|
|||
int n, i;
|
||||
|
||||
n = sizeof (shopt_vars) / sizeof (shopt_vars[0]);
|
||||
ret = alloc_array (n + 1);
|
||||
ret = strvec_create (n + 1);
|
||||
for (i = 0; shopt_vars[i].name; i++)
|
||||
ret[i] = savestring (shopt_vars[i].name);
|
||||
ret[i] = (char *)NULL;
|
||||
|
|
@ -509,7 +514,7 @@ shopt_listopt (name, reusable)
|
|||
i = find_shopt (name);
|
||||
if (i < 0)
|
||||
{
|
||||
SHOPT_ERROR (name);
|
||||
shopt_error (name);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is source.def, from which is created source.c.
|
||||
It implements the builtins "." and "source" in Bash.
|
||||
|
||||
Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -55,6 +55,7 @@ $END
|
|||
#include "../shell.h"
|
||||
#include "../findcmd.h"
|
||||
#include "common.h"
|
||||
#include "bashgetopt.h"
|
||||
|
||||
#if !defined (errno)
|
||||
extern int errno;
|
||||
|
|
@ -80,13 +81,11 @@ int source_searches_cwd = 1;
|
|||
static void
|
||||
maybe_pop_dollar_vars ()
|
||||
{
|
||||
if (variable_context == 0 && dollar_vars_changed ())
|
||||
{
|
||||
if (variable_context == 0 && (dollar_vars_changed () & ARGS_SETBLTIN))
|
||||
dispose_saved_dollar_vars ();
|
||||
set_dollar_vars_unchanged ();
|
||||
}
|
||||
else
|
||||
pop_dollar_vars ();
|
||||
set_dollar_vars_unchanged ();
|
||||
}
|
||||
|
||||
/* Read and execute commands from the file passed as argument. Guess what.
|
||||
|
|
@ -100,6 +99,10 @@ source_builtin (list)
|
|||
int result;
|
||||
char *filename;
|
||||
|
||||
if (no_options (list))
|
||||
return (EX_USAGE);
|
||||
list = loptend;
|
||||
|
||||
if (list == 0)
|
||||
{
|
||||
builtin_error ("filename argument required");
|
||||
|
|
@ -107,13 +110,10 @@ source_builtin (list)
|
|||
return (EX_USAGE);
|
||||
}
|
||||
|
||||
if (no_options (list))
|
||||
return (EX_USAGE);
|
||||
|
||||
#if defined (RESTRICTED_SHELL)
|
||||
if (restricted && strchr (list->word->word, '/'))
|
||||
{
|
||||
builtin_error ("%s: restricted", list->word->word);
|
||||
sh_restricted (list->word->word);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is suspend.def, from which is created suspend.c.
|
||||
It implements the builtin "suspend" in Bash.
|
||||
|
||||
Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -89,7 +89,7 @@ suspend_builtin (list)
|
|||
|
||||
if (job_control == 0)
|
||||
{
|
||||
builtin_error ("cannot suspend a shell without job control");
|
||||
sh_nojobs ("cannot suspend");
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is test.def, from which is created test.c.
|
||||
It implements the builtin "test" in Bash.
|
||||
|
||||
Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ $PRODUCES test.c
|
|||
$BUILTIN test
|
||||
$FUNCTION test_builtin
|
||||
$SHORT_DOC test [expr]
|
||||
Exits with a status of 0 (trueness) or 1 (falseness) depending on
|
||||
Exits with a status of 0 (true) or 1 (false) depending on
|
||||
the evaluation of EXPR. Expressions may be unary or binary. Unary
|
||||
expressions are often used to examine the status of a file. There
|
||||
are string operators as well, and numeric comparison operators.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is times.def, from which is created times.c.
|
||||
It implements the builtin "times" in Bash.
|
||||
|
||||
Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -61,6 +61,11 @@ times_builtin (list)
|
|||
#if defined (HAVE_GETRUSAGE) && defined (HAVE_TIMEVAL) && defined (RUSAGE_SELF)
|
||||
struct rusage self, kids;
|
||||
|
||||
USE_VAR(list);
|
||||
|
||||
if (no_options (list))
|
||||
return (EX_USAGE);
|
||||
|
||||
getrusage (RUSAGE_SELF, &self);
|
||||
getrusage (RUSAGE_CHILDREN, &kids); /* terminated child processes */
|
||||
|
||||
|
|
@ -79,6 +84,11 @@ times_builtin (list)
|
|||
`struct tms' with values of type clock_t. */
|
||||
struct tms t;
|
||||
|
||||
USE_VAR(list);
|
||||
|
||||
if (no_options (list))
|
||||
return (EX_USAGE);
|
||||
|
||||
times (&t);
|
||||
|
||||
print_clock_t (stdout, t.tms_utime);
|
||||
|
|
@ -89,8 +99,15 @@ times_builtin (list)
|
|||
putchar (' ');
|
||||
print_clock_t (stdout, t.tms_cstime);
|
||||
putchar ('\n');
|
||||
|
||||
# else /* !HAVE_TIMES */
|
||||
|
||||
USE_VAR(list);
|
||||
|
||||
if (no_options (list))
|
||||
return (EX_USAGE);
|
||||
printf ("0.00 0.00\n0.00 0.00\n");
|
||||
|
||||
# endif /* HAVE_TIMES */
|
||||
#endif /* !HAVE_TIMES */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is trap.def, from which is created trap.c.
|
||||
It implements the builtin "trap" in Bash.
|
||||
|
||||
Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -137,8 +137,7 @@ trap_builtin (list)
|
|||
|
||||
if (sig == NO_SIG)
|
||||
{
|
||||
builtin_error ("%s: not a signal specification",
|
||||
list->word->word);
|
||||
sh_invalidsig (list->word->word);
|
||||
result = EXECUTION_FAILURE;
|
||||
}
|
||||
else
|
||||
|
|
@ -239,8 +238,8 @@ display_traps (list)
|
|||
i = decode_signal (list->word->word);
|
||||
if (i == NO_SIG)
|
||||
{
|
||||
sh_invalidsig (list->word->word);
|
||||
result = EXECUTION_FAILURE;
|
||||
builtin_error ("%s: not a signal specification", list->word->word);
|
||||
}
|
||||
else
|
||||
showtrap (i);
|
||||
|
|
|
|||
|
|
@ -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, 1989, 1991, 1992 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ $PRODUCES type.c
|
|||
|
||||
$BUILTIN type
|
||||
$FUNCTION type_builtin
|
||||
$SHORT_DOC type [-apt] name [name ...]
|
||||
$SHORT_DOC type [-afptP] name [name ...]
|
||||
For each NAME, indicate how it would be interpreted if used as a
|
||||
command name.
|
||||
|
||||
|
|
@ -37,8 +37,14 @@ file that would be executed, or nothing if `type -t NAME' would not
|
|||
return `file'.
|
||||
|
||||
If the -a flag is used, `type' displays all of the places that contain
|
||||
an executable named `file'. This includes aliases and functions, if
|
||||
and only if the -p flag is not also used.
|
||||
an executable named `file'. This includes aliases, builtins, and
|
||||
functions, if and only if the -p flag is not also used.
|
||||
|
||||
The -f flag suppresses shell function lookup.
|
||||
|
||||
The -P flag forces a PATH search for each NAME, even if it is an alias,
|
||||
builtin, or function, and returns the name of the disk file that would
|
||||
be executed.
|
||||
$END
|
||||
|
||||
#include <config.h>
|
||||
|
|
@ -82,6 +88,12 @@ extern char *this_command_name;
|
|||
-a Returns all occurrences of words, whether they
|
||||
be a filename in the path, alias, function,
|
||||
or builtin.
|
||||
|
||||
-f Suppress shell function lookup, like `command'.
|
||||
|
||||
-P Force a path search even in the presence of other
|
||||
definitions.
|
||||
|
||||
Order of evaluation:
|
||||
alias
|
||||
keyword
|
||||
|
|
@ -94,72 +106,62 @@ int
|
|||
type_builtin (list)
|
||||
WORD_LIST *list;
|
||||
{
|
||||
int path_only, type_only, all, verbose;
|
||||
int successful_finds, opt;
|
||||
WORD_LIST *prev, *this;
|
||||
int dflags, successful_finds, opt;
|
||||
WORD_LIST *this;
|
||||
|
||||
if (list == 0)
|
||||
return (EXECUTION_SUCCESS);
|
||||
|
||||
path_only = type_only = all = 0;
|
||||
dflags = CDESC_SHORTDESC; /* default */
|
||||
successful_finds = 0;
|
||||
|
||||
/* Handle the obsolescent `-type', `-path', and `-all' by prescanning
|
||||
the arguments and removing those options from the list before calling
|
||||
internal_getopt. Recognize `--type', `--path', and `--all' also.
|
||||
THIS SHOULD REALLY GO AWAY. */
|
||||
for (this = list; this && this->word->word[0] == '-'; )
|
||||
the arguments and converting those options to the form that
|
||||
internal_getopt recognizes. Converts `--type', `--path', and `--all'
|
||||
also. THIS SHOULD REALLY GO AWAY. */
|
||||
for (this = list; this && this->word->word[0] == '-'; this = this->next)
|
||||
{
|
||||
char *flag = &(this->word->word[1]);
|
||||
|
||||
if (STREQ (flag, "type") || STREQ (flag, "-type"))
|
||||
{
|
||||
type_only = 1;
|
||||
path_only = 0;
|
||||
this->word->word[1] = 't';
|
||||
this->word->word[2] = '\0';
|
||||
}
|
||||
else if (STREQ (flag, "path") || STREQ (flag, "-path"))
|
||||
{
|
||||
path_only = 1;
|
||||
type_only = 0;
|
||||
this->word->word[1] = 'p';
|
||||
this->word->word[2] = '\0';
|
||||
}
|
||||
else if (STREQ (flag, "all") || STREQ (flag, "-all"))
|
||||
all = 1;
|
||||
else
|
||||
{
|
||||
prev = this;
|
||||
this = this->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* We found a long option; remove it from the argument list. Don't
|
||||
free it if it's the head of the argument list, though -- the
|
||||
argument list will be freed by the caller. */
|
||||
if (this == list)
|
||||
this = list = list->next;
|
||||
else
|
||||
{
|
||||
prev->next = this->next;
|
||||
this->next = (WORD_LIST *)NULL;
|
||||
dispose_words (this);
|
||||
this = prev->next;
|
||||
this->word->word[1] = 'a';
|
||||
this->word->word[2] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
reset_internal_getopt ();
|
||||
while ((opt = internal_getopt (list, "apt")) != -1)
|
||||
while ((opt = internal_getopt (list, "afptP")) != -1)
|
||||
{
|
||||
switch (opt)
|
||||
{
|
||||
case 't':
|
||||
type_only = 1;
|
||||
path_only = 0;
|
||||
case 'a':
|
||||
dflags |= CDESC_ALL;
|
||||
break;
|
||||
case 'f':
|
||||
dflags |= CDESC_NOFUNCS;
|
||||
break;
|
||||
case 'p':
|
||||
path_only = 1;
|
||||
type_only = 0;
|
||||
dflags |= CDESC_PATH_ONLY;
|
||||
dflags &= ~(CDESC_TYPE|CDESC_SHORTDESC);
|
||||
break;
|
||||
case 'a':
|
||||
all = 1;
|
||||
case 't':
|
||||
dflags |= CDESC_TYPE;
|
||||
dflags &= ~(CDESC_PATH_ONLY|CDESC_SHORTDESC);
|
||||
break;
|
||||
case 'P': /* shorthand for type -ap */
|
||||
dflags |= (CDESC_PATH_ONLY|CDESC_FORCE_PATH);
|
||||
dflags &= ~(CDESC_TYPE|CDESC_SHORTDESC);
|
||||
break;
|
||||
default:
|
||||
builtin_usage ();
|
||||
|
|
@ -168,23 +170,14 @@ type_builtin (list)
|
|||
}
|
||||
list = loptend;
|
||||
|
||||
if (type_only)
|
||||
verbose = 1;
|
||||
else if (path_only == 0)
|
||||
verbose = 2;
|
||||
else if (path_only)
|
||||
verbose = 3;
|
||||
else
|
||||
verbose = 0;
|
||||
|
||||
while (list)
|
||||
{
|
||||
int found;
|
||||
|
||||
found = describe_command (list->word->word, verbose, all);
|
||||
found = describe_command (list->word->word, dflags);
|
||||
|
||||
if (!found && !path_only && !type_only)
|
||||
builtin_error ("%s: not found", list->word->word);
|
||||
if (!found && (dflags & (CDESC_PATH_ONLY|CDESC_TYPE)) == 0)
|
||||
sh_notfound (list->word->word);
|
||||
|
||||
successful_finds += found;
|
||||
list = list->next;
|
||||
|
|
@ -196,43 +189,45 @@ type_builtin (list)
|
|||
}
|
||||
|
||||
/*
|
||||
* Describe COMMAND as required by the type builtin.
|
||||
* Describe COMMAND as required by the type and command builtins.
|
||||
*
|
||||
* If VERBOSE == 0, don't print anything
|
||||
* If VERBOSE == 1, print short description as for `type -t'
|
||||
* If VERBOSE == 2, print long description as for `type' and `command -V'
|
||||
* If VERBOSE == 3, print path name only for disk files
|
||||
* If VERBOSE == 4, print string used to invoke COMMAND, for `command -v'
|
||||
* Behavior is controlled by DFLAGS. Flag values are
|
||||
* CDESC_ALL print all descriptions of a command
|
||||
* CDESC_SHORTDESC print the description for type and command -V
|
||||
* CDESC_REUSABLE print in a format that may be reused as input
|
||||
* CDESC_TYPE print the type for type -t
|
||||
* CDESC_PATH_ONLY print the path for type -p
|
||||
* CDESC_FORCE_PATH force a path search for type -P
|
||||
* CDESC_NOFUNCS skip function lookup for type -f
|
||||
*
|
||||
* ALL says whether or not to look for all occurrences of COMMAND, or
|
||||
* CDESC_ALL says whether or not to look for all occurrences of COMMAND, or
|
||||
* return after finding it once.
|
||||
*/
|
||||
int
|
||||
describe_command (command, verbose, all)
|
||||
describe_command (command, dflags)
|
||||
char *command;
|
||||
int verbose, all;
|
||||
int dflags;
|
||||
{
|
||||
int found, i, found_file, f;
|
||||
int found, i, found_file, f, all;
|
||||
char *full_path, *x;
|
||||
SHELL_VAR *func;
|
||||
#if defined (ALIAS)
|
||||
alias_t *alias;
|
||||
#endif
|
||||
|
||||
all = (dflags & CDESC_ALL) != 0;
|
||||
found = found_file = 0;
|
||||
full_path = (char *)NULL;
|
||||
|
||||
#if defined (ALIAS)
|
||||
/* Command is an alias? */
|
||||
alias = find_alias (command);
|
||||
|
||||
if (alias)
|
||||
if (((dflags & CDESC_FORCE_PATH) == 0) && (alias = find_alias (command)))
|
||||
{
|
||||
if (verbose == 1)
|
||||
if (dflags & CDESC_TYPE)
|
||||
puts ("alias");
|
||||
else if (verbose == 2)
|
||||
else if (dflags & CDESC_SHORTDESC)
|
||||
printf ("%s is aliased to `%s'\n", command, alias->value);
|
||||
else if (verbose == 4)
|
||||
else if (dflags & CDESC_REUSABLE)
|
||||
{
|
||||
x = sh_single_quote (alias->value);
|
||||
printf ("alias %s=%s\n", command, x);
|
||||
|
|
@ -247,14 +242,13 @@ describe_command (command, verbose, all)
|
|||
#endif /* ALIAS */
|
||||
|
||||
/* Command is a shell reserved word? */
|
||||
i = find_reserved_word (command);
|
||||
if (i >= 0)
|
||||
if (((dflags & CDESC_FORCE_PATH) == 0) && (i = find_reserved_word (command)) >= 0)
|
||||
{
|
||||
if (verbose == 1)
|
||||
if (dflags & CDESC_TYPE)
|
||||
puts ("keyword");
|
||||
else if (verbose == 2)
|
||||
else if (dflags & CDESC_SHORTDESC)
|
||||
printf ("%s is a shell keyword\n", command);
|
||||
else if (verbose == 4)
|
||||
else if (dflags & CDESC_REUSABLE)
|
||||
printf ("%s\n", command);
|
||||
|
||||
found = 1;
|
||||
|
|
@ -264,13 +258,11 @@ describe_command (command, verbose, all)
|
|||
}
|
||||
|
||||
/* Command is a function? */
|
||||
func = find_function (command);
|
||||
|
||||
if (func)
|
||||
if (((dflags & (CDESC_FORCE_PATH|CDESC_NOFUNCS)) == 0) && (func = find_function (command)))
|
||||
{
|
||||
if (verbose == 1)
|
||||
if (dflags & CDESC_TYPE)
|
||||
puts ("function");
|
||||
else if (verbose == 2)
|
||||
else if (dflags & CDESC_SHORTDESC)
|
||||
{
|
||||
#define PRETTY_PRINT_FUNC 1
|
||||
char *result;
|
||||
|
|
@ -285,7 +277,7 @@ describe_command (command, verbose, all)
|
|||
printf ("%s\n", result);
|
||||
#undef PRETTY_PRINT_FUNC
|
||||
}
|
||||
else if (verbose == 4)
|
||||
else if (dflags & CDESC_REUSABLE)
|
||||
printf ("%s\n", command);
|
||||
|
||||
found = 1;
|
||||
|
|
@ -295,13 +287,13 @@ describe_command (command, verbose, all)
|
|||
}
|
||||
|
||||
/* Command is a builtin? */
|
||||
if (find_shell_builtin (command))
|
||||
if (((dflags & CDESC_FORCE_PATH) == 0) && find_shell_builtin (command))
|
||||
{
|
||||
if (verbose == 1)
|
||||
if (dflags & CDESC_TYPE)
|
||||
puts ("builtin");
|
||||
else if (verbose == 2)
|
||||
else if (dflags & CDESC_SHORTDESC)
|
||||
printf ("%s is a shell builtin\n", command);
|
||||
else if (verbose == 4)
|
||||
else if (dflags & CDESC_REUSABLE)
|
||||
printf ("%s\n", command);
|
||||
|
||||
found = 1;
|
||||
|
|
@ -318,11 +310,11 @@ describe_command (command, verbose, all)
|
|||
f = file_status (command);
|
||||
if (f & FS_EXECABLE)
|
||||
{
|
||||
if (verbose == 1)
|
||||
if (dflags & CDESC_TYPE)
|
||||
puts ("file");
|
||||
else if (verbose == 2)
|
||||
else if (dflags & CDESC_SHORTDESC)
|
||||
printf ("%s is %s\n", command, command);
|
||||
else if (verbose == 3 || verbose == 4)
|
||||
else if (dflags & (CDESC_REUSABLE|CDESC_PATH_ONLY))
|
||||
printf ("%s\n", command);
|
||||
|
||||
/* There's no use looking in the hash table or in $PATH,
|
||||
|
|
@ -334,15 +326,15 @@ describe_command (command, verbose, all)
|
|||
|
||||
/* If the user isn't doing "-a", then we might care about
|
||||
whether the file is present in our hash table. */
|
||||
if (all == 0)
|
||||
if (all == 0 || (dflags & CDESC_FORCE_PATH))
|
||||
{
|
||||
if ((full_path = find_hashed_filename (command)) != (char *)NULL)
|
||||
if (full_path = phash_search (command))
|
||||
{
|
||||
if (verbose == 1)
|
||||
if (dflags & CDESC_TYPE)
|
||||
puts ("file");
|
||||
else if (verbose == 2)
|
||||
else if (dflags & CDESC_SHORTDESC)
|
||||
printf ("%s is hashed (%s)\n", command, full_path);
|
||||
else if (verbose == 3 || verbose == 4)
|
||||
else if (dflags & (CDESC_REUSABLE|CDESC_PATH_ONLY))
|
||||
printf ("%s\n", full_path);
|
||||
|
||||
free (full_path);
|
||||
|
|
@ -376,18 +368,18 @@ describe_command (command, verbose, all)
|
|||
if (all == 0)
|
||||
break;
|
||||
}
|
||||
else if (verbose >= 2)
|
||||
else if (dflags & (CDESC_REUSABLE|CDESC_PATH_ONLY|CDESC_SHORTDESC))
|
||||
full_path = sh_makepath ((char *)NULL, full_path, MP_DOCWD);
|
||||
}
|
||||
|
||||
found_file++;
|
||||
found = 1;
|
||||
|
||||
if (verbose == 1)
|
||||
if (dflags & CDESC_TYPE)
|
||||
puts ("file");
|
||||
else if (verbose == 2)
|
||||
else if (dflags & CDESC_SHORTDESC)
|
||||
printf ("%s is %s\n", command, full_path);
|
||||
else if (verbose == 3 || verbose == 4)
|
||||
else if (dflags & (CDESC_REUSABLE|CDESC_PATH_ONLY))
|
||||
printf ("%s\n", full_path);
|
||||
|
||||
free (full_path);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is ulimit.def, from which is created ulimit.c.
|
||||
It implements the builtin "ulimit" in Bash.
|
||||
|
||||
Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -327,7 +327,7 @@ ulimit_builtin (list)
|
|||
{
|
||||
if (STREQ (list->word->word, "unlimited") == 0)
|
||||
{
|
||||
builtin_error ("invalid limit argument: %s", list->word->word);
|
||||
builtin_error ("%s: invalid limit argument", list->word->word);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
return (set_all_limits (mode == 0 ? LIMIT_SOFT|LIMIT_HARD : mode, RLIM_INFINITY));
|
||||
|
|
@ -353,7 +353,7 @@ ulimit_builtin (list)
|
|||
limind = _findlim (cmdlist[c].cmd);
|
||||
if (limind == -1)
|
||||
{
|
||||
builtin_error ("bad command: `%c'", cmdlist[c].cmd);
|
||||
builtin_error ("`%c': bad command", cmdlist[c].cmd);
|
||||
return (EX_USAGE);
|
||||
}
|
||||
}
|
||||
|
|
@ -382,7 +382,7 @@ ulimit_internal (cmd, cmdarg, mode, multiple)
|
|||
opt = get_limit (limind, &soft_limit, &hard_limit);
|
||||
if (opt < 0)
|
||||
{
|
||||
builtin_error ("cannot get %s limit: %s", limits[limind].description,
|
||||
builtin_error ("%s: cannot get limit: %s", limits[limind].description,
|
||||
strerror (errno));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
|
@ -408,19 +408,19 @@ ulimit_internal (cmd, cmdarg, mode, multiple)
|
|||
|
||||
if ((real_limit / block_factor) != limit)
|
||||
{
|
||||
builtin_error ("limit out of range: %s", cmdarg);
|
||||
sh_erange (cmdarg, "limit");
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
builtin_error ("bad non-numeric arg `%s'", cmdarg);
|
||||
sh_invalidnum (cmdarg);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
if (set_limit (limind, real_limit, mode) < 0)
|
||||
{
|
||||
builtin_error ("cannot modify %s limit: %s", limits[limind].description,
|
||||
builtin_error ("%s: cannot modify limit: %s", limits[limind].description,
|
||||
strerror (errno));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
|
@ -618,23 +618,19 @@ static int
|
|||
getmaxuprc (valuep)
|
||||
RLIMTYPE *valuep;
|
||||
{
|
||||
# if defined (HAVE_SYSCONF) && defined (_SC_CHILD_MAX)
|
||||
long maxchild;
|
||||
maxchild = sysconf (_SC_CHILD_MAX);
|
||||
|
||||
maxchild = getmaxchild ();
|
||||
if (maxchild < 0)
|
||||
return -1;
|
||||
else
|
||||
*valuep = (RLIMTYPE) maxchild;
|
||||
return 0;
|
||||
# else /* !HAVE_SYSCONF || !_SC_CHILD_MAX */
|
||||
# if defined (MAXUPRC)
|
||||
*valuep = (RLIMTYPE) MAXUPRC;
|
||||
return 0;
|
||||
# else /* MAXUPRC */
|
||||
{
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
# endif /* !MAXUPRC */
|
||||
# endif /* !HAVE_SYSCONF || !_SC_CHILD_MAX */
|
||||
}
|
||||
else
|
||||
{
|
||||
*valuep = (RLIMTYPE) maxchild;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -650,7 +646,8 @@ print_all_limits (mode)
|
|||
for (i = 0; limits[i].option > 0; i++)
|
||||
{
|
||||
if (get_limit (i, &softlim, &hardlim) < 0)
|
||||
builtin_error ("cannot get %s limit: %s", limits[i].description, strerror (errno));
|
||||
builtin_error ("%s: cannot get limit: %s", limits[i].description,
|
||||
strerror (errno));
|
||||
else
|
||||
printone (i, (mode & LIMIT_SOFT) ? softlim : hardlim, 1);
|
||||
}
|
||||
|
|
@ -716,7 +713,7 @@ set_all_limits (mode, newlim)
|
|||
for (retval = i = 0; limits[i].option > 0; i++)
|
||||
if (set_limit (i, newlim, mode) < 0)
|
||||
{
|
||||
builtin_error ("cannot modify %s limit: %s", limits[i].description,
|
||||
builtin_error ("%s: cannot modify limit: %s", limits[i].description,
|
||||
strerror (errno));
|
||||
retval = 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is umask.def, from which is created umask.c.
|
||||
It implements the builtin "umask" in Bash.
|
||||
|
||||
Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -107,8 +107,7 @@ umask_builtin (list)
|
|||
is lousy. */
|
||||
if (umask_value == -1)
|
||||
{
|
||||
builtin_error ("`%s' is not an octal number from 000 to 777",
|
||||
list->word->word);
|
||||
sh_erange (list->word->word, "octal number");
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
}
|
||||
|
|
@ -222,7 +221,7 @@ parse_symbolic_mode (mode, initial_bits)
|
|||
case '=':
|
||||
break;
|
||||
default:
|
||||
builtin_error ("bad symbolic mode operator: %c", op);
|
||||
builtin_error ("`%c': invalid symbolic mode operator", op);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
|
@ -275,7 +274,7 @@ parse_symbolic_mode (mode, initial_bits)
|
|||
}
|
||||
else
|
||||
{
|
||||
builtin_error ("bad character in symbolic mode: %c", *s);
|
||||
builtin_error ("`%c': invalid symbolic mode character", *s);
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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, 1989, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -60,6 +60,7 @@ $END
|
|||
#include "bashgetopt.h"
|
||||
|
||||
extern int interrupt_immediately;
|
||||
extern int wait_signal_received;
|
||||
|
||||
procenv_t wait_intr_buf;
|
||||
|
||||
|
|
@ -87,7 +88,6 @@ wait_builtin (list)
|
|||
|
||||
if (no_options (list))
|
||||
return (EX_USAGE);
|
||||
if (list != loptend)
|
||||
list = loptend;
|
||||
|
||||
old_interrupt_immediately = interrupt_immediately;
|
||||
|
|
@ -104,7 +104,7 @@ wait_builtin (list)
|
|||
code = setjmp (wait_intr_buf);
|
||||
if (code)
|
||||
{
|
||||
status = 128 + SIGINT;
|
||||
status = 128 + wait_signal_received;
|
||||
WAIT_RETURN (status);
|
||||
}
|
||||
|
||||
|
|
@ -124,7 +124,7 @@ wait_builtin (list)
|
|||
{
|
||||
pid_t pid;
|
||||
char *w;
|
||||
long pid_value;
|
||||
intmax_t pid_value;
|
||||
|
||||
w = list->word->word;
|
||||
if (DIGIT (*w))
|
||||
|
|
@ -136,7 +136,7 @@ wait_builtin (list)
|
|||
}
|
||||
else
|
||||
{
|
||||
builtin_error ("`%s' is not a pid or valid job spec", w);
|
||||
sh_badpid (w);
|
||||
WAIT_RETURN (EXECUTION_FAILURE);
|
||||
}
|
||||
}
|
||||
|
|
@ -153,7 +153,7 @@ wait_builtin (list)
|
|||
if (job < 0 || job >= job_slots || !jobs[job])
|
||||
{
|
||||
if (job != DUP_JOB)
|
||||
builtin_error ("%s: no such job", list->word->word);
|
||||
sh_badjob (list->word->word);
|
||||
UNBLOCK_CHILD (oset);
|
||||
status = 127; /* As per Posix.2, section 4.70.2 */
|
||||
list = list->next;
|
||||
|
|
@ -167,13 +167,13 @@ wait_builtin (list)
|
|||
else if (job_control == 0 && *w == '%')
|
||||
{
|
||||
/* can't use jobspecs as arguments if job control is not active. */
|
||||
builtin_error ("job control not enabled");
|
||||
sh_nojobs ((char *)NULL);
|
||||
status = EXECUTION_FAILURE;
|
||||
}
|
||||
#endif /* JOB_CONTROL */
|
||||
else
|
||||
{
|
||||
builtin_error ("`%s' is not a pid or valid job spec", w);
|
||||
sh_badpid (w);
|
||||
status = EXECUTION_FAILURE;
|
||||
}
|
||||
list = list->next;
|
||||
|
|
|
|||
15
command.h
15
command.h
|
|
@ -27,10 +27,11 @@
|
|||
/* Instructions describing what kind of thing to do for a redirection. */
|
||||
enum r_instruction {
|
||||
r_output_direction, r_input_direction, r_inputa_direction,
|
||||
r_appending_to, r_reading_until, r_duplicating_input,
|
||||
r_duplicating_output, r_deblank_reading_until, r_close_this,
|
||||
r_err_and_out, r_input_output, r_output_force,
|
||||
r_duplicating_input_word, r_duplicating_output_word
|
||||
r_appending_to, r_reading_until, r_reading_string,
|
||||
r_duplicating_input, r_duplicating_output, r_deblank_reading_until,
|
||||
r_close_this, r_err_and_out, r_input_output, r_output_force,
|
||||
r_duplicating_input_word, r_duplicating_output_word,
|
||||
r_move_input, r_move_output, r_move_input_word, r_move_output_word
|
||||
};
|
||||
|
||||
/* Redirection errors. */
|
||||
|
|
@ -55,6 +56,11 @@ enum r_instruction {
|
|||
ri == r_appending_to || \
|
||||
ri == r_output_force)
|
||||
|
||||
/* redirection needs translation */
|
||||
#define TRANSLATE_REDIRECT(ri) \
|
||||
(ri == r_duplicating_input_word || ri == r_duplicating_output_word || \
|
||||
ri == r_move_input_word || ri == r_move_output_word)
|
||||
|
||||
/* Command Types: */
|
||||
enum command_type { cm_for, cm_case, cm_while, cm_if, cm_simple, cm_select,
|
||||
cm_connection, cm_function_def, cm_until, cm_group,
|
||||
|
|
@ -68,6 +74,7 @@ enum command_type { cm_for, cm_case, cm_while, cm_if, cm_simple, cm_select,
|
|||
#define W_NOSPLIT 0x10 /* Do not perform word splitting on this word. */
|
||||
#define W_NOGLOB 0x20 /* Do not perform globbing on this word. */
|
||||
#define W_NOSPLIT2 0x40 /* Don't split word except for $@ expansion. */
|
||||
#define W_TILDEEXP 0x80 /* Tilde expand this assignment word */
|
||||
|
||||
/* Possible values for subshell_environment */
|
||||
#define SUBSHELL_ASYNC 0x01 /* subshell caused by `command &' */
|
||||
|
|
|
|||
59
config-bot.h
59
config-bot.h
|
|
@ -1,6 +1,24 @@
|
|||
/* config-bot.h */
|
||||
/* modify settings or make new ones based on what autoconf tells us. */
|
||||
|
||||
/* Copyright (C) 1989-2002 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 2, 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; see the file COPYING. If not, write to the Free Software
|
||||
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
|
||||
#if !defined (HAVE_VPRINTF) && defined (HAVE_DOPRNT)
|
||||
# define USE_VFPRINTF_EMULATION
|
||||
# define HAVE_VPRINTF
|
||||
|
|
@ -78,3 +96,44 @@
|
|||
# undef PPROMPT
|
||||
# define PPROMPT "$ "
|
||||
#endif
|
||||
|
||||
/************************************************/
|
||||
/* check multibyte capability for I18N code */
|
||||
/************************************************/
|
||||
|
||||
/* For platforms which support the ISO C amendement 1 functionality we
|
||||
support user defined character classes. */
|
||||
/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>. */
|
||||
#if defined (HAVE_WCTYPE_H) && defined (HAVE_WCHAR_H)
|
||||
# include <wchar.h>
|
||||
# include <wctype.h>
|
||||
# if defined (HAVE_MBSRTOWCS) /* system is supposed to support XPG5 */
|
||||
# define HANDLE_MULTIBYTE 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Some systems, like BeOS, have multibyte encodings but lack mbstate_t. */
|
||||
#if HANDLE_MULTIBYTE && !defined (HAVE_MBSTATE_T)
|
||||
# define wcsrtombs(dest, src, len, ps) (wcsrtombs) (dest, src, len, 0)
|
||||
# define mbsrtowcs(dest, src, len, ps) (mbsrtowcs) (dest, src, len, 0)
|
||||
# define wcrtomb(s, wc, ps) (wcrtomb) (s, wc, 0)
|
||||
# define mbrtowc(pwc, s, n, ps) (mbrtowc) (pwc, s, n, 0)
|
||||
# define mbrlen(s, n, ps) (mbrlen) (s, n, 0)
|
||||
# define mbstate_t int
|
||||
#endif
|
||||
|
||||
/* Make sure MB_LEN_MAX is at least 16 (some systems define
|
||||
MB_LEN_MAX as 1) */
|
||||
#ifdef HANDLE_MULTIBYTE
|
||||
# include <limits.h>
|
||||
# if defined(MB_LEN_MAX) && (MB_LEN_MAX < 16)
|
||||
# undef MB_LEN_MAX
|
||||
# endif
|
||||
# if !defined (MB_LEN_MAX)
|
||||
# define MB_LEN_MAX 16
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/************************************************/
|
||||
/* end of multibyte capability checks for I18N */
|
||||
/************************************************/
|
||||
|
|
|
|||
24
config-top.h
24
config-top.h
|
|
@ -3,6 +3,24 @@
|
|||
/* This contains various user-settable options not under the control of
|
||||
autoconf. */
|
||||
|
||||
/* Copyright (C) 2002 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 2, 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; see the file COPYING. If not, write to the Free Software
|
||||
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
|
||||
/* Define CONTINUE_AFTER_KILL_ERROR if you want the kill command to
|
||||
continue processing arguments after one of them fails. This is
|
||||
what POSIX.2 specifies. */
|
||||
|
|
@ -48,6 +66,12 @@
|
|||
#define PPROMPT "\\s-\\v\\$ "
|
||||
#define SPROMPT "> "
|
||||
|
||||
/* Undefine this if you don't want the ksh-compatible behavior of reprinting
|
||||
the select menu after a valid choice is made only if REPLY is set to NULL
|
||||
in the body of the select command. The menu is always reprinted if the
|
||||
reply to the select query is an empty line. */
|
||||
#define KSH_COMPATIBLE_SELECT
|
||||
|
||||
/* System-wide .bashrc file for interactive shells. */
|
||||
/* #define SYS_BASHRC "/etc/bash.bashrc" */
|
||||
|
||||
|
|
|
|||
66
config.h.in
66
config.h.in
|
|
@ -1,6 +1,6 @@
|
|||
/* config.h -- Configuration file for bash. */
|
||||
|
||||
/* Copyright (C) 1987-2001 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -132,6 +132,10 @@
|
|||
and the complete builtin. */
|
||||
#undef PROGRAMMABLE_COMPLETION
|
||||
|
||||
/* Define MEMSCRAMBLE if you want the bash malloc and free to scramble
|
||||
memory contents on malloc() and free(). */
|
||||
#undef MEMSCRAMBLE
|
||||
|
||||
/* Define AFS if you are using Transarc's AFS. */
|
||||
#undef AFS
|
||||
|
||||
|
|
@ -202,6 +206,8 @@
|
|||
/* Define if using the bash version of malloc in lib/malloc/malloc.c */
|
||||
#undef USING_BASH_MALLOC
|
||||
|
||||
#undef DISABLE_MALLOC_WRAPPERS
|
||||
|
||||
/* Define if using alloca.c. */
|
||||
#undef C_ALLOCA
|
||||
|
||||
|
|
@ -321,6 +327,8 @@
|
|||
|
||||
#undef HAVE_TIMEVAL
|
||||
|
||||
#undef HAVE_TZNAME
|
||||
|
||||
|
||||
/* Characteristics of some of the system structures. */
|
||||
|
||||
|
|
@ -336,6 +344,8 @@
|
|||
|
||||
#undef STRUCT_WINSIZE_IN_SYS_IOCTL
|
||||
|
||||
#undef TM_IN_SYS_TIME
|
||||
|
||||
#undef STRUCT_WINSIZE_IN_TERMIOS
|
||||
|
||||
#undef SPEED_T_IN_SYS_TYPES
|
||||
|
|
@ -346,6 +356,9 @@
|
|||
|
||||
#undef HAVE_STRUCT_STAT_ST_BLOCKS
|
||||
|
||||
#undef HAVE_STRUCT_TM_TM_ZONE
|
||||
#undef HAVE_TM_ZONE
|
||||
|
||||
/* Characteristics of definitions in the system header files. */
|
||||
|
||||
#undef HAVE_GETPW_DECLS
|
||||
|
|
@ -354,16 +367,22 @@
|
|||
|
||||
#undef HAVE_LIBC_FNM_EXTMATCH
|
||||
|
||||
|
||||
#undef HAVE_DECL_CONFSTR
|
||||
|
||||
#undef HAVE_DECL_STRTOLD
|
||||
|
||||
#undef HAVE_DECL_SBRK
|
||||
|
||||
#undef HAVE_DECL_PRINTF
|
||||
|
||||
#undef HAVE_DECL_SBRK
|
||||
|
||||
#undef HAVE_DECL_STRCPY
|
||||
|
||||
#undef HAVE_DECL_STRSIGNAL
|
||||
|
||||
#undef HAVE_DECL_STRTOLD
|
||||
|
||||
|
||||
#undef HAVE_MBSTATE_T
|
||||
|
||||
/* These are checked with BASH_CHECK_DECL */
|
||||
|
||||
#undef HAVE_DECL_STRTOIMAX
|
||||
|
|
@ -395,8 +414,15 @@
|
|||
|
||||
#undef CAN_REDEFINE_GETENV
|
||||
|
||||
#undef HAVE_STD_PUTENV
|
||||
|
||||
#undef HAVE_STD_UNSETENV
|
||||
|
||||
#undef HAVE_PRINTF_A_FORMAT
|
||||
|
||||
/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
|
||||
#undef HAVE_LANGINFO_CODESET
|
||||
|
||||
/* Characteristics of properties exported by the kernel. */
|
||||
|
||||
/* Define if the kernel can exec files beginning with #! */
|
||||
|
|
@ -496,6 +522,9 @@
|
|||
/* Define if you have the getservbyname function. */
|
||||
#undef HAVE_GETSERVBYNAME
|
||||
|
||||
/* Define if you have the getservent function. */
|
||||
#undef HAVE_GETSERVENT
|
||||
|
||||
/* Define if you have the gettext function. */
|
||||
#undef HAVE_GETTEXT
|
||||
|
||||
|
|
@ -517,6 +546,9 @@
|
|||
/* Define if you have the isgraph function. */
|
||||
#undef HAVE_ISGRAPH
|
||||
|
||||
/* Define if you have the isint function in libc */
|
||||
#undef HAVE_ISINF_IN_LIBC
|
||||
|
||||
/* Define if you have the isprint function. */
|
||||
#undef HAVE_ISPRINT
|
||||
|
||||
|
|
@ -532,9 +564,15 @@
|
|||
/* Define if you have the lstat function. */
|
||||
#undef HAVE_LSTAT
|
||||
|
||||
/* Define if you have the mbsrtowcs function. */
|
||||
#undef HAVE_MBSRTOWCS
|
||||
|
||||
/* Define if you have the memmove function. */
|
||||
#undef HAVE_MEMMOVE
|
||||
|
||||
/* Define if you have the memset function. */
|
||||
#undef HAVE_MEMSET
|
||||
|
||||
/* Define if you have the mkfifo function. */
|
||||
#undef HAVE_MKFIFO
|
||||
|
||||
|
|
@ -595,6 +633,9 @@
|
|||
/* Define if you have the strerror function. */
|
||||
#undef HAVE_STRERROR
|
||||
|
||||
/* Define if you have the strftime function. */
|
||||
#undef HAVE_STRFTIME
|
||||
|
||||
/* Define if you have the strpbrk function. */
|
||||
#undef HAVE_STRPBRK
|
||||
|
||||
|
|
@ -649,6 +690,9 @@
|
|||
/* Define if you have the uname function. */
|
||||
#undef HAVE_UNAME
|
||||
|
||||
/* Define if you have the unsetenv function. */
|
||||
#undef HAVE_UNSETENV
|
||||
|
||||
/* Define if you have the vasprintf function. */
|
||||
#undef HAVE_VASPRINTF
|
||||
|
||||
|
|
@ -664,6 +708,9 @@
|
|||
/* Define if you have the wait3 function. */
|
||||
#undef HAVE_WAIT3
|
||||
|
||||
/* Define if you have the wcwidth function. */
|
||||
#undef HAVE_WCWIDTH
|
||||
|
||||
/* Presence of certain system include files. */
|
||||
|
||||
/* Define if you have the <arpa/inet.h> header file. */
|
||||
|
|
@ -681,6 +728,9 @@
|
|||
/* Define if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define if you have the <langinfo.h> header file. */
|
||||
#undef HAVE_LANGINFO_H
|
||||
|
||||
/* Define if you have the <libintl.h> header file. */
|
||||
#undef HAVE_LIBINTL_H
|
||||
|
||||
|
|
@ -776,6 +826,12 @@
|
|||
/* Define if you have the <varargs.h> header file. */
|
||||
#undef HAVE_VARARGS_H
|
||||
|
||||
/* Define if you have the <wchar.h> header file. */
|
||||
#undef HAVE_WCHAR_H
|
||||
|
||||
/* Define if you have the <varargs.h> header file. */
|
||||
#undef HAVE_WCTYPE_H
|
||||
|
||||
/* Presence of certain system libraries. */
|
||||
|
||||
#undef HAVE_LIBDL
|
||||
|
|
|
|||
174
configure.in
174
configure.in
|
|
@ -5,7 +5,7 @@ dnl report bugs to chet@po.cwru.edu
|
|||
dnl
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
|
||||
# Copyright (C) 1987-2001 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1987-2002 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
|
||||
|
|
@ -22,9 +22,9 @@ dnl Process this file with autoconf to produce a configure script.
|
|||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
# 02111-1307, USA.
|
||||
|
||||
AC_REVISION([for Bash 2.05a, version 2.128, from autoconf version] AC_ACVERSION)dnl
|
||||
AC_REVISION([for Bash 2.05b, version 2.144, from autoconf version] AC_ACVERSION)dnl
|
||||
|
||||
AC_INIT(bash, 2.05a, bug-bash@gnu.org)
|
||||
AC_INIT(bash, 2.05b, bug-bash@gnu.org)
|
||||
|
||||
dnl make sure we are using a recent autoconf version
|
||||
AC_PREREQ(2.50)
|
||||
|
|
@ -35,7 +35,14 @@ AC_CONFIG_AUX_DIR(./support)
|
|||
AC_CONFIG_HEADERS(config.h)
|
||||
|
||||
dnl checks for version info
|
||||
BASHVERS=2.05a
|
||||
BASHVERS=2.05b
|
||||
RELSTATUS=release
|
||||
|
||||
dnl defaults for debug settings
|
||||
case "$RELSTATUS" in
|
||||
alp*|bet*|dev*|rc*) DEBUG='-DDEBUG' MALLOC_DEBUG='-DMALLOC_DEBUG' ;;
|
||||
*) DEBUG= MALLOC_DEBUG= ;;
|
||||
esac
|
||||
|
||||
dnl canonicalize the host and os so we can do some tricky things before
|
||||
dnl parsing options
|
||||
|
|
@ -63,7 +70,7 @@ sparc-netbsd*) opt_bash_malloc=no ;; # needs 8-byte alignment
|
|||
mips-irix6*) opt_bash_malloc=no ;; # needs 8-byte alignment
|
||||
m68k-sysv) opt_bash_malloc=no ;; # fixes file descriptor leak in closedir
|
||||
sparc-linux*) opt_bash_malloc=no ;; # sparc running linux; requires ELF
|
||||
#*-freebsd*) opt_bash_malloc=no ;; # they claim it's better
|
||||
#*-freebsd*) opt_bash_malloc=no ;; # they claim it's better; I disagree
|
||||
*-openbsd*) opt_bash_malloc=no ;; # they claim it needs eight-bit alignment
|
||||
*-aix*) opt_bash_malloc=no ;; # AIX machines
|
||||
*-nextstep*) opt_bash_malloc=no ;; # NeXT machines running NeXTstep
|
||||
|
|
@ -79,15 +86,21 @@ sparc-linux*) opt_bash_malloc=no ;; # sparc running linux; requires ELF
|
|||
*-opennt*|*-interix*) opt_bash_malloc=no ;; # Interix, now owned by Microsoft
|
||||
esac
|
||||
|
||||
# memory scrambling on free()
|
||||
case "${host_os}" in
|
||||
sco3.2v5*|sco3.2v4*) opt_memscramble=no ;;
|
||||
*) opt_memscramble=yes ;;
|
||||
esac
|
||||
|
||||
dnl arguments to configure
|
||||
dnl packages
|
||||
AC_ARG_WITH(afs, --with-afs if you are running AFS, opt_afs=$withval)
|
||||
AC_ARG_WITH(bash-malloc, --with-bash-malloc use the Bash version of malloc,opt_bash_malloc=$withval)
|
||||
AC_ARG_WITH(curses, --with-curses use the curses library instead of the termcap library,opt_curses=$withval)
|
||||
AC_ARG_WITH(gnu-malloc, --with-gnu-malloc synonym for --with-bash-malloc,opt_bash_malloc=$withval)
|
||||
AC_ARG_WITH(installed-readline, --with-installed-readline use a version of the readline library that is already installed, opt_with_installed_readline=$withval)
|
||||
AC_ARG_WITH(purecov, --with-purecov configure to postprocess with pure coverage, opt_purecov=$withval)
|
||||
AC_ARG_WITH(purify, --with-purify configure to postprocess with purify, opt_purify=$withval)
|
||||
AC_ARG_WITH(afs, AC_HELP_STRING([--with-afs], [if you are running AFS]), opt_afs=$withval)
|
||||
AC_ARG_WITH(bash-malloc, AC_HELP_STRING([--with-bash-malloc], [use the Bash version of malloc]), opt_bash_malloc=$withval)
|
||||
AC_ARG_WITH(curses, AC_HELP_STRING([--with-curses], [use the curses library instead of the termcap library]), opt_curses=$withval)
|
||||
AC_ARG_WITH(gnu-malloc, AC_HELP_STRING([--with-gnu-malloc], [synonym for --with-bash-malloc]), opt_bash_malloc=$withval)
|
||||
AC_ARG_WITH(installed-readline, AC_HELP_STRING([--with-installed-readline], [use a version of the readline library that is already installed]), opt_with_installed_readline=$withval)
|
||||
AC_ARG_WITH(purecov, AC_HELP_STRING([--with-purecov], [configure to postprocess with pure coverage]), opt_purecov=$withval)
|
||||
AC_ARG_WITH(purify, AC_HELP_STRING([--with-purify], [configure to postprocess with purify]), opt_purify=$withval)
|
||||
|
||||
if test "$opt_bash_malloc" = yes; then
|
||||
MALLOC_TARGET=malloc
|
||||
|
|
@ -108,6 +121,7 @@ fi
|
|||
|
||||
if test "$opt_purify" = yes; then
|
||||
PURIFY="purify "
|
||||
AC_DEFINE(DISABLE_MALLOC_WRAPPERS)
|
||||
else
|
||||
PURIFY=
|
||||
fi
|
||||
|
|
@ -149,14 +163,14 @@ opt_cond_command=yes
|
|||
opt_arith_for_command=yes
|
||||
opt_net_redirs=yes
|
||||
opt_progcomp=yes
|
||||
opt_largefile=yes
|
||||
opt_separate_help=no
|
||||
|
||||
dnl options that affect how bash is compiled and linked
|
||||
opt_static_link=no
|
||||
opt_profiling=no
|
||||
|
||||
dnl argument parsing for optional features
|
||||
AC_ARG_ENABLE(minimal-config, --enable-minimal-config a minimal sh-like configuration, opt_minimal_config=$enableval)
|
||||
AC_ARG_ENABLE(minimal-config, AC_HELP_STRING([--enable-minimal-config], [a minimal sh-like configuration]), opt_minimal_config=$enableval)
|
||||
|
||||
dnl a minimal configuration turns everything off, but features can be
|
||||
dnl added individually
|
||||
|
|
@ -167,37 +181,38 @@ if test $opt_minimal_config = yes; then
|
|||
opt_select=no opt_help=no opt_array_variables=no opt_dparen_arith=no
|
||||
opt_brace_expansion=no opt_disabled_builtins=no opt_command_timing=no
|
||||
opt_extended_glob=no opt_cond_command=no opt_arith_for_command=no
|
||||
opt_net_redirs=no opt_progcomp=no
|
||||
opt_net_redirs=no opt_progcomp=no opt_separate_help=no
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(alias, --enable-alias enable shell aliases, opt_alias=$enableval)
|
||||
AC_ARG_ENABLE(arith-for-command, --enable-arith-for-command enable arithmetic for command, opt_arith_for_command=$enableval)
|
||||
AC_ARG_ENABLE(array-variables, --enable-array-variables include shell array variables, opt_array_variables=$enableval)
|
||||
AC_ARG_ENABLE(bang-history, --enable-bang-history turn on csh-style history substitution, opt_bang_history=$enableval)
|
||||
AC_ARG_ENABLE(brace-expansion, --enable-brace-expansion include brace expansion, opt_brace_expansion=$enableval)
|
||||
AC_ARG_ENABLE(command-timing, --enable-command-timing enable the time reserved word and command timing, opt_command_timing=$enableval)
|
||||
AC_ARG_ENABLE(cond-command, --enable-cond-command enable the conditional command, opt_cond_command=$enableval)
|
||||
AC_ARG_ENABLE(directory-stack, --enable-directory-stack enable builtins pushd/popd/dirs, opt_dirstack=$enableval)
|
||||
AC_ARG_ENABLE(disabled-builtins, --enable-disabled-builtins allow disabled builtins to still be invoked, opt_disabled_builtins=$enableval)
|
||||
AC_ARG_ENABLE(dparen-arithmetic, [--enable-dparen-arithmetic include ((...)) command], opt_dparen_arith=$enableval)
|
||||
AC_ARG_ENABLE(extended-glob, --enable-extended-glob include ksh-style extended pattern matching, opt_extended_glob=$enableval)
|
||||
AC_ARG_ENABLE(help-builtin, --enable-help-builtin include the help builtin, opt_help=$enableval)
|
||||
AC_ARG_ENABLE(history, --enable-history turn on command history, opt_history=$enableval)
|
||||
AC_ARG_ENABLE(job-control, --enable-job-control enable job control features, opt_job_control=$enableval)
|
||||
AC_ARG_ENABLE(largefile, --enable-largefile enable support for large files, opt_largefile=$enableval)
|
||||
AC_ARG_ENABLE(net-redirections, --enable-net-redirections enable /dev/tcp/host/port redirection, opt_net_redirs=$enableval)
|
||||
AC_ARG_ENABLE(process-substitution, --enable-process-substitution enable process substitution, opt_process_subst=$enableval)
|
||||
AC_ARG_ENABLE(progcomp, --enable-progcomp enable programmable completion and the complete builtin, opt_progcomp=$enableval)
|
||||
AC_ARG_ENABLE(prompt-string-decoding, --enable-prompt-string-decoding turn on escape character decoding in prompts, opt_prompt_decoding=$enableval)
|
||||
AC_ARG_ENABLE(readline, --enable-readline turn on command line editing, opt_readline=$enableval)
|
||||
AC_ARG_ENABLE(restricted, --enable-restricted enable a restricted shell, opt_restricted=$enableval)
|
||||
AC_ARG_ENABLE(select, --enable-select include select command, opt_select=$enableval)
|
||||
AC_ARG_ENABLE(usg-echo-default, --enable-usg-echo-default a synonym for --enable-xpg-echo-default, opt_xpg_echo=$enableval)
|
||||
AC_ARG_ENABLE(xpg-echo-default, --enable-xpg-echo-default make the echo builtin expand escape sequences by default, opt_xpg_echo=$enableval)
|
||||
AC_ARG_ENABLE(alias, AC_HELP_STRING([--enable-alias], [enable shell aliases]), opt_alias=$enableval)
|
||||
AC_ARG_ENABLE(arith-for-command, AC_HELP_STRING([--enable-arith-for-command], [enable arithmetic for command]), opt_arith_for_command=$enableval)
|
||||
AC_ARG_ENABLE(array-variables, AC_HELP_STRING([--enable-array-variables], [include shell array variables]), opt_array_variables=$enableval)
|
||||
AC_ARG_ENABLE(bang-history, AC_HELP_STRING([--enable-bang-history], [turn on csh-style history substitution]), opt_bang_history=$enableval)
|
||||
AC_ARG_ENABLE(brace-expansion, AC_HELP_STRING([--enable-brace-expansion], [include brace expansion]), opt_brace_expansion=$enableval)
|
||||
AC_ARG_ENABLE(command-timing, AC_HELP_STRING([--enable-command-timing], [enable the time reserved word and command timing]), opt_command_timing=$enableval)
|
||||
AC_ARG_ENABLE(cond-command, AC_HELP_STRING([--enable-cond-command], [enable the conditional command]), opt_cond_command=$enableval)
|
||||
AC_ARG_ENABLE(directory-stack, AC_HELP_STRING([--enable-directory-stack], [enable builtins pushd/popd/dirs]), opt_dirstack=$enableval)
|
||||
AC_ARG_ENABLE(disabled-builtins, AC_HELP_STRING([--enable-disabled-builtins], [allow disabled builtins to still be invoked]), opt_disabled_builtins=$enableval)
|
||||
AC_ARG_ENABLE(dparen-arithmetic, AC_HELP_STRING([--enable-dparen-arithmetic], [include ((...)) command]), opt_dparen_arith=$enableval)
|
||||
AC_ARG_ENABLE(extended-glob, AC_HELP_STRING([--enable-extended-glob], [include ksh-style extended pattern matching]), opt_extended_glob=$enableval)
|
||||
AC_ARG_ENABLE(help-builtin, AC_HELP_STRING([--enable-help-builtin], [include the help builtin]), opt_help=$enableval)
|
||||
AC_ARG_ENABLE(history, AC_HELP_STRING([--enable-history], [turn on command history]), opt_history=$enableval)
|
||||
AC_ARG_ENABLE(job-control, AC_HELP_STRING([--enable-job-control], [enable job control features]), opt_job_control=$enableval)
|
||||
AC_ARG_ENABLE(net-redirections, AC_HELP_STRING([--enable-net-redirections], [enable /dev/tcp/host/port redirection]), opt_net_redirs=$enableval)
|
||||
AC_ARG_ENABLE(process-substitution, AC_HELP_STRING([--enable-process-substitution], [enable process substitution]), opt_process_subst=$enableval)
|
||||
AC_ARG_ENABLE(progcomp, AC_HELP_STRING([--enable-progcomp], [enable programmable completion and the complete builtin]), opt_progcomp=$enableval)
|
||||
AC_ARG_ENABLE(prompt-string-decoding, AC_HELP_STRING([--enable-prompt-string-decoding], [turn on escape character decoding in prompts]), opt_prompt_decoding=$enableval)
|
||||
AC_ARG_ENABLE(readline, AC_HELP_STRING([--enable-readline], [turn on command line editing]), opt_readline=$enableval)
|
||||
AC_ARG_ENABLE(restricted, AC_HELP_STRING([--enable-restricted], [enable a restricted shell]), opt_restricted=$enableval)
|
||||
AC_ARG_ENABLE(select, AC_HELP_STRING([--enable-select], [include select command]), opt_select=$enableval)
|
||||
AC_ARG_ENABLE(separate-helpfiles, AC_HELP_STRING([--enable-separate-helpfiles], [use external files for help builtin documentation]), opt_separate_help=$enableval)
|
||||
AC_ARG_ENABLE(usg-echo-default, AC_HELP_STRING([--enable-usg-echo-default], [a synonym for --enable-xpg-echo-default]), opt_xpg_echo=$enableval)
|
||||
AC_ARG_ENABLE(xpg-echo-default, AC_HELP_STRING([--enable-xpg-echo-default], [make the echo builtin expand escape sequences by default]), opt_xpg_echo=$enableval)
|
||||
|
||||
dnl options that alter how bash is compiled and linked
|
||||
AC_ARG_ENABLE(profiling, --enable-profiling allow profiling with gprof, opt_profiling=$enableval)
|
||||
AC_ARG_ENABLE(static-link, --enable-static-link [link bash statically, for use as a root shell], opt_static_link=$enableval)
|
||||
AC_ARG_ENABLE(mem-scramble, AC_HELP_STRING([--enable-mem-scramble], [scramble memory on calls to malloc and free]), opt_memscramble=$enableval)
|
||||
AC_ARG_ENABLE(profiling, AC_HELP_STRING([--enable-profiling], [allow profiling with gprof]), opt_profiling=$enableval)
|
||||
AC_ARG_ENABLE(static-link, AC_HELP_STRING([--enable-static-link], [link bash statically, for use as a root shell]), opt_static_link=$enableval)
|
||||
|
||||
dnl opt_job_control is handled later, after BASH_JOB_CONTROL_MISSING runs
|
||||
|
||||
|
|
@ -260,12 +275,27 @@ if test $opt_progcomp = yes; then
|
|||
AC_DEFINE(PROGRAMMABLE_COMPLETION)
|
||||
fi
|
||||
|
||||
if test $opt_memscramble = yes; then
|
||||
AC_DEFINE(MEMSCRAMBLE)
|
||||
fi
|
||||
|
||||
if test "$opt_minimal_config" = yes; then
|
||||
TESTSCRIPT=run-minimal
|
||||
else
|
||||
TESTSCRIPT=run-all
|
||||
fi
|
||||
|
||||
HELPDIR= HELPDIRDEFINE= HELPINSTALL=
|
||||
if test "$opt_separate_help" != no; then
|
||||
if test "$opt_separate_help" = "yes" ; then
|
||||
HELPDIR='${datadir}/bash'
|
||||
else
|
||||
HELPDIR=$opt_separate_help
|
||||
fi
|
||||
HELPDIRDEFINE='-H ${HELPDIR}'
|
||||
HELPINSTALL='install-help'
|
||||
fi
|
||||
|
||||
dnl now substitute in the values generated by arguments
|
||||
AC_SUBST(TESTSCRIPT)
|
||||
AC_SUBST(PURIFY)
|
||||
|
|
@ -279,8 +309,12 @@ AC_SUBST(MALLOC_DEP)
|
|||
|
||||
AC_SUBST(htmldir)
|
||||
|
||||
AC_SUBST(HELPDIR)
|
||||
AC_SUBST(HELPDIRDEFINE)
|
||||
AC_SUBST(HELPINSTALL)
|
||||
|
||||
echo ""
|
||||
echo "Beginning configuration for bash-$BASHVERS for ${host_cpu}-${host_vendor}-${host_os}"
|
||||
echo "Beginning configuration for bash-$BASHVERS-$RELSTATUS for ${host_cpu}-${host_vendor}-${host_os}"
|
||||
echo ""
|
||||
|
||||
dnl compilation checks
|
||||
|
|
@ -355,6 +389,7 @@ if test "$opt_profiling" = "yes"; then
|
|||
solaris2*) ;;
|
||||
*) opt_static_link=yes ;;
|
||||
esac
|
||||
DEBUG= MALLOC_DEBUG=
|
||||
fi
|
||||
|
||||
if test "$opt_static_link" = yes; then
|
||||
|
|
@ -368,11 +403,18 @@ if test "$opt_static_link" = yes; then
|
|||
fi
|
||||
fi
|
||||
|
||||
test -z "$CPPFLAGS_FOR_BUILD" && CPPFLAGS_FOR_BUILD="$CPPFLAGS"
|
||||
test -z "$CFLAGS_FOR_BUILD" && CFLAGS_FOR_BUILD="-g"
|
||||
|
||||
AC_SUBST(CFLAGS)
|
||||
AC_SUBST(CPPFLAGS)
|
||||
AC_SUBST(LDFLAGS)
|
||||
AC_SUBST(STATIC_LD)
|
||||
|
||||
AC_SUBST(CFLAGS_FOR_BUILD)
|
||||
AC_SUBST(CPPFLAGS_FOR_BUILD)
|
||||
AC_SUBST(LDFLAGS_FOR_BUILD)
|
||||
|
||||
AC_PROG_GCC_TRADITIONAL
|
||||
|
||||
dnl BEGIN READLINE and HISTORY LIBRARY SECTION
|
||||
|
|
@ -381,7 +423,6 @@ dnl prepare to allow bash to be linked against an already-installed readline
|
|||
dnl first test that the readline version is new enough to link bash against
|
||||
if test "$opt_readline" = yes && test "$opt_with_installed_readline" != "no"
|
||||
then
|
||||
echo opt_with_installed_readline = $opt_with_installed_readline
|
||||
# If the user specified --with-installed-readline=PREFIX and PREFIX
|
||||
# is not `yes', set ac_cv_rl_prefix to PREFIX
|
||||
test $opt_with_installed_readline != "yes" && ac_cv_rl_prefix=$opt_with_installed_readline
|
||||
|
|
@ -389,7 +430,7 @@ echo opt_with_installed_readline = $opt_with_installed_readline
|
|||
RL_LIB_READLINE_VERSION
|
||||
|
||||
case "$ac_cv_rl_version" in
|
||||
4.[[2-9]]*|5*|6*|7*|8*|9*) ;;
|
||||
4.[[3-9]]*|5*|6*|7*|8*|9*) ;;
|
||||
*) opt_with_installed_readline=no
|
||||
AC_MSG_WARN(installed readline library is too old to be linked with bash)
|
||||
AC_MSG_WARN(using private bash version)
|
||||
|
|
@ -530,6 +571,7 @@ AC_TYPE_SIGNAL
|
|||
dnl checks for certain version-specific system calls and libc functions
|
||||
AC_CHECK_FUNC(__setostype, AC_DEFINE(HAVE_SETOSTYPE))
|
||||
AC_CHECK_FUNC(wait3, AC_DEFINE(HAVE_WAIT3))
|
||||
AC_CHECK_FUNC(isinf, AC_DEFINE(HAVE_ISINF_IN_LIBC))
|
||||
|
||||
dnl checks for missing libc functions
|
||||
AC_CHECK_FUNC(mkfifo,AC_DEFINE(HAVE_MKFIFO),AC_DEFINE(MKFIFO_MISSING))
|
||||
|
|
@ -542,20 +584,21 @@ AC_CHECK_FUNCS(dup2 select getdtablesize getgroups gethostname \
|
|||
AC_REPLACE_FUNCS(rename)
|
||||
|
||||
dnl checks for c library functions
|
||||
AC_CHECK_FUNCS(bcopy bzero confstr sysconf pathconf setenv putenv \
|
||||
AC_CHECK_FUNCS(bcopy bzero confstr sysconf pathconf setenv putenv unsetenv \
|
||||
setlinebuf setvbuf setlocale strchr tcgetattr uname \
|
||||
ulimit tzset siginterrupt memmove ttyname times \
|
||||
getaddrinfo gethostbyname getservbyname inet_aton \
|
||||
getaddrinfo gethostbyname getservbyname getservent inet_aton \
|
||||
vsnprintf snprintf vasprintf asprintf fnmatch)
|
||||
AC_CHECK_FUNCS(isascii isblank isgraph isprint isspace isxdigit)
|
||||
AC_REPLACE_FUNCS(getcwd strcasecmp strerror strpbrk strtod)
|
||||
AC_REPLACE_FUNCS(strtol strtoul strtoll strtoull strtoimax strtoumax)
|
||||
AC_REPLACE_FUNCS(getcwd strcasecmp strerror strftime strpbrk memset)
|
||||
AC_REPLACE_FUNCS(strtod strtol strtoul strtoll strtoull strtoimax strtoumax)
|
||||
|
||||
AC_CHECK_DECLS([strtold])
|
||||
AC_CHECK_DECLS([confstr])
|
||||
AC_CHECK_DECLS([sbrk])
|
||||
AC_CHECK_DECLS([printf])
|
||||
AC_CHECK_DECLS([sbrk])
|
||||
AC_CHECK_DECLS([strcpy])
|
||||
AC_CHECK_DECLS([strsignal])
|
||||
AC_CHECK_DECLS([strtold])
|
||||
|
||||
BASH_CHECK_DECL(strtoimax)
|
||||
BASH_CHECK_DECL(strtol)
|
||||
|
|
@ -564,6 +607,8 @@ BASH_CHECK_DECL(strtoul)
|
|||
BASH_CHECK_DECL(strtoull)
|
||||
BASH_CHECK_DECL(strtoumax)
|
||||
|
||||
AC_FUNC_MKTIME
|
||||
|
||||
dnl checks for locale functions
|
||||
AC_CHECK_HEADERS(libintl.h)
|
||||
AC_CHECK_FUNCS(gettext textdomain bindtextdomain)
|
||||
|
|
@ -577,6 +622,8 @@ if test "$ac_cv_func_bindtextdomain" = "no"; then
|
|||
fi
|
||||
fi
|
||||
|
||||
BASH_CHECK_MULTIBYTE
|
||||
|
||||
dnl checks for the dynamic loading library functions in libc and libdl
|
||||
if test "$opt_static_link" != yes; then
|
||||
AC_CHECK_LIB(dl, dlopen)
|
||||
|
|
@ -684,18 +731,34 @@ BASH_STRUCT_DIRENT_D_FILENO
|
|||
BASH_STRUCT_WINSIZE
|
||||
BASH_STRUCT_TIMEVAL
|
||||
AC_CHECK_MEMBERS([struct stat.st_blocks])
|
||||
AC_STRUCT_TM
|
||||
AC_STRUCT_TIMEZONE
|
||||
|
||||
dnl presence and behavior of C library functions
|
||||
BASH_FUNC_STRSIGNAL
|
||||
BASH_FUNC_OPENDIR_CHECK
|
||||
BASH_FUNC_ULIMIT_MAXFDS
|
||||
BASH_FUNC_GETENV
|
||||
if test "$ac_func_getcwd" = "yes"; then
|
||||
if test "$ac_cv_func_getcwd" = "yes"; then
|
||||
BASH_FUNC_GETCWD
|
||||
fi
|
||||
BASH_FUNC_POSIX_SETJMP
|
||||
BASH_FUNC_STRCOLL
|
||||
|
||||
dnl If putenv or unsetenv is not present, set the right define so the
|
||||
dnl prototype and declaration in lib/sh/getenv.c will be standard-conformant
|
||||
|
||||
if test "$ac_cv_func_putenv" = "yes"; then
|
||||
BASH_FUNC_STD_PUTENV
|
||||
else
|
||||
AC_DEFINE(HAVE_STD_PUTENV)
|
||||
fi
|
||||
if test "$ac_cv_func_unsetenv" = "yes"; then
|
||||
BASH_FUNC_STD_UNSETENV
|
||||
else
|
||||
AC_DEFINE(HAVE_STD_UNSETENV)
|
||||
fi
|
||||
|
||||
dnl I have removed this check. The existing libc FNM_EXTMATCH implementation
|
||||
dnl (glibc-2.2.4) disagrees with bash on the matching of incorrectly-formed
|
||||
dnl patterns (bash treats them as strings or characters to be matched without
|
||||
|
|
@ -779,14 +842,14 @@ dgux*) LOCAL_CFLAGS=-D_DGUX_SOURCE; LOCAL_LIBS=-ldgc ;;
|
|||
isc*) LOCAL_CFLAGS=-Disc386 ;;
|
||||
rhapsody*) LOCAL_CFLAGS=-DRHAPSODY ;;
|
||||
darwin*) LOCAL_CFLAGS=-DMACOSX ;;
|
||||
sco3.2v5*) LOCAL_CFLAGS="-b elf -DWAITPID_BROKEN -DNO_MEMSCRAMBLE -DPATH_MAX=1024" ;;
|
||||
sco3.2v4*) LOCAL_CFLAGS="-DMUST_UNBLOCK_CHLD -DNO_MEMSCRAMBLE -DPATH_MAX=1024" ;;
|
||||
sco3.2v5*) LOCAL_CFLAGS="-b elf -DWAITPID_BROKEN -DPATH_MAX=1024" ;;
|
||||
sco3.2v4*) LOCAL_CFLAGS="-DMUST_UNBLOCK_CHLD -DPATH_MAX=1024" ;;
|
||||
sco3.2*) LOCAL_CFLAGS=-DMUST_UNBLOCK_CHLD ;;
|
||||
sunos4*) LOCAL_CFLAGS=-DSunOS4 ;;
|
||||
solaris2.5*) LOCAL_CFLAGS=-DSunOS5 ;;
|
||||
lynxos*) LOCAL_CFLAGS=-DRECYCLES_PIDS ;;
|
||||
linux*) LOCAL_LDFLAGS=-rdynamic ;; # allow dynamic loading
|
||||
*qnx*) LOCAL_CFLAGS="-Dqnx -F -3s" LOCAL_LDFLAGS="-3s -lunix -lncurses" ;;
|
||||
*qnx*) LOCAL_CFLAGS="-Dqnx -F -3s" LOCAL_LDFLAGS="-3s" LOCAL_LIBS="-lunix -lncurses" ;;
|
||||
powerux*) LOCAL_LIBS="-lgen" ;;
|
||||
cygwin*) LOCAL_LIBS="-luser32" ;;
|
||||
opennt*|interix*) LOCAL_CFLAGS="-DNO_MAIN_ENV_ARG -DBROKEN_DIRENT_D_INO" ;;
|
||||
|
|
@ -866,6 +929,9 @@ AC_SUBST(AR)
|
|||
AC_SUBST(ARFLAGS)
|
||||
|
||||
AC_SUBST(BASHVERS)
|
||||
AC_SUBST(RELSTATUS)
|
||||
AC_SUBST(DEBUG)
|
||||
AC_SUBST(MALLOC_DEBUG)
|
||||
|
||||
AC_SUBST(host_cpu)
|
||||
AC_SUBST(host_vendor)
|
||||
|
|
|
|||
26
copy_cmd.c
26
copy_cmd.c
|
|
@ -58,13 +58,8 @@ copy_word (w)
|
|||
{
|
||||
WORD_DESC *new_word;
|
||||
|
||||
new_word = (WORD_DESC *)xmalloc (sizeof (WORD_DESC));
|
||||
#if 1
|
||||
new_word = make_bare_word (w->word);
|
||||
new_word->flags = w->flags;
|
||||
#else
|
||||
FASTCOPY ((char *)w, (char *)new_word, sizeof (WORD_DESC));
|
||||
#endif
|
||||
new_word->word = savestring (w->word);
|
||||
return (new_word);
|
||||
}
|
||||
|
||||
|
|
@ -74,15 +69,11 @@ WORD_LIST *
|
|||
copy_word_list (list)
|
||||
WORD_LIST *list;
|
||||
{
|
||||
WORD_LIST *new_list, *temp;
|
||||
WORD_LIST *new_list;
|
||||
|
||||
for (new_list = (WORD_LIST *)NULL; list; list = list->next)
|
||||
{
|
||||
temp = (WORD_LIST *)xmalloc (sizeof (WORD_LIST));
|
||||
temp->next = new_list;
|
||||
new_list = temp;
|
||||
new_list->word = copy_word (list->word);
|
||||
}
|
||||
new_list = make_word_list (copy_word (list->word), new_list);
|
||||
|
||||
return (REVERSE_LIST (new_list, WORD_LIST *));
|
||||
}
|
||||
|
||||
|
|
@ -128,6 +119,7 @@ copy_redirect (redirect)
|
|||
case r_deblank_reading_until:
|
||||
new_redirect->here_doc_eof = savestring (redirect->here_doc_eof);
|
||||
/*FALLTHROUGH*/
|
||||
case r_reading_string:
|
||||
case r_appending_to:
|
||||
case r_output_direction:
|
||||
case r_input_direction:
|
||||
|
|
@ -137,10 +129,14 @@ copy_redirect (redirect)
|
|||
case r_output_force:
|
||||
case r_duplicating_input_word:
|
||||
case r_duplicating_output_word:
|
||||
case r_move_input_word:
|
||||
case r_move_output_word:
|
||||
new_redirect->redirectee.filename = copy_word (redirect->redirectee.filename);
|
||||
break;
|
||||
case r_duplicating_input:
|
||||
case r_duplicating_output:
|
||||
case r_move_input:
|
||||
case r_move_output:
|
||||
case r_close_this:
|
||||
break;
|
||||
}
|
||||
|
|
@ -253,7 +249,7 @@ copy_if_command (com)
|
|||
new_if->flags = com->flags;
|
||||
new_if->test = copy_command (com->test);
|
||||
new_if->true_case = copy_command (com->true_case);
|
||||
new_if->false_case = copy_command (com->false_case);
|
||||
new_if->false_case = com->false_case ? copy_command (com->false_case) : com->false_case;
|
||||
return (new_if);
|
||||
}
|
||||
|
||||
|
|
@ -301,7 +297,7 @@ copy_simple_command (com)
|
|||
new_simple = (SIMPLE_COM *)xmalloc (sizeof (SIMPLE_COM));
|
||||
new_simple->flags = com->flags;
|
||||
new_simple->words = copy_word_list (com->words);
|
||||
new_simple->redirects = copy_redirects (com->redirects);
|
||||
new_simple->redirects = com->redirects ? copy_redirects (com->redirects) : (REDIRECT *)NULL;
|
||||
new_simple->line = com->line;
|
||||
return (new_simple);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@
|
|||
#include "bashansi.h"
|
||||
#include "shell.h"
|
||||
|
||||
extern sh_obj_cache_t wdcache, wlcache;
|
||||
|
||||
/* Dispose of the command structure passed. */
|
||||
void
|
||||
dispose_command (command)
|
||||
|
|
@ -222,7 +224,11 @@ dispose_word (w)
|
|||
WORD_DESC *w;
|
||||
{
|
||||
FREE (w->word);
|
||||
#if 0
|
||||
free (w);
|
||||
#else
|
||||
ocache_free (wdcache, WORD_DESC, w);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* How to get rid of a linked list of words. A WORD_LIST. */
|
||||
|
|
@ -237,7 +243,11 @@ dispose_words (list)
|
|||
t = list;
|
||||
list = list->next;
|
||||
dispose_word (t->word);
|
||||
#if 0
|
||||
free (t);
|
||||
#else
|
||||
ocache_free (wlcache, WORD_LIST, t);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -277,6 +287,7 @@ dispose_redirects (list)
|
|||
case r_deblank_reading_until:
|
||||
free (t->here_doc_eof);
|
||||
/*FALLTHROUGH*/
|
||||
case r_reading_string:
|
||||
case r_output_direction:
|
||||
case r_input_direction:
|
||||
case r_inputa_direction:
|
||||
|
|
@ -286,6 +297,8 @@ dispose_redirects (list)
|
|||
case r_output_force:
|
||||
case r_duplicating_input_word:
|
||||
case r_duplicating_output_word:
|
||||
case r_move_input_word:
|
||||
case r_move_output_word:
|
||||
dispose_word (t->redirectee.filename);
|
||||
/* FALLTHROUGH */
|
||||
default:
|
||||
|
|
|
|||
178
doc/FAQ
178
doc/FAQ
|
|
@ -1,4 +1,4 @@
|
|||
This is the Bash FAQ, version 3.17, for Bash version 2.05a.
|
||||
This is the Bash FAQ, version 3.20, for Bash version 2.05b.
|
||||
|
||||
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 2.05a?
|
||||
B2) Are there any user-visible incompatibilities between bash-2.05a and
|
||||
B1) What's new in version 2.05b?
|
||||
B2) Are there any user-visible incompatibilities between bash-2.05b and
|
||||
bash-1.14.7?
|
||||
|
||||
Section C: Differences from other Unix shells
|
||||
|
|
@ -74,6 +74,7 @@ E7) What about empty for loops in Makefiles?
|
|||
E8) Why does the arithmetic evaluation code complain about `08'?
|
||||
E9) Why does the pattern matching expression [A-Z]* match files beginning
|
||||
with every letter except `z'?
|
||||
E10) Why does `cd //' leave $PWD as `//'?
|
||||
|
||||
Section F: Things to watch out for on certain Unix versions
|
||||
|
||||
|
|
@ -86,6 +87,8 @@ F4) I'm running SVR4.2. Why is the line erased every time I type `@'?
|
|||
F5) Why does bash report syntax errors when my C News scripts use a
|
||||
redirection before a subshell command?
|
||||
F6) Why can't I use vi-mode editing on Red Hat Linux 6.1?
|
||||
F7) Why do bash-2.05a and bash-2.05b fail to compile `printf.def' on
|
||||
HP/UX 11.x?
|
||||
|
||||
Section G: How can I get bash to do certain common things?
|
||||
|
||||
|
|
@ -134,23 +137,23 @@ of Case Western Reserve University.
|
|||
|
||||
A2) What's the latest version?
|
||||
|
||||
The latest version is 2.05a, first made available on Thursday, 15
|
||||
November, 2001.
|
||||
The latest version is 2.05b, first made available on Wednesday, 17
|
||||
July, 2002.
|
||||
|
||||
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 2.05a:
|
||||
The following URLs tell how to get version 2.05b:
|
||||
|
||||
ftp://ftp.gnu.org/pub/gnu/bash/bash-2.05a.tar.gz
|
||||
ftp://ftp.cwru.edu/pub/bash/bash-2.05a.tar.gz
|
||||
ftp://ftp.gnu.org/pub/gnu/bash/bash-2.05b.tar.gz
|
||||
ftp://ftp.cwru.edu/pub/bash/bash-2.05b.tar.gz
|
||||
|
||||
Formatted versions of the documentation are available with the URLs:
|
||||
|
||||
ftp://ftp.gnu.org/pub/gnu/bash/bash-doc-2.05a.tar.gz
|
||||
ftp://ftp.cwru.edu/pub/bash/bash-doc-2.05a.tar.gz
|
||||
ftp://ftp.gnu.org/pub/gnu/bash/bash-doc-2.05b.tar.gz
|
||||
ftp://ftp.cwru.edu/pub/bash/bash-doc-2.05b.tar.gz
|
||||
|
||||
A4) On what machines will bash run?
|
||||
|
||||
|
|
@ -187,7 +190,7 @@ early GNU-Win32 (the original name) releases. Cygnus has also done a
|
|||
port of bash-2.05 to the CYGWIN environment, and it is available as
|
||||
part of their current release.
|
||||
|
||||
Bash-2.05a should require no local Cygnus changes to build and run under
|
||||
Bash-2.05b should require no local Cygnus changes to build and run under
|
||||
CYGWIN.
|
||||
|
||||
The Cygnus port works only on Intel machines. There is a port of bash
|
||||
|
|
@ -363,6 +366,10 @@ available on the web at
|
|||
|
||||
http://www.opengroup.org/onlinepubs/007908799/
|
||||
|
||||
The Single Unix Specification, version 3, is available on the web at
|
||||
|
||||
http://www.opengroup.org/onlinepubs/007904975/
|
||||
|
||||
A10) What is the bash `posix mode'?
|
||||
|
||||
Although bash is an implementation of the POSIX.2 shell
|
||||
|
|
@ -370,29 +377,61 @@ specification, there are areas where the bash default behavior
|
|||
differs from that spec. The bash `posix mode' changes the bash
|
||||
behavior in these areas so that it obeys the spec more closely.
|
||||
|
||||
Posix mode is entered by starting bash with the --posix option or
|
||||
executing `set -o posix' after bash is running.
|
||||
Posix mode is entered by starting bash with the --posix or
|
||||
'-o posix' option or executing `set -o posix' after bash is running.
|
||||
|
||||
The specific aspects of bash which change when posix mode is
|
||||
active are listed in the file CWRU/POSIX.NOTES in the bash
|
||||
distribution. They are also listed in a section in the Bash
|
||||
Reference Manual.
|
||||
active are listed in the file POSIX in the bash distribution.
|
||||
They are also listed in a section in the Bash Reference Manual
|
||||
(from which that file is generated).
|
||||
|
||||
Section B: The latest version
|
||||
|
||||
B1) What's new in version 2.05a?
|
||||
B1) What's new in version 2.05b?
|
||||
|
||||
The raison d'etre for bash-2.05a is to make an intermediate release
|
||||
containing principally bug fixes (some very good work was done and
|
||||
contributed after bash-2.05 was released) available before I start to
|
||||
work on the major new features to be available in the next release
|
||||
(bash-2.06 or bash-3.0 or whatever I tag it). As such, there are
|
||||
only a few relatively minor new features.
|
||||
The raison d'etre for bash-2.05b is to make a second intermediate
|
||||
release containing the first of the new features to be available
|
||||
in bash-3.0 and get feedback on those features before proceeding.
|
||||
The major new feature is multibyte character support in both Bash
|
||||
and Readline.
|
||||
|
||||
Bash-2.05a contains the following new features (see the manual page for
|
||||
complete descriptions and the CHANGES and NEWS files in the bash-2.05a
|
||||
Bash-2.05b contains the following new features (see the manual page for
|
||||
complete descriptions and the CHANGES and NEWS files in the bash-2.05b
|
||||
distribution):
|
||||
|
||||
o support for multibyte characters has been added to both bash and readline
|
||||
|
||||
o the DEBUG trap is now run *before* simple commands, ((...)) commands,
|
||||
[[...]] conditional commands, and for ((...)) loops
|
||||
|
||||
o the shell now performs arithmetic in the largest integer size the machine
|
||||
supports (intmax_t)
|
||||
|
||||
o there is a new \D{...} prompt expansion; passes the `...' to strftime(3)
|
||||
and inserts the result into the expanded prompt
|
||||
|
||||
o there is a new `here-string' redirection operator: <<< word
|
||||
|
||||
o when displaying variables, function attributes and definitions are shown
|
||||
separately, allowing them to be re-used as input (attempting to re-use
|
||||
the old output would result in syntax errors).
|
||||
|
||||
o `read' has a new `-u fd' option to read from a specified file descriptor
|
||||
|
||||
o the bash debugger in examples/bashdb has been modified to work with the
|
||||
new DEBUG trap semantics, the command set has been made more gdb-like,
|
||||
and the changes to $LINENO make debugging functions work better
|
||||
|
||||
o the expansion of $LINENO inside a shell function is only relative to the
|
||||
function start if the shell is interactive -- if the shell is running a
|
||||
script, $LINENO expands to the line number in the script. This is as
|
||||
POSIX-2001 requires
|
||||
|
||||
|
||||
A short feature history dating from Bash-2.0:
|
||||
|
||||
Bash-2.05a introduced the following new features:
|
||||
|
||||
o The `printf' builtin has undergone major work
|
||||
|
||||
o There is a new read-only `shopt' option: login_shell, which is set by
|
||||
|
|
@ -418,8 +457,6 @@ o Readline can be configured to place the user at the same point on the line
|
|||
o Readline can be configured to skip `hidden' files (filenames with a leading
|
||||
`.' on Unix) when performing completion
|
||||
|
||||
A short feature history dating from bash-2.0:
|
||||
|
||||
Bash-2.05 introduced the following new features:
|
||||
|
||||
o This version has once again reverted to using locales and strcoll(3) when
|
||||
|
|
@ -570,13 +607,13 @@ 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-2.05a and
|
||||
B2) Are there any user-visible incompatibilities between bash-2.05b and
|
||||
bash-1.14.7?
|
||||
|
||||
There are a few incompatibilities between version 1.14.7 and version 2.05a.
|
||||
They are detailed in the file COMPAT in the bash-2.05a distribution. That
|
||||
file is not meant to be all-encompassing; send mail to bash-maintainers@gnu.org
|
||||
if you find something that's not mentioned there.
|
||||
There are a few incompatibilities between version 1.14.7 and version 2.05b.
|
||||
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
|
||||
if if you find something that's not mentioned there.
|
||||
|
||||
Section C: Differences from other Unix shells
|
||||
|
||||
|
|
@ -589,6 +626,7 @@ completely.
|
|||
Things bash has that sh does not:
|
||||
long invocation options
|
||||
[+-]O invocation option
|
||||
-l invocation option
|
||||
`!' reserved word to invert pipeline return value
|
||||
`time' reserved word to time pipelines and shell builtins
|
||||
the `function' reserved word
|
||||
|
|
@ -601,7 +639,7 @@ Things bash has that sh does not:
|
|||
the ${#param} parameter value length operator
|
||||
the ${!param} indirect parameter expansion operator
|
||||
the ${!param*} prefix expansion operator
|
||||
the ${param:length[:offset]} parameter substring operator
|
||||
the ${param:offset[:length]} parameter substring operator
|
||||
the ${param/pat[/string]} parameter pattern substitution operator
|
||||
expansions to perform substring removal (${p%[%]w}, ${p#[#]w})
|
||||
expansion of positional parameters beyond $9 with ${num}
|
||||
|
|
@ -616,18 +654,18 @@ Things bash has that sh does not:
|
|||
DEBUG trap
|
||||
ERR trap
|
||||
variable arrays with new compound assignment syntax
|
||||
redirections: <>, &>, >|
|
||||
redirections: <>, &>, >|, <<<, [n]<&word-, [n]>&word-
|
||||
prompt string special char translation and variable expansion
|
||||
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 -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,
|
||||
read -e/-p/-a/-t/-n/-d/-s/-u,
|
||||
readonly -a/-f/name=value, trap -l, set +o,
|
||||
set -b/-m/-o option/-h/-p/-B/-C/-H/-P,
|
||||
unset -f/-v, ulimit -m/-p/-u,
|
||||
type -a/-p/-t, suspend -f, kill -n,
|
||||
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
|
||||
bash reads ~/.bashrc for interactive shells, $ENV for non-interactive
|
||||
bash restricted shell mode is more extensive
|
||||
|
|
@ -690,15 +728,17 @@ C2) How does bash differ from the Korn shell, version ksh88?
|
|||
Things bash has or uses that ksh88 does not:
|
||||
long invocation options
|
||||
[-+]O invocation option
|
||||
-l invocation option
|
||||
`!' reserved word
|
||||
arithmetic for command: for ((expr1 ; expr2; expr3 )); do list; done
|
||||
arithmetic in largest machine-supported size (intmax_t)
|
||||
posix mode and posix conformance
|
||||
command hashing
|
||||
tilde expansion for assignment statements that look like $PATH
|
||||
process substitution with named pipes if /dev/fd is not available
|
||||
the ${!param} indirect parameter expansion operator
|
||||
the ${!param*} prefix expansion operator
|
||||
the ${param:length[:offset]} parameter substring operator
|
||||
the ${param:offset[:length]} parameter substring operator
|
||||
the ${param/pat[/string]} parameter pattern substitution operator
|
||||
variables: BASH, BASH_VERSION, BASH_VERSINFO, UID, EUID, SHLVL,
|
||||
TIMEFORMAT, HISTCMD, HOSTTYPE, OSTYPE, MACHTYPE,
|
||||
|
|
@ -707,7 +747,7 @@ Things bash has or uses that ksh88 does not:
|
|||
PIPESTATUS, HOSTNAME, OPTERR, SHELLOPTS, GLOBIGNORE,
|
||||
GROUPS, FUNCNAME, histchars, auto_resume
|
||||
prompt expansion with backslash escapes and command substitution
|
||||
redirection: &> (stdout and stderr)
|
||||
redirection: &> (stdout and stderr), <<<, [n]<&word-, [n]>&word-
|
||||
more extensive and extensible editing and programmable completion
|
||||
builtins: bind, builtin, command, declare, dirs, echo -e/-E, enable,
|
||||
exec -l/-c/-a, fc -s, export -n/-f/-p, hash, help, history,
|
||||
|
|
@ -727,6 +767,7 @@ Things bash has or uses that ksh88 does not:
|
|||
`**' arithmetic operator to do exponentiation
|
||||
redirection to /dev/fd/N, /dev/stdin, /dev/stdout, /dev/stderr
|
||||
arrays of unlimited size
|
||||
TMOUT is default timeout for `read' and `select'
|
||||
|
||||
Things ksh88 has or uses that bash does not:
|
||||
tracked aliases (alias -t)
|
||||
|
|
@ -736,7 +777,7 @@ Things ksh88 has or uses that bash does not:
|
|||
typeset +f to list all function names without definitions
|
||||
text of command history kept in a file, not memory
|
||||
builtins: alias -x, cd old new, fc -e -, newgrp, print,
|
||||
read -p/-s/-u/var?prompt, set -A/-o gmacs/
|
||||
read -p/-s/var?prompt, set -A/-o gmacs/
|
||||
-o bgnice/-o markdirs/-o nolog/-o trackall/-o viraw/-s,
|
||||
typeset -H/-L/-R/-Z/-A/-ft/-fu/-fx/-l/-u/-t, whence
|
||||
using environment to pass attributes of exported variables
|
||||
|
|
@ -754,7 +795,7 @@ Implementation differences:
|
|||
|
||||
C3) Which new features in ksh-93 are not in bash, and which are?
|
||||
|
||||
New things in ksh-93 not in bash-2.05a:
|
||||
New things in ksh-93 not in bash-2.05b:
|
||||
associative arrays
|
||||
floating point arithmetic and variables
|
||||
math library functions
|
||||
|
|
@ -775,15 +816,14 @@ New things in ksh-93 not in bash-2.05a:
|
|||
exit statuses between 0 and 255
|
||||
set -o pipefail
|
||||
`+=' variable assignment operator
|
||||
TMOUT is default timeout for `read' and `select'
|
||||
<&N- and >&N- redirections (combination dup and close)
|
||||
FPATH and PATH mixing
|
||||
getopts -a
|
||||
-I invocation option
|
||||
DEBUG trap now executed before each simple command, instead of after
|
||||
printf %H, %P, %T, %Z modifiers, output base for %d
|
||||
|
||||
New things in ksh-93 present in bash-2.05a:
|
||||
New things in ksh-93 present in bash-2.05b:
|
||||
[n]<&word- and [n]>&word- redirections (combination dup and close)
|
||||
for (( expr1; expr2; expr3 )) ; do list; done - arithmetic for command
|
||||
?:, ++, --, `expr1 , expr2' arithmetic operators
|
||||
expansions: ${!param}, ${param:offset[:len]}, ${param/pat[/str]},
|
||||
|
|
@ -980,7 +1020,7 @@ ksh-93 feature Bash equivalent
|
|||
sleep, getconf Bash has loadable versions in examples/loadables
|
||||
${.sh.version} $BASH_VERSION
|
||||
print -f printf
|
||||
hist alias fc=hist
|
||||
hist alias hist=fc
|
||||
$HISTEDIT $FCEDIT
|
||||
|
||||
Section E: How can I get bash to do certain things, and why does bash do
|
||||
|
|
@ -1139,7 +1179,7 @@ configure with the --enable-xpg-echo-default option to turn this
|
|||
on. Be aware that this will cause some of the tests run when you
|
||||
type `make tests' to fail.
|
||||
|
||||
There is a shell option, `xpg_echo', settable with `shopt' that will
|
||||
There is a shell option, `xpg_echo', settable with `shopt', that will
|
||||
change the behavior of echo at runtime. Enabling this option turns
|
||||
on expansion of backslash-escape sequences.
|
||||
|
||||
|
|
@ -1215,10 +1255,9 @@ http://www.pasc.org/interps/unofficial/db/p1003.2/pasc-1003.2-173.html
|
|||
E9) Why does the pattern matching expression [A-Z]* match files beginning
|
||||
with every letter except `z'?
|
||||
|
||||
Bash-2.05 and later versions have reverted to the bash-2.03 behavior of
|
||||
honoring the current locale setting when processing ranges within pattern
|
||||
matching bracket expressions ([A-Z]). This is what POSIX.2 and SUSv2/XPG5
|
||||
specify.
|
||||
Bash-2.03, Bash-2.05 and later versions honor the current locale setting
|
||||
when processing ranges within pattern matching bracket expressions ([A-Z]).
|
||||
This is what POSIX.2 and SUSv3/XPG6 specify.
|
||||
|
||||
The behavior of the matcher in bash-2.05 and later versions depends on the
|
||||
current LC_COLLATE setting. Setting this variable to `C' or `POSIX' will
|
||||
|
|
@ -1229,7 +1268,11 @@ this:
|
|||
|
||||
AaBb...Zz
|
||||
|
||||
which means that [A-Z] matches every letter except `z'.
|
||||
which means that [A-Z] matches every letter except `z'. Others collate like
|
||||
|
||||
aAbBcC...zZ
|
||||
|
||||
which means that [A-Z] matches every letter except `a'.
|
||||
|
||||
The portable way to specify upper case letters is [:upper:] instead of
|
||||
A-Z; lower case may be specified as [:lower:] instead of a-z.
|
||||
|
|
@ -1252,6 +1295,16 @@ from removing every file in the current directory except those beginning
|
|||
with `z' and still allow individual users to change the collation order.
|
||||
Users may put the above command into their own profiles as well, of course.
|
||||
|
||||
E10) Why does `cd //' leave $PWD as `//'?
|
||||
|
||||
POSIX.2, in its description of `cd', says that *three* or more leading
|
||||
slashes may be replaced with a single slash when canonicalizing the
|
||||
current working directory.
|
||||
|
||||
This is, I presume, for historical compatibility. Certain versions of
|
||||
Unix, and early network file systems, used paths of the form
|
||||
//hostname/path to access `path' on server `hostname'.
|
||||
|
||||
Section F: Things to watch out for on certain Unix versions
|
||||
|
||||
F1) Why can't I use command line editing in my `cmdtool'?
|
||||
|
|
@ -1386,6 +1439,21 @@ to the beginning of /etc/inputrc, or bracket the key bindings in
|
|||
[...]
|
||||
$endif
|
||||
|
||||
F7) Why do bash-2.05a and bash-2.05b fail to compile `printf.def' on
|
||||
HP/UX 11.x?
|
||||
|
||||
HP/UX's support for long double is imperfect at best.
|
||||
|
||||
GCC will support it without problems, but the HP C library functions
|
||||
like strtold(3) and printf(3) don't actually work with long doubles.
|
||||
HP implemented a `long_double' type as a 4-element array of 32-bit
|
||||
ints, and that is what the library functions use. The ANSI C
|
||||
`long double' type is a 128-bit floating point scalar.
|
||||
|
||||
The easiest fix, until HP fixes things up, is to edit the generated
|
||||
config.h and #undef the HAVE_LONG_DOUBLE line. After doing that,
|
||||
the compilation should complete successfully.
|
||||
|
||||
Section G: How can I get bash to do certain common things?
|
||||
|
||||
G1) How can I get bash to read and display eight-bit characters?
|
||||
|
|
@ -1607,11 +1675,8 @@ H3) What's coming in future versions?
|
|||
|
||||
These are features I hope to include in a future version of bash.
|
||||
|
||||
a better bash debugger (a minimally-tested version is included with bash-2.05a)
|
||||
a better bash debugger (a minimally-tested version is included with bash-2.05b)
|
||||
associative arrays
|
||||
changes to the DEBUG trap to be compatible with ksh93 (which runs the
|
||||
trap before each simple command, instead of after each one like previous
|
||||
versions)
|
||||
co-processes, but with a new-style syntax that looks like function declaration
|
||||
|
||||
H4) What's on the bash `wish list' for future versions?
|
||||
|
|
@ -1621,7 +1686,6 @@ These are features that may or may not appear in a future version of bash.
|
|||
breaking some of the shell functionality into embeddable libraries
|
||||
a module system like zsh's, using dynamic loading like builtins
|
||||
better internationalization using GNU `gettext'
|
||||
an option to use external files for the long `help' text
|
||||
date-stamped command history
|
||||
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
|
||||
|
|
@ -1637,7 +1701,7 @@ H5) When will the next release appear?
|
|||
The next version will appear sometime in 2002. Never make predictions.
|
||||
|
||||
|
||||
This document is Copyright 1995-2001 by Chester Ramey.
|
||||
This document is Copyright 1995-2002 by Chester Ramey.
|
||||
|
||||
Permission is hereby granted, without written agreement and
|
||||
without license or royalty fees, to use, copy, and distribute
|
||||
|
|
|
|||
|
|
@ -65,6 +65,10 @@ PSDPI = 300 # could be 600 if you like
|
|||
DVIPS = dvips -D ${PSDPI} $(QUIETPS) -t ${PAPERSIZE} -o $@ # tricky
|
||||
TEXINPUTDIR = $(RL_LIBDIR)/doc
|
||||
|
||||
# These tools might not be available; they're not required
|
||||
DVIPDF = dvipdfm -o $@ -p ${PAPERSIZE}
|
||||
PSPDF = gs -sPAPERSIZE=${PAPERSIZE} -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -sOutputFile=$@
|
||||
|
||||
MKDIRS = ${topdir}/support/mkdirs
|
||||
|
||||
# This should be a program that converts troff to an ascii-readable format
|
||||
|
|
@ -76,7 +80,7 @@ GROFF = groff
|
|||
HSUSER = $(RL_LIBDIR)/doc/hsuser.texinfo
|
||||
RLUSER = $(RL_LIBDIR)/doc/rluser.texinfo
|
||||
|
||||
.SUFFIXES: .0 .1 .3 .ms .ps .txt .dvi .html
|
||||
.SUFFIXES: .0 .1 .3 .ms .ps .txt .dvi .html .pdf
|
||||
|
||||
.1.ps:
|
||||
$(RM) $@
|
||||
|
|
@ -110,6 +114,14 @@ RLUSER = $(RL_LIBDIR)/doc/rluser.texinfo
|
|||
$(RM) $@
|
||||
-${MAN2HTML} $< > $@
|
||||
|
||||
.ps.pdf:
|
||||
$(RM) $@
|
||||
-${PSPDF} $<
|
||||
|
||||
.dvi.pdf:
|
||||
$(RM) $@
|
||||
-${DVIPDF} $<
|
||||
|
||||
all: ps info dvi text html
|
||||
nodvi: ps info text html
|
||||
|
||||
|
|
@ -118,12 +130,14 @@ DVIFILES = bashref.dvi bashref.ps
|
|||
INFOFILES = bashref.info
|
||||
MAN0FILES = bash.0 bashbug.0 builtins.0 rbash.0
|
||||
HTMLFILES = bashref.html bash.html
|
||||
PDFFILES = bash.pdf bashref.pdf article.pdf rose94.pdf
|
||||
|
||||
ps: ${PSFILES}
|
||||
dvi: ${DVIFILES}
|
||||
info: ${INFOFILES}
|
||||
text: ${MAN0FILES}
|
||||
html: ${HTMLFILES}
|
||||
pdf: ${PDFFILES}
|
||||
|
||||
bashref.dvi: $(srcdir)/bashref.texi $(HSUSER) $(RLUSER)
|
||||
TEXINPUTS=.:$(TEXINPUTDIR):$$TEXINPUTS $(TEXI2DVI) $(srcdir)/bashref.texi
|
||||
|
|
@ -148,12 +162,12 @@ new-bashref.ps: new-bashref.dvi
|
|||
new-bashref.info: $(srcdir)/new-bashref.texi $(HSUSER) $(RLUSER)
|
||||
$(MAKEINFO) --no-split -I$(TEXINPUTDIR) $(srcdir)/new-bashref.texi
|
||||
|
||||
bash.dvi: bash.texinfo $(HSUSER) $(RLUSER)
|
||||
TEXINPUTS=.:$(TEXINPUTDIR):$$TEXINPUTS $(TEXI2DVI) bash.texinfo
|
||||
|
||||
bashman.ps: bash.dvi
|
||||
$(RM) $@
|
||||
$(DVIPS) bash.dvi
|
||||
#bash.dvi: bash.texinfo $(HSUSER) $(RLUSER)
|
||||
# TEXINPUTS=.:$(TEXINPUTDIR):$$TEXINPUTS $(TEXI2DVI) bash.texinfo
|
||||
#
|
||||
#bashman.ps: bash.dvi
|
||||
# $(RM) $@
|
||||
# $(DVIPS) bash.dvi
|
||||
|
||||
bash.txt: bash.1
|
||||
bash.ps: bash.1
|
||||
|
|
@ -167,6 +181,11 @@ builtins.0: builtins.1 bash.1
|
|||
rbash.0: rbash.1 bash.1
|
||||
article.ps: article.ms
|
||||
|
||||
article.pdf: article.ps
|
||||
bashref.pdf: bashref.dvi
|
||||
bash.pdf: bash.ps
|
||||
rose94.pdf: rose94.ps
|
||||
|
||||
$(MAN2HTML): ${topdir}/support/man2html.c
|
||||
-( cd ${BUILD_DIR}/support ; ${MAKE} ${MFLAGS} man2html)
|
||||
|
||||
|
|
@ -175,7 +194,10 @@ clean:
|
|||
*.pgs *.bt *.bts *.rw *.rws *.fns *.kys *.tps *.vrs *.o
|
||||
${RM} core *.core
|
||||
|
||||
distclean mostlyclean: clean
|
||||
mostlyclean: clean
|
||||
$(RM) Makefile
|
||||
|
||||
distclean: clean maybe-clean
|
||||
$(RM) Makefile
|
||||
|
||||
maintainer-clean: clean
|
||||
|
|
@ -183,6 +205,11 @@ maintainer-clean: clean
|
|||
${RM} ${CREATED_FAQ}
|
||||
$(RM) Makefile
|
||||
|
||||
maybe-clean:
|
||||
-if test "X$(topdir)" != "X$(BUILD_DIR)"; then \
|
||||
$(RM) ${PSFILES} ${DVIFILES} ${INFOFILES} ${MAN0FILES} ${HTMLFILES}; \
|
||||
fi
|
||||
|
||||
installdirs:
|
||||
-test -d $(man1dir) || $(SHELL) ${MKDIRS} $(DESTDIR)$(man1dir)
|
||||
-test -d $(infodir) || $(SHELL) ${MKDIRS} $(DESTDIR)$(infodir)
|
||||
|
|
@ -250,7 +277,12 @@ inst: bashref.texi
|
|||
|
||||
posix: bashref.texi
|
||||
$(SHELL) ./mkposix
|
||||
cmp -s POSIX.NOTES ../CWRU/POSIX.NOTES || mv POSIX.NOTES ../CWRU/POSIX.NOTES
|
||||
$(RM) POSIX.NOTES
|
||||
cmp -s POSIX ../POSIX || mv POSIX ../POSIX
|
||||
$(RM) POSIX
|
||||
|
||||
xdist: inst posix
|
||||
rbash: bashref.texi
|
||||
$(SH) ./mkrbash
|
||||
cmp -s RBASH ../RBASH || mv RBASH ../RBASH
|
||||
$(RM) RBASH
|
||||
|
||||
xdist: inst posix rbash
|
||||
|
|
|
|||
305
doc/bash.1
305
doc/bash.1
|
|
@ -6,12 +6,12 @@
|
|||
.\" Case Western Reserve University
|
||||
.\" chet@ins.CWRU.Edu
|
||||
.\"
|
||||
.\" Last Change: Tue Nov 13 12:55:51 EST 2001
|
||||
.\" Last Change: Mon Jul 15 15:20:56 EDT 2002
|
||||
.\"
|
||||
.\" bash_builtins, strip all but Built-Ins section
|
||||
.if \n(zZ=1 .ig zZ
|
||||
.if \n(zY=1 .ig zY
|
||||
.TH BASH 1 "2001 November 13" "GNU Bash-2.05a"
|
||||
.TH BASH 1 "2002 July 15" "GNU Bash-2.05b"
|
||||
.\"
|
||||
.\" There's some problem with having a `@'
|
||||
.\" in a tagged paragraph with the BSD man macros.
|
||||
|
|
@ -51,8 +51,8 @@ bash \- GNU Bourne-Again SHell
|
|||
[options]
|
||||
[file]
|
||||
.SH COPYRIGHT
|
||||
.if n Bash is Copyright (C) 1989-2001 by the Free Software Foundation, Inc.
|
||||
.if t Bash is Copyright \(co 1989-2001 by the Free Software Foundation, Inc.
|
||||
.if n Bash is Copyright (C) 1989-2002 by the Free Software Foundation, Inc.
|
||||
.if t Bash is Copyright \(co 1989-2002 by the Free Software Foundation, Inc.
|
||||
.SH DESCRIPTION
|
||||
.B Bash
|
||||
is an \fBsh\fR-compatible command language interpreter that
|
||||
|
|
@ -81,6 +81,20 @@ If there are arguments after the
|
|||
they are assigned to the positional parameters, starting with
|
||||
.BR $0 .
|
||||
.TP
|
||||
.B \-i
|
||||
If the
|
||||
.B \-i
|
||||
option is present, the shell is
|
||||
.IR interactive .
|
||||
.TP
|
||||
.B \-l
|
||||
Make
|
||||
.B bash
|
||||
act as if it had been invoked as a login shell (see
|
||||
.SM
|
||||
.B INVOCATION
|
||||
below).
|
||||
.TP
|
||||
.B \-r
|
||||
If the
|
||||
.B \-r
|
||||
|
|
@ -91,12 +105,6 @@ option is present, the shell becomes
|
|||
.B "RESTRICTED SHELL"
|
||||
below).
|
||||
.TP
|
||||
.B \-i
|
||||
If the
|
||||
.B \-i
|
||||
option is present, the shell is
|
||||
.IR interactive .
|
||||
.TP
|
||||
.B \-s
|
||||
If the
|
||||
.B \-s
|
||||
|
|
@ -140,7 +148,7 @@ is equivalent to \fB\-\-\fP.
|
|||
.B Bash
|
||||
also interprets a number of multi-character options.
|
||||
These options must appear on the command line before the
|
||||
single-character options in order for them to be recognized.
|
||||
single-character options to be recognized.
|
||||
.PP
|
||||
.PD 0
|
||||
.TP
|
||||
|
|
@ -154,8 +162,8 @@ Equivalent to \fB\-D\fP.
|
|||
.B \-\-help
|
||||
Display a usage message on standard output and exit successfully.
|
||||
.TP
|
||||
.PD 0
|
||||
\fB\-\-init\-file\fP \fIfile\fP
|
||||
.PD 0
|
||||
.TP
|
||||
\fB\-\-rcfile\fP \fIfile\fP
|
||||
.PD
|
||||
|
|
@ -169,12 +177,7 @@ if the shell is interactive (see
|
|||
below).
|
||||
.TP
|
||||
.B \-\-login
|
||||
Make
|
||||
.B bash
|
||||
act as if it had been invoked as a login shell (see
|
||||
.SM
|
||||
.B INVOCATION
|
||||
below).
|
||||
Equivalent to \fB\-l\fP.
|
||||
.TP
|
||||
.B \-\-noediting
|
||||
Do not use the GNU
|
||||
|
|
@ -560,6 +563,9 @@ and
|
|||
.BR &,
|
||||
which have equal precedence.
|
||||
.PP
|
||||
A sequence of one or more newlines may appear in a \fIlist\fP instead
|
||||
of a semicolon to delimit commands.
|
||||
.PP
|
||||
If a command is terminated by the control operator
|
||||
.BR & ,
|
||||
the shell executes the command in the \fIbackground\fP
|
||||
|
|
@ -685,7 +691,7 @@ is true.
|
|||
The \fB&&\fP and
|
||||
.if t \fB\(bv\(bv\fP
|
||||
.if n \fB||\fP
|
||||
operators do not execute \fIexpression2\fP if the value of
|
||||
operators do not evaluate \fIexpression2\fP if the value of
|
||||
\fIexpression1\fP is sufficient to determine the return value of
|
||||
the entire conditional expression.
|
||||
.RE
|
||||
|
|
@ -773,8 +779,8 @@ command completes. Otherwise, the \fBelse\fP \fIlist\fP is
|
|||
executed, if present. The exit status is the exit status of the
|
||||
last command executed, or zero if no condition tested true.
|
||||
.TP
|
||||
.PD 0
|
||||
\fBwhile\fP \fIlist\fP; \fBdo\fP \fIlist\fP; \fBdone\fP
|
||||
.PD 0
|
||||
.TP
|
||||
\fBuntil\fP \fIlist\fP; \fBdo\fP \fIlist\fP; \fBdone\fP
|
||||
.PD
|
||||
|
|
@ -929,6 +935,9 @@ the eight-bit character whose value is the octal value \fInnn\fP
|
|||
.B \ex\fIHH\fP
|
||||
the eight-bit character whose value is the hexadecimal value \fIHH\fP
|
||||
(one or two hex digits)
|
||||
.TP
|
||||
.B \ec\fIx\fP
|
||||
a control-\fIx\fP character
|
||||
.PD
|
||||
.RE
|
||||
.LP
|
||||
|
|
@ -1417,7 +1426,9 @@ This is a colon-separated list of directories in which the shell looks
|
|||
for destination directories specified by the
|
||||
.B cd
|
||||
command.
|
||||
A sample value is ``.:~:/usr''.
|
||||
A sample value is
|
||||
.if t \f(CW".:~:/usr"\fP.
|
||||
.if n ".:~:/usr".
|
||||
.TP
|
||||
.B COLUMNS
|
||||
Used by the \fBselect\fP builtin command to determine the terminal width
|
||||
|
|
@ -1443,7 +1454,9 @@ A filename whose suffix matches one of the entries in
|
|||
.SM
|
||||
.B FIGNORE
|
||||
is excluded from the list of matched filenames.
|
||||
A sample value is ``.o:~''.
|
||||
A sample value is
|
||||
.if t \f(CW".o:~"\fP.
|
||||
.if n ".o:~".
|
||||
.TP
|
||||
.B GLOBIGNORE
|
||||
A colon-separated list of patterns defining the set of filenames to
|
||||
|
|
@ -1761,7 +1774,11 @@ If the value is null, no timing information is displayed.
|
|||
A trailing newline is added when the format string is displayed.
|
||||
.TP
|
||||
.B TMOUT
|
||||
If set to a value greater than zero, the value is interpreted as the
|
||||
If set to a value greater than zero, \fBTMOUT\fP is treated as the
|
||||
default timeout for the \fBread\fP builtin.
|
||||
The \fBselect\fP command terminates if input does not arrive
|
||||
after \fBTMOUT\fP seconds when input is coming from a terminal.
|
||||
In an interactive shell, the value is interpreted as the
|
||||
number of seconds to wait for input after issuing the primary prompt.
|
||||
.B Bash
|
||||
terminates after waiting for that number of seconds if input does
|
||||
|
|
@ -2150,8 +2167,8 @@ is null or unset, nothing is substituted, otherwise the expansion of
|
|||
.I word
|
||||
is substituted.
|
||||
.TP
|
||||
.PD 0
|
||||
${\fIparameter\fP\fB:\fP\fIoffset\fP}
|
||||
.PD 0
|
||||
.TP
|
||||
${\fIparameter\fP\fB:\fP\fIoffset\fP\fB:\fP\fIlength\fP}
|
||||
.PD
|
||||
|
|
@ -2200,8 +2217,8 @@ or
|
|||
.BR @ ,
|
||||
the value substituted is the number of elements in the array.
|
||||
.TP
|
||||
.PD 0
|
||||
${\fIparameter\fP\fB#\fP\fIword\fP}
|
||||
.PD 0
|
||||
.TP
|
||||
${\fIparameter\fP\fB##\fP\fIword\fP}
|
||||
.PD
|
||||
|
|
@ -2232,8 +2249,8 @@ or
|
|||
the pattern removal operation is applied to each member of the
|
||||
array in turn, and the expansion is the resultant list.
|
||||
.TP
|
||||
.PD 0
|
||||
${\fIparameter\fP\fB%\fP\fIword\fP}
|
||||
.PD 0
|
||||
.TP
|
||||
${\fIparameter\fP\fB%%\fP\fIword\fP}
|
||||
.PD
|
||||
|
|
@ -2262,8 +2279,8 @@ or
|
|||
the pattern removal operation is applied to each member of the
|
||||
array in turn, and the expansion is the resultant list.
|
||||
.TP
|
||||
.PD 0
|
||||
${\fIparameter\fP\fB/\fP\fIpattern\fP\fB/\fP\fIstring\fP}
|
||||
.PD 0
|
||||
.TP
|
||||
${\fIparameter\fP\fB//\fP\fIpattern\fP\fB/\fP\fIstring\fP}
|
||||
.PD
|
||||
|
|
@ -2596,10 +2613,11 @@ following classes defined in the POSIX.2 standard:
|
|||
.PP
|
||||
.RS
|
||||
.B
|
||||
.if n alnum alpha ascii blank cntrl digit graph lower print punct space upper xdigit
|
||||
.if t alnum alpha ascii blank cntrl digit graph lower print punct space upper xdigit
|
||||
.if n alnum alpha ascii blank cntrl digit graph lower print punct space upper word xdigit
|
||||
.if t alnum alpha ascii blank cntrl digit graph lower print punct space upper word xdigit
|
||||
.br
|
||||
A character class matches any character belonging to that class.
|
||||
The \fBword\fP character class matches letters, digits, and the character _.
|
||||
.br
|
||||
.if t .sp 0.5
|
||||
.if n .sp 1
|
||||
|
|
@ -2849,7 +2867,7 @@ is seen. All of
|
|||
the lines read up to that point are then used as the standard
|
||||
input for a command.
|
||||
.PP
|
||||
The format of here-documents is as follows:
|
||||
The format of here-documents is:
|
||||
.RS
|
||||
.PP
|
||||
.nf
|
||||
|
|
@ -2890,6 +2908,17 @@ line containing
|
|||
This allows
|
||||
here-documents within shell scripts to be indented in a
|
||||
natural fashion.
|
||||
.SS "Here Strings"
|
||||
A variant of here documents, the format is:
|
||||
.RS
|
||||
.PP
|
||||
.nf
|
||||
\fB<<<\fP\fIword\fP
|
||||
.fi
|
||||
.RE
|
||||
.PP
|
||||
The \fIword\fP is expanded and supplied to the command on its standard
|
||||
input.
|
||||
.SS "Duplicating File Descriptors"
|
||||
.PP
|
||||
The redirection operator
|
||||
|
|
@ -2932,6 +2961,28 @@ do not specify a file descriptor open for output, a redirection error occurs.
|
|||
As a special case, if \fIn\fP is omitted, and \fIword\fP does not
|
||||
expand to one or more digits, the standard output and standard
|
||||
error are redirected as described previously.
|
||||
.SS "Moving File Descriptors"
|
||||
.PP
|
||||
The redirection operator
|
||||
.RS
|
||||
.PP
|
||||
[\fIn\fP]\fB<&\fP\fIdigit\fP\fB\-\fP
|
||||
.RE
|
||||
.PP
|
||||
moves the file descriptor \fIdigit\fP to file descriptor
|
||||
.IR n ,
|
||||
or the standard input (file descriptor 0) if \fIn\fP is not specified.
|
||||
\fIdigit\fP is closed after being duplicated to \fIn\fP.
|
||||
.PP
|
||||
Similarly, the redirection operator
|
||||
.RS
|
||||
.PP
|
||||
[\fIn\fP]\fB>&\fP\fIdigit\fP\fB\-\fP
|
||||
.RE
|
||||
.PP
|
||||
moves the file descriptor \fIdigit\fP to file descriptor
|
||||
.IR n ,
|
||||
or the standard output (file descriptor 1) if \fIn\fP is not specified.
|
||||
.SS "Opening File Descriptors for Reading and Writing"
|
||||
.PP
|
||||
The redirection operator
|
||||
|
|
@ -3058,7 +3109,11 @@ trap (see the description of the
|
|||
builtin under
|
||||
.SM
|
||||
.B SHELL BUILTIN COMMANDS
|
||||
below) is not inherited.
|
||||
below) is not inherited unless the function has been given the
|
||||
\fBtrace\fP attribute (see the description of the
|
||||
.SM
|
||||
.B declare
|
||||
builtin below).
|
||||
.PP
|
||||
Variables local to the function may be declared with the
|
||||
.B local
|
||||
|
|
@ -3101,7 +3156,7 @@ of recursive calls.
|
|||
The shell allows arithmetic expressions to be evaluated, under
|
||||
certain circumstances (see the \fBlet\fP builtin command and
|
||||
\fBArithmetic Expansion\fP).
|
||||
Evaluation is done in long integers with no check for overflow,
|
||||
Evaluation is done in fixed-width integers with no check for overflow,
|
||||
though division by 0 is trapped and flagged as an error.
|
||||
The operators and their precedence and associativity are the same
|
||||
as in the C language.
|
||||
|
|
@ -3269,14 +3324,15 @@ True if \fIfile\fP exists and is a socket.
|
|||
True if \fIfile\fP exists and has been modified since it was last read.
|
||||
.TP
|
||||
\fIfile1\fP \-\fBnt\fP \fIfile2\fP
|
||||
True if \fIfile1\fP is newer (according to
|
||||
modification date) than \fIfile2\fP.
|
||||
True if \fIfile1\fP is newer (according to modification date) than \fIfile2\fP,
|
||||
or if \fIfile1\fP exists and \fPfile2\fP does not.
|
||||
.TP
|
||||
\fIfile1\fP \-\fBot\fP \fIfile2\fP
|
||||
True if \fIfile1\fP is older than \fIfile2\fP.
|
||||
True if \fIfile1\fP is older than \fIfile2\fP, or if \fIfile2\fP exists
|
||||
and \fIfile1\fP does not.
|
||||
.TP
|
||||
\fIfile1\fP \fB\-ef\fP \fIfile2\fP
|
||||
True if \fIfile1\fP and \fIfile2\fP have the same device and
|
||||
True if \fIfile1\fP and \fIfile2\fP refer to the same device and
|
||||
inode numbers.
|
||||
.TP
|
||||
.B \-o \fIoptname\fP
|
||||
|
|
@ -3301,7 +3357,7 @@ is non-zero.
|
|||
.TP
|
||||
\fIstring1\fP \fB==\fP \fIstring2\fP
|
||||
True if the strings are equal. \fB=\fP may be used in place of
|
||||
\fB==\fP.
|
||||
\fB==\fP for strict POSIX compliance.
|
||||
.TP
|
||||
\fIstring1\fP \fB!=\fP \fIstring2\fP
|
||||
True if the strings are not equal.
|
||||
|
|
@ -3851,6 +3907,11 @@ an ASCII bell character (07)
|
|||
.B \ed
|
||||
the date in "Weekday Month Date" format (e.g., "Tue May 26")
|
||||
.TP
|
||||
.B \eD{\fIformat\fP}
|
||||
the \fIformat\fP is passed to \fIstrftime\fP(3) and the result is inserted
|
||||
into the prompt string; an empty \fIformat\fP results in a locale-specific
|
||||
time representation. The braces are required
|
||||
.TP
|
||||
.B \ee
|
||||
an ASCII escape character (033)
|
||||
.TP
|
||||
|
|
@ -4328,6 +4389,11 @@ appended.
|
|||
If set to \fBOn\fP, history lines that have been modified are displayed
|
||||
with a preceding asterisk (\fB*\fP).
|
||||
.TP
|
||||
.B mark\-symlinked\-directories (Off)
|
||||
If set to \fBOn\fP, completed names which are symbolic links to directories
|
||||
have a slash appended (subject to the value of
|
||||
\fBmark\-directories\fP).
|
||||
.TP
|
||||
.B match\-hidden\-files (On)
|
||||
This variable, when set to \fBOn\fP, causes readline to match files whose
|
||||
names begin with a `.' (hidden files) when performing filename
|
||||
|
|
@ -4339,6 +4405,10 @@ If set to \fBOn\fP, readline will display characters with the
|
|||
eighth bit set directly rather than as a meta-prefixed escape
|
||||
sequence.
|
||||
.TP
|
||||
.B page\-completions (On)
|
||||
If set to \fBOn\fP, readline uses an internal \fImore\fP-like pager
|
||||
to display a screenful of possible completions at a time.
|
||||
.TP
|
||||
.B print\-completions\-horizontally (Off)
|
||||
If set to \fBOn\fP, readline will display completions with matches
|
||||
sorted horizontally in alphabetical order, rather than down the screen.
|
||||
|
|
@ -4616,6 +4686,16 @@ A synonym for \fByank\-last\-arg\fP.
|
|||
Accept the current line for execution and fetch the next line
|
||||
relative to the current line from the history for editing. Any
|
||||
argument is ignored.
|
||||
.TP
|
||||
.B edit\-and\-execute\-command (C\-xC\-e)
|
||||
Invoke an editor on the current command line, and execute the result as shell
|
||||
commands.
|
||||
\fBBash\fP attempts to invoke
|
||||
.SM
|
||||
.BR $FCEDIT ,
|
||||
.SM
|
||||
.BR $EDITOR ,
|
||||
and \fIemacs\fP as the editor, in that order.
|
||||
.PD
|
||||
.SS Commands for Changing Text
|
||||
.PP
|
||||
|
|
@ -4672,6 +4752,17 @@ lowercase the previous word, but do not move point.
|
|||
.B capitalize\-word (M\-c)
|
||||
Capitalize the current (or following) word. With a negative argument,
|
||||
capitalize the previous word, but do not move point.
|
||||
.TP
|
||||
.B overwrite\-mode
|
||||
Toggle overwrite mode. With an explicit positive numeric argument,
|
||||
switches to overwrite mode. With an explicit non-positive numeric
|
||||
argument, switches to insert mode. This command affects only
|
||||
\fBemacs\fP mode; \fBvi\fP mode does overwrite differently.
|
||||
Each call to \fIreadline()\fP starts in insert mode.
|
||||
In overwrite mode, characters bound to \fBself\-insert\fP replace
|
||||
the text at point rather than pushing the text to the right.
|
||||
Characters bound to \fBbackward\-delete\-char\fP replace the character
|
||||
before point with a space. By default, this command is unbound.
|
||||
.PD
|
||||
.SS Killing and Yanking
|
||||
.PP
|
||||
|
|
@ -4915,21 +5006,38 @@ A character is read and point is moved to the previous occurrence of that
|
|||
character. A negative count searches for subsequent occurrences.
|
||||
.TP
|
||||
.B insert\-comment (M\-#)
|
||||
The value of the readline
|
||||
Without a numeric argument, the value of the readline
|
||||
.B comment\-begin
|
||||
variable is inserted at the beginning of the current line, and the line
|
||||
is accepted as if a newline had been typed. The default value of
|
||||
variable is inserted at the beginning of the current line.
|
||||
If a numeric argument is supplied, this command acts as a toggle: if
|
||||
the characters at the beginning of the line do not match the value
|
||||
of \fBcomment\-begin\fP, the value is inserted, otherwise
|
||||
the characters in \fBcomment-begin\fP are deleted from the beginning of
|
||||
the line.
|
||||
In either case, the line is accepted as if a newline had been typed.
|
||||
The default value of
|
||||
\fBcomment\-begin\fP causes this command to make the current line
|
||||
a shell comment.
|
||||
If a numeric argument causes the comment character to be removed, the line
|
||||
will be executed by the shell.
|
||||
.TP
|
||||
.B glob\-complete\-word (M\-g)
|
||||
The word before point is treated as a pattern for pathname expansion,
|
||||
with an asterisk implicitly appended. This pattern is used to
|
||||
generate a list of matching file names for possible completions.
|
||||
.TP
|
||||
.B glob\-expand\-word (C\-x *)
|
||||
The word before point is treated as a pattern for pathname expansion,
|
||||
and the list of matching file names is inserted, replacing the word.
|
||||
If a numeric argument is supplied, an asterisk is appended before
|
||||
pathname expansion.
|
||||
.TP
|
||||
.B glob\-list\-expansions (C\-x g)
|
||||
The list of expansions that would have been generated by
|
||||
.B glob\-expand\-word
|
||||
is displayed, and the line is redrawn.
|
||||
If a numeric argument is supplied, an asterisk is appended before
|
||||
pathname expansion.
|
||||
.TP
|
||||
.B dump\-functions
|
||||
Print all of the functions and their key bindings to the
|
||||
|
|
@ -5083,6 +5191,12 @@ default of filename completion is disabled.
|
|||
If the \fB-o default\fP option was supplied to \fBcomplete\fP when the
|
||||
compspec was defined, readline's default completion will be performed
|
||||
if the compspec generates no matches.
|
||||
.PP
|
||||
When a compspec indicates that directory name completion is desired,
|
||||
the programmable completion functions force readline to append a slash
|
||||
to completed names which are symbolic links to directories, subject to
|
||||
the value of the \fBmark\-directories\fP readline variable, regardless
|
||||
of the setting of the \fBmark-symlinked\-directories\fP readline variable.
|
||||
.SH HISTORY
|
||||
When the
|
||||
.B \-o history
|
||||
|
|
@ -5460,8 +5574,8 @@ No effect; the command does nothing beyond expanding
|
|||
and performing any specified
|
||||
redirections. A zero exit code is returned.
|
||||
.TP
|
||||
.PD 0
|
||||
\fB .\| \fP \fIfilename\fP [\fIarguments\fP]
|
||||
.PD 0
|
||||
.TP
|
||||
\fBsource\fP \fIfilename\fP [\fIarguments\fP]
|
||||
.PD
|
||||
|
|
@ -5528,8 +5642,8 @@ returns 0 unless run when job control is disabled or, when run with
|
|||
job control enabled, if \fIjobspec\fP was not found or started without
|
||||
job control.
|
||||
.TP
|
||||
.PD 0
|
||||
\fBbind\fP [\fB\-m\fP \fIkeymap\fP] [\fB\-lpsvPSV\fP]
|
||||
.PD 0
|
||||
.TP
|
||||
\fBbind\fP [\fB\-m\fP \fIkeymap\fP] [\fB\-q\fP \fIfunction\fP] [\fB\-u\fP \fIfunction\fP] [\fB\-r\fP \fIkeyseq\fP]
|
||||
.TP
|
||||
|
|
@ -5538,16 +5652,21 @@ job control.
|
|||
\fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fB\-x\fP \fIkeyseq\fP:\fIshell\-command\fP
|
||||
.TP
|
||||
\fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fIkeyseq\fP:\fIfunction\-name\fP
|
||||
.TP
|
||||
\fBbind\fP \fIreadline\-command\fP
|
||||
.PD
|
||||
Display current
|
||||
.B readline
|
||||
key and function bindings, or bind a key sequence to a
|
||||
key and function bindings, bind a key sequence to a
|
||||
.B readline
|
||||
function or macro. The binding syntax accepted is identical to that of
|
||||
function or macro, or set a
|
||||
.B readline
|
||||
variable.
|
||||
Each non-option argument is a command as it would appear in
|
||||
.IR .inputrc ,
|
||||
but each binding must be passed as a separate argument;
|
||||
e.g., '"\eC\-x\eC\-r": re\-read\-init\-file'. Options, if supplied, have the
|
||||
following meanings:
|
||||
but each binding or command must be passed as a separate argument;
|
||||
e.g., '"\eC\-x\eC\-r": re\-read\-init\-file'.
|
||||
Options, if supplied, have the following meanings:
|
||||
.RS
|
||||
.PD 0
|
||||
.TP
|
||||
|
|
@ -5639,7 +5758,7 @@ The return status is false if
|
|||
.I shell\-builtin
|
||||
is not a shell builtin command.
|
||||
.TP
|
||||
\fBcd\fP [\fB\-LP\fP] [\fIdir\fP]
|
||||
\fBcd\fP [\fB\-L|-P\fP] [\fIdir\fP]
|
||||
Change the current directory to \fIdir\fP. The variable
|
||||
.SM
|
||||
.B HOME
|
||||
|
|
@ -5743,10 +5862,10 @@ will be displayed.
|
|||
The return value is true unless an invalid option is supplied, or no
|
||||
matches were generated.
|
||||
.TP
|
||||
.PD 0
|
||||
\fBcomplete\fP [\fB\-abcdefgjkvu\fP] [\fB\-o\fP \fIcomp-option\fP] [\fB\-A\fP \fIaction\fP] [\fB\-G\fP \fIglobpat\fP] [\fB\-W\fP \fIwordlist\fP] [\fB\-P\fP \fIprefix\fP] [\fB\-S\fP \fIsuffix\fP]
|
||||
\fBcomplete\fP [\fB\-abcdefgjksuv\fP] [\fB\-o\fP \fIcomp-option\fP] [\fB\-A\fP \fIaction\fP] [\fB\-G\fP \fIglobpat\fP] [\fB\-W\fP \fIwordlist\fP] [\fB\-P\fP \fIprefix\fP] [\fB\-S\fP \fIsuffix\fP]
|
||||
.br
|
||||
[\fB\-X\fP \fIfilterpat\fP] [\fB\-F\fP \fIfunction\fP] [\fB\-C\fP \fIcommand\fP] \fIname\fP [\fIname ...\fP]
|
||||
.PD 0
|
||||
.TP
|
||||
\fBcomplete\fP \fB\-pr\fP [\fIname\fP ...]
|
||||
.PD
|
||||
|
|
@ -5777,7 +5896,8 @@ beyond the simple generation of completions.
|
|||
.RS
|
||||
.TP 8
|
||||
.B default
|
||||
Use readline's default completion if the compspec generates no matches.
|
||||
Use readline's default filename completion if the compspec generates
|
||||
no matches.
|
||||
.TP 8
|
||||
.B dirnames
|
||||
Perform directory name completion if the compspec generates no matches.
|
||||
|
|
@ -5786,6 +5906,10 @@ Perform directory name completion if the compspec generates no matches.
|
|||
Tell readline that the compspec generates filenames, so it can perform any
|
||||
filename\-specific processing (like adding a slash to directory names or
|
||||
suppressing trailing spaces). Intended to be used with shell functions.
|
||||
.TP 8
|
||||
.B nospace
|
||||
Tell readline not to append a space (the default) to words completed at
|
||||
the end of the line.
|
||||
.RE
|
||||
.TP 8
|
||||
\fB\-A\fP \fIaction\fP
|
||||
|
|
@ -5847,6 +5971,9 @@ Shell reserved words. May also be specified as \fB\-k\fP.
|
|||
.B running
|
||||
Names of running jobs, if job control is active.
|
||||
.TP 8
|
||||
.B service
|
||||
Service names. May also be specified as \fB\-s\fP.
|
||||
.TP 8
|
||||
.B setopt
|
||||
Valid arguments for the \fB\-o\fP option to the \fBset\fP builtin.
|
||||
.TP 8
|
||||
|
|
@ -5935,10 +6062,10 @@ shell is not executing a loop when
|
|||
.B continue
|
||||
is executed.
|
||||
.TP
|
||||
\fBdeclare\fP [\fB\-afFirtx\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP]]
|
||||
.PD 0
|
||||
\fBdeclare\fP [\fB\-afFirx\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP]]
|
||||
.TP
|
||||
\fBtypeset\fP [\fB\-afFirx\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP]]
|
||||
\fBtypeset\fP [\fB\-afFirtx\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP]]
|
||||
.PD
|
||||
Declare variables and/or give them attributes.
|
||||
If no \fIname\fPs are given then display the values of variables.
|
||||
|
|
@ -5981,6 +6108,11 @@ is performed when the variable is assigned a value.
|
|||
Make \fIname\fPs readonly. These names cannot then be assigned values
|
||||
by subsequent assignment statements or unset.
|
||||
.TP
|
||||
.B \-t
|
||||
Give each \fIname\fP the \fItrace\fP attribute.
|
||||
Traced functions inherit the \fBDEBUG\fP trap from the calling shell.
|
||||
The trace attribute has no special meaning for variables.
|
||||
.TP
|
||||
.B \-x
|
||||
Mark \fIname\fPs for export to subsequent commands via the environment.
|
||||
.PD
|
||||
|
|
@ -6132,9 +6264,13 @@ vertical tab
|
|||
.B \e\e
|
||||
backslash
|
||||
.TP
|
||||
.B \e0\fInnn\fP
|
||||
the eight-bit character whose value is the octal value \fInnn\fP
|
||||
(zero to three octal digits)
|
||||
.TP
|
||||
.B \e\fInnn\fP
|
||||
the eight-bit character whose value is the octal value \fInnn\fP
|
||||
(one to three digits)
|
||||
(one to three octal digits)
|
||||
.TP
|
||||
.B \ex\fIHH\fP
|
||||
the eight-bit character whose value is the hexadecimal value \fIHH\fP
|
||||
|
|
@ -6239,8 +6375,8 @@ A trap on
|
|||
.B EXIT
|
||||
is executed before the shell terminates.
|
||||
.TP
|
||||
.PD 0
|
||||
\fBexport\fP [\fB\-fn\fP\^] [\fIname\fP[=\fIword\fP]] ...
|
||||
.PD 0
|
||||
.TP
|
||||
.B export \-p
|
||||
.PD
|
||||
|
|
@ -6272,8 +6408,8 @@ is supplied with a
|
|||
.I name
|
||||
that is not a function.
|
||||
.TP
|
||||
.PD 0
|
||||
\fBfc\fP [\fB\-e\fP \fIename\fP] [\fB\-nlr\fP] [\fIfirst\fP] [\fIlast\fP]
|
||||
.PD 0
|
||||
.TP
|
||||
\fBfc\fP \fB\-s\fP [\fIpat\fP=\fIrep\fP] [\fIcmd\fP]
|
||||
.PD
|
||||
|
|
@ -6484,7 +6620,7 @@ returns true if an option, specified or unspecified, is found.
|
|||
It returns false if the end of options is encountered or an
|
||||
error occurs.
|
||||
.TP
|
||||
\fBhash\fP [\fB\-r\fP] [\fB\-p\fP \fIfilename\fP] [\fB\-t\fP] [\fIname\fP]
|
||||
\fBhash\fP [\fB\-lr\fP] [\fB\-p\fP \fIfilename\fP] [\fB\-dt\fP] [\fIname\fP]
|
||||
For each
|
||||
.IR name ,
|
||||
the full file name of the command is determined by searching
|
||||
|
|
@ -6500,12 +6636,19 @@ The
|
|||
.B \-r
|
||||
option causes the shell to forget all
|
||||
remembered locations.
|
||||
The
|
||||
.B \-d
|
||||
option causes the shell to forget the remembered location of each \fIname\fP.
|
||||
If the
|
||||
.B \-t
|
||||
option is supplied, the full pathname to which each \fIname\fP corresponds
|
||||
is printed. If multiple \fIname\fP arguments are supplied with \fB\-t\fP,
|
||||
the \fIname\fP is printed before the hashed full pathname.
|
||||
If no arguments are given, information about remembered commands is printed.
|
||||
The
|
||||
.B \-l
|
||||
option causes output to be displayed in a format that may be reused as input.
|
||||
If no arguments are given, or if only \fB\-l\fP is supplied,
|
||||
information about remembered commands is printed.
|
||||
The return status is true unless a
|
||||
.I name
|
||||
is not found or an invalid option is supplied.
|
||||
|
|
@ -6524,8 +6667,8 @@ usage synopsis.
|
|||
The return status is 0 unless no command matches
|
||||
.IR pattern .
|
||||
.TP
|
||||
.PD 0
|
||||
\fBhistory [\fIn\fP]
|
||||
.PD 0
|
||||
.TP
|
||||
\fBhistory\fP \fB\-c\fP
|
||||
.TP
|
||||
|
|
@ -6598,8 +6741,8 @@ error occurs while reading or writing the history file, an invalid
|
|||
history expansion supplied as an argument to \fB\-p\fP fails.
|
||||
.RE
|
||||
.TP
|
||||
.PD 0
|
||||
\fBjobs\fP [\fB\-lnprs\fP] [ \fIjobspec\fP ... ]
|
||||
.PD 0
|
||||
.TP
|
||||
\fBjobs\fP \fB\-x\fP \fIcommand\fP [ \fIargs\fP ... ]
|
||||
.PD
|
||||
|
|
@ -6652,8 +6795,8 @@ passing it
|
|||
returning its exit status.
|
||||
.RE
|
||||
.TP
|
||||
.PD 0
|
||||
\fBkill\fP [\fB\-s\fP \fIsigspec\fP | \fB\-n\fP \fIsignum\fP | \fB\-\fP\fIsigspec\fP] [\fIpid\fP | \fIjobspec\fP] ...
|
||||
.PD 0
|
||||
.TP
|
||||
\fBkill\fP \fB\-l\fP [\fIsigspec\fP | \fIexit_status\fP]
|
||||
.PD
|
||||
|
|
@ -6805,8 +6948,8 @@ extra format specifications behave as if a zero value or null string, as
|
|||
appropriate, had been supplied. The return value is zero on success,
|
||||
non-zero on failure.
|
||||
.TP
|
||||
.PD 0
|
||||
\fBpushd\fP [\fB\-n\fP] [\fIdir\fP]
|
||||
.PD 0
|
||||
.TP
|
||||
\fBpushd\fP [\fB\-n\fP] [+\fIn\fP] [\-\fIn\fP]
|
||||
.PD
|
||||
|
|
@ -6875,8 +7018,9 @@ The return status is 0 unless an error occurs while
|
|||
reading the name of the current directory or an
|
||||
invalid option is supplied.
|
||||
.TP
|
||||
\fBread\fP [\fB\-ers\fP] [\fB\-t\fP \fItimeout\fP] [\fB\-a\fP \fIaname\fP] [\fB\-p\fP \fIprompt\fP] [\fB\-n\fP \fInchars\fP] [\fB\-d\fP \fIdelim\fP] [\fIname\fP ...]
|
||||
One line is read from the standard input, and the first word
|
||||
\fBread\fP [\fB\-ers\fP] [\fB\-u\fP \fIfd\fP] [\fB\-t\fP \fItimeout\fP] [\fB\-a\fP \fIaname\fP] [\fB\-p\fP \fIprompt\fP] [\fB\-n\fP \fInchars\fP] [\fB\-d\fP \fIdelim\fP] [\fIname\fP ...]
|
||||
One line is read from the standard input, or from the file descriptor
|
||||
\fIfd\fP supplied as an argument to the \fB\-u\fP option, and the first word
|
||||
is assigned to the first
|
||||
.IR name ,
|
||||
the second word to the second
|
||||
|
|
@ -6884,7 +7028,7 @@ the second word to the second
|
|||
and so on, with leftover words and their intervening separators assigned
|
||||
to the last
|
||||
.IR name .
|
||||
If there are fewer words read from the standard input than names,
|
||||
If there are fewer words read from the input stream than names,
|
||||
the remaining names are assigned empty values.
|
||||
The characters in
|
||||
.SM
|
||||
|
|
@ -6942,6 +7086,9 @@ Cause \fBread\fP to time out and return failure if a complete line of
|
|||
input is not read within \fItimeout\fP seconds.
|
||||
This option has no effect if \fBread\fP is not reading input from the
|
||||
terminal or a pipe.
|
||||
.TP
|
||||
.B \-u \fIfd\FP
|
||||
Read input from file descriptor \fIfd\fP.
|
||||
.PD
|
||||
.PP
|
||||
If no
|
||||
|
|
@ -6949,8 +7096,9 @@ If no
|
|||
are supplied, the line read is assigned to the variable
|
||||
.SM
|
||||
.BR REPLY .
|
||||
The return code is zero, unless end-of-file is encountered or \fBread\fP
|
||||
times out.
|
||||
The return code is zero, unless end-of-file is encountered, \fBread\fP
|
||||
times out, or an invalid file descriptor is supplied as the argument to
|
||||
\fB\-u\fP.
|
||||
.RE
|
||||
.TP
|
||||
\fBreadonly\fP [\fB\-apf\fP] [\fIname\fP ...]
|
||||
|
|
@ -7573,8 +7721,8 @@ the shell is a login shell and
|
|||
.B \-f
|
||||
is not supplied, or if job control is not enabled.
|
||||
.TP
|
||||
.PD 0
|
||||
\fBtest\fP \fIexpr\fP
|
||||
.PD 0
|
||||
.TP
|
||||
\fB[\fP \fIexpr\fP \fB]\fP
|
||||
Return a status of 0 or 1 depending on
|
||||
|
|
@ -7761,7 +7909,7 @@ is invalid; otherwise
|
|||
.B trap
|
||||
returns true.
|
||||
.TP
|
||||
\fBtype\fP [\fB\-atp\fP] \fIname\fP [\fIname\fP ...]
|
||||
\fBtype\fP [\fB\-aftpP\fP] \fIname\fP [\fIname\fP ...]
|
||||
With no options,
|
||||
indicate how each
|
||||
.I name
|
||||
|
|
@ -7798,9 +7946,21 @@ or nothing if
|
|||
.if n ``type -t name''
|
||||
would not return
|
||||
.IR file .
|
||||
The
|
||||
.B \-P
|
||||
option forces a
|
||||
.SM
|
||||
.B PATH
|
||||
search for each \fIname\fP, even if
|
||||
.if t \f(CWtype -t name\fP
|
||||
.if n ``type -t name''
|
||||
would not return
|
||||
.IR file .
|
||||
If a command is hashed,
|
||||
.B \-p
|
||||
prints the hashed value, not necessarily the file that appears
|
||||
and
|
||||
.B \-P
|
||||
print the hashed value, not necessarily the file that appears
|
||||
first in
|
||||
.SM
|
||||
.BR PATH .
|
||||
|
|
@ -7818,6 +7978,9 @@ option is not also used.
|
|||
The table of hashed commands is not consulted
|
||||
when using
|
||||
.BR \-a .
|
||||
The
|
||||
.B \-f
|
||||
option suppresses shell function lookup, as with the \fBcommand\fP builtin.
|
||||
.B type
|
||||
returns true if any of the arguments are found, false if
|
||||
none are found.
|
||||
|
|
@ -8057,6 +8220,8 @@ options to the
|
|||
.B enable
|
||||
builtin command
|
||||
.IP \(bu
|
||||
Using the \fBenable\fP builtin command to enable disabled shell builtins
|
||||
.IP \(bu
|
||||
specifying the
|
||||
.B \-p
|
||||
option to the
|
||||
|
|
|
|||
628
doc/bashref.info
628
doc/bashref.info
File diff suppressed because it is too large
Load diff
227
doc/bashref.texi
227
doc/bashref.texi
|
|
@ -5,13 +5,13 @@
|
|||
@c %**end of header
|
||||
|
||||
@ignore
|
||||
Last Change: Tue Nov 13 12:48:51 EST 2001
|
||||
Last Change: Mon Jul 15 15:21:16 EDT 2002
|
||||
@end ignore
|
||||
|
||||
@set EDITION 2.5a
|
||||
@set VERSION 2.05a
|
||||
@set UPDATED 13 November 2001
|
||||
@set UPDATE-MONTH November 2001
|
||||
@set EDITION 2.5b
|
||||
@set VERSION 2.05b
|
||||
@set UPDATED 15 July 2002
|
||||
@set UPDATE-MONTH July 2002
|
||||
|
||||
@iftex
|
||||
@finalout
|
||||
|
|
@ -36,7 +36,7 @@ This is Edition @value{EDITION}, last updated @value{UPDATED},
|
|||
of @cite{The GNU Bash Reference Manual},
|
||||
for @code{Bash}, Version @value{VERSION}.
|
||||
|
||||
Copyright (C) 1991-2001 Free Software Foundation, Inc.
|
||||
Copyright (C) 1991-2002 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to make and distribute verbatim copies of
|
||||
this manual provided the copyright notice and this permission notice
|
||||
|
|
@ -70,7 +70,7 @@ by the Free Software Foundation.
|
|||
@author Brian Fox, Free Software Foundation
|
||||
@page
|
||||
@vskip 0pt plus 1filll
|
||||
Copyright @copyright{} 1991-1999 Free Software Foundation, Inc.
|
||||
Copyright @copyright{} 1991-2002 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to make and distribute verbatim copies of
|
||||
this manual provided the copyright notice and this permission notice
|
||||
|
|
@ -100,7 +100,7 @@ This is Edition @value{EDITION}, last updated @value{UPDATED},
|
|||
of @cite{The GNU Bash Reference Manual},
|
||||
for @code{Bash}, Version @value{VERSION}.
|
||||
|
||||
Copyright (C) 1991, 1993, 1996 Free Software Foundation, Inc.
|
||||
Copyright (C) 1991-2002 Free Software Foundation, Inc.
|
||||
|
||||
Bash contains features that appear in other popular shells, and some
|
||||
features that only appear in Bash. Some of the shells that Bash has
|
||||
|
|
@ -548,6 +548,8 @@ the eight-bit character whose value is the octal value @var{nnn}
|
|||
@item \x@var{HH}
|
||||
the eight-bit character whose value is the hexadecimal value @var{HH}
|
||||
(one or two hex digits)
|
||||
@item \c@var{x}
|
||||
a control-@var{x} character
|
||||
@end table
|
||||
|
||||
@noindent
|
||||
|
|
@ -688,6 +690,9 @@ Of these list operators, @samp{&&} and @samp{||}
|
|||
have equal precedence, followed by @samp{;} and @samp{&},
|
||||
which have equal precedence.
|
||||
|
||||
A sequence of one or more newlines may appear in a @code{list}
|
||||
to delimit commands, equivalent to a semicolon.
|
||||
|
||||
If a command is terminated by the control operator @samp{&},
|
||||
the shell executes the command asynchronously in a subshell.
|
||||
This is known as executing the command in the @var{background}.
|
||||
|
|
@ -972,7 +977,7 @@ True if both @var{expression1} and @var{expression2} are true.
|
|||
True if either @var{expression1} or @var{expression2} is true.
|
||||
@end table
|
||||
@noindent
|
||||
The @code{&&} and @code{||} commands do not execute @var{expression2} if the
|
||||
The @code{&&} and @code{||} operators do not evaluate @var{expression2} if the
|
||||
value of @var{expression1} is sufficient to determine the return
|
||||
value of the entire conditional expression.
|
||||
|
||||
|
|
@ -1778,10 +1783,12 @@ using the syntax
|
|||
following classes defined in the @sc{posix} 1003.2 standard:
|
||||
@example
|
||||
alnum alpha ascii blank cntrl digit graph lower
|
||||
print punct space upper xdigit
|
||||
print punct space upper word xdigit
|
||||
@end example
|
||||
@noindent
|
||||
A character class matches any character belonging to that class.
|
||||
The @code{word} character class matches letters, digits, and the character
|
||||
@samp{_}.
|
||||
|
||||
Within @samp{[} and @samp{]}, an @var{equivalence class} can be
|
||||
specified using the syntax @code{[=}@var{c}@code{=]}, which
|
||||
|
|
@ -1905,20 +1912,20 @@ is not specified.
|
|||
|
||||
The general format for redirecting input is:
|
||||
@example
|
||||
[n]<@var{word}
|
||||
[@var{n}]<@var{word}
|
||||
@end example
|
||||
|
||||
@subsection Redirecting Output
|
||||
Redirection of output causes the file whose name results from
|
||||
the expansion of @var{word}
|
||||
to be opened for writing on file descriptor @code{n},
|
||||
or the standard output (file descriptor 1) if @code{n}
|
||||
to be opened for writing on file descriptor @var{n},
|
||||
or the standard output (file descriptor 1) if @var{n}
|
||||
is not specified. If the file does not exist it is created;
|
||||
if it does exist it is truncated to zero size.
|
||||
|
||||
The general format for redirecting output is:
|
||||
@example
|
||||
[n]>[|]@var{word}
|
||||
[@var{n}]>[|]@var{word}
|
||||
@end example
|
||||
|
||||
If the redirection operator is @samp{>}, and the @code{noclobber}
|
||||
|
|
@ -1933,13 +1940,13 @@ is attempted even if the file named by @var{word} exists.
|
|||
Redirection of output in this fashion
|
||||
causes the file whose name results from
|
||||
the expansion of @var{word}
|
||||
to be opened for appending on file descriptor @code{n},
|
||||
or the standard output (file descriptor 1) if @code{n}
|
||||
to be opened for appending on file descriptor @var{n},
|
||||
or the standard output (file descriptor 1) if @var{n}
|
||||
is not specified. If the file does not exist it is created.
|
||||
|
||||
The general format for appending output is:
|
||||
@example
|
||||
[n]>>@var{word}
|
||||
[@var{n}]>>@var{word}
|
||||
@end example
|
||||
|
||||
@subsection Redirecting Standard Output and Standard Error
|
||||
|
|
@ -1973,7 +1980,7 @@ current source until a line containing only @var{word}
|
|||
the lines read up to that point are then used as the standard
|
||||
input for a command.
|
||||
|
||||
The format of here-documents is as follows:
|
||||
The format of here-documents is:
|
||||
@example
|
||||
<<[@minus{}]@var{word}
|
||||
@var{here-document}
|
||||
|
|
@ -1998,45 +2005,71 @@ line containing @var{delimiter}.
|
|||
This allows here-documents within shell scripts to be indented in a
|
||||
natural fashion.
|
||||
|
||||
@subsection Here Strings
|
||||
A variant of here documents, the format is:
|
||||
@example
|
||||
<<< @var{word}
|
||||
@end example
|
||||
|
||||
The @var{word} is expanded and supplied to the command on its standard
|
||||
input.
|
||||
|
||||
@subsection Duplicating File Descriptors
|
||||
The redirection operator
|
||||
@example
|
||||
[n]<&@var{word}
|
||||
[@var{n}]<&@var{word}
|
||||
@end example
|
||||
@noindent
|
||||
is used to duplicate input file descriptors.
|
||||
If @var{word}
|
||||
expands to one or more digits, the file descriptor denoted by @code{n}
|
||||
expands to one or more digits, the file descriptor denoted by @var{n}
|
||||
is made to be a copy of that file descriptor.
|
||||
If the digits in @var{word} do not specify a file descriptor open for
|
||||
input, a redirection error occurs.
|
||||
If @var{word}
|
||||
evaluates to @samp{-}, file descriptor @code{n} is closed. If
|
||||
@code{n} is not specified, the standard input (file descriptor 0) is used.
|
||||
evaluates to @samp{-}, file descriptor @var{n} is closed. If
|
||||
@var{n} is not specified, the standard input (file descriptor 0) is used.
|
||||
|
||||
The operator
|
||||
@example
|
||||
[n]>&@var{word}
|
||||
[@var{n}]>&@var{word}
|
||||
@end example
|
||||
@noindent
|
||||
is used similarly to duplicate output file descriptors. If
|
||||
@code{n}
|
||||
is not specified, the standard output (file descriptor 1) is used.
|
||||
@var{n} is not specified, the standard output (file descriptor 1) is used.
|
||||
If the digits in @var{word} do not specify a file descriptor open for
|
||||
output, a redirection error occurs.
|
||||
As a special case, if @code{n} is omitted, and @var{word} does not
|
||||
As a special case, if @var{n} is omitted, and @var{word} does not
|
||||
expand to one or more digits, the standard output and standard
|
||||
error are redirected as described previously.
|
||||
|
||||
@subsection Moving File Descriptors
|
||||
The redirection operator
|
||||
@example
|
||||
[@var{n}]<&@var{digit}-
|
||||
@end example
|
||||
@noindent
|
||||
moves the file descriptor @var{digit} to file descriptor @var{n},
|
||||
or the standard input (file descriptor 0) if @var{n} is not specified.
|
||||
@var{digit} is closed after being duplicated to @var{n}.
|
||||
|
||||
Similarly, the redirection operator
|
||||
@example
|
||||
[@var{n}]>&@var{digit}-
|
||||
@end example
|
||||
@noindent
|
||||
moves the file descriptor @var{digit} to file descriptor @var{n},
|
||||
or the standard output (file descriptor 1) if @var{n} is not specified.
|
||||
|
||||
@subsection Opening File Descriptors for Reading and Writing
|
||||
The redirection operator
|
||||
@example
|
||||
[n]<>@var{word}
|
||||
[@var{n}]<>@var{word}
|
||||
@end example
|
||||
@noindent
|
||||
causes the file whose name is the expansion of @var{word}
|
||||
to be opened for both reading and writing on file descriptor
|
||||
@code{n}, or on file descriptor 0 if @code{n}
|
||||
@var{n}, or on file descriptor 0 if @var{n}
|
||||
is not specified. If the file does not exist, it is created.
|
||||
|
||||
@node Executing Commands
|
||||
|
|
@ -2501,7 +2534,7 @@ The return status is zero unless @var{n} is not greater than or equal to 1.
|
|||
@item cd
|
||||
@btindex cd
|
||||
@example
|
||||
cd [-LP] [@var{directory}]
|
||||
cd [-L|-P] [@var{directory}]
|
||||
@end example
|
||||
Change the current working directory to @var{directory}. If @var{directory}
|
||||
is not given, the value of the @env{HOME} shell variable is used. If the
|
||||
|
|
@ -2637,7 +2670,7 @@ If @code{getopts} is silent, then a colon (@samp{:}) is placed in
|
|||
@item hash
|
||||
@btindex hash
|
||||
@example
|
||||
hash [-r] [-p @var{filename}] [-t] [@var{name}]
|
||||
hash [-'r] [-p @var{filename}] [-dt] [@var{name}]
|
||||
@end example
|
||||
Remember the full pathnames of commands specified as @var{name} arguments,
|
||||
so they need not be searched for on subsequent invocations.
|
||||
|
|
@ -2646,11 +2679,16 @@ The commands are found by searching through the directories listed in
|
|||
The @option{-p} option inhibits the path search, and @var{filename} is
|
||||
used as the location of @var{name}.
|
||||
The @option{-r} option causes the shell to forget all remembered locations.
|
||||
The @option{-d} option causes the shell to forget the remembered location
|
||||
of each @var{name}.
|
||||
If the @option{-t} option is supplied, the full pathname to which each
|
||||
@var{name} corresponds is printed. If multiple @var{name} arguments are
|
||||
supplied with @option{-t} the @var{name} is printed before the hashed
|
||||
full pathname.
|
||||
If no arguments are given, information about remembered commands is printed.
|
||||
The @option{-l} option causes output to be displayed in a format
|
||||
that may be reused as input.
|
||||
If no arguments are given, or if only @option{-l} is supplied,
|
||||
information about remembered commands is printed.
|
||||
The return status is zero unless a @var{name} is not found or an invalid
|
||||
option is supplied.
|
||||
|
||||
|
|
@ -2905,14 +2943,16 @@ bind [-m @var{keymap}] [-q @var{function}] [-u @var{function}] [-r @var{keyseq}]
|
|||
bind [-m @var{keymap}] -f @var{filename}
|
||||
bind [-m @var{keymap}] -x @var{keyseq:shell-command}
|
||||
bind [-m @var{keymap}] @var{keyseq:function-name}
|
||||
bind @var{readline-command}
|
||||
@end example
|
||||
|
||||
Display current Readline (@pxref{Command Line Editing})
|
||||
key and function bindings, or
|
||||
bind a key sequence to a Readline function or macro. The
|
||||
binding syntax accepted is identical to that of
|
||||
key and function bindings,
|
||||
bind a key sequence to a Readline function or macro,
|
||||
or set a Readline variable.
|
||||
Each non-option argument is a command as it would appear in a
|
||||
a Readline initialization file (@pxref{Readline Init File}),
|
||||
but each binding must be passed as a separate argument: e.g.,
|
||||
but each binding or command must be passed as a separate argument; e.g.,
|
||||
@samp{"\C-x\C-r":re-read-init-file}.
|
||||
Options, if supplied, have the following meanings:
|
||||
|
||||
|
|
@ -3019,7 +3059,7 @@ zero if @var{command} is found, and non-zero if not.
|
|||
@item declare
|
||||
@btindex declare
|
||||
@example
|
||||
declare [-afFrxi] [-p] [@var{name}[=@var{value}]]
|
||||
declare [-afFirtx] [-p] [@var{name}[=@var{value}]]
|
||||
@end example
|
||||
|
||||
Declare variables and give them attributes. If no @var{name}s
|
||||
|
|
@ -3049,6 +3089,11 @@ performed when the variable is assigned a value.
|
|||
Make @var{name}s readonly. These names cannot then be assigned values
|
||||
by subsequent assignment statements or unset.
|
||||
|
||||
@item -t
|
||||
Give each @var{name} the @code{trace} attribute.
|
||||
Traced functions inherit the @code{DEBUG} trap from the calling shell.
|
||||
The trace attribute has no special meaning for variables.
|
||||
|
||||
@item -x
|
||||
Mark each @var{name} for export to subsequent commands via
|
||||
the environment.
|
||||
|
|
@ -3106,9 +3151,12 @@ horizontal tab
|
|||
vertical tab
|
||||
@item \\
|
||||
backslash
|
||||
@item \0@var{nnn}
|
||||
the eight-bit character whose value is the octal value @var{nnn}
|
||||
(zero to three octal digits)
|
||||
@item \@var{nnn}
|
||||
the eight-bit character whose value is the octal value @var{nnn}
|
||||
(one to three digits)
|
||||
(one to three octal digits)
|
||||
@item \x@var{HH}
|
||||
the eight-bit character whose value is the hexadecimal value @var{HH}
|
||||
(one or two hex digits)
|
||||
|
|
@ -3218,13 +3266,14 @@ non-zero on failure.
|
|||
@item read
|
||||
@btindex read
|
||||
@example
|
||||
read [-ers] [-a @var{aname}] [-p @var{prompt}] [-t @var{timeout}] [-n @var{nchars}] [-d @var{delim}] [@var{name} @dots{}]
|
||||
read [-ers] [-a @var{aname}] [-d @var{delim}] [-n @var{nchars}] [-p @var{prompt}] [-t @var{timeout}] [-u @var{fd}] [@var{name} @dots{}]
|
||||
@end example
|
||||
One line is read from the standard input, and the first word
|
||||
One line is read from the standard input, or from the file descriptor
|
||||
@var{fd} supplied as an argument to the @option{-u} option, and the first word
|
||||
is assigned to the first @var{name}, the second word to the second @var{name},
|
||||
and so on, with leftover words and their intervening separators assigned
|
||||
to the last @var{name}.
|
||||
If there are fewer words read from the standard input than names,
|
||||
If there are fewer words read from the input stream than names,
|
||||
the remaining names are assigned empty values.
|
||||
The characters in the value of the @env{IFS} variable
|
||||
are used to split the line into words.
|
||||
|
|
@ -3232,8 +3281,9 @@ The backslash character @samp{\} may be used to remove any special
|
|||
meaning for the next character read and for line continuation.
|
||||
If no names are supplied, the line read is assigned to the
|
||||
variable @env{REPLY}.
|
||||
The return code is zero, unless end-of-file is encountered or @code{read}
|
||||
times out.
|
||||
The return code is zero, unless end-of-file is encountered, @code{read}
|
||||
times out, or an invalid file descriptor is supplied as the argument to
|
||||
@option{-u}.
|
||||
Options, if supplied, have the following meanings:
|
||||
|
||||
@table @code
|
||||
|
|
@ -3275,6 +3325,9 @@ input is not read within @var{timeout} seconds.
|
|||
This option has no effect if @code{read} is not reading input from the
|
||||
terminal or a pipe.
|
||||
|
||||
@item -u @var{fd}
|
||||
Read input from file descriptor @var{fd}.
|
||||
|
||||
@end table
|
||||
|
||||
@item shopt
|
||||
|
|
@ -3482,7 +3535,7 @@ A synonym for @code{.} (@pxref{Bourne Shell Builtins}).
|
|||
@item type
|
||||
@btindex type
|
||||
@example
|
||||
type [-atp] [@var{name} @dots{}]
|
||||
type [-afptP] [@var{name} @dots{}]
|
||||
@end example
|
||||
For each @var{name}, indicate how it would be interpreted if used as a
|
||||
command name.
|
||||
|
|
@ -3499,11 +3552,20 @@ If the @option{-p} option is used, @code{type} either returns the name
|
|||
of the disk file that would be executed, or nothing if @option{-t}
|
||||
would not return @samp{file}.
|
||||
|
||||
The @option{-P} option forces a path search for each @var{name}, even if
|
||||
@option{-t} would not return @samp{file}.
|
||||
|
||||
If a command is hashed, @option{-p} and @option{-P} print the hashed value,
|
||||
not necessarily the file that appears first in @code{$PATH}.
|
||||
|
||||
If the @option{-a} option is used, @code{type} returns all of the places
|
||||
that contain an executable named @var{file}.
|
||||
This includes aliases and functions, if and only if the @option{-p} option
|
||||
is not also used.
|
||||
|
||||
If the @option{-f} option is used, @code{type} does not attempt to find
|
||||
shell functions, as with the @code{command} builtin.
|
||||
|
||||
The return status is zero if any of the @var{names} are found, non-zero
|
||||
if none are found.
|
||||
|
||||
|
|
@ -4329,7 +4391,13 @@ If the value is null, no timing information is displayed.
|
|||
A trailing newline is added when the format string is displayed.
|
||||
|
||||
@item TMOUT
|
||||
If set to a value greater than zero, the value is interpreted as
|
||||
If set to a value greater than zero, @code{TMOUT} is treated as the
|
||||
default timeout for the @code{read} builtin (@pxref{Bash Builtins}).
|
||||
The @code{select} command (@pxref{Conditional Constructs}) terminates
|
||||
if input does not arrive after @code{TMOUT} seconds when input is coming
|
||||
from a terminal.
|
||||
|
||||
In an interative shell, the value is interpreted as
|
||||
the number of seconds to wait for input after issuing the primary
|
||||
prompt when the shell is interactive.
|
||||
Bash terminates after that number of seconds if input does
|
||||
|
|
@ -4374,8 +4442,7 @@ bash [long-opt] -s [-abefhkmnptuvxdBCDHP] [-o @var{option}] [-O @var{shopt_optio
|
|||
In addition to the single-character shell command-line options
|
||||
(@pxref{The Set Builtin}), there are several multi-character
|
||||
options that you can use. These options must appear on the command
|
||||
line before the single-character options in order for them
|
||||
to be recognized.
|
||||
line before the single-character options to be recognized.
|
||||
|
||||
@table @code
|
||||
@item --dump-po-strings
|
||||
|
|
@ -4396,15 +4463,7 @@ Execute commands from @var{filename} (instead of @file{~/.bashrc})
|
|||
in an interactive shell.
|
||||
|
||||
@item --login
|
||||
Make this shell act as if it had been directly invoked by login.
|
||||
When the shell is interactive, this is equivalent to starting a
|
||||
login shell with @samp{exec -l bash}.
|
||||
When the shell is not interactive, the login shell startup files will
|
||||
be executed.
|
||||
@samp{exec bash --login}
|
||||
will replace the current shell with a Bash login shell.
|
||||
@xref{Bash Startup Files}, for a description of the special behavior
|
||||
of a login shell.
|
||||
Equivalent to @option{-l}.
|
||||
|
||||
@item --noediting
|
||||
Do not use the @sc{gnu} Readline library (@pxref{Command Line Editing})
|
||||
|
|
@ -4453,6 +4512,17 @@ positional parameters, starting with @code{$0}.
|
|||
Force the shell to run interactively. Interactive shells are
|
||||
described in @ref{Interactive Shells}.
|
||||
|
||||
@item -l
|
||||
Make this shell act as if it had been directly invoked by login.
|
||||
When the shell is interactive, this is equivalent to starting a
|
||||
login shell with @samp{exec -l bash}.
|
||||
When the shell is not interactive, the login shell startup files will
|
||||
be executed.
|
||||
@samp{exec bash -l} or @samp{exec bash --login}
|
||||
will replace the current shell with a Bash login shell.
|
||||
@xref{Bash Startup Files}, for a description of the special behavior
|
||||
of a login shell.
|
||||
|
||||
@item -r
|
||||
Make the shell a restricted shell (@pxref{The Restricted Shell}).
|
||||
|
||||
|
|
@ -4860,14 +4930,15 @@ True if @var{file} exists and is a socket.
|
|||
True if @var{file} exists and has been modified since it was last read.
|
||||
|
||||
@item @var{file1} -nt @var{file2}
|
||||
True if @var{file1} is newer (according to
|
||||
modification date) than @var{file2}.
|
||||
True if @var{file1} is newer (according to modification date)
|
||||
than @var{file2}, or if @var{file1} exists and @var{file2} does not.
|
||||
|
||||
@item @var{file1} -ot @var{file2}
|
||||
True if @var{file1} is older than @var{file2}.
|
||||
True if @var{file1} is older than @var{file2},
|
||||
or if @var{file2} exists and @var{file1} does not.
|
||||
|
||||
@item @var{file1} -ef @var{file2}
|
||||
True if @var{file1} and @var{file2} have the same device and
|
||||
True if @var{file1} and @var{file2} refer to the same device and
|
||||
inode numbers.
|
||||
|
||||
@item -o @var{optname}
|
||||
|
|
@ -4884,7 +4955,7 @@ True if the length of @var{string} is non-zero.
|
|||
|
||||
@item @var{string1} == @var{string2}
|
||||
True if the strings are equal.
|
||||
@samp{=} may be used in place of @samp{==}.
|
||||
@samp{=} may be used in place of @samp{==} for strict @sc{posix} compliance.
|
||||
|
||||
@item @var{string1} != @var{string2}
|
||||
True if the strings are not equal.
|
||||
|
|
@ -4919,7 +4990,7 @@ may be positive or negative integers.
|
|||
The shell allows arithmetic expressions to be evaluated, as one of
|
||||
the shell expansions or by the @code{let} builtin.
|
||||
|
||||
Evaluation is done in long integers with no check for overflow,
|
||||
Evaluation is done in fixed-width integers with no check for overflow,
|
||||
though division by 0 is trapped and flagged as an error.
|
||||
The operators and their precedence and associativity are the same
|
||||
as in the C language.
|
||||
|
|
@ -5277,6 +5348,10 @@ can appear in the prompt variables:
|
|||
A bell character.
|
||||
@item \d
|
||||
The date, in "Weekday Month Date" format (e.g., "Tue May 26").
|
||||
@item \D@{@var{format}@}
|
||||
The @var{format} is passed to @code{strftime}(3) and the result is inserted
|
||||
into the prompt string; an empty @var{format} results in a locale-specific
|
||||
time representation. The braces are required.
|
||||
@item \e
|
||||
An escape character.
|
||||
@item \h
|
||||
|
|
@ -5347,11 +5422,14 @@ expansion, and quote removal, subject to the value of the
|
|||
|
||||
If Bash is started with the name @code{rbash}, or the
|
||||
@option{--restricted}
|
||||
or
|
||||
@option{-r}
|
||||
option is supplied at invocation, the shell becomes restricted.
|
||||
A restricted shell is used to
|
||||
set up an environment more controlled than the standard shell.
|
||||
A restricted shell behaves identically to @code{bash}
|
||||
with the exception that the following are disallowed:
|
||||
with the exception that the following are disallowed or not performed:
|
||||
|
||||
@itemize @bullet
|
||||
@item
|
||||
Changing directories with the @code{cd} builtin.
|
||||
|
|
@ -5379,11 +5457,19 @@ Using the @code{exec} builtin to replace the shell with another command.
|
|||
Adding or deleting builtin commands with the
|
||||
@option{-f} and @option{-d} options to the @code{enable} builtin.
|
||||
@item
|
||||
Using the @code{enable} builtin command to enable disabled shell builtins.
|
||||
@item
|
||||
Specifying the @option{-p} option to the @code{command} builtin.
|
||||
@item
|
||||
Turning off restricted mode with @samp{set +r} or @samp{set +o restricted}.
|
||||
@end itemize
|
||||
|
||||
These restrictions are enforced after any startup files are read.
|
||||
|
||||
When a command that is found to be a shell script is executed
|
||||
(@pxref{Shell Scripts}), @code{rbash} turns off any restrictions in
|
||||
the shell spawned to execute the script.
|
||||
|
||||
@node Bash POSIX Mode
|
||||
@section Bash POSIX Mode
|
||||
@cindex POSIX Mode
|
||||
|
|
@ -5393,6 +5479,9 @@ Starting Bash with the @option{--posix} command-line option or executing
|
|||
closely to the @sc{posix} 1003.2 standard by changing the behavior to
|
||||
match that specified by @sc{posix} in areas where the Bash default differs.
|
||||
|
||||
When invoked as @code{sh}, Bash enters @sc{posix} mode after reading the
|
||||
startup files.
|
||||
|
||||
The following list is what's changed when `@sc{posix} mode' is in effect:
|
||||
|
||||
@enumerate
|
||||
|
|
@ -5538,6 +5627,12 @@ shell function names and definitions.
|
|||
When the @code{set} builtin is invoked without options, it displays
|
||||
variable values without quotes, unless they contain shell metacharacters,
|
||||
even if the result contains nonprinting characters.
|
||||
|
||||
@item
|
||||
When the @code{cd} builtin is invoked in @var{logical} mode, and the pathname
|
||||
constructed from @code{$PWD} and the directory name supplied as an argument
|
||||
does not refer to an existing directory, @code{cd} will fail instead of
|
||||
falling back to @var{physical} mode.
|
||||
@end enumerate
|
||||
|
||||
There is other @sc{posix} 1003.2 behavior that Bash does not implement.
|
||||
|
|
@ -6129,7 +6224,7 @@ A synonym for @code{--with-bash-malloc}.
|
|||
@item --with-installed-readline[=@var{PREFIX}]
|
||||
Define this to make Bash link with a locally-installed version of Readline
|
||||
rather than the version in @file{lib/readline}. This works only with
|
||||
Readline 4.2 and later versions. If @var{PREFIX} is @code{yes} or not
|
||||
Readline 4.3 and later versions. If @var{PREFIX} is @code{yes} or not
|
||||
supplied, @code{configure} uses the values of the make variables
|
||||
@code{includedir} and @code{libdir}, which are subdirectories of @code{prefix}
|
||||
by default, to find the installed version of Readline if it is not in
|
||||
|
|
@ -6158,7 +6253,8 @@ compiled and linked, rather than changing run-time features.
|
|||
@item --enable-largefile
|
||||
Enable support for @uref{http://www.sas.com/standards/large_file/x_open.20Mar96.html,
|
||||
large files} if the operating system requires special compiler options
|
||||
to build programs which can access large files.
|
||||
to build programs which can access large files. This is enabled by
|
||||
default, if the operating system provides large file support.
|
||||
|
||||
@item --enable-profiling
|
||||
This builds a Bash binary that produces profiling information to be
|
||||
|
|
@ -6628,7 +6724,8 @@ The @code{trap} builtin (@pxref{Bourne Shell Builtins}) allows a
|
|||
@code{DEBUG} pseudo-signal specification, similar to @code{EXIT}.
|
||||
Commands specified with a @code{DEBUG} trap are executed after every
|
||||
simple command.
|
||||
The @code{DEBUG} trap is not inherited by shell functions.
|
||||
The @code{DEBUG} trap is not inherited by shell functions unless the
|
||||
function has been given the @code{trace} attribute.
|
||||
|
||||
The @code{trap} builtin (@pxref{Bourne Shell Builtins}) allows an
|
||||
@code{ERR} pseudo-signal specification, similar to @code{EXIT} and @code{DEBUG}.
|
||||
|
|
|
|||
|
|
@ -1,14 +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 "2001 October 29" "GNU Bash-2.05a"
|
||||
.TH BASH_BUILTINS 1 "2001 November 27" "GNU Bash-2.05a"
|
||||
.SH NAME
|
||||
bash, :, ., [, alias, bg, bind, break, builtin, case, cd, command, compgen,
|
||||
complete,
|
||||
bash, :, ., [, alias, bg, bind, break, builtin, cd, command, compgen, complete,
|
||||
continue, declare, dirs, disown, echo, enable, eval, exec, exit,
|
||||
export, fc, fg, for, getopts, hash, help, history, if, jobs, kill,
|
||||
export, fc, fg, getopts, hash, help, history, jobs, kill,
|
||||
let, local, logout, popd, printf, pushd, pwd, read, readonly, return, set,
|
||||
shift, shopt, source, suspend, test, times, trap, type, typeset,
|
||||
ulimit, umask, unalias, unset, until, wait, while \- bash built-in commands, see \fBbash\fR(1)
|
||||
ulimit, umask, unalias, unset, wait \- bash built-in commands, see \fBbash\fR(1)
|
||||
.SH BASH BUILTIN COMMANDS
|
||||
.nr zZ 1
|
||||
.so bash.1
|
||||
|
|
|
|||
247
error.c
247
error.c
|
|
@ -29,10 +29,8 @@
|
|||
#if defined (PREFER_STDARG)
|
||||
# include <stdarg.h>
|
||||
#else
|
||||
# if defined (PREFER_VARARGS)
|
||||
# include <varargs.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
|
@ -53,7 +51,9 @@ extern int errno;
|
|||
# include "bashhist.h"
|
||||
#endif
|
||||
|
||||
extern int interactive_shell, interactive;
|
||||
extern int executing_line_number __P((void));
|
||||
|
||||
extern int interactive_shell, interactive, startup_state;
|
||||
extern char *dollar_vars[];
|
||||
extern char *shell_name;
|
||||
#if defined (JOB_CONTROL)
|
||||
|
|
@ -61,6 +61,8 @@ extern pid_t shell_pgrp;
|
|||
extern int give_terminal_to __P((pid_t, int));
|
||||
#endif /* JOB_CONTROL */
|
||||
|
||||
static void error_prolog __P((int));
|
||||
|
||||
/* The current maintainer of the shell. You change this in the
|
||||
Makefile. */
|
||||
#if !defined (MAINTAINER)
|
||||
|
|
@ -69,6 +71,22 @@ extern int give_terminal_to __P((pid_t, int));
|
|||
|
||||
char *the_current_maintainer = MAINTAINER;
|
||||
|
||||
static void
|
||||
error_prolog (print_lineno)
|
||||
int print_lineno;
|
||||
{
|
||||
int line;
|
||||
|
||||
fprintf (stderr, "%s: ", get_name_for_error ());
|
||||
|
||||
if (print_lineno && interactive_shell == 0)
|
||||
{
|
||||
line = executing_line_number ();
|
||||
if (line > 0)
|
||||
fprintf (stderr, "line %d: ", line);
|
||||
}
|
||||
}
|
||||
|
||||
/* Return the name of the shell or the shell script for error reporting. */
|
||||
char *
|
||||
get_name_for_error ()
|
||||
|
|
@ -100,120 +118,6 @@ file_error (filename)
|
|||
report_error ("%s: %s", filename, strerror (errno));
|
||||
}
|
||||
|
||||
#if !defined (USE_VARARGS)
|
||||
void
|
||||
programming_error (reason, arg1, arg2, arg3, arg4, arg5)
|
||||
char *reason;
|
||||
{
|
||||
char *h;
|
||||
|
||||
#if defined (JOB_CONTROL)
|
||||
give_terminal_to (shell_pgrp);
|
||||
#endif /* JOB_CONTROL */
|
||||
|
||||
report_error (reason, arg1, arg2);
|
||||
|
||||
#if defined (HISTORY)
|
||||
if (remember_on_history)
|
||||
{
|
||||
h = last_history_line ();
|
||||
fprintf (stderr, "last command: %s\n", h ? h : "(null)");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
fprintf (stderr, "Report this to %s\n", the_current_maintainer);
|
||||
#endif
|
||||
|
||||
fprintf (stderr, "Stopping myself...");
|
||||
fflush (stderr);
|
||||
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
report_error (format, arg1, arg2, arg3, arg4, arg5)
|
||||
char *format;
|
||||
{
|
||||
fprintf (stderr, "%s: ", get_name_for_error ());
|
||||
|
||||
fprintf (stderr, format, arg1, arg2, arg3, arg4, arg5);
|
||||
fprintf (stderr, "\n");
|
||||
if (exit_immediately_on_error)
|
||||
exit (1);
|
||||
}
|
||||
|
||||
void
|
||||
parser_error (lineno, format, arg1, arg2, arg3, arg4, arg5);
|
||||
int lineno;
|
||||
char *format;
|
||||
va_dcl
|
||||
{
|
||||
char *ename, *iname;
|
||||
|
||||
ename = get_name_for_error ();
|
||||
iname = bash_input.name ? bash_input.name : "stdin";
|
||||
|
||||
if (interactive)
|
||||
fprintf (stderr, "%s: ", ename);
|
||||
else if (interactive_shell)
|
||||
fprintf (stderr, "%s: %s: line %d: ", ename, iname, lineno);
|
||||
else if (STREQ (ename, iname))
|
||||
fprintf (stderr, "%s: line %d: ", ename, lineno);
|
||||
else
|
||||
fprintf (stderr, "%s: %s: line %d: ", ename, iname, lineno);
|
||||
|
||||
fprintf (stderr, format, arg1, arg2, arg3, arg4, arg5);
|
||||
fprintf (stderr, "\n");
|
||||
|
||||
if (exit_immediately_on_error)
|
||||
exit (2);
|
||||
}
|
||||
|
||||
void
|
||||
fatal_error (format, arg1, arg2, arg3, arg4, arg5)
|
||||
char *format;
|
||||
{
|
||||
fprintf (stderr, "%s: ", get_name_for_error ());
|
||||
|
||||
fprintf (stderr, format, arg1, arg2, arg3, arg4, arg5);
|
||||
fprintf (stderr, "\n");
|
||||
|
||||
exit (2);
|
||||
}
|
||||
|
||||
void
|
||||
internal_error (format, arg1, arg2, arg3, arg4, arg5)
|
||||
char *format;
|
||||
{
|
||||
fprintf (stderr, "%s: ", get_name_for_error ());
|
||||
|
||||
fprintf (stderr, format, arg1, arg2, arg3, arg4, arg5);
|
||||
fprintf (stderr, "\n");
|
||||
}
|
||||
|
||||
void
|
||||
internal_warning (format, arg1, arg2, arg3, arg4, arg5)
|
||||
char *format;
|
||||
{
|
||||
fprintf (stderr, "%s: warning: ", get_name_for_error ());
|
||||
|
||||
fprintf (stderr, format, arg1, arg2, arg3, arg4, arg5);
|
||||
fprintf (stderr, "\n");
|
||||
}
|
||||
|
||||
void
|
||||
sys_error (format, arg1, arg2, arg3, arg4, arg5)
|
||||
char *format;
|
||||
{
|
||||
fprintf (stderr, "%s: ", get_name_for_error ());
|
||||
|
||||
fprintf (stderr, format, arg1, arg2, arg3, arg4, arg5);
|
||||
fprintf (stderr, ": %s\n", strerror (errno));
|
||||
}
|
||||
|
||||
#else /* We have VARARGS support, so use it. */
|
||||
|
||||
void
|
||||
#if defined (PREFER_STDARG)
|
||||
programming_error (const char *format, ...)
|
||||
|
|
@ -230,11 +134,7 @@ programming_error (format, va_alist)
|
|||
give_terminal_to (shell_pgrp, 0);
|
||||
#endif /* JOB_CONTROL */
|
||||
|
||||
#if defined (PREFER_STDARG)
|
||||
va_start (args, format);
|
||||
#else
|
||||
va_start (args);
|
||||
#endif
|
||||
SH_VA_START (args, format);
|
||||
|
||||
vfprintf (stderr, format, args);
|
||||
fprintf (stderr, "\n");
|
||||
|
|
@ -258,6 +158,10 @@ programming_error (format, va_alist)
|
|||
abort ();
|
||||
}
|
||||
|
||||
/* Print an error message and, if `set -e' has been executed, exit the
|
||||
shell. Used in this file by file_error and programming_error. Used
|
||||
outside this file mostly to report substitution and expansion errors,
|
||||
and for bad invocation options. */
|
||||
void
|
||||
#if defined (PREFER_STDARG)
|
||||
report_error (const char *format, ...)
|
||||
|
|
@ -269,20 +173,16 @@ report_error (format, va_alist)
|
|||
{
|
||||
va_list args;
|
||||
|
||||
fprintf (stderr, "%s: ", get_name_for_error ());
|
||||
error_prolog (1);
|
||||
|
||||
#if defined (PREFER_STDARG)
|
||||
va_start (args, format);
|
||||
#else
|
||||
va_start (args);
|
||||
#endif
|
||||
SH_VA_START (args, format);
|
||||
|
||||
vfprintf (stderr, format, args);
|
||||
fprintf (stderr, "\n");
|
||||
|
||||
va_end (args);
|
||||
if (exit_immediately_on_error)
|
||||
exit (1);
|
||||
sh_exit (1);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -296,19 +196,15 @@ fatal_error (format, va_alist)
|
|||
{
|
||||
va_list args;
|
||||
|
||||
fprintf (stderr, "%s: ", get_name_for_error ());
|
||||
error_prolog (0);
|
||||
|
||||
#if defined (PREFER_STDARG)
|
||||
va_start (args, format);
|
||||
#else
|
||||
va_start (args);
|
||||
#endif
|
||||
SH_VA_START (args, format);
|
||||
|
||||
vfprintf (stderr, format, args);
|
||||
fprintf (stderr, "\n");
|
||||
|
||||
va_end (args);
|
||||
exit (2);
|
||||
sh_exit (2);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -322,13 +218,9 @@ internal_error (format, va_alist)
|
|||
{
|
||||
va_list args;
|
||||
|
||||
fprintf (stderr, "%s: ", get_name_for_error ());
|
||||
error_prolog (1);
|
||||
|
||||
#if defined (PREFER_STDARG)
|
||||
va_start (args, format);
|
||||
#else
|
||||
va_start (args);
|
||||
#endif
|
||||
SH_VA_START (args, format);
|
||||
|
||||
vfprintf (stderr, format, args);
|
||||
fprintf (stderr, "\n");
|
||||
|
|
@ -349,11 +241,7 @@ internal_warning (format, va_alist)
|
|||
|
||||
fprintf (stderr, "%s: warning: ", get_name_for_error ());
|
||||
|
||||
#if defined (PREFER_STDARG)
|
||||
va_start (args, format);
|
||||
#else
|
||||
va_start (args);
|
||||
#endif
|
||||
SH_VA_START (args, format);
|
||||
|
||||
vfprintf (stderr, format, args);
|
||||
fprintf (stderr, "\n");
|
||||
|
|
@ -370,18 +258,16 @@ sys_error (format, va_alist)
|
|||
va_dcl
|
||||
#endif
|
||||
{
|
||||
int e;
|
||||
va_list args;
|
||||
|
||||
fprintf (stderr, "%s: ", get_name_for_error ());
|
||||
e = errno;
|
||||
error_prolog (0);
|
||||
|
||||
#if defined (PREFER_STDARG)
|
||||
va_start (args, format);
|
||||
#else
|
||||
va_start (args);
|
||||
#endif
|
||||
SH_VA_START (args, format);
|
||||
|
||||
vfprintf (stderr, format, args);
|
||||
fprintf (stderr, ": %s\n", strerror (errno));
|
||||
fprintf (stderr, ": %s\n", strerror (e));
|
||||
|
||||
va_end (args);
|
||||
}
|
||||
|
|
@ -408,7 +294,7 @@ parser_error (lineno, format, va_alist)
|
|||
char *ename, *iname;
|
||||
|
||||
ename = get_name_for_error ();
|
||||
iname = bash_input.name ? bash_input.name : "stdin";
|
||||
iname = yy_input_name ();
|
||||
|
||||
if (interactive)
|
||||
fprintf (stderr, "%s: ", ename);
|
||||
|
|
@ -419,11 +305,7 @@ parser_error (lineno, format, va_alist)
|
|||
else
|
||||
fprintf (stderr, "%s: %s: line %d: ", ename, iname, lineno);
|
||||
|
||||
#if defined (PREFER_STDARG)
|
||||
va_start (args, format);
|
||||
#else
|
||||
va_start (args);
|
||||
#endif
|
||||
SH_VA_START (args, format);
|
||||
|
||||
vfprintf (stderr, format, args);
|
||||
fprintf (stderr, "\n");
|
||||
|
|
@ -431,7 +313,7 @@ parser_error (lineno, format, va_alist)
|
|||
va_end (args);
|
||||
|
||||
if (exit_immediately_on_error)
|
||||
exit (2);
|
||||
sh_exit (2);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
|
@ -448,11 +330,7 @@ itrace (format, va_alist)
|
|||
|
||||
fprintf(stderr, "TRACE: pid %ld: ", (long)getpid());
|
||||
|
||||
#if defined (PREFER_STDARG)
|
||||
va_start (args, format);
|
||||
#else
|
||||
va_start (args);
|
||||
#endif
|
||||
SH_VA_START (args, format);
|
||||
|
||||
vfprintf (stderr, format, args);
|
||||
fprintf (stderr, "\n");
|
||||
|
|
@ -486,11 +364,7 @@ trace (format, va_alist)
|
|||
|
||||
fprintf(tracefp, "TRACE: pid %ld: ", (long)getpid());
|
||||
|
||||
#if defined (PREFER_STDARG)
|
||||
va_start (args, format);
|
||||
#else
|
||||
va_start (args);
|
||||
#endif
|
||||
SH_VA_START (args, format);
|
||||
|
||||
vfprintf (tracefp, format, args);
|
||||
fprintf (tracefp, "\n");
|
||||
|
|
@ -500,9 +374,15 @@ trace (format, va_alist)
|
|||
fflush(tracefp);
|
||||
}
|
||||
|
||||
#endif /* USE_VARARGS */
|
||||
#endif /* DEBUG */
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Common error reporting */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
|
||||
static char *cmd_error_table[] = {
|
||||
"unknown command error", /* CMDERR_DEFAULT */
|
||||
"bad command type", /* CMDERR_BADTYPE */
|
||||
|
|
@ -531,3 +411,26 @@ command_errstr (code)
|
|||
|
||||
return (cmd_error_table[code]);
|
||||
}
|
||||
|
||||
#ifdef ARRAY_VARS
|
||||
void
|
||||
err_badarraysub (s)
|
||||
const char *s;
|
||||
{
|
||||
report_error ("%s: bad array subscript", s);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
err_unboundvar (s)
|
||||
const char *s;
|
||||
{
|
||||
report_error ("%s: unbound variable", s);
|
||||
}
|
||||
|
||||
void
|
||||
err_readonly (s)
|
||||
const char *s;
|
||||
{
|
||||
report_error ("%s: readonly variable", s);
|
||||
}
|
||||
|
|
|
|||
11
error.h
11
error.h
|
|
@ -50,12 +50,19 @@ extern void internal_error __P((const char *, ...)) __attribute__((__format__ (
|
|||
/* Report an internal warning. */
|
||||
extern void internal_warning __P((const char *, ...)) __attribute__((__format__ (printf, 1, 2)));
|
||||
|
||||
/* Debugging function, not enabled in released version. */
|
||||
extern void itrace __P((const char *, ...)) __attribute__ ((__format__ (printf, 1, 2)));
|
||||
|
||||
/* Report an error having to do with command parsing or execution. */
|
||||
extern void command_error __P((const char *, int, int, int));
|
||||
|
||||
extern char *command_errstr __P((int));
|
||||
|
||||
/* Debugging function, not enabled in released version. */
|
||||
extern void itrace __P((const char *, ...)) __attribute__ ((__format__ (printf, 1, 2)));
|
||||
/* Specific errror message functions that eventually call report_error or
|
||||
internal_error. */
|
||||
|
||||
extern void err_badarraysub __P((const char *));
|
||||
extern void err_unboundvar __P((const char *));
|
||||
extern void err_readonly __P((const char *));
|
||||
|
||||
#endif /* !_ERROR_H_ */
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue