Imported from ../bash-2.05.tar.gz.

This commit is contained in:
Jari Aalto 2001-04-06 19:14:31 +00:00
commit 28ef6c316f
251 changed files with 22319 additions and 12413 deletions

558
CHANGES
View file

@ -1,3 +1,559 @@
This document details the changes between this version, bash-2.05-release,
and the previous version, bash-2.05-beta2.
1. Changes to Bash
a. Make sure we note that the first line of a multi-line command was not
saved in the history if the tests for HISTCONTROL succeed, but the
HISTIGNORE check fails.
b. Fixed a bug in the pattern matching code that caused `[' to be treated
as a special character inside a `[...]' bracket expression.
c. Fixed a bug in the pattern matching code that caused `]' to terminate
a bracket expression even if it was the first character after the `['
(or a leading `!' or `^').
d. Made a small change to report a more user-friendly error message if
execve(2) fails because of an error with the interpreter in a script
with a leading `#! interpreter'.
e. If the OS does not support an exec(2) magic number of `#!', make sure we
have a non-null interpreter name before attempting to execute it.
f. Fixed a bug that caused the shell process to end up in a different
process group than the controlling terminal if a job-control shell was
run with `exec' in the startup files.
g. When started in POSIX mode, either by `bash --posix', `bash -o posix', or
`sh', $SHELLOPTS includes `posix' and POSIXLY_CORRECT is set.
h. Fixed a problem that caused the `\W' prompt string escape sequence to
expand to nothing when $PWD was `//'.
i. The `bashbug' shell script no longer uses $(...) command substitution.
j. When `set' is invoked without options in POSIX mode, it no longer prints
the names and definitions of shell functions.
2. Changes to Readline
a. rl_set_paren_blink_timeout() is now documented.
b. Corrected history.3 man page: `$' is not in the default value of
history_word_delimiters.
c. If a hook function assigned to rl_event_hook sets rl_done to a non-zero
value, rl_read_key() now immediately returns '\n' (which is assumed to
be bound to accept-line).
3. New Features in Bash
a. The `>&word' redirection now works in POSIX mode as it does by default,
since POSIX.2 leaves it unspecified.
------------------------------------------------------------------------------
This document details the changes between this version, bash-2.05-beta2,
and the previous version, bash-2.05-beta1.
1. Changes to Bash
a. Fixed a bug in the arithmetic evaluation code so that a^=b is supported.
b. Fixed startup so posixly_correct is retained across subshells begun to
execute scripts without a leading `#!'.
c. Fixed a bug that caused $(< file) to not work in a (...) subshell.
d. Added config support for Linux running on the IBM S390.
e. Fixed a bug that caused bash to get its input pointer out of sync when
reading commands through a pipe and running a command with standard
input redirected from a file.
f. Made a change so that command completion now makes about half as many
stat(2) calls when searching the $PATH.
g. Fixed a bug that caused variable assignments preceding `return' to not
be propagated to the shell environment in POSIX mode.
h. Fixed a bug with ${parameter[:]?word} -- tilde expansion was not performed
on `word'.
i. In POSIX mode, `break' and `continue' do not complain and return success
if called when the shell is not executing a loop.
j. Fixed `bash -o posix' to work the same as `bash --posix'.
k. Fixed a bug where variable assignments preceding `eval' or `source/.'
would not show up in the environment exported to subshells run by the
commands.
l. In POSIX mode, shells started to execute command substitutions inherit
the value of the `-e' option from their parent shell.
m. In POSIX mode, aliases are expanded even in non-interactive shells.
n. Changed some of the job control messages to display the text required by
POSIX.2 when the shell is in POSIX mode.
o. Fixed a bug in `test' that caused it to occasionally return incorrect
results when non-numeric arguments were supplied to `-t'.
2. Changes to Readline
a. Some changes were made to avoid gcc warnings with -Wall.
b. rl_get_keymap_by_name now finds keymaps case-insensitively, so
`set keymap EMACS' works.
c. The history file writing and truncation functions now return a useful
status on error.
d. Fixed a bug that could cause applications to dereference a NULL pointer
if a NULL second argument was passed to history_expand().
3. New Features in Bash
a. doc/readline.3 has been moved to the readline distribution.
4. New Features in Readline
a. New function, rl_get_screen_size (int *rows, int *columns), returns
readline's idea of the screen dimensions.
b. The timeout in rl_gather_tyi (readline keyboard input polling function)
is now settable via a function (rl_set_keyboard_input_timeout()).
c. Renamed the max_input_history variable to history_max_entries; the old
variable is maintained for backwards compatibility.
d. The list of characters that separate words for the history tokenizer is
now settable with a variable: history_word_delimiters. The default
value is as before.
------------------------------------------------------------------------------
This document details the changes between this version, bash-2.05-beta1,
and the previous version, bash-2.05-alpha1.
1. Changes to Bash
a. Changes to allow shared library and object building on the GNU Hurd.
b. Fixes to the way exported functions are placed into the environment and
cached.
c. The globbing library once again respects locales when processing ranges
in bracket expressions while doing pattern matching.
d. System-specific configuration changes for: Tru 64, Interix
e. Bashbug now uses /usr/bin/editor as one of the editing alternatives, and
will use mktemp(1) or tempfile(1), if present, for temporary file creation.
f. Bash no longer performs a binary file check on a script argument that's
really a tty (like /dev/fd/0 or /dev/stdin).
g. Fixed a bug in the execution of shell scripts that caused the effects of
$BASH_ENV to be undone in some cases.
h. Fixed several bugs that made `bash [-i] /dev/stdin' not work correctly.
i. Several changes to the job control code to avoid some signal state
manipulation.
j. The Bash malloc no longer blocks signals as often, which should make it
faster.
k. Fixed a parsing bug that did not allow backslash to escape a single quote
inside a $'...' construct.
l. Fixed a bug that caused things like ${var:=$'value'} to be parsed
incorrectly. This showed up in newer versions of autoconf.
m. Fixed a bug in the bash-specific readline initialization that caused
key bindings to bash-specific function names appearing in .inputrc to
not be honored.
n. Bash now sets the file descriptor it uses to save the file descriptor
opened on a shell script to close on exec.
o. Fixed a bug in the prompt string decoding that caused it to misbehave
when presented an octal sequence of fewer than three characters.
p. Fixed the `test' builtin to return an error if `[' is supplied a single
argument that is not `]'.
q. Fixed a bug that caused subshells started to run executable shell scripts
without a leading `#!' to incorrectly inherit an argument list preceding
a shell builtin (like such a script called from a script sourced with `.',
where there were variable assignments preceding the `.' command)
r. Fixed a bug that caused changes to variables supplied in an assignment
statement preceding a shell builtin to not be honored (like a script
run with `.').
s. HOSTTYPE, OSTYPE, and MACHTYPE are set only if they do not have values
when the shell is started.
t. Fixed a bug that caused SIGINT to kill shell scripts after the script
called `wait'.
u. The `fc' builtin now tries to create its temporary files in the directory
named by $TMPDIR.
v. Bash no longer calls any Readline functions or uses any Readline variables
not declared in readline.h.
w. Fixed a bug that caused some substitutions involving $@ to not be split
correctly, especially expansions of the form ${paramterOPword}.
x. SSH2_CLIENT is now treated like SSH_CLIENT and not auto-exported if it
appears in the initial environment.
y. Fixed a couple of problems with shell scripts without a leading `#!'
being executed out of shell functions that could cause core dumps if
such a script attempted to execute `return'.
z. Fixed a problem with the `-nt' and `-ot' binary operators for the
`test/[' builtin and the `[[' conditional command that caused wrong
return values if one of the file arguments did not exist.
aa. Fixed a bug that caused non-interactive shells which had previously
executed `shopt -s expand_aliases' to fail to expand aliases in a
command like `(command) &'.
2. Changes to Readline
a. Changes to make most (but not yet all -- there is still crlf()) of the
exported readline functions declared in readline.h have an rl_ prefix.
b. More `const' changes in function arguments, mostly for completion
functions.
c. Fixed a bug in rl_forward that could cause the point to be set to before
the beginning of the line in vi mode.
d. Fixed a bug in the callback read-char interface to make it work when a
readline function pushes some input onto the input stream with
rl_execute_next (like the incremental search functions).
e. Fixed a file descriptor leak in the history file manipulation code that
was tripped when attempting to truncate a non-regular file (like
/dev/null).
f. Some existing variables are now documented and part of the public
interface (declared in readline.h): rl_explict_arg, rl_numeric_arg,
rl_editing_mode, rl_last_func.
g. Renamed rltty_set_default_bindings to rl_tty_set_default_bindings and
crlf to rl_crlf, so there are no public functions declared in readline.h
without an `rl_' prefix. The old functions still exist for backwards
compatibility.
3. New Features in Bash
a. A new loadable builtin, realpath, which canonicalizes and expands symlinks
in pathname arguments.
b. When `set' is called without options, it prints function defintions in a
way that allows them to be reused as input. This affects `declare' and
`declare -p' as well.
4. New Features in Readline
a. New application-callable function rl_set_prompt(const char *prompt):
expands its prompt string argument and sets rl_prompt to the result.
b. New application-callable function rl_set_screen_size(int rows, int cols):
public method for applications to set readline's idea of the screen
dimensions.
c. The history example program (examples/histexamp.c) is now built as one
of the examples.
------------------------------------------------------------------------------
This document details the changes between this version, bash-2.05-alpha1,
and the previous version, bash-2.04-release.
1. Changes to Bash
a. A fix was made to allow newlines in compond array assignments.
b. configure now checks for real-time signals with unusable values.
c. Interactive shells no longer exit if a substitution fails because of an
unset variable within a sourced file.
d. Fixed a problem with incorrect matching of extended glob patterns when
doing pattern substitution.
e. `{' is now quoted by the completion code when it appears in a filename.
f. Fixed an error in pattern matching that caused the matcher to not
correctly skip the rest of a bracket expression after a character
matched.
g. Fixed a bug in the IFS word splitting code to make a non-whitespace IFS
character preceded by IFS whitespace part of the current delimiter rather
than generating a separate field.
h. The {!prefix@} expansion now generates separate words, analogous to $@,
when double-quoted.
i. Command substitution now ignores NUL bytes in the command output, and the
parser ignores them on input.
j. A fix was made to the job control code to prevent hanging processes when
the shell thinks background processes are running but the kernel returns
-1/ECHILD from waitpid().
k. `pwd' now prints an error message if the write fails when displaying the
current directory.
l. When in POSIX mode, the shell prints trap dispostions without a leading
`SIG' in the signal specification.
m. Fixed a parser bug that caused the current command's line count to be
messed up by a compound array assignment.
n. Fixed a bug in the unwind-protect code that caused bad behavior on machines
where ints and pointers are not the same size.
o. System-specific configure changes for: MacOS X.
p. Changes for Cygwin to translate \r\n and \r to \n and to set file
descriptors used for reading input to text mode in various places.
q. Fixed a bug that caused `!' to occasionally not be honored when in
a (...) subshell.
r. Bash no longer assumes that getcwd() will return any useful error message
in the buffer passed as an argument if the call fails.
s. The `source', `.', and `fc' builtins no longer check whether a file is
binary before reading commands from it.
t. Subshells no longer turn off job control when they exit, since that
sometimes resulted in the terminal being reset to the wrong process
group.
u. The history code no longer tries to save the second and subsequent lines
of a multi-line command if the first line was not saved.
v. The history saving code now does a better job of saving blank lines in a
multi-line command.
w. Removed a `feature' that made `ulimit' silently translate `unlimited' to
the current hard limit, which obscured some kernel error returns.
x. Fixed the grammar so that `}' is recognized as a reserved word after
another reserved word, rather than requiring a `;' or newline. This
means that constructs like
{ { echo a b c ; } }
work as expected.
y. Conditional commands ([[...]]) now perform tilde expansion on their
arguments.
z. Noted in the documentation that `set -a' will cause functions to be
exported if they are defined after `set -a' is executed.
aa. When an interactive login shell starts, if $PWD and $HOME refer to the
same directory but are not the same string, $PWD is set to $HOME.
bb. Fixed `printf' to handle invalid floating point numbers better.
cc. Temporary files are now created with random filenames, to improve security.
dd. The readline initialization code now binds the custom bash functions and
key bindings after the readline defaults are set up.
ee. Fixed the `source' builtin to no longer overwrite a shell function's
argument list, even if the sourced file changes the positional parameters.
ff. A bug fix was made in the expansion of `$*' in contexts where it should
not be split, like assignment statements.
gg. Fixed a bug in the parameter substring expansion to handle conditional
arithmetic expressions ( exp ? val1 : val2 ) without cutting the expression
off at the wrong `:'.
hh. The `<>' redirection is no longer subject to the current setting of
`noclobber', as POSIX.2 specifies.
ii. Fixed a bug in the conditional command parsing code that caused expressions
in parentheses to occasionally be parsed incorrectly.
jj. Fixed a bug in the ((...)) arithmetic command to allow do...done or
{...} to follow the )) without an intervening list terminator.
kk. `printf' now treats `\E' the same as `\e' when performing backslash escape
expansion for the `%b' format specifier.
ll. When in POSIX mode, the shell no longer searches the current directory for
a file to be sourced with `.' or `source' if `.' is not in $PATH.
mm. Interactive comments are no longer turned off when POSIX mode is disabled.
nn. The UID, EUID, HOSTNAME variables are not set if they are in the shell's
environment when it starts up.
oo. Fixed a bug in the `command' builtin so the effect of a command like
`command exec 4<file' is as if the `command' had been omitted.
pp. ${foo[@]} and ${foo[*]} now work as in ksh93 if `foo' is not an array
variable.
qq. ${#foo[X]}, where X is 0, @, or *, now work as in ksh93 if `foo' is not
an array variable.
rr. The shell's idea of an absolute pathname now takes into account a
possible drive specification on Cygwin and other Windows systems.
ss. Fixed a bug which caused incorrect parsing of some multi-character
constructs if they were split across input lines with backslash-newline
line continuation.
tt. Fixed a bug that caused restricted shell mode to be set inappropriately
when trying to execute a shell script without a leading `#!'.
uu. Shell function definitions no longer require that the body be a group
command ( {...} ), as POSIX.2 requires.
vv. The `cd' and `pwd' builtins now process symlinks in pathnames internally
and should require many fewer calls to getcwd().
ww. Fixed a bug that caused a pipeline's process group to be set incorrectly
if one of the pipeline elements contained a command substitution.
xx. Fixed a bug that caused core dumps when expanding the value of HISTIGNORE.
yy. The output of `set' is now quoted using $'...' so invisible characters are
displayed as escape sequences.
zz. Fixed the help text for `unset', since PATH and IFS may both be unset.
aaa. The shell no longer puts directory names into the command hash table.
bbb. Fixed a bug in `read' that caused it to occasionally free memory twice if
it was interrupted after reading a large amount of data.
ccc. Assignment statements that attempt to assign values to readonly variables
now cause the command to return an error status.
ddd. Fixed a bug that could cause incorrect output if a $(<file) construct was
interrupted.
eee. GROUPS and FUNCNAME now return an error status when assignment is
attempted, but may be unset (in which case they lose their special
properties). In all respects except unsetting, they are readonly.
fff. The string-to-integer conversion code now ignores trailing whitespace in
the string, even if strtol(3) does not.
ggg. The tcsh magic-space function now does a better job of inserting the
space close to where the point was before the history expansion, rather
than just appending it.
hhh. Fixed a bug which caused a file sourced from an interactive shell to
fill up the jobs table if it ran lots of jobs.
iii. Fixed a bug in the parameter pattern substitution code to avoid infinite
recursion on zero-length matches.
2. Changes to Readline
a. When setting the terminal attributes on systems using `struct termio',
readline waits for output to drain before changing the attributes.
b. A fix was made to the history word tokenization code to avoid attempts to
dereference a null pointer.
c. Readline now defaults rl_terminal_name to $TERM if the calling application
has left it unset, and tries to initialize with the resultant value.
d. Instead of calling (*rl_getc_function)() directly to get input in certain
places, readline now calls rl_read_key() consistently.
e. Fixed a bug in the completion code that allowed a backslash to quote a
single quote inside a single-quoted string.
f. rl_prompt is no longer assigned directly from the argument to readline(),
but uses memory allocated by readline. This allows constant strings to
be passed to readline without problems arising when the prompt processing
code wants to modify the string.
g. Fixed a bug that caused non-interactive history searches to return the
wrong line when performing multiple searches backward for the same string.
h. Many variables, function arguments, and function return values are now
declared `const' where appropriate, to improve behavior when linking with
C++ code.
i. The control character detection code now works better on systems where
`char' is unsigned by default.
j. The vi-mode numeric argument is now capped at 999999, just like emacs mode.
k. The Function, CPFunction, CPPFunction, and VFunction typedefs have been
replaced with a set of specific prototyped typedefs, though they are
still in the readline header files for backwards compatibility.
m. Nearly all of the (undocumented) internal global variables in the library
now have an _rl_ prefix -- there were a number that did not, like
screenheight, screenwidth, alphabetic, etc.
n. The ding() convenience function has been renamed to rl_ding(), though the
old function is still defined for backwards compatibility.
o. The completion convenience functions filename_completion_function,
username_completion_function, and completion_matches now have an rl_
prefix, though the old names are still defined for backwards compatibility.
p. The functions shared by readline and bash (linkage is satisfied from bash
when compiling with bash, and internally otherwise) now have an sh_ prefix.
q. Changed the shared library creation procedure on Linux and BSD/OS 4.x so
that the `soname' contains only the major version number rather than the
major and minor numbers.
r. Fixed a redisplay bug that occurred when the prompt spanned more than one
physical line and contained invisible characters.
3. New Features in Bash
a. Added a new `--init-file' invocation argument as a synonym for `--rcfile',
per the new GNU coding standards.
b. The /dev/tcp and /dev/udp redirections now accept service names as well as
port numbers.
c. `complete' and `compgen' now take a `-o value' option, which controls some
of the aspects of that compspec. Valid values are:
default - perform bash default completion if programmable
completion produces no matches
dirnames - perform directory name completion if programmable
completion produces no matches
filenames - tell readline that the compspec produces filenames,
so it can do things like append slashes to
directory names and suppress trailing spaces
4. New Features in Readline
a. The blink timeout for paren matching is now settable by applications.
b. _rl_executing_macro has been renamed to rl_executing_macro, which means
it's now part of the public interface.
c. Readline has a new variable, rl_readline_state, which is a bitmap that
encapsulates the current state of the library; intended for use by
callbacks and hook functions.
------------------------------------------------------------------------------
This document details the changes between this version, bash-2.04-release,
and the previous version, bash-2.04-beta5.
@ -480,7 +1036,7 @@ t. The SSH_CLIENT environment variable is no longer auto-exported.
u. A bug that caused redirections with (...) subshells to be performed in
the wrong order was fixed.
v. A bug that occasionally caused inaapropriate expansion of assignment
v. A bug that occasionally caused inappropriate expansion of assignment
statements in compound array assignments was fixed.
w. The code that parses the words in a compound array assignment was

69
COMPAT
View file

@ -1,5 +1,5 @@
This document details the incompatibilites between this version of bash,
bash-2.04, and the previous widely-available version, bash-1.14 (which
bash-2.05, 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.
@ -131,3 +131,70 @@ were discovered by users of bash-2.x, so this list is not comprehensive.
that declares them:
alias -x='chmod a-x' --> alias -- -x='chmod a-x'
13. There was a bug in bash-1.14 and previous versions that caused it to
accept as valid syntax for loops of the form
for f in ; do ... ; done
This should be a syntax error, and bash-2.x treats it as such.
14. The behavior of range specificiers within bracket matching expressions
in the pattern matcher (e.g., [A-Z]) depends on the current locale,
specifically the value of the LC_COLLATE environment variable. Setting
this variable to C or POSIX will result in the traditional ASCII behavior
for range comparisons. If the locale is set to something else, e.g.,
en_US (specified by the LANG or LC_ALL variables), collation order is
locale-dependent. For example, the en_US locale sorts the upper and
lower case letters like this:
AaBb...Zz
so a range specification like [A-Z] will match every letter except `z'.
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.
Look at the manual pages for setlocale(3), strcoll(3), and, if it is
present, locale(1).
You can find your current locale information by running locale(1):
caleb.ins.cwru.edu(2)$ locale
LANG=en_US
LC_CTYPE="en_US"
LC_NUMERIC="en_US"
LC_TIME="en_US"
LC_COLLATE="en_US"
LC_MONETARY="en_US"
LC_MESSAGES="en_US"
LC_ALL=en_US
My advice is to put
export LC_COLLATE=C
into /etc/profile and inspect any shell scripts run from cron for
constructs like [A-Z]. This will prevent things like
rm [A-Z]*
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.
15. Bash versions up to 1.14.7 included an undocumented `-l' operator to
the `test/[' builtin. It was a unary operator that expanded to the
length of its string argument. This let you do things like
test -l $variable -lt 20
for example.
This was included for backwards compatibility with old versions of the
Bourne shell, which did not provide an easy way to obtain the length of
the value of a shell variable.
This operator is not part of the POSIX standard, because one can (and
should) use ${#variable} to get the length of a variable's value.
Bash-2.x does not support it.

View file

@ -12,10 +12,12 @@ The following list is what's changed when `POSIX mode' is in effect:
re-search `$PATH' to find the new location. This is also
available with `shopt -s checkhash'.
2. The `>&' redirection does not redirect stdout and stderr.
2. The message printed by the job control code and builtins when a job
exits with a non-zero status is `Done(status)'.
3. The message printed by the job control code and builtins when a job
exits with a non-zero status is `Done(status)'.
is stopped is `Stopped(SIGNAME)', where SIGNAME is, for example,
`SIGTSTP'.
4. Reserved words may not be aliased.
@ -69,7 +71,7 @@ The following list is what's changed when `POSIX mode' is in effect:
`$CDPATH', the value it assigns to the `PWD' variable does not
contain any symbolic links, as if `cd -P' had been executed.
19. If `$CDPATH' is set, the `cd' builtin will not implicitly append
19. If `CDPATH' is set, the `cd' builtin will not implicitly append
the current directory to it. This means that `cd' will fail if no
valid directory name can be constructed from any of the entries in
`$CDPATH', even if the a directory with the same name as the name
@ -89,9 +91,27 @@ The following list is what's changed when `POSIX mode' is in effect:
23. Assignment statements preceding POSIX 1003.2 special builtins
persist in the shell environment after the builtin completes.
24. The `export' and `readonly' builtin commands display their output
24. Assignment statements preceding shell function calls persist in the
shell environment after the function returns, as if a POSIX
special builtin command had been executed.
25. The `export' and `readonly' builtin commands display their output
in the format required by POSIX 1003.2.
26. The `trap' builtin displays signal names without the leading `SIG'.
27. The `.' and `source' builtins do not search the current directory
for the filename argument if it is not found by searching `PATH'.
28. Subshells spawned to execute command substitutions inherit the
value of the `-e' option from the parent shell. When not in POSIX
mode, Bash clears the `-e' option in such subshells.
29. Alias expansion is always enabled, even in non-interactive shells.
30. When the `set' builtin is invoked without options, it does not
display shell function names and definitions.
There is other POSIX 1003.2 behavior that Bash does not implement.
Specifically:
@ -99,3 +119,13 @@ Specifically:
1. Assignment statements affect the execution environment of all
builtins, not just special ones.
2. When a subshell is created to execute a shell script with execute
permission, but without a leading `#!', Bash sets `$0' to the full
pathname of the script as found by searching `$PATH', rather than
the command as typed by the user.
3. When using `.' to source a shell script found in `$PATH', bash
checks execute permission bits rather than read permission bits,
just as if it were searching for a command.

File diff suppressed because it is too large Load diff

175
CWRU/maildir-patch Normal file
View file

@ -0,0 +1,175 @@
# DP: From: Miquel van Smoorenburg <miquels@cistron.nl>
# DP: A patch that adds support for Maildir type mailboxes.
--- ./mailcheck.c.orig Wed Feb 4 21:30:33 1998
+++ ./mailcheck.c Sun Nov 14 15:35:07 1999
@@ -21,8 +21,10 @@
#include "config.h"
#include <stdio.h>
+#include <errno.h>
#include "bashtypes.h"
#include "posixstat.h"
+#include "posixdir.h"
#ifndef _MINIX
# include <sys/param.h>
#endif
@@ -37,6 +39,8 @@
#include "mailcheck.h"
#include <tilde/tilde.h>
+#include "mailstat.c"
+
#ifndef NOW
#define NOW ((time_t)time ((time_t *)0))
#endif
@@ -131,7 +135,7 @@
struct stat finfo;
file = mailfiles[i]->name;
- if (stat (file, &finfo) == 0)
+ if (mailstat (file, &finfo) == 0)
{
mailfiles[i]->access_time = finfo.st_atime;
mailfiles[i]->mod_time = finfo.st_mtime;
@@ -155,7 +159,7 @@
i = find_mail_file (filename);
if (i >= 0)
{
- if (stat (filename, &finfo) == 0)
+ if (mailstat (filename, &finfo) == 0)
{
mailfiles[i]->mod_time = finfo.st_mtime;
mailfiles[i]->access_time = finfo.st_atime;
@@ -221,7 +225,7 @@
file = mailfiles[i]->name;
mtime = mailfiles[i]->mod_time;
- if ((stat (file, &finfo) == 0) && (finfo.st_size > 0))
+ if ((mailstat (file, &finfo) == 0) && (finfo.st_size > 0))
return (mtime != finfo.st_mtime);
return (0);
@@ -239,7 +243,7 @@
file = mailfiles[i]->name;
atime = mailfiles[i]->access_time;
- if ((stat (file, &finfo) == 0) && (finfo.st_size > 0))
+ if ((mailstat (file, &finfo) == 0) && (finfo.st_size > 0))
return (atime != finfo.st_atime);
return (0);
@@ -257,7 +261,7 @@
file = mailfiles[i]->name;
size = mailfiles[i]->file_size;
- return ((stat (file, &finfo) == 0) && (finfo.st_size > size));
+ return ((mailstat (file, &finfo) == 0) && (finfo.st_size > size));
}
/* Take an element from $MAILPATH and return the portion from
diff -ruN bash-2.01.1.b4/mailstat.c bash-2.01.1/mailstat.c
--- bash-2.01.1.b4/mailstat.c Thu Jan 1 01:00:00 1970
+++ bash-2.01.1/mailstat.c Wed Jun 2 12:05:04 1999
@@ -0,0 +1,98 @@
+/*
+ * Stat a file. If it's a maildir, check all messages
+ * in the maildir and present the grand total as a file.
+ * The fields in the 'struct stat' are from the mail directory.
+ * The following fields are emulated:
+ *
+ * st_nlink always 1
+ * st_size total number of bytes in all files
+ * st_blocks total number of messages
+ * st_atime access time of newest file in maildir
+ * st_mtime modify time of newest file in maildir
+ * st_mode S_IFDIR changed to S_IFREG
+ *
+ * This is good enough for most mail-checking applications.
+ */
+int
+mailstat(char *path, struct stat *st)
+{
+ DIR *dd;
+ struct dirent *fn;
+ struct stat st_ret, st_tmp;
+ static struct stat st_new_last, st_ret_last;
+ char dir[PATH_MAX * 2];
+ char file[PATH_MAX * 2];
+ int i, l;
+ time_t atime = 0, mtime = 0;
+
+ /* First see if it's a directory. */
+ if ((i = stat(path, st)) != 0 || !S_ISDIR(st->st_mode))
+ return i;
+ if (strlen(path) > sizeof(dir) - 5) {
+ errno = ENAMETOOLONG;
+ return -1;
+ }
+
+ st_ret = *st;
+ st_ret.st_nlink = 1;
+ st_ret.st_size = 0;
+ st_ret.st_blocks = 0;
+ st_ret.st_mode &= ~S_IFDIR;
+ st_ret.st_mode |= S_IFREG;
+
+ /* See if cur/ is present */
+ sprintf(dir, "%s/cur", path);
+ if (stat(dir, &st_tmp) || !S_ISDIR(st_tmp.st_mode)) return 0;
+ st_ret.st_atime = st_tmp.st_atime;
+
+ /* See if tmp/ is present */
+ sprintf(dir, "%s/tmp", path);
+ if (stat(dir, &st_tmp) || !S_ISDIR(st_tmp.st_mode)) return 0;
+ st_ret.st_mtime = st_tmp.st_mtime;
+
+ /* And new/ */
+ sprintf(dir, "%s/new", path);
+ if (stat(dir, &st_tmp) || !S_ISDIR(st_tmp.st_mode)) return 0;
+ st_ret.st_mtime = st_tmp.st_mtime;
+
+ /* Optimization - if new/ didn't change, nothing else did. */
+ if (st_tmp.st_dev == st_new_last.st_dev &&
+ st_tmp.st_ino == st_new_last.st_ino &&
+ st_tmp.st_atime == st_new_last.st_atime &&
+ st_tmp.st_mtime == st_new_last.st_mtime) {
+ *st = st_ret_last;
+ return 0;
+ }
+ st_new_last = st_tmp;
+
+ /* Loop over new/ and cur/ */
+ for (i = 0; i < 2; i++) {
+ sprintf(dir, "%s/%s", path, i ? "cur" : "new");
+ sprintf(file, "%s/", dir);
+ l = strlen(file);
+ if ((dd = opendir(dir)) == NULL)
+ return 0;
+ while ((fn = readdir(dd)) != NULL) {
+ if (fn->d_name[0] == '.' ||
+ strlen(fn->d_name) + l >= sizeof(file))
+ continue;
+ strcpy(file + l, fn->d_name);
+ if (stat(file, &st_tmp) != 0)
+ continue;
+ st_ret.st_size += st_tmp.st_size;
+ st_ret.st_blocks++;
+ if (st_tmp.st_atime != st_tmp.st_mtime &&
+ st_tmp.st_atime > atime)
+ atime = st_tmp.st_atime;
+ if (st_tmp.st_mtime > mtime)
+ mtime = st_tmp.st_mtime;
+ }
+ closedir(dd);
+ }
+
+ if (atime) st_ret.st_atime = atime;
+ if (mtime) st_ret.st_mtime = mtime;
+
+ *st = st_ret_last = st_ret;
+ return 0;
+}

34
INSTALL
View file

@ -255,20 +255,20 @@ does not provide the necessary support.
`--enable-alias'
Allow alias expansion and include the `alias' and `unalias'
builtins (*note Aliases::.).
builtins (*note Aliases::).
`--enable-arith-for-command'
Include support for the alternate form of the `for' command that
behaves like the C language `for' statement (*note Looping
Constructs::.).
Constructs::).
`--enable-array-variables'
Include support for one-dimensional array shell variables (*note
Arrays::.).
Arrays::).
`--enable-bang-history'
Include support for `csh'-like history substitution (*note History
Interaction::.).
Interaction::).
`--enable-brace-expansion'
Include `csh'-like brace expansion ( `b{a,b}c' ==> `bac bbc' ).
@ -277,16 +277,16 @@ does not provide the necessary support.
`--enable-command-timing'
Include support for recognizing `time' as a reserved word and for
displaying timing statistics for the pipeline following `time'
(*note Pipelines::.). This allows pipelines as well as shell
(*note Pipelines::). This allows pipelines as well as shell
builtins and functions to be timed.
`--enable-cond-command'
Include support for the `[[' conditional command (*note
Conditional Constructs::.).
Conditional Constructs::).
`--enable-directory-stack'
Include support for a `csh'-like directory stack and the `pushd',
`popd', and `dirs' builtins (*note The Directory Stack::.).
`popd', and `dirs' builtins (*note The Directory Stack::).
`--enable-disabled-builtins'
Allow builtin commands to be invoked via `builtin xxx' even after
@ -296,7 +296,7 @@ does not provide the necessary support.
`--enable-dparen-arithmetic'
Include support for the `((...))' command (*note Conditional
Constructs::.).
Constructs::).
`--enable-extended-glob'
Include support for the extended pattern matching features
@ -304,24 +304,24 @@ does not provide the necessary support.
`--enable-help-builtin'
Include the `help' builtin, which displays help on shell builtins
and variables (*note Bash Builtins::.).
and variables (*note Bash Builtins::).
`--enable-history'
Include command history and the `fc' and `history' builtin
commands (*note Bash History Facilities::.).
commands (*note Bash History Facilities::).
`--enable-job-control'
This enables the job control features (*note Job Control::.), if
This enables the job control features (*note Job Control::), if
the operating system supports them.
`--enable-net-redirections'
This enables the special handling of filenames of the form
`/dev/tcp/HOST/PORT' and `/dev/udp/HOST/PORT' when used in
redirections (*note Redirections::.).
redirections (*note Redirections::).
`--enable-process-substitution'
This enables process substitution (*note Process Substitution::.)
if the operating system provides the necessary support.
This enables process substitution (*note Process Substitution::) if
the operating system provides the necessary support.
`--enable-prompt-string-decoding'
Turn on the interpretation of a number of backslash-escaped
@ -331,12 +331,12 @@ does not provide the necessary support.
`--enable-progcomp'
Enable the programmable completion facilities (*note Programmable
Completion::.). If Readline is not enabled, this option has no
Completion::). If Readline is not enabled, this option has no
effect.
`--enable-readline'
Include support for command-line editing and history with the Bash
version of the Readline library (*note Command Line Editing::.).
version of the Readline library (*note Command Line Editing::).
`--enable-restricted'
Include support for a "restricted shell". If this is enabled,
@ -345,7 +345,7 @@ does not provide the necessary support.
`--enable-select'
Include the `select' builtin, which allows the generation of simple
menus (*note Conditional Constructs::.).
menus (*note Conditional Constructs::).
`--enable-usg-echo-default'
A synonym for `--enable-xpg-echo-default'.

View file

@ -95,6 +95,7 @@ error.c f
xmalloc.c f
pcomplete.c f
pcomplib.c f
mksyntax.c f
alias.h f
builtins.h f
bashhist.h f
@ -107,6 +108,7 @@ hashlib.h f
quit.h f
flags.h f
shell.h f
syntax.h f
pathexp.h f
parser.h f
pcomplete.h f
@ -251,6 +253,7 @@ lib/readline/search.c f
lib/readline/isearch.c f
lib/readline/parens.c f
lib/readline/rltty.c f
lib/readline/compat.c f
lib/readline/complete.c f
lib/readline/bind.c f
lib/readline/display.c f
@ -269,6 +272,7 @@ lib/readline/rldefs.h f
lib/readline/rlconf.h f
lib/readline/rlshell.h f
lib/readline/rltty.h f
lib/readline/rltypedefs.h f
lib/readline/rlwinsize.h f
lib/readline/readline.h f
lib/readline/tcap.h f
@ -310,18 +314,26 @@ lib/sh/itos.c f
lib/sh/makepath.c f
lib/sh/netopen.c f
lib/sh/oslib.c f
lib/sh/pathcanon.c f
lib/sh/pathphys.c f
lib/sh/rename.c f
lib/sh/setlinebuf.c f
lib/sh/shquote.c f
lib/sh/shtty.c f
lib/sh/spell.c f
lib/sh/strcasecmp.c f
lib/sh/strerror.c f
lib/sh/strindex.c f
lib/sh/stringlist.c f
lib/sh/stringvec.c f
lib/sh/strpbrk.c f
lib/sh/strtod.c f
lib/sh/strtol.c f
lib/sh/strtoul.c f
lib/sh/strtrans.c f
lib/sh/times.c f
lib/sh/timeval.c f
lib/sh/tmpfile.c f
lib/sh/vprint.c f
lib/sh/zread.c f
lib/sh/zwrite.c f
@ -367,6 +379,7 @@ CWRU/POSIX.NOTES f
CWRU/changelog f
CWRU/sh-redir-hack f
CWRU/empty-for-wordlist f
CWRU/maildir-patch f
CWRU/mh-folder-comp f
doc/FAQ f
doc/Makefile.in f
@ -376,7 +389,6 @@ doc/builtins.1 f
doc/rbash.1 f
doc/README f
doc/INTRO f
doc/readline.3 f
doc/texinfo.tex f
doc/bashref.texi f
doc/bashref.info f
@ -412,18 +424,23 @@ examples/bashdb/bashdb f
examples/bashdb/bashdb.fns f
examples/bashdb/bashdb.pre f
examples/complete/complete-examples f
examples/complete/complete.ianmac f
examples/complete/complete2.ianmac f
examples/complete/complete.freebsd f
examples/loadables/README f
examples/loadables/template.c f
examples/loadables/Makefile.in f
examples/loadables/necho.c f
examples/loadables/hello.c f
examples/loadables/print.c f
examples/loadables/realpath.c f
examples/loadables/sprintf.c f
examples/loadables/sleep.c f
examples/loadables/truefalse.c f
examples/loadables/getconf.c f
examples/loadables/finfo.c f
examples/loadables/cat.c f
examples/loadables/cut.c f
examples/loadables/logname.c f
examples/loadables/basename.c f
examples/loadables/dirname.c f
@ -433,6 +450,7 @@ examples/loadables/tee.c f
examples/loadables/rmdir.c f
examples/loadables/head.c f
examples/loadables/printenv.c f
examples/loadables/push.c f
examples/loadables/id.c f
examples/loadables/whoami.c f
examples/loadables/uname.c f
@ -445,6 +463,7 @@ examples/loadables/perl/README f
examples/loadables/perl/bperl.c f
examples/loadables/perl/iperl.c f
examples/functions/array-stuff f
examples/functions/array-to-string f
examples/functions/autoload f
examples/functions/autoload.v2 f
examples/functions/autoload.v3 f
@ -453,11 +472,13 @@ examples/functions/basename2 f
examples/functions/csh-compat f
examples/functions/dirfuncs f
examples/functions/dirname f
examples/functions/emptydir f
examples/functions/exitstat f
examples/functions/external f
examples/functions/fact f
examples/functions/fstty f
examples/functions/func f
examples/functions/gethtml f
examples/functions/getoptx.bash f
examples/functions/inetaddr f
examples/functions/inpath f
@ -466,6 +487,7 @@ examples/functions/isnum2 f
examples/functions/jdate.bash f
examples/functions/jj.bash f
examples/functions/keep f
examples/functions/ksh-cd f
examples/functions/ksh-compat-test f
examples/functions/kshenv f
examples/functions/login f
@ -474,12 +496,14 @@ examples/functions/manpage f
examples/functions/mhfold f
examples/functions/notify.bash f
examples/functions/pathfuncs f
examples/functions/recurse f
examples/functions/repeat2 f
examples/functions/repeat3 f
examples/functions/seq f
examples/functions/seq2 f
examples/functions/shcat f
examples/functions/shcat2 f
examples/functions/sort-pos-params f
examples/functions/substr f
examples/functions/substr2 f
examples/functions/term f
@ -490,7 +514,9 @@ examples/functions/xalias.bash f
examples/functions/xfind.bash f
examples/scripts/adventure.sh f
examples/scripts/bcsh.sh f
examples/scripts/cat.sh f
examples/scripts/center f
examples/scripts/dd-ex.sh f
examples/scripts/fixfiles.bash f
examples/scripts/hanoi.bash f
examples/scripts/inpath f
@ -567,6 +593,7 @@ tests/exec2.sub f
tests/exec3.sub f
tests/exec4.sub f
tests/exec5.sub f
tests/exec6.sub f
tests/exp-tests f
tests/exp.right f
tests/extglob.tests f
@ -576,6 +603,8 @@ tests/extglob2.right f
tests/func.tests f
tests/func.right f
tests/func1.sub f
tests/func2.sub f
tests/func3.sub f
tests/getopts.tests f
tests/getopts.right f
tests/getopts1.sub f
@ -712,6 +741,7 @@ tests/type.tests f
tests/type.right f
tests/varenv.right f
tests/varenv.sh f
tests/varenv1.sub f
tests/version f
tests/version.mini f
tests/misc/dev-tcp.tests f

View file

@ -1,4 +1,4 @@
# Makefile for bash-2.04, version 2.115
# Makefile for bash-2.05, version 2.120
#
# Copyright (C) 1996 Free Software Foundation, Inc.
@ -85,6 +85,9 @@ OS = @host_os@
VENDOR = @host_vendor@
MACHTYPE = @host@
# comment out for release
# DEBUG = -DDEBUG
THIS_SH = $(BUILD_DIR)/$(Program)
# PROFILE_FLAGS is either -pg, to generate profiling info for use
@ -96,7 +99,7 @@ PROFILE_FLAGS= @PROFILE_FLAGS@
# passed to cc. A different name should have been used.
CFLAGS = @CFLAGS@
CPPFLAGS = @CPPFLAGS@
LOCAL_CFLAGS = @LOCAL_CFLAGS@
LOCAL_CFLAGS = @LOCAL_CFLAGS@ ${DEBUG}
DEFS = @DEFS@
LOCAL_DEFS = @LOCAL_DEFS@
LOCAL_LIBS = @LOCAL_LIBS@
@ -146,7 +149,11 @@ SHLIB_SOURCE = ${SH_LIBSRC}/clktck.c ${SH_LIBSRC}/getcwd.c \
${SH_LIBSRC}/shtty.c ${SH_LIBSRC}/inet_aton.c \
${SH_LIBSRC}/netopen.c ${SH_LIBSRC}/strpbrk.c \
${SH_LIBSRC}/timeval.c ${SH_LIBSRC}/clock.c \
${SH_LIBSRC}/makepath.c
${SH_LIBSRC}/makepath.c ${SH_LIBSRC}/pathcanon.c \
${SH_LIBSRC}/pathphys.c ${SH_LIBSRC}/stringlist.c \
${SH_LIBSRC}/stringvec.c ${SH_LIBSRC}/tmpfile.c \
${SH_LIBSRC}/spell.c ${SH_LIBSRC}/strtrans.c \
${SH_LIBSRC}/strindex.c ${SH_LIBSRC}/shquote.c
SHLIB_LIB = -lsh
SHLIB_LIBNAME = libsh.a
@ -186,6 +193,7 @@ READLINE_SOURCE = $(RL_LIBSRC)/rldefs.h $(RL_LIBSRC)/rlconf.h \
$(RL_LIBSRC)/terminal.c $(RL_LIBSRC)/nls.c \
$(RL_LIBSRC)/input.c $(RL_LIBSRC)/xmalloc.c \
$(RL_LIBSRC)/shell.c $(RL_LIBSRC)/savestring.c \
$(RL_LIBSRC)/compat.c \
$(RL_LIBSRC)/histexpand.c $(RL_LIBSRC)/history.c \
$(RL_LIBSRC)/histsearch.c $(RL_LIBSRC)/histfile.c
@ -200,6 +208,7 @@ READLINE_OBJ = $(RL_LIBDIR)/readline.o $(RL_LIBDIR)/funmap.o \
$(RL_LIBDIR)/macro.o $(RL_LIBDIR)/input.o \
$(RL_LIBDIR)/terminal.o $(RL_LIBDIR)/callback.o \
$(RL_LIBDIR)/shell.o $(RL_LIBDIR)/savestring.o \
$(RL_LIBDIR)/compat.o \
$(RL_LIBDIR)/history.o $(RL_LIBDIR)/histexpand.o \
$(RL_LIBDIR)/histsearch.o $(RL_LIBDIR)/histfile.o
@ -295,11 +304,11 @@ BASHINCFILES = $(BASHINCDIR)/posixstat.h $(BASHINCDIR)/ansi_stdlib.h \
$(BASHINCDIR)/unionwait.h $(BASHINCDIR)/maxpath.h \
$(BASHINCDIR)/shtty.h
LIBRARIES = $(READLINE_LIB) $(HISTORY_LIB) $(TERMCAP_LIB) $(GLOB_LIB) \
$(TILDE_LIB) $(MALLOC_LIB) $(SHLIB_LIB) $(LOCAL_LIBS)
LIBRARIES = $(SHLIB_LIB) $(READLINE_LIB) $(HISTORY_LIB) $(TERMCAP_LIB) $(GLOB_LIB) \
$(TILDE_LIB) $(MALLOC_LIB) $(LOCAL_LIBS)
LIBDEP = $(READLINE_DEP) $(HISTORY_DEP) $(TERMCAP_DEP) $(GLOB_DEP) \
$(TILDE_DEP) $(MALLOC_DEP) $(SHLIB_DEP)
LIBDEP = $(SHLIB_DEP) $(READLINE_DEP) $(HISTORY_DEP) $(TERMCAP_DEP) $(GLOB_DEP) \
$(TILDE_DEP) $(MALLOC_DEP)
LIBRARY_LDFLAGS = $(READLINE_LDFLAGS) $(HISTORY_LDFLAGS) $(GLOB_LDFLAGS) \
$(TILDE_LDFLAGS) $(MALLOC_LDFLAGS) $(SHLIB_LDFLAGS)
@ -316,11 +325,11 @@ CSOURCES = shell.c eval.c parse.y general.c make_cmd.c print_cmd.c y.tab.c \
input.c bashhist.c array.c sig.c pathexp.c \
unwind_prot.c siglist.c bashline.c bracecomp.c error.c \
list.c stringlib.c locale.c findcmd.c redir.c \
pcomplete.c pcomplib.c xmalloc.c
pcomplete.c pcomplib.c syntax.c xmalloc.c
HSOURCES = shell.h flags.h trap.h hashcmd.h hashlib.h jobs.h builtins.h \
general.h variables.h config.h $(ALLOC_HEADERS) alias.h \
quit.h unwind_prot.h \
quit.h unwind_prot.h syntax.h \
command.h input.h error.h bashansi.h dispose_cmd.h make_cmd.h \
subst.h externs.h siglist.h bashhist.h bashline.h bashtypes.h \
array.h sig.h mailcheck.h bashintl.h bashjmp.h ${GRAM_H} \
@ -342,7 +351,7 @@ OBJECTS = shell.o eval.o y.tab.o general.o make_cmd.o print_cmd.o $(GLOBO) \
trap.o input.o unwind_prot.o pathexp.o sig.o test.o version.o \
alias.o array.o braces.o bracecomp.o bashhist.o bashline.o \
siglist.o list.o stringlib.o locale.o findcmd.o redir.o \
pcomplete.o pcomplib.o xmalloc.o
pcomplete.o pcomplib.o syntax.o xmalloc.o
# Where the source code of the shell builtins resides.
BUILTIN_SRCDIR=$(srcdir)/builtins
@ -404,7 +413,8 @@ SDIR = $(dot)/support/
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
tests/printenv$(EXEEXT) mksignames$(EXEEXT) lsignames.h \
mksyntax${EXEEXT} syntax.c
CREATED_CONFIGURE = config.h config.cache config.status config.log \
stamp-h
CREATED_MAKEFILES = Makefile builtins/Makefile doc/Makefile \
@ -503,6 +513,9 @@ $(SHLIB_LIBRARY): config.h ${SHLIB_SOURCE}
mksignames$(EXEEXT): $(SUPPORT_SRC)mksignames.c
$(CC_FOR_BUILD) $(CCFLAGS) $(CPPFLAGS) -o $@ $(SUPPORT_SRC)mksignames.c
mksyntax$(EXEEXT): ${srcdir}/mksyntax.c config.h syntax.h
${CC_FOR_BUILD} ${CCFLAGS} ${CPPFLAGS} -o $@ ${srcdir}/mksyntax.c
# make a list of signals for the local system -- this is done when we're
# *not* cross-compiling
lsignames.h: mksignames$(EXEEXT)
@ -513,6 +526,10 @@ lsignames.h: mksignames$(EXEEXT)
signames.h: $(SIGNAMES_H)
-if cmp -s $(SIGNAMES_H) $@ ; then :; else $(RM) $@ ; $(CP) $(SIGNAMES_H) $@ ; fi
syntax.c: mksyntax${EXEEXT} $(srcdir)/syntax.h
$(RM) $@
./mksyntax -o $@
$(BUILTINS_LIBRARY): $(BUILTIN_DEFS) $(BUILTIN_C_SRC) config.h ${BASHINCDIR}/memalloc.h
@(cd $(DEFDIR) && $(MAKE) $(MFLAGS) libbuiltins.a ) || exit 1
@ -706,25 +723,25 @@ builtins/exit.o: config-top.h
builtins/kill.o: config-top.h
# shell basics
copy_cmd.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
copy_cmd.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
copy_cmd.o: general.h bashtypes.h variables.h array.h hashlib.h
copy_cmd.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
copy_cmd.o: make_cmd.h subst.h sig.h pathnames.h externs.h
dispose_cmd.o: bashansi.h ${BASHINCDIR}/ansi_stdlib.h
dispose_cmd.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h
dispose_cmd.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h
dispose_cmd.o: error.h general.h bashtypes.h variables.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
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 externs.h input.h bashhist.h
eval.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h trap.h flags.h ${DEFSRC}/common.h
eval.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
eval.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
eval.o: general.h bashtypes.h variables.h array.h hashlib.h
eval.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
eval.o: make_cmd.h subst.h sig.h pathnames.h externs.h
eval.o: input.h execute_cmd.h
execute_cmd.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
execute_cmd.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
execute_cmd.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
execute_cmd.o: general.h bashtypes.h variables.h array.h hashlib.h
execute_cmd.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
execute_cmd.o: make_cmd.h subst.h sig.h pathnames.h externs.h
@ -733,48 +750,48 @@ execute_cmd.o: execute_cmd.h findcmd.h redir.h trap.h test.h pathexp.h
execute_cmd.o: $(DEFSRC)/common.h ${DEFDIR}/builtext.h ${GLOB_LIBSRC}/fnmatch.h
execute_cmd.o: ${BASHINCDIR}/posixtime.h
expr.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
expr.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
expr.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
expr.o: general.h bashtypes.h variables.h array.h hashlib.h
expr.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
expr.o: make_cmd.h subst.h sig.h pathnames.h externs.h
findcmd.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h ${BASHINCDIR}/posixstat.h bashansi.h
findcmd.o: ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/memalloc.h shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h
findcmd.o: ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/memalloc.h shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h
findcmd.o: ${BASHINCDIR}/stdc.h error.h general.h variables.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h
findcmd.o: dispose_cmd.h make_cmd.h subst.h sig.h pathnames.h externs.h
findcmd.o: flags.h hashlib.h pathexp.h hashcmd.h
flags.o: config.h flags.h
flags.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
flags.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
flags.o: general.h bashtypes.h variables.h array.h hashlib.h
flags.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
flags.o: make_cmd.h subst.h sig.h pathnames.h externs.h
general.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h ${BASHINCDIR}/filecntl.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
general.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
general.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
general.o: general.h bashtypes.h variables.h array.h hashlib.h
general.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
general.o: make_cmd.h subst.h sig.h pathnames.h externs.h
general.o: ${BASHINCDIR}/maxpath.h ${BASHINCDIR}/posixtime.h
hashcmd.o: config.h ${BASHINCDIR}/posixstat.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
hashcmd.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.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 bashtypes.h variables.h array.h hashcmd.h
hashcmd.o: execute_cmd.h findcmd.h ${BASHINCDIR}/stdc.h
hashlib.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
hashlib.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.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 bashtypes.h variables.h array.h hashlib.h
hashlib.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
hashlib.o: make_cmd.h subst.h sig.h pathnames.h externs.h
input.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
input.o: command.h ${BASHINCDIR}/stdc.h general.h input.h error.h externs.h
list.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
list.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
list.o: general.h bashtypes.h variables.h array.h hashlib.h
list.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
list.o: make_cmd.h subst.h sig.h pathnames.h externs.h
locale.o: config.h bashtypes.h bashintl.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
locale.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
locale.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
locale.o: general.h bashtypes.h variables.h array.h hashlib.h
locale.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
locale.o: make_cmd.h subst.h sig.h pathnames.h externs.h
mailcheck.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
mailcheck.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
mailcheck.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
mailcheck.o: general.h bashtypes.h variables.h array.h hashlib.h
mailcheck.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
mailcheck.o: make_cmd.h subst.h sig.h pathnames.h externs.h
@ -782,34 +799,34 @@ 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 error.h flags.h make_cmd.h
make_cmd.o: variables.h array.h hashlib.h subst.h input.h externs.h
make_cmd.o: jobs.h quit.h siglist.h
make_cmd.o: jobs.h quit.h siglist.h syntax.h
y.tab.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/memalloc.h
y.tab.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.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 bashtypes.h variables.h array.h hashlib.h
y.tab.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
y.tab.o: make_cmd.h subst.h sig.h pathnames.h externs.h
y.tab.o: trap.h flags.h parser.h input.h mailcheck.h $(DEFSRC)/common.h
y.tab.o: $(DEFDIR)/builtext.h bashline.h bashhist.h jobs.h siglist.h alias.h
pathexp.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
pathexp.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
pathexp.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
pathexp.o: general.h bashtypes.h variables.h array.h hashlib.h
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)/fnmatch.h
print_cmd.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
print_cmd.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.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 bashtypes.h variables.h array.h hashlib.h
print_cmd.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
print_cmd.o: make_cmd.h subst.h sig.h pathnames.h externs.h
print_cmd.o: ${GRAM_H} $(DEFSRC)/common.h
redir.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/filecntl.h
redir.o: ${BASHINCDIR}/memalloc.h shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
redir.o: ${BASHINCDIR}/memalloc.h shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
redir.o: general.h variables.h array.h hashlib.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h
redir.o: dispose_cmd.h make_cmd.h subst.h sig.h pathnames.h externs.h
redir.o: flags.h execute_cmd.h redir.h input.h
shell.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/filecntl.h
shell.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
shell.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
shell.o: general.h bashtypes.h variables.h array.h hashlib.h
shell.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
shell.o: make_cmd.h subst.h sig.h pathnames.h externs.h
@ -817,19 +834,19 @@ shell.o: flags.h trap.h mailcheck.h builtins.h $(DEFSRC)/common.h
shell.o: jobs.h siglist.h input.h execute_cmd.h findcmd.h bashhist.h
shell.o: ${GLOB_LIBSRC}/fnmatch.h
sig.o: config.h bashtypes.h
sig.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
sig.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
sig.o: general.h bashtypes.h variables.h array.h hashlib.h
sig.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
sig.o: make_cmd.h subst.h sig.h pathnames.h externs.h
sig.o: jobs.h siglist.h trap.h $(DEFSRC)/common.h bashline.h bashhist.h
siglist.o: config.h bashtypes.h siglist.h trap.h
stringlib.o: bashtypes.h
stringlib.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
stringlib.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
stringlib.o: general.h bashtypes.h variables.h array.h hashlib.h
stringlib.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
stringlib.o: make_cmd.h subst.h sig.h pathnames.h externs.h
subst.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/posixstat.h
subst.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
subst.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
subst.o: general.h bashtypes.h variables.h array.h hashlib.h
subst.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
subst.o: make_cmd.h subst.h sig.h pathnames.h externs.h
@ -837,13 +854,13 @@ 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}/fnmatch.h
test.o: bashtypes.h ${BASHINCDIR}/posixstat.h ${BASHINCDIR}/filecntl.h
test.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.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 bashtypes.h variables.h array.h hashlib.h
test.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
test.o: make_cmd.h subst.h sig.h pathnames.h externs.h test.h
test.o: ${DEFSRC}/common.h
trap.o: config.h bashtypes.h trap.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
trap.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
trap.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
trap.o: general.h bashtypes.h variables.h array.h hashlib.h
trap.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
trap.o: make_cmd.h subst.h sig.h pathnames.h externs.h
@ -851,7 +868,7 @@ trap.o: signames.h $(DEFSRC)/common.h
unwind_prot.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h command.h ${BASHINCDIR}/stdc.h
unwind_prot.o: general.h unwind_prot.h quit.h sig.h
variables.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
variables.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
variables.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
variables.o: general.h bashtypes.h variables.h array.h hashlib.h
variables.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
variables.o: make_cmd.h subst.h sig.h pathnames.h externs.h
@ -865,7 +882,7 @@ xmalloc.o: config.h bashtypes.h ${BASHINCDIR}/ansi_stdlib.h error.h
jobs.o: config.h bashtypes.h trap.h ${BASHINCDIR}/filecntl.h input.h ${BASHINCDIR}/shtty.h
jobs.o: bashansi.h ${BASHINCDIR}/ansi_stdlib.h
jobs.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
jobs.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
jobs.o: general.h bashtypes.h variables.h array.h hashlib.h
jobs.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
jobs.o: make_cmd.h subst.h sig.h pathnames.h externs.h
@ -878,13 +895,13 @@ nojobs.o: sig.h error.h ${BASHINCDIR}/shtty.h input.h
# shell features that may be compiled in
array.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
array.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
array.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
array.o: general.h bashtypes.h variables.h array.h hashlib.h
array.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
array.o: make_cmd.h subst.h sig.h pathnames.h externs.h
array.o: $(DEFSRC)/common.h
braces.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
braces.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.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 bashtypes.h variables.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
@ -893,13 +910,13 @@ alias.o: general.h bashtypes.h externs.h alias.h
alias.o: pcomplete.h
pcomplib.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h bashtypes.h
pcomplib.o: ${BASHINCDIR}/stdc.h hashlib.h pcomplete.h shell.h
pcomplib.o: ${BASHINCDIR}/stdc.h hashlib.h pcomplete.h shell.h syntax.h
pcomplib.o: bashjmp.h command.h general.h error.h variables.h quit.h
pcomplib.o: unwind_prot.h dispose_cmd.h make_cmd.h subst.h sig.h pathnames.h
pcomplib.o: externs.h ${BASHINCDIR}/maxpath.h
pcomplete.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h bashtypes.h
pcomplete.o: ${BASHINCDIR}/stdc.h hashlib.h pcomplete.h shell.h
pcomplete.o: ${BASHINCDIR}/stdc.h hashlib.h pcomplete.h shell.h syntax.h
pcomplete.o: bashjmp.h command.h general.h error.h variables.h quit.h
pcomplete.o: unwind_prot.h dispose_cmd.h make_cmd.h subst.h sig.h pathnames.h
pcomplete.o: externs.h ${BASHINCDIR}/maxpath.h
@ -908,14 +925,14 @@ pcomplete.o: externs.h ${BASHINCDIR}/maxpath.h
bashhist.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/posixstat.h
bashhist.o: ${BASHINCDIR}/filecntl.h
bashhist.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
bashhist.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
bashhist.o: general.h bashtypes.h variables.h array.h hashlib.h
bashhist.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
bashhist.o: make_cmd.h subst.h sig.h pathnames.h externs.h
bashhist.o: flags.h input.h parser.h pathexp.h $(DEFSRC)/common.h bashline.h
bashhist.o: $(GLOB_LIBSRC)/fnmatch.h
bashline.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
bashline.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
bashline.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
bashline.o: general.h bashtypes.h variables.h array.h hashlib.h
bashline.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
bashline.o: make_cmd.h subst.h sig.h pathnames.h externs.h
@ -923,11 +940,11 @@ 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
bracecomp.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
bracecomp.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.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 bashtypes.h variables.h array.h hashlib.h
bracecomp.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
bracecomp.o: make_cmd.h subst.h sig.h pathnames.h externs.h
bracecomp.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h command.h hashlib.h builtins.h general.h
bracecomp.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h command.h hashlib.h builtins.h general.h
bracecomp.o: quit.h alias.h config.h variables.h
bracecomp.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
@ -960,32 +977,32 @@ variables.o: $(TILDE_LIBSRC)/tilde.h
# builtin c sources
builtins/bashgetopt.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
builtins/bashgetopt.o: shell.h config.h bashjmp.h command.h general.h error.h
builtins/bashgetopt.o: shell.h syntax.h config.h bashjmp.h command.h general.h error.h
builtins/bashgetopt.o: variables.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
builtins/bashgetopt.o: make_cmd.h subst.h sig.h pathnames.h externs.h
builtins/bashgetopt.o: $(DEFSRC)/common.h
builtins/common.o: bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
builtins/common.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h command.h
builtins/common.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h command.h
builtins/common.o: ${BASHINCDIR}/memalloc.h variables.h input.h siglist.h
builtins/common.o: quit.h unwind_prot.h ${BASHINCDIR}/maxpath.h jobs.h builtins.h
builtins/common.o: dispose_cmd.h make_cmd.h subst.h externs.h bashhist.h
builtins/common.o: execute_cmd.h ${BASHINCDIR}/stdc.h general.h error.h pathnames.h
builtins/common.o: ${DEFDIR}/builtext.h
builtins/evalfile.o: bashtypes.h ${BASHINCDIR}/posixstat.h ${BASHINCDIR}/filecntl.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
builtins/evalfile.o: shell.h config.h bashjmp.h command.h general.h error.h
builtins/evalfile.o: shell.h syntax.h config.h bashjmp.h command.h general.h error.h
builtins/evalfile.o: variables.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
builtins/evalfile.o: make_cmd.h subst.h sig.h pathnames.h externs.h
builtins/evalfile.o: jobs.h builtins.h flags.h input.h execute_cmd.h
builtins/evalfile.o: bashhist.h $(DEFSRC)/common.h
builtins/evalstring.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
builtins/evalstring.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h command.h siglist.h
builtins/evalstring.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h command.h siglist.h
builtins/evalstring.o: ${BASHINCDIR}/memalloc.h variables.h input.h
builtins/evalstring.o: quit.h unwind_prot.h ${BASHINCDIR}/maxpath.h jobs.h builtins.h
builtins/evalstring.o: dispose_cmd.h make_cmd.h subst.h externs.h
builtins/evalstring.o: jobs.h builtins.h flags.h input.h execute_cmd.h
builtins/evalstring.o: bashhist.h $(DEFSRC)/common.h
builtins/getopt.o: config.h ${BASHINCDIR}/memalloc.h
builtins/getopt.o: shell.h bashjmp.h command.h general.h error.h
builtins/getopt.o: shell.h syntax.h bashjmp.h command.h general.h error.h
builtins/getopt.o: variables.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
builtins/getopt.o: make_cmd.h subst.h sig.h pathnames.h externs.h
builtins/getopt.o: $(DEFSRC)/getopt.h
@ -995,150 +1012,150 @@ builtins/mkbuiltins.o: bashansi.h ${BASHINCDIR}/ansi_stdlib.h
# builtin def files
builtins/alias.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
builtins/alias.o: quit.h $(DEFSRC)/common.h
builtins/alias.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h command.h ${BASHINCDIR}/stdc.h unwind_prot.h
builtins/alias.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h command.h ${BASHINCDIR}/stdc.h unwind_prot.h
builtins/alias.o: dispose_cmd.h make_cmd.h subst.h externs.h variables.h
builtins/bind.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
builtins/bind.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/bind.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/bind.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/bind.o: $(DEFSRC)/bashgetopt.h
builtins/break.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
builtins/break.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/break.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.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 ${BASHINCDIR}/maxpath.h
builtins/builtin.o: quit.h $(DEFSRC)/common.h
builtins/builtin.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/builtin.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.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 ${BASHINCDIR}/maxpath.h
builtins/cd.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/cd.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/cd.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/cd.o: $(DEFSRC)/common.h quit.h
builtins/command.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
builtins/command.o: quit.h $(DEFSRC)/bashgetopt.h
builtins/command.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/command.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/command.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/declare.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
builtins/declare.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/declare.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/declare.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/echo.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
builtins/echo.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/echo.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/echo.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/enable.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
builtins/enable.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/enable.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/enable.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/enable.o: pcomplete.h
builtins/eval.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
builtins/eval.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/eval.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/eval.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/exec.o: bashtypes.h
builtins/exec.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
builtins/exec.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/exec.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/exec.o: dispose_cmd.h make_cmd.h subst.h externs.h execute_cmd.h
builtins/exec.o: findcmd.h flags.h quit.h $(DEFSRC)/common.h ${BASHINCDIR}/stdc.h
builtins/exit.o: bashtypes.h
builtins/exit.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
builtins/exit.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/exit.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/exit.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/fc.o: bashtypes.h ${BASHINCDIR}/posixstat.h
builtins/fc.o: bashansi.h ${BASHINCDIR}/ansi_stdlib.h builtins.h command.h ${BASHINCDIR}/stdc.h
builtins/fc.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
builtins/fc.o: flags.h unwind_prot.h variables.h shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h
builtins/fc.o: flags.h unwind_prot.h variables.h shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.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/fg_bg.o: bashtypes.h
builtins/fg_bg.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
builtins/fg_bg.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/fg_bg.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/fg_bg.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/getopts.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
builtins/getopts.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/getopts.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/getopts.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/hash.o: bashtypes.h
builtins/hash.o: builtins.h command.h findcmd.h ${BASHINCDIR}/stdc.h $(DEFSRC)/common.h
builtins/hash.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
builtins/hash.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/hash.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/help.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
builtins/help.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/help.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/help.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/help.o: $(GLOB_LIBSRC)/glob.h
builtins/history.o: bashtypes.h
builtins/history.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
builtins/history.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/history.o: ${BASHINCDIR}/filecntl.h shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h
builtins/history.o: ${BASHINCDIR}/filecntl.h shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h
builtins/history.o: bashhist.h variables.h
builtins/inlib.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
builtins/inlib.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/inlib.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/inlib.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/jobs.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
builtins/jobs.o: quit.h $(DEFSRC)/bashgetopt.h
builtins/jobs.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/jobs.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/jobs.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/kill.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
builtins/kill.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/kill.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h trap.h unwind_prot.h variables.h
builtins/kill.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h trap.h unwind_prot.h variables.h
builtins/let.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
builtins/let.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/let.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/let.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/printf.o: config.h ${BASHINCDIR}/memalloc.h bashjmp.h command.h error.h
builtins/printf.o: general.h quit.h dispose_cmd.h make_cmd.h subst.h
builtins/printf.o: externs.h sig.h pathnames.h shell.h unwind_prot.h
builtins/printf.o: externs.h sig.h pathnames.h shell.h syntax.h unwind_prot.h
builtins/printf.o: variables.h ${BASHINCDIR}/stdc.h $(DEFSRC)/bashgetopt.h
builtins/pushd.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
builtins/pushd.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/pushd.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/pushd.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/pushd.o: $(DEFSRC)/common.h
builtins/read.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
builtins/read.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/read.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/read.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/return.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
builtins/return.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/return.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/return.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/set.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
builtins/set.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/set.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h flags.h
builtins/set.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h flags.h
builtins/setattr.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
builtins/setattr.o: quit.h $(DEFSRC)/common.h $(DEFSRC)/bashgetopt.h
builtins/setattr.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/setattr.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/setattr.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/shift.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
builtins/shift.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/shift.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/shift.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/shift.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/shopt.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h
builtins/shopt.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h
builtins/shopt.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h unwind_prot.h variables.h ${BASHINCDIR}/maxpath.h
builtins/shopt.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h unwind_prot.h variables.h ${BASHINCDIR}/maxpath.h
builtins/shopt.o: $(DEFSRC)/common.h $(DEFSRC)/bashgetopt.h
builtins/source.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.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 bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/source.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/source.o: findcmd.h
builtins/suspend.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.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 bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/suspend.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/test.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
builtins/test.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/test.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/test.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/test.o: test.h
builtins/times.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
builtins/times.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/times.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/times.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/trap.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
builtins/trap.o: quit.h $(DEFSRC)/common.h
builtins/trap.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/trap.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/trap.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/type.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
builtins/type.o: quit.h $(DEFSRC)/common.h findcmd.h
builtins/type.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/type.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/type.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/ulimit.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
builtins/ulimit.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/ulimit.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/ulimit.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/umask.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
builtins/umask.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/umask.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/umask.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/wait.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
builtins/wait.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/wait.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/wait.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/complete.o: config.h shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h
builtins/complete.o: config.h shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h
builtins/complete.o: unwind_prot.h variables.h
builtins/complete.o: bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
builtins/complete.o: builtins.h

67
NEWS
View file

@ -1,3 +1,70 @@
This is a terse description of the new features added to bash-2.05 since
the release of bash-2.04. As always, the manual page (doc/bash.1) is
the place to look for complete descriptions.
1. New Features in Bash
a. Added a new `--init-file' invocation argument as a synonym for `--rcfile',
per the new GNU coding standards.
b. The /dev/tcp and /dev/udp redirections now accept service names as well as
port numbers.
c. `complete' and `compgen' now take a `-o value' option, which controls some
of the aspects of that compspec. Valid values are:
default - perform bash default completion if programmable
completion produces no matches
dirnames - perform directory name completion if programmable
completion produces no matches
filenames - tell readline that the compspec produces filenames,
so it can do things like append slashes to
directory names and suppress trailing spaces
d. A new loadable builtin, realpath, which canonicalizes and expands symlinks
in pathname arguments.
e. When `set' is called without options, it prints function defintions in a
way that allows them to be reused as input. This affects `declare' and
`declare -p' as well. This only happens when the shell is not in POSIX
mode, since POSIX.2 forbids this behavior.
f. Bash-2.05 once again honors the current locale setting when processing
ranges within pattern matching bracket expressions (e.g., [A-Z]).
2. New Features in Readline
a. The blink timeout for paren matching is now settable by applications,
via the rl_set_paren_blink_timeout() function.
b. _rl_executing_macro has been renamed to rl_executing_macro, which means
it's now part of the public interface.
c. Readline has a new variable, rl_readline_state, which is a bitmap that
encapsulates the current state of the library; intended for use by
callbacks and hook functions.
d. New application-callable function rl_set_prompt(const char *prompt):
expands its prompt string argument and sets rl_prompt to the result.
e. New application-callable function rl_set_screen_size(int rows, int cols):
public method for applications to set readline's idea of the screen
dimensions.
f. New function, rl_get_screen_size (int *rows, int *columns), returns
readline's idea of the screen dimensions.
g. The timeout in rl_gather_tyi (readline keyboard input polling function)
is now settable via a function (rl_set_keyboard_input_timeout()).
h. Renamed the max_input_history variable to history_max_entries; the old
variable is maintained for backwards compatibility.
i. The list of characters that separate words for the history tokenizer is
now settable with a variable: history_word_delimiters. The default
value is as before.
-------------------------------------------------------------------------------
This is a terse description of the new features added to bash-2.04 since
the release of bash-2.03. As always, the manual page (doc/bash.1) is
the place to look for complete descriptions.

57
NOTES
View file

@ -51,9 +51,9 @@ being built and linked against, but there is only a stub file in the archive.)
configure runs and removing the `-lnsl' from the assignment to `LIBS'
fixes the problem.
5. There is a problem with Red Hat Linux's `makewhatis' script.
Running `makewhatis' with bash-2.0 or later versions results
in error messages like this:
5. There is a problem with the `makewhatis' script in older (pre-7.0)
versions of Red Hat Linux. Running `makewhatis' with bash-2.0 or
later versions results in error messages like this:
/usr/sbin/makewhatis: cd: manpath: No such file or directory
/usr/sbin/makewhatis: manpath/whatis: No such file or directory
@ -215,7 +215,8 @@ being built and linked against, but there is only a stub file in the archive.)
It's not possible to build a completely statically-linked binary, since
part of the C library depends on dynamic linking. The following recipe
assumes that you're using gcc and the Solaris ld (/usr/ccs/bin/ld).
assumes that you're using gcc and the Solaris ld (/usr/ccs/bin/ld) on
Solaris 2.5.x or 2.6:
configure --enable-static-link
make STATIC_LD= LOCAL_LIBS='-Wl,-B,dynamic -ldl -Wl,-B,static'
@ -251,6 +252,17 @@ being built and linked against, but there is only a stub file in the archive.)
thor(2)$ ldd bash
libdl.so.1 => /etc/lib/libdl.so.1
On Solaris 7 (and presumably Solaris 8, though I do not run that), the
following recipe appears to work for gcc:
configure --enable-static-link
make STATIC_LD='-Wl,-Bstatic' LOCAL_LIBS='Wl,-Bdynamic -Wl,-R/etc/lib -ldl -Wl,-Bstatic'
thor.ins.cwru.edu(2)$ ldd bash
libdl.so.1 => /etc/lib/libdl.so.1
Make the analogous changes if you are running Sun's C Compiler.
12. Configuring bash to build it in a cross environment. Currently only
two native versions can be compiled this way, cygwin32 and x86 BeOS.
For BeOS, you would configure it like this:
@ -261,3 +273,40 @@ being built and linked against, but there is only a stub file in the archive.)
configure i586-beos
Similarly for cygwin32.
13. Bash-2.05 has 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 specify.
The behavior of the matcher in bash-2.05 depends on the current LC_COLLATE
setting. Setting this variable to `C' or `POSIX' will result in the
traditional behavior ([A-Z] matches all uppercase ASCII characters).
Many other locales, including the en_US locale (the default on many US
versions of Linux) collate the upper and lower case letters like this:
AaBb...Zz
which means that [A-Z] matches every letter except `z'.
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.
Look at the manual pages for setlocale(3), strcoll(3), and, if it is
present, locale(1). If you have locale(1), you can use it to find
your current locale information even if you do not have any of the
LC_ variables set.
My advice is to put
export LC_COLLATE=C
into /etc/profile and inspect any shell scripts run from cron for
constructs like [A-Z]. This will prevent things like
rm [A-Z]*
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.

2
README
View file

@ -1,7 +1,7 @@
Introduction
============
This is GNU Bash, version 2.04. Bash is the GNU Project's Bourne
This is GNU Bash, version 2.05. 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

58
aclocal.m4 vendored
View file

@ -1065,17 +1065,19 @@ fi
])
AC_DEFUN(BASH_CHECK_GETPW_FUNCS,
[AC_MSG_CHECKING(whether programs are able to redeclare getpw functions)
AC_CACHE_VAL(bash_cv_can_redecl_getpw,
[AC_TRY_COMPILE([#include <sys/types.h>
[AC_MSG_CHECKING(whether getpw functions are declared in pwd.h)
AC_CACHE_VAL(bash_cv_getpw_declared,
[AC_EGREP_CPP(getpwuid,
[
#include <sys/types.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <pwd.h>
extern struct passwd *getpwent();
extern struct passwd *getpwuid();
extern struct passwd *getpwnam();],
[struct passwd *z; z = getpwent(); z = getpwuid(0); z = getpwnam("root");],
bash_cv_can_redecl_getpw=yes,bash_cv_can_redecl_getpw=no)])
AC_MSG_RESULT($bash_cv_can_redecl_getpw)
if test $bash_cv_can_redecl_getpw = no; then
],
bash_cv_getpw_declared=yes,bash_cv_getpw_declared=no)])
AC_MSG_RESULT($bash_cv_getpw_declared)
if test $bash_cv_getpw_declared = yes; then
AC_DEFINE(HAVE_GETPW_DECLS)
fi
])
@ -1350,12 +1352,15 @@ dnl causes system calls to be restarted after the signal is caught
dnl
AC_DEFUN(BASH_SYS_RESTARTABLE_SYSCALLS,
[AC_REQUIRE([BASH_SIGNAL_CHECK])
AC_CACHE_CHECK(for restartable system calls with posix sigaction,
AC_CACHE_CHECK(whether posix sigaction restarts system calls by default,
bash_cv_sys_restartable_syscalls,
[AC_TRY_RUN(
[/* Exit 0 (true) if wait returns something other than -1,
i.e. the pid of the child, which means that wait was restarted
after getting the signal. */
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <sys/types.h>
#include <signal.h>
static int caught = 0;
@ -1425,3 +1430,34 @@ if test $bash_cv_struct_timeval = yes; then
AC_DEFINE(HAVE_TIMEVAL)
fi
])
AC_DEFUN(BASH_CHECK_RTSIGS,
[AC_MSG_CHECKING(for unusable real-time signals due to large values)
AC_CACHE_VAL(bash_cv_unusable_rtsigs,
[AC_TRY_RUN([
#include <sys/types.h>
#include <signal.h>
#ifndef NSIG
# define NSIG 64
#endif
main ()
{
int n_sigs = 2 * NSIG;
#ifdef SIGRTMIN
int rtmin = SIGRTMIN;
#else
int rtmin = 0;
#endif
exit(rtmin < n_sigs);
}], bash_cv_unusable_rtsigs=yes, bash_cv_unusable_rtsigs=no,
[AC_MSG_WARN(cannot check real-time signals if cross compiling -- defaulting to yes)
bash_cv_unusable_rtsigs=yes]
)])
AC_MSG_RESULT($bash_cv_unusable_rtsigs)
if test $bash_cv_unusable_rtsigs = yes; then
AC_DEFINE(UNUSABLE_RT_SIGNALS)
fi
])

View file

@ -364,7 +364,7 @@ ARRAY *a;
for (ae = element_forw(a->head); ae != a->head; ae = element_forw(ae)) {
indstr = itos (element_index(ae));
valstr = element_value (ae) ? double_quote (element_value(ae))
valstr = element_value (ae) ? sh_double_quote (element_value(ae))
: (char *)NULL;
elen = STRLEN (indstr) + 8 + STRLEN (valstr);
RESIZE_MALLOCED_BUFFER (result, rlen, (elen + 1), rsize, rsize);
@ -401,7 +401,7 @@ ARRAY *a;
if (sv == 0)
return ((char *)NULL);
vstr = single_quote (sv);
vstr = sh_single_quote (sv);
free (sv);
return (vstr);
}

View file

@ -490,10 +490,10 @@ void
maybe_add_history (line)
char *line;
{
int should_add;
static int first_line_saved = 0;
HIST_ENTRY *temp;
should_add = hist_last_line_added = 0;
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
@ -504,19 +504,24 @@ maybe_add_history (line)
if (current_command_line_count > 1)
#endif
{
if (literal_history || dstack.delimiter_depth != 0 || shell_comment (line) == 0)
if (first_line_saved &&
(literal_history || dstack.delimiter_depth != 0 || shell_comment (line) == 0))
bash_add_history (line);
return;
}
/* 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:
should_add = 1;
first_line_saved = 1;
break;
case 1:
if (*line != ' ')
should_add = 1;
first_line_saved = 1;
break;
case 3:
if (*line == ' ')
@ -527,14 +532,16 @@ maybe_add_history (line)
temp = previous_history ();
if (temp == 0 || STREQ (temp->line, line) == 0)
should_add = 1;
first_line_saved = 1;
using_history ();
break;
}
if (should_add && history_should_ignore (line) == 0)
if (first_line_saved && history_should_ignore (line) == 0)
bash_add_history (line);
else
first_line_saved = 0;
}
/* Add a line to the history list.

File diff suppressed because it is too large Load diff

View file

@ -33,11 +33,11 @@ extern int bash_re_edit __P((char *));
extern int bind_keyseq_to_unix_command __P((char *));
/* Used by programmable completion code. */
extern char *command_word_completion_function __P((char *, int));
extern char *command_word_completion_function __P((const char *, int));
extern char **get_hostname_list __P((void));
extern void clear_hostname_list __P((void));
extern char **bash_directory_completion_matches __P((char *));
extern char **bash_directory_completion_matches __P((const char *));
#endif /* _BASHLINE_H_ */

View file

@ -39,7 +39,7 @@
#include "shell.h"
#include <readline/readline.h>
extern char *backslash_quote ();
extern char *sh_backslash_quote ();
/* Find greatest common prefix of two strings. */
static int
@ -73,8 +73,8 @@ really_munge_braces (array, real_start, real_end, gcd_zero)
if (real_start == real_end)
{
x = array[real_start] ? backslash_quote (array[real_start] + gcd_zero)
: backslash_quote (array[0]);
x = array[real_start] ? sh_backslash_quote (array[real_start] + gcd_zero)
: sh_backslash_quote (array[0]);
return x;
}
@ -113,7 +113,7 @@ really_munge_braces (array, real_start, real_end, gcd_zero)
if (start == end)
{
x = savestring (array[start] + gcd_zero);
subterm = backslash_quote (x);
subterm = sh_backslash_quote (x);
free (x);
}
else
@ -124,7 +124,7 @@ really_munge_braces (array, real_start, real_end, gcd_zero)
x = xmalloc (tlen + 1);
strncpy (x, array[start] + gcd_zero, tlen);
x[tlen] = '\0';
subterm = backslash_quote (x);
subterm = sh_backslash_quote (x);
free (x);
result_size += strlen (subterm) + 1;
result = xrealloc (result, result_size);
@ -147,7 +147,7 @@ really_munge_braces (array, real_start, real_end, gcd_zero)
return (result);
}
static void
static int
hack_braces_completion (names)
char **names;
{
@ -162,18 +162,20 @@ hack_braces_completion (names)
names[i] = NULL;
}
names[0] = temp;
return 0;
}
/* We handle quoting ourselves within hack_braces_completion, so we turn off
rl_filename_quoting_desired and rl_filename_quoting_function. */
void
bash_brace_completion ()
int
bash_brace_completion (count, ignore)
int count, ignore;
{
Function *orig_ignore_func;
Function *orig_entry_func;
CPFunction *orig_quoting_func;
CPPFunction *orig_attempt_func;
int orig_quoting_desired;
rl_compignore_func_t *orig_ignore_func;
rl_compentry_func_t *orig_entry_func;
rl_quote_func_t *orig_quoting_func;
rl_completion_func_t *orig_attempt_func;
int orig_quoting_desired, r;
orig_ignore_func = rl_ignore_some_completions_function;
orig_attempt_func = rl_attempted_completion_function;
@ -181,18 +183,20 @@ bash_brace_completion ()
orig_quoting_func = rl_filename_quoting_function;
orig_quoting_desired = rl_filename_quoting_desired;
rl_completion_entry_function = (Function *) filename_completion_function;
rl_attempted_completion_function = NULL;
rl_ignore_some_completions_function = (Function *) hack_braces_completion;
rl_filename_quoting_function = NULL;
rl_completion_entry_function = rl_filename_completion_function;
rl_attempted_completion_function = (rl_completion_func_t *)NULL;
rl_ignore_some_completions_function = hack_braces_completion;
rl_filename_quoting_function = (rl_quote_func_t *)NULL;
rl_filename_quoting_desired = 0;
rl_complete_internal (TAB);
r = rl_complete_internal (TAB);
rl_ignore_some_completions_function = orig_ignore_func;
rl_attempted_completion_function = orig_attempt_func;
rl_completion_entry_function = orig_entry_func;
rl_filename_quoting_function = orig_quoting_func;
rl_filename_quoting_desired = orig_quoting_desired;
return r;
}
#endif /* BRACE_EXPANSION && READLINE */

View file

@ -239,10 +239,10 @@ brace_gobbler (text, indx, satisfy)
/* A backslash escapes the next character. This allows backslash to
escape the quote character in a double-quoted string. */
if (c == '\\' && (quoted == 0 || quoted == '"' || quoted == '`'))
{
pass_next = 1;
continue;
}
{
pass_next = 1;
continue;
}
if (quoted)
{

View file

@ -213,14 +213,14 @@ complete.o: complete.def
# C files
bashgetopt.o: ../config.h $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h
bashgetopt.o: $(topdir)/shell.h $(topdir)/bashjmp.h
bashgetopt.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/bashjmp.h
bashgetopt.o: $(topdir)/command.h $(topdir)/general.h $(topdir)/error.h
bashgetopt.o: $(topdir)/variables.h $(topdir)/quit.h $(BASHINCDIR)/maxpath.h
bashgetopt.o: $(topdir)/unwind_prot.h $(topdir)/dispose_cmd.h
bashgetopt.o: $(topdir)/make_cmd.h $(topdir)/subst.h $(topdir)/sig.h
bashgetopt.o: $(topdir)/pathnames.h $(topdir)/externs.h $(srcdir)/common.h
common.o: $(topdir)/bashtypes.h $(BASHINCDIR)/posixstat.h $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h
common.o: $(topdir)/shell.h ../config.h $(topdir)/bashjmp.h $(BASHINCDIR)/posixjmp.h
common.o: $(topdir)/shell.h $(topdir)/syntax.h ../config.h $(topdir)/bashjmp.h $(BASHINCDIR)/posixjmp.h
common.o: $(topdir)/sig.h $(topdir)/command.h
common.o: $(topdir)/general.h $(BASHINCDIR)/stdc.h $(BASHINCDIR)/memalloc.h
common.o: $(topdir)/variables.h $(topdir)/input.h
@ -231,7 +231,7 @@ common.o: $(topdir)/subst.h $(topdir)/execute_cmd.h $(topdir)/error.h
common.o: $(topdir)/externs.h $(topdir)/pathnames.h ./builtext.h
evalfile.o: $(topdir)/bashtypes.h $(BASHINCDIR)/posixstat.h ${BASHINCDIR}/filecntl.h
evalfile.o: $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h
evalfile.o: $(topdir)/shell.h ../config.h $(topdir)/bashjmp.h
evalfile.o: $(topdir)/shell.h $(topdir)/syntax.h ../config.h $(topdir)/bashjmp.h
evalfile.o: $(topdir)/command.h $(topdir)/general.h $(topdir)/error.h
evalfile.o: $(topdir)/variables.h $(topdir)/quit.h $(BASHINCDIR)/maxpath.h
evalfile.o: $(topdir)/unwind_prot.h $(topdir)/dispose_cmd.h
@ -241,7 +241,7 @@ evalfile.o: $(topdir)/jobs.h $(topdir)/builtins.h $(topdir)/flags.h
evalfile.o: $(topdir)/input.h $(topdir)/execute_cmd.h
evalfile.o: $(topdir)/bashhist.h $(srcdir)/common.h
evalstring.o: ../config.h $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h
evalstring.o: $(topdir)/shell.h $(topdir)/bashjmp.h $(BASHINCDIR)/posixjmp.h
evalstring.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/bashjmp.h $(BASHINCDIR)/posixjmp.h
evalstring.o: $(topdir)/sig.h $(topdir)/command.h $(topdir)/siglist.h
evalstring.o: $(BASHINCDIR)/memalloc.h $(topdir)/variables.h $(topdir)/input.h
evalstring.o: $(topdir)/quit.h $(topdir)/unwind_prot.h
@ -251,7 +251,7 @@ evalstring.o: $(topdir)/externs.h $(topdir)/jobs.h $(topdir)/builtins.h
evalstring.o: $(topdir)/flags.h $(topdir)/input.h $(topdir)/execute_cmd.h
evalstring.o: $(topdir)/bashhist.h $(srcdir)/common.h
getopt.o: ../config.h $(BASHINCDIR)/memalloc.h
getopt.o: $(topdir)/shell.h $(topdir)/bashjmp.h $(topdir)/command.h
getopt.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/bashjmp.h $(topdir)/command.h
getopt.o: $(topdir)/general.h $(topdir)/error.h $(topdir)/variables.h
getopt.o: $(topdir)/quit.h $(BASHINCDIR)/maxpath.h $(topdir)/unwind_prot.h
getopt.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
@ -266,61 +266,61 @@ alias.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
alias.o: $(topdir)/error.h $(topdir)/general.h $(BASHINCDIR)/maxpath.h
alias.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
alias.o: $(topdir)/subst.h $(topdir)/externs.h $(srcdir)/common.h
alias.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
alias.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
bind.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
bind.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
bind.o: $(topdir)/subst.h $(topdir)/externs.h $(srcdir)/bashgetopt.h
bind.o: $(topdir)/general.h $(BASHINCDIR)/maxpath.h $(topdir)/bashline.h
bind.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
bind.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
break.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
break.o: $(topdir)/error.h $(topdir)/general.h
break.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
break.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
break.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
break.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
builtin.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
builtin.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/externs.h
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)/unwind_prot.h $(topdir)/variables.h
builtin.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
cd.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
cd.o: $(topdir)/general.h $(topdir)/quit.h $(topdir)/dispose_cmd.h
cd.o: $(topdir)/make_cmd.h $(topdir)/subst.h $(topdir)/externs.h
cd.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
cd.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
cd.o: $(srcdir)/common.h $(BASHINCDIR)/maxpath.h
command.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
command.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/externs.h
command.o: $(topdir)/quit.h $(srcdir)/bashgetopt.h $(BASHINCDIR)/maxpath.h
command.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
command.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
command.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
declare.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
declare.o: $(topdir)/error.h $(topdir)/general.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)/unwind_prot.h $(topdir)/variables.h
declare.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
echo.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
echo.o: $(topdir)/general.h $(topdir)/subst.h $(topdir)/externs.h
echo.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
echo.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
echo.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
echo.o: $(BASHINCDIR)/maxpath.h
enable.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
enable.o: $(topdir)/error.h $(topdir)/general.h
enable.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
enable.o: $(topdir)/subst.h $(topdir)/externs.h
enable.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
enable.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
enable.o: $(BASHINCDIR)/maxpath.h
enable.o: $(topdir)/pcomplete.h
eval.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
eval.o: $(topdir)/error.h $(topdir)/general.h
eval.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
eval.o: $(topdir)/subst.h $(topdir)/externs.h
eval.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
eval.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
eval.o: $(BASHINCDIR)/maxpath.h
exec.o: $(topdir)/bashtypes.h
exec.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
exec.o: $(topdir)/error.h $(topdir)/general.h
exec.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
exec.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/flags.h
exec.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
exec.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
exec.o: $(srcdir)/common.h $(topdir)/execute_cmd.h $(BASHINCDIR)/maxpath.h
exec.o: $(topdir)/findcmd.h
exit.o: $(topdir)/bashtypes.h
@ -328,7 +328,7 @@ exit.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
exit.o: $(topdir)/error.h $(topdir)/general.h
exit.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
exit.o: $(topdir)/subst.h $(topdir)/externs.h
exit.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
exit.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
exit.o: $(BASHINCDIR)/maxpath.h ./builtext.h
fc.o: $(topdir)/bashtypes.h $(BASHINCDIR)/posixstat.h
fc.o: $(topdir)/builtins.h $(topdir)/command.h $(srcdir)/bashgetopt.h
@ -336,7 +336,7 @@ fc.o: $(topdir)/bashhist.h
fc.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
fc.o: $(topdir)/general.h $(BASHINCDIR)/maxpath.h
fc.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
fc.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/shell.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
fc.o: $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h
fg_bg.o: $(topdir)/bashtypes.h
@ -344,147 +344,147 @@ fg_bg.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
fg_bg.o: $(topdir)/error.h $(topdir)/general.h
fg_bg.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
fg_bg.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
fg_bg.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
fg_bg.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
getopts.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
getopts.o: $(topdir)/error.h $(topdir)/general.h
getopts.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
getopts.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
getopts.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
getopts.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
hash.o: $(topdir)/builtins.h $(topdir)/command.h $(topdir)/quit.h
hash.o: $(topdir)/findcmd.h $(topdir)/hashlib.h
hash.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
hash.o: $(topdir)/error.h $(topdir)/general.h
hash.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
hash.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
hash.o: $(srcdir)/common.h $(BASHINCDIR)/maxpath.h
help.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
help.o: $(topdir)/error.h $(topdir)/general.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)/unwind_prot.h $(topdir)/variables.h
help.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
history.o: $(topdir)/bashtypes.h
history.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
history.o: $(topdir)/error.h $(topdir)/general.h
history.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
history.o: $(topdir)/subst.h $(topdir)/externs.h
history.o: ${BASHINCDIR}/filecntl.h $(topdir)/shell.h $(topdir)/unwind_prot.h
history.o: ${BASHINCDIR}/filecntl.h $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h
history.o: $(topdir)/variables.h $(topdir)/bashhist.h $(BASHINCDIR)/maxpath.h
inlib.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
inlib.o: $(topdir)/error.h $(topdir)/general.h
inlib.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
inlib.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
inlib.o: $(BASHINCDIR)/maxpath.h $(topdir)/subst.h $(topdir)/externs.h
inlib.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
jobs.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
jobs.o: $(topdir)/general.h $(topdir)/quit.h $(srcdir)/bashgetopt.h
jobs.o: $(BASHINCDIR)/maxpath.h $(topdir)/externs.h
jobs.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
jobs.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
jobs.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
kill.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
kill.o: $(topdir)/general.h $(topdir)/subst.h $(topdir)/externs.h
kill.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
kill.o: $(topdir)/shell.h $(topdir)/trap.h $(topdir)/unwind_prot.h
kill.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/trap.h $(topdir)/unwind_prot.h
kill.o: $(topdir)/variables.h $(BASHINCDIR)/maxpath.h
let.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
let.o: $(topdir)/error.h $(topdir)/general.h
let.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
let.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
let.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
let.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
printf.o: ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/bashjmp.h
printf.o: $(topdir)/command.h $(topdir)/error.h $(topdir)/general.h
printf.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
printf.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/sig.h
printf.o: $(topdir)/pathnames.h $(topdir)/shell.h $(topdir)/unwind_prot.h
printf.o: $(topdir)/pathnames.h $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h
printf.o: $(topdir)/variables.h $(BASHINCDIR)/stdc.h $(srcdir)/bashgetopt.h
pushd.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
pushd.o: $(topdir)/error.h $(topdir)/general.h
pushd.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
pushd.o: $(topdir)/subst.h $(topdir)/externs.h
pushd.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
pushd.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
pushd.o: $(BASHINCDIR)/maxpath.h $(srcdir)/common.h ./builtext.h
read.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
read.o: $(topdir)/error.h $(topdir)/general.h
read.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
read.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
read.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
read.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
read.o: $(BASHINCDIR)/shtty.h
return.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
return.o: $(topdir)/error.h $(topdir)/general.h
return.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
return.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
return.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
return.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
set.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
set.o: $(topdir)/general.h $(topdir)/subst.h $(topdir)/externs.h
set.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
set.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
set.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
set.o: $(BASHINCDIR)/maxpath.h $(topdir)/error.h
setattr.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
setattr.o: $(topdir)/error.h $(topdir)/general.h $(BASHINCDIR)/maxpath.h
setattr.o: $(topdir)/quit.h $(srcdir)/common.h $(srcdir)/bashgetopt.h
setattr.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
setattr.o: $(topdir)/externs.h
setattr.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
setattr.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
shift.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
shift.o: $(topdir)/error.h $(topdir)/general.h
shift.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
shift.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
shift.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
shift.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
source.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
source.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/findcmd.h
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)/unwind_prot.h $(topdir)/variables.h
source.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
suspend.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
suspend.o: $(topdir)/error.h $(topdir)/general.h
suspend.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
suspend.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
suspend.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
suspend.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
test.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
test.o: $(topdir)/error.h $(topdir)/general.h
test.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
test.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
test.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
test.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
test.o: $(topdir)/test.h
times.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
times.o: $(topdir)/error.h $(topdir)/general.h
times.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
times.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
times.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
times.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
times.o: $(BASHINCDIR)/posixtime.h
trap.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
trap.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/externs.h
trap.o: $(topdir)/quit.h $(srcdir)/common.h $(BASHINCDIR)/maxpath.h
trap.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
trap.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
trap.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
trap.o: $(topdir)/findcmd.h
type.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
type.o: $(topdir)/error.h $(topdir)/general.h
type.o: $(topdir)/quit.h $(srcdir)/common.h $(BASHINCDIR)/maxpath.h
type.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
type.o: $(topdir)/externs.h $(topdir)/hashcmd.h
type.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
type.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
ulimit.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
ulimit.o: $(topdir)/error.h $(topdir)/general.h
ulimit.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
ulimit.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
ulimit.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
ulimit.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
umask.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
umask.o: $(topdir)/error.h $(topdir)/general.h
umask.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
umask.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
umask.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
umask.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
wait.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
wait.o: $(topdir)/error.h $(topdir)/general.h
wait.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
wait.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
wait.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
wait.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
shopt.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
shopt.o: $(topdir)/error.h $(topdir)/general.h
shopt.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
shopt.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
shopt.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
shopt.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
shopt.o: $(srcdir)/common.h $(srcdir)/bashgetopt.h
complete.o: ../config.h
complete.o: ${topdir}/shell.h ${topdir}/bashjmp.h ${BASHINCDIR}/posixjmp.h ${topdir}/sig.h
complete.o: ${topdir}/shell.h $(topdir)/syntax.h ${topdir}/bashjmp.h ${BASHINCDIR}/posixjmp.h ${topdir}/sig.h
complete.o: ${topdir}/unwind_prot.h ${topdir}/variables.h
complete.o: ${topdir}/bashtypes.h ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
complete.o: ${topdir}/builtins.h

View file

@ -198,7 +198,7 @@ print_alias (alias)
{
char *value;
value = single_quote (alias->value);
value = sh_single_quote (alias->value);
printf ("alias %s=%s\n", alias->name, value);
free (value);

View file

@ -189,10 +189,10 @@ bind_builtin (list)
{
kmap = rl_get_keymap_by_name (map_name);
if (!kmap)
{
{
builtin_error ("`%s': invalid keymap name", map_name);
BIND_RETURN (EXECUTION_FAILURE);
}
}
}
if (kmap)

View file

@ -40,6 +40,7 @@ $END
#include "common.h"
extern char *this_command_name;
extern int posixly_correct;
static int check_loop_level ();
@ -61,7 +62,7 @@ break_builtin (list)
int newbreak;
if (check_loop_level () == 0)
return (EXECUTION_FAILURE);
return (EXECUTION_SUCCESS);
newbreak = get_numeric_arg (list, 1);
@ -96,7 +97,7 @@ continue_builtin (list)
int newcont;
if (check_loop_level () == 0)
return (EXECUTION_FAILURE);
return (EXECUTION_SUCCESS);
newcont = get_numeric_arg (list, 1);
@ -121,7 +122,7 @@ static int
check_loop_level ()
{
#if defined (BREAK_COMPLAINS)
if (loop_level == 0)
if (loop_level == 0 && posixly_correct == 0)
builtin_error ("only meaningful in a `for', `while', or `until' loop");
#endif /* BREAK_COMPLAINS */

View file

@ -60,7 +60,6 @@ extern char *bash_getcwd_errstr;
static int change_to_directory ();
static char *cdspell ();
static int spname (), mindist (), spdist ();
/* Change this to 1 to get cd spelling correction by default. */
int cdspelling = 0;
@ -91,15 +90,10 @@ bindpwd (no_symlinks)
int old_symlinks, old_anm;
SHELL_VAR *tvar;
if (no_symlinks)
{
old_symlinks = no_symbolic_links;
no_symbolic_links = 1;
dirname = get_working_directory ("cd");
no_symbolic_links = old_symlinks;
}
else
dirname = get_working_directory ("cd");
#define tcwd the_current_working_directory
dirname = tcwd ? (no_symlinks ? sh_physpath (tcwd, 0) : tcwd)
: get_working_directory ("cd");
#undef tcwd
old_anm = array_needs_making;
pwdvar = get_string_value ("PWD");
@ -118,10 +112,16 @@ bindpwd (no_symlinks)
array_needs_making = 0;
}
FREE (dirname);
if (dirname && dirname != the_current_working_directory)
free (dirname);
return (EXECUTION_SUCCESS);
}
#define LCD_DOVARS 0x001
#define LCD_DOSPELL 0x002
#define LCD_PRINTPATH 0x004
#define LCD_FREEDIRNAME 0x010
/* This builtin is ultimately the way that all user-visible commands should
change the current working directory. It is called by cd_to_string (),
so the programming interface is simple, and it handles errors and
@ -131,8 +131,7 @@ cd_builtin (list)
WORD_LIST *list;
{
char *dirname, *cdpath, *path, *temp;
int path_index, no_symlinks, opt;
struct stat sb;
int path_index, no_symlinks, opt, lflag;
#if defined (RESTRICTED_SHELL)
if (restricted)
@ -161,6 +160,9 @@ cd_builtin (list)
}
list = loptend;
lflag = (cdable_vars ? LCD_DOVARS : 0) |
((interactive && cdspelling) ? LCD_DOSPELL : 0);
if (list == 0)
{
/* `cd' without arguments is equivalent to `cd $HOME' */
@ -171,118 +173,106 @@ cd_builtin (list)
builtin_error ("HOME not set");
return (EXECUTION_FAILURE);
}
if (change_to_directory (dirname, no_symlinks) == 0)
{
builtin_error ("%s: %s", dirname, strerror (errno));
return (EXECUTION_FAILURE);
}
lflag = 0;
}
else if (list->word->word[0] == '-' && list->word->word[1] == '\0')
{
/* This is `cd -', equivalent to `cd $OLDPWD' */
dirname = get_string_value ("OLDPWD");
if (dirname == 0 || change_to_directory (dirname, no_symlinks) == 0)
if (dirname == 0)
{
if (dirname == 0)
builtin_error ("OLDPWD not set");
else
builtin_error ("%s: %s", dirname, strerror (errno));
builtin_error ("OLDPWD not set");
return (EXECUTION_FAILURE);
}
if (interactive)
printf ("%s\n", dirname);
lflag = interactive ? LCD_PRINTPATH : 0;
}
else
else if (absolute_pathname (list->word->word))
dirname = list->word->word;
else if (cdpath = get_string_value ("CDPATH"))
{
dirname = list->word->word;
if (absolute_pathname (dirname) == 0 && (cdpath = get_string_value ("CDPATH")))
/* Find directory in $CDPATH. */
path_index = 0;
while (path = extract_colon_unit (cdpath, &path_index))
{
/* Find directory in $CDPATH. */
path_index = 0;
while (path = extract_colon_unit (cdpath, &path_index))
/* OPT is 1 if the path element is non-empty */
opt = path[0] != '\0';
temp = sh_makepath (path, dirname, MP_DOTILDE);
free (path);
if (change_to_directory (temp, no_symlinks))
{
/* OPT is 1 if the path element is non-empty */
opt = path[0] != '\0';
temp = sh_makepath (path, dirname, MP_DOTILDE);
free (path);
/* POSIX.2 says that if a nonempty directory from CDPATH
is used to find the directory to change to, the new
directory name is echoed to stdout, whether or not
the shell is interactive. */
if (opt)
printf ("%s\n", no_symlinks ? temp : the_current_working_directory);
if (stat (temp, &sb) < 0 || S_ISDIR (sb.st_mode) == 0)
{
free (temp);
continue;
}
if (change_to_directory (temp, no_symlinks))
{
/* POSIX.2 says that if a nonempty directory from CDPATH
is used to find the directory to change to, the new
directory name is echoed to stdout, whether or not
the shell is interactive. */
if (opt)
printf ("%s\n", no_symlinks ? temp : the_current_working_directory);
free (temp);
/* Posix.2 says that after using CDPATH, the resultant
value of $PWD will not contain symlinks. */
return (bindpwd (posixly_correct || no_symlinks));
}
else
free (temp);
}
/* POSIX.2 says that if `.' does not appear in $CDPATH, we don't
try the current directory, so we just punt now with an error
message if POSIXLY_CORRECT is non-zero. The check for cdpath[0]
is so we don't mistakenly treat a CDPATH value of "" as not
specifying the current directory. */
if (posixly_correct && cdpath[0])
{
builtin_error ("%s: %s", dirname, strerror (ENOENT));
return (EXECUTION_FAILURE);
free (temp);
/* Posix.2 says that after using CDPATH, the resultant
value of $PWD will not contain `.' or `..'. */
return (bindpwd (posixly_correct || no_symlinks));
}
else
free (temp);
}
if (change_to_directory (dirname, no_symlinks))
return (bindpwd (no_symlinks));
/* If the user requests it, then perhaps this is the name of
a shell variable, whose value contains the directory to
change to. If that is the case, then change to that
directory. */
if (cdable_vars)
/* POSIX.2 says that if `.' does not appear in $CDPATH, we don't
try the current directory, so we just punt now with an error
message if POSIXLY_CORRECT is non-zero. The check for cdpath[0]
is so we don't mistakenly treat a CDPATH value of "" as not
specifying the current directory. */
if (posixly_correct && cdpath[0])
{
temp = get_string_value (dirname);
if (temp && change_to_directory (temp, no_symlinks))
{
printf ("%s\n", temp);
return (bindpwd (no_symlinks));
}
builtin_error ("%s: %s", dirname, strerror (ENOENT));
return (EXECUTION_FAILURE);
}
}
else
dirname = list->word->word;
/* If the user requests it, try to find a directory name similar in
spelling to the one requested, in case the user made a simple
typo. This is similar to the UNIX 8th and 9th Edition shells. */
if (interactive && cdspelling)
{
temp = cdspell (dirname);
if (temp && change_to_directory (temp, no_symlinks))
{
printf ("%s\n", temp);
free (temp);
return (bindpwd (no_symlinks));
}
else
FREE (temp);
}
builtin_error ("%s: %s", dirname, strerror (errno));
return (EXECUTION_FAILURE);
/* When we get here, DIRNAME is the directory to change to. If we
chdir successfully, just return. */
if (change_to_directory (dirname, no_symlinks))
{
if (lflag & LCD_PRINTPATH)
printf ("%s\n", dirname);
return (bindpwd (no_symlinks));
}
return (bindpwd (no_symlinks));
/* If the user requests it, then perhaps this is the name of
a shell variable, whose value contains the directory to
change to. */
if (lflag & LCD_DOVARS)
{
temp = get_string_value (dirname);
if (temp && change_to_directory (temp, no_symlinks))
{
printf ("%s\n", temp);
return (bindpwd (no_symlinks));
}
}
/* If the user requests it, try to find a directory name similar in
spelling to the one requested, in case the user made a simple
typo. This is similar to the UNIX 8th and 9th Edition shells. */
if (lflag & LCD_DOSPELL)
{
temp = cdspell (dirname);
if (temp && change_to_directory (temp, no_symlinks))
{
printf ("%s\n", temp);
return (bindpwd (no_symlinks));
}
else
FREE (temp);
}
builtin_error ("%s: %s", dirname, strerror (errno));
return (EXECUTION_FAILURE);
}
$BUILTIN pwd
@ -302,7 +292,7 @@ int
pwd_builtin (list)
WORD_LIST *list;
{
char *directory, *buffer;
char *directory;
int opt;
verbatim_pwd = no_symbolic_links;
@ -324,25 +314,23 @@ pwd_builtin (list)
}
list = loptend;
if (verbatim_pwd)
{
buffer = xmalloc (PATH_MAX);
directory = getcwd (buffer, PATH_MAX);
#define tcwd the_current_working_directory
if (directory == 0)
{
builtin_error ("%s: %s", bash_getcwd_errstr, strerror (errno));
free (buffer);
}
}
else
directory = get_working_directory ("pwd");
directory = tcwd ? (verbatim_pwd ? sh_physpath (tcwd, 0) : tcwd)
: get_working_directory ("pwd");
#undef tcwd
if (directory)
{
printf ("%s\n", directory);
if (directory != the_current_working_directory)
free (directory);
fflush (stdout);
free (directory);
if (ferror (stdout))
{
builtin_error ("write error: %s", strerror (errno));
return (EXECUTION_FAILURE);
}
return (EXECUTION_SUCCESS);
}
else
@ -350,83 +338,79 @@ pwd_builtin (list)
}
/* Do the work of changing to the directory NEWDIR. Handle symbolic
link following, etc. */
link following, etc. This function *must* return with
the_current_working_directory either set to NULL (in which case
getcwd() will eventually be called), or set to a string corresponding
to the working directory. Return 1 on success, 0 on failure. */
static int
change_to_directory (newdir, nolinks)
char *newdir;
int nolinks;
{
char *t;
char *t, *tdir;
int err;
if (nolinks == 0)
tdir = (char *)NULL;
if (the_current_working_directory == 0)
{
int chdir_return = 0;
char *tdir = (char *)NULL;
t = get_working_directory ("chdir");
FREE (t);
}
if (the_current_working_directory == 0)
{
t = get_working_directory ("cd_links");
FREE (t);
}
t = make_absolute (newdir, the_current_working_directory);
if (the_current_working_directory)
t = make_absolute (newdir, the_current_working_directory);
else
t = savestring (newdir);
/* TDIR is either the canonicalized absolute pathname of NEWDIR
(nolinks == 0) or the absolute physical pathname of NEWDIR
(nolinks != 0). */
tdir = nolinks ? sh_physpath (t, 0)
: sh_canonpath (t, PATH_CHECKDOTDOT|PATH_CHECKEXISTS);
/* TDIR is the canonicalized absolute pathname of the NEWDIR. */
tdir = canonicalize_pathname (t);
/* Use the canonicalized version of NEWDIR, or, if canonicalization
failed, use the non-canonical form. */
if (tdir && *tdir)
free (t);
else
{
FREE (tdir);
tdir = t;
}
/* Use the canonicalized version of NEWDIR, or, if canonicalization
failed, use the non-canonical form. */
if (tdir && *tdir)
free (t);
else
{
FREE (tdir);
tdir = t;
}
/* If the chdir succeeds, update the_current_working_directory. */
if (chdir (nolinks ? newdir : tdir) == 0)
{
FREE (the_current_working_directory);
the_current_working_directory = tdir;
if (chdir (tdir) < 0)
{
int err;
return (1);
}
chdir_return = 0;
free (tdir);
/* We failed to change to the appropriate directory name. If we tried
what the user passed (nolinks != 0), punt now. */
if (nolinks)
return (0);
err = errno;
err = errno;
free (tdir);
/* We failed changing to the canonicalized directory name. Try
what the user passed verbatim. If we succeed, reinitialize
the_current_working_directory. */
if (chdir (newdir) == 0)
{
chdir_return = 1;
if (the_current_working_directory)
{
free (the_current_working_directory);
the_current_working_directory = (char *)NULL;
}
/* We're not in physical mode (nolinks == 0), but we failed to change to
the canonicalized directory name (TDIR). Try what the user passed
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");
FREE (tdir);
tdir = get_working_directory ("cd");
FREE (tdir);
}
else
errno = err;
}
else
{
chdir_return = 1;
FREE (the_current_working_directory);
the_current_working_directory = tdir;
}
return (chdir_return);
return (1);
}
else
return (chdir (newdir) == 0);
{
errno = err;
return (0);
}
}
/* Code for cd spelling correction. Original patch submitted by
@ -453,147 +437,3 @@ cdspell (dirname)
return guess;
}
}
/*
* `spname' and its helpers are inspired by the code in "The UNIX
* Programming Environment, Kernighan & Pike, Prentice-Hall 1984",
* pages 209 - 213.
*/
/*
* `spname' -- return a correctly spelled filename
*
* int spname(char * oldname, char * newname)
* Returns: -1 if no reasonable match found
* 0 if exact match found
* 1 if corrected
* Stores corrected name in `newname'.
*/
static int
spname(oldname, newname)
char *oldname;
char *newname;
{
char *op, *np, *p;
char guess[PATH_MAX + 1], best[PATH_MAX + 1];
op = oldname;
np = newname;
for (;;)
{
while (*op == '/') /* Skip slashes */
*np++ = *op++;
*np = '\0';
if (*op == '\0') /* Exact or corrected */
{
/* `.' is rarely the right thing. */
if (oldname[1] == '\0' && newname[1] == '\0' &&
oldname[0] != '.' && newname[0] == '.')
return -1;
return strcmp(oldname, newname) != 0;
}
/* Copy next component into guess */
for (p = guess; *op != '/' && *op != '\0'; op++)
if (p < guess + PATH_MAX)
*p++ = *op;
*p = '\0';
if (mindist(newname, guess, best) >= 3)
return -1; /* Hopeless */
/*
* Add to end of newname
*/
for (p = best; *np = *p++; np++)
;
}
}
/*
* Search directory for a guess
*/
static int
mindist(dir, guess, best)
char *dir;
char *guess;
char *best;
{
DIR *fd;
struct dirent *dp;
int dist, x;
dist = 3; /* Worst distance */
if (*dir == '\0')
dir = ".";
if ((fd = opendir(dir)) == NULL)
return dist;
while ((dp = readdir(fd)) != NULL)
{
/*
* Look for a better guess. If the new guess is as
* good as the current one, we take it. This way,
* any single character match will be a better match
* than ".".
*/
x = spdist(dp->d_name, guess);
if (x <= dist && x != 3)
{
strcpy(best, dp->d_name);
dist = x;
if (dist == 0) /* Exact match */
break;
}
}
(void)closedir(fd);
/* Don't return `.' */
if (best[0] == '.' && best[1] == '\0')
dist = 3;
return dist;
}
/*
* `spdist' -- return the "distance" between two names.
*
* int spname(char * oldname, char * newname)
* Returns: 0 if strings are identical
* 1 if two characters are transposed
* 2 if one character is wrong, added or deleted
* 3 otherwise
*/
static int
spdist(cur, new)
char *cur, *new;
{
while (*cur == *new)
{
if (*cur == '\0')
return 0; /* Exact match */
cur++;
new++;
}
if (*cur)
{
if (*new)
{
if (cur[1] && new[1] && cur[0] == new[1] && cur[1] == new[0] && strcmp (cur + 2, new + 2) == 0)
return 1; /* Transposition */
if (strcmp (cur + 1, new + 1) == 0)
return 2; /* One character mismatch */
}
if (strcmp(&cur[1], &new[0]) == 0)
return 2; /* Extra character */
}
if (*new && strcmp(cur, new + 1) == 0)
return 2; /* Missing character */
return 3;
}

View file

@ -327,7 +327,7 @@ set_dollar_vars_changed ()
/* **************************************************************** */
/* */
/* Validating numeric input and arguments */
/* Validating numeric input and arguments */
/* */
/* **************************************************************** */
@ -371,10 +371,10 @@ read_octal (string)
int result, digits;
result = digits = 0;
while (*string && *string >= '0' && *string < '8')
while (*string && ISOCTAL (*string))
{
digits++;
result = (result * 8) + *string++ - '0';
result = (result * 8) + (*string++ - '0');
}
if (!digits || result > 0777 || *string)
@ -416,10 +416,7 @@ get_working_directory (for_whom)
{
fprintf (stderr, "%s: could not get current directory: %s: %s\n",
(for_whom && *for_whom) ? for_whom : get_name_for_error (),
the_current_working_directory[0]
? the_current_working_directory
: bash_getcwd_errstr,
strerror (errno));
bash_getcwd_errstr, strerror (errno));
free (the_current_working_directory);
the_current_working_directory = (char *)NULL;
@ -710,221 +707,3 @@ initialize_shell_builtins ()
qsort (shell_builtins, num_shell_builtins, sizeof (struct builtin),
(QSFUNC *)shell_builtin_compare);
}
/* **************************************************************** */
/* */
/* Functions for quoting strings to be re-read as input */
/* */
/* **************************************************************** */
/* Return a new string which is the single-quoted version of STRING.
Used by alias and trap, among others. */
char *
single_quote (string)
char *string;
{
register int c;
char *result, *r, *s;
result = (char *)xmalloc (3 + (4 * strlen (string)));
r = result;
*r++ = '\'';
for (s = string; s && (c = *s); s++)
{
*r++ = c;
if (c == '\'')
{
*r++ = '\\'; /* insert escaped single quote */
*r++ = '\'';
*r++ = '\''; /* start new quoted string */
}
}
*r++ = '\'';
*r = '\0';
return (result);
}
/* Quote STRING using double quotes. Return a new string. */
char *
double_quote (string)
char *string;
{
register int c;
char *result, *r, *s;
result = (char *)xmalloc (3 + (2 * strlen (string)));
r = result;
*r++ = '"';
for (s = string; s && (c = *s); s++)
{
switch (c)
{
case '"':
case '$':
case '`':
case '\\':
case '\n': /* XXX */
*r++ = '\\';
default:
*r++ = c;
break;
}
}
*r++ = '"';
*r = '\0';
return (result);
}
/* Remove backslashes that are quoting characters that are special between
double quotes. Return a new string. */
char *
un_double_quote (string)
char *string;
{
register int c, pass_next;
char *result, *r, *s;
r = result = xmalloc (strlen (string) + 1);
for (pass_next = 0, s = string; s && (c = *s); s++)
{
if (pass_next)
{
*r++ = c;
pass_next = 0;
continue;
}
if (c == '\\' && strchr (slashify_in_quotes, s[1]))
{
pass_next = 1;
continue;
}
*r++ = c;
}
*r = '\0';
return result;
}
/* Quote special characters in STRING using backslashes. Return a new
string. */
char *
backslash_quote (string)
char *string;
{
int c;
char *result, *r, *s;
result = xmalloc (2 * strlen (string) + 1);
for (r = result, s = string; s && (c = *s); s++)
{
switch (c)
{
case ' ': case '\t': case '\n': /* IFS white space */
case '\'': case '"': case '\\': /* quoting chars */
case '|': case '&': case ';': /* shell metacharacters */
case '(': case ')': case '<': case '>':
case '!': case '{': case '}': /* reserved words */
case '*': case '[': case '?': case ']': /* globbing chars */
case '^':
case '$': case '`': /* expansion chars */
*r++ = '\\';
*r++ = c;
break;
#if 0
case '~': /* tilde expansion */
if (s == string || s[-1] == '=' || s[-1] == ':')
*r++ = '\\';
*r++ = c;
break;
#endif
case '#': /* comment char */
if (s == string)
*r++ = '\\';
/* FALLTHROUGH */
default:
*r++ = c;
break;
}
}
*r = '\0';
return (result);
}
#if defined (PROMPT_STRING_DECODE)
/* Quote characters that get special treatment when in double quotes in STRING
using backslashes. Return a new string. */
char *
backslash_quote_for_double_quotes (string)
char *string;
{
int c;
char *result, *r, *s;
result = xmalloc (2 * strlen (string) + 1);
for (r = result, s = string; s && (c = *s); s++)
{
switch (c)
{
case '"':
case '$':
case '`':
case '\\':
case '\n':
*r++ = '\\';
*r++ = c;
break;
default:
*r++ = c;
break;
}
}
*r = '\0';
return (result);
}
#endif /* PROMPT_STRING_DECODE */
int
contains_shell_metas (string)
char *string;
{
char *s;
for (s = string; s && *s; s++)
{
switch (*s)
{
case ' ': case '\t': case '\n': /* IFS white space */
case '\'': case '"': case '\\': /* quoting chars */
case '|': case '&': case ';': /* shell metacharacters */
case '(': case ')': case '<': case '>':
case '!': case '{': case '}': /* reserved words */
case '*': case '[': case '?': case ']': /* globbing chars */
case '^':
case '$': case '`': /* expansion chars */
return (1);
case '~': /* tilde expansion */
if (s == string || s[-1] == '=' || s[-1] == ':')
return (1);
case '#':
if (s == string) /* comment char */
return (1);
/* FALLTHROUGH */
default:
break;
}
}
return (0);
}

View file

@ -70,13 +70,6 @@ extern Function *builtin_address __P((char *));
extern Function *find_special_builtin __P((char *));
extern void initialize_shell_builtins __P((void));
extern char *single_quote __P((char *));
extern char *double_quote __P((char *));
extern char *un_double_quote __P((char *));
extern char *backslash_quote __P((char *));
extern char *backslash_quote_for_double_quotes __P((char *));
extern int contains_shell_metas __P((char *));
/* Functions from set.def */
extern void initialize_shell_options __P((int));
extern void list_minus_o_opts __P((int, int));
@ -111,5 +104,6 @@ extern void parse_and_execute_cleanup __P((void));
/* Functions from evalfile.c */
extern int maybe_execute_file __P((char *, int));
extern int source_file __P((char *));
extern int fc_execute_file __P((char *));
#endif /* !__COMMON_H */

View file

@ -24,7 +24,7 @@ $PRODUCES complete.c
$BUILTIN complete
$DEPENDS_ON PROGRAMMABLE_COMPLETION
$FUNCTION complete_builtin
$SHORT_DOC complete [-abcdefjkvu] [-pr] [-A action] [-G globpat] [-W wordlist] [-P prefix] [-S suffix] [-X filterpat] [-F function] [-C command] [name ...]
$SHORT_DOC complete [-abcdefjkvu] [-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
@ -90,6 +90,16 @@ static struct _compacts {
{ (char *)NULL, 0, 0 },
};
static struct _compopt {
char *optname;
int optflag;
} compopts[] = {
{ "default", COPT_DEFAULT },
{ "dirnames", COPT_DIRNAMES },
{ "filenames",COPT_FILENAMES},
{ (char *)NULL, 0 },
};
static int
find_compact (name)
char *name;
@ -102,32 +112,46 @@ find_compact (name)
return -1;
}
/* Build the actions from the options specified in LIST. ACTP is a pointer
to an unsigned long in which to place the bitmap of actions. PP, if
non-null, gets 1 if -p is supplied; RP, if non-null, gets 1 if -r is
supplied. If either is null, the corresponding option generates an
error. This also sets variables corresponding to options that take
arguments as a side effect; the caller should ensure that those variables
are set to NULL before calling build_actions. Return value:
static int
find_compopt (name)
char *name;
{
register int i;
for (i = 0; compopts[i].optname; i++)
if (STREQ (name, compopts[i].optname))
return i;
return -1;
}
/* Build the actions and compspec options from the options specified in LIST.
ACTP is a pointer to an unsigned long in which to place the bitmap of
actions. OPTP is a pointer to an unsigned long in which to place the
btmap of compspec options (arguments to `-o'). PP, if non-null, gets 1
if -p is supplied; RP, if non-null, gets 1 if -r is supplied.
If either is null, the corresponding option generates an error.
This also sets variables corresponding to options that take arguments as
a side effect; the caller should ensure that those variables are set to
NULL before calling build_actions. Return value:
EX_USAGE = bad option
EXECUTION_SUCCESS = some options supplied
EXECUTION_FAILURE = no options supplied
*/
static int
build_actions (list, pp, rp, actp)
build_actions (list, pp, rp, actp, optp)
WORD_LIST *list;
int *pp, *rp;
unsigned long *actp;
unsigned long *actp, *optp;
{
int opt, ind, pflag, rflag, opt_given;
unsigned long acts;
unsigned long acts, copts;
acts = (unsigned long)0L;
acts = copts = (unsigned long)0L;
opt_given = 0;
reset_internal_getopt ();
while ((opt = internal_getopt (list, "abcdefjkpruvA:G:W:P:S:X:F:C:")) != -1)
while ((opt = internal_getopt (list, "abcdefjko:pruvA:G:W:P:S:X:F:C:")) != -1)
{
opt_given = 1;
switch (opt)
@ -188,6 +212,15 @@ build_actions (list, pp, rp, actp)
case 'v':
acts |= CA_VARIABLE;
break;
case 'o':
ind = find_compopt (list_optarg);
if (ind < 0)
{
builtin_error ("%s: invalid option name", list_optarg);
return (EX_USAGE);
}
copts |= compopts[ind].optflag;
break;
case 'A':
ind = find_compact (list_optarg);
if (ind < 0)
@ -225,6 +258,8 @@ build_actions (list, pp, rp, actp)
}
*actp = acts;
*optp = copts;
return (opt_given ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
}
@ -234,7 +269,7 @@ complete_builtin (list)
WORD_LIST *list;
{
int opt_given, pflag, rflag, rval;
unsigned long acts;
unsigned long acts, copts;
char *cmd;
COMPSPEC *cs;
@ -245,13 +280,13 @@ complete_builtin (list)
}
opt_given = pflag = rflag = 0;
acts = (unsigned long)0L;
acts = copts = (unsigned long)0L;
Aarg = 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
as a side effect if they are supplied as options. */
rval = build_actions (list, &pflag, &rflag, &acts);
rval = build_actions (list, &pflag, &rflag, &acts, &copts);
if (rval == EX_USAGE)
return (rval);
opt_given = rval != EXECUTION_FAILURE;
@ -290,6 +325,7 @@ complete_builtin (list)
remaining argument. */
cs = alloc_compspec ();
cs->actions = acts;
cs->options = copts;
cs->globpat = STRDUP (Garg);
cs->words = STRDUP (Warg);
@ -304,7 +340,7 @@ complete_builtin (list)
/* Add CS as the compspec for the specified commands. */
cmd = list->word->word;
if (add_progcomp (cmd, cs) == 0)
rval = EXECUTION_FAILURE;
rval = EXECUTION_FAILURE;
}
return (rval);
@ -332,7 +368,7 @@ remove_cmd_completions (list)
do { \
if (a) \
{ \
x = single_quote (a); \
x = sh_single_quote (a); \
printf ("%s %s ", f, x); \
free (x); \
} \
@ -356,19 +392,32 @@ remove_cmd_completions (list)
printf ("-A %s ", f); \
} while (0)
#define PRINTCOMPOPT(a, f) \
do { \
if (copts & a) \
printf ("-o %s ", f); \
} while (0)
static void
print_one_completion (cmd, cs)
char *cmd;
COMPSPEC *cs;
{
unsigned long acts;
unsigned long acts, copts;
char *x;
printf ("complete ");
copts = cs->options;
/* First, print the -o options. */
PRINTCOMPOPT (COPT_DEFAULT, "default");
PRINTCOMPOPT (COPT_DIRNAMES, "dirnames");
PRINTCOMPOPT (COPT_FILENAMES, "filenames");
acts = cs->actions;
/* simple flags first */
/* simple flags next */
PRINTOPT (CA_ALIAS, "-a");
PRINTOPT (CA_BUILTIN, "-b");
PRINTOPT (CA_COMMAND, "-c");
@ -428,7 +477,7 @@ print_cmd_completions (list)
{
cs = find_compspec (l->word->word);
if (cs)
print_one_completion (l->word->word, cs);
print_one_completion (l->word->word, cs);
else
{
builtin_error ("%s: no completion specification", l->word->word);
@ -441,7 +490,7 @@ print_cmd_completions (list)
$BUILTIN compgen
$DEPENDS_ON PROGRAMMABLE_COMPLETION
$FUNCTION compgen_builtin
$SHORT_DOC compgen [-abcdefjkvu] [-A action] [-G globpat] [-W wordlist] [-P prefix] [-S suffix] [-X filterpat] [-F function] [-C command] [word]
$SHORT_DOC compgen [-abcdefjkvu] [-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
@ -453,7 +502,7 @@ compgen_builtin (list)
WORD_LIST *list;
{
int rval;
unsigned long acts;
unsigned long acts, copts;
COMPSPEC *cs;
STRINGLIST *sl;
char *word;
@ -461,13 +510,13 @@ compgen_builtin (list)
if (list == 0)
return (EXECUTION_SUCCESS);
acts = (unsigned long)0L;
acts = copts = (unsigned long)0L;
Aarg = 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
as a side effect if they are supplied as options. */
rval = build_actions (list, (int *)NULL, (int *)NULL, &acts);
rval = build_actions (list, (int *)NULL, (int *)NULL, &acts, &copts);
if (rval == EX_USAGE)
return (rval);
if (rval == EXECUTION_FAILURE)
@ -485,6 +534,7 @@ compgen_builtin (list)
/* If we get here, we need to build a compspec and evaluate it. */
cs = alloc_compspec ();
cs->actions = acts;
cs->options = copts;
cs->refcount = 1;
cs->globpat = STRDUP (Garg);

View file

@ -333,10 +333,12 @@ declare_internal (list, local_var)
NEXT_VARIABLE ();
}
/* Cannot use declare to assign value to readonly variable. */
if (readonly_p (var) && offset)
/* Cannot use declare to assign value to readonly or noassign
variable. */
if ((readonly_p (var) || noassign_p (var)) && offset)
{
builtin_error ("%s: readonly variable", name);
if (readonly_p (var))
builtin_error ("%s: readonly variable", name);
assign_error++;
NEXT_VARIABLE ();
}
@ -347,7 +349,7 @@ declare_internal (list, local_var)
if ((making_array_special || (flags_on & att_array) || array_p (var)) && offset)
{
if (value[0] == '(' && strchr (value, ')'))
assigning_array_special = 1;
assigning_array_special = 1;
else
{
builtin_error ("%s: cannot assign to array variables in this way", name);

View file

@ -164,7 +164,7 @@ enable_builtin (list)
{
filter = (flags & NFLAG) ? DISABLED : ENABLED;
if (flags & SFLAG)
filter |= SPECIAL;
filter |= SPECIAL;
result = dyn_load_builtin (list, filter, filename);
#if defined (PROGRAMMABLE_COMPLETION)
@ -326,10 +326,10 @@ dyn_load_builtin (list, flags, filename)
b->handle = handle;
if (old_builtin = builtin_address_internal (name, 1))
{
replaced++;
{
replaced++;
FASTCOPY ((char *)b, (char *)old_builtin, sizeof (struct builtin));
}
}
else
new_builtins[new++] = b;
}

View file

@ -56,6 +56,7 @@ extern int errno;
#define FEVAL_NONINT 0x008
#define FEVAL_LONGJMP 0x010
#define FEVAL_HISTORY 0x020
#define FEVAL_CHECKBINARY 0x040
extern int interactive, interactive_shell, posixly_correct;
extern int indirection_level, startup_state, subshell_environment;
@ -87,7 +88,7 @@ file_error_and_exit:
file_error (filename);
if (flags & FEVAL_LONGJMP)
{
{
last_command_exit_value = 1;
jump_to_top_level (EXITPROG);
}
@ -116,6 +117,11 @@ file_error_and_exit:
(*errfunc) ("%s: file is too large", filename);
return ((flags & FEVAL_BUILTIN) ? EXECUTION_FAILURE : -1);
}
#if defined (__CYGWIN__) && defined (O_TEXT)
setmode (fd, O_TEXT);
#endif
string = xmalloc (1 + file_size);
result = read (fd, string, file_size);
string[result] = '\0';
@ -136,7 +142,8 @@ file_error_and_exit:
return ((flags & FEVAL_BUILTIN) ? EXECUTION_SUCCESS : 1);
}
if (check_binary_file ((unsigned char *)string, (result > 80) ? 80 : result))
if ((flags & FEVAL_CHECKBINARY) &&
check_binary_file ((unsigned char *)string, (result > 80) ? 80 : result))
{
free (string);
(*errfunc) ("%s: cannot execute binary file", filename);

View file

@ -175,7 +175,7 @@ parse_and_execute (string, from_file, flags)
case DISCARD:
run_unwind_frame ("pe_dispose");
last_command_exit_value = 1; /* XXX */
last_result = last_command_exit_value = EXECUTION_FAILURE; /* XXX */
if (subshell_environment)
{
should_jump_to_top_level = 1;
@ -238,7 +238,7 @@ parse_and_execute (string, from_file, flags)
/* See if this is a candidate for $( <file ). */
if (startup_state == 2 &&
subshell_environment == SUBSHELL_COMSUB &&
(subshell_environment & SUBSHELL_COMSUB) &&
*bash_input.location.string == '\0' &&
command->type == cm_simple && !command->redirects &&
(command->flags & CMD_TIME_PIPELINE) == 0 &&
@ -277,8 +277,8 @@ parse_and_execute (string, from_file, flags)
if (interrupt_state && parse_and_execute_level == 0)
{
/* An interrupt during non-interactive execution in an
interactive shell (e.g. via $PROMPT_COMMAND) should
not cause the shell to exit. */
interactive shell (e.g. via $PROMPT_COMMAND) should
not cause the shell to exit. */
interactive = interactive_shell;
throw_to_top_level ();
}

View file

@ -86,7 +86,7 @@ extern int literal_history;
extern int unlink ();
extern int fc_execute_file ();
extern FILE *sh_mktmpfp __P((char *, int, char **));
/* **************************************************************** */
/* */
@ -161,7 +161,7 @@ fc_builtin (list)
REPL *rlist, *rl;
char *ename, *command, *newcom, *line;
HIST_ENTRY **hlist;
char fn[64];
char *fn;
numbering = 1;
reverse = listing = execute = 0;
@ -327,14 +327,11 @@ fc_builtin (list)
else
{
numbering = 0;
/* XXX - this is raceable */
sprintf (fn, "/tmp/bash%d", (int)time ((time_t *) 0) + (int)getpid ());
stream = fopen (fn, "w");
stream = sh_mktmpfp ("bash-fc", MT_USERANDOM|MT_USETMPDIR, &fn);
if (stream == 0)
{
builtin_error ("cannot open temp file %s", fn);
builtin_error ("cannot open temp file %s", fn ? fn : "");
FREE (fn);
return (EXECUTION_FAILURE);
}
}
@ -369,6 +366,7 @@ fc_builtin (list)
if (retval != EXECUTION_SUCCESS)
{
unlink (fn);
free (fn);
return (EXECUTION_FAILURE);
}
@ -381,6 +379,7 @@ fc_builtin (list)
/* Turn on the `v' flag while fc_execute_file runs so the commands
will be echoed as they are read by the parser. */
begin_unwind_frame ("fc builtin");
add_unwind_protect ((Function *)xfree, fn);
add_unwind_protect (unlink, fn);
unwind_protect_int (echo_input_at_read);
echo_input_at_read = 1;

View file

@ -196,9 +196,9 @@ dogetopts (argc, argv)
;
v = alloc_array (i + 1);
for (i = 0; i < 10 && dollar_vars[i]; i++)
v[i] = dollar_vars[i];
v[i] = dollar_vars[i];
for (words = rest_of_args; words; words = words->next, i++)
v[i] = words->word->word;
v[i] = words->word->word;
v[i] = (char *)NULL;
sh_getopt_restore_state (v);
ret = sh_getopt (i, v, optstr);

View file

@ -41,6 +41,8 @@ $END
# include <unistd.h>
#endif
#include <errno.h>
#include "../bashansi.h"
#include "../shell.h"
@ -119,7 +121,19 @@ hash_builtin (list)
/* Add or rehash the specified commands. */
w = list->word->word;
if (pathname)
remember_filename (w, pathname, 0, 0);
{
if (is_directory (pathname))
{
#ifdef EISDIR
builtin_error ("%s: %s", pathname, strerror (EISDIR));
#else
builtin_error ("%s: is a directory", pathname);
#endif
opt = EXECUTION_FAILURE;
}
else
remember_filename (w, pathname, 0, 0);
}
else if (absolute_program (w))
continue;
else if (add_hashed_command (w, 0))

View file

@ -157,7 +157,7 @@ history_builtin (list)
else if (flags & PFLAG)
{
if (list)
return (expand_and_print_history (list));
return (expand_and_print_history (list));
return (EXECUTION_SUCCESS);
}
#endif
@ -326,10 +326,10 @@ expand_and_print_history (list)
result = EXECUTION_FAILURE;
}
else
{
{
fputs (s, stdout);
putchar ('\n');
}
}
FREE (s);
list = list->next;
}

View file

@ -614,10 +614,10 @@ free_defs (defs)
if (defs->builtins)
{
for (i = 0; builtin = (BUILTIN_DESC *)defs->builtins->array[i]; i++)
{
{
free_builtin (builtin);
free (builtin);
}
}
array_free (defs->builtins);
}
free (defs);
@ -990,9 +990,9 @@ copy_builtin (builtin)
new = (BUILTIN_DESC *)xmalloc (sizeof (BUILTIN_DESC));
new->name = savestring (builtin->name);
new->shortdoc = savestring (builtin->shortdoc);
new->longdoc = copy_string_array (builtin->longdoc);
new->name = savestring (builtin->name);
new->shortdoc = savestring (builtin->shortdoc);
new->longdoc = copy_string_array (builtin->longdoc);
new->dependencies = copy_string_array (builtin->dependencies);
new->function =
@ -1151,7 +1151,7 @@ write_builtins (defs, structfile, externfile)
builtin->function);
fprintf (externfile, "extern char *%s_doc[];\n",
builtin->docname ?builtin->docname : builtin->name);
builtin->docname ? builtin->docname : builtin->name);
}
/* Write the structure definition. */

View file

@ -88,13 +88,13 @@ static char *getstr __P((void));
static int getint __P((void));
static int getlong __P((long *));
static int getulong __P((unsigned long *));
static double getdouble __P((void));
static int getdouble __P((double *));
static int asciicode __P((void));
static WORD_LIST *garglist;
static int retval;
extern char *backslash_quote ();
extern char *sh_backslash_quote ();
int
printf_builtin (list)
@ -255,7 +255,7 @@ printf_builtin (list)
char *p, *xp;
p = getstr ();
xp = backslash_quote (p);
xp = sh_backslash_quote (p);
if (xp)
{
/* Use printstr to get fieldwidth and precision right. */
@ -307,7 +307,8 @@ printf_builtin (list)
{
double p;
p = getdouble ();
if (getdouble (&p))
PRETURN (EXECUTION_FAILURE);
PF(start, p);
break;
}
@ -471,7 +472,8 @@ tescape (estart, trans_squote, cp, sawc)
case 'b': *cp = '\b'; break;
case 'e': *cp = '\033'; break; /* ESC -- non-ANSI */
case 'e':
case 'E': *cp = '\033'; break; /* ESC -- non-ANSI */
case 'f': *cp = '\f'; break;
@ -484,7 +486,7 @@ tescape (estart, trans_squote, cp, sawc)
case 'v': *cp = '\v'; break;
/* %b octal constants are `\0' followed by one, two, or three
octal digits... */
octal digits... */
case '0':
for (temp = 3, evalue = 0; isoctal (*p) && temp--; p++)
evalue = (evalue * 8) + OCTVALUE (*p);
@ -638,8 +640,13 @@ getint ()
if (ret > INT_MAX)
{
builtin_error ("%s: %s", garglist->word->word, strerror(ERANGE));
return (0);
builtin_error ("warning: %s: %s", garglist->word->word, strerror(ERANGE));
ret = INT_MAX;
}
else if (ret < INT_MIN)
{
builtin_error ("warning: %s: %s", garglist->word->word, strerror(ERANGE));
ret = INT_MIN;
}
return ((int)ret);
@ -676,10 +683,7 @@ getlong (lp)
return (1);
}
else if (errno == ERANGE)
{
builtin_error ("%s: %s", garglist->word->word, strerror(ERANGE));
return (1);
}
builtin_error ("warning: %s: %s", garglist->word->word, strerror(ERANGE));
*lp = ret;
garglist = garglist->next;
@ -714,31 +718,45 @@ getulong (ulp)
return (1);
}
else if (errno == ERANGE)
{
builtin_error ("%s: %s", garglist->word->word, strerror(ERANGE));
return (1);
}
builtin_error ("warning: %s: %s", garglist->word->word, strerror(ERANGE));
*ulp = ret;
garglist = garglist->next;
return (0);
}
static double
getdouble ()
static int
getdouble (dp)
double *dp;
{
double ret;
char *ep;
if (garglist == 0)
return ((double)0);
{
*dp = (double)0;
return (0);
}
if (garglist->word->word[0] == '\'' || garglist->word->word[0] == '"')
return ((double)asciicode ());
{
*dp = (double)asciicode ();
return (0);
}
/* This should use strtod if it is available. */
ret = atof (garglist->word->word);
errno = 0;
ret = strtod (garglist->word->word, &ep);
if (*ep)
{
builtin_error ("%s: invalid number", garglist->word->word);
return (1);
}
else if (errno == ERANGE)
builtin_error ("warning: %s: %s", garglist->word->word, strerror(ERANGE));
*dp = ret;
garglist = garglist->next;
return (ret);
return (0);
}
/* NO check is needed for garglist here. */

View file

@ -186,10 +186,10 @@ pushd_builtin (list)
flags |= NOCD;
}
else if (ISOPTION (list->word->word, '-'))
{
list = list->next;
break;
}
{
list = list->next;
break;
}
else if (list->word->word[0] == '-' && list->word->word[1] == '\0')
/* Let `pushd -' work like it used to. */
break;
@ -296,14 +296,14 @@ popd_builtin (list)
for (flags = 0, which = 0L, direction = '+'; list; list = list->next)
{
if (ISOPTION (list->word->word, 'n'))
{
flags |= NOCD;
}
{
flags |= NOCD;
}
else if (ISOPTION (list->word->word, '-'))
{
list = list->next;
break;
}
{
list = list->next;
break;
}
else if (((direction = list->word->word[0]) == '+') || direction == '-')
{
if (legal_number (list->word->word + 1, &which) == 0)
@ -335,7 +335,7 @@ popd_builtin (list)
(direction == '-' && which == directory_list_offset))
{
i = ((flags & NOCD) == 0) ? cd_to_string (pushd_directory_list[directory_list_offset - 1])
: EXECUTION_SUCCESS;
: EXECUTION_SUCCESS;
if (i != EXECUTION_SUCCESS)
return (i);
free (pushd_directory_list[--directory_list_offset]);
@ -386,14 +386,14 @@ dirs_builtin (list)
vflag |= 1;
}
else if (ISOPTION (list->word->word, '-'))
{
list = list->next;
break;
}
{
list = list->next;
break;
}
else if (*list->word->word == '+' || *list->word->word == '-')
{
int sign;
if (legal_number (w = list->word->word + 1, &i) == 0)
{
int sign;
if (legal_number (w = list->word->word + 1, &i) == 0)
{
builtin_error (m_badarg, list->word->word);
builtin_usage ();

View file

@ -58,6 +58,11 @@ $END
#include <signal.h>
#include <errno.h>
#ifdef __CYGWIN__
# include <fcntl.h>
# include <io.h>
#endif
#include "../shell.h"
#include "common.h"
#include "bashgetopt.h"
@ -148,8 +153,8 @@ read_builtin (list)
while ((opt = internal_getopt (list, "erp:a:d:t:n:s")) != -1)
{
switch (opt)
{
case 'r':
{
case 'r':
raw = 1;
break;
case 'p':
@ -211,15 +216,13 @@ read_builtin (list)
input_string = xmalloc (size = 128);
begin_unwind_frame ("read_builtin");
add_unwind_protect (xfree, input_string);
#if defined (READLINE)
add_unwind_protect (xfree, rlbuf);
#endif
interrupt_immediately++;
input_is_tty = isatty (0);
if (input_is_tty == 0)
#ifndef __CYGWIN32__
#ifndef __CYGWIN__
input_is_pipe = (lseek (0, 0L, SEEK_CUR) < 0) && (errno == ESPIPE);
#else
input_is_pipe = 1;
@ -247,7 +250,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))
tmout = -1;
tmout = -1;
}
if (tmout > 0)
@ -285,7 +288,7 @@ read_builtin (list)
else
#endif
if (input_is_tty)
{
{
ttsave ();
if (silent)
ttcbreak ();
@ -301,8 +304,17 @@ read_builtin (list)
add_unwind_protect ((Function *)ttrestore, (char *)NULL);
}
/* This *must* be the top unwind-protect on the stack, so the manipulation
of the unwind-protect stack after the realloc() works right. */
add_unwind_protect (xfree, input_string);
interrupt_immediately++;
unbuffered_read = (nchars > 0) || (delim != '\n') || input_is_pipe;
#if defined (__CYGWIN__) && defined (O_TEXT)
setmode (0, O_TEXT);
#endif
for (eof = 0;;)
{
#if defined (READLINE)
@ -345,7 +357,11 @@ read_builtin (list)
#endif
if (i + 2 >= size)
input_string = xrealloc (input_string, size += 128);
{
input_string = xrealloc (input_string, size += 128);
remove_unwind_protect ();
add_unwind_protect (xfree, input_string);
}
/* If the next character is to be accepted verbatim, a backslash
newline pair still disappears from the input. */
@ -419,9 +435,9 @@ read_builtin (list)
{
var = find_variable (arrayname);
if (var == 0)
var = make_new_array_variable (arrayname);
var = make_new_array_variable (arrayname);
else if (array_p (var) == 0)
var = convert_var_to_array (var);
var = convert_var_to_array (var);
empty_array (array_cell (var));
@ -441,7 +457,8 @@ read_builtin (list)
so that `read x ; echo "$x"' and `read ; echo "$REPLY"' behave the
same way, but I believe that the difference in behaviors is useful
enough to not do it. Without the bash behavior, there is no way
to read a line completely without interpretation or modification.
to read a line completely without interpretation or modification
unless you mess with $IFS (e.g., setting it to the empty string).
If you disagree, change the occurrences of `#if 0' to `#if 1' below. */
if (list == 0)
{
@ -462,11 +479,8 @@ read_builtin (list)
else
var = bind_variable ("REPLY", input_string);
VUNSETATTR (var, att_invisible);
#if 0
free (orig_input_string);
#else
free (input_string);
#endif
return (retval);
}
@ -572,10 +586,10 @@ bind_read_variable (name, value)
{
#if 0
if (legal_identifier (name) == 0)
{
{
builtin_error ("`%s': not a valid identifier", name);
return ((SHELL_VAR *)NULL);
}
}
#endif
return (bind_variable (name, value));
}

View file

@ -52,7 +52,7 @@ $PRODUCES set.c
extern int interactive;
extern int noclobber, posixly_correct, ignoreeof, eof_encountered_limit;
#if defined (READLINE)
extern int rl_editing_mode, no_line_editing;
extern int no_line_editing;
#endif /* READLINE */
$BUILTIN set
@ -224,7 +224,7 @@ minus_o_option_value (name)
for (i = 0; binary_o_options[i].name; i++)
{
if (STREQ (name, binary_o_options[i].name))
return (GET_BINARY_O_OPTION_VALUE (i, name));
return (GET_BINARY_O_OPTION_VALUE (i, name));
}
return (-1);
@ -256,13 +256,13 @@ list_minus_o_opts (mode, reusable)
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);
print_minus_o_option (o_options[i].name, *on_or_off, reusable);
}
for (i = 0; binary_o_options[i].name; i++)
{
value = GET_BINARY_O_OPTION_VALUE (i, binary_o_options[i].name);
if (mode == -1 || mode == value)
print_minus_o_option (binary_o_options[i].name, value, reusable);
print_minus_o_option (binary_o_options[i].name, value, reusable);
}
}
@ -390,10 +390,10 @@ set_minus_o_option (on_or_off, option_name)
for (i = 0, option_char = -1, set_func = 0; o_options[i].name; i++)
{
if (STREQ (option_name, o_options[i].name))
{
option_char = o_options[i].letter;
break;
}
{
option_char = o_options[i].letter;
break;
}
}
if (option_char == -1)
{
@ -420,11 +420,16 @@ print_all_shell_variables ()
free (vars);
}
vars = all_shell_functions ();
if (vars)
/* POSIX.2 does not allow function names and definitions to be output when
`set' is invoked without options (PASC Interp #202). */
if (posixly_correct == 0)
{
print_var_list (vars);
free (vars);
vars = all_shell_functions ();
if (vars)
{
print_func_list (vars);
free (vars);
}
}
}
@ -533,14 +538,16 @@ initialize_shell_options (no_shellopts)
set_shellopts ();
}
/* Reset the values of the -o options that are not also shell flags. */
/* Reset the values of the -o options that are not also shell flags. This is
called from execute_cmd.c:initialize_subshell() when setting up a subshell
to run an executable shell script without a leading `#!'. */
void
reset_shell_options ()
{
#if defined (HISTORY)
remember_on_history = 1;
#endif
ignoreeof = posixly_correct = 0;
ignoreeof = 0;
}
/* Set some flags from the word values in the input list. If LIST is empty,
@ -695,8 +702,7 @@ For each NAME, remove the corresponding variable or function. Given
the `-v', unset will only act on variables. Given the `-f' flag,
unset will only act on functions. With neither flag, unset first
tries to unset a variable, and if that fails, then tries to unset a
function. Some variables (such as PATH and IFS) cannot be unset; also
see readonly.
function. Some variables cannot be unset; also see readonly.
$END
#define NEXT_VARIABLE() any_failed++; list = list->next; continue;
@ -758,10 +764,10 @@ unset_builtin (list)
to be created when not in posix mode, so check only when in posix
mode when unsetting a function. */
if (((unset_function && posixly_correct) || !unset_function) && legal_identifier (name) == 0)
{
builtin_error ("`%s': not a valid identifier", name);
NEXT_VARIABLE ();
}
{
builtin_error ("`%s': not a valid identifier", name);
NEXT_VARIABLE ();
}
var = unset_function ? find_function (name) : find_variable (name);

View file

@ -169,7 +169,7 @@ set_or_show_attributes (list, attribute, nodefs)
/* xxx [-np] name[=value] */
assign = assignment (name);
if (assign)
if (assign)
name[assign] = '\0';
if (legal_identifier (name) == 0)
@ -233,11 +233,11 @@ set_or_show_attributes (list, attribute, nodefs)
#if defined (ARRAY_VARS)
if (attribute & att_array)
{
arrays_only++;
if (attribute != att_array)
{
arrays_only++;
if (attribute != att_array)
attribute &= ~att_array;
}
}
#endif
if (variable_list)
@ -246,7 +246,7 @@ set_or_show_attributes (list, attribute, nodefs)
{
#if defined (ARRAY_VARS)
if (arrays_only && array_p (var) == 0)
continue;
continue;
#endif
if ((var->attributes & attribute) && invisible_p (var) == 0)
show_var_attributes (var, READONLY_OR_EXPORT, nodefs);
@ -285,16 +285,16 @@ show_var_attributes (var, pattr, nodefs)
#endif
if (function_p (var))
flags[i++] = 'f';
flags[i++] = 'f';
if (integer_p (var))
flags[i++] = 'i';
flags[i++] = 'i';
if (readonly_p (var))
flags[i++] = 'r';
flags[i++] = 'r';
if (exported_p (var))
flags[i++] = 'x';
flags[i++] = 'x';
}
else
{
@ -304,7 +304,7 @@ show_var_attributes (var, pattr, nodefs)
#endif
if (function_p (var))
flags[i++] = 'f';
flags[i++] = 'f';
}
flags[i] = '\0';
@ -329,7 +329,7 @@ show_var_attributes (var, pattr, nodefs)
printf ("%s\n", named_function_string (var->name, function_cell (var), 1));
else
{
x = double_quote (value_cell (var) ? value_cell (var) : "");
x = sh_double_quote (value_cell (var) ? value_cell (var) : "");
printf ("%s=%s\n", var->name, x);
free (x);
}

View file

@ -332,8 +332,9 @@ list_shopts (list, flags)
if (val == 0)
rval = EXECUTION_FAILURE;
if ((flags & QFLAG) == 0)
print_shopt (l->word->word, val, flags);
print_shopt (l->word->word, val, flags);
}
return (rval);
}

View file

@ -67,15 +67,20 @@ extern int restricted;
/* If non-zero, `.' uses $PATH to look up the script to be sourced. */
int source_uses_path = 1;
/* If non-zero, `.' looks in the current directory if the filename argument
is not found in the $PATH. */
int source_searches_cwd = 1;
/* If this . script is supplied arguments, we save the dollar vars and
replace them with the script arguments for the duration of the script's
execution. If the script does not change the dollar vars, we restore
what we saved. If the dollar vars are changed in the script, we leave
the new values alone and free the saved values. */
what we saved. If the dollar vars are changed in the script, and we are
not executing a shell function, we leave the new values alone and free
the saved values. */
static void
maybe_pop_dollar_vars ()
{
if (dollar_vars_changed ())
if (variable_context == 0 && dollar_vars_changed ())
{
dispose_saved_dollar_vars ();
set_dollar_vars_unchanged ();
@ -117,7 +122,15 @@ source_builtin (list)
if (source_uses_path)
filename = find_path_file (list->word->word);
if (filename == 0)
filename = savestring (list->word->word);
{
if (source_searches_cwd == 0)
{
builtin_error ("%s: file not found", list->word->word);
return (EXECUTION_FAILURE);
}
else
filename = savestring (list->word->word);
}
begin_unwind_frame ("source");
add_unwind_protect ((Function *)xfree, filename);

View file

@ -79,7 +79,7 @@ static int display_traps ();
#define REVERT 1 /* Revert to this signals original value. */
#define IGNORE 2 /* Ignore this signal. */
extern int interactive;
extern int interactive, posixly_correct;
int
trap_builtin (list)
@ -201,12 +201,19 @@ showtrap (i)
if (p == (char *)DEFAULT_SIG)
return;
t = (p == (char *)IGNORE_SIG) ? (char *)NULL : single_quote (p);
t = (p == (char *)IGNORE_SIG) ? (char *)NULL : sh_single_quote (p);
sn = signal_name (i);
/* Make sure that signals whose names are unknown (for whatever reason)
are printed as signal numbers. */
if (STREQN (sn, "SIGJUNK", 7) || STREQN (sn, "unknown", 7))
printf ("trap -- %s %d\n", t ? t : "''", i);
else if (posixly_correct)
{
if (STREQN (sn, "SIG", 3))
printf ("trap -- %s %s\n", t ? t : "''", sn+3);
else
printf ("trap -- %s %s\n", t ? t : "''", sn);
}
else
printf ("trap -- %s %s\n", t ? t : "''", sn);

View file

@ -123,12 +123,12 @@ type_builtin (list)
type_only = 0;
}
else if (STREQ (flag, "all") || STREQ (flag, "-all"))
all = 1;
all = 1;
else
{
prev = this;
this = this->next;
continue;
prev = this;
this = this->next;
continue;
}
/* We found a long option; remove it from the argument list. Don't
@ -234,7 +234,7 @@ describe_command (command, verbose, all)
printf ("%s is aliased to `%s'\n", command, alias->value);
else if (verbose == 4)
{
x = single_quote (alias->value);
x = sh_single_quote (alias->value);
printf ("alias %s=%s\n", command, x);
free (x);
}
@ -317,7 +317,7 @@ describe_command (command, verbose, all)
{
f = file_status (command);
if (f & FS_EXECABLE)
{
{
if (verbose == 1)
puts ("file");
else if (verbose == 2)
@ -329,7 +329,7 @@ describe_command (command, verbose, all)
because they're not consulted when an absolute program
name is supplied. */
return (1);
}
}
}
/* If the user isn't doing "-a", then we might care about

View file

@ -201,6 +201,9 @@ static RESOURCE_LIMITS limits[] = {
{ 'u', RLIMIT_MAXUPROC, 1, "max user processes" },
#if defined (HAVE_RESOURCE)
{ 'v', RLIMIT_VIRTMEM, RLIMIT_VMBLKSZ, "virtual memory (kbytes)" },
#endif
#ifdef RLIMIT_SWAP
{ 'w', RLIMIT_SWAP, 1024, "swap size (kbytes)" },
#endif
{ -1, -1, -1, (char *)NULL }
};
@ -476,7 +479,13 @@ set_limit (ind, newlim, mode)
case RLIMIT_OPENFILES:
#if defined (HAVE_SETDTABLESIZE)
# if defined (__CYGWIN__)
/* Grrr... Cygwin declares setdtablesize as void. */
setdtablesize (newlim);
return 0;
# else
return (setdtablesize (newlim));
# endif
#endif
case RLIMIT_PIPESIZE:
case RLIMIT_VIRTMEM:
@ -495,6 +504,7 @@ set_limit (ind, newlim, mode)
newlim /= 512; /* Ugh. */
# endif /* HPUX9 */
val = (current_user.euid != 0 && newlim == RLIM_INFINITY &&
(mode & LIMIT_HARD) == 0 && /* XXX -- test */
(limit.rlim_cur <= limit.rlim_max))
? limit.rlim_max : newlim;
if (mode & LIMIT_SOFT)

View file

@ -188,7 +188,7 @@ parse_symbolic_mode (mode, initial_bits)
/* Parse the `who' portion of the symbolic mode clause. */
while (member (*s, "agou"))
{
{
switch (c = *s++)
{
case 'u':

View file

@ -66,21 +66,27 @@ procenv_t wait_intr_buf;
0. If a list of pids or job specs are given, return the exit status of
the last one waited for. */
#define WAIT_RETURN(s) do { run_unwind_frame ("wait_builtin"); return (s); } while (0)
#define WAIT_RETURN(s) \
do \
{ \
interrupt_immediately = old_interrupt_immediately;\
return (s);\
} \
while (0)
int
wait_builtin (list)
WORD_LIST *list;
{
int status, code;
volatile int old_interrupt_immediately;
if (no_options (list))
return (EX_USAGE);
if (list != loptend)
list = loptend;
begin_unwind_frame ("wait_builtin");
unwind_protect_int (interrupt_immediately);
old_interrupt_immediately = interrupt_immediately;
interrupt_immediately++;
/* POSIX.2 says: When the shell is waiting (by means of the wait utility)

View file

@ -39,6 +39,9 @@ enum r_instruction {
#define RESTRICTED_REDIRECT -3 /* can only happen in restricted shells. */
#define HEREDOC_REDIRECT -4 /* here-doc temp file can't be created */
#define CLOBBERING_REDIRECT(ri) \
(ri == r_output_direction || ri == r_err_and_out)
#define OUTPUT_REDIRECT(ri) \
(ri == r_output_direction || ri == r_input_output || ri == r_err_and_out)
@ -64,12 +67,14 @@ enum command_type { cm_for, cm_case, cm_while, cm_if, cm_simple, cm_select,
#define W_GLOBEXP 0x08 /* This word is the result of a glob expansion. */
#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. */
/* Possible values for subshell_environment */
#define SUBSHELL_ASYNC 0x01 /* subshell caused by `command &' */
#define SUBSHELL_PAREN 0x02 /* subshell caused by ( ... ) */
#define SUBSHELL_COMSUB 0x04 /* subshell caused by `command` or $(command) */
#define SUBSHELL_FORK 0x08 /* subshell caused by executing a disk command */
#define SUBSHELL_PIPE 0x10 /* subshell from a pipeline element */
/* A structure which represents a word. */
typedef struct word_desc {

View file

@ -1,4 +1,4 @@
/* config.h.bot */
/* config-bot.h */
/* modify settings or make new ones based on what autoconf tells us. */
#if !defined (HAVE_VPRINTF) && defined (HAVE_DOPRNT)

View file

@ -1,4 +1,4 @@
/* config.h.top */
/* config-top.h */
/* This contains various user-settable options not under the control of
autoconf. */

View file

@ -142,6 +142,10 @@
/* Beginning of autoconf additions. */
#define DEFAULT_MAIL_DIRECTORY "/usr/spool/mail"
/* Memory management functions. */
/* Define if using the bash version of malloc in lib/malloc/malloc.c */
#undef USING_BASH_MALLOC
@ -152,48 +156,14 @@
This function is required for alloca.c support on those systems. */
#undef CRAY_STACKSEG_END
/* Define to the type of elements in the array set by `getgroups'.
Usually this is either `int' or `gid_t'. */
#undef GETGROUPS_T
/* Define if the `getpgrp' function takes no argument. */
#undef GETPGRP_VOID
/* Define to `int' if <sys/types.h> doesn't define. */
#undef gid_t
/* Define if you have alloca, as a function or macro. */
#undef HAVE_ALLOCA
/* Define if you have <alloca.h> and it should be used (not on Ultrix). */
#undef HAVE_ALLOCA_H
/* Define if you don't have vprintf but do have _doprnt. */
#undef HAVE_DOPRNT
/* Define if system calls automatically restart after interruption
by a signal. */
#undef HAVE_RESTARTABLE_SYSCALLS
/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
#undef HAVE_SYS_WAIT_H
/* Define if you have <sys/time.h> */
#undef HAVE_SYS_TIME_H
#undef TIME_WITH_SYS_TIME
#undef HAVE_SYS_TIMES_H
/* Define if you have the vprintf function. */
#undef HAVE_VPRINTF
#undef HAVE_WAIT3
#undef HAVE_SETOSTYPE
/* Define if on MINIX. */
#undef _MINIX
/* SYSTEM TYPES */
/* The number of bytes in a int. */
#undef SIZEOF_INT
@ -255,6 +225,18 @@
/* Define to `long' if <sys/types.h> doesn't define. */
#undef time_t
/* Define to `int' if <sys/types.h> doesn't define. */
#undef gid_t
/* Define if you have quad_t in <sys/types.h>. */
#undef HAVE_QUAD_T
#undef RLIMTYPE
/* Define to the type of elements in the array set by `getgroups'.
Usually this is either `int' or `gid_t'. */
#undef GETGROUPS_T
/* Define if the system does not provide POSIX.1 features except
with this defined. */
#undef _POSIX_1_SOURCE
@ -262,13 +244,7 @@
/* Define if you need to in order for stat and other things to work. */
#undef _POSIX_SOURCE
/* Define as the return type of signal handlers (int or void). */
#undef RETSIGTYPE
/* Define if the setvbuf function takes the buffering type as its second
argument and the buffer pointer as the third, as on System V
before release 3. */
#undef SETVBUF_REVERSED
/* Characteristics of the machine archictecture. */
/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
@ -279,98 +255,41 @@
*/
#undef STACK_DIRECTION
/* Define if the machine architecture is big-endian. */
#undef WORDS_BIGENDIAN
/* Define if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Check for the presence of certain non-function symbols in the system
libraries. */
/* Define if `sys_siglist' is declared by <signal.h> or <unistd.h>. */
#undef SYS_SIGLIST_DECLARED
/* Define if `_sys_siglist' is declared by <signal.h> or <unistd.h>. */
#undef UNDER_SYS_SIGLIST_DECLARED
#undef DUP2_BROKEN
#undef HAVE_SYS_SIGLIST
#undef HAVE_GETHOSTBYNAME
#undef HAVE_UNDER_SYS_SIGLIST
#undef HAVE_INET_ATON
#undef HAVE_SYS_ERRLIST
#undef HAVE_GETRLIMIT
#undef HAVE_TIMEVAL
#undef HAVE_GETRUSAGE
#undef HAVE_GETTIMEOFDAY
/* Characteristics of some of the system structures. */
#undef GWINSZ_IN_SYS_IOCTL
#undef STRUCT_DIRENT_HAS_D_INO
#undef STRUCT_DIRENT_HAS_D_FILENO
#undef TIOCSTAT_IN_SYS_IOCTL
#undef FIONREAD_IN_SYS_IOCTL
#undef WORDS_BIGENDIAN
#undef HAVE_HASH_BANG_EXEC
#undef HAVE_BSD_SIGNALS
#undef HAVE_POSIX_SIGNALS
#undef HAVE_USG_SIGHOLD
#undef HAVE_DEV_FD
#undef DEV_FD_PREFIX
#undef HAVE_DEV_STDIN
#undef HAVE_GETPW_DECLS
#undef HAVE_QUAD_T
#undef HAVE_RESOURCE
#undef HAVE_STRSIGNAL
#undef HAVE_SYS_ERRLIST
#undef STAT_MACROS_BROKEN
#undef HAVE_TIMEVAL
#undef HAVE_MEMMOVE
#undef HAVE_MKFIFO
#undef NAMED_PIPES_MISSING
#undef OPENDIR_NOT_ROBUST
#undef PGRP_PIPE
#undef RLIMTYPE
#undef SBRK_DECLARED
#undef PRINTF_DECLARED
#undef HAVE_SYS_SIGLIST
#undef HAVE_TIMES
#undef HAVE_UNDER_SYS_SIGLIST
#undef VOID_SIGHANDLER
#undef TERMIOS_LDISC
#undef TERMIO_LDISC
#undef ULIMIT_MAXFDS
#undef GETCWD_BROKEN
#undef STRUCT_DIRENT_HAS_D_INO
#undef STRUCT_DIRENT_HAS_D_FILENO
#undef GWINSZ_IN_SYS_IOCTL
#undef STRUCT_WINSIZE_IN_SYS_IOCTL
@ -378,19 +297,90 @@
#undef SPEED_T_IN_SYS_TYPES
#undef TERMIOS_LDISC
#undef TERMIO_LDISC
/* Characteristics of definitions in the system header files. */
#undef HAVE_GETPW_DECLS
#undef HAVE_RESOURCE
#undef SBRK_DECLARED
#undef PRINTF_DECLARED
/* Characteristics of system calls and C library functions. */
/* Define if the `getpgrp' function takes no argument. */
#undef GETPGRP_VOID
#undef NAMED_PIPES_MISSING
#undef OPENDIR_NOT_ROBUST
#undef PGRP_PIPE
/* Define if the setvbuf function takes the buffering type as its second
argument and the buffer pointer as the third, as on System V
before release 3. */
#undef SETVBUF_REVERSED
#undef STAT_MACROS_BROKEN
#undef ULIMIT_MAXFDS
#undef CAN_REDEFINE_GETENV
/* Characteristics of properties exported by the kernel. */
/* Define if the kernel can exec files beginning with #! */
#undef HAVE_HASH_BANG_EXEC
/* Define if you have the /dev/fd devices to map open files into the file system. */
#undef HAVE_DEV_FD
/* Defined to /dev/fd or /proc/self/fd (linux). */
#undef DEV_FD_PREFIX
/* Define if you have the /dev/stdin device. */
#undef HAVE_DEV_STDIN
/* Type and behavior of signal handling functions. */
/* Define as the return type of signal handlers (int or void). */
#undef RETSIGTYPE
/* Define if return type of signal handlers is void */
#undef VOID_SIGHANDLER
#undef MUST_REINSTALL_SIGHANDLERS
#undef JOB_CONTROL_MISSING
/* Define if system calls automatically restart after interruption
by a signal. */
#undef HAVE_RESTARTABLE_SYSCALLS
#undef HAVE_POSIX_SIGSETJMP
#undef HAVE_BSD_SIGNALS
#define DEFAULT_MAIL_DIRECTORY "/usr/spool/mail"
#undef HAVE_POSIX_SIGNALS
#undef HAVE_USG_SIGHOLD
#undef UNUSABLE_RT_SIGNALS
/* Presence of system and C library functions. */
/* Define if you have the bcopy function. */
#undef HAVE_BCOPY
/* Define if you have the bindtextdomain function. */
#undef HAVE_BINDTEXTDOMAIN
/* Define if you have the bzero function. */
#undef HAVE_BZERO
@ -406,6 +396,9 @@
/* Define if you have the dlsym function. */
#undef HAVE_DLSYM
/* Define if you don't have vprintf but do have _doprnt. */
#undef HAVE_DOPRNT
/* Define if you have the dup2 function. */
#undef HAVE_DUP2
@ -418,6 +411,9 @@
/* Define if you have the getgroups function. */
#undef HAVE_GETGROUPS
/* Define if you have the gethostbyname function. */
#undef HAVE_GETHOSTBYNAME
/* Define if you have the gethostname function. */
#undef HAVE_GETHOSTNAME
@ -427,18 +423,48 @@
/* Define if you have the getpeername function. */
#undef HAVE_GETPEERNAME
/* Define if you have the getrlimit function. */
#undef HAVE_GETRLIMIT
/* Define if you have the getrusage function. */
#undef HAVE_GETRUSAGE
/* Define if you have the getservbyname function. */
#undef HAVE_GETSERVBYNAME
/* Define if you have the gettext function. */
#undef HAVE_GETTEXT
/* Define if you have the gettimeofday function. */
#undef HAVE_GETTIMEOFDAY
/* Define if you have the getwd function. */
#undef HAVE_GETWD
/* Define if you have the inet_aton function. */
#undef HAVE_INET_ATON
/* Define if you have the killpg function. */
#undef HAVE_KILLPG
/* Define if you have the lstat function. */
#undef HAVE_LSTAT
/* Define if you have the memmove function. */
#undef HAVE_MEMMOVE
/* Define if you have the mkfifo function. */
#undef HAVE_MKFIFO
/* Define if you have the pathconf function. */
#undef HAVE_PATHCONF
/* Define if you have the putenv function. */
#undef HAVE_PUTENV
/* Define if you have the readlink function. */
#undef HAVE_READLINK
/* Define if you have the rename function. */
#undef HAVE_RENAME
@ -460,18 +486,27 @@
/* Define if you have the setlocale function. */
#undef HAVE_SETLOCALE
/* Define if you have the setostype function. */
#undef HAVE_SETOSTYPE
/* Define if you have the setvbuf function. */
#undef HAVE_SETVBUF
/* Define if you have the siginterrupt function. */
#undef HAVE_SIGINTERRUPT
/* Define if you have the POSIX.1-style sigsetjmp function. */
#undef HAVE_POSIX_SIGSETJMP
/* Define if you have the strcasecmp function. */
#undef HAVE_STRCASECMP
/* Define if you have the strchr function. */
#undef HAVE_STRCHR
/* Define if you have the strcoll function. */
#undef HAVE_STRCOLL
/* Define if you have the strerror function. */
#undef HAVE_STRERROR
@ -487,33 +522,50 @@
/* Define if you have the strtoul function. */
#undef HAVE_STRTOUL
/* Define if you have the tcgetattr function. */
#undef HAVE_TCGETATTR
/* Define if you have the strsignal function or macro. */
#undef HAVE_STRSIGNAL
/* Define if you have the sysconf function. */
#undef HAVE_SYSCONF
/* Define if you have the uname function. */
#undef HAVE_UNAME
/* Define if you have the tcgetattr function. */
#undef HAVE_TCGETATTR
/* Define if you have the tcgetpgrp function. */
#undef HAVE_TCGETPGRP
/* Define if you have the textdomain function. */
#undef HAVE_TEXTDOMAIN
/* Define if you have the times function. */
#undef HAVE_TIMES
/* Define if you have the ttyname function. */
#undef HAVE_TTYNAME
/* Define if you have the tzset function. */
#undef HAVE_TZSET
/* Define if you have the ulimit function. */
#undef HAVE_ULIMIT
#undef HAVE_TTYNAME
/* Define if you have the uname function. */
#undef HAVE_UNAME
/* Define if you have the vprintf function. */
#undef HAVE_VPRINTF
/* Define if you have the waitpid function. */
#undef HAVE_WAITPID
#undef HAVE_TCGETPGRP
/* Define if you have the wait3 function. */
#undef HAVE_WAIT3
#undef HAVE_GETTEXT
#undef HAVE_TEXTDOMAIN
/* Presence of certain system include files. */
#undef HAVE_BINDTEXTDOMAIN
#undef HAVE_STRCOLL
#undef HAVE_TZSET
/* Define if you have the <arpa/inet.h> header file. */
#undef HAVE_ARPA_INET_H
/* Define if you have the <dirent.h> header file. */
#undef HAVE_DIRENT_H
@ -521,6 +573,9 @@
/* Define if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define if you have the <libintl.h> header file. */
#undef HAVE_LIBINTL_H
/* Define if you have the <limits.h> header file. */
#undef HAVE_LIMITS_H
@ -530,6 +585,12 @@
/* Define if you have the <ndir.h> header file. */
#undef HAVE_NDIR_H
/* Define if you have the <netdh.h> header file. */
#undef HAVE_NETDB_H
/* Define if you have the <netinet/in.h> header file. */
#undef HAVE_NETINET_IN_H
/* Define if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
@ -542,6 +603,9 @@
/* Define if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define if you have the <stddef.h> header file. */
#undef HAVE_STDDEF_H
/* Define if you have the <sys/dir.h> header file. */
#undef HAVE_SYS_DIR_H
@ -572,6 +636,17 @@
/* Define if you have the <sys/stream.h> header file. */
#undef HAVE_SYS_STREAM_H
/* Define if you have <sys/time.h> */
#undef HAVE_SYS_TIME_H
#undef TIME_WITH_SYS_TIME
/* Define if you have <sys/times.h> */
#undef HAVE_SYS_TIMES_H
/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
#undef HAVE_SYS_WAIT_H
/* Define if you have the <termcap.h> header file. */
#undef HAVE_TERMCAP_H
@ -587,20 +662,7 @@
/* Define if you have the <varargs.h> header file. */
#undef HAVE_VARARGS_H
/* Define if you have the <libintl.h> header file. */
#undef HAVE_LIBINTL_H
/* Define if you have the <stddef.h> header file. */
#undef HAVE_STDDEF_H
/* Define if you have the <netdh.h> header file. */
#undef HAVE_NETDB_H
/* Define if you have the <netinet/in.h> header file. */
#undef HAVE_NETINET_IN_H
/* Define if you have the <arpa/inet.h> header file. */
#undef HAVE_ARPA_INET_H
/* Presence of certain system libraries. */
#undef HAVE_LIBDL
@ -608,6 +670,10 @@
#undef HAVE_LIBSOCKET
/* Define if on MINIX. */
#undef _MINIX
/* Are we running SVR5 (UnixWare 7)? */
#undef SVR5
@ -617,6 +683,9 @@
/* Are we running some version of SVR4? */
#undef SVR4
/* Define if job control is unusable or unsupported. */
#undef JOB_CONTROL_MISSING
/* Do we need to define _KERNEL to get the RLIMIT_* defines from
<sys/resource.h>? */
#undef RLIMIT_NEEDS_KERNEL
@ -624,6 +693,10 @@
/* Do strcoll(3) and strcmp(3) give different results in the default locale? */
#undef STRCOLL_BROKEN
#undef DUP2_BROKEN
#undef GETCWD_BROKEN
#include "config-bot.h"
#endif /* _CONFIG_H_ */

924
configure vendored

File diff suppressed because it is too large Load diff

View file

@ -1,12 +1,12 @@
dnl
dnl Configure script for bash-2.04
dnl Configure script for bash-2.05
dnl
dnl report bugs to chet@po.cwru.edu
dnl
dnl Process this file with autoconf to produce a configure script.
dnl checks for version info
AC_REVISION([for Bash 2.04, version 2.77, from autoconf version] AC_ACVERSION)dnl
AC_REVISION([for Bash 2.05, version 2.90, from autoconf version] AC_ACVERSION)dnl
AC_INIT(shell.h)
AC_CONFIG_HEADER(config.h)
@ -32,12 +32,12 @@ opt_with_installed_readline=no
#htmldir=
dnl some systems should be configured without gnu malloc by default
dnl some systems should be configured without the bash malloc by default
dnl and some need a special compiler or loader
dnl look in the NOTES file for more
case "${host_cpu}-${host_os}" in
alpha*-*) opt_bash_malloc=no ;; # alpha running osf/1 or linux
*[Cc]ray*-*) opt_bash_malloc=no ;; # Crays
*[[Cc]]ray*-*) opt_bash_malloc=no ;; # Crays
*-osf1*) opt_bash_malloc=no ;; # other osf/1 machines
sparc-svr4*) opt_bash_malloc=no ;; # sparc SVR4, SVR4.2
sparc-netbsd*) opt_bash_malloc=no ;; # needs 8-byte alignment
@ -47,13 +47,16 @@ sparc-linux*) opt_bash_malloc=no ;; # sparc running linux; requires ELF
#*-freebsd*) opt_bash_malloc=no ;; # they claim it's better
*-aix*) opt_bash_malloc=no ;; # AIX machines
*-nextstep*) opt_bash_malloc=no ;; # NeXT machines running NeXTstep
*-rhapsody*) opt_bash_malloc=no ;; # Apple Rhapsody
*-macos*) opt_bash_malloc=no ;; # Apple MacOS X
*-rhapsody*) opt_bash_malloc=no ;; # Apple Rhapsody (MacOS X)
*-darwin*) opt_bash_malloc=no ;; # Apple Darwin (MacOS X)
*-dgux*) opt_bash_malloc=no ;; # DG/UX machines
*-qnx*) opt_bash_malloc=no ;; # QNX 4.2
*-machten4) opt_bash_malloc=no ;; # MachTen 4.x
*-bsdi2.1|*-bsdi3.?) opt_bash_malloc=no ; : ${CC:=shlicc2} ;; # for loadable builtins
*-beos*) opt_bash_malloc=no ;; # they say it's suitable
*-cygwin32*) opt_bash_malloc=no ;; # Cygnus's CYGWIN32 environment
*-cygwin*) opt_bash_malloc=no ;; # Cygnus's CYGWIN environment
*-opennt*|*-interix*) opt_bash_malloc=no ;; # Interix, now owned by Microsoft
esac
dnl arguments to configure
@ -270,7 +273,7 @@ AC_CYGWIN
AC_MINGW32
AC_EXEEXT
dnl BEGIN changes for cross-building for cygwin32 and BeOS
dnl BEGIN changes for cross-building for cygwin and BeOS
SIGNAMES_H=lsignames.h
@ -283,7 +286,7 @@ dnl Set SIGNAMES_H based on whether or not we're cross-compiling.
if test "x$cross_compiling" = "xyes"; then
case "${host}" in
*-cygwin32*)
*-cygwin*)
cross_cache=${srcdir}/cross-build/cygwin32.cache
SIGNAMES_H='$(srcdir)/cross-build/win32sig.h'
;;
@ -333,6 +336,7 @@ if test "$opt_static_link" = yes; then
# if we're using gcc, add `-static' to LDFLAGS
if test -n "$GCC" || test "$ac_cv_prog_gcc" = "yes"; then
STATIC_LD="-static"
LDFLAGS="$LDFLAGS -static" # XXX experimental
fi
fi
@ -361,11 +365,11 @@ dnl the correct directory for the readline library
test "x$exec_prefix" = xNONE && _rl_exec_prefix=${_rl_prefix} || _rl_exec_prefix=${exec_prefix}
AC_MSG_CHECKING(version of installed readline library)
_rl_version=`exec_prefix=${_rl_exec_prefix} ${CONFIG_SHELL-/bin/sh} ${srcdir}/support/rlvers.sh -C "${CC}" -L ${libdir} -T ${TERMCAP_LIB}`
_rl_version=`exec_prefix=${_rl_exec_prefix} ${CONFIG_SHELL-/bin/sh} ${srcdir}/support/rlvers.sh -C "${CC}" -L ${libdir} -I ${includedir} -T ${TERMCAP_LIB}`
AC_MSG_RESULT($_rl_version)
case "$_rl_version" in
4.[[1-9]]*|5*|6*|7*|8*|9*) ;;
4.[[2-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)
@ -466,14 +470,15 @@ AC_CHECK_FUNC(mkfifo,AC_DEFINE(HAVE_MKFIFO),AC_DEFINE(MKFIFO_MISSING))
dnl checks for system calls
AC_CHECK_FUNCS(dup2 select getdtablesize getgroups gethostname \
setdtablesize getpagesize killpg lstat getpeername sbrk \
getrlimit getrusage gettimeofday waitpid tcgetpgrp rename)
getrlimit getrusage gettimeofday waitpid tcgetpgrp \
readlink rename)
dnl checks for c library functions
AC_CHECK_FUNCS(bcopy bzero confstr getcwd strcasecmp setenv putenv \
setlinebuf setlocale strchr strerror strtod strtol \
strtoul tcgetattr uname sysconf ulimit times tzset \
siginterrupt memmove ttyname gethostbyname inet_aton \
strpbrk setvbuf)
siginterrupt memmove ttyname gethostbyname getservbyname \
inet_aton strpbrk setvbuf pathconf)
dnl checks for locale functions
AC_CHECK_HEADERS(libintl.h)
@ -630,6 +635,7 @@ BASH_HAVE_FIONREAD
dnl miscellaneous
BASH_MISC_SPEED_T
BASH_CHECK_GETPW_FUNCS
BASH_CHECK_RTSIGS
dnl special checks
case "$host_os" in
@ -692,7 +698,7 @@ lynxos*) LOCAL_CFLAGS=-DRECYCLES_PIDS ;;
linux*) LOCAL_LDFLAGS=-rdynamic ;; # allow dynamic loading
*qnx*) LOCAL_CFLAGS="-Dqnx -F -3s" LOCAL_LDFLAGS="-3s -lunix -lncurses" ;;
powerux*) LOCAL_LIBS="-lgen" ;;
cygwin32*) LOCAL_LIBS="-luser32" ;;
cygwin*) LOCAL_LIBS="-luser32" ;;
opennt*|interix*) LOCAL_CFLAGS="-DNO_MAIN_ENV_ARG" ;;
esac
@ -705,9 +711,11 @@ esac
dnl FreeBSD-3.x can have either a.out or ELF
case "${host_os}" in
freebsd3*) if test -x /usr/bin/objformat && test "`/usr/bin/objformat`" = "elf" ; then
freebsd[[3-9]]*)
if test -x /usr/bin/objformat && test "`/usr/bin/objformat`" = "elf" ; then
LOCAL_LDFLAGS=-rdynamic # allow dynamic loading
fi ;;
freebsdelf*) LOCAL_LDFLAGS=-rdynamic ;; # allow dynamic loading
esac
case "$host_cpu" in
@ -730,7 +738,7 @@ esac
if test "$ac_cv_func_dlopen" = "yes" && test -f ${srcdir}/support/shobj-conf
then
AC_MSG_CHECKING(shared object configuration for loadable builtins)
eval `${CONFIG_SHELL-/bin/sh} ${srcdir}/support/shobj-conf -C "${CC}" -c ${host_cpu} -o ${host_os} -v ${host_vendor}`
eval `${CONFIG_SHELL-/bin/sh} ${srcdir}/support/shobj-conf -C "${CC}" -c "${host_cpu}" -o "${host_os}" -v "${host_vendor}"`
AC_SUBST(SHOBJ_CC)
AC_SUBST(SHOBJ_CFLAGS)
AC_SUBST(SHOBJ_LD)

View file

@ -39,7 +39,11 @@ copy_word (w)
WORD_DESC *new_word;
new_word = (WORD_DESC *)xmalloc (sizeof (WORD_DESC));
#if 1
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);
}
@ -291,6 +295,8 @@ copy_function_def (com)
new_def = (FUNCTION_DEF *)xmalloc (sizeof (FUNCTION_DEF));
new_def->name = copy_word (com->name);
new_def->command = copy_command (com->command);
new_def->flags = com->flags;
new_def->line = com->line;
return (new_def);
}
@ -338,8 +344,8 @@ copy_command (command)
break;
case cm_subshell:
new_command->value.Subshell = copy_subshell_command (command->value.Subshell);
break;
new_command->value.Subshell = copy_subshell_command (command->value.Subshell);
break;
case cm_case:
new_command->value.Case = copy_case_command (command->value.Case);
@ -356,8 +362,8 @@ copy_command (command)
#if defined (DPAREN_ARITHMETIC)
case cm_arith:
new_command->value.Arith = copy_arith_command (command->value.Arith);
break;
new_command->value.Arith = copy_arith_command (command->value.Arith);
break;
#endif
#if defined (COND_COMMAND)

220
doc/FAQ
View file

@ -1,4 +1,4 @@
This is the Bash FAQ, version 3.7, for Bash version 2.04.
This is the Bash FAQ, version 3.11, for Bash version 2.05.
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.04?
B2) Are there any user-visible incompatibilities between bash-2.04 and
B1) What's new in version 2.05?
B2) Are there any user-visible incompatibilities between bash-2.05 and
bash-1.14.7?
Section C: Differences from other Unix shells
@ -70,6 +70,10 @@ E5) I have a bunch of shell scripts that use backslash-escaped characters
in arguments to `echo'. Bash doesn't interpret these characters. Why
not, and how can I make it understand them?
E6) Why doesn't a while or for loop get suspended when I type ^Z?
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'?
Section F: Things to watch out for on certain Unix versions
@ -130,22 +134,22 @@ of Case Western Reserve University.
A2) What's the latest version?
The latest version is 2.04, first made available on Friday, 17 March 2000.
The latest version is 2.05, first made available on Monday, 9 April 2001.
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.04:
The following URLs tell how to get version 2.05:
ftp://ftp.gnu.org/pub/gnu/bash/bash-2.04.tar.gz
ftp://ftp.cwru.edu/pub/bash/bash-2.04.tar.gz
ftp://ftp.gnu.org/pub/gnu/bash/bash-2.05.tar.gz
ftp://ftp.cwru.edu/pub/bash/bash-2.05.tar.gz
Formatted versions of the documentation are available with the URLs:
ftp://ftp.gnu.org/pub/gnu/bash/bash-doc-2.04.tar.gz
ftp://ftp.cwru.edu/pub/bash/bash-doc-2.04.tar.gz
ftp://ftp.gnu.org/pub/gnu/bash/bash-doc-2.05.tar.gz
ftp://ftp.cwru.edu/pub/bash/bash-doc-2.05.tar.gz
A4) On what machines will bash run?
@ -160,7 +164,7 @@ More information appears in the file `INSTALL' in the distribution.
A5) Will bash run on operating systems other than Unix?
Configuration specifics for Unix-like systems such as QNX and
LynxOS are included in the distribution. Bash-2.04 should
LynxOS are included in the distribution. Bash-2.05 should
compile and run on Minix 2.0 (patches were contributed), but I
don't believe anyone has built bash-2.x on earlier Minix versions
yet.
@ -168,16 +172,17 @@ yet.
Bash has been ported to versions of Windows implementing the Win32
programming interface. This includes Windows 95 and Windows NT.
The port was done by Cygnus Solutions as part of their CYGWIN
project. For more information about the project, look at the URL
project. For more information about the project, look at the URLs
http:/sourceware.cygnus.com/cygwin
http://www.cygwin.com/
http://sourceware.cygnus.com/cygwin
Cygnus originally ported bash-1.14.7, and that port was part of their
early GNU-Win32 (the original name) releases. Cygnus has also done a
port of bash-2.02.1 to the CYGWIN environment, and it is available as
part of their current release. (They may have upgraded by now.)
port of bash-2.04 to the CYGWIN environment, and it is available as
part of their current release.
Bash-2.04 should require no local Cygnus changes to build and run under
Bash-2.05 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
@ -185,25 +190,13 @@ The Cygnus port works only on Intel machines. There is a port of bash
ftp://ftp.gnustep.org//pub/win32/bash-alpha-nt-1.01.tar.gz
Softway Systems has ported bash-2.01 to their Interix (nee OpenNT)
system, a Unix subsystem for NT that replaces the Microsoft POSIX
subsystem. Check out http://www.interix.com for more information.
Some support for Interix has been incorporated into bash, beginning
with Bash-2.03. It should be easier to build bash on Interix now,
but Interix users should fetch
ftp://ftp.interix.com/pub/tw/unsup/bash.diffs.tar.gz
and read the README.OpenNT file in that archive. It will detail the
arguments `configure' needs to build on Interix. A configure cache
file for Interix is in the bash distribution in cross-build/opennt.cache;
copy that to `config.cache' before starting configure.
D. J. Delorie has ported bash-1.14.7 to run under MS-DOS, as part of
the DJGPP project. For more information on the project, see
DJ Delorie has a port of bash-1.14.7 which runs under MS-DOS, as part
of the DJGPP project. For more information on the project, see
http://www.delorie.com/djgpp/
I have been told that the original DJGPP port was done by Daisuke Aoyama.
I picked up a binary of bash-1.14.7 that is purported to work with
the DJGPP V2 environment from
@ -374,18 +367,45 @@ Reference Manual.
Section B: The latest version
B1) What's new in version 2.04?
B1) What's new in version 2.05?
Bash-2.04 contains the following new features (see the manual page for
complete descriptions and the CHANGES and NEWS files in the bash-2.04
Bash-2.05 contains the following new features (see the manual page for
complete descriptions and the CHANGES and NEWS files in the bash-2.05
distribution):
o This version has once again reverted to using locales and strcoll(3) when
processing pattern matching bracket expressions, as POSIX requires.
o Added a new `--init-file' invocation argument as a synonym for `--rcfile',
per the new GNU coding standards.
o The /dev/tcp and /dev/udp redirections now accept service names as well as
port numbers.
o `complete' and `compgen' now take a `-o value' option, which controls some
of the aspects of that compspec. Valid values are:
default - perform bash default completion if programmable
completion produces no matches
dirnames - perform directory name completion if programmable
completion produces no matches
filenames - tell readline that the compspec produces filenames,
so it can do things like append slashes to
directory names and suppress trailing spaces
o A new loadable builtin, realpath, which canonicalizes and expands symlinks
in pathname arguments.
o When `set' is called without options, it prints function defintions in a
way that allows them to be reused as input. This affects `declare' and
`declare -p' as well. This only happens when the shell is not in POSIX
mode, since POSIX.2 forbids this behavior.
A short feature history dating from bash-2.0:
Bash-2.04 introduced the following new features:
o Programmable word completion with the new `complete' and `compgen' builtins;
examples are provided in examples/complete/complete-examples
o `history' has a new `-d' option to delete a history entry
o `bind' has a new `-x' option to bind key sequences to shell commands
o The prompt expansion code has new `\j' and `\l' escape sequences
o The `no_empty_command_completion' shell option, if enabled, inhibits
o The `no_empty_cmd_completion' shell option, if enabled, inhibits
command completion when TAB is typed on an empty line
o `help' has a new `-s' option to print a usage synopsis
o New arithmetic operators: var++, var--, ++var, --var, expr1,expr2 (comma)
@ -405,7 +425,7 @@ o A new shopt `xpg_echo' variable, to control the behavior of echo with
respect to backslash-escape sequences at runtime
o The NON_INTERACTIVE_LOGIN_SHELLS #define has returned
The version of Readline released with Bash-2.04, Readline-4.1, has several
The version of Readline released with Bash-2.04, Readline-4.1, had several
new features as well:
o Parentheses matching is always compiled into readline, and controllable
@ -417,8 +437,6 @@ o A new function for applications: rl_on_new_line_with_prompt()
o New variables for applications: rl_already_prompted, and rl_gnu_readline_p
A short feature history dating from bash-2.0:
Bash-2.03 had very few new features, in keeping with the convention
that odd-numbered releases provide mainly bug fixes. A number of new
features were added to Readline, mostly at the request of the Cygnus
@ -505,11 +523,11 @@ 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.04 and
B2) Are there any user-visible incompatibilities between bash-2.05 and
bash-1.14.7?
There are a few incompatibilities between version 1.14.7 and version 2.04.
They are detailed in the file COMPAT in the bash-2.04 distribution.
There are a few incompatibilities between version 1.14.7 and version 2.05.
They are detailed in the file COMPAT in the bash-2.05 distribution.
Section C: Differences from other Unix shells
@ -660,6 +678,7 @@ Things bash has or uses that ksh88 does not:
Things ksh88 has or uses that bash does not:
tracked aliases
variables: ERRNO, FPATH, EDITOR, VISUAL
trap on ERR
co-processes (|&, >&p, <&p)
weirdly-scoped functions
typeset +f to list all function names without definitions
@ -678,7 +697,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.04:
New things in ksh-93 not in bash-2.05:
associative arrays
floating point arithmetic
math library functions
@ -824,15 +843,15 @@ D4) How can I make my csh aliases work when I convert to bash?
Bash uses a different syntax to support aliases than csh does.
The details can be found in the documentation. We have provided
a shell script which does most of the work of conversion for you;
this script can be found in ./examples/misc/alias-conv.sh. Here is
this script can be found in ./examples/misc/aliasconv.sh. Here is
how you use it:
Start csh in the normal way for you. (e.g., `csh')
Pipe the output of `alias' through `alias-conv.sh', saving the
Pipe the output of `alias' through `aliasconv.sh', saving the
results into `bash_aliases':
alias | alias-conv.sh >bash_aliases
alias | bash aliasconv.sh >bash_aliases
Edit `bash_aliases', carefully reading through any created
functions. You will need to change the names of some csh specific
@ -967,7 +986,10 @@ E4) If I pipe the output of a command into `read variable', why doesn't
the output show up in $variable when the read command finishes?
This has to do with the parent-child relationship between Unix
processes.
processes. It affects all commands run in pipelines, not just
simple calls to `read'. For example, piping a command's output
into a `while' loop that repeatedly calls `read' will result in
the same behavior.
Each element of a pipeline runs in a separate process, a child of
the shell running the pipeline. A subprocess cannot affect its
@ -1058,6 +1080,100 @@ If you want to be able to stop the entire loop, you need to put it
within parentheses, which will force the loop into a subshell that
may be stopped (and subsequently restarted) as a single unit.
E7) What about empty for loops in Makefiles?
It's fairly common to see constructs like this in automatically-generated
Makefiles:
SUBDIRS = @SUBDIRS@
...
subdirs-clean:
for d in ${SUBDIRS}; do \
( cd $$d && ${MAKE} ${MFLAGS} clean ) \
done
When SUBDIRS is empty, this results in a command like this being passed to
bash:
for d in ; do
( cd $d && ${MAKE} ${MFLAGS} clean )
done
This is a syntax error. If the reserved word `in' is present, a word must
follow it before the semicolon or newline. The language in the manual page
referring to the list of words being empty refers to the list after it is
expanded. There must be at least one word following the `in' when the
construct is parsed.
The idiomatic Makefile solution is something like:
SUBDIRS = @SUBDIRS@
subdirs-clean:
subdirs=$SUBDIRS ; for d in $$subdirs; do \
( cd $$d && ${MAKE} ${MFLAGS} clean ) \
done
The POSIX.2 interpretation committee has considered this issue and declared
that the bash implemenation is correct, according to the standard:
http://www.pasc.org/interps/unofficial/db/p1003.2/pasc-1003.2-169.html
E8) Why does the arithmetic evaluation code complain about `08'?
The bash arithmetic evaluation code (used for `let', $(()), (()), and in
other places), interprets a leading `0' in numeric constants as denoting
an octal number, and a leading `0x' as denoting hexadecimal. This is
in accordance with the POSIX.2 spec, section 2.9.2.1, which states that
arithmetic constants should be handled as signed long integers as defined
by the ANSI/ISO C standard.
The POSIX.2 interpretation committee has confirmed this:
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.
The behavior of the matcher in bash-2.05 depends on the current LC_COLLATE
setting. Setting this variable to `C' or `POSIX' will result in the
traditional behavior ([A-Z] matches all uppercase ASCII characters).
Many other locales, including the en_US locale (the default on many US
versions of Linux) collate the upper and lower case letters like this:
AaBb...Zz
which means that [A-Z] matches every letter except `z'.
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.
Look at the manual pages for setlocale(3), strcoll(3), and, if it is
present, locale(1). If you have locale(1), you can use it to find
your current locale information even if you do not have any of the
LC_ variables set.
My advice is to put
export LC_COLLATE=C
into /etc/profile and inspect any shell scripts run from cron for
constructs like [A-Z]. This will prevent things like
rm [A-Z]*
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.
Section F: Things to watch out for on certain Unix versions
F1) Why can't I use command line editing in my `cmdtool'?
@ -1163,7 +1279,7 @@ comp.unix.shell). While most commands of the form
can be converted to `< file command', shell control structures such as
loops and subshells require `command < file'.
The file CWRU/sh-redir-hack in the bash-2.04 distribution is an
The file CWRU/sh-redir-hack in the bash-2.05 distribution is an
(unofficial) patch to parse.y that will modify the grammar to
support this construct. It will not apply with `patch'; you must
modify parse.y by hand. Note that if you apply this, you must
@ -1410,8 +1526,12 @@ H3) What's coming in future versions?
These are features I plan to include in a future version of bash.
a bash debugger (a minimally-tested version is included with bash-2.04)
a bash debugger (a minimally-tested version is included with bash-2.05)
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)
an implementation of the ksh-like ERR trap
H4) What's on the bash `wish list' for future versions?
@ -1428,11 +1548,11 @@ a better loadable interface to perl with access to the shell builtins and
H5) When will the next release appear?
The next version will appear sometime in 2000 or 2001. Never make
The next version will appear sometime in 2001 or 2002. Never make
predictions.
This document is Copyright 1995-2000 by Chester Ramey.
This document is Copyright 1995-2001 by Chester Ramey.
Permission is hereby granted, without written agreement and
without license or royalty fees, to use, copy, and distribute

View file

@ -110,10 +110,10 @@ RLUSER = $(RL_LIBDIR)/doc/rluser.texinfo
all: ps info dvi text html
nodvi: ps info text html
PSFILES = bash.ps bashbug.ps readline.ps article.ps builtins.ps rbash.ps
PSFILES = bash.ps bashbug.ps article.ps builtins.ps rbash.ps
DVIFILES = bashref.dvi bashref.ps
INFOFILES = bashref.info
MAN0FILES = bash.0 bashbug.0 builtins.0 rbash.0 readline.0
MAN0FILES = bash.0 bashbug.0 builtins.0 rbash.0
HTMLFILES = bashref.html bash.html
ps: ${PSFILES}
@ -162,8 +162,6 @@ bash.0: bash.1
bashbug.0: bashbug.1
builtins.0: builtins.1 bash.1
rbash.0: rbash.1 bash.1
readline.0: readline.3
readline.ps: readline.3
article.ps: article.ms
$(MAN2HTML): ${topdir}/support/man2html.c
@ -212,8 +210,6 @@ maintainer-clean: clean
installdirs:
-test -d $(man1dir) || $(SHELL) ${MKDIRS} $(man1dir)
# uncomment the next line to create the directory for the readline man page
# -test -d $(man3dir) || $(SHELL) ${MKDIRS} $(man3dir)
-test -d $(infodir) || $(SHELL) ${MKDIRS} $(infodir)
-if [ -n "$(htmldir)" ]; then \
test -d $(htmldir) || $(SHELL) ${MKDIRS} $(htmldir) ; \
@ -222,8 +218,6 @@ installdirs:
install: info installdirs
-$(INSTALL_DATA) $(srcdir)/bash.1 $(man1dir)/bash.${man1ext}
-$(INSTALL_DATA) $(srcdir)/bashbug.1 $(man1dir)/bashbug.${man1ext}
# uncomment the next line to install the readline man page
# -$(INSTALL_DATA) $(srcdir)/readline.3 $(man3dir)/readline.${man3ext}
# uncomment the next line to install the builtins man page
# $(INSTALL_DATA) $(srcdir)/builtins.1 $(man1dir)/bash_builtins.${man1ext}
-$(INSTALL_DATA) $(srcdir)/bashref.info $(infodir)/bash.info
@ -239,7 +233,6 @@ install: info installdirs
uninstall:
-$(RM) $(man1dir)/bash.${man1ext} $(man1dir)/bashbug.${man1ext}
-$(RM) $(man3dir)/readline.${man3ext}
$(RM) $(infodir)/bash.info
-if [ -n "$(htmldir)" ]; then \
$(RM) $(htmldir)/bash.html ; \
@ -256,3 +249,5 @@ posix: bashref.texi
$(SHELL) ./mkposix
cmp -s POSIX.NOTES ../CWRU/POSIX.NOTES || mv POSIX.NOTES ../CWRU/POSIX.NOTES
$(RM) POSIX.NOTES
xdist: inst posix

View file

@ -6,12 +6,12 @@
.\" Case Western Reserve University
.\" chet@ins.CWRU.Edu
.\"
.\" Last Change: Tue Mar 14 11:36:43 EST 2000
.\" Last Change: Mon Mar 5 10:19:14 EST 2001
.\"
.\" bash_builtins, strip all but Built-Ins section
.if \n(zZ=1 .ig zZ
.if \n(zY=1 .ig zY
.TH BASH 1 "2000 Mar 14" "GNU Bash-2.04"
.TH BASH 1 "2001 Mar 5" "GNU Bash-2.05"
.\"
.\" 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-1999 by the Free Software Foundation, Inc.
.if t Bash is Copyright \(co 1989-1999 by the Free Software Foundation, Inc.
.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.
.SH DESCRIPTION
.B Bash
is an \fBsh\fR-compatible command language interpreter that
@ -110,7 +110,7 @@ A list of all double-quoted strings preceded by \fB$\fP
is printed on the standard ouput.
These are the strings that
are subject to language translation when the current locale
is not C or POSIX.
is not \fBC\fP or \fBPOSIX\fP.
This implies the \fB\-n\fP option; no commands will be executed.
.TP
.B \-\-
@ -141,6 +141,20 @@ 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
.TP
\fB\-\-rcfile\fP \fIfile\fP
.PD
Execute commands from
.I file
instead of the standard personal initialization file
.I ~/.bashrc
if the shell is interactive (see
.SM
.B INVOCATION
below).
.TP
.B \-\-login
Make
.B bash
@ -178,17 +192,7 @@ This option is on by default if the shell is invoked as
.TP
.B \-\-posix
Change the behavior of \fBbash\fP where the default operation differs
from the POSIX 1003.2 standard to match the standard.
.TP
\fB\-\-rcfile\fP \fIfile\fP
Execute commands from
.I file
instead of the standard personal initialization file
.I ~/.bashrc
if the shell is interactive (see
.SM
.B INVOCATION
below).
from the POSIX 1003.2 standard to match the standard (\fIposix mode\fP).
.TP
.B \-\-restricted
The shell becomes restricted (see
@ -303,7 +307,8 @@ expanded value as the name of a file to read and execute.
behaves as if the following command were executed:
.sp .5
.RS
\f(CWif [ \-n "$BASH_ENV" ]; then . "$BASH_ENV"; fi\fP
.if t \f(CWif [ \-n "$BASH_ENV" ]; then . "$BASH_ENV"; fi\fP
.if n if [ \-n "$BASH_ENV" ]; then . "$BASH_ENV"; fi
.RE
.sp .5
but the value of the
@ -1119,7 +1124,7 @@ user is a member.
Assignments to
.SM
.B GROUPS
have no effect and are silently discarded.
have no effect and return an error status.
If
.SM
.B GROUPS
@ -1223,7 +1228,7 @@ This variable exists only when a shell function is executing.
Assignments to
.SM
.B FUNCNAME
have no effect and are silently discarded.
have no effect and return an error status.
If
.SM
.B FUNCNAME
@ -1376,7 +1381,9 @@ the shell looks for commands (see
below). The default path is system-dependent,
and is set by the administrator who installs
.BR bash .
A common value is ``/usr/gnu/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin:.''.
A common value is
.if t \f(CW/usr/gnu/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin:.\fP.
.if n ``/usr/gnu/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin:.''.
.TP
.B HOME
The home directory of the current user; the default argument for the
@ -1421,7 +1428,8 @@ often (in seconds)
.B bash
checks for mail. The default is 60 seconds. When it is time to check
for mail, the shell does so before displaying the primary prompt.
If this variable is unset, the shell disables mail checking.
If this variable is unset, or set to a value that is not a number
greater than or equal to zero, the shell disables mail checking.
.TP
.B MAILPATH
A colon-separated list of file names to be checked for mail.
@ -1578,6 +1586,14 @@ strings preceded by a \fB$\fP.
.B LC_NUMERIC
This variable determines the locale category used for number formatting.
.TP
.B LINES
Used by the \fBselect\fP builtin command to determine the column length
for printing selection lists. Automatically set upon receipt of a SIGWINCH.
.TP
.B COLUMNS
Used by the \fBselect\fP builtin command to determine the terminal width
when printing selection lists. Automatically set upon receipt of a SIGWINCH.
.TP
.B PROMPT_COMMAND
If set, the value is executed as a command prior to issuing each primary
prompt.
@ -2502,9 +2518,10 @@ Matches any single character.
.TP
.B [...]
Matches any one of the enclosed characters. A pair of characters
separated by a minus sign denotes a
.IR range ;
any character lexically between those two characters, inclusive,
separated by a hyphen denotes a
\fIrange expression\fP;
any character that sorts between those two characters, inclusive,
using the current locale's collating sequence and character set,
is matched. If the first character following the
.B [
is a
@ -2512,6 +2529,9 @@ is a
or a
.B ^
then any character not enclosed is matched.
The sorting order of characters in range expressions is determined by
the current locale and the value of the \fBLC_COLLATE\fP shell variable,
if set.
A
.B \-
may be matched by including it as the first or last character
@ -3990,6 +4010,7 @@ command or the text of a macro and a key sequence to which
it should be bound. The name may be specified in one of two ways:
as a symbolic key name, possibly with \fIMeta\-\fP or \fIControl\-\fP
prefixes, or as a key sequence.
.PP
When using the form \fBkeyname\fP:\^\fIfunction\-name\fP or \fImacro\fP,
.I keyname
is the name of a key spelled out in English. For example:
@ -4013,7 +4034,8 @@ and
.I C\-o
is bound to run the macro
expressed on the right hand side (that is, to insert the text
.I "> output"
.if t \f(CW> output\fP
.if n ``> output''
into the line).
.PP
In the second form, \fB"keyseq"\fP:\^\fIfunction\-name\fP or \fImacro\fP,
@ -4023,7 +4045,8 @@ differs from
above in that strings denoting
an entire key sequence may be specified by placing the sequence
within double quotes. Some GNU Emacs style key escapes can be
used, as in the following example.
used, as in the following example, but the symbolic character names
are not recognized.
.sp
.RS
"\eC\-u": universal\-argument
@ -4043,7 +4066,9 @@ is bound to the function
and
.I "ESC [ 1 1 ~"
is bound to insert the text
.BR "Function Key 1" .
.if t \f(CWFunction Key 1\fP.
.if n ``Function Key 1''.
.PP
The full set of GNU Emacs style escape sequences is
.RS
.PD 0
@ -4467,8 +4492,8 @@ This is a non-incremental search.
.TP
.B yank\-nth\-arg (M\-C\-y)
Insert the first argument to the previous command (usually
the second word on the previous line) at point (the current
cursor position). With an argument
the second word on the previous line) at point.
With an argument
.IR n ,
insert the \fIn\fPth word from the previous command (the words
in the previous command begin with word 0). A negative argument
@ -4527,7 +4552,7 @@ argument is ignored.
.PD 0
.TP
.B delete\-char (C\-d)
Delete the character under the cursor. If point is at the
Delete the character at point. If point is at the
beginning of the line, there are no characters in the line, and
the last character typed was not bound to \fBdelete\-char\fP,
then return
@ -4554,15 +4579,15 @@ Insert a tab character.
Insert the character typed.
.TP
.B transpose\-chars (C\-t)
Drag the character before point forward over the character at point.
Point moves forward as well.
If point is at the end of the line, then transpose the two characters
before point.
Drag the character before point forward over the character at point,
moving point forward as well.
If point is at the end of the line, then this transposes
the two characters before point.
Negative arguments have no effect.
.TP
.B transpose\-words (M\-t)
Drag the word before point past the word after point,
moving the point over that word as well.
moving point over that word as well.
.TP
.B upcase\-word (M\-u)
Uppercase the current (or following) word. With a negative argument,
@ -4605,7 +4630,6 @@ Word boundaries are the same as those used by \fBbackward\-word\fP.
.TP
.B unix\-word\-rubout (C\-w)
Kill the word behind point, using white space as a word boundary.
The word boundaries are different from \fBbackward\-kill\-word\fP.
The killed text is saved on the kill-ring.
.TP
.B delete\-horizontal\-space (M\-\e)
@ -4626,7 +4650,7 @@ Copy the word following point to the kill buffer.
The word boundaries are the same as \fBforward\-word\fP.
.TP
.B yank (C\-y)
Yank the top of the kill ring into the buffer at the cursor.
Yank the top of the kill ring into the buffer at point.
.TP
.B yank\-pop (M\-y)
Rotate the kill ring, and yank the new top. Only works following
@ -4682,8 +4706,9 @@ Similar to \fBcomplete\fP, but replaces the word to be completed
with a single match from the list of possible completions.
Repeated execution of \fBmenu\-complete\fP steps through the list
of possible completions, inserting each match in turn.
At the end of the list of completions, the bell is rung and the
original text is restored.
At the end of the list of completions, the bell is rung
(subject to the setting of \Bbell\-style\fP)
and the original text is restored.
An argument of \fIn\fP moves \fIn\fP positions forward in the list
of matches; a negative argument may be used to move backward
through the list.
@ -4802,7 +4827,7 @@ command enough times to return the line to its initial state.
Perform tilde expansion on the current word.
.TP
.B set\-mark (C\-@, M\-<space>)
Set the mark to the current point. If a
Set the mark to the point. If a
numeric argument is supplied, the mark is set to that position.
.TP
.B exchange\-point\-and\-mark (C\-x C\-x)
@ -4975,10 +5000,17 @@ options are added to each member of the completion list, and the result is
returned to the readline completion code as the list of possible
completions.
.PP
If a compspec is found, whatever it generates is returned to the completion
code as the full set of possible completions.
If the previously-applied actions do not generate any matches, and the
\fB\-o dirnames\fP option was supplied to \fBcomplete\fP when the
compspec was defined, directory name completion is attempted.
.PP
By default, if a compspec is found, whatever it generates is returned
to the completion code as the full set of possible completions.
The default \fBbash\fP completions are not attempted, and the readline
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.
.SH HISTORY
When the
.B \-o history
@ -5377,7 +5409,8 @@ are used to find the directory containing
The file searched for in
.SM
.B PATH
need not be executable. The current directory is
need not be executable.
When \fBbash\fP is not in \fIposix mode\fP, the current directory is
searched if no file is found in
.SM
.BR PATH .
@ -5454,7 +5487,7 @@ Acceptable
.I keymap
names are
\fIemacs, emacs\-standard, emacs\-meta, emacs\-ctlx, vi,
vi\-command\fP, and
vi\-move, vi\-command\fP, and
.IR vi\-insert .
\fIvi\fP is equivalent to \fIvi\-command\fP; \fIemacs\fP is
equivalent to \fIemacs\-standard\fP.
@ -5639,7 +5672,7 @@ The return value is true unless an invalid option is supplied, or no
matches were generated.
.TP
.PD 0
\fBcomplete\fP [\fB\-abcdefjkvu\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\-abcdefjkvu\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]
.TP
@ -5665,6 +5698,24 @@ builtin is invoked.
.RS
.PD 0
.TP 8
\fB\-o\fP \fIcomp-option\fP
The \fIcomp-option\fP controls several aspects of the compspec's behavior
beyond the simple generation of completions.
\fIcomp-option\fP may be one of:
.RS
.TP 8
.B default
Use readline's default completion if the compspec generates no matches.
.TP 8
.B dirnames
Perform directory name completion if the compspec generates no matches.
.TP 8
.B filenames
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.
.RE
.TP 8
\fB\-A\fP \fIaction\fP
The \fIaction\fP may be one of the following to generate a list of possible
completions:
@ -5964,7 +6015,7 @@ the following backslash-escaped characters is enabled. The
.B \-E
option disables the interpretation of these escape characters,
even on systems where they are interpreted by default.
The \fBxpg_echo\fP shell option to the may be used to
The \fBxpg_echo\fP shell option may be used to
dynamically determine whether or not \fBecho\fP expands these
escape characters by default.
.B echo
@ -6029,7 +6080,8 @@ binary found via the
.SM
.B PATH
instead of the shell builtin version, run
\f(CWenable -n test\fP.
.if t \f(CWenable -n test\fP.
.if n ``enable -n test''.
The
.B \-f
option means to load the new builtin command
@ -6885,8 +6937,8 @@ Options, if specified, have the following meanings:
.PD 0
.TP 8
.B \-a
Automatically mark variables which are modified or created for export
to the environment of subsequent commands.
Automatically mark variables and functions which are modified or created
for export to the environment of subsequent commands.
.TP 8
.B \-b
Report the status of terminated background jobs
@ -6978,7 +7030,10 @@ Enable command history, as described above under
This option is on by default in interactive shells.
.TP 8
.B ignoreeof
The effect is as if the shell command \f(CWIGNOREEOF=10\fP had been executed
The effect is as if the shell command
.if t \f(CWIGNOREEOF=10\fP
.if n ``IGNOREEOF=10''
had been executed
(see
.B Shell Variables
above).
@ -7023,7 +7078,7 @@ Same as
Change the behavior of
.B bash
where the default operation differs
from the POSIX 1003.2 standard to match the standard.
from the POSIX 1003.2 standard to match the standard (\fIposix mode\fP).
.TP 8
.B privileged
Same as
@ -7621,7 +7676,9 @@ either returns the name of the disk file
that would be executed if
.I name
were specified as a command name,
or nothing if \f(CWtype -t name\fP
or nothing if
.if t \f(CWtype -t name\fP
.if n ``type -t name''
would not return
.IR file .
If a command is hashed,

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -434,6 +434,7 @@ parser_error (lineno, format, va_alist)
exit (2);
}
#ifdef DEBUG
void
#if defined (PREFER_STDARG)
itrace (const char *format, ...)
@ -500,6 +501,7 @@ trace (format, va_alist)
}
#endif /* USE_VARARGS */
#endif /* DEBUG */
static char *cmd_error_table[] = {
"unknown command error", /* CMDERR_DEFAULT */

4
eval.c
View file

@ -140,10 +140,10 @@ reader_loop ()
exec_done:
if (current_command)
{
{
dispose_command (current_command);
current_command = (COMMAND *)NULL;
}
}
QUIT;
}

View file

@ -352,7 +352,7 @@ _complete_meta_func()
if [[ $prev == -A ]]; then
COMPREPLY=(alias arrayvar binding builtin command directory \
disabled enabled export file function helptopic hostname job keyword \
disabled enabled export file 'function' helptopic hostname job keyword \
running setopt shopt signal stopped variable)
return 0
elif [[ $prev == -F ]]; then
@ -400,7 +400,11 @@ _make_targets ()
esac
# make reads `makefile' before `Makefile'
if [ -f makefile ]; then
# GNU make reads `GNUmakefile' before all other makefiles, but we
# check that we're completing `gmake' before checking for it
if [ -f GNUmakefile ] && [ ${COMP_WORDS[0]} == gmake ]; then
mdef=GNUmakefile
elif [ -f makefile ]; then
mdef=makefile
elif [ -f Makefile ]; then
mdef=Makefile
@ -458,11 +462,13 @@ complete -d mkdir rmdir
complete -f strip
complete -f -X '*.gz' gzip
complete -f -X '*.bz2' bzip2
complete -f -X '*.Z' compress
complete -f -X '!*.+(gz|tgz|Gz)' gunzip gzcat zcat zmore
complete -f -X '!*.Z' uncompress zmore zcat
complete -f -X '!*.+(gif|jpg|jpeg|GIF|JPG|bmp)' xv
complete -f -X '!*.bz2' bunzip2
complete -f -X '!*.zip' unzip
complete -f -X '!*.+(gif|jpg|jpeg|GIF|JPG|JPEG|bmp)' xv
complete -f -X '!*.pl' perl perl5
@ -472,11 +478,14 @@ complete -A hostname rxterm rxterm3 rxvt2
complete -u su
complete -f -X '!*.+(ps|PS)' gs gv ghostview psselect pswrap
complete -f -X '!*.+(dvi|DVI)' dvips xdvi dviselect dvitype
complete -f -X '!*.+(pdf|PDF)' acroread
complete -f -X '!*.+(dvi|DVI)' dvips xdvi dviselect dvitype catdvi
complete -f -X '!*.+(pdf|PDF)' acroread4
complete -f -X '!*.texi*' makeinfo texi2dvi texi2html
complete -f -X '!*.+(tex|TEX)' tex latex slitex
complete -f -X '!*.+(mp3|MP3)' mpg123
complete -f -X '!*.+(htm|html)' links w3m lynx
#
# other possibilities, left as exercises
#

View file

@ -0,0 +1,31 @@
#Date: Wed, 31 Jan 2001 12:53:56 -0800
#From: Aaron Smith <aaron@mutex.org>
#To: freebsd-ports@freebsd.org
#Subject: useful bash completion function for pkg commands
#Message-ID: <20010131125356.G52003@gelatinous.com>
#hi all. i just wanted to share this bash completion function i wrote that
#completes package names for pkg_info and pkg_delete. i find this a great
#help when dealing with port management. programmed completion requires
#bash-2.04.
_pkg_func ()
{
local cur
cur=${COMP_WORDS[COMP_CWORD]}
if [[ $cur == '-' ]]; then
if [[ ${COMP_WORDS[0]} == 'pkg_info' ]]; then
COMPREPLY=(-a -c -d -D -i -k -r -R -p -L -q -I -m -v -e -l)
return 0;
elif [[ ${COMP_WORDS[0]} == 'pkg_delete' ]]; then
COMPREPLY=(-v -D -d -n -f -p)
return 0;
fi
fi
COMPREPLY=( $(compgen -d /var/db/pkg/$cur | sed sN/var/db/pkg/NNg) )
return 0
}
complete -F _pkg_func pkg_delete pkg_info

View file

@ -0,0 +1,433 @@
#####
#To: chet@po.cwru.edu, sarahmckenna@lucent.com
#Message-Id: <slrn8mqioc.msb.ian@lovelorn.linuxcare.com>
#Posted-To: comp.unix.shell, gnu.bash.bug
#Subject: bash 2.04 programmable completion examples
#Reply-To: ian@linuxcare.com, ian@caliban.org
#Summary: examples of programmable completion for bash 2.04
#Date: Thu, 13 Jul 2000 00:52:33 -0400 (EDT)
#From: ianmacd@linuxcare.com (Ian Macdonald)
#####
#########################################################################
# Turn on extended globbing
shopt -s extglob
# A lot of the following one-liners were taken directly from the
# completion examples provided with the bash 2.04 source distribution
# Make directory commands see only directories
complete -d cd mkdir rmdir pushd
# Make file commands see only files
complete -f cat less more chown ln strip
complete -f -X '*.gz' gzip
complete -f -X '*.Z' compress
complete -f -X '!*.+(Z|gz|tgz|Gz)' gunzip zcat zmore
complete -f -X '!*.Z' uncompress zmore zcat
complete -f -X '!*.+(gif|jpg|jpeg|GIF|JPG|bmp)' ee xv
complete -f -X '!*.+(ps|PS|ps.gz)' gv
complete -f -X '!*.+(dvi|DVI)' dvips xdvi dviselect dvitype
complete -f -X '!*.+(pdf|PDF)' acroread xpdf
complete -f -X '!*.texi*' makeinfo texi2dvi texi2html
complete -f -X '!*.+(tex|TEX)' tex latex slitex
complete -f -X '!*.+(mp3|MP3)' mpg123
# kill sees only signals
complete -A signal kill -P '%'
# user commands see only users
complete -u finger su usermod userdel passwd
# bg completes with stopped jobs
complete -A stopped -P '%' bg
# other job commands
complete -j -P '%' fg jobs disown
# network commands complete with hostname
complete -A hostname ssh rsh telnet rlogin ftp ping fping host traceroute \
nslookup
# export and others complete with shell variables
complete -v export local readonly unset
# set completes with set options
complete -A setopt set
# shopt completes with shopt options
complete -A shopt shopt
# helptopics
complete -A helptopic help
# unalias completes with aliases
complete -a unalias
# various commands complete with commands
complete -c command type nohup exec nice eval strace gdb
# bind completes with readline bindings (make this more intelligent)
complete -A binding bind
# Now we get to the meat of the file, the functions themselves. Some
# of these are works in progress. Most assume GNU versions of the
# tools in question and may require modifications for use on vanilla
# UNIX systems.
#
# A couple of functions may have non-portable, Linux specific code in
# them, but this will be noted where applicable
# GNU chown(1) completion. This should be expanded to allow the use of
# ':' as well as '.' as the user.group separator.
#
_chown ()
{
local cur prev user group
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
# do not attempt completion if we're specifying an option
if [ "${cur:0:1}" = "-" ]; then return 0; fi
# first parameter on line or first since an option?
if [ $COMP_CWORD -eq 1 ] || [ "${prev:0:1}" = "-" ]; then
case "$cur" in
[a-zA-Z]*.*)
user=${cur%.*}
group=${cur#*.}
COMPREPLY=( $( awk 'BEGIN {FS=":"} \
{if ($1 ~ /^'$group'/) print $1}' \
/etc/group ) )
for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
COMPREPLY[i]=$user.${COMPREPLY[i]}
done
return 0
;;
*)
COMPREPLY=( $( compgen -u $cur -S '.' ) )
return 0
;;
esac
else
COMPREPLY=( $( compgen -f $cur ) )
fi
return 0
}
complete -F _chown chown
# umount(8) completion. This relies on the mount point being the third
# space-delimited field in the output of mount(8)
#
_umount ()
{
local cur
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
# could rewrite the cut | grep to be a sed command, but this is
# clearer and doesn't result in much overhead
COMPREPLY=( $( mount | cut -d' ' -f 3 | grep ^$cur) )
return 0
}
complete -F _umount umount
# GID completion. This will get a list of all valid group names from
# /etc/group and should work anywhere.
#
_gid_func ()
{
local cur
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $( awk 'BEGIN {FS=":"} {if ($1 ~ /^'$cur'/) print $1}' \
/etc/group ) )
return 0
}
complete -F _gid_func groupdel groupmod
# mount(8) completion. This will pull a list of possible mounts out of
# /etc/fstab, unless the word being completed contains a ':', which
# would indicate the specification of an NFS server. In that case, we
# query the server for a list of all available exports and complete on
# that instead.
#
_mount ()
{ local cur
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
case "$cur" in
*:*)
COMPREPLY=( $( /usr/sbin/showmount -e --no-headers ${cur%%:*} |\
grep ^${cur#*:} | awk '{print $1}'))
return 0
;;
*)
COMPREPLY=( $( awk '{if ($2 ~ /\//) print $2}' /etc/fstab | \
grep ^$cur ))
return 0
;;
esac
}
complete -F _mount mount
# Linux rmmod(1) completion. This completes on a list of all currently
# installed kernel modules.
#
_rmmod ()
{
local cur
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=($( lsmod | awk '{if (NR != 1 && $1 ~ /^'$cur'/) print $1}'))
return 0
}
complete -F _rmmod rmmod
# Linux insmod(1) completion. This completes on a list of all
# available modules for the version of the kernel currently running.
#
_insmod ()
{
local cur modpath
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
modpath=/lib/modules/`uname -r`
COMPREPLY=($( ls -R $modpath | sed -ne 's/^\('$cur'.*\)\.o$/\1/p'))
return 0
}
complete -F _insmod insmod depmod modprobe
# man(1) completion. This relies on the security enhanced version of
# GNU locate(1). UNIX variants having non-numeric man page sections
# other than l, m and n should add the appropriate sections to the
# first clause of the case statement.
#
# This is Linux specific, in that 'man <section> <page>' is the
# expected syntax. This allows one to do something like
# 'man 3 str<tab>' to obtain a list of all string handling syscalls on
# the system.
#
_man ()
{
local cur prev
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
case "$prev" in
[0-9lmn])
COMPREPLY=($( slocate -ql 0 -r '/man/man'$prev'/'$cur | \
sed -ne 's/^.*\/\('$cur'[^.\/]*\)\..*$/\1/p' ))
return 0
;;
*)
COMPREPLY=($( slocate -ql 0 -r '/man/man./'$cur | \
sed -ne 's/^.*\/\('$cur'[^.\/]*\)\..*$/\1/p' ))
return 0
;;
esac
}
complete -F _man man
# Linux killall(1) completion. This wouldn't be much use on, say,
# Solaris, where killall does exactly that: kills ALL processes.
#
# This could be improved. For example, it currently doesn't take
# command line options into account
#
_killall ()
{
local cur prev
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
case "$prev" in
-[A-Z0-9]*)
# get a list of processes (the first sed evaluation
# takes care of swapped out processes, the second
# takes care of getting the basename of the process)
COMPREPLY=( $( ps ahx | awk '{if ($5 ~ /^'$cur'/) print $5}' | \
sed -e 's#[]\[]##g' -e 's#^.*/##' ))
return 0
;;
esac
# first parameter can be either a signal or a process
if [ $COMP_CWORD -eq 1 ]; then
# standard signal completion is rather braindead, so we need
# to hack around to get what we want here, which is to
# complete on a dash, followed by the signal name minus
# the SIG prefix
COMPREPLY=( $( compgen -A signal SIG${cur#-} ))
for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
COMPREPLY[i]=-${COMPREPLY[i]#SIG}
done
fi
# get processes, adding to signals if applicable
COMPREPLY=( ${COMPREPLY[*]} $( ps ahx | \
awk '{if ($5 ~ /^'$cur'/) print $5}' | \
sed -e 's#[]\[]##g' -e 's#^.*/##' ))
return 0
}
complete -F _killall killall
# GNU find(1) completion. This makes heavy use of ksh style extended
# globs and contains Linux specific code for completing the parameter
# to the -fstype option.
#
_find ()
{
local cur prev
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]#-}
prev=${COMP_WORDS[COMP_CWORD-1]}
case "$prev" in
-@(max|min)depth)
COMPREPLY=( $( compgen -W '0 1 2 3 4 5 6 7 8 9' ) )
return 0
;;
-?(a)newer|-fls|-fprint?(0|f))
COMPREPLY=( $( compgen -f $cur ) )
return 0
;;
-fstype)
# this is highly non-portable (the option to -d is a tab)
COMPREPLY=( $( cut -d' ' -f 2 /proc/filesystems | grep ^$cur ) )
return 0
;;
-gid)
COMPREPLY=( $( awk 'BEGIN {FS=":"} \
{if ($3 ~ /^'$cur'/) print $3}' /etc/group ) )
return 0
;;
-group)
COMPREPLY=( $( awk 'BEGIN {FS=":"} \
{if ($1 ~ /^'$cur'/) print $1}' /etc/group ) )
return 0
;;
-?(x)type)
COMPREPLY=( $( compgen -W 'b c d p f l s' $cur ) )
return 0
;;
-uid)
COMPREPLY=( $( awk 'BEGIN {FS=":"} \
{if ($3 ~ /^'$cur'/) print $3}' /etc/passwd ) )
return 0
;;
-user)
COMPREPLY=( $( compgen -u $cur ) )
return 0
;;
-[acm]min|-[acm]time|-?(i)?(l)name|-inum|-?(i)path|-?(i)regex| \
-links|-perm|-size|-used|-exec|-ok|-printf)
# do nothing, just wait for a parameter to be given
return 0
;;
esac
# complete using basic options ($cur has had its dash removed here,
# as otherwise compgen will bomb out with an error, since it thinks
# the dash is an option to itself)
COMPREPLY=( $( compgen -W 'daystart depth follow help maxdepth \
mindepth mount noleaf version xdev amin anewer atime \
cmin cnewer ctime empty false fstype gid group ilname \
iname inum ipath iregex links lname mmin mtime name \
newer nouser nogroup perm regex size true type uid \
used user xtype exec fls fprint fprint0 fprintf ok \
print print0 printf prune ls' $cur ) )
# this removes any options from the list of completions that have
# already been specified somewhere on the command line.
COMPREPLY=( $( echo "${COMP_WORDS[@]}-" | \
(while read -d '-' i; do
[ "$i" == "" ] && continue
# flatten array with spaces on either side,
# otherwise we cannot grep on word boundaries of
# first and last word
COMPREPLY=" ${COMPREPLY[@]} "
# remove word from list of completions
COMPREPLY=( ${COMPREPLY/ ${i%% *} / } )
done
echo ${COMPREPLY[@]})
) )
# put dashes back
for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
COMPREPLY[i]=-${COMPREPLY[i]}
done
return 0
}
complete -F _find find
# Linux ifconfig(8) completion
#
_ifconfig ()
{
local cur
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
case "${COMP_WORDS[1]}" in
-|*[0-9]*)
COMPREPLY=( $( compgen -W '-a up down arp promisc allmulti \
metric mtu dstaddr netmask add del \
tunnel irq io_addr mem_start media \
broadcast pointopoint hw multicast \
address txqueuelen' $cur ))
COMPREPLY=( $( echo " ${COMP_WORDS[@]}" | \
(while read -d ' ' i; do
[ "$i" == "" ] && continue
# flatten array with spaces on either side,
# otherwise we cannot grep on word
# boundaries of first and last word
COMPREPLY=" ${COMPREPLY[@]} "
# remove word from list of completions
COMPREPLY=( ${COMPREPLY/ $i / } )
done
echo ${COMPREPLY[@]})
) )
return 0
;;
esac
COMPREPLY=( $( ifconfig -a | sed -ne 's/^\('$cur'[^ ]*\).*$/\1/p' ))
}
complete -F _ifconfig ifconfig
# Linux ipsec(8) completion (for FreeS/WAN). Very basic.
#
_ipsec ()
{
local cur
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $( compgen -W 'auto barf eroute klipsdebug look manual \
pluto ranbits rsasigkey setup showdefaults \
showhostkey spi spigrp tncfg whack' $cur ))
}
complete -F _ipsec ipsec
#########################################################################

View file

@ -0,0 +1,271 @@
#####
#From: ian@linuxcare.com (Ian Macdonald)
#Newsgroups: comp.unix.shell
#Subject: More bash 2.04 completions
#Date: 12 Aug 2000 09:53:40 GMT
#Organization: Linuxcare, Inc.
#Lines: 274
#Message-ID: <slrn8pa7l2.jgm.ian@lovelorn.linuxcare.com>
#Reply-To: ian@linuxcare.com
#####
# Turn on extended globbing
shopt -s extglob
# cvs(1) completion
#
_cvs ()
{
local cur prev
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
if [ $COMP_CWORD -eq 1 ] || [ "${prev:0:1}" = "-" ]; then
COMPREPLY=( $( compgen -W 'add admin checkout commit diff \
export history import log rdiff release remove rtag status \
tag update' $cur ))
else
COMPREPLY=( $( compgen -f $cur ))
fi
return 0
}
complete -F _cvs cvs
# rpm(8) completion. This isn't exhaustive yet, but still provides
# quite a lot of functionality.
#
_rpm()
{
dashify()
{
local i
for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
if [ ${#COMPREPLY[i]} -le 2 ]; then
COMPREPLY[i]=-${COMPREPLY[i]}
else
COMPREPLY[i]=--${COMPREPLY[i]}
fi
done
}
local cur cur_nodash prev
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
cur_nodash=${cur#-}
prev=${COMP_WORDS[COMP_CWORD-1]}
if [ $COMP_CWORD = 1 ]; then
# first parameter on line
case "$cur" in
-b*)
COMPREPLY=( $( compgen -W 'ba bb bc bi bl bp bs' \
$cur_nodash ) )
dashify
return 0
;;
-t*)
COMPREPLY=( $( compgen -W 'ta tb tc ti tl tp ts' \
$cur_nodash ) )
dashify
return 0
;;
--*)
COMPREPLY=( $( compgen -W 'help version initdb \
checksig recompile rebuild resign addsign rebuilddb \
showrc setperms setgids' ${cur_nodash#-} ) )
dashify;
return 0
;;
*)
COMPREPLY=( $( compgen -W 'b e F i q t U V' \
$cur_nodash ) )
dashify
return 0
;;
esac
fi
case "${COMP_WORDS[1]}" in
-[iFU]*)
# complete on list of relevant options
COMPREPLY=( $( compgen -W 'percent force test replacepkgs \
replacefiles root excludedocs includedocs noscripts rcfile \
ignorearch dbpath prefix ignoreos nodeps allfiles ftpproxy \
ftpport justdb httpproxy httpport noorder relocate badreloc \
notriggers excludepath ignoresize oldpackage' ${cur_nodash#-} ))
dashify;
# return if $cur is an option
[ "${cur:0:1}" = "-" ] && return 0
# add a list of RPMS to possible completions
COMPREPLY=( ${COMPREPLY[@]} $( compgen -G $cur\*.rpm ) )
return 0
;;
-qp*)
# complete on list of relevant options
COMPREPLY=( $( compgen -W 'scripts root rcfile whatprovides \
whatrequires requires triggeredby ftpport ftpproxy httpproxy \
httpport provides triggers dump changelog dbpath filesbypkg' \
${cur_nodash#-} ) )
dashify;
# return if $cur is an option
[ "${cur:0:1}" = "-" ] && return 0
# add a list of RPMS to possible completions
COMPREPLY=( ${COMPREPLY[@]} $( compgen -G $cur\*.rpm ) )
return 0
;;
-*f)
# standard filename completion
COMPREPLY=( $( compgen -f $cur ) )
return 0
;;
-e)
# complete on list of relevant options
COMPREPLY=( $( compgen -W 'allmatches noscripts notriggers \
nodeps test' ${cur_nodash#-} ) )
dashify;
# return if $cur is an option
[ "${cur:0:1}" = "-" ] && return 0
# complete on basename of installed RPMs
COMPREPLY=( $( rpm -qa | \
sed -ne 's/^\('$cur'.*\)-[0-9a-zA-Z._]\+-[0-9.]\+$/\1/p' ) )
return 0
;;
-qa*)
# complete on list of relevant options
COMPREPLY=( $( compgen -W 'scripts root rcfile whatprovides \
whatrequires requires triggeredby ftpport ftpproxy httpproxy \
httpport provides triggers dump changelog dbpath specfile \
querybynumber last filesbypkg' ${cur_nodash#-} ) )
dashify;
return 0
;;
-q*)
# complete on list of relevant options
COMPREPLY=( $( compgen -W 'scripts root rcfile whatprovides \
whatrequires requires triggeredby ftpport ftpproxy httpproxy \
httpport provides triggers dump changelog dbpath specfile \
querybynumber last filesbypkg' ${cur_nodash#-} ) )
dashify;
# return if $cur is an option
[ "${cur:0:1}" = "-" ] && return 0
# add a list of RPMS to possible completions
COMPREPLY=( ${COMPREPLY[@]} $( rpm -qa | \
sed -ne 's/^\('$cur'.*\)-[0-9a-zA-Z._]\+-[0-9.]\+$/\1/p' ) )
return 0
;;
-[Vy]*)
# complete on list of relevant options
COMPREPLY=( $( compgen -W 'root rcfile dbpath nodeps nofiles \
noscripts nomd5 nopgp' ${cur_nodash#-} ) )
dashify;
# return if $cur is an option
[ "${cur:0:1}" = "-" ] && return 0
# add a list of RPMS to possible completions
COMPREPLY=( ${COMPREPLY[@]} $( rpm -qa | \
sed -ne 's/^\('$cur'.*\)-[0-9a-zA-Z._]\+-[0-9.]\+$/\1/p' ) )
return 0
;;
-b*)
# complete on list of relevant options
COMPREPLY=( $( compgen -W 'short-circuit timecheck clean \
rmsource test sign buildroot target buildarch buildos' \
${cur_nodash#-} ) )
dashify;
# return if $cur is an option
[ "${cur:0:1}" = "-" ] && return 0
# complete on .spec files
COMPREPLY=( $( compgen -G $cur\*.spec ) )
return 0
;;
-t*)
# complete on list of relevant options
COMPREPLY=( $( compgen -W 'short-circuit timecheck clean \
rmsource test sign buildroot target buildarch buildos' \
${cur_nodash#-} ) )
dashify;
# return if $cur is an option
[ "${cur:0:1}" = "-" ] && return 0
# complete on .tar.gz files
COMPREPLY=( $( compgen -G $cur\*.tar.gz ) )
return 0
;;
--re@(build|compile))
# complete on source RPMs
COMPREPLY=( $( compgen -G $cur\*.src.rpm ) )
return 0
;;
--@(checksig|@(re|add)sign))
# complete on RPMs
COMPREPLY=( $( compgen -G $cur\*.rpm ) )
return 0
;;
--set@(perms|gids))
# complete on installed RPMs
COMPREPLY=( ${COMPREPLY[@]} $( rpm -qa | \
sed -ne 's/^\('$cur'.*\)-[0-9a-zA-Z._]\+-[0-9.]\+$/\1/p' ) )
return 0
;;
esac
}
complete -F _rpm rpm
# chsh(1) completion
#
_chsh()
{
local cur prev
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
if [ "$prev" = "-s" ]; then
COMPREPLY=( $( chsh -l | grep ^$cur ) )
else
COMPREPLY=( $( compgen -u $cur ) )
fi
}
complete -F _chsh chsh
# chkconfig(8) completion
#
_chkconfig()
{
local cur prev
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
cur_nodash=${cur#--}
prev=${COMP_WORDS[COMP_CWORD-1]}
if [ $COMP_CWORD -eq 1 ]; then
COMPREPLY=( $( compgen -W 'list add del level' $cur_nodash ) )
for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
COMPREPLY[i]=--${COMPREPLY[i]}
done
return 0
fi
if [ $COMP_CWORD -eq 4 ]; then
COMPREPLY=( $( compgen -W 'on off reset' $cur ) )
return 0
fi
case "$prev" in
@([1-6]|--@(list|add|del)))
COMPREPLY=( $( compgen -W "`(cd /etc/rc.d/init.d; echo *)`" \
$cur) )
return 0
;;
--level)
COMPREPLY=( $( compgen -W '1 2 3 4 5 6' $cur ) )
return 0
;;
esac
}
complete -F _chkconfig chkconfig
###

View file

@ -0,0 +1,15 @@
#! /bin/bash
# Format: array_to_string vname_of_array vname_of_string separator
array_to_string()
{
(( ($# < 2) || ($# > 3) )) && {
"$FUNCNAME: usage: $FUNCNAME arrayname stringname [separator]"
return 2
}
local array=$1 string=$2
((3==$#)) && [[ $3 = ? ]] && local IFS="${3}${IFS}"
eval $string="\"\${$array[*]}\""
return 0
}

View file

@ -0,0 +1,28 @@
#! /bin/bash
#
#Derived from:
#
#From: damercer@mmm.com (Dan Mercer)
#Newsgroups: comp.unix.admin,comp.unix.shell,comp.unix.programmer,comp.sys.sun.admin
#Subject: Re: Command to find out if a directory is empty
#Date: 17 Aug 2000 14:35:56 GMT
#Message-ID: <8ngt8c$fmr$1@magnum.mmm.com>
# usage: emptydir [dirname] ; default dirname is "."
emptydir()
{
typeset file dir=${1:-.}
[[ -d $dir ]] || {
echo "$FUNCNAME: $dir is not a directory" >&2
return 2
}
for file in $dir/.* $dir/*
do
case ${file#$dir/} in
.|..) ;;
\*) [[ -e $file ]];let $?;return;;
*) return 1;;
esac
done
}

View file

@ -9,5 +9,5 @@ fact ()
echo 1
return ;
fi;
echo $[ $num * $(fact $[ $num - 1 ])]
echo $(( $num * $(fact $(( $num - 1 )) ) ))
}

View file

@ -0,0 +1,35 @@
#
# get_html -- get a web page from a remote server
#
# Original Author: Jeff Korn <jlk@cs.princeton.edu>
# Modified for bash by Chet Ramey <chet@po.cwru.edu>
#
# Example: get_html cnswww.cns.cwru.edu /~chet/ | more
get_html()
{
local host port
(($# < 2)) && {
echo "usage: $FUNCNAME hostname path [port]" >&2
return 1
}
host="$1"
port="${3:-80}"
exec 3<> /dev/tcp/$host/$port || {
echo "$FUNCNAME: $host/$port: cannot connect" >&2
exit 1
}
echo -e "GET $2 HTTP/1.0\n" >&3
cat <&3
exec 3<&-
return 0
}
get_html "$@"

35
examples/functions/ksh-cd Normal file
View file

@ -0,0 +1,35 @@
#
# ksh-like `cd': cd [-LP] [dir [change]]
#
cd()
{
OPTIND=1
while getopts "LP" opt
do
case $opt in
L|P) CDOPTS="$CDOPTS -$opt" ;;
*) echo "$FUNCNAME: usage: $FUNCNAME [-LP] [dir] [change]" >&2
return 2;;
esac
done
shift $(( $OPTIND - 1 ))
case $# in
0) builtin cd $CDOPTS "$HOME" ;;
1) builtin cd $CDOPTS "$@" ;;
2) old="$1" new="$2"
case "$PWD" in
*$old*) ;;
*) echo "${0##*/}: $FUNCNAME: bad substitution" >&2 ; return 1 ;;
esac
dir=${PWD//$old/$new}
builtin cd $CDOPTS "$dir" && echo "$PWD"
;;
*) echo "${0##*/}: $FUNCNAME: usage: $FUNCNAME [-LP] [dir] [change]" >&2
return 2 ;;
esac
}

View file

@ -109,27 +109,39 @@ $1 == "'$cmd'" && $2 == "()" {printit=0; next; }
# whence -v "$*"
#}
#
# ksh-like `cd': cd [-LP] [dir [change]]
#
cd()
{
case $# in
0) builtin cd "$HOME" ;;
1) builtin cd "$@" ;;
2) old="$1"
new="$2"
# dir=$(echo "$PWD" | sed "s:$old:$new:g")
dir=${PWD//$old/$new}
case "$dir" in
"$PWD") case "$PWD" in
*$old*) ;;
*) echo "$FUNCNAME: bad substitution" >&2 ; return 1 ;;
esac ;;
*) echo "$dir"
builtin cd "$dir"
;;
OPTIND=1
while getopts "LP" opt
do
case $opt in
L|P) CDOPTS="$CDOPTS -$opt" ;;
*) echo "$FUNCNAME: usage: $FUNCNAME [-LP] [dir] [change]" >&2
return 2;;
esac
done
shift $(( $OPTIND - 1 ))
case $# in
0) builtin cd $CDOPTS "$HOME" ;;
1) builtin cd $CDOPTS "$@" ;;
2) old="$1" new="$2"
case "$PWD" in
*$old*) ;;
*) echo "${0##*/}: $FUNCNAME: bad substitution" >&2 ; return 1 ;;
esac
dir=${PWD//$old/$new}
builtin cd $CDOPTS "$dir" && echo "$PWD"
;;
*) echo "$FUNCNAME: usage: $FUNCNAME [-LP] [dir] [change]" >&2
return 1 ;;
*) echo "${0##*/}: $FUNCNAME: usage: $FUNCNAME [-LP] [dir] [change]" >&2
return 2 ;;
esac
}

View file

@ -11,7 +11,7 @@ lowercase()
for file; do
[ -f "$file" ] || continue
filename=${file##*/}
case "$filename" in
case "$file" in
*/*) dirname=${file%/*} ;;
*) dirname=.;;
esac

View file

@ -0,0 +1,64 @@
#!/bin/bash
#From: kaz@ashi.footprints.net (Kaz Kylheku)
#Newsgroups: comp.os.linux.misc
#Subject: Re: bash question: subdirectories
#Message-ID: <slrn8a0gu9.v5n.kaz@ashi.FootPrints.net>
#Date: Tue, 08 Feb 2000 16:24:35 GMT
#Actually it can be made to. That is to say, it is possible to code a recursive
#descender function in the bash language. Here is an example.
#
#What is nice about this is that you can embed the function into your shell
#script. The function changes the current working directory as it descends.
#So it can handle arbitrarily deep paths. Whereas paths generated by the
#find command can cause a problem when they get too long; the kernel has a
#hard limit on the length of the string passed to the open() and other
#system calls.
#There are races; what if the directory tree is blown away during the traversal?
#The function won't be able to crawl back up using the .. link and will just
#bail.
# Recursive Directory Traverser
# Author: Kaz Kylheku
# Date: Feb 27, 1999
# Copyright 1999
# Function parameter usage:
# $1 directory to search
# $2 pattern to search for
# $3 command to execute
# $4 secret argument for passing down path
function recurse
{
local file
local path
if [ "$4" = "" ] ; then
path="${1%/}/"
else
path="$4$1/"
fi
if cd "$1" ; then
for file in $2; do
if [ -f "$file" -o -d "$file" ]; then
eval "$3"
fi
done
for file in .* * ; do
if [ "$file" = "." -o "$file" = ".." ] ; then
continue
fi
if [ -d "$file" -a ! -L "$file" ]; then
recurse "$file" "$2" "$3" "$path"
fi
done
cd ..
fi
}
recurse "$1" "$2" 'echo "$path$file"'

View file

@ -0,0 +1,50 @@
# Sort the positional paramters.
# Make sure the positional parameters are passed as arguments to the function.
# If -u is the first arg, remove duplicate array members.
sort_posparams()
{
local -a R
local u
case "$1" in
-u) u=-u ; shift ;;
esac
# if you want the case of no positional parameters to return success,
# remove the error message and return 0
if [ $# -eq 0 ]; then
echo "$FUNCNAME: argument expected" >&2
return 1
fi
# make R a copy of the positional parameters
R=( "${@}" )
# sort R.
R=( $( printf "%s\n" "${R[@]}" | sort $u) )
printf "%s\n" "${R[@]}"
return 0
}
# will print everything on separate lines
set -- 3 1 4 1 5 9 2 6 5 3 2
sort_posparams "$@"
# sets without preserving quoted parameters
set -- $( sort_posparams "$@" )
echo "$@"
echo $#
# sets preserving quoted parameters, beware pos params with embedded newlines
set -- 'a b' 'a c' 'x z'
oifs=$IFS
IFS=$'\n'
set -- $( sort_posparams "$@" )
IFS="$oifs"
echo "$@"
echo $#
sort_posparams

View file

@ -67,7 +67,7 @@ INC = -I. -I.. -I$(topdir) -I$(topdir)/lib -I$(topdir)/builtins \
ALLPROG = print truefalse sleep pushd finfo logname basename dirname \
tty pathchk tee head mkdir rmdir sprintf printenv id whoami \
uname sync push ln unlink
uname sync push ln unlink cut realpath
OTHERPROG = necho getconf hello cat
all: $(SHOBJ_STATUS)
@ -164,6 +164,11 @@ ln: ln.o
unlink: unlink.o
$(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ unlink.o $(SHOBJ_LIBS)
cut: cut.o
$(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ cut.o $(SHOBJ_LIBS)
realpath: realpath.o
$(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ realpath.o $(SHOBJ_LIBS)
# pushd is a special case. We use the same source that the builtin version
# uses, with special compilation options.
@ -214,3 +219,4 @@ uname.o: uname.c
sync.o: sync.c
push.o: push.c
mkdir.o: mkdir.c
realpath.o: realpath.c

376
examples/loadables/cut.c Normal file
View file

@ -0,0 +1,376 @@
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Adam S. Moskowitz of Menlo Consulting and Marciano Pitargue.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef lint
static const char copyright[] =
"@(#) Copyright (c) 1989, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
static const char sccsid[] = "@(#)cut.c 8.3 (Berkeley) 5/4/95";
#endif /* not lint */
#include <config.h>
#include <ctype.h>
#include <stdio.h>
#include <errno.h>
#include "bashansi.h"
#ifdef HAVE_LIMITS_H
# include <limits.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include "builtins.h"
#include "shell.h"
#include "bashgetopt.h"
#if !defined (errno)
extern int errno;
#endif
#if !defined (_POSIX2_LINE_MAX)
# define _POSIX2_LINE_MAX 2048
#endif
static int cflag;
static char dchar;
static int dflag;
static int fflag;
static int sflag;
static int autostart, autostop, maxval;
static char positions[_POSIX2_LINE_MAX + 1];
static int c_cut __P((FILE *, char *));
static int f_cut __P((FILE *, char *));
static int get_list __P((char *));
static char *_cut_strsep __P((char **, const char *));
int
cut_builtin(list)
WORD_LIST *list;
{
FILE *fp;
int (*fcn) __P((FILE *, char *)) = NULL;
int ch;
fcn = NULL;
dchar = '\t'; /* default delimiter is \t */
/* Since we don't support multi-byte characters, the -c and -b
options are equivalent, and the -n option is meaningless. */
reset_internal_getopt ();
while ((ch = internal_getopt (list, "b:c:d:f:sn")) != -1)
switch(ch) {
case 'b':
case 'c':
fcn = c_cut;
if (get_list(list_optarg) < 0)
return (EXECUTION_FAILURE);
cflag = 1;
break;
case 'd':
dchar = *list_optarg;
dflag = 1;
break;
case 'f':
fcn = f_cut;
if (get_list(list_optarg) < 0)
return (EXECUTION_FAILURE);
fflag = 1;
break;
case 's':
sflag = 1;
break;
case 'n':
break;
case '?':
default:
builtin_usage();
return (EX_USAGE);
}
list = loptend;
if (fflag) {
if (cflag) {
builtin_usage();
return (EX_USAGE);
}
} else if (!cflag || dflag || sflag) {
builtin_usage();
return (EX_USAGE);
}
if (list) {
while (list) {
fp = fopen(list->word->word, "r");
if (fp == 0) {
builtin_error("%s", list->word->word);
return (EXECUTION_FAILURE);
}
ch = (*fcn)(fp, list->word->word);
(void)fclose(fp);
if (ch < 0)
return (EXECUTION_FAILURE);
list = list->next;
}
} else {
ch = (*fcn)(stdin, "stdin");
if (ch < 0)
return (EXECUTION_FAILURE);
}
return (EXECUTION_SUCCESS);
}
static int
get_list(list)
char *list;
{
int setautostart, start, stop;
char *pos;
char *p;
/*
* set a byte in the positions array to indicate if a field or
* column is to be selected; use +1, it's 1-based, not 0-based.
* This parser is less restrictive than the Draft 9 POSIX spec.
* POSIX doesn't allow lists that aren't in increasing order or
* overlapping lists. We also handle "-3-5" although there's no
* real reason too.
*/
for (; (p = _cut_strsep(&list, ", \t")) != NULL;) {
setautostart = start = stop = 0;
if (*p == '-') {
++p;
setautostart = 1;
}
if (isdigit((unsigned char)*p)) {
start = stop = strtol(p, &p, 10);
if (setautostart && start > autostart)
autostart = start;
}
if (*p == '-') {
if (isdigit((unsigned char)p[1]))
stop = strtol(p + 1, &p, 10);
if (*p == '-') {
++p;
if (!autostop || autostop > stop)
autostop = stop;
}
}
if (*p) {
builtin_error("[-cf] list: illegal list value");
return -1;
}
if (!stop || !start) {
builtin_error("[-cf] list: values may not include zero");
return -1;
}
if (stop > _POSIX2_LINE_MAX) {
builtin_error("[-cf] list: %d too large (max %d)",
stop, _POSIX2_LINE_MAX);
return -1;
}
if (maxval < stop)
maxval = stop;
for (pos = positions + start; start++ <= stop; *pos++ = 1);
}
/* overlapping ranges */
if (autostop && maxval > autostop)
maxval = autostop;
/* set autostart */
if (autostart)
memset(positions + 1, '1', autostart);
return 0;
}
/* ARGSUSED */
static int
c_cut(fp, fname)
FILE *fp;
char *fname;
{
int ch, col;
char *pos;
ch = 0;
for (;;) {
pos = positions + 1;
for (col = maxval; col; --col) {
if ((ch = getc(fp)) == EOF)
return;
if (ch == '\n')
break;
if (*pos++)
(void)putchar(ch);
}
if (ch != '\n') {
if (autostop)
while ((ch = getc(fp)) != EOF && ch != '\n')
(void)putchar(ch);
else
while ((ch = getc(fp)) != EOF && ch != '\n');
}
(void)putchar('\n');
}
return (0);
}
static int
f_cut(fp, fname)
FILE *fp;
char *fname;
{
int ch, field, isdelim;
char *pos, *p, sep;
int output;
char lbuf[_POSIX2_LINE_MAX + 1];
for (sep = dchar; fgets(lbuf, sizeof(lbuf), fp);) {
output = 0;
for (isdelim = 0, p = lbuf;; ++p) {
if (!(ch = *p)) {
builtin_error("%s: line too long.", fname);
return -1;
}
/* this should work if newline is delimiter */
if (ch == sep)
isdelim = 1;
if (ch == '\n') {
if (!isdelim && !sflag)
(void)printf("%s", lbuf);
break;
}
}
if (!isdelim)
continue;
pos = positions + 1;
for (field = maxval, p = lbuf; field; --field, ++pos) {
if (*pos) {
if (output++)
(void)putchar(sep);
while ((ch = *p++) != '\n' && ch != sep)
(void)putchar(ch);
} else {
while ((ch = *p++) != '\n' && ch != sep)
continue;
}
if (ch == '\n')
break;
}
if (ch != '\n') {
if (autostop) {
if (output)
(void)putchar(sep);
for (; (ch = *p) != '\n'; ++p)
(void)putchar(ch);
} else
for (; (ch = *p) != '\n'; ++p);
}
(void)putchar('\n');
}
return (0);
}
/*
* Get next token from string *stringp, where tokens are possibly-empty
* strings separated by characters from delim.
*
* Writes NULs into the string at *stringp to end tokens.
* delim need not remain constant from call to call.
* On return, *stringp points past the last NUL written (if there might
* be further tokens), or is NULL (if there are definitely no more tokens).
*
* If *stringp is NULL, strsep returns NULL.
*/
static char *
_cut_strsep(stringp, delim)
register char **stringp;
register const char *delim;
{
register char *s;
register const char *spanp;
register int c, sc;
char *tok;
if ((s = *stringp) == NULL)
return (NULL);
for (tok = s;;) {
c = *s++;
spanp = delim;
do {
if ((sc = *spanp++) == c) {
if (c == 0)
s = NULL;
else
s[-1] = 0;
*stringp = s;
return (tok);
}
} while (sc != 0);
}
/* NOTREACHED */
}
static char *cut_doc[] = {
"Select portions of each line (as specified by LIST) from each FILE",
"(by default, the standard input), and write them to the standard output.",
"Items specified by LIST are either column positions or fields delimited",
"by a special character. Column numbering starts at 1.",
(char *)0
};
struct builtin cut_struct = {
"cut",
cut_builtin,
BUILTIN_ENABLED,
cut_doc,
"cut -b list [-n] [file ...] OR cut -c list [file ...] OR cut -f list [-s] [-d delim] [file ...]",
0
};

View file

@ -9,6 +9,7 @@
#include <grp.h>
#include <errno.h>
#include "bashansi.h"
#include "shell.h"
#include "builtins.h"
#include "common.h"
@ -17,7 +18,6 @@
extern int errno;
#endif
extern char *strrchr();
extern char **make_builtin_argv ();
static int printst();
@ -137,7 +137,11 @@ char *f;
fd = lfd;
r = fstat(fd, &st);
} else
#ifdef HAVE_LSTAT
r = lstat(f, &st);
#else
r = stat(f, &st);
#endif
if (r < 0) {
builtin_error("%s: cannot stat: %s", f, strerror(errno));
return ((struct stat *)0);

View file

@ -55,7 +55,7 @@
struct conf_variable
{
const char *name;
enum { SYSCONF, CONFSTR, PATHCONF, CONSTANT } type;
enum { SYSCONF, CONFSTR, PATHCONF, CONSTANT, G_UNDEF } type;
long value;
};
@ -105,19 +105,55 @@ static const struct conf_variable conf_table[] =
#endif /* _CS_XBS5_ILP32_OFF32_CFLAGS */
/* POSIX.2 Utility Limit Minimum Values */
#ifdef _POSIX2_BC_BASE_MAX
{ "POSIX2_BC_BASE_MAX", CONSTANT, _POSIX2_BC_BASE_MAX },
#else
{ "POSIX2_BC_BASE_MAX", G_UNDEF, -1 },
#endif
#ifdef _POSIX2_BC_DIM_MAX
{ "POSIX2_BC_DIM_MAX", CONSTANT, _POSIX2_BC_DIM_MAX },
#else
{ "POSIX2_BC_DIM_MAX", G_UNDEF, -1 },
#endif
#ifdef _POSIX2_BC_SCALE_MAX
{ "POSIX2_BC_SCALE_MAX", CONSTANT, _POSIX2_BC_SCALE_MAX },
#else
{ "POSIX2_BC_SCALE_MAX", G_UNDEF, -1 },
#endif
#ifdef _POSIX2_BC_STRING_MAX
{ "POSIX2_BC_STRING_MAX", CONSTANT, _POSIX2_BC_STRING_MAX },
#else
{ "POSIX2_BC_STRING_MAX", G_UNDEF, -1 },
#endif
#ifdef _POSIX2_COLL_WEIGHTS_MAX
{ "POSIX2_COLL_WEIGHTS_MAX", CONSTANT, _POSIX2_COLL_WEIGHTS_MAX },
#else
{ "POSIX2_COLL_WEIGHTS_MAX", G_UNDEF, -1 },
#endif
#if defined (_POSIX2_EQUIV_CLASS_MAX)
{ "POSIX2_EQUIV_CLASS_MAX", CONSTANT, _POSIX2_EQUIV_CLASS_MAX },
#endif
#ifdef _POSIX2_EXPR_NEST_MAX
{ "POSIX2_EXPR_NEST_MAX", CONSTANT, _POSIX2_EXPR_NEST_MAX },
#else
{ "POSIX2_EXPR_NEST_MAX", G_UNDEF, -1 },
#endif
#ifdef _POSIX2_LINE_MAX
{ "POSIX2_LINE_MAX", CONSTANT, _POSIX2_LINE_MAX },
#else
{ "POSIX2_LINE_MAX", G_UNDEF, -1 },
#endif
#ifdef _POSIX2_RE_DUP_MAX
{ "POSIX2_RE_DUP_MAX", CONSTANT, _POSIX2_RE_DUP_MAX },
#else
{ "POSIX2_RE_DUP_MAX", G_UNDEF, -1 },
#endif
#if defined (_POSIX2_VERSION)
{ "POSIX2_VERSION", CONSTANT, _POSIX2_VERSION },
#else
# if !defined (_SC_2_VERSION)
{ "POSIX2_VERSION", G_UNDEF, -1 },
# endif
#endif
/* POSIX.1 Minimum Values */
@ -146,20 +182,50 @@ static const struct conf_variable conf_table[] =
{ "RE_DUP_MAX", SYSCONF, _SC_RE_DUP_MAX },
/* POSIX.2 Optional Facility Configuration Values */
#ifdef _SC_2_C_BIND
{ "POSIX2_C_BIND", SYSCONF, _SC_2_C_BIND },
#else
{ "POSIX2_C_BIND", G_UNDEF, -1 },
#endif
#ifdef _SC_2_C_DEV
{ "POSIX2_C_DEV", SYSCONF, _SC_2_C_DEV },
#else
{ "POSIX2_C_DEV", G_UNDEF, -1 },
#endif
#if defined (_SC_2_C_VERSION)
{ "POSIX2_C_VERSION", SYSCONF, _SC_2_C_VERSION },
#else
{ "POSIX2_C_VERSION", G_UNDEF, -1 },
#endif
#if defined (_SC_2_CHAR_TERM)
{ "POSIX2_CHAR_TERM", SYSCONF, _SC_2_CHAR_TERM },
#else
{ "POSIX2_CHAR_TERM", G_UNDEF, -1 },
#endif
#ifdef _SC_2_FORT_DEV
{ "POSIX2_FORT_DEV", SYSCONF, _SC_2_FORT_DEV },
#else
{ "POSIX2_FORT_DEV", G_UNDEF, -1 },
#endif
#ifdef _SC_2_FORT_RUN
{ "POSIX2_FORT_RUN", SYSCONF, _SC_2_FORT_RUN },
#else
{ "POSIX2_FORT_RUN", G_UNDEF, -1 },
#endif
#ifdef _SC_2_LOCALEDEF
{ "POSIX2_LOCALEDEF", SYSCONF, _SC_2_LOCALEDEF },
#else
{ "POSIX2_LOCALEDEF", G_UNDEF, -1 },
#endif
#ifdef _SC_2_SW_DEV
{ "POSIX2_SW_DEV", SYSCONF, _SC_2_SW_DEV },
#else
{ "POSIX2_SW_DEV", G_UNDEF, -1 },
#endif
#if defined (_SC2_UPE)
{ "POSIX2_UPE", SYSCONF, _SC_2_UPE },
#else
{ "POSIX2_UPE", G_UNDEF, -1 },
#endif
#if !defined (_POSIX2_VERSION) && defined (_SC_2_VERSION)
{ "POSIX2_VERSION" SYSCONF, _SC_2_VERSION },
@ -449,6 +515,10 @@ int all;
size_t slen;
switch (cp->type) {
case G_UNDEF:
printf("undefined\n");
break;
case CONSTANT:
printf("%ld\n", cp->value);
break;
@ -508,7 +578,8 @@ int all;
break;
}
return (ferror(stdout) ? EXECUTION_FAILURE : EXECUTION_SUCCESS);
return ((ferror(stdout) || cp->type == G_UNDEF) ? EXECUTION_FAILURE
: EXECUTION_SUCCESS);
}
static int

95
examples/loadables/push.c Normal file
View file

@ -0,0 +1,95 @@
/*
* push - anyone remember TOPS-20?
*
*/
#include <config.h>
#include <stdio.h>
#include <errno.h>
#include "builtins.h"
#include "shell.h"
#include "jobs.h"
#include "bashgetopt.h"
#ifndef errno
extern int errno;
#endif
extern int dollar_dollar_pid;
extern int last_command_exit_value;
int
push_builtin (list)
WORD_LIST *list;
{
pid_t pid;
int xstatus, opt;
xstatus = EXECUTION_SUCCESS;
reset_internal_getopt ();
while ((opt = internal_getopt (list, "")) != -1)
{
switch (opt)
{
default:
builtin_usage ();
return (EX_USAGE);
}
}
list = loptend;
pid = make_child (savestring ("push"), 0);
if (pid == -1)
{
builtin_error ("cannot fork: %s", strerror (errno));
return (EXECUTION_FAILURE);
}
else if (pid == 0)
{
/* Shell variable adjustments: $SHLVL, $$, $PPID, $! */
adjust_shell_level (1);
dollar_dollar_pid = getpid ();
set_ppid ();
/* Clean up job control stuff. */
stop_making_children ();
cleanup_the_pipeline ();
delete_all_jobs (0);
last_asynchronous_pid = NO_PID;
/* Make sure the job control code has the right values for
the shell's process group and tty process group, and that
the signals are set correctly for job control. */
initialize_job_control (0);
initialize_job_signals ();
/* And read commands until exit. */
reader_loop ();
exit_shell (last_command_exit_value);
}
else
{
stop_pipeline (0, (COMMAND *)NULL);
xstatus = wait_for (pid);
return (xstatus);
}
}
char *push_doc[] = {
"Create a child that is an exact duplicate of the running shell",
"and wait for it to exit. The $SHLVL, $!, $$, and $PPID variables",
"are adjusted in the child. The return value is the exit status",
"of the child.",
(char *)NULL
};
struct builtin push_struct = {
"push",
push_builtin,
BUILTIN_ENABLED,
push_doc,
"push",
0
};

View file

@ -0,0 +1,119 @@
/*
* realpath -- canonicalize pathnames, resolving symlinks
*
* usage: realpath [-csv] pathname [pathname...]
*
* options: -c check whether or not each resolved path exists
* -s no output, exit status determines whether path is valid
* -v produce verbose output
*
*
* exit status: 0 if all pathnames resolved
* 1 if any of the pathname arguments could not be resolved
*
*
* Bash loadable builtin version
*
* Chet Ramey
* chet@po.cwru.edu
*/
#include "config.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include "bashansi.h"
#include <maxpath.h>
#include <errno.h>
#include "builtins.h"
#include "shell.h"
#include "bashgetopt.h"
#ifndef errno
extern int errno;
#endif
extern char *sh_realpath();
realpath_builtin(list)
WORD_LIST *list;
{
int opt, cflag, vflag, sflag, es;
char *r, realbuf[PATH_MAX], *p;
struct stat sb;
if (list == 0) {
builtin_usage();
return (EX_USAGE);
}
vflag = cflag = sflag = 0;
reset_internal_getopt();
while ((opt = internal_getopt (list, "csv")) != -1) {
switch (opt) {
case 'c':
cflag = 1;
break;
case 's':
sflag = 1;
break;
case 'v':
vflag = 1;
break;
default:
usage();
}
}
list = loptend;
if (list == 0)
usage();
for (es = EXECUTION_SUCCESS; list; list = list->next) {
p = list->word->word;
r = sh_realpath(p, realbuf);
if (r == 0) {
es = EXECUTION_FAILURE;
if (sflag == 0)
builtin_error("%s: cannot resolve: %s", p, strerror(errno));
continue;
}
if (cflag && (stat(realbuf, &sb) < 0)) {
es = EXECUTION_FAILURE;
if (sflag == 0)
builtin_error("%s: %s", p, strerror(errno));
continue;
}
if (sflag == 0) {
if (vflag)
printf ("%s -> ", p);
printf("%s\n", realbuf);
}
}
return es;
}
char *realpath_doc[] = {
"Display the canonicalized version of each PATHNAME argument, resolving",
"symbolic links. The -c option checks whether or not each resolved name",
"exists. The -s option produces no output; the exit status determines the",
"valididty of each PATHNAME. The -v option produces verbose output. The",
"exit status is 0 if each PATHNAME was resolved; non-zero otherwise.",
(char *)NULL
};
struct builtin realpath_struct = {
"realpath", /* builtin name */
realpath_builtin, /* function implementing the builtin */
BUILTIN_ENABLED, /* initial flags for builtin */
realpath_doc, /* array of long documentation strings */
"realpath [-csv] pathname [pathname...]", /* usage synopsis */
0 /* reserved for internal use */
};

View file

@ -99,7 +99,7 @@ set -o emacs
cd
LIM=.limbo # $HOME/$LIM contains "destroyed" objects
mkdir $LIM || {
echo "ash: cannot mkdir $LIM: exiting
echo "ash: cannot mkdir $LIM: exiting"
exit 1
}
KNAP=.knapsack # $HOME/$KNAP contains objects being "carried"

12
examples/scripts/cat.sh Normal file
View file

@ -0,0 +1,12 @@
shcat()
{
while read -r ; do
echo "$REPLY"
done
}
if [ -n "$1" ]; then
shcat < "$1"
else
shcat
fi

476
examples/scripts/dd-ex.sh Normal file
View file

@ -0,0 +1,476 @@
#!/bin/sh
# this is a line editor using only /bin/sh, /bin/dd and /bin/rm
# /bin/rm is not really required, but it is nice to clean up temporary files
PATH=
dd=/bin/dd
rm=/bin/rm
# temporary files we might need
tmp=/tmp/silly.$$
ed=/tmp/ed.$$
trap "$rm -f $tmp $tmp.1 $tmp.2 $tmp.3 $tmp.4 $tmp.5 $tmp.6 $ed.a $ed.b $ed.c; exit" 0 1 2 3
# from now on, no more rm - the above trap is enough
unset rm
# we do interesting things with IFS, but better save it...
saveIFS="$IFS"
# in case "echo" is not a shell builtin...
Echo () {
case "$1" in
-n) shift
$dd of=$tmp 2>/dev/null <<EOF
$@
EOF
IFS="+"
set `$dd if=$tmp bs=1 of=/dev/null skip=1 2>&1`
IFS="$saveIFS"
$dd if=$tmp bs=1 count=$1 2>/dev/null
;;
*) $dd 2>/dev/null <<EOF
$@
EOF
;;
esac
}
# this is used to generate garbage files
true () {
return 0
}
false () {
return 1
}
zero () {
( trap 'go=false' 13
go=true
while $go
do
$dd "if=$0"
case "$?" in
0) ;;
*) go=false ;;
esac
done
) 2>/dev/null
}
# arithmetic using dd!
# add variable n1 n2 n3...
# assigns n1+n2+n3+... to variable
add () {
result="$1"
shift
$dd if=/dev/null of=$tmp bs=1 2>/dev/null
for n in "$@"
do
case "$n" in
0) ;;
*) zero | $dd of=$tmp.1 bs=1 "count=$n" 2>/dev/null
( $dd if=$tmp; $dd if=$tmp.1 ) 2>/dev/null | $dd of=$tmp.2 2>/dev/null
$dd if=$tmp.2 of=$tmp 2>/dev/null
;;
esac
done
IFS="+"
set `$dd if=$tmp bs=1 of=/dev/null 2>&1`
IFS="$saveIFS"
eval $result='$1'
}
# subtract variable n1 n2
# subtracts n2 from n1, assigns result to variable
subtract () {
result="$1"
zero | $dd of=$tmp bs=1 "count=$2" 2>/dev/null
IFS="+"
set `$dd if=$tmp bs=1 of=/dev/null "skip=$3" 2>&1`
IFS="$saveIFS"
case "$1" in
dd*) set 0 ;;
esac
eval $result='$1'
}
# multiply variable n1 n2
# variable = n1 * n2
multiply () {
result="$1"
zero | $dd "bs=$2" of=$tmp "count=$3" 2>/dev/null
IFS="+"
set `$dd if=$tmp bs=1 of=/dev/null 2>&1`
IFS="$saveIFS"
eval $result='$1'
}
# divide variable n1 n2
# variable = int( n1 / n2 )
divide () {
result="$1"
zero | $dd bs=1 of=$tmp "count=$2" 2>/dev/null
IFS="+"
set `$dd if=$tmp "bs=$3" of=/dev/null 2>&1`
IFS="$saveIFS"
eval $result='$1'
}
# compare variable n1 n2 sets variable to lt if n1<n2, gt if n1>n2, eq if n1==n2
compare () {
res="$1"
n1="$2"
n2="$3"
subtract somename "$n1" "$n2"
case "$somename" in
0) ;;
*) eval $res=gt; return;
esac
subtract somename "$n2" "$n1"
case "$somename" in
0) ;;
*) eval $res=lt; return;
esac
eval $res=eq
}
# lt n1 n2 returns true if n1 < n2
lt () {
n1="$1"
n2="$2"
subtract somename "$n2" "$n1"
case "$somename" in
0) return 1 ;;
esac
return 0
}
# le n1 n2 returns true if n1 <= n2
le () {
n1="$1"
n2="$2"
subtract somename "$n1" "$n2"
case "$somename" in
0) return 0 ;;
esac
return 1
}
# gt n1 n2 returns true if n1 > n2
gt () {
n1="$1"
n2="$2"
subtract somename "$n1" "$n2"
case "$somename" in
0) return 1 ;;
esac
return 0
}
# ge n1 n2 returns true if n1 >= n2
ge () {
n1="$1"
n2="$2"
subtract somename "$n2" "$n1"
case "$somename" in
0) return 0 ;;
esac
return 1
}
# useful functions for the line editor
# open a file - copy it to the buffers
open () {
file="$1"
set `$dd "if=$file" of=/dev/null 2>&1`
case "$1" in
dd*) return 1
esac
# copy the first line to $ed.c
go=true
len=0
while $go
do
case "`$dd "if=$file" bs=1 skip=$len count=1 2>/dev/null`" in
?*) go=true ;;
*) go=false ;;
esac
add len 1 $len
done
# now $len is the length of the first line (including newline)
$dd "if=$file" bs=1 count=$len of=$ed.c 2>/dev/null
$dd "if=$file" bs=1 skip=$len of=$ed.b 2>/dev/null
$dd if=/dev/null of=$ed.a 2>/dev/null
lineno=1
}
# save a file - copy the buffers to the file
save () {
# make a backup copy of the original
$dd "if=$1" "of=$1.bak" 2>/dev/null
# and save
( $dd if=$ed.a; $dd if=$ed.c; $dd if=$ed.b ) > "$1" 2>/dev/null
}
# replace n1 n2 bla replaces n2 chars of current line, starting n1-th
replace () {
$dd if=$ed.c of=$tmp.1 bs=1 "count=$1" 2>/dev/null
( $dd if=$ed.c "skip=$1" bs=1 | $dd of=$tmp.2 bs=1 "skip=$2" ) 2>/dev/null
shift
shift
( $dd if=$tmp.1; Echo -n "$@"; $dd if=$tmp.2 ) > $tmp.3 2>/dev/null
$dd if=$tmp.3 of=$ed.c 2>/dev/null
}
# rstring n s bla
# replace the n-th occurence of s with bla
rstring () {
n="$1"
shift;
# first we have to find it - this is fun!
# we have $tmp.4 => text before string, $tmp.5 => text after
$dd if=/dev/null of=$tmp.4 2>/dev/null
$dd if=$ed.c of=$tmp.5 2>/dev/null
string="$1"
shift
$dd of=$tmp.6 2>/dev/null <<EOF
$@
EOF
while :
do
case "`$dd if=$tmp.5 2>/dev/null`" in
$string*)
if lt $n 2
then
# now we want to replace the string
Echo -n "$@" > $tmp.2
Echo -n "$string" > $tmp.1
IFS="+"
set `$dd bs=1 if=$tmp.1 of=/dev/null 2>&1`
IFS="$saveIFS"
slen=$1
IFS="+"
( $dd if=$tmp.4; $dd if=$tmp.2; $dd if=$tmp.5 bs=1 skip=$slen ) \
2>/dev/null > $tmp
$dd if=$tmp of=$ed.c 2>/dev/null
return 0
else
subtract n $n 1
( $dd if=$tmp.4; $dd if=$tmp.5 bs=1 count=1 ) > $tmp 2>/dev/null
$dd if=$tmp of=$tmp.4 2>/dev/null
# and remove it from $tmp.5
$dd if=$tmp.5 of=$tmp bs=1 skip=1 2>/dev/null
$dd if=$tmp of=$tmp.5 2>/dev/null
fi
;;
?*) # add one more byte...
( $dd if=$tmp.4; $dd if=$tmp.5 bs=1 count=1 ) > $tmp 2>/dev/null
$dd if=$tmp of=$tmp.4 2>/dev/null
# and remove it from $tmp.5
$dd if=$tmp.5 of=$tmp bs=1 skip=1 2>/dev/null
$dd if=$tmp of=$tmp.5 2>/dev/null
;;
*) # not found
return 1
;;
esac
done
}
# skip to next line
next () {
add l $lineno 1
( $dd if=$ed.a; $dd if=$ed.c ) 2>/dev/null > $tmp.3
$dd if=$ed.b of=$tmp.4 2>/dev/null
open $tmp.4
$dd if=$tmp.3 of=$ed.a 2>/dev/null
lineno=$l
}
# delete current line
delete () {
l=$lineno
$dd if=$ed.a 2>/dev/null > $tmp.1
$dd if=$ed.b of=$tmp.2 2>/dev/null
open $tmp.2
$dd if=$tmp.1 of=$ed.a 2>/dev/null
lineno=$l
}
# insert before current line (without changing current)
insert () {
( $dd if=$ed.a; Echo "$@" ) 2>/dev/null > $tmp.1
$dd if=$tmp.1 of=$ed.a 2>/dev/null
add lineno $lineno 1
}
# previous line
prev () {
case "$lineno" in
1) ;;
*) subtract lineno $lineno 1
# read last line of $ed.a
IFS='+'
set `$dd if=$ed.a of=/dev/null bs=1 2>&1`
IFS="$saveIFS"
size=$1
# empty?
case "$size" in
0) return ;;
esac
subtract size $size 1
# skip final newline
case "$size" in
0) ;;
*) subtract size1 $size 1
case "`$dd if=$ed.a bs=1 skip=$size count=1 2>/dev/null`" in
?*) ;;
*) size=$size1 ;;
esac
;;
esac
go=true
while $go
do
case "$size" in
0) go=false ;;
*) case "`$dd if=$ed.a bs=1 skip=$size count=1 2>/dev/null`" in
?*) go=true; subtract size $size 1 ;;
*) go=false; add size $size 1 ;;
esac
;;
esac
done
# now $size is the size of the first n-1 lines
# add $ed.c to $ed.b
( $dd if=$ed.c; $dd if=$ed.b ) 2>/dev/null > $tmp.5
$dd if=$tmp.5 of=$ed.b 2>/dev/null
# move line to ed.c
case "$size" in
0) $dd if=$ed.a of=$ed.c 2>/dev/null
$dd if=/dev/null of=$tmp.5 2>/dev/null
;;
*) $dd if=$ed.a of=$ed.c bs=1 skip=$size 2>/dev/null
$dd if=$ed.a of=$tmp.5 bs=1 count=$size 2>/dev/null
;;
esac
# move rest to ed.a
$dd if=$tmp.5 of=$ed.a 2>/dev/null
;;
esac
}
# goes to a given line
goto () {
rl="$1"
compare bla "$rl" $lineno
case "$bla" in
eq) return
;;
gt) while gt "$rl" $lineno
do
next
done
;;
lt) while lt "$rl" $lineno
do
prev
done
;;
esac
}
lineout () {
Echo -n "$lineno: "
$dd if=$ed.c 2>/dev/null
}
state=closed
name=
autoprint=true
while true
do
Echo -n '> '
read cmd arg
case "$cmd:$state" in
open:open) Echo "There is a file open already" ;;
open:*) if open "$arg"
then state=open; name="$arg"; $autoprint
else Echo "Cannot open $arg"
fi
;;
new:open) Echo "There is a file open already" ;;
new:*) open "$arg"
state=open
name="$arg"
$autoprint
;;
close:changed) Echo "Use 'discard' or 'save'" ;;
close:closed) Echo "Closed already" ;;
close:*) state=closed ;;
save:closed) Echo "There isn't a file to save" ;;
save:*) case "$arg" in
?*) save "$arg" ;;
*) save "$name" ;;
esac
state=open
;;
discard:changed) Echo "Your problem!"; state=closed ;;
discard:*) state=closed ;;
print:closed) Echo "No current file" ;;
print:*) lineout ;;
goto:closed) Echo "No current file" ;;
goto:*) goto "$arg"; $autoprint ;;
next:closed) Echo "No current file" ;;
next:*) next; $autoprint ;;
prev:closed) Echo "No current file" ;;
prev:*) prev; $autoprint ;;
name:closed) Echo "No current file" ;;
name:*) name="$arg" ;;
replace:closed) Echo "No current file" ;;
replace:*) if rstring 1 $arg
then state=changed; $autoprint
else Echo "Not found"
fi
;;
nreplace:closed) Echo "No current file" ;;
nreplace:*) if rstring $arg
then state=changed; $autoprint
else Echo "Not found"
fi
;;
delete:closed) Echo "No current file" ;;
delete:*) delete; state=changed; $autoprint ;;
insert:closed) Echo "No current file" ;;
insert:*) insert "$arg"; prev; state=changed; $autoprint ;;
quit:changed) Echo "Use 'save' or 'discard'" ;;
quit:*) Echo "bye"; exit;;
autoprint:*) autoprint="lineout" ;;
noprint:*) autoprint="" ;;
:*) ;;
*) Echo "Command not understood" ;;
esac
done

View file

@ -460,8 +460,8 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
paren_pid = make_child (savestring (make_command_string (command)),
asynchronous);
if (paren_pid == 0)
exit (execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close));
/* NOTREACHED */
exit (execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close));
/* NOTREACHED */
else
{
close_pipes (pipe_in, pipe_out);
@ -1057,7 +1057,8 @@ time_command (command, asynchronous, pipe_in, pipe_out, fds_to_close)
#endif /* COMMAND_TIMING */
/* Execute a command that's supposed to be in a subshell. This must be
called after make_child and we must be running in the child process. */
called after make_child and we must be running in the child process.
The caller will return or exit() immediately with the value this returns. */
static int
execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close)
COMMAND *command;
@ -1065,14 +1066,17 @@ execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close)
int pipe_in, pipe_out;
struct fd_bitmap *fds_to_close;
{
int user_subshell, return_code, function_value, should_redir_stdin;
int user_subshell, return_code, function_value, should_redir_stdin, invert;
int ois;
COMMAND *tcom;
should_redir_stdin = (asynchronous && (command->flags & CMD_STDIN_REDIR) &&
pipe_in == NO_PIPE &&
stdin_redirects (command->redirects) == 0);
invert = (command->flags & CMD_INVERT_RETURN) != 0;
user_subshell = command->type == cm_subshell || ((command->flags & CMD_WANT_SUBSHELL) != 0);
command->flags &= ~(CMD_FORCE_SUBSHELL | CMD_WANT_SUBSHELL | CMD_INVERT_RETURN);
/* If a command is asynchronous in a subshell (like ( foo ) & or
@ -1098,8 +1102,14 @@ execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close)
undoing all the work we just did in make_child. */
original_pgrp = -1;
#endif /* JOB_CONTROL */
ois = interactive_shell;
interactive_shell = 0;
expand_aliases = 0;
/* This test is to prevent alias expansion by interactive shells that
run `(command) &' but to allow scripts that have enabled alias
expansion with `shopt -s expand_alias' to continue to expand
aliases. */
if (ois != interactive_shell)
expand_aliases = 0;
asynchronous = 0;
}
@ -1151,7 +1161,7 @@ execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close)
if (command->redirects)
{
if (do_redirections (command->redirects, 1, 0, 0) != 0)
exit (EXECUTION_FAILURE);
exit (invert ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
dispose_redirects (command->redirects);
command->redirects = (REDIRECT *)NULL;
@ -1162,16 +1172,20 @@ execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close)
/* If this is a simple command, tell execute_disk_command that it
might be able to get away without forking and simply exec.
This means things like ( sleep 10 ) will only cause one fork.
If we're timing the command, however, we cannot do this
optimization. */
If we're timing the command or inverting its return value, however,
we cannot do this optimization. */
if (user_subshell && (tcom->type == cm_simple || tcom->type == cm_subshell) &&
(tcom->flags & CMD_TIME_PIPELINE) == 0)
((tcom->flags & CMD_TIME_PIPELINE) == 0) &&
((tcom->flags & CMD_INVERT_RETURN) == 0))
{
tcom->flags |= CMD_NO_FORK;
if (tcom->type == cm_simple)
tcom->value.Simple->flags |= CMD_NO_FORK;
}
invert = (tcom->flags & CMD_INVERT_RETURN) != 0;
tcom->flags &= ~CMD_INVERT_RETURN;
/* If we're inside a function while executing this subshell, we
need to handle a possible `return'. */
function_value = 0;
@ -1184,6 +1198,11 @@ execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close)
return_code = execute_command_internal
(tcom, asynchronous, NO_PIPE, NO_PIPE, fds_to_close);
/* If we are asked to, invert the return value. */
if (invert)
return_code = (return_code == EXECUTION_SUCCESS) ? EXECUTION_FAILURE
: EXECUTION_SUCCESS;
/* If we were explicitly placed in a subshell with (), we need
to do the `shell cleanup' things, such as running traps[0]. */
if (user_subshell && signal_is_trapped (0))
@ -1513,9 +1532,9 @@ execute_for_command (for_command)
QUIT;
this_command_name = (char *)NULL;
v = bind_variable (identifier, list->word->word);
if (readonly_p (v))
if (readonly_p (v) || noassign_p (v))
{
if (interactive_shell == 0 && posixly_correct)
if (readonly_p (v) && interactive_shell == 0 && posixly_correct)
{
last_command_exit_value = EXECUTION_FAILURE;
jump_to_top_level (FORCE_EOF);
@ -1634,7 +1653,7 @@ execute_arith_for_command (arith_for_command)
}
REAP ();
if (expresult == 0)
break;
break;
/* Execute the body of the arithmetic for command. */
QUIT;
@ -1888,9 +1907,9 @@ execute_select_command (select_command)
break;
v = bind_variable (identifier, selection);
if (readonly_p (v))
if (readonly_p (v) || noassign_p (v))
{
if (interactive_shell == 0 && posixly_correct)
if (readonly_p (v) && interactive_shell == 0 && posixly_correct)
{
last_command_exit_value = EXECUTION_FAILURE;
jump_to_top_level (FORCE_EOF);
@ -1958,7 +1977,7 @@ execute_case_command (case_command)
case_command->word->word = word;
}
wlist = expand_word_no_split (case_command->word, 0);
wlist = expand_word_unsplit (case_command->word, 0);
word = wlist ? string_list (wlist) : savestring ("");
dispose_words (wlist);
@ -2404,6 +2423,10 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close)
already_forked = 1;
simple_command->flags |= CMD_NO_FORK;
subshell_environment = (pipe_in != NO_PIPE || pipe_out != NO_PIPE)
? (SUBSHELL_PIPE|SUBSHELL_FORK)
: (SUBSHELL_ASYNC|SUBSHELL_FORK);
/* We need to do this before piping to handle some really
pathological cases where one of the pipe file descriptors
is < 2. */
@ -2414,7 +2437,6 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close)
pipe_in = pipe_out = -1;
last_asynchronous_pid = old_last_async_pid;
subshell_environment = async ? SUBSHELL_ASYNC : SUBSHELL_FORK;
}
else
{
@ -2581,7 +2603,7 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close)
if (builtin || func)
{
if (already_forked)
if (already_forked)
{
/* reset_terminating_signals (); */ /* XXX */
/* Cancel traps, in trap.c. */
@ -2714,14 +2736,26 @@ execute_builtin (builtin, words, flags, subshell)
add_unwind_protect (dispose_builtin_env, (char *)NULL);
dispose_used_env_vars ();
}
#if 0
else
builtin_env = (char **)NULL;
#endif
/* Otherwise we inherit builtin_env from our caller. */
}
/* `return' does a longjmp() back to a saved environment in execute_function.
If a variable assignment list preceded the command, and the shell is
running in POSIX mode, we need to merge that into the shell_variables
table, since `return' is a POSIX special builtin. */
if (posixly_correct && subshell == 0 && builtin == return_builtin && temporary_env)
{
begin_unwind_frame ("return_temp_env");
add_unwind_protect (merge_temporary_env, (char *)NULL);
}
result = ((*builtin) (words->next));
/* This shouldn't happen, but in case `return' comes back instead of
longjmp'ing, we need to unwind. */
if (posixly_correct && subshell == 0 && builtin == return_builtin && temporary_env)
discard_unwind_frame ("return_temp_env");
if (subshell == 0 && (builtin == source_builtin || builtin == eval_builtin))
{
/* In POSIX mode, if any variable assignments precede the `.' or
@ -2729,12 +2763,8 @@ execute_builtin (builtin, words, flags, subshell)
and `eval' are special builtins. */
if (posixly_correct && builtin_env)
merge_builtin_env ();
#if 0
dispose_builtin_env ();
discard_unwind_frame ("builtin_env");
#else
run_unwind_frame ("builtin_env");
#endif
}
if (eval_unwind)
@ -2801,14 +2831,19 @@ execute_function (var, words, flags, fds_to_close, async, subshell)
if (temporary_env)
{
function_env = copy_array (temporary_env);
/* In POSIX mode, variable assignments preceding function names are
supposed to persist in the environment after the function returns,
as if a special builtin command had been executed. */
if (subshell == 0)
add_unwind_protect (dispose_function_env, (char *)NULL);
{
if (posixly_correct)
add_unwind_protect (merge_function_env, (char *)NULL);
else
add_unwind_protect (dispose_function_env, (char *)NULL);
}
dispose_used_env_vars ();
}
#if 0
else
function_env = (char **)NULL;
#endif
/* Otherwise, we inherit function_env from our caller. */
remember_args (words->next, 1);
@ -2968,6 +3003,7 @@ execute_builtin_or_function (words, builtin, var, redirects,
{
int result;
REDIRECT *saved_undo_list;
Function *saved_this_shell_builtin;
if (do_redirections (redirects, 1, 1, 0) != 0)
{
@ -2977,6 +3013,7 @@ execute_builtin_or_function (words, builtin, var, redirects,
return (EX_REDIRFAIL); /* was EXECUTION_FAILURE */
}
saved_this_shell_builtin = this_shell_builtin;
saved_undo_list = redirection_undo_list;
/* Calling the "exec" builtin changes redirections forever. */
@ -3002,6 +3039,21 @@ execute_builtin_or_function (words, builtin, var, redirects,
else
result = execute_function (var, words, flags, fds_to_close, 0, 0);
/* If we are executing the `command' builtin, but this_shell_builtin is
set to `exec_builtin', we know that we have something like
`command exec [redirection]', since otherwise `exec' would have
overwritten the shell and we wouldn't get here. In this case, we
want to behave as if the `command' builtin had not been specified
and preserve the redirections. */
if (builtin == command_builtin && this_shell_builtin == exec_builtin)
{
if (saved_undo_list)
dispose_redirects (saved_undo_list);
redirection_undo_list = exec_redirection_undo_list;
saved_undo_list = exec_redirection_undo_list = (REDIRECT *)NULL;
discard_unwind_frame ("saved_redirects");
}
if (saved_undo_list)
{
redirection_undo_list = saved_undo_list;
@ -3186,6 +3238,24 @@ execute_disk_command (words, redirects, command_line, pipe_in, pipe_out,
The word immediately following the #! is the interpreter to execute.
A single argument to the interpreter is allowed. */
/* CPP defines to decide whether a particular index into the #! line
corresponds to a valid interpreter name or argument character, or
whitespace. The MSDOS define is to allow \r to be treated the same
as \n. */
#if !defined (MSDOS)
# define STRINGCHAR(ind) \
(!whitespace (sample[ind]) && sample[ind] != '\n' && ind < sample_len)
# define WHITECHAR(ind) \
(whitespace (sample[ind]) && sample[ind] != '\n' && ind < sample_len)
#else /* MSDOS */
# define STRINGCHAR(ind) \
(!whitespace (sample[ind]) && sample[ind] != '\n' && sample[ind] != '\r' && ind < sample_len)
# define WHITECHAR(ind) \
(whitespace (sample[ind]) && sample[ind] != '\n' && sample[ind] != '\r' && ind < sample_len)
#endif /* MSDOS */
static int
execute_shell_script (sample, sample_len, command, args, env)
unsigned char *sample;
@ -3201,45 +3271,24 @@ execute_shell_script (sample, sample_len, command, args, env)
for (i = 2; whitespace (sample[i]) && i < sample_len; i++)
;
for (start = i;
!whitespace (sample[i]) && sample[i] != '\n' && i < sample_len;
i++)
for (start = i; STRINGCHAR(i); i++)
;
#if 1
execname = substring ((char *)sample, start, i);
#else
larry = i - start;
execname = xmalloc (1 + larry);
strncpy (execname, (char *)(sample + start), larry);
execname[larry] = '\0';
#endif
size_increment = 1;
/* Now the argument, if any. */
firstarg = (char *)NULL;
for (start = i;
whitespace (sample[i]) && sample[i] != '\n' && i < sample_len;
i++)
for (firstarg = (char *)NULL, start = i; WHITECHAR(i); i++)
;
/* If there is more text on the line, then it is an argument for the
interpreter. */
if (i < sample_len && sample[i] != '\n' && !whitespace (sample[i]))
{
for (start = i;
!whitespace (sample[i]) && sample[i] != '\n' && i < sample_len;
i++)
;
#if 1
firstarg = substring ((char *)sample, start, i);
#else
larry = i - start;
firstarg = xmalloc (1 + larry);
strncpy (firstarg, (char *)(sample + start), larry);
firstarg[larry] = '\0';
#endif
if (STRINGCHAR(i))
{
for (start = i; STRINGCHAR(i); i++)
;
firstarg = substring ((char *)sample, start, i);
size_increment = 2;
}
@ -3263,6 +3312,9 @@ execute_shell_script (sample, sample_len, command, args, env)
return (shell_execve (execname, args, env));
}
#undef STRINGCHAR
#undef WHITECHAR
#endif /* !HAVE_HASH_BANG_EXEC */
static void
@ -3290,6 +3342,17 @@ initialize_subshell ()
reset_shell_options ();
reset_shopt_options ();
/* Zero out builtin_env, since this could be a shell script run from a
sourced file with a temporary environment supplied to the `source/.'
builtin. Such variables are not supposed to be exported (empirical
testing with sh and ksh). */
builtin_env = 0;
clear_unwind_protect_list (0);
/* We're no longer inside a shell function. */
variable_context = return_catch_flag = 0;
/* If we're not interactive, close the file descriptor from which we're
reading the current shell script. */
if (interactive_shell == 0)
@ -3302,6 +3365,20 @@ initialize_subshell ()
# define SETOSTYPE(x)
#endif
#define READ_SAMPLE_BUF(file, buf, len) \
do \
{ \
fd = open(file, O_RDONLY); \
if (fd >= 0) \
{ \
len = read (fd, (char *)buf, 80); \
close (fd); \
} \
else \
len = -1; \
} \
while (0)
/* Call execve (), handling interpreting shell scripts, and handling
exec failures. */
int
@ -3311,20 +3388,31 @@ shell_execve (command, args, env)
{
struct stat finfo;
int larray, i, fd;
unsigned char sample[80];
int sample_len;
SETOSTYPE (0); /* Some systems use for USG/POSIX semantics */
execve (command, args, env);
i = errno; /* error from execve() */
SETOSTYPE (1);
/* If we get to this point, then start checking out the file.
Maybe it is something we can hack ourselves. */
if (errno != ENOEXEC)
if (i != ENOEXEC)
{
i = errno;
if ((stat (command, &finfo) == 0) && (S_ISDIR (finfo.st_mode)))
internal_error ("%s: is a directory", command);
else
{
#if defined (HAVE_HASH_BANG_EXEC)
READ_SAMPLE_BUF (command, sample, sample_len);
if (sample_len > 2 && sample[0] == '#' && sample[1] == '!')
{
errno = i;
sys_error ("%s: bad interpreter", command);
return (EX_NOEXEC);
}
#endif
errno = i;
file_error (command);
}
@ -3334,41 +3422,37 @@ shell_execve (command, args, env)
/* This file is executable.
If it begins with #!, then help out people with losing operating
systems. Otherwise, check to see if it is a binary file by seeing
if the first line (or up to 80 characters) are in the ASCII set.
Execute the contents as shell commands. */
fd = open (command, O_RDONLY);
if (fd >= 0)
if the contents of the first line (or up to 80 characters) are in the
ASCII set. If it's a text file, execute the contents as shell commands,
otherwise return 126 (EX_BINARY_FILE). */
READ_SAMPLE_BUF (command, sample, sample_len);
if (sample_len == 0)
return (EXECUTION_SUCCESS);
/* Is this supposed to be an executable script?
If so, the format of the line is "#! interpreter [argument]".
A single argument is allowed. The BSD kernel restricts
the length of the entire line to 32 characters (32 bytes
being the size of the BSD exec header), but we allow 80
characters. */
if (sample_len > 0)
{
unsigned char sample[80];
int sample_len;
sample_len = read (fd, (char *)sample, 80);
close (fd);
if (sample_len == 0)
return (EXECUTION_SUCCESS);
/* Is this supposed to be an executable script?
If so, the format of the line is "#! interpreter [argument]".
A single argument is allowed. The BSD kernel restricts
the length of the entire line to 32 characters (32 bytes
being the size of the BSD exec header), but we allow 80
characters. */
if (sample_len > 0)
{
#if !defined (HAVE_HASH_BANG_EXEC)
if (sample[0] == '#' && sample[1] == '!')
return (execute_shell_script (sample, sample_len, command, args, env));
else
if (sample_len > 2 && sample[0] == '#' && sample[1] == '!')
return (execute_shell_script (sample, sample_len, command, args, env));
else
#endif
if (check_binary_file (sample, sample_len))
{
internal_error ("%s: cannot execute binary file", command);
return (EX_BINARY_FILE);
}
if (check_binary_file (sample, sample_len))
{
internal_error ("%s: cannot execute binary file", command);
return (EX_BINARY_FILE);
}
}
/* We have committed to attempting to execute the contents of this file
as shell commands. */
initialize_subshell ();
set_sigint_handler ();
@ -3430,9 +3514,10 @@ execute_intern_function (name, function)
}
var = find_function (name->word);
if (var && readonly_p (var))
if (var && (readonly_p (var) || noassign_p (var)))
{
internal_error ("%s: readonly function", var->name);
if (readonly_p (var))
internal_error ("%s: readonly function", var->name);
return (EXECUTION_FAILURE);
}

39
expr.c
View file

@ -417,6 +417,9 @@ expassign ()
case BOR:
lvalue |= value;
break;
case BXOR:
lvalue ^= value;
break;
default:
free (lhs);
evalerror ("bug: bad expassign token");
@ -461,9 +464,9 @@ expcond ()
val1 = EXP_HIGHEST ();
#endif
if (set_noeval)
noeval--;
noeval--;
if (curtok != COL)
evalerror ("`:' expected for conditional expression");
evalerror ("`:' expected for conditional expression");
readtok ();
if (curtok == 0)
evalerror ("expression expected");
@ -475,7 +478,7 @@ expcond ()
}
val2 = explor ();
if (set_noeval)
noeval--;
noeval--;
rval = cval ? val1 : val2;
lasttok = COND;
}
@ -695,8 +698,8 @@ exp2 ()
val1 = exppower ();
while ((curtok == MUL) ||
(curtok == DIV) ||
(curtok == MOD))
(curtok == DIV) ||
(curtok == MOD))
{
int op = curtok;
@ -708,11 +711,11 @@ exp2 ()
evalerror ("division by 0");
if (op == MUL)
val1 *= val2;
val1 *= val2;
else if (op == DIV)
val1 /= val2;
val1 /= val2;
else if (op == MOD)
val1 %= val2;
val1 %= val2;
}
return (val1);
}
@ -773,7 +776,7 @@ exp0 ()
stok = lasttok = curtok;
readtok ();
if (curtok != STR)
/* readtok() catches this */
/* readtok() catches this */
evalerror ("identifier expected after pre-increment or pre-decrement");
v2 = tokval + ((stok == PREINC) ? 1 : -1);
@ -906,7 +909,7 @@ readtok ()
/* The tests for PREINC and PREDEC aren't strictly correct, but they
preserve old behavior if a construct like --x=9 is given. */
if (lasttok == PREINC || lasttok == PREDEC || peektok != EQ)
{
{
#if defined (ARRAY_VARS)
value = (e == ']') ? get_array_value (tokstr, 0) : get_string_value (tokstr);
#else
@ -919,9 +922,9 @@ readtok ()
if (e == ']')
FREE (value); /* get_array_value returns newly-allocated memory */
#endif
}
}
else
tokval = 0;
tokval = 0;
lasttok = curtok;
curtok = STR;
@ -977,12 +980,12 @@ readtok ()
else if ((c == BOR) && (c1 == BOR))
c = LOR;
else if ((c == '*') && (c1 == '*'))
c = POWER;
c = POWER;
else if ((c == '-') && (c1 == '-') && legal_variable_starter (*cp))
c = PREDEC;
c = PREDEC;
else if ((c == '+') && (c1 == '+') && legal_variable_starter (*cp))
c = PREINC;
else if (c1 == EQ && member(c, "*/%+-&^|"))
c = PREINC;
else if (c1 == EQ && member (c, "*/%+-&^|"))
{
assigntok = c; /* a OP= b */
c = OP_ASSIGN;
@ -1133,9 +1136,9 @@ main (argc, argv)
{
v = evalexp (argv[i], &expok);
if (expok == 0)
fprintf (stderr, "%s: expression error\n", argv[i]);
fprintf (stderr, "%s: expression error\n", argv[i]);
else
printf ("'%s' -> %ld\n", argv[i], v);
printf ("'%s' -> %ld\n", argv[i], v);
}
exit (0);
}

153
externs.h
View file

@ -95,15 +95,6 @@ extern GENERIC_LIST *list_append ();
extern GENERIC_LIST *delete_element ();
/* Declarations for functions defined in stringlib.c */
extern char *ansicstr __P((char *, int, int, int *, int *));
extern int find_name_in_array __P((char *, char **));
extern char **alloc_array __P((int));
extern int array_len __P((char **));
extern void free_array_members __P((char **));
extern void free_array __P((char **));
extern char **copy_array __P((char **));
extern int qsort_string_compare ();
extern void sort_char_array __P((char **));
extern char **word_list_to_argv __P((WORD_LIST *, int, int, int *));
extern WORD_LIST *argv_to_word_list __P((char **, int, int));
@ -113,11 +104,18 @@ extern char *strsub __P((char *, char *, char *, int));
extern char *strcreplace __P((char *, int, char *, int));
extern void strip_leading __P((char *));
extern void strip_trailing __P((char *, int, int));
extern char *strindex __P((char *, char *));
extern void xbcopy __P((char *, char *, int));
/* Functions from the bash library, lib/sh/libsh.a. These should really
go into a separate include file. */
/* declarations for functions defined in lib/sh/clktck.c */
extern long get_clk_tck __P((void));
/* declarations for functions defined in lib/sh/clock.c */
extern void clock_t_to_secs ();
extern void print_clock_t ();
/* Declarations for functions defined in lib/sh/getcwd.c */
#if !defined (HAVE_GETCWD)
extern char *getcwd __P((char *, size_t));
@ -127,32 +125,100 @@ extern char *getcwd __P((char *, size_t));
extern char *inttostr __P((int, char *, int));
extern char *itos __P((int));
/* declarations for functions defined in lib/sh/makepath.c */
#define MP_DOTILDE 0x01
#define MP_DOCWD 0x02
#define MP_RMDOT 0x04
extern char *sh_makepath __P((char *, char *, int));
/* declarations for functions defined in lib/sh/netopen.c */
extern int netopen __P((char *));
/* Declarations for functions defined in lib/sh/oslib.c */
extern long get_clk_tck __P((void));
#if !defined (strerror)
extern char *strerror __P((int));
#endif
#if !defined (HAVE_STRCASECMP)
extern int strncasecmp __P((const char *, const char *, int));
extern int strcasecmp __P((const char *, const char *));
#endif /* HAVE_STRCASECMP */
extern int dup2 __P((int, int));
#if !defined (HAVE_GETHOSTNAME)
extern int gethostname __P((char *, int));
#endif /* !HAVE_GETHOSTNAME */
#if !defined (HAVE_GETDTABLESIZE)
extern int getdtablesize __P((void));
#endif /* !HAVE_GETDTABLESIZE */
#if !defined (HAVE_GETHOSTNAME)
extern int gethostname __P((char *, int));
#endif /* !HAVE_GETHOSTNAME */
/* declarations for functions defined in lib/sh/pathcanon.c */
#define PATH_CHECKDOTDOT 0x0001
#define PATH_CHECKEXISTS 0x0002
#define PATH_HARDPATH 0x0004
#define PATH_NOALLOC 0x0008
extern char *sh_canonpath __P((char *, int));
/* declarations for functions defined in lib/sh/pathphys.c */
extern char *sh_physpath __P((char *, int));
extern char *sh_realpath __P((const char *, char *));
/* declarations for functions defined in lib/sh/setlinebuf.c */
#if !defined (HAVE_SETLINEBUF)
extern int setlinebuf ();
#endif
/* declarations for functions defined in lib/sh/shquote.c */
extern char *sh_single_quote __P((char *));
extern char *sh_double_quote __P((char *));
extern char *sh_un_double_quote __P((char *));
extern char *sh_backslash_quote __P((char *));
extern char *sh_backslash_quote_for_double_quotes __P((char *));
extern int sh_contains_shell_metas __P((char *));
/* declarations for functions defined in lib/sh/spell.c */
extern int spname __P((char *, char *));
/* declarations for functions defined in lib/sh/strcasecmp.c */
#if !defined (HAVE_STRCASECMP)
extern int strncasecmp __P((const char *, const char *, int));
extern int strcasecmp __P((const char *, const char *));
#endif /* HAVE_STRCASECMP */
/* declarations for functions defined in lib/sh/strerror.c */
#if !defined (strerror)
extern char *strerror __P((int));
#endif
/* declarations for functions defined in lib/sh/strindex.c */
extern char *strindex __P((const char *, const char *));
/* declarations for functions and structures defined in lib/sh/stringlist.c */
/* This is a general-purpose argv-style array struct. */
typedef struct _list_of_strings {
char **list;
int list_size;
int list_len;
} STRINGLIST;
extern STRINGLIST *alloc_stringlist __P((int));
extern STRINGLIST *realloc_stringlist __P((STRINGLIST *, int));
extern void free_stringlist __P((STRINGLIST *));
extern STRINGLIST *copy_stringlist __P((STRINGLIST *));
extern STRINGLIST *merge_stringlists __P((STRINGLIST *, STRINGLIST *));
extern STRINGLIST *append_stringlist __P((STRINGLIST *, STRINGLIST *));
extern STRINGLIST *prefix_suffix_stringlist __P((STRINGLIST *, char *, char *));
extern void print_stringlist __P((STRINGLIST *, char *));
extern void sort_stringlist __P((STRINGLIST *));
/* declarations for functions defined in lib/sh/stringvec.c */
extern int find_name_in_array __P((char *, char **));
extern char **alloc_array __P((int));
extern int array_len __P((char **));
extern void free_array_members __P((char **));
extern void free_array __P((char **));
extern char **copy_array __P((char **));
extern int qsort_string_compare ();
extern void sort_char_array __P((char **));
/* declarations for functions defined in lib/sh/strtod.c */
#if !defined (HAVE_STRTOD)
extern double strtod __P((const char *, char **));
@ -168,6 +234,25 @@ extern long strtol __P((const char *, char **, int));
extern unsigned long strtoul __P((const char *, char **, int));
#endif
/* declarations for functions defined in lib/sh/strtrans.c */
extern char *ansicstr __P((char *, int, int, int *, int *));
extern char *ansic_quote __P((char *, int, int *));
/* declarations for functions defined in lib/sh/timeval.c. No prototypes
so we don't have to count on having a definition of struct timeval in
scope when this file is included. */
extern void timeval_to_secs ();
extern void print_timeval ();
/* declarations for functions defined in lib/sh/tmpfile.c */
#define MT_USETMPDIR 0x0001
#define MT_READWRITE 0x0002
#define MT_USERANDOM 0x0004
extern char *sh_mktmpname __P((char *, int));
extern int sh_mktmpfd __P((char *, int, char **));
/* extern FILE *sh_mktmpfp __P((char *, int, char **)); */
/* declarations for functions defined in lib/sh/zread.c */
extern int zread __P((int, char *, size_t));
extern int zread1 __P((int, char *, size_t));
@ -178,24 +263,4 @@ extern void zsyncfd __P((int));
/* declarations for functions defined in lib/sh/zwrite.c */
extern int zwrite __P((int, unsigned char *, size_t));
/* declarations for functions defined in lib/sh/netopen.c */
extern int netopen __P((char *));
/* declarations for functions defined in lib/sh/timeval.c. No prototypes
so we don't have to count on having a definition of struct timeval in
scope when this file is included. */
extern void timeval_to_secs ();
extern void print_timeval ();
/* declarations for functions defined in lib/sh/clock.c */
extern void clock_t_to_secs ();
extern void print_clock_t ();
/* declarations for functions defined in lib/sh/makepath.c */
#define MP_DOTILDE 0x01
#define MP_DOCWD 0x02
#define MP_RMDOT 0x04
extern char *sh_makepath __P((char *, char *, int));
#endif /* _EXTERNS_H_ */

View file

@ -160,6 +160,16 @@ is_directory (file)
return (file_status (file) & FS_DIRECTORY);
}
int
executable_or_directory (file)
char *file;
{
int s;
s = file_status (file);
return ((s & FS_EXECABLE) || (s & FS_DIRECTORY));
}
/* Locate the executable file referenced by NAME, searching along
the contents of the shell PATH variable. Return a new string
which is the full pathname to the file, or NULL if the file
@ -305,12 +315,12 @@ search_for_command (pathname)
/* If $PATH is in the temporary environment, we've already retrieved
it, so don't bother trying again. */
if (temp_path)
{
{
command = find_user_command_in_path (pathname, value_cell (path),
FS_EXEC_PREFERRED|FS_NODIRS);
if (tempvar_p (path))
dispose_variable (path);
}
}
else
command = find_user_command (pathname);
if (command && hashing_enabled && temp_path == 0)
@ -557,6 +567,14 @@ find_user_command_in_path (name, path_list, flags)
/* We didn't find exactly what the user was looking for. Return
the contents of FILE_TO_LOSE_ON which is NULL when the search
required an executable, or non-NULL if a file was found and the
search would accept a non-executable as a last resort. */
search would accept a non-executable as a last resort. If the
caller specified FS_NODIRS, and file_to_lose_on is a directory,
return NULL. */
if (file_to_lose_on && (flags & FS_NODIRS) && is_directory (file_to_lose_on))
{
free (file_to_lose_on);
file_to_lose_on = (char *)NULL;
}
return (file_to_lose_on);
}

View file

@ -26,6 +26,7 @@
extern int file_status __P((char *));
extern int executable_file __P((char *));
extern int is_directory __P((char *));
extern int executable_or_directory __P((char *));
extern char *find_user_command __P((char *));
extern char *find_path_file __P((char *));
extern char *search_for_command __P((char *));

View file

@ -249,7 +249,7 @@ change_flag (flag, on_or_off)
#if defined (RESTRICTED_SHELL)
case 'r':
if (on_or_off == FLAG_ON)
maybe_make_restricted (shell_name);
maybe_make_restricted (shell_name);
break;
#endif

238
general.c
View file

@ -50,8 +50,12 @@ extern int errno;
# define to_lower(c) (isupper(c) ? tolower(c) : (c))
#endif
extern int interactive_shell, expand_aliases;
extern int interrupt_immediately;
extern int interactive_comments;
extern int check_hashed_filenames;
extern int source_uses_path;
extern int source_searches_cwd;
/* A standard error message to use when getcwd() returns NULL. */
char *bash_getcwd_errstr = "getcwd: cannot access parent directories";
@ -61,7 +65,18 @@ void
posix_initialize (on)
int on;
{
interactive_comments = on != 0;
/* Things that should be turned on when posix mode is enabled. */
if (on != 0)
{
interactive_comments = source_uses_path = expand_aliases = 1;
}
/* Things that should be turned on when posix mode is disabled. */
if (on == 0)
{
source_searches_cwd = 1;
expand_aliases = interactive_shell;
}
}
/* **************************************************************** */
@ -131,13 +146,12 @@ int
all_digits (string)
char *string;
{
while (*string)
{
if (!digit (*string))
return (0);
else
string++;
}
register char *s;
for (s = string; *s; s++)
if (isdigit (*s) == 0)
return (0);
return (1);
}
@ -157,6 +171,10 @@ legal_number (string, result)
value = strtol (string, &ep, 10);
/* Skip any trailing whitespace, since strtol does not. */
while (whitespace (*ep))
ep++;
/* If *string is not '\0' but *ep is '\0' on return, the entire string
is valid. */
if (string && *string && *ep == '\0')
@ -187,7 +205,7 @@ legal_identifier (name)
for (s = name + 1; *s; s++)
{
if (legal_variable_char (*s) == 0)
return (0);
return (0);
}
return (1);
}
@ -234,7 +252,7 @@ check_identifier (word, check_word)
/* Make sure no-delay mode is not set on file descriptor FD. */
int
unset_nodelay_mode (fd)
sh_unset_nodelay_mode (fd)
int fd;
{
int flags, bflags;
@ -394,175 +412,6 @@ check_binary_file (sample, sample_len)
/* */
/* **************************************************************** */
/* Return 1 if PATH corresponds to a directory. */
static int
canon_stat (path)
char *path;
{
int l;
char *s;
struct stat sb;
l = strlen (path);
s = xmalloc (l + 3);
strcpy (s, path);
s[l] = '/';
s[l+1] = '.';
s[l+2] = '\0';
l = stat (s, &sb) == 0 && S_ISDIR (sb.st_mode);
free (s);
return l;
}
/* Canonicalize PATH, and return a new path. The new path differs from PATH
in that:
Multple `/'s are collapsed to a single `/'.
Leading `./'s and trailing `/.'s are removed.
Trailing `/'s are removed.
Non-leading `../'s and trailing `..'s are handled by removing
portions of the path. */
char *
canonicalize_pathname (path)
char *path;
{
register int i, start;
char stub_char;
char *result;
/* The result cannot be larger than the input PATH. */
result = savestring (path);
stub_char = (*path == '/') ? '/' : '.';
/* Walk along RESULT looking for things to compact. */
i = 0;
while (1)
{
if (!result[i])
break;
while (result[i] && result[i] != '/')
i++;
start = i++;
/* If we didn't find any slashes, then there is nothing left to do. */
if (!result[start])
break;
/* Handle multiple `/'s in a row. */
while (result[i] == '/')
i++;
#if 0
if ((start + 1) != i)
#else
/* Leave a leading `//' alone, as POSIX requires. */
if ((start + 1) != i && (start != 0 || i != 2))
#endif
{
strcpy (result + start + 1, result + i);
i = start + 1;
/* Make sure that what we have so far corresponds to a directory.
If it does not, just punt. */
if (*result)
{
char c;
c = result[start];
result[start] = '\0';
if (canon_stat (result) == 0)
{
free (result);
return ((char *)NULL);
}
result[start] = c;
}
}
#if 0
/* Handle backslash-quoted `/'. */
if (start > 0 && result[start - 1] == '\\')
continue;
#endif
/* Check for trailing `/'. */
if (start && !result[i])
{
zero_last:
result[--i] = '\0';
break;
}
/* Check for `../', `./' or trailing `.' by itself. */
if (result[i] == '.')
{
/* Handle trailing `.' by itself. */
if (!result[i + 1])
goto zero_last;
/* Handle `./'. */
if (result[i + 1] == '/')
{
strcpy (result + i, result + i + 1);
i = (start < 0) ? 0 : start;
continue;
}
/* Handle `../' or trailing `..' by itself. */
if (result[i + 1] == '.' &&
(result[i + 2] == '/' || !result[i + 2]))
{
/* Make sure that the last component corresponds to a directory
before blindly chopping it off. */
if (i)
{
result[i] = '\0';
if (canon_stat (result) == 0)
{
free (result);
return ((char *)NULL);
}
result[i] = '.';
}
while (--start > -1 && result[start] != '/');
strcpy (result + start + 1, result + i + 2);
#if 0 /* Unnecessary */
if (*result && canon_stat (result) == 0)
{
free (result);
return ((char *)NULL);
}
#endif
i = (start < 0) ? 0 : start;
continue;
}
}
}
if (!*result)
{
*result = stub_char;
result[1] = '\0';
}
/* If the result starts with `//', but the original path does not, we
can turn the // into /. */
if ((result[0] == '/' && result[1] == '/' && result[2] != '/') &&
(path[0] != '/' || path[1] != '/' || path[2] == '/'))
{
char *r2;
if (result[2] == '\0') /* short-circuit for bare `//' */
result[1] = '\0';
else
{
r2 = savestring (result + 1);
free (result);
result = r2;
}
}
return (result);
}
/* Turn STRING (a pathname) into an absolute pathname, assuming that
DOT_PATH contains the symbolic location of `.'. This always
returns a new string, even if STRING was an absolute pathname to
@ -573,7 +422,7 @@ make_absolute (string, dot_path)
{
char *result;
if (dot_path == 0 || *string == '/')
if (dot_path == 0 || ABSPATH(string))
result = savestring (string);
else
result = sh_makepath (dot_path, string, 0);
@ -581,23 +430,24 @@ make_absolute (string, dot_path)
return (result);
}
/* Return 1 if STRING contains an absolute pathname, else 0. */
/* Return 1 if STRING contains an absolute pathname, else 0. Used by `cd'
to decide whether or not to look up a directory name in $CDPATH. */
int
absolute_pathname (string)
char *string;
{
if (!string || !*string)
if (string == 0 || *string == '\0')
return (0);
if (*string == '/')
if (ABSPATH(string))
return (1);
if (string[0] == '.' && PATHSEP(string[1])) /* . and ./ */
return (1);
if (string[0] == '.' && string[1] == '.' && PATHSEP(string[2])) /* .. and ../ */
return (1);
if (*string++ == '.')
{
if (!*string || *string == '/' ||
(*string == '.' && (string[1] == '\0' || string[1] == '/')))
return (1);
}
return (0);
}
@ -619,7 +469,7 @@ base_pathname (string)
{
char *p;
if (!absolute_pathname (string))
if (absolute_pathname (string) == 0)
return (string);
p = (char *)strrchr (string, '/');
@ -638,7 +488,7 @@ full_pathname (file)
file = (*file == '~') ? bash_tilde_expand (file) : savestring (file);
if ((*file == '/') && absolute_pathname (file))
if (ABSPATH(file))
return (file);
ret = sh_makepath ((char *)NULL, file, (MP_DOCWD|MP_RMDOT));
@ -857,7 +707,7 @@ initialize_group_array ()
if (i == ngroups && ngroups < maxgroups)
{
for (i = ngroups; i > 0; i--)
group_array[i] = group_array[i - 1];
group_array[i] = group_array[i - 1];
group_array[0] = current_user.gid;
ngroups++;
}
@ -868,8 +718,8 @@ initialize_group_array ()
if (group_array[0] != current_user.gid)
{
for (i = 0; i < ngroups; i++)
if (group_array[i] == current_user.gid)
break;
if (group_array[i] == current_user.gid)
break;
if (i < ngroups)
{
group_array[i] = group_array[0];

View file

@ -79,17 +79,21 @@ extern char *strcpy ();
#endif
#ifndef digit
#define digit(c) ((c) >= '0' && (c) <= '9')
#define digit(c) (isdigit(c))
#endif
#ifndef isletter
#define isletter(c) (((c) >= 'A' && (c) <= 'Z') || ((c) >= 'a' && (c) <= 'z'))
#define isletter(c) (isalpha(c))
#endif
#ifndef digit_value
#define digit_value(c) ((c) - '0')
#endif
#ifndef ISOCTAL
#define ISOCTAL(c) ((c) >= '0' && (c) <= '7')
#endif
/* Define exactly what a legal shell identifier consists of. */
#define legal_variable_starter(c) (isletter(c) || (c == '_'))
#define legal_variable_char(c) (isletter (c) || digit (c) || c == '_')
@ -115,7 +119,7 @@ typedef struct {
/* A macro to avoid making an uneccessary function call. */
#define REVERSE_LIST(list, type) \
((list && list->next) ? (type)reverse_list ((GENERIC_LIST *)list) \
: (type)(list))
: (type)(list))
#if __GNUC__ > 1
# define FASTCOPY(s, d, n) __builtin_memcpy (d, s, n)
@ -178,6 +182,23 @@ typedef char **CPPFunction ();
#define FS_DIRECTORY 0x10
#define FS_NODIRS 0x20
/* Some useful definitions for Unix pathnames. Argument convention:
x == string, c == character */
#if !defined (__CYGWIN__)
# define ABSPATH(x) ((x)[0] == '/')
# define RELPATH(x) ((x)[0] != '/')
#else /* __CYGWIN__ */
# define ABSPATH(x) (((x)[0] && isalpha((x)[0]) && (x)[1] == ':' && (x)[2] == '/') || (x)[0] == '/')
# define RELPATH(x) (!(x)[0] || ((x)[1] != ':' && (x)[0] != '/'))
#endif /* __CYGWIN__ */
#define ROOTEDPATH(x) (ABSPATH(x))
#define DIRSEP '/'
#define ISDIRSEP(c) ((c) == '/')
#define PATHSEP(c) (ISDIRSEP(c) || (c) == 0)
/* Declarations for functions defined in xmalloc.c */
extern char *xmalloc __P((size_t));
extern char *xrealloc __P((void *, size_t));
@ -196,13 +217,12 @@ extern int legal_number __P((char *, long *));
extern int legal_identifier __P((char *));
extern int check_identifier __P((WORD_DESC *, int));
extern int unset_nodelay_mode __P((int));
extern int sh_unset_nodelay_mode __P((int));
extern void check_dev_tty __P((void));
extern int same_file (); /* too many problems with prototype */
extern int move_to_high_fd __P((int, int, int));
extern int check_binary_file __P((unsigned char *, int));
extern char *canonicalize_pathname __P((char *));
extern char *make_absolute __P((char *, char *));
extern int absolute_pathname __P((char *));
extern int absolute_program __P((char *));

View file

@ -270,7 +270,7 @@ print_table_stats (table, name)
fprintf (stderr, "\tslot %3d: ", slot);
for (bcount = 0; bc; bc = bc->next)
bcount++;
bcount++;
fprintf (stderr, "%d\n", bcount);
}
@ -310,9 +310,9 @@ main ()
{
char *temp_string;
if (fgets (string, sizeof (string), stdin) == 0)
break;
break;
if (!*string)
break;
break;
temp_string = savestring (string);
tt = add_hash_item (temp_string, table);
if (tt->times_found)

View file

@ -27,6 +27,9 @@
extern int atoi ();
extern long int atol ();
extern double atof ();
extern double strtod ();
/* Memory allocation functions. */
extern char *malloc ();
extern char *realloc ();

View file

@ -1,4 +1,4 @@
/* Copyright (C) 1999 Free Software Foundation, Inc.
/* Copyright (C) 1999 Free Software Foundation, Inc. */
/* This file is part of GNU Bash, the Bourne Again SHell.

181
input.c
View file

@ -100,6 +100,15 @@ ungetc_with_restart (c, stream)
# define SEEK_CUR 1
#endif /* !SEEK_CUR */
#ifdef max
# undef max
#endif
#define max(a, b) (((a) > (b)) ? (a) : (b))
#ifdef min
# undef min
#endif
#define min(a, b) ((a) > (b) ? (b) : (a))
extern int return_EOF ();
extern int interactive_shell;
@ -114,8 +123,6 @@ int bash_input_fd_changed;
static BUFFERED_STREAM **buffers = (BUFFERED_STREAM **)NULL;
static int nbuffers;
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define ALLOCATE_BUFFERS(n) \
do { if ((n) >= nbuffers) allocate_buffers (n); } while (0)
@ -173,65 +180,104 @@ copy_buffered_stream (bp)
return (nbp);
}
int
set_bash_input_fd (fd)
int fd;
{
if (bash_input.type == st_bstream)
bash_input.location.buffered_fd = fd;
else if (interactive_shell == 0)
default_buffered_input = fd;
return 0;
}
int
fd_is_bash_input (fd)
int fd;
{
if (bash_input.type == st_bstream && bash_input.location.buffered_fd == fd)
return 1;
else if (interactive_shell == 0 && default_buffered_input == fd)
return 1;
return 0;
}
/* Save the buffered stream corresponding to file descriptor FD (which bash
is using to read input) to a buffered stream associated with NEW_FD. If
NEW_FD is -1, a new file descriptor is allocated with fcntl. The new
file descriptor is returned on success, -1 on error. */
int
save_bash_input (fd, new_fd)
int fd, new_fd;
{
int nfd;
/* Sync the stream so we can re-read from the new file descriptor. We
might be able to avoid this by copying the buffered stream verbatim
to the new file descriptor. */
if (buffers[fd])
sync_buffered_stream (fd);
/* Now take care of duplicating the file descriptor that bash is
using for input, so we can reinitialize it later. */
nfd = (new_fd == -1) ? fcntl (fd, F_DUPFD, 10) : new_fd;
if (nfd == -1)
{
if (fcntl (fd, F_GETFD, 0) == 0)
sys_error ("cannot allocate new file descriptor for bash input from fd %d", fd);
return -1;
}
if (buffers[nfd])
{
/* What's this? A stray buffer without an associated open file
descriptor? Free up the buffer and report the error. */
internal_error ("check_bash_input: buffer already exists for new fd %d", nfd);
free_buffered_stream (buffers[nfd]);
}
/* Reinitialize bash_input.location. */
if (bash_input.type == st_bstream)
{
bash_input.location.buffered_fd = nfd;
fd_to_buffered_stream (nfd);
close_buffered_fd (fd); /* XXX */
}
else
/* If the current input type is not a buffered stream, but the shell
is not interactive and therefore using a buffered stream to read
input (e.g. with an `eval exec 3>output' inside a script), note
that the input fd has been changed. pop_stream() looks at this
value and adjusts the input fd to the new value of
default_buffered_input accordingly. */
bash_input_fd_changed++;
if (default_buffered_input == fd)
default_buffered_input = nfd;
SET_CLOSE_ON_EXEC (nfd);
return nfd;
}
/* Check that file descriptor FD is not the one that bash is currently
using to read input from a script. FD is about to be duplicated onto,
which means that the kernel will close it for us. If FD is the bash
input file descriptor, we need to seek backwards in the script (if
possible and necessary -- scripts read from stdin are still unbuffered),
allocate a new file descriptor to use for bash input, and re-initialize
the buffered stream. */
the buffered stream. Make sure the file descriptor used to save bash
input is set close-on-exec. Returns 0 on success, -1 on failure. This
works only if fd is > 0 -- if fd == 0 and bash is reading input from
fd 0, save_bash_input is used instead, to cooperate with input
redirection (look at redir.c:add_undo_redirect()). */
int
check_bash_input (fd)
int fd;
{
int nfd;
if (fd > 0 && ((bash_input.type == st_bstream && bash_input.location.buffered_fd == fd) ||
(interactive_shell == 0 && default_buffered_input == fd)))
{
/* Sync the stream so we can re-read from the new file descriptor. We
might be able to avoid this by copying the buffered stream verbatim
to the new file descriptor. */
if (buffers[fd])
sync_buffered_stream (fd);
/* Now take care of duplicating the file descriptor that bash is
using for input, so we can reinitialize it later. */
nfd = fcntl (fd, F_DUPFD, 10);
if (nfd == -1)
{
if (fcntl (fd, F_GETFD, 0) == 0)
sys_error ("cannot allocate new file descriptor for bash input from fd %d", fd);
return -1;
}
if (buffers[nfd])
{
/* What's this? A stray buffer without an associated open file
descriptor? Free up the buffer and report the error. */
internal_error ("check_bash_input: buffer already exists for new fd %d", nfd);
free_buffered_stream (buffers[nfd]);
}
/* Reinitialize bash_input.location. */
if (bash_input.type == st_bstream)
{
bash_input.location.buffered_fd = nfd;
fd_to_buffered_stream (nfd);
close_buffered_fd (fd); /* XXX */
}
else
/* If the current input type is not a buffered stream, but the shell
is not interactive and therefore using a buffered stream to read
input (e.g. with an `eval exec 3>output' inside a script), note
that the input fd has been changed. pop_stream() looks at this
value and adjusts the input fd to the new value of
default_buffered_input accordingly. */
bash_input_fd_changed++;
if (default_buffered_input == fd)
default_buffered_input = nfd;
}
if (fd > 0 && fd_is_bash_input (fd))
return ((save_bash_input (fd, -1) == -1) ? -1 : 0);
return 0;
}
@ -264,18 +310,22 @@ duplicate_buffered_stream (fd1, fd2)
if (buffers[fd2])
buffers[fd2]->b_fd = fd2;
if (is_bash_input && !buffers[fd2])
fd_to_buffered_stream (fd2);
if (is_bash_input)
{
if (!buffers[fd2])
fd_to_buffered_stream (fd2);
buffers[fd2]->b_flag |= B_WASBASHINPUT;
}
return (fd2);
}
/* Return 1 if a seek on FD will succeed. */
#ifndef __CYGWIN32__
#ifndef __CYGWIN__
# define fd_is_seekable(fd) (lseek ((fd), 0L, SEEK_CUR) >= 0)
#else
# define fd_is_seekable(fd) 0
#endif /* __CYGWIN32__ */
#endif /* __CYGWIN__ */
/* Take FD, a file descriptor, and create and return a buffered stream
corresponding to it. If something is wrong and the file descriptor
@ -294,13 +344,9 @@ fd_to_buffered_stream (fd)
return ((BUFFERED_STREAM *)NULL);
}
if (fd_is_seekable (fd) == 0)
size = (fd_is_seekable (fd)) ? min (sb.st_size, MAX_INPUT_BUFFER_SIZE) : 1;
if (size == 0)
size = 1;
else
size = (size_t)((sb.st_size > MAX_INPUT_BUFFER_SIZE)
? MAX_INPUT_BUFFER_SIZE
: sb.st_size);
buffer = (char *)xmalloc (size);
return (make_buffered_stream (fd, buffer, size));
@ -381,6 +427,11 @@ b_fill_buffer (bp)
BUFFERED_STREAM *bp;
{
bp->b_used = zread (bp->b_fd, bp->b_buffer, bp->b_size);
#if defined (__CYGWIN__)
/* If on cygwin, translate \r\n to \n. */
if (bp->b_buffer[bp->b_used - 1] == '\r' && bp->b_buffer[bp->b_used] == '\n')
bp->b_buffer[--bp->b_used] = '\n';
#endif
if (bp->b_used <= 0)
{
bp->b_buffer[0] = 0;
@ -422,9 +473,9 @@ sync_buffered_stream (bfd)
BUFFERED_STREAM *bp;
off_t chars_left;
bp = buffers[bfd];
if (!bp)
if (buffers == 0 || (bp = buffers[bfd]) == 0)
return (-1);
chars_left = bp->b_used - bp->b_inputp;
if (chars_left)
lseek (bp->b_fd, -chars_left, SEEK_CUR);
@ -435,7 +486,15 @@ sync_buffered_stream (bfd)
int
buffered_getchar ()
{
#if !defined (DJGPP)
return (bufstream_getc (buffers[bash_input.location.buffered_fd]));
#else
/* On DJGPP, ignore \r. */
int ch;
while ((ch = bufstream_getc (buffers[bash_input.location.buffered_fd])) == '\r')
;
return ch;
#endif
}
int

10
input.h
View file

@ -40,9 +40,10 @@ enum stream_type {st_none, st_stdin, st_stream, st_string, st_bstream};
#undef B_ERROR /* There are some systems with this define */
#undef B_UNBUFF
#define B_EOF 0x1
#define B_ERROR 0x2
#define B_UNBUFF 0x4
#define B_EOF 0x01
#define B_ERROR 0x02
#define B_UNBUFF 0x04
#define B_WASBASHINPUT 0x08
/* A buffered stream. Like a FILE *, but with our own buffering and
synchronization. Look in input.c for the implementation. */
@ -106,6 +107,9 @@ extern int ungetc_with_restart ();
#if defined (BUFFERED_INPUT)
/* Functions from input.c. */
extern int fd_is_bash_input __P((int));
extern int set_bash_input_fd __P((int));
extern int save_bash_input __P((int, int));
extern int check_bash_input __P((int));
extern int duplicate_buffered_stream __P((int, int));
extern BUFFERED_STREAM *fd_to_buffered_stream __P((int));

762
jobs.c

File diff suppressed because it is too large Load diff

2
jobs.h
View file

@ -151,7 +151,7 @@ extern int start_job __P((int, int));
extern int kill_pid __P((pid_t, int, int));
extern int initialize_job_control __P((int));
extern void initialize_job_signals __P((void));
extern int give_terminal_to __P((pid_t));
extern int give_terminal_to __P((pid_t, int));
extern void set_sigwinch_handler __P((void));
extern void unset_sigwinch_handler __P((void));

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