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

This commit is contained in:
Jari Aalto 1999-02-19 17:11:39 +00:00
commit b72432fdcc
191 changed files with 10113 additions and 3553 deletions

321
CHANGES
View file

@ -1,3 +1,322 @@
This document details the changes between this version, bash-2.03-release,
and the previous version, bash-2.03-beta2.
1. Changes to Bash
a. A file descriptor leak in the `fc' builtin was fixed.
b. A bug was fixed in the `read' builtin that caused occasional spurious
failures when using `read -e'.
c. The version code needed to use the value of the cpp variable
CONF_MACHTYPE rather than MACHTYPE.
d. A new test was added to exercise the command printing and copying code.
e. A bug was fixed that caused `time' to be recognized as a reserved word
if it was the first pattern in a `case' statement pattern list.
------------------------------------------------------------------------------
This document details the changes between this version, bash-2.03-beta2,
and the previous version, bash-2.03-beta1.
1. Changes to Bash
a. Slight additions to support/shobj-conf, mostly for the benefit of AIX 4.2.
b. config.{guess,sub} support added for the NEC SX4.
c. Changed some of the cross-compiling sections of the configure macros in
aclocal.m4 so that configure won't abort.
d. Slight changes to how the HTML versions of the bash and readline manuals
are generated.
e. Fixed conditional command printing to avoid interpreting printf `%'-escapes
in arguments to [[.
f. Don't include the bash malloc on all variants of the alpha processor.
g. Changes to configure to make --enable-profiling work on Solaris 2.x.
h. Fixed a bug that manifested itself when shell functions were called
between calls to `getopts'.
i. Fixed pattern substitution so that a bare `#'as a pattern causes the
replacement string to be prefixed to the search string, and a bare
`%' causes the replacement string to be appended to the search string.
j. Fixed a bug in the command execution code that caused child processes
to occasionally have the wrong value for $!.
2. Changes to Readline
a. Added code to the history library to catch history substitutions using
`&' without a previous history substitution or search having been
performed.
3. New Features in Bash
4. New Features in Readline
a. New bindable variable: `isearch-terminators'.
b. New bindable function: `forward-backward-delete-char' (unbound by default).
------------------------------------------------------------------------------
This document details the changes between this version, bash-2.03-beta1,
and the previous version, bash-2.03-alpha.
1. Changes to Bash
a. A change was made to the help text for `{...}' to make it clear that a
semicolon is required before the closing brace.
b. A fix was made to the `test' builtin so that syntax errors cause test
to return an exit status > 1.
c. Globbing is no longer performed on assignment statements that appear as
arguments to `assignment builtins' such as `export'.
d. System-specific configuration changes were made for: Rhapsody,
AIX 4.2/gcc, BSD/OS 4.0.
e. New loadable builtins: ln, unlink.
f. Some fixes were made to the globbing code to handle extended glob patterns
which immediately follow a `*'.
g. A fix was made to the command printing code to ensure that redirections
following compound commands have a space separating them from the rest
of the command.
h. The pathname canonicalization code was changed to produce fewer leading
`//' sequences, since those are interpreted as network file system
pathnames on some systems.
i. A fix was made so that loops containing `eval' commands in commands passed
to `bash -c' would not exit prematurely.
j. Some changes were made to the job reaping code when the shell is not
interactive, so the shell will retain exit statuses longer for examination
by `wait'.
k. A fix was made so that `jobs | command' works again.
l. The erroneous compound array assignment var=((...)) is now a syntax error.
m. A change was made to the dynamic loading code in `enable' to support
Tenon's MachTen.
n. A fix was made to the globbing code so that extended globbing patterns
will correctly match `.' in a bracket expression.
2. Changes to Readline
a. A fix was made to the completion code in which a typo caused the wrong
value to be passed to the function that computed the longest common
prefix of the list of matches.
b. The completion code now checks the value of rl_filename_completion_desired,
which is set by application-supplied completion functions to indicate
that filename completion is being performed, to decide whether or not to
call an application-supplied `ignore completions' function.
3. New Features in Bash
a. A change was made to the startup file code so that any shell begun with
the `--login' option, even non-interactive shells, will source the login
shell startup files.
4. New Features in Readline
a. A new variable, rl_erase_empty_line, which, if set by an application using
readline, will cause readline to erase, prompt and all, lines on which the
only thing typed was a newline.
------------------------------------------------------------------------------
This document details the changes between this version, bash-2.03-alpha,
and the previous version, bash-2.02.1-release.
1. Changes to Bash
a. System-specific configuration changes were made for: Irix 6.x, Unixware 7.
b. The texi2dvi and texi2html scripts were updated to the latest versions
from the net.
c. The configure tests that determine which native type is 32 bits were
changed to not require a compiled program.
d. Fixed a bug in shell_execve that could cause memory to be freed twice
after a failed exec.
e. The `printf' test uses `diff -a' if it's available to prevent confusion
due to the non-ascii output.
f. Shared object configuration is now performed by a shell script,
support/shobj-conf, which generates values to be substituted into
makefiles by configure.
g. Some changes were made to `ulimit' to avoid the use of RLIM_INVALID as a
return value.
h. Changes were made to `ulimit' to work around HPUX 9.x's peculiar
handling of RLIMIT_FILESIZE.
i. Some new loadable builtins were added: id, printenv, sync, whoami, push,
mkdir. `pushd', `popd', and `dirs' can now be built as regular or
loadable builtins from the same source file.
j. Changes were made to `printf' to handle NUL bytes in the expanded format
string.
k. The various `make clean' Makefile targets now descend into lib/sh.
l. The `type' builtin was changed to use the internal `getopt' so that things
like `type -ap' work as expected.
m. There is a new configuration option, --with-installed-readline, to link
bash with a locally-installed version of readline. Only readline version
4.0 and later releases can support this. Shared and static libraries
are supported. The installed include files are used.
n. There is a new autoconf macro used to find which basic type is 64 bits.
o. Dynamic linking and loadable builtins should now work on SCO 3.2v5*,
AIX 4.2 with gcc, Unixware 7, and many other systems using gcc, where
the `-shared' options works correctly.
p. A bug was fixed in the bash filename completion code that caused memory to
be freed twice if a directory name containing an unset variable was
completed and the -u option was set.
q. The prompt expansion code now quotes the `$' in the `\$' expansion so it
is not processed by subsequent parameter expansion.
r. Fixed a parsing bug that caused a single or double quote after a `$$' to
trigger ANSI C expansion or locale translation.
s. Fixed a bug in the globbing code that caused quoted filenames containing
no globbing characters to sometimes be incorrectly expanded.
t. Changes to the default prompt strings if prompt string decoding is not
compiled into the shell.
u. Added `do', `then', `else', `{', and `(' to the list of keywords that may
precede the `time' reserved word.
v. The shell may now be cross-built for BeOS as well as cygwin32.
w. The conditional command execution code now treats `=' the same as `=='
for deciding when to perform pattern matching.
x. The `-e' option no longer causes the shell to exit if a command exits
with a non-zero status while running the startup files.
y. The `printf' builtin no longer dumps core if a modifier is supplied in
the format string without a conversion character (e.g. `%h').
z. Array assignments of the form a=(...) no longer show up in the history
list.
aa. The parser was fixed to obey the POSIX.2 rules for finding the closing
`}' in a ${...} expression.
bb. The history file is now opened with mode 0600 rather than 0666, so bash
no longer relies on the user's umask being set appropriately.
cc. Setting LANG no longer causes LC_ALL to be assigned a value; bash now
relies on proper behavior from the C library.
dd. Minor changes were made to allow quoted variable expansions using
${...} to be completed correctly if there is no closing `"'.
ee. Changes were made to builtins/Makefile.in so that configuring the shell
with `--enable-profiling' works right and builtins/mkbuiltins is
generated.
2. Changes to Readline
a. The version number is now 4.0.
b. There is no longer any #ifdef SHELL code in the source files.
c. Some changes were made to the key binding code to fix memory leaks and
better support Win32 systems.
d. Fixed a silly typo in the paren matching code -- it's microseconds, not
milliseconds.
e. The readline library should be compilable by C++ compilers.
f. The readline.h public header file now includes function prototypes for
all readline functions, and some changes were made to fix errors in the
source files uncovered by the use of prototypes.
g. The maximum numeric argument is now clamped at 1000000.
h. Fixes to rl_yank_last_arg to make it behave better.
i. Fixed a bug in the display code that caused core dumps if the prompt
string length exceeded 1024 characters.
j. The menu completion code was fixed to properly insert a single completion
if there is only one match.
k. A bug was fixed that caused the display code to improperly display tabs
after newlines.
3. New Features in Bash
a. New `shopt' option, `restricted_shell', indicating whether or not the
shell was started in restricted mode, for use in startup files.
b. Filename generation is now performed on the words between ( and ) in
array assignments (which it probably should have done all along).
c. OLDPWD is now auto-exported, as POSIX.2 seems to require.
d. ENV and BASH_ENV are read-only variables in a restricted shell.
4. New Features in Readline
a. Many changes to the signal handling:
o Readline now catches SIGQUIT and cleans up the tty before returning;
o A new variable, rl_catch_signals, is available to application writers
to indicate to readline whether or not it should install its own
signal handlers for SIGINT, SIGTERM, SIGQUIT, SIGALRM, SIGTSTP,
SIGTTIN, and SIGTTOU;
o A new variable, rl_catch_sigwinch, is available to application
writers to indicate to readline whether or not it should install its
own signal handler for SIGWINCH, which will chain to the calling
applications's SIGWINCH handler, if one is installed;
o There is a new function, rl_free_line_state, for application signal
handlers to call to free up the state associated with the current
line after receiving a signal;
o There is a new function, rl_cleanup_after_signal, to clean up the
display and terminal state after receiving a signal;
o There is a new function, rl_reset_after_signal, to reinitialize the
terminal and display state after an application signal handler
returns and readline continues
b. There is a new function, rl_resize_terminal, to reset readline's idea of
the screen size after a SIGWINCH.
c. New public functions: rl_save_prompt and rl_restore_prompt. These were
previously private functions with a `_' prefix.
d. New function hook: rl_pre_input_hook, called just before readline starts
reading input, after initialization.
e. New function hook: rl_display_matches_hook, called when readline would
display the list of completion matches. The new function
rl_display_match_list is what readline uses internally, and is available
for use by application functions called via this hook.
f. New bindable function, delete-char-or-list, like tcsh.
------------------------------------------------------------------------------
This document details the changes between this version, bash-2.02.1-release, This document details the changes between this version, bash-2.02.1-release,
and the previous version, bash-2.02-release. and the previous version, bash-2.02-release.
@ -795,7 +1114,7 @@ x. A fix was made to the command timing code so that `time' can be used in
a loop. a loop.
y. A fix was made to the parser so that `((cmd); cmd2)' is now parsed as y. A fix was made to the parser so that `((cmd); cmd2)' is now parsed as
a nested subshell rather than strictly as an (errnoeous) arithmetic a nested subshell rather than strictly as an (erroneous) arithmetic
command. command.
z. A fix was made to the globbing code so that it correctly matches quoted z. A fix was made to the globbing code so that it correctly matches quoted

21
COMPAT
View file

@ -1,7 +1,7 @@
This document details the incompatibilites between this version of bash, This document details the incompatibilites between this version of bash,
bash-2.01, and the previous widely-available version, bash-1.14. These bash-2.03, and the previous widely-available version, bash-1.14 (which
were discovered by alpha and beta testers, so they will likely be is still the `standard' version for many Linux distributions). These
encountered by a significant number of users. were discovered by users of bash-2.x, so this list is not comprehensive.
1. Bash now uses a new quoting syntax, $"...", to do locale-specific 1. Bash now uses a new quoting syntax, $"...", to do locale-specific
string translation. Users who have relied on the (undocumented) string translation. Users who have relied on the (undocumented)
@ -63,9 +63,11 @@ encountered by a significant number of users.
"\C-\\": self-insert "\C-\\": self-insert
6. A number of people complained above having to use ESC to terminate an 6. A number of people complained above having to use ESC to terminate an
incremental search, and asked for an alternate mechanism. Bash-2.0 incremental search, and asked for an alternate mechanism. Bash-2.03
allows ^J to terminate the search without accepting the line. Use uses the value of the settable readline variable `isearch-terminators'
^M to terminate the search and accept the line, as in bash-1.14. to decide which characters should terminate an incremental search. If
that variable has not been set, ESC and Control-J will terminate a
search.
7. Some variables have been removed: MAIL_WARNING, notify, history_control, 7. Some variables have been removed: MAIL_WARNING, notify, history_control,
command_oriented_history, glob_dot_filenames, allow_null_glob_expansion, command_oriented_history, glob_dot_filenames, allow_null_glob_expansion,
@ -115,3 +117,10 @@ encountered by a significant number of users.
An interactive shell started in posix mode reads and executes commands An interactive shell started in posix mode reads and executes commands
from the file named by $ENV. from the file named by $ENV.
11. The <> redirection operator was changed to conform to the POSIX.2 spec.
In the absence of any file descriptor specification preceding the `<>',
file descriptor 0 is used. In bash-1.14, this was the behavior only
when in POSIX mode. The bash-1.14 behavior may be obtained with
<>filename 1>&0

View file

@ -24,8 +24,8 @@ The following list is what's changed when `POSIX mode' is in effect:
performed on the values of `PS1' and `PS2' regardless of the performed on the values of `PS1' and `PS2' regardless of the
setting of the `promptvars' option. setting of the `promptvars' option.
6. Interactive comments are enabled by default. (Note that Bash has 6. Interactive comments are enabled by default. (Bash has them on by
them on by default anyway.) default anyway.)
7. The POSIX.2 startup files are executed (`$ENV') rather than the 7. The POSIX.2 startup files are executed (`$ENV') rather than the
normal Bash files. normal Bash files.

View file

@ -14,4 +14,7 @@ modification.
sh-redir-hack - diff to parse.y to get redirections before sh-redir-hack - diff to parse.y to get redirections before
compound commands compound commands
empty-for-wordlist - diff to parse.y to allow an empty wordlist after
the `in' keyword in a `for' statement
mh-folder-comp - diffs that reportedly add MH folder completion mh-folder-comp - diffs that reportedly add MH folder completion

File diff suppressed because it is too large Load diff

25
CWRU/empty-for-wordlist Normal file
View file

@ -0,0 +1,25 @@
This patch is from Brian Fox, in reply to an email message from
"Marcin 'Qrczak' Kowalczyk" <qrczak@knm.org.pl>, who wrote:
I think that bash should accept such a syntax:
for var in ; do command; done
Of course it should do nothing. It would simplify some scripts.
Here is a patch for those who wish it:
*** parse.y.~1~ Wed Mar 4 09:39:46 1998
--- parse.y Mon Jul 13 14:40:23 1998
***************
*** 495,500 ****
--- 495,504 ----
{ $$ = make_for_command ($2, REVERSE_LIST ($5, WORD_LIST *), $9); }
| FOR WORD newline_list IN word_list list_terminator newline_list '{' compound_list '}'
{ $$ = make_for_command ($2, REVERSE_LIST ($5, WORD_LIST *), $9); }
+ | FOR WORD newline_list IN list_terminator newline_list DO compound_list DONE
+ { $$ = make_for_command ($2, (WORD_LIST *)NULL, $8); }
+ | FOR WORD newline_list IN list_terminator newline_list '{' compound_list '}'
+ { $$ = make_for_command ($2, (WORD_LIST *)NULL, $8); }
;

39
CWRU/misc/errlist.c Normal file
View file

@ -0,0 +1,39 @@
/*
* If necessary, link with lib/sh/libsh.a
*/
#include <stdio.h>
#include <errno.h>
extern char *strerror();
extern int sys_nerr;
int
main(c, v)
int c;
char **v;
{
int i, n;
if (c == 1) {
for (i = 1; i < sys_nerr; i++)
printf("%d --> %s\n", i, strerror(i));
} else {
for (i = 1; i < c; i++) {
n = atoi(v[i]);
printf("%d --> %s\n", n, strerror(n));
}
}
exit (0);
}
programming_error(a, b)
char *a;
int b;
{
}
fatal_error()
{
}

45
CWRU/misc/hpux10-dlfcn.h Normal file
View file

@ -0,0 +1,45 @@
/*
* HPUX 10.x stubs to implement dl* in terms of shl*
*
* Not needed for later versions; HPUX 11.x has dlopen() and friends.
*
* configure also needs to be faked out. You can create a dummy libdl.a
* with stub entries for dlopen, dlclose, dlsym, and dlerror:
*
* int dlopen() { return(0);}
* int dlclose() { return(0);}
* int dlsym() { return(0);}
* int dlerror() { return(0);}
*
* This has not been tested; I just read the manual page and coded this up.
*
* According to the ld manual page, you need to link bash with -dld and add
* the -E flag to LOCAL_LDFLAGS.
*/
#if !defined (__HPUX10_DLFCN_H__)
#define __HPUX10_DLFCN_H__
#include <dl.h>
#include <errno.h>
#ifndef errno
extern int errno;
#endif
#define RTLD_LAZY BIND_DEFERRED
#define RTLD_NOW BIND_IMMEDIATE
#define RTLD_GLOBAL DYNAMIC_PATH
char *bash_global_sym_addr;
#define dlopen(file,mode) (void *)shl_load((file), (mode), 0L)
#define dlclose(handle) shl_unload((shl_t)(handle))
#define dlsym(handle,name) (bash_global_sym_addr=0,shl_findsym((shl_t *)&(handle),name,TYPE_UNDEFINED,&bash_global_sym_addr), (void *)bash_global_sym_addr)
#define dlerror() strerror(errno)
#endif /* __HPUX10_DLFCN_H__ */

69
INSTALL
View file

@ -16,10 +16,10 @@ compiler output (useful mainly for debugging `configure'). If at some
point `config.cache' contains results you don't want to keep, you may point `config.cache' contains results you don't want to keep, you may
remove or edit it. remove or edit it.
If you need to do unusual things to compile the package, please try to If you need to do unusual things to compile Bash, please try to figure
figure out how `configure' could check whether or not to do them, and out how `configure' could check whether or not to do them, and mail
mail diffs or instructions to `bash-maintainers@prep.ai.mit.edu' so diffs or instructions to <bash-maintainers@gnu.org> so they can be
they can be considered for the next release. considered for the next release.
The file `configure.in' is used to create `configure' by a program The file `configure.in' is used to create `configure' by a program
called Autoconf. You only need `configure.in' if you want to change it called Autoconf. You only need `configure.in' if you want to change it
@ -29,8 +29,8 @@ this, make sure you are using Autoconf version 2.10 or newer.
If you need to change `configure.in' or regenerate `configure', you If you need to change `configure.in' or regenerate `configure', you
will need to create two files: `_distribution' and `_patchlevel'. will need to create two files: `_distribution' and `_patchlevel'.
`_distribution' should contain the major and minor version numbers of `_distribution' should contain the major and minor version numbers of
the Bash distribution, for example `2.02'. `_patchlevel' should the Bash distribution, for example `2.01'. `_patchlevel' should
contain the patch level of the Bash distribution, `1' for example. The contain the patch level of the Bash distribution, `0' for example. The
script `support/mkconffiles' has been provided to automate the creation script `support/mkconffiles' has been provided to automate the creation
of these files. of these files.
@ -115,17 +115,17 @@ than `/usr/local' by giving `configure' the option `--prefix=PATH'.
You can specify separate installation prefixes for You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you architecture-specific files and architecture-independent files. If you
give `configure' the option `--exec-prefix=PATH', the package will use give `configure' the option `--exec-prefix=PATH', `make install' will
`PATH' as the prefix for installing programs and libraries. use `PATH' as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix. Documentation and other data files will still use the regular prefix.
Specifying the System Type Specifying the System Type
========================== ==========================
There may be some features `configure' can not figure out There may be some features `configure' can not figure out
automatically, but needs to determine by the type of host the package automatically, but needs to determine by the type of host Bash will run
will run on. Usually `configure' can figure that out, but if it prints on. Usually `configure' can figure that out, but if it prints a
a message saying it can not guess the host type, give it the message saying it can not guess the host type, give it the
`--host=TYPE' option. `TYPE' can either be a short name for the system `--host=TYPE' option. `TYPE' can either be a short name for the system
type, such as `sun4', or a canonical name with three fields: type, such as `sun4', or a canonical name with three fields:
`CPU-COMPANY-SYSTEM' (e.g., `sparc-sun-sunos4.1.2'). `CPU-COMPANY-SYSTEM' (e.g., `sparc-sun-sunos4.1.2').
@ -177,12 +177,11 @@ Optional Features
================= =================
The Bash `configure' has a number of `--enable-FEATURE' options, where The Bash `configure' has a number of `--enable-FEATURE' options, where
FEATURE indicates an optional part of the package. There are also FEATURE indicates an optional part of Bash. There are also several
several `--with-PACKAGE' options, where PACKAGE is something like `--with-PACKAGE' options, where PACKAGE is something like `gnu-malloc'
`gnu-malloc' or `purify' (for the Purify memory allocation checker). To or `purify'. To turn off the default use of a package, use
turn off the default use of a package, use `--without-PACKAGE'. To `--without-PACKAGE'. To configure Bash without a feature that is
configure Bash without a feature that is enabled by default, use enabled by default, use `--disable-FEATURE'.
`--disable-FEATURE'.
Here is a complete list of the `--enable-' and `--with-' options that Here is a complete list of the `--enable-' and `--with-' options that
the Bash `configure' recognizes. the Bash `configure' recognizes.
@ -212,6 +211,11 @@ the Bash `configure' recognizes.
for which this should be turned off, and `configure' disables this for which this should be turned off, and `configure' disables this
option automatically for a number of systems. option automatically for a number of systems.
`--with-installed-readline'
Define this to make bash link with a locally-installed version of
Readline rather than the version in lib/readline. This works only
with readline 4.0 and later versions.
`--with-purify' `--with-purify'
Define this to use the Purify memory allocation checker from Pure Define this to use the Purify memory allocation checker from Pure
Software. Software.
@ -241,16 +245,19 @@ does not provide the necessary support.
`--enable-alias' `--enable-alias'
Allow alias expansion and include the `alias' and `unalias' Allow alias expansion and include the `alias' and `unalias'
builtins. builtins (*note Aliases::.).
`--enable-array-variables' `--enable-array-variables'
Include support for one-dimensional array shell variables. Include support for one-dimensional array shell variables (*note
Arrays::.).
`--enable-bang-history' `--enable-bang-history'
Include support for `csh'-like history substitution. Include support for `csh'-like history substitution (*note History
Interaction::.).
`--enable-brace-expansion' `--enable-brace-expansion'
Include `csh'-like brace expansion ( `b{a,b}c' ==> `bac bbc' ). Include `csh'-like brace expansion ( `b{a,b}c' ==> `bac bbc' ).
See *Note Brace Expansion::, for a complete description.
`--enable-command-timing' `--enable-command-timing'
Include support for recognizing `time' as a reserved word and for Include support for recognizing `time' as a reserved word and for
@ -259,11 +266,12 @@ does not provide the necessary support.
be timed. be timed.
`--enable-cond-command' `--enable-cond-command'
Include support for the `[[' conditional command. Include support for the `[[' conditional command (*note
Conditional Constructs::.).
`--enable-directory-stack' `--enable-directory-stack'
Include support for a `csh'-like directory stack and the `pushd', Include support for a `csh'-like directory stack and the `pushd',
`popd', and `dirs' builtins. `popd', and `dirs' builtins (*note The Directory Stack::.).
`--enable-disabled-builtins' `--enable-disabled-builtins'
Allow builtin commands to be invoked via `builtin xxx' even after Allow builtin commands to be invoked via `builtin xxx' even after
@ -272,7 +280,8 @@ does not provide the necessary support.
commands. commands.
`--enable-dparen-arithmetic' `--enable-dparen-arithmetic'
Include support for the `ksh' `((...))' command. Include support for the `((...))' command (*note Conditional
Constructs::.).
`--enable-extended-glob' `--enable-extended-glob'
Include support for the extended pattern matching features Include support for the extended pattern matching features
@ -287,20 +296,22 @@ does not provide the necessary support.
commands. commands.
`--enable-job-control' `--enable-job-control'
This enables job control features, if the OS supports them. This enables the job control features (*note Job Control::.), if
the operating system supports them.
`--enable-process-substitution' `--enable-process-substitution'
This enables process substitution (*note Process Substitution::.) This enables process substitution (*note Process Substitution::.)
if the OS provides the necessary support. if the operating system provides the necessary support.
`--enable-prompt-string-decoding' `--enable-prompt-string-decoding'
Turn on the interpretation of a number of backslash-escaped Turn on the interpretation of a number of backslash-escaped
characters in the `$PS1', `$PS2', `$PS3', and `$PS4' prompt characters in the `$PS1', `$PS2', `$PS3', and `$PS4' prompt
strings. strings. See *Note Printing a Prompt::, for a complete list of
prompt string escape sequences.
`--enable-readline' `--enable-readline'
Include support for command-line editing and history with the Bash Include support for command-line editing and history with the Bash
version of the Readline library. version of the Readline library (*note Command Line Editing::.).
`--enable-restricted' `--enable-restricted'
Include support for a "restricted shell". If this is enabled, Include support for a "restricted shell". If this is enabled,
@ -308,8 +319,8 @@ does not provide the necessary support.
The Restricted Shell::, for a description of restricted mode. The Restricted Shell::, for a description of restricted mode.
`--enable-select' `--enable-select'
Include the `ksh' `select' builtin, which allows the generation of Include the `select' builtin, which allows the generation of simple
simple menus. menus (*note Conditional Constructs::.).
`--enable-usg-echo-default' `--enable-usg-echo-default'
Make the `echo' builtin expand backslash-escaped characters by Make the `echo' builtin expand backslash-escaped characters by

View file

@ -43,11 +43,12 @@ NEWS f
NOTES f NOTES f
README f README f
AUTHORS f AUTHORS f
Y2K f
configure.in f configure.in f
configure f configure f
Makefile.in f Makefile.in f
config.h.top f config-top.h f
config.h.bot f config-bot.h f
config.h.in f config.h.in f
aclocal.m4 f aclocal.m4 f
array.c f array.c f
@ -195,6 +196,9 @@ builtins/common.h f
builtins/bashgetopt.h f builtins/bashgetopt.h f
cross-build/cygwin32.cache f cross-build/cygwin32.cache f
cross-build/win32sig.h f cross-build/win32sig.h f
cross-build/x86-beos.cache f
cross-build/beos-sig.h f
cross-build/opennt.cache f
lib/glob/ChangeLog f lib/glob/ChangeLog f
lib/glob/Makefile.in f lib/glob/Makefile.in f
lib/glob/fnmatch.c f lib/glob/fnmatch.c f
@ -256,6 +260,7 @@ lib/readline/input.c f
lib/readline/callback.c f lib/readline/callback.c f
lib/readline/nls.c f lib/readline/nls.c f
lib/readline/shell.c f lib/readline/shell.c f
lib/readline/savestring.c f
lib/readline/tilde.c f lib/readline/tilde.c f
lib/readline/tilde.h f lib/readline/tilde.h f
lib/readline/rldefs.h f lib/readline/rldefs.h f
@ -272,7 +277,9 @@ lib/readline/posixdir.h f
lib/readline/posixjmp.h f lib/readline/posixjmp.h f
lib/readline/posixstat.h f lib/readline/posixstat.h f
lib/readline/ansi_stdlib.h f lib/readline/ansi_stdlib.h f
lib/readline/rlstdc.h f
lib/readline/doc/Makefile f lib/readline/doc/Makefile f
lib/readline/doc/manvers.texinfo f
lib/readline/doc/rlman.texinfo f lib/readline/doc/rlman.texinfo f
lib/readline/doc/rltech.texinfo f lib/readline/doc/rltech.texinfo f
lib/readline/doc/rluser.texinfo f lib/readline/doc/rluser.texinfo f
@ -292,6 +299,7 @@ lib/sh/getcwd.c f
lib/sh/getenv.c f lib/sh/getenv.c f
lib/sh/itos.c f lib/sh/itos.c f
lib/sh/oslib.c f lib/sh/oslib.c f
lib/sh/rename.c f
lib/sh/setlinebuf.c f lib/sh/setlinebuf.c f
lib/sh/strcasecmp.c f lib/sh/strcasecmp.c f
lib/sh/strerror.c f lib/sh/strerror.c f
@ -319,22 +327,27 @@ lib/termcap/grot/configure f
lib/termcap/grot/configure.in f lib/termcap/grot/configure.in f
lib/termcap/grot/COPYING f lib/termcap/grot/COPYING f
lib/termcap/grot/README f lib/termcap/grot/README f
lib/tilde/README f
lib/tilde/ChangeLog f lib/tilde/ChangeLog f
lib/tilde/Makefile.in f lib/tilde/Makefile.in f
lib/tilde/doc/tilde.texi f lib/tilde/doc/tilde.texi f
lib/tilde/doc/Makefile f lib/tilde/doc/Makefile f
lib/tilde/tilde.c f lib/tilde/tilde.c f
lib/tilde/tilde.h f lib/tilde/tilde.h f
lib/tilde/shell.c f
CWRU/misc/open-files.c f CWRU/misc/open-files.c f
CWRU/misc/sigs.c f CWRU/misc/sigs.c f
CWRU/misc/pid.c f CWRU/misc/pid.c f
CWRU/misc/sigstat.c f CWRU/misc/sigstat.c f
CWRU/misc/bison f CWRU/misc/bison f
CWRU/misc/errlist.c f
CWRU/misc/hpux10-dlfcn.h f
CWRU/PLATFORMS f CWRU/PLATFORMS f
CWRU/README f CWRU/README f
CWRU/POSIX.NOTES f CWRU/POSIX.NOTES f
CWRU/changelog f CWRU/changelog f
CWRU/sh-redir-hack f CWRU/sh-redir-hack f
CWRU/empty-for-wordlist f
CWRU/mh-folder-comp f CWRU/mh-folder-comp f
doc/FAQ f doc/FAQ f
doc/Makefile.in f doc/Makefile.in f
@ -355,6 +368,7 @@ support/config.sub f
support/printenv.sh f 755 support/printenv.sh f 755
support/printenv.c f support/printenv.c f
support/bash.xbm f support/bash.xbm f
support/missing f 755
support/mkclone f 755 support/mkclone f 755
support/mkconffiles f 755 support/mkconffiles f 755
support/mkdirs f 755 support/mkdirs f 755
@ -368,14 +382,17 @@ support/SYMLINKS f
support/fixlinks f 755 support/fixlinks f 755
support/install.sh f 755 support/install.sh f 755
support/texi2dvi f support/texi2dvi f
support/texi2html f support/texi2html f 755
support/xenix-link.sh f 755 support/xenix-link.sh f 755
support/shobj-conf f 755
support/rlvers.sh f 755
examples/bashdb/PERMISSION f examples/bashdb/PERMISSION f
examples/bashdb/README f examples/bashdb/README f
examples/bashdb/bashdb f examples/bashdb/bashdb f
examples/bashdb/bashdb.fns f examples/bashdb/bashdb.fns f
examples/bashdb/bashdb.pre f examples/bashdb/bashdb.pre f
examples/loadables/README f examples/loadables/README f
examples/loadables/template.c f
examples/loadables/Makefile.in f examples/loadables/Makefile.in f
examples/loadables/necho.c f examples/loadables/necho.c f
examples/loadables/hello.c f examples/loadables/hello.c f
@ -384,7 +401,6 @@ examples/loadables/sprintf.c f
examples/loadables/sleep.c f examples/loadables/sleep.c f
examples/loadables/truefalse.c f examples/loadables/truefalse.c f
examples/loadables/getconf.c f examples/loadables/getconf.c f
examples/loadables/pushd.c f
examples/loadables/finfo.c f examples/loadables/finfo.c f
examples/loadables/cat.c f examples/loadables/cat.c f
examples/loadables/logname.c f examples/loadables/logname.c f
@ -395,8 +411,17 @@ examples/loadables/pathchk.c f
examples/loadables/tee.c f examples/loadables/tee.c f
examples/loadables/rmdir.c f examples/loadables/rmdir.c f
examples/loadables/head.c f examples/loadables/head.c f
examples/loadables/printenv.c f
examples/loadables/id.c f
examples/loadables/whoami.c f
examples/loadables/uname.c f
examples/loadables/sync.c f
examples/loadables/mkdir.c f
examples/loadables/ln.c f
examples/loadables/unlink.c f
examples/functions/autoload f examples/functions/autoload f
examples/functions/autoload.v2 f examples/functions/autoload.v2 f
examples/functions/autoload.v3 f
examples/functions/basename f examples/functions/basename f
examples/functions/basename2 f examples/functions/basename2 f
examples/functions/csh-compat f examples/functions/csh-compat f
@ -423,7 +448,9 @@ examples/functions/mhfold f
examples/functions/notify.bash f examples/functions/notify.bash f
examples/functions/pathfuncs f examples/functions/pathfuncs f
examples/functions/repeat2 f examples/functions/repeat2 f
examples/functions/repeat3 f
examples/functions/seq f examples/functions/seq f
examples/functions/seq2 f
examples/functions/shcat f examples/functions/shcat f
examples/functions/shcat2 f examples/functions/shcat2 f
examples/functions/substr f examples/functions/substr f
@ -431,6 +458,7 @@ examples/functions/substr2 f
examples/functions/term f examples/functions/term f
examples/functions/whatis f examples/functions/whatis f
examples/functions/whence f examples/functions/whence f
examples/functions/which f
examples/functions/xalias.bash f examples/functions/xalias.bash f
examples/scripts/adventure.sh f examples/scripts/adventure.sh f
examples/scripts/bcsh.sh f examples/scripts/bcsh.sh f
@ -479,6 +507,8 @@ tests/source4.sub f
tests/source5.sub f tests/source5.sub f
tests/cond.tests f tests/cond.tests f
tests/cond.right f tests/cond.right f
tests/cprint.tests f
tests/cprint.right f
tests/dollar-at-star f tests/dollar-at-star f
tests/dollar.right f tests/dollar.right f
tests/dstack.tests f tests/dstack.tests f
@ -573,6 +603,7 @@ tests/run-array2 f
tests/run-braces f tests/run-braces f
tests/run-builtins f tests/run-builtins f
tests/run-cond f tests/run-cond f
tests/run-cprint f
tests/run-dirstack f tests/run-dirstack f
tests/run-dollars f tests/run-dollars f
tests/run-errors f tests/run-errors f

View file

@ -1,4 +1,4 @@
# Makefile for bash-2.02, version 2.84 # Makefile for bash-2.03, version 2.103
# #
# Make sure the first target in the makefile is the right one # Make sure the first target in the makefile is the right one
all: .made all: .made
@ -29,15 +29,17 @@ VPATH = .:@srcdir@
CC = @CC@ CC = @CC@
CC_FOR_BUILD = @CC_FOR_BUILD@ CC_FOR_BUILD = @CC_FOR_BUILD@
YACC = @YACC@ YACC = @YACC@
SHELL=/bin/sh SHELL = @MAKE_SHELL@
CP = cp CP = cp
RM = rm -f RM = rm -f
AR = @AR@ AR = @AR@
ARFLAGS = @ARFLAGS@
RANLIB = @RANLIB@ RANLIB = @RANLIB@
INSTALL = @INSTALL@ INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@ INSTALL_DATA = @INSTALL_DATA@
INSTALLMODE= -m 0755
COMPRESS = gzip COMPRESS = gzip
COMPRESS_EXT = .gz COMPRESS_EXT = .gz
@ -63,6 +65,7 @@ RELSTATUS = release
Machine = @host_cpu@ Machine = @host_cpu@
OS = @host_os@ OS = @host_os@
VENDOR = @host_vendor@
MACHTYPE = @host@ MACHTYPE = @host@
THIS_SH = $(BUILD_DIR)/$(Program) THIS_SH = $(BUILD_DIR)/$(Program)
@ -80,20 +83,21 @@ LOCAL_CFLAGS = @LOCAL_CFLAGS@
DEFS = @DEFS@ DEFS = @DEFS@
LOCAL_DEFS = @LOCAL_DEFS@ LOCAL_DEFS = @LOCAL_DEFS@
LOCAL_LIBS = @LOCAL_LIBS@ LOCAL_LIBS = @LOCAL_LIBS@
LIBS = $(BUILTINS_LIB) $(LIBRARIES) $(LOCAL_LIBS) @LIBS@ LIBS = $(BUILTINS_LIB) $(LIBRARIES) @LIBS@
LDFLAGS = @LDFLAGS@ $(LOCAL_LDFLAGS) $(PROFILE_FLAGS) $(CFLAGS) LDFLAGS = @LDFLAGS@ $(STATIC_LD) $(LOCAL_LDFLAGS) $(PROFILE_FLAGS) $(CFLAGS)
STATIC_LD = @STATIC_LD@
LOCAL_LDFLAGS = @LOCAL_LDFLAGS@ LOCAL_LDFLAGS = @LOCAL_LDFLAGS@
SYSTEM_FLAGS = -DPROGRAM='"$(Program)"' -DHOSTTYPE='"$(Machine)"' -DOSTYPE='"$(OS)"' -DMACHTYPE='"$(MACHTYPE)"' SYSTEM_FLAGS = -DPROGRAM='"$(Program)"' -DCONF_HOSTTYPE='"$(Machine)"' -DCONF_OSTYPE='"$(OS)"' -DCONF_MACHTYPE='"$(MACHTYPE)"' -DCONF_VENDOR='"$(VENDOR)"'
CCFLAGS = $(PROFILE_FLAGS) $(SYSTEM_FLAGS) $(LOCAL_DEFS) \ CCFLAGS = $(PROFILE_FLAGS) $(SYSTEM_FLAGS) $(LOCAL_DEFS) \
$(DEFS) $(LOCAL_CFLAGS) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) $(DEFS) $(LOCAL_CFLAGS) $(CPPFLAGS) $(INCLUDES) $(CFLAGS)
INCLUDES = -I. -I$(srcdir) -I$(LIBSRC) INCLUDES = -I. @RL_INCLUDE@ -I$(srcdir) -I$(LIBSRC) -I$(includedir)
GCC_LINT_FLAGS = -ansi -Wall -Wshadow -Wpointer-arith -Wcast-qual \ GCC_LINT_FLAGS = -ansi -Wall -Wshadow -Wpointer-arith -Wcast-qual \
-Wwrite-strings -Werror -Wstrict-prototypes \ -Wwrite-strings -Werror -Wstrict-prototypes \
-Wmissing-prototypes -Wmissing-prototypes -Wno-implicit
GCC_LINT_CFLAGS = $(CCFLAGS) $(GCC_LINT_FLAGS) GCC_LINT_CFLAGS = $(CCFLAGS) $(GCC_LINT_FLAGS)
# #
@ -105,7 +109,7 @@ dot = .
LIBSUBDIR = lib LIBSUBDIR = lib
LIBSRC = $(srcdir)/$(LIBSUBDIR) LIBSRC = $(srcdir)/$(LIBSUBDIR)
SUBDIR_INCLUDES = -I. -I$(topdir) -I$(topdir)/$(LIBSUBDIR) -I$(includedir) SUBDIR_INCLUDES = -I. @RL_INCLUDE@ -I$(topdir) -I$(topdir)/$(LIBSUBDIR) -I$(includedir)
# the bash library # the bash library
# the library is a mix of functions that the C library does not provide on # the library is a mix of functions that the C library does not provide on
@ -120,7 +124,7 @@ SHLIB_SOURCE = ${SH_LIBSRC}/clktck.c ${SH_LIBSRC}/getcwd.c \
${SH_LIBSRC}/strcasecmp.c ${SH_LIBSRC}/strerror.c \ ${SH_LIBSRC}/strcasecmp.c ${SH_LIBSRC}/strerror.c \
${SH_LIBSRC}/strtod.c ${SH_LIBSRC}/strtol.c \ ${SH_LIBSRC}/strtod.c ${SH_LIBSRC}/strtol.c \
${SH_LIBSRC}/strtoul.c ${SH_LIBSRC}/vprint.c \ ${SH_LIBSRC}/strtoul.c ${SH_LIBSRC}/vprint.c \
${SH_LIBSRC}/itos.c ${SH_LIBSRC}/itos.c ${SH_LIBSRC}/rename.c
SHLIB_LIB = -lsh SHLIB_LIB = -lsh
SHLIB_LIBNAME = libsh.a SHLIB_LIBNAME = libsh.a
@ -131,7 +135,7 @@ SHLIB_DEP = ${SHLIB_LIBRARY}
# we assume for now that readline source is being shipped with bash # we assume for now that readline source is being shipped with bash
RL_LIBSRC = $(LIBSRC)/readline RL_LIBSRC = $(LIBSRC)/readline
RL_LIBDOC = $(RL_LIBSRC)/doc RL_LIBDOC = $(RL_LIBSRC)/doc
RL_LIBDIR = $(dot)/$(LIBSUBDIR)/readline RL_LIBDIR = @RL_LIBDIR@
RL_ABSSRC = ${topdir}/$(RL_LIBDIR) RL_ABSSRC = ${topdir}/$(RL_LIBDIR)
READLINE_LIB = @READLINE_LIB@ READLINE_LIB = @READLINE_LIB@
@ -145,6 +149,7 @@ READLINE_SOURCE = $(RL_LIBSRC)/rldefs.h $(RL_LIBSRC)/rlconf.h \
$(RL_LIBSRC)/chardefs.h $(RL_LIBSRC)/keymaps.h \ $(RL_LIBSRC)/chardefs.h $(RL_LIBSRC)/keymaps.h \
$(RL_LIBSRC)/history.h $(RL_LIBSRC)/histlib.h \ $(RL_LIBSRC)/history.h $(RL_LIBSRC)/histlib.h \
$(RL_LIBSRC)/posixstat.h $(RL_LIBSRC)/tilde.h \ $(RL_LIBSRC)/posixstat.h $(RL_LIBSRC)/tilde.h \
$(RL_LIBSRC)/rlstdc.h \
$(RL_LIBSRC)/funmap.c $(RL_LIBSRC)/emacs_keymap.c \ $(RL_LIBSRC)/funmap.c $(RL_LIBSRC)/emacs_keymap.c \
$(RL_LIBSRC)/search.c $(RL_LIBSRC)/vi_keymap.c \ $(RL_LIBSRC)/search.c $(RL_LIBSRC)/vi_keymap.c \
$(RL_LIBSRC)/keymaps.c $(RL_LIBSRC)/parens.c \ $(RL_LIBSRC)/keymaps.c $(RL_LIBSRC)/parens.c \
@ -157,7 +162,7 @@ READLINE_SOURCE = $(RL_LIBSRC)/rldefs.h $(RL_LIBSRC)/rlconf.h \
$(RL_LIBSRC)/undo.c $(RL_LIBSRC)/macro.c \ $(RL_LIBSRC)/undo.c $(RL_LIBSRC)/macro.c \
$(RL_LIBSRC)/terminal.c $(RL_LIBSRC)/nls.c \ $(RL_LIBSRC)/terminal.c $(RL_LIBSRC)/nls.c \
$(RL_LIBSRC)/input.c $(RL_LIBSRC)/xmalloc.c \ $(RL_LIBSRC)/input.c $(RL_LIBSRC)/xmalloc.c \
$(RL_LIBSRC)/shell.c \ $(RL_LIBSRC)/shell.c $(RL_LIBSRC)/savestring.c \
$(RL_LIBSRC)/histexpand.c $(RL_LIBSRC)/history.c \ $(RL_LIBSRC)/histexpand.c $(RL_LIBSRC)/history.c \
$(RL_LIBSRC)/histsearch.c $(RL_LIBSRC)/histfile.c $(RL_LIBSRC)/histsearch.c $(RL_LIBSRC)/histfile.c
@ -171,12 +176,12 @@ READLINE_OBJ = $(RL_LIBDIR)/readline.o $(RL_LIBDIR)/funmap.o \
$(RL_LIBDIR)/kill.o $(RL_LIBDIR)/undo.o $(RL_LIBDIR)/nls.o \ $(RL_LIBDIR)/kill.o $(RL_LIBDIR)/undo.o $(RL_LIBDIR)/nls.o \
$(RL_LIBDIR)/macro.o $(RL_LIBDIR)/input.o \ $(RL_LIBDIR)/macro.o $(RL_LIBDIR)/input.o \
$(RL_LIBDIR)/terminal.o $(RL_LIBDIR)/callback.o \ $(RL_LIBDIR)/terminal.o $(RL_LIBDIR)/callback.o \
$(RL_LIBDIR)/shell.o \ $(RL_LIBDIR)/shell.o $(RL_LIBDIR)/savestring.o \
$(RL_LIBDIR)/history.o $(RL_LIBDIR)/histexpand.o \ $(RL_LIBDIR)/history.o $(RL_LIBDIR)/histexpand.o \
$(RL_LIBDIR)/histsearch.o $(RL_LIBDIR)/histfile.o $(RL_LIBDIR)/histsearch.o $(RL_LIBDIR)/histfile.o
HIST_LIBSRC = $(LIBSRC)/readline HIST_LIBSRC = $(LIBSRC)/readline
HIST_LIBDIR = $(dot)/$(LIBSUBDIR)/readline HIST_LIBDIR = @HIST_LIBDIR@
HIST_ABSSRC = ${topdir}/$(HIST_LIBDIR) HIST_ABSSRC = ${topdir}/$(HIST_LIBDIR)
HISTORY_LIB = @HISTORY_LIB@ HISTORY_LIB = @HISTORY_LIB@
@ -265,11 +270,11 @@ BASHPOSIX_SUPPORT = $(BASHPOSIX_LIB)/posixstat.h $(BASHPOSIX_LIB)/ansi_stdlib.h
LIBRARIES = $(READLINE_LIB) $(HISTORY_LIB) $(TERMCAP_LIB) $(GLOB_LIB) \ LIBRARIES = $(READLINE_LIB) $(HISTORY_LIB) $(TERMCAP_LIB) $(GLOB_LIB) \
$(TILDE_LIB) $(MALLOC_LIB) $(SHLIB_LIB) $(LOCAL_LIBS) $(TILDE_LIB) $(MALLOC_LIB) $(SHLIB_LIB) $(LOCAL_LIBS)
LIBDEP = $(READLINE_DEP) $(TERMCAP_DEP) $(GLOB_DEP) $(HISTORY_DEP) \ LIBDEP = $(READLINE_DEP) $(HISTORY_DEP) $(TERMCAP_DEP) $(GLOB_DEP) \
$(TILDE_DEP) $(MALLOC_DEP) $(SHLIB_DEP) $(TILDE_DEP) $(MALLOC_DEP) $(SHLIB_DEP)
LIBRARY_LDFLAGS = $(READLINE_LDFLAGS) $(HISTORY_LDFLAGS) $(TILDE_LDFLAGS) \ LIBRARY_LDFLAGS = $(READLINE_LDFLAGS) $(HISTORY_LDFLAGS) $(GLOB_LDFLAGS) \
$(GLOB_LDFLAGS) $(MALLOC_LDFLAGS) $(SHLIB_LDFLAGS) $(TILDE_LDFLAGS) $(MALLOC_LDFLAGS) $(SHLIB_LDFLAGS)
# #
# The shell itself # The shell itself
@ -411,8 +416,8 @@ strip: $(Program) .made
size $(Program) size $(Program)
version.h: $(SOURCES) config.h Makefile version.h: $(SOURCES) config.h Makefile
if $(SHELL) $(SUPPORT_SRC)mkversion.sh -b -s $(RELSTATUS) -d $(Version) -p $(PatchLevel) -o newversion.h; \ $(SHELL) $(SUPPORT_SRC)mkversion.sh -b -s $(RELSTATUS) -d $(Version) -p $(PatchLevel) -o newversion.h \
then mv newversion.h version.h; fi; && mv newversion.h version.h
# old rules # old rules
GRAM_H = parser-built GRAM_H = parser-built
@ -435,13 +440,13 @@ y.tab.c y.tab.h: parse.y
$(READLINE_LIBRARY): config.h $(READLINE_SOURCE) $(READLINE_LIBRARY): config.h $(READLINE_SOURCE)
@echo making $@ in ${RL_LIBDIR} @echo making $@ in ${RL_LIBDIR}
@(cd ${RL_LIBDIR} && \ @( { test "${RL_LIBDIR}" = "${libdir}" && exit 0; } || \
$(MAKE) $(MFLAGS) libreadline.a) || exit 1 cd ${RL_LIBDIR} && $(MAKE) $(MFLAGS) libreadline.a) || exit 1
$(HISTORY_LIBRARY): config.h $(HISTORY_SOURCE) $(HISTORY_LIBRARY): config.h $(HISTORY_SOURCE)
@echo making $@ in ${HIST_LIBDIR} @echo making $@ in ${HIST_LIBDIR}
@(cd ${HIST_LIBDIR} && \ @( { test "${HIST_LIBDIR}" = "${libdir}" && exit 0; } || \
$(MAKE) $(MFLAGS) libhistory.a) || exit 1 cd ${HIST_LIBDIR} && $(MAKE) $(MFLAGS) libhistory.a) || exit 1
$(GLOB_LIBRARY): config.h $(GLOB_SOURCE) $(GLOB_LIBRARY): config.h $(GLOB_SOURCE)
@echo making $@ in ${GLOB_LIBDIR} @echo making $@ in ${GLOB_LIBDIR}
@ -464,7 +469,7 @@ $(SHLIB_LIBRARY): config.h ${SHLIB_SOURCE}
$(MAKE) $(MFLAGS) ${SHLIB_LIBNAME}) || exit 1 $(MAKE) $(MFLAGS) ${SHLIB_LIBNAME}) || exit 1
mksignames: $(SUPPORT_SRC)mksignames.c mksignames: $(SUPPORT_SRC)mksignames.c
$(CC) $(CCFLAGS) $(CPPFLAGS) -o $@ $(SUPPORT_SRC)mksignames.c $(CC_FOR_BUILD) $(CCFLAGS) $(CPPFLAGS) -o $@ $(SUPPORT_SRC)mksignames.c
# make a list of signals for the local system -- this is done when we're # make a list of signals for the local system -- this is done when we're
# *not* cross-compiling # *not* cross-compiling
@ -502,15 +507,19 @@ Makefiles makefiles: config.status $(srcdir)/Makefile.in
config.h: stamp-h config.h: stamp-h
stamp-h: config.status $(srcdir)/config.h.in $(srcdir)/config.h.top $(srcdir)/config.h.bot stamp-h: config.status $(srcdir)/config.h.in $(srcdir)/config-top.h $(srcdir)/config-bot.h
CONFIG_FILES= CONFIG_HEADERS=config.h $(SHELL) ./config.status CONFIG_FILES= CONFIG_HEADERS=config.h $(SHELL) ./config.status
config.status: $(srcdir)/configure config.status: $(srcdir)/configure
$(SHELL) ./config.status --recheck $(SHELL) ./config.status --recheck
# comment out for distribution # comment out for distribution
#$(srcdir)/configure: $(srcdir)/configure.in $(srcdir)/aclocal.m4 $(srcdir)/configure: $(srcdir)/configure.in $(srcdir)/aclocal.m4 $(srcdir)/config.h.in
# cd $(srcdir) && autoconf cd $(srcdir) && autoconf
# for chet
reconfig: force
sh $(srcdir)/configure
#newversion: mkversion #newversion: mkversion
# $(RM) .build # $(RM) .build
@ -540,8 +549,8 @@ installdirs:
@${SHELL} $(SUPPORT_SRC)mkdirs $(infodir) @${SHELL} $(SUPPORT_SRC)mkdirs $(infodir)
install: .made installdirs install: .made installdirs
$(INSTALL_PROGRAM) $(Program) $(bindir)/$(Program) $(INSTALL_PROGRAM) $(INSTALLMODE) $(Program) $(bindir)/$(Program)
$(INSTALL_PROGRAM) bashbug $(bindir)/bashbug $(INSTALL_PROGRAM) $(INSTALLMODE) bashbug $(bindir)/bashbug
-( cd $(DOCDIR) ; $(MAKE) $(MFLAGS) \ -( cd $(DOCDIR) ; $(MAKE) $(MFLAGS) \
man1dir=$(man1dir) man1ext=$(man1ext) \ man1dir=$(man1dir) man1ext=$(man1ext) \
man3dir=$(man3dir) man3ext=$(man3ext) \ man3dir=$(man3dir) man3ext=$(man3ext) \
@ -572,6 +581,7 @@ clean: basic-clean
-(cd $(GLOB_LIBDIR) && $(MAKE) $(MFLAGS) $@) -(cd $(GLOB_LIBDIR) && $(MAKE) $(MFLAGS) $@)
-(cd $(TILDE_LIBDIR) && $(MAKE) $(MFLAGS) $@) -(cd $(TILDE_LIBDIR) && $(MAKE) $(MFLAGS) $@)
-(cd $(ALLOC_LIBDIR) && $(MAKE) $(MFLAGS) $@) -(cd $(ALLOC_LIBDIR) && $(MAKE) $(MFLAGS) $@)
-(cd $(SH_LIBDIR) && $(MAKE) $(MFLAGS) $@)
$(RM) $(CREATED_SUPPORT) $(RM) $(CREATED_SUPPORT)
mostlyclean: basic-clean mostlyclean: basic-clean
@ -583,6 +593,7 @@ mostlyclean: basic-clean
-(cd $(GLOB_LIBDIR) && $(MAKE) $(MFLAGS) $@) -(cd $(GLOB_LIBDIR) && $(MAKE) $(MFLAGS) $@)
-(cd $(TILDE_LIBDIR) && $(MAKE) $(MFLAGS) $@) -(cd $(TILDE_LIBDIR) && $(MAKE) $(MFLAGS) $@)
-(cd $(ALLOC_LIBDIR) && $(MAKE) $(MFLAGS) $@) -(cd $(ALLOC_LIBDIR) && $(MAKE) $(MFLAGS) $@)
-(cd $(SH_LIBDIR) && $(MAKE) $(MFLAGS) $@)
distclean: basic-clean distclean: basic-clean
( cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ ) ( cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ )
@ -593,6 +604,7 @@ distclean: basic-clean
-(cd $(GLOB_LIBDIR) && $(MAKE) $(MFLAGS) $@) -(cd $(GLOB_LIBDIR) && $(MAKE) $(MFLAGS) $@)
-(cd $(TILDE_LIBDIR) && $(MAKE) $(MFLAGS) $@) -(cd $(TILDE_LIBDIR) && $(MAKE) $(MFLAGS) $@)
-(cd $(ALLOC_LIBDIR) && $(MAKE) $(MFLAGS) $@) -(cd $(ALLOC_LIBDIR) && $(MAKE) $(MFLAGS) $@)
-(cd $(SH_LIBDIR) && $(MAKE) $(MFLAGS) $@)
$(RM) $(CREATED_CONFIGURE) tags TAGS $(RM) $(CREATED_CONFIGURE) tags TAGS
$(RM) $(CREATED_SUPPORT) Makefile $(CREATED_MAKEFILES) $(RM) $(CREATED_SUPPORT) Makefile $(CREATED_MAKEFILES)
@ -608,6 +620,7 @@ maintainer-clean: basic-clean
-(cd $(GLOB_LIBDIR) && $(MAKE) $(MFLAGS) $@) -(cd $(GLOB_LIBDIR) && $(MAKE) $(MFLAGS) $@)
-(cd $(TILDE_LIBDIR) && $(MAKE) $(MFLAGS) $@) -(cd $(TILDE_LIBDIR) && $(MAKE) $(MFLAGS) $@)
-(cd $(ALLOC_LIBDIR) && $(MAKE) $(MFLAGS) $@) -(cd $(ALLOC_LIBDIR) && $(MAKE) $(MFLAGS) $@)
-(cd $(SH_LIBDIR) && $(MAKE) $(MFLAGS) $@)
$(RM) $(CREATED_CONFIGURE) $(CREATED_MAKEFILES) $(RM) $(CREATED_CONFIGURE) $(CREATED_MAKEFILES)
$(RM) $(CREATED_SUPPORT) Makefile $(RM) $(CREATED_SUPPORT) Makefile
@ -643,22 +656,22 @@ sdepend: force
############################ DEPENDENCIES ############################### ############################ DEPENDENCIES ###############################
# Files that depend on the definitions in config.h.top, which are not meant # Files that depend on the definitions in config-top.h, which are not meant
# to be changed # to be changed
shell.o: config.h.top shell.o: config-top.h
input.o: config.h.top input.o: config-top.h
y.tab.o: config.h.top y.tab.o: config-top.h
jobs.o: config.h.top jobs.o: config-top.h
nojobs.o: config.h.top nojobs.o: config-top.h
execute_cmd.o: config.h.top execute_cmd.o: config-top.h
variables.o: config.h.top variables.o: config-top.h
builtins/command.o: config.h.top builtins/command.o: config-top.h
builtins/common.o: config.h.top builtins/common.o: config-top.h
builtins/break.o: config.h.top builtins/break.o: config-top.h
builtins/echo.o: config.h.top builtins/echo.o: config-top.h
builtins/evalstring.o: config.h.top builtins/evalstring.o: config-top.h
builtins/exit.o: config.h.top builtins/exit.o: config-top.h
builtins/kill.o: config.h.top builtins/kill.o: config-top.h
# shell basics # shell basics
copy_cmd.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h copy_cmd.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
@ -872,18 +885,20 @@ bracecomp.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
# library dependencies # library dependencies
bashline.o: $(RL_LIBSRC)/rlconf.h bashline.o: $(RL_LIBSRC)/rlconf.h
bashline.o: $(RL_LIBSRC)/keymaps.h bashline.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/rlstdc.h
bashline.o: $(RL_LIBSRC)/chardefs.h $(RL_LIBSRC)/readline.h bashline.o: $(RL_LIBSRC)/chardefs.h $(RL_LIBSRC)/readline.h
bracecomp.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/chardefs.h bracecomp.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/chardefs.h
bracecomp.o: $(RL_LIBSRC)/readline.h bracecomp.o: $(RL_LIBSRC)/readline.h $(RL_LIBSRC)/rlstdc.h
y.tab.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/chardefs.h $(RL_LIBSRC)/readline.h y.tab.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/chardefs.h
subst.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/chardefs.h $(RL_LIBSRC)/readline.h y.tab.o: $(RL_LIBSRC)/readline.h $(RL_LIBSRC)/rlstdc.h
subst.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/chardefs.h
subst.o: $(RL_LIBSRC)/readline.h $(RL_LIBSRC)/rlstdc.h
shell.o: $(HIST_LIBSRC)/history.h shell.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h
subst.o: $(HIST_LIBSRC)/history.h subst.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h
bashline.o: $(HIST_LIBSRC)/history.h bashline.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h
bashhist.o: $(HIST_LIBSRC)/history.h bashhist.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h
y.tab.o: $(HIST_LIBSRC)/history.h y.tab.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h
execute_cmd.o: $(TILDE_LIBSRC)/tilde.h execute_cmd.o: $(TILDE_LIBSRC)/tilde.h
general.o: $(TILDE_LIBSRC)/tilde.h general.o: $(TILDE_LIBSRC)/tilde.h
@ -1075,11 +1090,11 @@ builtins/wait.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
# builtin library dependencies # builtin library dependencies
builtins/bind.o: $(RL_LIBSRC)/chardefs.h $(RL_LIBSRC)/readline.h builtins/bind.o: $(RL_LIBSRC)/chardefs.h $(RL_LIBSRC)/readline.h
builtins/bind.o: $(RL_LIBSRC)/keymaps.h builtins/bind.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/rlstdc.h
builtins/bind.o: $(HIST_LIBSRC)/history.h builtins/bind.o: $(HIST_LIBSRC)/history.h $(RL_LIBSRC)/rlstdc.h
builtins/fc.o: $(HIST_LIBSRC)/history.h builtins/fc.o: $(HIST_LIBSRC)/history.h $(RL_LIBSRC)/rlstdc.h
builtins/history.o: $(HIST_LIBSRC)/history.h builtins/history.o: $(HIST_LIBSRC)/history.h $(RL_LIBSRC)/rlstdc.h
builtins/common.o: $(TILDE_LIBSRC)/tilde.h builtins/common.o: $(TILDE_LIBSRC)/tilde.h
builtins/cd.o: $(TILDE_LIBSRC)/tilde.h builtins/cd.o: $(TILDE_LIBSRC)/tilde.h

66
NEWS
View file

@ -1,3 +1,69 @@
This is a terse description of the new features added to bash-2.03 since
the release of bash-2.02. As always, the manual page (doc/bash.1) is
the place to look for complete descriptions.
1. New Features in Bash
a. New `shopt' option, `restricted_shell', indicating whether or not the
shell was started in restricted mode, for use in startup files.
b. Filename generation is now performed on the words between ( and ) in
array assignments (which it probably should have done all along).
c. OLDPWD is now auto-exported, as POSIX.2 seems to require.
d. ENV and BASH_ENV are read-only variables in a restricted shell.
e. A change was made to the startup file code so that any shell begun with
the `--login' option, even non-interactive shells, will source the login
shell startup files.
2. New Features in Readline
a. Many changes to the signal handling:
o Readline now catches SIGQUIT and cleans up the tty before returning;
o A new variable, rl_catch_signals, is available to application writers
to indicate to readline whether or not it should install its own
signal handlers for SIGINT, SIGTERM, SIGQUIT, SIGALRM, SIGTSTP,
SIGTTIN, and SIGTTOU;
o A new variable, rl_catch_sigwinch, is available to application
writers to indicate to readline whether or not it should install its
own signal handler for SIGWINCH, which will chain to the calling
applications's SIGWINCH handler, if one is installed;
o There is a new function, rl_free_line_state, for application signal
handlers to call to free up the state associated with the current
line after receiving a signal;
o There is a new function, rl_cleanup_after_signal, to clean up the
display and terminal state after receiving a signal;
o There is a new function, rl_reset_after_signal, to reinitialize the
terminal and display state after an application signal handler
returns and readline continues
b. There is a new function, rl_resize_terminal, to reset readline's idea of
the screen size after a SIGWINCH.
c. New public functions: rl_save_prompt and rl_restore_prompt. These were
previously private functions with a `_' prefix.
d. New function hook: rl_pre_input_hook, called just before readline starts
reading input, after initialization.
e. New function hook: rl_display_matches_hook, called when readline would
display the list of completion matches. The new function
rl_display_match_list is what readline uses internally, and is available
for use by application functions called via this hook.
f. New bindable function, delete-char-or-list, like tcsh.
g. A new variable, rl_erase_empty_line, which, if set by an application using
readline, will cause readline to erase, prompt and all, lines on which the
only thing typed was a newline.
h. New bindable variable: `isearch-terminators'.
i. New bindable function: `forward-backward-delete-char' (unbound by default).
-------------------------------------------------------------------------------
This is a terse description of the new features added to bash-2.02 since This is a terse description of the new features added to bash-2.02 since
the release of bash-2.01.1. As always, the manual page (doc/bash.1) is the release of bash-2.01.1. As always, the manual page (doc/bash.1) is
the place to look for complete descriptions. the place to look for complete descriptions.

55
NOTES
View file

@ -198,3 +198,58 @@ being built and linked against, but there is only a stub file in the archive.)
You will see many warnings of the form: You will see many warnings of the form:
warning: unknown s_type: 98 warning: unknown s_type: 98
I have no idea what this means, but it doesn't seem to matter. I have no idea what this means, but it doesn't seem to matter.
10. If you do not have /usr/ccs/bin in your PATH when building on SunOS 5.x
(Solaris 2), the configure script will be unable to find `ar' and
`ranlib' (of course, ranlib is unnecessary). Make sure your $PATH
includes /usr/ccs/bin on SunOS 5.x.
11. Building a statically-linked bash on Solaris 2.5.x or 2.6 is complicated.
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).
configure --enable-static-link
make STATIC_LD= LOCAL_LIBS='-Wl,-B,dynamic -ldl -Wl,-B,static'
This should result in a bash binary that depends only on libdl.so:
thor(2)$ ldd bash
libdl.so.1 => /usr/lib/libdl.so.1
If you're using the Sun C Compiler (Sun WorkShop C Compiler version
4.2 was what I used), you should be able to get away with using
configure --enable-static-link
make STATIC_LD= LOCAL_LIBS='-B dynamic -ldl -B static'
If you want to completely remove any dependence on /usr, perhaps
to put a copy of bash in /sbin and have it available when /usr is
not mounted, force the build process to use the shared ld.so library
in /etc/lib.
For gcc, this would be something like
configure --enable-static-link
make STATIC_LD= LOCAL_LIBS='-Wl,-B,dynamic -Wl,-R/etc/lib -ldl -Wl,-B,static'
For Sun's WS4.2 cc
configure --enable-static-link
make STATIC_LD= LOCAL_LIBS='-B dynamic -R/etc/lib -ldl -B static'
seems to work, at least on Solaris 2.5.1:
thor(2)$ ldd bash
libdl.so.1 => /etc/lib/libdl.so.1
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:
export RANLIB=i586-beos-ranlib
export AR=i586-beos-ar
export CC=i586-beos-gcc
configure i586-beos
Similarly for cygwin32.

6
README
View file

@ -1,7 +1,7 @@
Introduction Introduction
============ ============
This is GNU Bash, version 2.02.1. Bash is the GNU Project's Bourne This is GNU Bash, version 2.03. Bash is the GNU Project's Bourne
Again SHell, a complete implementation of the POSIX.2 shell spec, Again SHell, a complete implementation of the POSIX.2 shell spec,
but also with interactive command line editing, job control on but also with interactive command line editing, job control on
architectures that support it, csh-like features such as history architectures that support it, csh-like features such as history
@ -49,7 +49,7 @@ more ambitious script that attempts to do a more complete job.
Reporting Bugs Reporting Bugs
============== ==============
Bug reports for bash-2.02.1 should be sent to: Bug reports for bash should be sent to:
bug-bash@prep.ai.mit.edu bug-bash@prep.ai.mit.edu
@ -67,7 +67,7 @@ bashbug directly with `make bashbug'. If you cannot build `bashbug',
please send mail to bug-bash@prep.ai.mit.edu with the following please send mail to bug-bash@prep.ai.mit.edu with the following
information: information:
* the version number and release status of Bash (e.g., 2.02.1-release) * the version number and release status of Bash (e.g., 2.01-release)
* the machine and OS that it is running on (look at the file * the machine and OS that it is running on (look at the file
`.made' in the bash build directory) `.made' in the bash build directory)
* a list of the compilation flags or the contents of `config.h', if * a list of the compilation flags or the contents of `config.h', if

5
Y2K Normal file
View file

@ -0,0 +1,5 @@
Since Bash does not manipulate date strings, it is Y2K-safe.
The only thing that Bash does with date strings is manipulate the string
returned by ctime(3) in the prompt customization code. In all cases,
it discards the year.

167
aclocal.m4 vendored
View file

@ -26,7 +26,7 @@ main()
exit(fl != 1); exit(fl != 1);
} }
], bash_cv_dup2_broken=yes, bash_cv_dup2_broken=no, ], bash_cv_dup2_broken=yes, bash_cv_dup2_broken=no,
[AC_MSG_ERROR(cannot check dup2 if cross compiling -- defaulting to no) [AC_MSG_WARN(cannot check dup2 if cross compiling -- defaulting to no)
bash_cv_dup2_broken=no]) bash_cv_dup2_broken=no])
]) ])
AC_MSG_RESULT($bash_cv_dup2_broken) AC_MSG_RESULT($bash_cv_dup2_broken)
@ -129,7 +129,7 @@ main()
exit(ok ? 0 : 5); exit(ok ? 0 : 5);
} }
], bash_cv_pgrp_pipe=no,bash_cv_pgrp_pipe=yes, ], bash_cv_pgrp_pipe=no,bash_cv_pgrp_pipe=yes,
[AC_MSG_ERROR(cannot check pgrp synchronization if cross compiling -- defaulting to no) [AC_MSG_WARN(cannot check pgrp synchronization if cross compiling -- defaulting to no)
bash_cv_pgrp_pipe=no]) bash_cv_pgrp_pipe=no])
]) ])
AC_MSG_RESULT($bash_cv_pgrp_pipe) AC_MSG_RESULT($bash_cv_pgrp_pipe)
@ -187,7 +187,7 @@ main()
#endif #endif
exit(1); exit(1);
}], bash_cv_type_rlimit=quad_t, bash_cv_type_rlimit=long, }], bash_cv_type_rlimit=quad_t, bash_cv_type_rlimit=long,
[AC_MSG_ERROR(cannot check quad_t if cross compiling -- defaulting to long) [AC_MSG_WARN(cannot check quad_t if cross compiling -- defaulting to long)
bash_cv_type_rlimit=long])]) bash_cv_type_rlimit=long])])
]) ])
AC_MSG_RESULT($bash_cv_type_rlimit) AC_MSG_RESULT($bash_cv_type_rlimit)
@ -211,7 +211,7 @@ AC_CACHE_VAL(bash_cv_decl_under_sys_siglist,
#include <unistd.h> #include <unistd.h>
#endif], [ char *msg = _sys_siglist[2]; ], #endif], [ char *msg = _sys_siglist[2]; ],
bash_cv_decl_under_sys_siglist=yes, bash_cv_decl_under_sys_siglist=no, bash_cv_decl_under_sys_siglist=yes, bash_cv_decl_under_sys_siglist=no,
[AC_MSG_ERROR(cannot check for _sys_siglist[] if cross compiling -- defaulting to no)])])dnl [AC_MSG_WARN(cannot check for _sys_siglist[] if cross compiling -- defaulting to no)])])dnl
AC_MSG_RESULT($bash_cv_decl_under_sys_siglist) AC_MSG_RESULT($bash_cv_decl_under_sys_siglist)
if test $bash_cv_decl_under_sys_siglist = yes; then if test $bash_cv_decl_under_sys_siglist = yes; then
AC_DEFINE(UNDER_SYS_SIGLIST_DECLARED) AC_DEFINE(UNDER_SYS_SIGLIST_DECLARED)
@ -237,7 +237,7 @@ char *msg = (char *)_sys_siglist[2];
exit(msg == 0); exit(msg == 0);
}], }],
bash_cv_under_sys_siglist=yes, bash_cv_under_sys_siglist=no, bash_cv_under_sys_siglist=yes, bash_cv_under_sys_siglist=no,
[AC_MSG_ERROR(cannot check for _sys_siglist[] if cross compiling -- defaulting to no) [AC_MSG_WARN(cannot check for _sys_siglist[] if cross compiling -- defaulting to no)
bash_cv_under_sys_siglist=no])]) bash_cv_under_sys_siglist=no])])
AC_MSG_RESULT($bash_cv_under_sys_siglist) AC_MSG_RESULT($bash_cv_under_sys_siglist)
if test $bash_cv_under_sys_siglist = yes; then if test $bash_cv_under_sys_siglist = yes; then
@ -264,7 +264,7 @@ char *msg = sys_siglist[2];
exit(msg == 0); exit(msg == 0);
}], }],
bash_cv_sys_siglist=yes, bash_cv_sys_siglist=no, bash_cv_sys_siglist=yes, bash_cv_sys_siglist=no,
[AC_MSG_ERROR(cannot check for sys_siglist if cross compiling -- defaulting to no) [AC_MSG_WARN(cannot check for sys_siglist if cross compiling -- defaulting to no)
bash_cv_sys_siglist=no])]) bash_cv_sys_siglist=no])])
AC_MSG_RESULT($bash_cv_sys_siglist) AC_MSG_RESULT($bash_cv_sys_siglist)
if test $bash_cv_sys_siglist = yes; then if test $bash_cv_sys_siglist = yes; then
@ -325,7 +325,7 @@ dir = opendir("/tmp/not_a_directory");
unlink("/tmp/not_a_directory"); unlink("/tmp/not_a_directory");
exit (dir == 0); exit (dir == 0);
}], bash_cv_opendir_not_robust=yes,bash_cv_opendir_not_robust=no, }], bash_cv_opendir_not_robust=yes,bash_cv_opendir_not_robust=no,
[AC_MSG_ERROR(cannot check opendir if cross compiling -- defaulting to no) [AC_MSG_WARN(cannot check opendir if cross compiling -- defaulting to no)
bash_cv_opendir_not_robust=no] bash_cv_opendir_not_robust=no]
)]) )])
AC_MSG_RESULT($bash_cv_opendir_not_robust) AC_MSG_RESULT($bash_cv_opendir_not_robust)
@ -356,109 +356,47 @@ fi
AC_DEFUN(BASH_TYPE_INT32_T, AC_DEFUN(BASH_TYPE_INT32_T,
[ [
if test "X$bash_cv_type_int32_t" = "X"; then if test "$ac_cv_sizeof_int" = 4; then
_bash_needmsg=yes AC_CHECK_TYPE(int32_t, int)
elif test "$ac_cv_sizeof_long" = 4; then
AC_CHECK_TYPE(int32_t, long)
else else
AC_MSG_CHECKING(which builtin C type is 32 bits wide) AC_CHECK_TYPE(int32_t, int)
_bash_needmsg=
fi
AC_CACHE_VAL(bash_cv_type_int32_t,
[AC_TRY_RUN([
main()
{
#if SIZEOF_INT == 4
exit (0);
#else
# if SIZEOF_LONG == 4
exit (1);
# else
# error cannot find 32 bit type...
# endif
#endif
}], bash_cv_type_int32_t=int, bash_cv_type_int32_t=long,
[AC_MSG_ERROR(cannot check type sizes if cross-compiling -- defaulting to int)
bash_cv_type_int32_t=int]
)])
if test "X$_bash_needmsg" = "Xyes"; then
AC_MSG_CHECKING(which builtin C type is 32 bits wide)
fi
AC_MSG_RESULT($bash_cv_type_int32_t);
if test "$bash_cv_type_int32_t" = "int"; then
AC_DEFINE(int32_t, int)
else
AC_DEFINE(int32_t, long)
fi fi
]) ])
AC_DEFUN(BASH_TYPE_U_INT32_T, AC_DEFUN(BASH_TYPE_U_INT32_T,
[ [
if test "X$bash_cv_type_u_int32_t" = "X"; then if test "$ac_cv_sizeof_int" = 4; then
_bash_needmsg=yes AC_CHECK_TYPE(u_int32_t, unsigned int)
elif test "$ac_cv_sizeof_long" = 4; then
AC_CHECK_TYPE(u_int32_t, unsigned long)
else else
AC_MSG_CHECKING(which unsigned builtin C type is 32 bits wide) AC_CHECK_TYPE(u_int32_t, unsigned int)
_bash_needmsg=
fi
AC_CACHE_VAL(bash_cv_type_u_int32_t,
[AC_TRY_RUN([
main()
{
#if SIZEOF_INT == 4
exit (0);
#else
# if SIZEOF_LONG == 4
exit (1);
# else
# error cannot find 32 bit type...
# endif
#endif
}], bash_cv_type_u_int32_t=int, bash_cv_type_u_int32_t=long,
[AC_MSG_ERROR(cannot check type sizes if cross-compiling -- defaulting to int)
bash_cv_type_u_int32_t=int]
)])
if test "X$_bash_needmsg" = "Xyes"; then
AC_MSG_CHECKING(which unsigned builtin C type is 32 bits wide)
fi
AC_MSG_RESULT($bash_cv_type_u_int32_t);
if test "$bash_cv_type_u_int32_t" = "int"; then
AC_DEFINE(u_int32_t, unsigned int)
else
AC_DEFINE(u_int32_t, unsigned long)
fi fi
]) ])
AC_DEFUN(BASH_TYPE_PTRDIFF_T, AC_DEFUN(BASH_TYPE_PTRDIFF_T,
[ [
if test "X$bash_cv_type_ptrdiff_t" = "X"; then if test "$ac_cv_sizeof_int" = "$ac_cv_sizeof_char_p"; then
_bash_needmsg=yes AC_CHECK_TYPE(ptrdiff_t, int)
elif test "$ac_cv_sizeof_long" = "$ac_cv_sizeof_char_p"; then
AC_CHECK_TYPE(ptrdiff_t, long)
else else
AC_MSG_CHECKING(which builtin C type is correct for ptrdiff_t) AC_CHECK_TYPE(ptrdiff_t, int)
_bash_needmsg=
fi fi
AC_CACHE_VAL(bash_cv_type_ptrdiff_t, ])
[AC_TRY_RUN([
main() AC_DEFUN(BASH_TYPE_BITS64_T,
{ [
#if SIZEOF_CHAR_P == SIZEOF_INT if test "$ac_sv_sizeof_char_p" = 8; then
exit (0); AC_CHECK_TYPE(bits64_t, char *)
#else elif test "$ac_cv_sizeof_double" = 8; then
# if SIZEOF_CHAR_P == SIZEOF_LONG AC_CHECK_TYPE(bits64_t, double)
exit (1); elif test "$ac_cv_sizeof_long" = 8; then
# else AC_CHECK_TYPE(bits64_t, long)
# error cannot find type for pointer arithmetic...
# endif
#endif
}], bash_cv_type_ptrdiff_t=int, bash_cv_type_ptrdiff_t=long,
[AC_MSG_ERROR(cannot check type sizes if cross-compiling -- defaulting to int)
bash_cv_type_ptrdiff_t=int]
)])
if test "X$_bash_needmsg" = "Xyes"; then
AC_MSG_CHECKING(which builtin C type is correct for ptrdiff_t)
fi
AC_MSG_RESULT($bash_cv_type_ptrdiff_t);
if test "$bash_cv_type_ptrdiff_t" = "int"; then
AC_DEFINE(ptrdiff_t, int)
else else
AC_DEFINE(ptrdiff_t, long) AC_CHECK_TYPE(bits64_t, double)
fi fi
]) ])
@ -548,7 +486,7 @@ s = getenv("ABCDE");
exit(s == 0); /* force optimizer to leave getenv in */ exit(s == 0); /* force optimizer to leave getenv in */
} }
], bash_cv_getenv_redef=yes, bash_cv_getenv_redef=no, ], bash_cv_getenv_redef=yes, bash_cv_getenv_redef=no,
[AC_MSG_ERROR(cannot check getenv redefinition if cross compiling -- defaulting to yes) [AC_MSG_WARN(cannot check getenv redefinition if cross compiling -- defaulting to yes)
bash_cv_getenv_redef=yes] bash_cv_getenv_redef=yes]
)]) )])
AC_MSG_RESULT($bash_cv_getenv_redef) AC_MSG_RESULT($bash_cv_getenv_redef)
@ -574,7 +512,7 @@ pf = (_bashfunc) printf;
exit(pf == 0); exit(pf == 0);
} }
], bash_cv_printf_declared=yes, bash_cv_printf_declared=no, ], bash_cv_printf_declared=yes, bash_cv_printf_declared=no,
[AC_MSG_ERROR(cannot check printf declaration if cross compiling -- defaulting to yes) [AC_MSG_WARN(cannot check printf declaration if cross compiling -- defaulting to yes)
bash_cv_printf_declared=yes] bash_cv_printf_declared=yes]
)]) )])
AC_MSG_RESULT($bash_cv_printf_declared) AC_MSG_RESULT($bash_cv_printf_declared)
@ -593,7 +531,7 @@ long maxfds = ulimit(4, 0L);
exit (maxfds == -1L); exit (maxfds == -1L);
} }
], bash_cv_ulimit_maxfds=yes, bash_cv_ulimit_maxfds=no, ], bash_cv_ulimit_maxfds=yes, bash_cv_ulimit_maxfds=no,
[AC_MSG_ERROR(cannot check ulimit if cross compiling -- defaulting to no) [AC_MSG_WARN(cannot check ulimit if cross compiling -- defaulting to no)
bash_cv_ulimit_maxfds=no] bash_cv_ulimit_maxfds=no]
)]) )])
AC_MSG_RESULT($bash_cv_ulimit_maxfds) AC_MSG_RESULT($bash_cv_ulimit_maxfds)
@ -690,7 +628,7 @@ main()
exit (popen_called); exit (popen_called);
} }
], bash_cv_getcwd_calls_popen=no, bash_cv_getcwd_calls_popen=yes, ], bash_cv_getcwd_calls_popen=no, bash_cv_getcwd_calls_popen=yes,
[AC_MSG_ERROR(cannot check whether getcwd calls popen if cross compiling -- defaulting to no) [AC_MSG_WARN(cannot check whether getcwd calls popen if cross compiling -- defaulting to no)
bash_cv_getcwd_calls_popen=no] bash_cv_getcwd_calls_popen=no]
)]) )])
AC_MSG_RESULT($bash_cv_getcwd_calls_popen) AC_MSG_RESULT($bash_cv_getcwd_calls_popen)
@ -814,7 +752,7 @@ main()
exit(nsigint != 2); exit(nsigint != 2);
} }
], bash_cv_must_reinstall_sighandlers=no, bash_cv_must_reinstall_sighandlers=yes, ], bash_cv_must_reinstall_sighandlers=no, bash_cv_must_reinstall_sighandlers=yes,
[AC_MSG_ERROR(cannot check signal handling if cross compiling -- defaulting to no) [AC_MSG_WARN(cannot check signal handling if cross compiling -- defaulting to no)
bash_cv_must_reinstall_sighandlers=no] bash_cv_must_reinstall_sighandlers=no]
)]) )])
AC_MSG_RESULT($bash_cv_must_reinstall_sighandlers) AC_MSG_RESULT($bash_cv_must_reinstall_sighandlers)
@ -883,7 +821,7 @@ exit(1);
exit(0); exit(0);
}], bash_cv_job_control_missing=present, bash_cv_job_control_missing=missing, }], bash_cv_job_control_missing=present, bash_cv_job_control_missing=missing,
[AC_MSG_ERROR(cannot check job control if cross-compiling -- defaulting to missing) [AC_MSG_WARN(cannot check job control if cross-compiling -- defaulting to missing)
bash_cv_job_control_missing=missing] bash_cv_job_control_missing=missing]
)]) )])
AC_MSG_RESULT($bash_cv_job_control_missing) AC_MSG_RESULT($bash_cv_job_control_missing)
@ -928,7 +866,7 @@ close(fd);
unlink ("/tmp/sh-np-autoconf"); unlink ("/tmp/sh-np-autoconf");
exit(0); exit(0);
}], bash_cv_sys_named_pipes=present, bash_cv_sys_named_pipes=missing, }], bash_cv_sys_named_pipes=present, bash_cv_sys_named_pipes=missing,
[AC_MSG_ERROR(cannot check for named pipes if cross-compiling -- defaulting to missing) [AC_MSG_WARN(cannot check for named pipes if cross-compiling -- defaulting to missing)
bash_cv_sys_named_pipes=missing] bash_cv_sys_named_pipes=missing]
)]) )])
AC_MSG_RESULT($bash_cv_sys_named_pipes) AC_MSG_RESULT($bash_cv_sys_named_pipes)
@ -979,7 +917,7 @@ siglongjmp(xx, 10);
exit(1); exit(1);
#endif #endif
}], bash_cv_func_sigsetjmp=present, bash_cv_func_sigsetjmp=missing, }], bash_cv_func_sigsetjmp=present, bash_cv_func_sigsetjmp=missing,
[AC_MSG_ERROR(cannot check for sigsetjmp/siglongjmp if cross-compiling -- defaulting to missing) [AC_MSG_WARN(cannot check for sigsetjmp/siglongjmp if cross-compiling -- defaulting to missing)
bash_cv_func_sigsetjmp=missing] bash_cv_func_sigsetjmp=missing]
)]) )])
AC_MSG_RESULT($bash_cv_func_sigsetjmp) AC_MSG_RESULT($bash_cv_func_sigsetjmp)
@ -1246,7 +1184,7 @@ char *v[];
exit (r1 > 0 && r2 > 0); exit (r1 > 0 && r2 > 0);
} }
], bash_cv_func_strcoll_broken=yes, bash_cv_func_strcoll_broken=no, ], bash_cv_func_strcoll_broken=yes, bash_cv_func_strcoll_broken=no,
[AC_MSG_ERROR(cannot check strcoll if cross compiling -- defaulting to no) [AC_MSG_WARN(cannot check strcoll if cross compiling -- defaulting to no)
bash_cv_func_strcoll_broken=no] bash_cv_func_strcoll_broken=no]
)]) )])
AC_MSG_RESULT($bash_cv_func_strcoll_broken) AC_MSG_RESULT($bash_cv_func_strcoll_broken)
@ -1336,9 +1274,28 @@ main ()
#endif #endif
} }
], bash_cv_sys_restartable_syscalls=yes, bash_cv_sys_restartable_syscalls=no, ], bash_cv_sys_restartable_syscalls=yes, bash_cv_sys_restartable_syscalls=no,
AC_MSG_ERROR(cannot check restartable syscalls if cross compiling)) AC_MSG_WARN(cannot check restartable syscalls if cross compiling))
]) ])
if test $bash_cv_sys_restartable_syscalls = yes; then if test $bash_cv_sys_restartable_syscalls = yes; then
AC_DEFINE(HAVE_RESTARTABLE_SYSCALLS) AC_DEFINE(HAVE_RESTARTABLE_SYSCALLS)
fi fi
]) ])
dnl
dnl Check for 64-bit off_t -- used for malloc alignment
dnl
dnl C does not allow duplicate case labels, so the compile will fail if
dnl sizeof(off_t) is > 4.
dnl
AC_DEFUN(BASH_CHECK_OFF_T_64,
[AC_CACHE_CHECK(for 64-bit off_t, bash_cv_off_t_64,
AC_TRY_COMPILE([
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <sys/types.h>
],[
switch (0) case 0: case (sizeof (off_t) <= 4):;
], bash_cv_off_t_64=no, bash_cv_off_t_64=yes))
if test $bash_cv_off_t_64 = yes; then
AC_DEFINE(HAVE_OFF_T_64)
fi])

View file

@ -289,7 +289,7 @@ maybe_append_history (filename)
/* If the filename was supplied, then create it if necessary. */ /* If the filename was supplied, then create it if necessary. */
if (stat (filename, &buf) == -1 && errno == ENOENT) if (stat (filename, &buf) == -1 && errno == ENOENT)
{ {
fd = open (filename, O_WRONLY|O_CREAT, 0666); fd = open (filename, O_WRONLY|O_CREAT, 0600);
if (fd < 0) if (fd < 0)
{ {
builtin_error ("%s: cannot create: %s", filename, strerror (errno)); builtin_error ("%s: cannot create: %s", filename, strerror (errno));
@ -324,7 +324,7 @@ maybe_save_shell_history ()
if (stat (hf, &buf) == -1) if (stat (hf, &buf) == -1)
{ {
int file; int file;
file = open (hf, O_CREAT | O_TRUNC | O_WRONLY, 0666); file = open (hf, O_CREAT | O_TRUNC | O_WRONLY, 0600);
if (file != -1) if (file != -1)
close (file); close (file);
} }

View file

@ -239,50 +239,50 @@ initialize_readline ()
#endif #endif
#if defined (BRACE_COMPLETION) #if defined (BRACE_COMPLETION)
rl_add_defun ("complete-into-braces", bash_brace_completion, -1); rl_add_defun ("complete-into-braces", (Function *)bash_brace_completion, -1);
rl_bind_key_in_map ('{', bash_brace_completion, emacs_meta_keymap); rl_bind_key_in_map ('{', (Function *)bash_brace_completion, emacs_meta_keymap);
#endif /* BRACE_COMPLETION */ #endif /* BRACE_COMPLETION */
#if defined (SPECIFIC_COMPLETION_FUNCTIONS) #if defined (SPECIFIC_COMPLETION_FUNCTIONS)
rl_add_defun ("complete-filename", bash_complete_filename, -1); rl_add_defun ("complete-filename", (Function *)bash_complete_filename, -1);
rl_bind_key_in_map ('/', bash_complete_filename, emacs_meta_keymap); rl_bind_key_in_map ('/', (Function *)bash_complete_filename, emacs_meta_keymap);
rl_add_defun ("possible-filename-completions", rl_add_defun ("possible-filename-completions",
bash_possible_filename_completions, -1); (Function *)bash_possible_filename_completions, -1);
rl_bind_key_in_map ('/', bash_possible_filename_completions, emacs_ctlx_keymap); rl_bind_key_in_map ('/', (Function *)bash_possible_filename_completions, emacs_ctlx_keymap);
rl_add_defun ("complete-username", bash_complete_username, -1); rl_add_defun ("complete-username", (Function *)bash_complete_username, -1);
rl_bind_key_in_map ('~', bash_complete_username, emacs_meta_keymap); rl_bind_key_in_map ('~', (Function *)bash_complete_username, emacs_meta_keymap);
rl_add_defun ("possible-username-completions", rl_add_defun ("possible-username-completions",
bash_possible_username_completions, -1); (Function *)bash_possible_username_completions, -1);
rl_bind_key_in_map ('~', bash_possible_username_completions, emacs_ctlx_keymap); rl_bind_key_in_map ('~', (Function *)bash_possible_username_completions, emacs_ctlx_keymap);
rl_add_defun ("complete-hostname", bash_complete_hostname, -1); rl_add_defun ("complete-hostname", (Function *)bash_complete_hostname, -1);
rl_bind_key_in_map ('@', bash_complete_hostname, emacs_meta_keymap); rl_bind_key_in_map ('@', (Function *)bash_complete_hostname, emacs_meta_keymap);
rl_add_defun ("possible-hostname-completions", rl_add_defun ("possible-hostname-completions",
bash_possible_hostname_completions, -1); (Function *)bash_possible_hostname_completions, -1);
rl_bind_key_in_map ('@', bash_possible_hostname_completions, emacs_ctlx_keymap); rl_bind_key_in_map ('@', (Function *)bash_possible_hostname_completions, emacs_ctlx_keymap);
rl_add_defun ("complete-variable", bash_complete_variable, -1); rl_add_defun ("complete-variable", (Function *)bash_complete_variable, -1);
rl_bind_key_in_map ('$', bash_complete_variable, emacs_meta_keymap); rl_bind_key_in_map ('$', (Function *)bash_complete_variable, emacs_meta_keymap);
rl_add_defun ("possible-variable-completions", rl_add_defun ("possible-variable-completions",
bash_possible_variable_completions, -1); (Function *)bash_possible_variable_completions, -1);
rl_bind_key_in_map ('$', bash_possible_variable_completions, emacs_ctlx_keymap); rl_bind_key_in_map ('$', (Function *)bash_possible_variable_completions, emacs_ctlx_keymap);
rl_add_defun ("complete-command", bash_complete_command, -1); rl_add_defun ("complete-command", (Function *)bash_complete_command, -1);
rl_bind_key_in_map ('!', bash_complete_command, emacs_meta_keymap); rl_bind_key_in_map ('!', (Function *)bash_complete_command, emacs_meta_keymap);
rl_add_defun ("possible-command-completions", rl_add_defun ("possible-command-completions",
bash_possible_command_completions, -1); (Function *)bash_possible_command_completions, -1);
rl_bind_key_in_map ('!', bash_possible_command_completions, emacs_ctlx_keymap); rl_bind_key_in_map ('!', (Function *)bash_possible_command_completions, emacs_ctlx_keymap);
rl_add_defun ("glob-expand-word", bash_glob_expand_word, -1); rl_add_defun ("glob-expand-word", (Function *)bash_glob_expand_word, -1);
rl_add_defun ("glob-list-expansions", bash_glob_list_expansions, -1); rl_add_defun ("glob-list-expansions", (Function *)bash_glob_list_expansions, -1);
rl_bind_key_in_map ('*', bash_glob_expand_word, emacs_ctlx_keymap); rl_bind_key_in_map ('*', (Function *)bash_glob_expand_word, emacs_ctlx_keymap);
rl_bind_key_in_map ('g', bash_glob_list_expansions, emacs_ctlx_keymap); rl_bind_key_in_map ('g', (Function *)bash_glob_list_expansions, emacs_ctlx_keymap);
#endif /* SPECIFIC_COMPLETION_FUNCTIONS */ #endif /* SPECIFIC_COMPLETION_FUNCTIONS */
rl_add_defun ("dynamic-complete-history", dynamic_complete_history, -1); rl_add_defun ("dynamic-complete-history", (Function *)dynamic_complete_history, -1);
rl_bind_key_in_map (TAB, dynamic_complete_history, emacs_meta_keymap); rl_bind_key_in_map (TAB, (Function *)dynamic_complete_history, emacs_meta_keymap);
/* Tell the completer that we want a crack first. */ /* Tell the completer that we want a crack first. */
rl_attempted_completion_function = (CPPFunction *)attempt_shell_completion; rl_attempted_completion_function = (CPPFunction *)attempt_shell_completion;
@ -295,9 +295,9 @@ initialize_readline ()
rl_ignore_some_completions_function = (Function *)filename_completion_ignore; rl_ignore_some_completions_function = (Function *)filename_completion_ignore;
#if defined (VI_MODE) #if defined (VI_MODE)
rl_bind_key_in_map ('v', vi_edit_and_execute_command, vi_movement_keymap); rl_bind_key_in_map ('v', (Function *)vi_edit_and_execute_command, vi_movement_keymap);
# if defined (ALIAS) # if defined (ALIAS)
rl_bind_key_in_map ('@', posix_edit_macros, vi_movement_keymap); rl_bind_key_in_map ('@', (Function *)posix_edit_macros, vi_movement_keymap);
# endif # endif
#endif #endif
@ -561,7 +561,7 @@ static void
set_saved_history () set_saved_history ()
{ {
if (saved_history_line_to_use >= 0) if (saved_history_line_to_use >= 0)
rl_get_previous_history (history_length - saved_history_line_to_use); rl_get_previous_history (history_length - saved_history_line_to_use, 0);
saved_history_line_to_use = -1; saved_history_line_to_use = -1;
rl_startup_hook = old_rl_startup_hook; rl_startup_hook = old_rl_startup_hook;
} }
@ -573,7 +573,7 @@ operate_and_get_next (count, c)
int where; int where;
/* Accept the current line. */ /* Accept the current line. */
rl_newline (); rl_newline (1, c);
/* Find the current line, and find the next line to use. */ /* Find the current line, and find the next line to use. */
where = where_history (); where = where_history ();
@ -602,7 +602,7 @@ vi_edit_and_execute_command (count, c)
char *command; char *command;
/* Accept the current line. */ /* Accept the current line. */
rl_newline (); rl_newline (1, c);
if (rl_explicit_arg) if (rl_explicit_arg)
{ {
@ -1258,7 +1258,7 @@ set_up_new_line (new_line)
{ {
rl_point = old_point; rl_point = old_point;
if (!whitespace (rl_line_buffer[rl_point])) if (!whitespace (rl_line_buffer[rl_point]))
rl_forward_word (1); rl_forward_word (1, 0);
} }
} }
@ -1419,7 +1419,7 @@ shell_expand_line (ignore)
{ {
rl_point = old_point; rl_point = old_point;
if (!whitespace (rl_line_buffer[rl_point])) if (!whitespace (rl_line_buffer[rl_point]))
rl_forward_word (1); rl_forward_word (1, 0);
} }
} }
else else
@ -1553,10 +1553,24 @@ name_is_acceptable (name)
return (1); return (1);
} }
#if 0
static int
ignore_dot_names (name)
char *name;
{
return (name[0] != '.');
}
#endif
static void static void
filename_completion_ignore (names) filename_completion_ignore (names)
char **names; char **names;
{ {
#if 0
if (glob_dot_filenames == 0)
_ignore_completion_names (names, ignore_dot_names);
#endif
setup_ignore_patterns (&fignore); setup_ignore_patterns (&fignore);
if (fignore.num_ignores == 0) if (fignore.num_ignores == 0)
@ -1597,14 +1611,15 @@ static int
bash_directory_completion_hook (dirname) bash_directory_completion_hook (dirname)
char **dirname; char **dirname;
{ {
char *local_dirname, *t; char *local_dirname, *new_dirname, *t;
int return_value = 0; int return_value = 0;
WORD_LIST *wl; WORD_LIST *wl;
local_dirname = *dirname; local_dirname = *dirname;
new_dirname = savestring (local_dirname);
if (strchr (local_dirname, '$') || strchr (local_dirname, '`')) if (strchr (local_dirname, '$') || strchr (local_dirname, '`'))
{ {
wl = expand_string (local_dirname, 0); wl = expand_string (new_dirname, 0);
if (wl) if (wl)
{ {
*dirname = string_list (wl); *dirname = string_list (wl);
@ -1612,11 +1627,13 @@ bash_directory_completion_hook (dirname)
actually expanded something. */ actually expanded something. */
return_value = STREQ (local_dirname, *dirname) == 0; return_value = STREQ (local_dirname, *dirname) == 0;
free (local_dirname); free (local_dirname);
free (new_dirname);
dispose_words (wl); dispose_words (wl);
local_dirname = *dirname; local_dirname = *dirname;
} }
else else
{ {
free (new_dirname);
free (local_dirname); free (local_dirname);
*dirname = xmalloc (1); *dirname = xmalloc (1);
**dirname = '\0'; **dirname = '\0';

View file

@ -1,10 +1,11 @@
# This Makefile for building libbuiltins.a is in -*- text -*- for Emacs. # This Makefile for building libbuiltins.a is in -*- text -*- for Emacs.
# #
SHELL = /bin/sh SHELL = @MAKE_SHELL@
RANLIB = @RANLIB@ RANLIB = @RANLIB@
CC = @CC@ CC = @CC@
CC_FOR_BUILD = @CC_FOR_BUILD@ CC_FOR_BUILD = @CC_FOR_BUILD@
AR = @AR@ AR = @AR@
ARFLAGS = @ARFLAGS@
RM = rm -f RM = rm -f
CP = cp CP = cp
@ -24,7 +25,7 @@ LDFLAGS = @LDFLAGS@ $(LOCAL_LDFLAGS) $(CFLAGS)
LOCAL_LDFLAGS = @LOCAL_LDFLAGS@ LOCAL_LDFLAGS = @LOCAL_LDFLAGS@
LIBS = @LIBS@ LIBS = @LIBS@
INCLUDES = -I. -I.. -I$(topdir) -I$(topdir)/lib -I$(srcdir) INCLUDES = -I. -I.. @RL_INCLUDE@ -I$(topdir) -I$(topdir)/lib -I$(srcdir)
CCFLAGS = ${PROFILE_FLAGS} $(DEFS) $(LOCAL_DEFS) $(SYSTEM_FLAGS) $(CPPFLAGS) \ CCFLAGS = ${PROFILE_FLAGS} $(DEFS) $(LOCAL_DEFS) $(SYSTEM_FLAGS) $(CPPFLAGS) \
${INCLUDES} $(LOCAL_CFLAGS) $(CFLAGS) ${INCLUDES} $(LOCAL_CFLAGS) $(CFLAGS)
@ -87,7 +88,7 @@ all: $(MKBUILTINS) libbuiltins.a
libbuiltins.a: $(MKBUILTINS) $(OFILES) builtins.o libbuiltins.a: $(MKBUILTINS) $(OFILES) builtins.o
$(RM) $@ $(RM) $@
$(AR) cr $@ $(OFILES) $(AR) $(ARFLAGS) $@ $(OFILES)
-$(RANLIB) $@ -$(RANLIB) $@
builtext.h builtins.c: $(MKBUILTINS) $(DEFSRC) builtext.h builtins.c: $(MKBUILTINS) $(DEFSRC)
@ -95,12 +96,12 @@ builtext.h builtins.c: $(MKBUILTINS) $(DEFSRC)
@-if test -f builtext.h; then mv -f builtext.h old-builtext.h; fi @-if test -f builtext.h; then mv -f builtext.h old-builtext.h; fi
./$(MKBUILTINS) -externfile builtext.h -structfile builtins.c \ ./$(MKBUILTINS) -externfile builtext.h -structfile builtins.c \
-noproduction $(DIRECTDEFINE) $(DEFSRC) -noproduction $(DIRECTDEFINE) $(DEFSRC)
@-if cmp -s old-builtext.h builtext.h; then \ @-if cmp -s old-builtext.h builtext.h 2>/dev/null; then \
mv old-builtext.h builtext.h; \ mv old-builtext.h builtext.h; \
else \ else \
$(RM) old-builtext.h; \ $(RM) old-builtext.h; \
fi fi
@-if cmp -s old-builtins.c builtins.c; then \ @-if cmp -s old-builtins.c builtins.c 2>/dev/null; then \
mv old-builtins.c builtins.c; \ mv old-builtins.c builtins.c; \
else \ else \
$(RM) old-builtins.c; \ $(RM) old-builtins.c; \
@ -112,7 +113,7 @@ mkbuiltins.o: mkbuiltins.c
$(CC_FOR_BUILD) -c $(CCFLAGS) $< $(CC_FOR_BUILD) -c $(CCFLAGS) $<
mkbuiltins: mkbuiltins.o mkbuiltins: mkbuiltins.o
$(CC_FOR_BUILD) $(LDFLAGS) -o $(MKBUILTINS) mkbuiltins.o $(LIBS) $(CC_FOR_BUILD) $(PROFILE_FLAGS) $(LDFLAGS) -o $(MKBUILTINS) mkbuiltins.o $(LIBS)
# rules for deficient makes, like SunOS # rules for deficient makes, like SunOS
mkbuiltins.o: mkbuiltins.c mkbuiltins.o: mkbuiltins.c
@ -126,7 +127,7 @@ evalfile.o: evalfile.c
ulimit.o: pipesize.h ulimit.o: pipesize.h
pipesize.h: psize.aux pipesize.h: psize.aux
$(SHELL) $(srcdir)/psize.sh > pipesize.h $(SHELL) $(srcdir)/psize.sh > $@
psize.aux: psize.c psize.aux: psize.c
$(CC_FOR_BUILD) $(CCFLAGS) -o $@ $(srcdir)/psize.c $(CC_FOR_BUILD) $(CCFLAGS) -o $@ $(srcdir)/psize.c
@ -139,7 +140,7 @@ builtins.texi: $(MKBUILTINS)
./$(MKBUILTINS) -documentonly $(DEFSRC) ./$(MKBUILTINS) -documentonly $(DEFSRC)
clean: clean:
$(RM) $(OFILES) $(CREATED_FILES) $(MKBUILTINS) libbuiltins.a $(RM) $(OFILES) $(CREATED_FILES) $(MKBUILTINS) mkbuiltins.o libbuiltins.a
mostlyclean: mostlyclean:
$(RM) $(OFILES) libbuiltins.a $(RM) $(OFILES) libbuiltins.a

View file

@ -140,22 +140,20 @@ bindpwd (no_symlinks)
else else
dirname = get_working_directory ("cd"); dirname = get_working_directory ("cd");
bind_variable ("OLDPWD", get_string_value ("PWD"));
old_anm = array_needs_making; old_anm = array_needs_making;
tvar = bind_variable ("PWD", dirname); pwdvar = get_string_value ("PWD");
/* This is an efficiency hack. If PWD is exported, we will need to
remake the exported environment every time we change directories. tvar = bind_variable ("OLDPWD", pwdvar);
If there is no other reason to make the exported environment, just
update PWD in place and mark the exported environment as no longer
needing a remake. */
if (old_anm == 0 && array_needs_making && exported_p (tvar)) if (old_anm == 0 && array_needs_making && exported_p (tvar))
{ {
pwdvar = xmalloc (STRLEN (dirname) + 5); /* 5 = "PWD" + '=' + '\0' */ update_export_env_inplace ("OLDPWD=", 7, pwdvar);
strcpy (pwdvar, "PWD="); array_needs_making = 0;
if (dirname) }
strcpy (pwdvar + 4, dirname);
add_or_supercede_exported_var (pwdvar, 0); tvar = bind_variable ("PWD", dirname);
if (old_anm == 0 && array_needs_making && exported_p (tvar))
{
update_export_env_inplace ("PWD=", 4, dirname);
array_needs_making = 0; array_needs_making = 0;
} }
@ -243,7 +241,7 @@ cd_builtin (list)
{ {
/* Find directory in $CDPATH. */ /* Find directory in $CDPATH. */
path_index = 0; path_index = 0;
while ((path = extract_colon_unit (cdpath, &path_index))) while (path = extract_colon_unit (cdpath, &path_index))
{ {
/* OPT is 1 if the path element is non-empty */ /* OPT is 1 if the path element is non-empty */
opt = path[0] != '\0'; opt = path[0] != '\0';

View file

@ -26,17 +26,17 @@ $FUNCTION enable_builtin
$SHORT_DOC enable [-pnds] [-a] [-f filename] [name ...] $SHORT_DOC enable [-pnds] [-a] [-f filename] [name ...]
Enable and disable builtin shell commands. This allows Enable and disable builtin shell commands. This allows
you to use a disk command which has the same name as a shell you to use a disk command which has the same name as a shell
builtin. If -n is used, the NAMEs become disabled; otherwise builtin without specifying a full pathname. If -n is used, the
NAMEs are enabled. For example, to use the `test' found on your NAMEs become disabled; otherwise NAMEs are enabled. For example,
path instead of the shell builtin version, type `enable -n test'. to use the `test' found in $PATH instead of the shell builtin
On systems supporting dynamic loading, the -f option may be used version, type `enable -n test'. On systems supporting dynamic
to load new builtins from the shared object FILENAME. The -d loading, the -f option may be used to load new builtins from the
option will delete a builtin previously loaded with -f. If no shared object FILENAME. The -d option will delete a builtin
non-option names are given, or the -p option is supplied, a list previously loaded with -f. If no non-option names are given, or
of builtins is printed. The -a option means to print every builtin the -p option is supplied, a list of builtins is printed. The
with an indication of whether or not it is enabled. The -s option -a option means to print every builtin with an indication of whether
restricts the output to the Posix.2 `special' builtins. The -n or not it is enabled. The -s option restricts the output to the POSIX.2
option displays a list of all disabled builtins. `special' builtins. The -n option displays a list of all disabled builtins.
$END $END
#include <config.h> #include <config.h>
@ -391,6 +391,20 @@ delete_builtin (b)
shell_builtins = new_shell_builtins; shell_builtins = new_shell_builtins;
} }
/* Tenon's MachTen has a dlclose that doesn't return a value, so we
finesse it with a local wrapper. */
static int
local_dlclose (handle)
void *handle;
{
#if !defined (__MACHTEN__)
return (dlclose (handle));
#else /* __MACHTEN__ */
dlclose (handle);
return ((dlerror () != NULL) ? -1 : 0);
#endif /* __MACHTEN__ */
}
static int static int
dyn_unload_builtin (name) dyn_unload_builtin (name)
char *name; char *name;
@ -398,6 +412,7 @@ dyn_unload_builtin (name)
struct builtin *b; struct builtin *b;
void *handle; void *handle;
int ref, i; int ref, i;
char *uerror;
b = builtin_address_internal (name, 1); b = builtin_address_internal (name, 1);
if (b == 0) if (b == 0)
@ -420,7 +435,7 @@ dyn_unload_builtin (name)
/* Don't remove the shared object unless the reference count of builtins /* Don't remove the shared object unless the reference count of builtins
using it drops to zero. */ using it drops to zero. */
if (ref == 1 && dlclose (handle) != 0) if (ref == 1 && local_dlclose (handle) != 0)
{ {
builtin_error ("cannot delete %s: %s", name, dlerror ()); builtin_error ("cannot delete %s: %s", name, dlerror ());
return (EXECUTION_FAILURE); return (EXECUTION_FAILURE);

View file

@ -51,6 +51,8 @@
extern int errno; extern int errno;
#endif #endif
#define IS_BUILTIN(s) (builtin_address_internal(s, 0) != (struct builtin *)NULL)
extern void run_trap_cleanup (); extern void run_trap_cleanup ();
extern int interactive, interactive_shell; extern int interactive, interactive_shell;
@ -181,7 +183,7 @@ parse_and_execute (string, from_file, flags)
} }
default: default:
programming_error ("parse_and_execute: bad jump: code %d", code); command_error ("parse_and_execute", CMDERR_BADJUMP, code, 0);
break; break;
} }
} }
@ -206,9 +208,20 @@ parse_and_execute (string, from_file, flags)
global_command = (COMMAND *)NULL; global_command = (COMMAND *)NULL;
#if defined (ONESHOT) #if defined (ONESHOT)
if (startup_state == 2 && *bash_input.location.string == '\0' && /*
command->type == cm_simple && !command->redirects && * IF
!command->value.Simple->redirects && * we were invoked as `bash -c' (startup_state == 2) AND
* parse_and_execute has not been called recursively AND
* we have parsed the full command (string == '\0') AND
* we have a simple command without redirections AND
* the command is not being timed
* THEN
* tell the execution code that we don't need to fork
*/
if (startup_state == 2 && parse_and_execute_level == 1 &&
*bash_input.location.string == '\0' &&
command->type == cm_simple &&
!command->redirects && !command->value.Simple->redirects &&
((command->flags & CMD_TIME_PIPELINE) == 0)) ((command->flags & CMD_TIME_PIPELINE) == 0))
{ {
command->flags |= CMD_NO_FORK; command->flags |= CMD_NO_FORK;

View file

@ -26,13 +26,13 @@ $FUNCTION fc_builtin
$DEPENDS_ON HISTORY $DEPENDS_ON HISTORY
$SHORT_DOC fc [-e ename] [-nlr] [first] [last] or fc -s [pat=rep] [cmd] $SHORT_DOC fc [-e ename] [-nlr] [first] [last] or fc -s [pat=rep] [cmd]
fc is used to list or edit and re-execute commands from the history list.
FIRST and LAST can be numbers specifying the range, or FIRST can be a FIRST and LAST can be numbers specifying the range, or FIRST can be a
string, which means the most recent command beginning with that string, which means the most recent command beginning with that
string. string.
-e ENAME selects which editor to use. Default is FCEDIT, then EDITOR, -e ENAME selects which editor to use. Default is FCEDIT, then EDITOR,
then the editor which corresponds to the current readline editing then vi.
mode, then vi.
-l means list lines instead of editing. -l means list lines instead of editing.
-n means no line numbers listed. -n means no line numbers listed.
@ -156,7 +156,7 @@ fc_builtin (list)
register int i; register int i;
register char *sep; register char *sep;
int numbering, reverse, listing, execute; int numbering, reverse, listing, execute;
int histbeg, histend, last_hist, retval, first, opt; int histbeg, histend, last_hist, retval, opt;
FILE *stream; FILE *stream;
REPL *rlist, *rl; REPL *rlist, *rl;
char *ename, *command, *newcom, *line; char *ename, *command, *newcom, *line;
@ -372,64 +372,11 @@ fc_builtin (list)
return (EXECUTION_FAILURE); return (EXECUTION_FAILURE);
} }
/* Now reopen the file and execute the edited commands. */
stream = fopen (fn, "r");
if (stream == NULL)
{
builtin_error ("cannot reopen temp file %s", fn);
unlink (fn);
return (EXECUTION_FAILURE);
}
retval = EXECUTION_SUCCESS;
first = 1;
#if 1
/* Make sure parse_and_execute doesn't turn this off, even though a /* Make sure parse_and_execute doesn't turn this off, even though a
call to parse_and_execute farther up the function call stack (e.g., call to parse_and_execute farther up the function call stack (e.g.,
if this is called by vi_edit_and_execute_command) may have already if this is called by vi_edit_and_execute_command) may have already
called bash_history_disable. */ called bash_history_disable. */
remember_on_history = 1; remember_on_history = 1;
#else
/* First, write the commands to the history file. This will not happen
when we call parse_and_execute, since parse_and_execute disables
the command line history while it executes. */
opt = current_command_line_count;
while ((line = fc_readline (stream)) != NULL)
{
if (line[0] == '\n')
{
free (line);
continue; /* Skip blank lines. */
}
if (first)
{
first = 0;
/* If we retrieved only one command from the history file, but we
read multiple lines from the edited file, and literal_history
has been set by `shopt', we assume that it was a compound
command stored with embedded newlines. In this case, we want
the history code to store it as one command again. */
if (literal_history && histbeg == histend)
current_command_line_count = 1;
fc_replhist (line);
}
else
{
if (literal_history && histbeg == histend)
current_command_line_count++;
fc_addhist (line);
}
free (line);
}
fclose (stream);
current_command_line_count = opt;
#endif
/* Turn on the `v' flag while fc_execute_file runs so the commands /* Turn on the `v' flag while fc_execute_file runs so the commands
will be echoed as they are read by the parser. */ will be echoed as they are read by the parser. */

View file

@ -232,6 +232,19 @@ sh_getopt_restore_state (argv)
nextchar = argv[sh_curopt] + sh_charindex; nextchar = argv[sh_curopt] + sh_charindex;
} }
#if 0
void
sh_getopt_debug_restore_state (argv)
char **argv;
{
if (nextchar && nextchar != argv[sh_curopt] + sh_charindex)
{
itrace("sh_getopt_debug_restore_state: resetting nextchar");
nextchar = argv[sh_curopt] + sh_charindex;
}
}
#endif
#ifdef TEST #ifdef TEST
/* Compile with -DTEST to make an executable for use in testing /* Compile with -DTEST to make an executable for use in testing

View file

@ -181,6 +181,8 @@ dogetopts (argc, argv)
{ {
for (i = 0; i < 10 && dollar_vars[i]; i++) for (i = 0; i < 10 && dollar_vars[i]; i++)
; ;
sh_getopt_restore_state (dollar_vars);
ret = sh_getopt (i, dollar_vars, optstr); ret = sh_getopt (i, dollar_vars, optstr);
} }
else else
@ -198,6 +200,7 @@ dogetopts (argc, argv)
for (words = rest_of_args; words; words = words->next, 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; v[i] = (char *)NULL;
sh_getopt_restore_state (v);
ret = sh_getopt (i, v, optstr); ret = sh_getopt (i, v, optstr);
free (v); free (v);
} }

View file

@ -130,6 +130,10 @@ char *assignment_builtins[] =
static int is_special_builtin (); static int is_special_builtin ();
static int is_assignment_builtin (); static int is_assignment_builtin ();
#if !defined (HAVE_RENAME)
static int rename ();
#endif
void extract_info (); void extract_info ();
void file_error (); void file_error ();
@ -265,8 +269,7 @@ main (argc, argv)
{ {
write_longdocs (structfile, saved_builtins); write_longdocs (structfile, saved_builtins);
fclose (structfile); fclose (structfile);
link (temp_struct_filename, struct_filename); rename (temp_struct_filename, struct_filename);
unlink (temp_struct_filename);
} }
if (externfile) if (externfile)
@ -457,6 +460,10 @@ extract_info (filename, structfile, externfile)
if ((nr = read (fd, buffer, file_size)) < 0) if ((nr = read (fd, buffer, file_size)) < 0)
file_error (filename); file_error (filename);
/* This is needed on WIN32, and does not hurt on Unix. */
if (nr < file_size)
file_size = nr;
close (fd); close (fd);
if (nr == 0) if (nr == 0)
@ -1395,3 +1402,16 @@ is_assignment_builtin (name)
{ {
return (_find_in_table (name, assignment_builtins)); return (_find_in_table (name, assignment_builtins));
} }
#if !defined (HAVE_RENAME)
static int
rename (from, to)
char *from, *to;
{
unlink (to);
if (link (from, to) < 0)
return (-1);
unlink (from);
return (0);
}
#endif /* !HAVE_RENAME */

View file

@ -99,7 +99,7 @@ int
printf_builtin (list) printf_builtin (list)
WORD_LIST *list; WORD_LIST *list;
{ {
int ch, end, fieldwidth, precision, foundmod; int ch, end, fieldwidth, precision, foundmod, fmtlen;
char convch, nextch, *format, *fmt, *start; char convch, nextch, *format, *fmt, *start;
retval = EXECUTION_SUCCESS; retval = EXECUTION_SUCCESS;
@ -125,12 +125,12 @@ printf_builtin (list)
if (list->word->word == 0 || list->word->word[0] == '\0') if (list->word->word == 0 || list->word->word[0] == '\0')
return (EXECUTION_SUCCESS); return (EXECUTION_SUCCESS);
format = ansicstr (list->word->word, strlen (list->word->word), (int *)NULL, (int *)NULL); format = ansicstr (list->word->word, strlen (list->word->word), (int *)NULL, &fmtlen);
garglist = list->next; garglist = list->next;
/* If the format string is empty after preprocessing, return immediately. */ /* If the format string is empty after preprocessing, return immediately. */
if (format == 0 || *format == 0) if ((format == 0 || *format == 0) && fmtlen == 0)
return (EXECUTION_SUCCESS); return (EXECUTION_SUCCESS);
/* Basic algorithm is to scan the format string for conversion /* Basic algorithm is to scan the format string for conversion
@ -139,11 +139,12 @@ printf_builtin (list)
format strings are reused as necessary to use up the provided format strings are reused as necessary to use up the provided
arguments, arguments of zero/null string are provided to use arguments, arguments of zero/null string are provided to use
up the format string. */ up the format string. */
#define FMTIND (fmt - format)
do do
{ {
/* find next format specification */ /* find next format specification */
for (fmt = format; *fmt; fmt++) for (fmt = format; FMTIND < fmtlen; fmt++)
{ {
precision = fieldwidth = foundmod = 0; precision = fieldwidth = foundmod = 0;
@ -179,11 +180,6 @@ printf_builtin (list)
/* skip to conversion char */ /* skip to conversion char */
for (; *fmt && strchr(SKIP2, *fmt); ++fmt) for (; *fmt && strchr(SKIP2, *fmt); ++fmt)
; ;
if (*fmt == 0)
{
builtin_error ("`%s': missing format character", start);
PRETURN (EXECUTION_FAILURE);
}
/* skip possible format modifiers */ /* skip possible format modifiers */
if (*fmt == 'l' || *fmt == 'L' || *fmt == 'h') if (*fmt == 'l' || *fmt == 'L' || *fmt == 'h')
@ -192,6 +188,12 @@ printf_builtin (list)
foundmod = 1; foundmod = 1;
} }
if (*fmt == 0)
{
builtin_error ("`%s': missing format character", start);
PRETURN (EXECUTION_FAILURE);
}
convch = *fmt; convch = *fmt;
nextch = fmt[1]; nextch = fmt[1];
fmt[1] = '\0'; fmt[1] = '\0';

View file

@ -117,6 +117,10 @@ $END
#include "common.h" #include "common.h"
#include "builtext.h" #include "builtext.h"
#ifdef LOADABLE_BUILTIN
# include "builtins.h"
#endif
#if !defined (errno) #if !defined (errno)
extern int errno; extern int errno;
#endif /* !errno */ #endif /* !errno */
@ -642,4 +646,98 @@ get_directory_stack ()
free (d); free (d);
return ret; /* was (REVERSE_LIST (ret, (WORD_LIST *)); */ return ret; /* was (REVERSE_LIST (ret, (WORD_LIST *)); */
} }
#ifdef LOADABLE_BUILTIN
static char *dirs_doc[] = {
"Display the list of currently remembered directories. Directories",
"find their way onto the list with the `pushd' command; you can get",
"back up through the list with the `popd' command.",
"",
"The -l flag specifies that `dirs' should not print shorthand versions",
"of directories which are relative to your home directory. This means",
"that `~/bin' might be displayed as `/homes/bfox/bin'. The -v flag",
"causes `dirs' to print the directory stack with one entry per line,",
"prepending the directory name with its position in the stack. The -p",
"flag does the same thing, but the stack position is not prepended.",
"The -c flag clears the directory stack by deleting all of the elements.",
"",
"+N displays the Nth entry counting from the left of the list shown by",
" dirs when invoked without options, starting with zero.",
"",
"-N displays the Nth entry counting from the right of the list shown by",
" dirs when invoked without options, starting with zero.",
(char *)NULL
};
static char *pushd_doc[] = {
"Adds a directory to the top of the directory stack, or rotates",
"the stack, making the new top of the stack the current working",
"directory. With no arguments, exchanges the top two directories.",
"",
"+N Rotates the stack so that the Nth directory (counting",
" from the left of the list shown by `dirs', starting with",
" zero) is at the top.",
"",
"-N Rotates the stack so that the Nth directory (counting",
" from the right of the list shown by `dirs', starting with",
" zero) is at the top.",
"",
"-n suppress the normal change of directory when adding directories",
" to the stack, so only the stack is manipulated.",
"",
"dir adds DIR to the directory stack at the top, making it the",
" new current working directory.",
"",
"You can see the directory stack with the `dirs' command.",
(char *)NULL
};
static char *popd_doc[] = {
"Removes entries from the directory stack. With no arguments,",
"removes the top directory from the stack, and cd's to the new",
"top directory.",
"",
"+N removes the Nth entry counting from the left of the list",
" shown by `dirs', starting with zero. For example: `popd +0'",
" removes the first directory, `popd +1' the second.",
"",
"-N removes the Nth entry counting from the right of the list",
" shown by `dirs', starting with zero. For example: `popd -0'",
" removes the last directory, `popd -1' the next to last.",
"",
"-n suppress the normal change of directory when removing directories",
" from the stack, so only the stack is manipulated.",
"",
"You can see the directory stack with the `dirs' command.",
(char *)NULL
};
struct builtin pushd_struct = {
"pushd",
pushd_builtin,
BUILTIN_ENABLED,
pushd_doc,
"pushd [+N | -N] [-n] [dir]",
0
};
struct builtin popd_struct = {
"popd",
popd_builtin,
BUILTIN_ENABLED,
popd_doc,
"popd [+N | -N] [-n]",
0
};
struct builtin dirs_struct = {
"dirs",
dirs_builtin,
BUILTIN_ENABLED,
dirs_doc,
"dirs [-clpv] [+N] [-N]",
0
};
#endif /* LOADABLE_BUILTIN */
#endif /* PUSHD_AND_POPD */ #endif /* PUSHD_AND_POPD */

View file

@ -189,6 +189,7 @@ read_builtin (list)
c = rlbuf[rlind++]; c = rlbuf[rlind++];
} }
else else
{
#endif #endif
while (((retval = read (0, &c, 1)) < 0) && errno == EINTR) while (((retval = read (0, &c, 1)) < 0) && errno == EINTR)
@ -199,6 +200,10 @@ read_builtin (list)
break; break;
} }
#if defined (READLINE)
}
#endif
if (i + 2 >= size) if (i + 2 >= size)
input_string = xrealloc (input_string, size += 128); input_string = xrealloc (input_string, size += 128);

View file

@ -89,7 +89,7 @@ $END
$BUILTIN { ... } $BUILTIN { ... }
$DOCNAME grouping_braces $DOCNAME grouping_braces
$SHORT_DOC { COMMANDS } $SHORT_DOC { COMMANDS ; }
Run a set of commands in a group. This is one way to redirect an Run a set of commands in a group. This is one way to redirect an
entire set of commands. entire set of commands.
$END $END

View file

@ -92,7 +92,7 @@ $SHORT_DOC set [--abefhkmnptuvxBCHP] [-o option] [arg ...]
noclobber same as -C noclobber same as -C
noexec same as -n noexec same as -n
noglob same as -f noglob same as -f
notify save as -b notify same as -b
nounset same as -u nounset same as -u
onecmd same as -t onecmd same as -t
physical same as -P physical same as -P

View file

@ -79,10 +79,19 @@ extern int hist_verify, history_reediting, perform_hostname_completion;
extern void enable_hostname_completion (); extern void enable_hostname_completion ();
#endif #endif
#if defined (RESTRICTED_SHELL)
extern int restricted_shell;
extern char *shell_name;
#endif
extern void set_shellopts (); extern void set_shellopts ();
static int set_interactive_comments (); static int set_interactive_comments ();
#if defined (RESTRICTED_SHELL)
static int set_restricted_shell ();
#endif
static struct { static struct {
char *name; char *name;
int *value; int *value;
@ -120,6 +129,9 @@ static struct {
{ "nocaseglob", &glob_ignore_case, (Function *)NULL }, { "nocaseglob", &glob_ignore_case, (Function *)NULL },
{ "nullglob", &allow_null_glob_expansion, (Function *)NULL }, { "nullglob", &allow_null_glob_expansion, (Function *)NULL },
{ "promptvars", &promptvars, (Function *)NULL }, { "promptvars", &promptvars, (Function *)NULL },
#if defined (RESTRICTED_SHELL)
{ "restricted_shell", &restricted_shell, set_restricted_shell },
#endif
{ "shift_verbose", &print_shift_error, (Function *)NULL }, { "shift_verbose", &print_shift_error, (Function *)NULL },
{ "sourcepath", &source_uses_path, (Function *)NULL }, { "sourcepath", &source_uses_path, (Function *)NULL },
{ (char *)0, (int *)0, (Function *)NULL } { (char *)0, (int *)0, (Function *)NULL }
@ -262,7 +274,7 @@ toggle_shopts (mode, list, quiet)
return (rval); return (rval);
} }
static int static void
print_shopt (name, val, flags) print_shopt (name, val, flags)
char *name; char *name;
int val, flags; int val, flags;
@ -400,3 +412,20 @@ set_interactive_comments (mode)
set_shellopts (); set_shellopts ();
return (0); return (0);
} }
#if defined (RESTRICTED_SHELL)
/* Don't allow the value of restricted_shell to be modified. */
static int
set_restricted_shell (mode)
int mode;
{
static int save_restricted = -1;
if (save_restricted == -1)
save_restricted = shell_is_restricted (shell_name);
restricted_shell = save_restricted;
return (0);
}
#endif /* RESTRICTED_SHELL */

View file

@ -129,7 +129,10 @@ test_builtin (list)
if (list == 0) if (list == 0)
{ {
if (this_command_name[0] == '[' && !this_command_name[1]) if (this_command_name[0] == '[' && !this_command_name[1])
builtin_error ("missing `]'"); {
builtin_error ("missing `]'");
return (EX_BADUSAGE);
}
return (EXECUTION_FAILURE); return (EXECUTION_FAILURE);
} }

View file

@ -62,6 +62,7 @@ $END
#endif /* ALIAS */ #endif /* ALIAS */
#include "common.h" #include "common.h"
#include "bashgetopt.h"
extern int find_reserved_word (); extern int find_reserved_word ();
@ -69,14 +70,14 @@ extern int find_reserved_word ();
it as a simple command. i.e., which file would this shell use to it as a simple command. i.e., which file would this shell use to
execve, or if it is a builtin command, or an alias. Possible flag execve, or if it is a builtin command, or an alias. Possible flag
arguments: arguments:
-type Returns the "type" of the object, one of -t Returns the "type" of the object, one of
`alias', `keyword', `function', `builtin', `alias', `keyword', `function', `builtin',
or `file'. or `file'.
-path Returns the pathname of the file if -type is -p Returns the pathname of the file if -type is
a file. a file.
-all Returns all occurrences of words, whether they -a Returns all occurrences of words, whether they
be a filename in the path, alias, function, be a filename in the path, alias, function,
or builtin. or builtin.
Order of evaluation: Order of evaluation:
@ -86,12 +87,14 @@ extern int find_reserved_word ();
builtin builtin
file file
*/ */
int int
type_builtin (list) type_builtin (list)
WORD_LIST *list; WORD_LIST *list;
{ {
int path_only, type_only, all, verbose; int path_only, type_only, all, verbose;
int successful_finds; int successful_finds, opt;
WORD_LIST *prev, *this;
if (list == 0) if (list == 0)
return (EXECUTION_SUCCESS); return (EXECUTION_SUCCESS);
@ -99,32 +102,69 @@ type_builtin (list)
path_only = type_only = all = 0; path_only = type_only = all = 0;
successful_finds = 0; successful_finds = 0;
while (list && *(list->word->word) == '-') /* Handle the obsolescent `-type', `-path', and `-all' by prescanning
the arguments and removing those options from the list before calling
internal_getopt. Recognize `--type', `--path', and `--all' also.
THIS SHOULD REALLY GO AWAY. */
for (this = list; this && this->word->word[0] == '-'; )
{ {
char *flag = &(list->word->word[1]); char *flag = &(this->word->word[1]);
if (flag[0] == 't' && (!flag[1] || strcmp (flag + 1, "ype") == 0)) if (STREQ (flag, "type") || STREQ (flag, "-type"))
{ {
type_only = 1; type_only = 1;
path_only = 0; path_only = 0;
} }
else if (flag[0] == 'p' && (!flag[1] || strcmp (flag + 1, "ath") == 0)) else if (STREQ (flag, "path") || STREQ (flag, "-path"))
{ {
path_only = 1; path_only = 1;
type_only = 0; type_only = 0;
} }
else if (flag[0] == 'a' && (!flag[1] || strcmp (flag + 1, "ll") == 0)) else if (STREQ (flag, "all") || STREQ (flag, "-all"))
{ all = 1;
all = 1;
}
else else
{ {
bad_option (flag); prev = this;
this = this->next;
continue;
}
/* We found a long option; remove it from the argument list. Don't
free it if it's the head of the argument list, though -- the
argument list will be freed by the caller. */
if (this == list)
this = list = list->next;
else
{
prev->next = this->next;
this->next = (WORD_LIST *)NULL;
dispose_words (this);
this = prev->next;
}
}
reset_internal_getopt ();
while ((opt = internal_getopt (list, "apt")) != -1)
{
switch (opt)
{
case 't':
type_only = 1;
path_only = 0;
break;
case 'p':
path_only = 1;
type_only = 0;
break;
case 'a':
all = 1;
break;
default:
builtin_usage (); builtin_usage ();
return (EX_USAGE); return (EX_USAGE);
} }
list = list->next;
} }
list = loptend;
if (type_only) if (type_only)
verbose = 1; verbose = 1;
@ -150,10 +190,7 @@ type_builtin (list)
fflush (stdout); fflush (stdout);
if (successful_finds != 0) return ((successful_finds != 0) ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
return (EXECUTION_SUCCESS);
else
return (EXECUTION_FAILURE);
} }
/* /*
@ -202,7 +239,7 @@ describe_command (command, verbose, all)
found = 1; found = 1;
if (!all) if (all == 0)
return (1); return (1);
} }
#endif /* ALIAS */ #endif /* ALIAS */
@ -220,7 +257,7 @@ describe_command (command, verbose, all)
found = 1; found = 1;
if (!all) if (all == 0)
return (1); return (1);
} }
@ -251,7 +288,7 @@ describe_command (command, verbose, all)
found = 1; found = 1;
if (!all) if (all == 0)
return (1); return (1);
} }
@ -267,7 +304,7 @@ describe_command (command, verbose, all)
found = 1; found = 1;
if (!all) if (all == 0)
return (1); return (1);
} }
@ -293,9 +330,9 @@ describe_command (command, verbose, all)
} }
} }
/* If the user isn't doing "-all", then we might care about /* If the user isn't doing "-a", then we might care about
whether the file is present in our hash table. */ whether the file is present in our hash table. */
if (!all) if (all == 0)
{ {
if ((full_path = find_hashed_filename (command)) != (char *)NULL) if ((full_path = find_hashed_filename (command)) != (char *)NULL)
{ {
@ -314,7 +351,7 @@ describe_command (command, verbose, all)
/* Now search through $PATH. */ /* Now search through $PATH. */
while (1) while (1)
{ {
if (!all) if (all == 0)
full_path = find_user_command (command); full_path = find_user_command (command);
else else
full_path = full_path =
@ -337,7 +374,7 @@ describe_command (command, verbose, all)
free (full_path); free (full_path);
full_path = (char *)NULL; full_path = (char *)NULL;
if (!all) if (all == 0)
break; break;
} }

View file

@ -154,24 +154,20 @@ extern int errno;
# define RLIM_INFINITY 0x7fffffff # define RLIM_INFINITY 0x7fffffff
#endif #endif
#if !defined (RLIM_INVALID)
# define RLIM_INVALID (RLIMTYPE)-1
#endif
#define LIMIT_HARD 0x01 #define LIMIT_HARD 0x01
#define LIMIT_SOFT 0x02 #define LIMIT_SOFT 0x02
static int ulimit_internal (); static int ulimit_internal __P((int, char *, int, int));
static void printone (); static void printone __P((int, RLIMTYPE, int));
static void print_all_limits (); static void print_all_limits __P((int));
static int get_limit (); static int get_limit __P((int, int, RLIMTYPE *));
static int set_limit (); static int set_limit __P((int, RLIMTYPE, int));
static RLIMTYPE filesize (); static int filesize __P((RLIMTYPE *));
static RLIMTYPE pipesize (); static int pipesize __P((RLIMTYPE *));
static RLIMTYPE getmaxuprc (); static int getmaxuprc __P((int, RLIMTYPE *));
static RLIMTYPE getmaxvm (); static int getmaxvm __P((int, RLIMTYPE *));
typedef struct { typedef struct {
int option; /* The ulimit option for this limit. */ int option; /* The ulimit option for this limit. */
@ -351,7 +347,6 @@ ulimit_internal (cmd, cmdarg, mode, multiple)
long block_factor; long block_factor;
RLIMTYPE current_limit, real_limit, limit; RLIMTYPE current_limit, real_limit, limit;
limit = RLIM_INVALID;
setting = cmdarg != 0; setting = cmdarg != 0;
limind = _findlim (cmd); limind = _findlim (cmd);
if (mode == 0) if (mode == 0)
@ -412,26 +407,30 @@ get_limit (ind, mode, limptr)
switch (limits[ind].parameter) switch (limits[ind].parameter)
{ {
case RLIMIT_FILESIZE: case RLIMIT_FILESIZE:
value = filesize (); if (filesize (&value) < 0)
return -1;
break; break;
case RLIMIT_PIPESIZE: case RLIMIT_PIPESIZE:
value = pipesize (); if (pipesize (&value) < 0)
return -1;
break; break;
case RLIMIT_OPENFILES: case RLIMIT_OPENFILES:
value = (RLIMTYPE)getdtablesize (); value = (RLIMTYPE)getdtablesize ();
break; break;
case RLIMIT_VIRTMEM: case RLIMIT_VIRTMEM:
value = getmaxvm (mode); if (getmaxvm (mode, &value) < 0)
return -1;
break; break;
case RLIMIT_MAXUPROC: case RLIMIT_MAXUPROC:
value = getmaxuprc (mode); if (getmaxuprc (mode, &value) < 0)
return -1;
break; break;
default: default:
errno = EINVAL; errno = EINVAL;
return -1; return -1;
} }
*limptr = value; *limptr = value;
return ((value == RLIM_INVALID) ? -1 : 0); return (0);
} }
else else
{ {
@ -439,6 +438,11 @@ get_limit (ind, mode, limptr)
if (getrlimit (limits[ind].parameter, &limit) < 0) if (getrlimit (limits[ind].parameter, &limit) < 0)
return -1; return -1;
value = (mode & LIMIT_SOFT) ? limit.rlim_cur : limit.rlim_max; value = (mode & LIMIT_SOFT) ? limit.rlim_cur : limit.rlim_max;
# if defined (HPUX9)
if (limits[ind].parameter == RLIMIT_FILESIZE)
*limptr = value * 512; /* Ugh. */
else
# endif /* HPUX9 */
*limptr = value; *limptr = value;
return 0; return 0;
#else #else
@ -486,6 +490,10 @@ set_limit (ind, newlim, mode)
#if defined (HAVE_RESOURCE) #if defined (HAVE_RESOURCE)
if (getrlimit (limits[ind].parameter, &limit) < 0) if (getrlimit (limits[ind].parameter, &limit) < 0)
return -1; return -1;
# if defined (HPUX9)
if (limits[ind].parameter == RLIMIT_FILESIZE)
newlim /= 512; /* Ugh. */
# endif /* HPUX9 */
val = (current_user.euid != 0 && newlim == RLIM_INFINITY && val = (current_user.euid != 0 && newlim == RLIM_INFINITY &&
(limit.rlim_cur <= limit.rlim_max)) (limit.rlim_cur <= limit.rlim_max))
? limit.rlim_max : newlim; ? limit.rlim_max : newlim;
@ -502,72 +510,91 @@ set_limit (ind, newlim, mode)
} }
} }
static RLIMTYPE static int
getmaxvm (mode) getmaxvm (mode, valuep)
int mode; int mode;
RLIMTYPE *valuep;
{ {
#if defined (HAVE_RESOURCE) #if defined (HAVE_RESOURCE)
struct rlimit rl; struct rlimit rl;
RLIMTYPE maxdata, maxstack; RLIMTYPE maxdata, maxstack;
if (getrlimit (RLIMIT_DATA, &rl) < 0) if (getrlimit (RLIMIT_DATA, &rl) < 0)
return (RLIM_INVALID); return -1;
else else
maxdata = (mode & LIMIT_SOFT) ? rl.rlim_cur : rl.rlim_max; maxdata = (mode & LIMIT_SOFT) ? rl.rlim_cur : rl.rlim_max;
if (getrlimit (RLIMIT_STACK, &rl) < 0) if (getrlimit (RLIMIT_STACK, &rl) < 0)
return (RLIM_INVALID); return -1;
else else
maxstack = (mode & LIMIT_SOFT) ? rl.rlim_cur : rl.rlim_max; maxstack = (mode & LIMIT_SOFT) ? rl.rlim_cur : rl.rlim_max;
/* Protect against overflow. */ /* Protect against overflow. */
return ((maxdata / 1024L) + (maxstack / 1024L)); *valuep = (maxdata / 1024L) + (maxstack / 1024L);
return 0;
#else #else
errno = EINVAL; errno = EINVAL;
return RLIM_INVALID; return -1;
#endif /* HAVE_RESOURCE */ #endif /* HAVE_RESOURCE */
} }
static RLIMTYPE static int
filesize() filesize(valuep)
RLIMTYPE *valuep;
{ {
#if !defined (HAVE_RESOURCE) #if !defined (HAVE_RESOURCE)
return ((RLIMTYPE)ulimit (1, 0L)); long result;
if ((result = ulimit (1, 0L)) < 0)
return -1;
else
*valuep = (RLIMTYPE) result;
return 0;
#else #else
errno = EINVAL; errno = EINVAL;
return RLIM_INVALID; return -1;
#endif #endif
} }
static RLIMTYPE static int
pipesize () pipesize (valuep)
RLIMTYPE *valuep;
{ {
#if defined (PIPE_BUF) #if defined (PIPE_BUF)
/* This is defined on Posix systems. */ /* This is defined on Posix systems. */
return ((RLIMTYPE) PIPE_BUF); *valuep = (RLIMTYPE) PIPE_BUF;
return 0;
#else #else
# if defined (PIPESIZE) # if defined (PIPESIZE)
/* This is defined by running a program from the Makefile. */ /* This is defined by running a program from the Makefile. */
return ((RLIMTYPE) PIPESIZE); *valuep = (RLIMTYPE) PIPESIZE;
return 0;
# else # else
errno = EINVAL; errno = EINVAL;
return RLIM_INVALID; return -1;
# endif /* PIPESIZE */ # endif /* PIPESIZE */
#endif /* PIPE_BUF */ #endif /* PIPE_BUF */
} }
static RLIMTYPE static int
getmaxuprc (mode) getmaxuprc (mode, valuep)
int mode; int mode;
RLIMTYPE *valuep;
{ {
# if defined (HAVE_SYSCONF) && defined (_SC_CHILD_MAX) # if defined (HAVE_SYSCONF) && defined (_SC_CHILD_MAX)
return ((RLIMTYPE)sysconf (_SC_CHILD_MAX)); long maxchild;
maxchild = sysconf (_SC_CHILD_MAX);
if (maxchild < 0)
return -1;
else
*valuep = (RLIMTYPE) maxchild;
return 0;
# else /* !HAVE_SYSCONF || !_SC_CHILD_MAX */ # else /* !HAVE_SYSCONF || !_SC_CHILD_MAX */
# if defined (MAXUPRC) # if defined (MAXUPRC)
return ((RLIMTYPE)MAXUPRC); *valuep = (RLIMTYPE) MAXUPRC;
return 0;
# else /* MAXUPRC */ # else /* MAXUPRC */
errno = EINVAL; errno = EINVAL;
return RLIM_INVALID; return -1;
# endif /* !MAXUPRC */ # endif /* !MAXUPRC */
# endif /* !HAVE_SYSCONF || !_SC_CHILD_MAX */ # endif /* !HAVE_SYSCONF || !_SC_CHILD_MAX */
} }
@ -585,8 +612,12 @@ print_all_limits (mode)
for (i = 0; limits[i].option > 0; i++) for (i = 0; limits[i].option > 0; i++)
{ {
if (get_limit (i, mode, &value) < 0) if (get_limit (i, mode, &value) < 0)
value = RLIM_INVALID; {
printone (i, value, 1); fprintf (stderr, DESCFMT, limits[i].description);
builtin_error ("cannot get limit: %s", strerror (errno));
}
else
printone (i, value, 1);
} }
} }
@ -600,8 +631,6 @@ printone (limind, curlim, pdesc)
printf (DESCFMT, limits[limind].description); printf (DESCFMT, limits[limind].description);
if (curlim == RLIM_INFINITY) if (curlim == RLIM_INFINITY)
puts ("unlimited"); puts ("unlimited");
else if (curlim == RLIM_INVALID)
builtin_error ("cannot get limit: %s\n", strerror (errno));
else else
print_rlimtype ((curlim / limits[limind].block_factor), 1); print_rlimtype ((curlim / limits[limind].block_factor), 1);
} }

View file

@ -174,29 +174,15 @@ print_symbolic_umask (um)
printf ("u=%s,g=%s,o=%s\n", ubits, gbits, obits); printf ("u=%s,g=%s,o=%s\n", ubits, gbits, obits);
} }
/* Set the umask from a symbolic mode string similar to that accepted int
by chmod. If the -S argument is given, then print the umask in a parse_symbolic_mode (mode, initial_bits)
symbolic form. */ char *mode;
static int int initial_bits;
symbolic_umask (list)
WORD_LIST *list;
{ {
int um, umc, c; int who, op, perm, mask, bits, c;
int who, op, perm, mask;
char *s; char *s;
/* Get the initial umask. Don't change it yet. */ for (s = mode, bits = initial_bits;;)
um = umask (022);
umask (um);
/* All work below is done with the complement of the umask -- it's
more intuitive and easier to deal with. It is complemented
again before being returned. */
umc = ~um;
s = list->word->word;
for (;;)
{ {
who = op = perm = mask = 0; who = op = perm = mask = 0;
@ -205,20 +191,20 @@ symbolic_umask (list)
{ {
switch (c = *s++) switch (c = *s++)
{ {
case 'u': case 'u':
who |= S_IRWXU; who |= S_IRWXU;
continue; continue;
case 'g': case 'g':
who |= S_IRWXG; who |= S_IRWXG;
continue; continue;
case 'o': case 'o':
who |= S_IRWXO; who |= S_IRWXO;
continue; continue;
case 'a': case 'a':
who |= S_IRWXU | S_IRWXG | S_IRWXO; who |= S_IRWXU | S_IRWXG | S_IRWXO;
continue; continue;
default: default:
break; break;
} }
} }
@ -226,13 +212,13 @@ symbolic_umask (list)
op = *s++; op = *s++;
switch (op) switch (op)
{ {
case '+': case '+':
case '-': case '-':
case '=': case '=':
break; break;
default: default:
builtin_error ("bad symbolic mode operator: %c", op); builtin_error ("bad symbolic mode operator: %c", op);
return (-1); return (-1);
} }
/* Parse out the `perm' section of the symbolic mode clause. */ /* Parse out the `perm' section of the symbolic mode clause. */
@ -242,17 +228,15 @@ symbolic_umask (list)
switch (c) switch (c)
{ {
case 'r': case 'r':
perm |= S_IRUGO; perm |= S_IRUGO;
break; break;
case 'w':
case 'w': perm |= S_IWUGO;
perm |= S_IWUGO; break;
break; case 'x':
perm |= S_IXUGO;
case 'x': break;
perm |= S_IXUGO;
break;
} }
} }
@ -265,32 +249,22 @@ symbolic_umask (list)
switch (op) switch (op)
{ {
case '+': case '+':
umc |= perm; bits |= perm;
break;
case '-':
umc &= ~perm;
break;
case '=':
umc &= ~who;
umc |= perm;
break;
#if 0
/* No other values are possible. */
default:
builtin_error ("bad symbolic mode operator: %c", op);
return (-1);
#endif
}
if (!*s)
{
um = ~umc & 0777;
break; break;
case '-':
bits &= ~perm;
break;
case '=':
bits &= ~who;
bits |= perm;
break;
/* No other values are possible. */
} }
if (*s == '\0')
break;
else else
s++; /* skip past ',' */ s++; /* skip past ',' */
} }
@ -300,5 +274,28 @@ symbolic_umask (list)
return (-1); return (-1);
} }
} }
return (bits);
}
/* Set the umask from a symbolic mode string similar to that accepted
by chmod. If the -S argument is given, then print the umask in a
symbolic form. */
static int
symbolic_umask (list)
WORD_LIST *list;
{
int um, bits;
/* Get the initial umask. Don't change it yet. */
um = umask (022);
umask (um);
/* All work is done with the complement of the umask -- it's
more intuitive and easier to deal with. It is complemented
again before being returned. */
bits = parse_symbolic_mode (list->word->word, ~um);
um = ~bits & 0777;
return (um); return (um);
} }

View file

@ -63,6 +63,7 @@ enum command_type { cm_for, cm_case, cm_while, cm_if, cm_simple, cm_select,
#define W_ASSIGNMENT 0x04 /* This word is a variable assignment. */ #define W_ASSIGNMENT 0x04 /* This word is a variable assignment. */
#define W_GLOBEXP 0x08 /* This word is the result of a glob expansion. */ #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_NOSPLIT 0x10 /* Do not perform word splitting on this word. */
#define W_NOGLOB 0x20 /* Do not perform globbing on this word. */
/* Possible values for subshell_environment */ /* Possible values for subshell_environment */
#define SUBSHELL_ASYNC 0x01 /* subshell caused by `command &' */ #define SUBSHELL_ASYNC 0x01 /* subshell caused by `command &' */
@ -268,6 +269,14 @@ typedef struct group_com {
extern COMMAND *global_command; extern COMMAND *global_command;
/* Possible command errors */
#define CMDERR_DEFAULT 0
#define CMDERR_BADTYPE 1
#define CMDERR_BADCONN 2
#define CMDERR_BADJUMP 3
#define CMDERR_LAST 3
/* Forward declarations of functions declared in copy_cmd.c. */ /* Forward declarations of functions declared in copy_cmd.c. */
extern WORD_DESC *copy_word __P((WORD_DESC *)); extern WORD_DESC *copy_word __P((WORD_DESC *));

View file

@ -65,3 +65,7 @@
#if defined (STRCOLL_BROKEN) #if defined (STRCOLL_BROKEN)
# undef HAVE_STRCOLL # undef HAVE_STRCOLL
#endif #endif
#if !defined (PROMPT_STRING_DECODE)
# define PPROMPT "$ "
#endif

View file

@ -122,9 +122,9 @@
#undef AFS #undef AFS
/* End of configuration settings controllable by autoconf. */ /* End of configuration settings controllable by autoconf. */
/* Other settable options appear in config.h.top. */ /* Other settable options appear in config-top.h. */
#include "config.h.top" #include "config-top.h"
/* Beginning of autoconf additions. */ /* Beginning of autoconf additions. */
@ -187,6 +187,9 @@
/* The number of bytes in a pointer to char. */ /* The number of bytes in a pointer to char. */
#undef SIZEOF_CHAR_P #undef SIZEOF_CHAR_P
/* The number of bytes in a double (hopefully 8). */
#undef SIZEOF_DOUBLE
/* Define to `long' if <sys/types.h> doesn't define. */ /* Define to `long' if <sys/types.h> doesn't define. */
#undef off_t #undef off_t
@ -208,6 +211,9 @@
/* Define to `int' if <sys/types.h> doesn't define. */ /* Define to `int' if <sys/types.h> doesn't define. */
#undef ptrdiff_t #undef ptrdiff_t
/* Define to `double' if <sys/types.h> doesn't define. */
#undef bits64_t
/* Define to `unsigned' if <sys/types.h> doesn't define. */ /* Define to `unsigned' if <sys/types.h> doesn't define. */
#undef size_t #undef size_t
@ -392,11 +398,18 @@
/* Define if you have the killpg function. */ /* Define if you have the killpg function. */
#undef HAVE_KILLPG #undef HAVE_KILLPG
/* Define if you have the lstat function. */
#undef HAVE_LSTAT #undef HAVE_LSTAT
/* Define if you have the putenv function. */ /* Define if you have the putenv function. */
#undef HAVE_PUTENV #undef HAVE_PUTENV
/* Define if you have the rename function. */
#undef HAVE_RENAME
/* Define if you have the sbrk function. */
#undef HAVE_SBRK
/* Define if you have the select function. */ /* Define if you have the select function. */
#undef HAVE_SELECT #undef HAVE_SELECT
@ -542,6 +555,9 @@
#undef HAVE_LIBSOCKET #undef HAVE_LIBSOCKET
/* Are we running SVR5 (UnixWare 7)? */
#undef SVR5
/* Are we running SVR4.2? */ /* Are we running SVR4.2? */
#undef SVR4_2 #undef SVR4_2
@ -555,6 +571,6 @@
/* Do strcoll(3) and strcmp(3) give different results in the default locale? */ /* Do strcoll(3) and strcmp(3) give different results in the default locale? */
#undef STRCOLL_BROKEN #undef STRCOLL_BROKEN
#include "config.h.bot" #include "config-bot.h"
#endif /* _CONFIG_H_ */ #endif /* _CONFIG_H_ */

1482
configure vendored

File diff suppressed because it is too large Load diff

View file

@ -1,12 +1,12 @@
dnl dnl
dnl Configure script for bash-2.02 dnl Configure script for bash-2.03
dnl dnl
dnl report bugs to chet@po.cwru.edu dnl report bugs to chet@po.cwru.edu
dnl dnl
dnl Process this file with autoconf to produce a configure script. dnl Process this file with autoconf to produce a configure script.
dnl checks for version info dnl checks for version info
AC_REVISION([for Bash 2.02, version 2.19, from autoconf version] AC_ACVERSION)dnl AC_REVISION([for Bash 2.03, version 2.49, from autoconf version] AC_ACVERSION)dnl
AC_INIT(shell.h) AC_INIT(shell.h)
AC_CONFIG_HEADER(config.h) AC_CONFIG_HEADER(config.h)
@ -28,25 +28,28 @@ opt_purify=no
opt_purecov=no opt_purecov=no
opt_afs=no opt_afs=no
opt_curses=no opt_curses=no
opt_with_installed_readline=no
dnl some systems should be configured without gnu malloc by default dnl some systems should be configured without gnu malloc by default
dnl and some need a special compiler or loader dnl and some need a special compiler or loader
dnl look in the NOTES file for more dnl look in the NOTES file for more
case "${host_cpu}-${host_os}" in case "${host_cpu}-${host_os}" in
alpha-*) opt_gnu_malloc=no ;; # alpha running osf/1 or linux alpha*-*) opt_gnu_malloc=no ;; # alpha running osf/1 or linux
*[Cc]ray*-*) opt_gnu_malloc=no ;; # Crays *[Cc]ray*-*) opt_gnu_malloc=no ;; # Crays
*-osf1*) opt_gnu_malloc=no ;; # other osf/1 machines *-osf1*) opt_gnu_malloc=no ;; # other osf/1 machines
sparc-svr4*) opt_gnu_malloc=no ;; # sparc SVR4, SVR4.2 sparc-svr4*) opt_gnu_malloc=no ;; # sparc SVR4, SVR4.2
sparc-netbsd*) opt_gnu_malloc=no ;; # needs 8-byte alignment sparc-netbsd*) opt_gnu_malloc=no ;; # needs 8-byte alignment
#mips-irix6*) opt_gnu_malloc=no ;; # needs 8-byte alignment mips-irix6*) opt_gnu_malloc=no ;; # needs 8-byte alignment
sparc-linux*) opt_gnu_malloc=no ;; # sparc running linux; requires ELF sparc-linux*) opt_gnu_malloc=no ;; # sparc running linux; requires ELF
#*-freebsd*) opt_gnu_malloc=no ;; # they claim it's better #*-freebsd*) opt_gnu_malloc=no ;; # they claim it's better
*-aix*) opt_gnu_malloc=no ;; # AIX machines *-aix*) opt_gnu_malloc=no ;; # AIX machines
*-nextstep*) opt_gnu_malloc=no ;; # NeXT machines running NeXTstep *-nextstep*) opt_gnu_malloc=no ;; # NeXT machines running NeXTstep
*-rhapsody*) opt_gnu_malloc=no ;; # Apple Rhapsody
*-dgux*) opt_gnu_malloc=no ;; # DG/UX machines *-dgux*) opt_gnu_malloc=no ;; # DG/UX machines
*-qnx*) opt_gnu_malloc=no ;; # QNX 4.2 *-qnx*) opt_gnu_malloc=no ;; # QNX 4.2
*-machten4) opt_gnu_malloc=no ;; # MachTen 4.x *-machten4) opt_gnu_malloc=no ;; # MachTen 4.x
*-bsdi2.1|*-bsdi3.?) opt_gnu_malloc=no ; : ${CC:=shlicc2} ;; # for loadable builtins *-bsdi2.1|*-bsdi3.?) opt_gnu_malloc=no ; : ${CC:=shlicc2} ;; # for loadable builtins
*-beos*) opt_gnu_malloc=no ;; # they say it's suitable
*-cygwin32*) opt_gnu_malloc=no ;; # Cygnus's CYGWIN32 environment *-cygwin32*) opt_gnu_malloc=no ;; # Cygnus's CYGWIN32 environment
esac esac
@ -56,6 +59,7 @@ AC_ARG_WITH(afs, --with-afs if you are running AFS, opt_afs=$withval)
AC_ARG_WITH(curses, --with-curses use the curses library instead of the termcap library,opt_curses=$withval) AC_ARG_WITH(curses, --with-curses use the curses library instead of the termcap library,opt_curses=$withval)
AC_ARG_WITH(glibc-malloc, --with-glibc-malloc use the GNU C library version of malloc,opt_glibc_malloc=$withval) AC_ARG_WITH(glibc-malloc, --with-glibc-malloc use the GNU C library version of malloc,opt_glibc_malloc=$withval)
AC_ARG_WITH(gnu-malloc, --with-gnu-malloc use the GNU version of malloc,opt_gnu_malloc=$withval) AC_ARG_WITH(gnu-malloc, --with-gnu-malloc use the GNU version of malloc,opt_gnu_malloc=$withval)
AC_ARG_WITH(installed-readline, --with-installed-readline use a version of the readline library that is already installed, opt_with_installed_readline=$withval)
AC_ARG_WITH(purecov, --with-purecov configure to postprocess with pure coverage, opt_purecov=$withval) AC_ARG_WITH(purecov, --with-purecov configure to postprocess with pure coverage, opt_purecov=$withval)
AC_ARG_WITH(purify, --with-purify configure to postprocess with purify, opt_purify=$withval) AC_ARG_WITH(purify, --with-purify configure to postprocess with purify, opt_purify=$withval)
@ -156,30 +160,13 @@ AC_ARG_ENABLE(static-link, --enable-static-link [link bash statically, for use
dnl opt_job_control is handled later, after BASH_JOB_CONTROL_MISSING runs dnl opt_job_control is handled later, after BASH_JOB_CONTROL_MISSING runs
dnl opt_readline and opt_history are handled later, because AC_PROG_CC needs
dnl to be run before we can check the version of an already-installed readline
dnl library
if test $opt_alias = yes; then if test $opt_alias = yes; then
AC_DEFINE(ALIAS) AC_DEFINE(ALIAS)
fi fi
if test $opt_readline = yes; then
AC_DEFINE(READLINE)
READLINE_LIB=-lreadline
READLINE_DEP='$(READLINE_LIBRARY)'
else
READLINE_LIB= READLINE_DEP=
fi
if test $opt_history = yes; then
AC_DEFINE(HISTORY)
HISTORY_LIB=-lhistory
HISTORY_DEP='$(HISTORY_LIBRARY)'
else
HISTORY_LIB= HISTORY_DEP=
fi
if test $opt_bang_history = yes; then
AC_DEFINE(BANG_HISTORY)
HISTORY_LIB=-lhistory
HISTORY_DEP='$(HISTORY_LIBRARY)'
else
HISTORY_LIB= HISTORY_DEP=
fi
if test $opt_dirstack = yes; then if test $opt_dirstack = yes; then
AC_DEFINE(PUSHD_AND_POPD) AC_DEFINE(PUSHD_AND_POPD)
fi fi
@ -234,10 +221,6 @@ AC_SUBST(TESTSCRIPT)
AC_SUBST(PURIFY) AC_SUBST(PURIFY)
AC_SUBST(MALLOC_TARGET) AC_SUBST(MALLOC_TARGET)
AC_SUBST(MALLOC_SRC) AC_SUBST(MALLOC_SRC)
AC_SUBST(READLINE_LIB)
AC_SUBST(READLINE_DEP)
AC_SUBST(HISTORY_LIB)
AC_SUBST(HISTORY_DEP)
dnl Use GNU m4 macros to get the distribution and patchlevel information dnl Use GNU m4 macros to get the distribution and patchlevel information
dnl into configure without requiring the files to be distributed dnl into configure without requiring the files to be distributed
@ -256,24 +239,37 @@ BASH_LARGE_FILE_SUPPORT
AC_ISC_POSIX AC_ISC_POSIX
AC_MINIX AC_MINIX
dnl BEGIN changes for CYGNUS cross-building for cygwin32 dnl BEGIN changes for cross-building for cygwin32 and BeOS
SIGNAMES_H=lsignames.h
dnl load up the cross-building cache file -- add more cases and cache dnl load up the cross-building cache file -- add more cases and cache
dnl files as necessary dnl files as necessary
dnl Note that host and target machine are the same, and different than the
dnl build machine.
dnl Set SIGNAMES_H based on whether or not we're cross-compiling.
if test "x$cross_compiling" = "xyes"; then if test "x$cross_compiling" = "xyes"; then
case "${host}" in case "${host}" in
*-cygwin32*) *-cygwin32*)
cross_cache=${srcdir}/cross-build/cygwin32.cache cross_cache=${srcdir}/cross-build/cygwin32.cache
if test -r "${cross_cache}"; then SIGNAMES_H='$(srcdir)/cross-build/win32sig.h'
echo "loading cross-build cache file ${cross_cache}"
. ${cross_cache}
fi
unset cross_cache
;; ;;
*) echo "configure: cross-compiling for a non-cygwin32 target is not supported" >&2 i[[3456]]86-*-beos*)
cross_cache=${srcdir}/cross-build/x86-beos.cache
SIGNAMES_H='${srcdir}/cross-build/beos-sig.h'
;;
*) echo "configure: cross-compiling for $host is not supported" >&2
;; ;;
esac esac
if test -n "${cross_cache}" && test -r "${cross_cache}"; then
echo "loading cross-build cache file ${cross_cache}"
. ${cross_cache}
fi
unset cross_cache
fi fi
AC_SUBST(SIGNAMES_H)
if test -z "$CC_FOR_BUILD"; then if test -z "$CC_FOR_BUILD"; then
if test "x$cross_compiling" = "xno"; then if test "x$cross_compiling" = "xno"; then
@ -284,15 +280,7 @@ if test -z "$CC_FOR_BUILD"; then
fi fi
AC_SUBST(CC_FOR_BUILD) AC_SUBST(CC_FOR_BUILD)
dnl Set SIGNAMES_H based on whether or not we're cross-compiling dnl END changes for cross-building
if test "x$cross_compiling" = "xno"; then
SIGNAMES_H=lsignames.h
else
SIGNAMES_H='$(srcdir)/cross-build/win32sig.h'
fi
AC_SUBST(SIGNAMES_H)
dnl END changes for CYGNUS cross-building for cygwin32
dnl We want these before the checks, so the checks can modify their values. dnl We want these before the checks, so the checks can modify their values.
test -z "$CFLAGS" && CFLAGS=-g auto_cflags=1 test -z "$CFLAGS" && CFLAGS=-g auto_cflags=1
@ -304,29 +292,114 @@ dnl handle options that alter how bash is compiled and linked
dnl these must come after the test for cc/gcc dnl these must come after the test for cc/gcc
if test "$opt_profiling" = "yes"; then if test "$opt_profiling" = "yes"; then
PROFILE_FLAGS=-pg PROFILE_FLAGS=-pg
opt_static_link=yes case "$host_os" in
solaris2*) ;;
*) opt_static_link=yes ;;
esac
fi fi
if test "$opt_static_link" = yes; then if test "$opt_static_link" = yes; then
# if we're using gcc, add `-static' to LDFLAGS # if we're using gcc, add `-static' to LDFLAGS
if test -n "$GCC" || test "$ac_cv_prog_gcc" = "yes"; then if test -n "$GCC" || test "$ac_cv_prog_gcc" = "yes"; then
LDFLAGS="$LDFLAGS -static" STATIC_LD="-static"
fi fi
fi fi
AC_SUBST(CFLAGS) AC_SUBST(CFLAGS)
AC_SUBST(CPPFLAGS) AC_SUBST(CPPFLAGS)
AC_SUBST(LDFLAGS) AC_SUBST(LDFLAGS)
AC_SUBST(STATIC_LD)
AC_PROG_GCC_TRADITIONAL AC_PROG_GCC_TRADITIONAL
dnl BEGIN READLINE and HISTORY LIBRARY SECTION
dnl prepare to allow bash to be linked against an already-installed readline
dnl first test that the readline version is new enough to link bash against
if test "$opt_readline" = yes && test "$opt_with_installed_readline" = "yes"
then
dnl we duplicate some work that's done later here so we can look in
dnl the correct directory for the readline library
test "x$prefix" = xNONE && _rl_prefix=$ac_default_prefix || _rl_prefix=${prefix}
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}`
AC_MSG_RESULT($_rl_version)
case "$_rl_version" in
3*|4*|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)
;;
esac
unset _rl_version _rl_prefix _rl_exec_prefix
fi
if test $opt_readline = yes; then
AC_DEFINE(READLINE)
READLINE_LIB=-lreadline
if test "$opt_with_installed_readline" = "yes" ; then
RL_LIBDIR='$(libdir)'
READLINE_DEP=
RL_INCLUDE='-I$(includedir)'
else
RL_LIBDIR='$(dot)/$(LIBSUBDIR)/readline'
READLINE_DEP='$(READLINE_LIBRARY)'
fi
else
RL_LIBDIR='$(dot)/$(LIBSUBDIR)/readline'
READLINE_LIB= READLINE_DEP=
fi
if test $opt_history = yes || test $opt_bang_history = yes; then
if test $opt_history = yes; then
AC_DEFINE(HISTORY)
fi
if test $opt_bang_history = yes; then
AC_DEFINE(BANG_HISTORY)
fi
HISTORY_LIB=-lhistory
if test "$opt_with_installed_readline" = "yes"; then
HIST_LIBDIR='$(libdir)'
HISTORY_DEP=
RL_INCLUDE='-I$(includedir)'
else
HIST_LIBDIR='$(dot)/$(LIBSUBDIR)/readline'
HISTORY_DEP='$(HISTORY_LIBRARY)'
fi
else
HIST_LIBDIR='$(dot)/$(LIBSUBDIR)/readline'
HISTORY_LIB= HISTORY_DEP=
fi
AC_SUBST(READLINE_LIB)
AC_SUBST(READLINE_DEP)
AC_SUBST(RL_LIBDIR)
AC_SUBST(RL_INCLUDE)
AC_SUBST(HISTORY_LIB)
AC_SUBST(HISTORY_DEP)
AC_SUBST(HIST_LIBDIR)
dnl END READLINE and HISTORY LIBRARY SECTION
dnl programs needed by the build and install process dnl programs needed by the build and install process
AC_PROG_INSTALL AC_PROG_INSTALL
AC_CHECK_PROG(AR, ar, ar) AC_CHECK_PROG(AR, ar, ar)
dnl Set default for ARFLAGS, since autoconf does not have a macro for it.
dnl This allows people to set it when running configure or make
test -n "$ARFLAGS" || ARFLAGS="cr"
AC_PROG_RANLIB AC_PROG_RANLIB
AC_PROG_YACC AC_PROG_YACC
AC_PROG_MAKE_SET AC_PROG_MAKE_SET
case "$host_os" in
opennt*|interix*) MAKE_SHELL="$OPENNT_ROOT/bin/sh" ;;
*) MAKE_SHELL=/bin/sh ;;
esac
AC_SUBST(MAKE_SHELL)
dnl special checks for libc functions dnl special checks for libc functions
AC_FUNC_ALLOCA AC_FUNC_ALLOCA
AC_FUNC_GETPGRP AC_FUNC_GETPGRP
@ -357,8 +430,8 @@ AC_CHECK_FUNC(mkfifo,AC_DEFINE(HAVE_MKFIFO),AC_DEFINE(MKFIFO_MISSING))
dnl checks for system calls dnl checks for system calls
AC_CHECK_FUNCS(dup2 select getdtablesize getgroups gethostname \ AC_CHECK_FUNCS(dup2 select getdtablesize getgroups gethostname \
setdtablesize getpagesize killpg lstat getpeername \ setdtablesize getpagesize killpg lstat getpeername sbrk \
getrlimit getrusage gettimeofday waitpid tcgetpgrp) getrlimit getrusage gettimeofday waitpid tcgetpgrp rename)
dnl checks for c library functions dnl checks for c library functions
AC_CHECK_FUNCS(bcopy bzero confstr getcwd strcasecmp setenv putenv \ AC_CHECK_FUNCS(bcopy bzero confstr getcwd strcasecmp setenv putenv \
@ -418,23 +491,15 @@ AC_CHECK_TYPE(time_t, long)
AC_TYPE_SIGNAL AC_TYPE_SIGNAL
AC_CHECK_SIZEOF(int) AC_CHECK_SIZEOF(int, 4)
AC_CHECK_SIZEOF(long) AC_CHECK_SIZEOF(long, 4)
AC_CHECK_SIZEOF(char *) AC_CHECK_SIZEOF(char *, 4)
AC_CHECK_SIZEOF(double, 8)
AC_CHECK_TYPE(int32_t) BASH_TYPE_INT32_T
if test "$ac_cv_type_int32_t" = "no"; then BASH_TYPE_U_INT32_T
BASH_TYPE_INT32_T BASH_TYPE_PTRDIFF_T
fi BASH_TYPE_BITS64_T
AC_CHECK_TYPE(u_int32_t)
if test "$ac_cv_type_u_int32_t" = "no"; then
BASH_TYPE_U_INT32_T
fi
AC_CHECK_TYPE(ptrdiff_t)
if test "$ac_cv_type_ptrdiff_t" = "no"; then
BASH_TYPE_PTRDIFF_T
fi
dnl structures dnl structures
AC_HEADER_STAT AC_HEADER_STAT
@ -556,23 +621,33 @@ dnl libraries, and specify any additional local cc flags
dnl dnl
dnl this should really go away someday dnl this should really go away someday
case "$host_os" in case "${host_os}" in
sysv4.2*) AC_DEFINE(SVR4_2) sysv4.2*) AC_DEFINE(SVR4_2)
AC_DEFINE(SVR4) ;; AC_DEFINE(SVR4) ;;
sysv4*) AC_DEFINE(SVR4) ;; sysv4*) AC_DEFINE(SVR4) ;;
sysv5*) AC_DEFINE(SVR5) ;;
hpux9*) LOCAL_CFLAGS="-DHPUX9 -DHPUX" ;;
hpux*) LOCAL_CFLAGS=-DHPUX ;; hpux*) LOCAL_CFLAGS=-DHPUX ;;
dgux*) LOCAL_CFLAGS=-D_DGUX_SOURCE; LOCAL_LIBS=-ldgc ;; dgux*) LOCAL_CFLAGS=-D_DGUX_SOURCE; LOCAL_LIBS=-ldgc ;;
isc*) LOCAL_CFLAGS=-Disc386;; isc*) LOCAL_CFLAGS=-Disc386;;
sco3.2v5*) LOCAL_CFLAGS="-DWAITPID_BROKEN -DNO_MEMSCRAMBLE -DPATH_MAX=1024" ;; sco3.2v5*) LOCAL_CFLAGS="-b elf -DWAITPID_BROKEN -DNO_MEMSCRAMBLE -DPATH_MAX=1024" ;;
sco3.2v4*) LOCAL_CFLAGS="-DMUST_UNBLOCK_CHLD -DNO_MEMSCRAMBLE -DPATH_MAX=1024" ;; sco3.2v4*) LOCAL_CFLAGS="-DMUST_UNBLOCK_CHLD -DNO_MEMSCRAMBLE -DPATH_MAX=1024" ;;
sco3.2*) LOCAL_CFLAGS=-DMUST_UNBLOCK_CHLD ;; sco3.2*) LOCAL_CFLAGS=-DMUST_UNBLOCK_CHLD ;;
sunos4*) LOCAL_CFLAGS=-DSunOS4 ;; sunos4*) LOCAL_CFLAGS=-DSunOS4 ;;
solaris2.5*) LOCAL_CFLAGS=-DSunOS5 ;; solaris2.5*) LOCAL_CFLAGS=-DSunOS5 ;;
lynxos*) LOCAL_CFLAGS=-DRECYCLES_PIDS ;;
linux*) LOCAL_LDFLAGS=-rdynamic ;; # allow dynamic loading linux*) LOCAL_LDFLAGS=-rdynamic ;; # allow dynamic loading
aix4.2*) LOCAL_LDFLAGS="-bexpall -brtl" ;;# allow dynamic loading
*qnx*) LOCAL_CFLAGS="-Dqnx -F -3s" LOCAL_LDFLAGS="-3s -lunix -lncurses" ;; *qnx*) LOCAL_CFLAGS="-Dqnx -F -3s" LOCAL_LDFLAGS="-3s -lunix -lncurses" ;;
powerux) LOCAL_LIBS="-lgen" ;; powerux*) LOCAL_LIBS="-lgen" ;;
cygwin32*) LOCAL_LIBS="-luser32" ;; cygwin32*) LOCAL_LIBS="-luser32" ;;
opennt*|interix*) LOCAL_CFLAGS="-DNO_MAIN_ENV_ARG" ;;
esac
dnl Stanza for OS/compiler pair-specific flags
case "${host_os}-${CC}" in
aix4.2*-*gcc*) LOCAL_LDFLAGS="-Xlinker -bexpall -Xlinker -brtl" ;;
aix4.2*) LOCAL_LDFLAGS="-bexpall -brtl" ;;
bsdi4*-*gcc*) LOCAL_LDFLAGS="-rdynamic" ;; # allow dynamic loading, like Linux
esac esac
case "$host_cpu" in case "$host_cpu" in
@ -588,6 +663,24 @@ m88k-motorola-sysv3) LOCAL_CFLAGS=-DWAITPID_BROKEN ;;
mips-pyramid-sysv4) LOCAL_CFLAGS=-Xa ;; mips-pyramid-sysv4) LOCAL_CFLAGS=-Xa ;;
esac esac
#
# Shared object configuration section. These values are generated by
# ${srcdir}/support/shobj-conf
#
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}`
AC_SUBST(SHOBJ_CC)
AC_SUBST(SHOBJ_CFLAGS)
AC_SUBST(SHOBJ_LD)
AC_SUBST(SHOBJ_LDFLAGS)
AC_SUBST(SHOBJ_XLDFLAGS)
AC_SUBST(SHOBJ_LIBS)
AC_SUBST(SHOBJ_STATUS)
AC_MSG_RESULT($SHOBJ_STATUS)
fi
# try to create a directory tree if the source is elsewhere # try to create a directory tree if the source is elsewhere
# this should be packaged into a script accessible via ${srcdir}/support # this should be packaged into a script accessible via ${srcdir}/support
case "$srcdir" in case "$srcdir" in
@ -611,11 +704,13 @@ AC_SUBST(BUILD_DIR)
AC_SUBST(YACC) AC_SUBST(YACC)
AC_SUBST(AR) AC_SUBST(AR)
AC_SUBST(ARFLAGS)
AC_SUBST(BASHVERS) AC_SUBST(BASHVERS)
AC_SUBST(BASHPATCH) AC_SUBST(BASHPATCH)
AC_SUBST(host_cpu) AC_SUBST(host_cpu)
AC_SUBST(host_vendor)
AC_SUBST(host_os) AC_SUBST(host_os)
AC_SUBST(LOCAL_LIBS) AC_SUBST(LOCAL_LIBS)

36
cross-build/beos-sig.h Normal file
View file

@ -0,0 +1,36 @@
/* This file is used when cross compiling bash to run native on BeOS. */
#ifndef __GNUC__
# error cross compiling requires gcc
#endif
/* A translation list so we can be polite to our users.
Use gcc labelled initializers to set up the array. Note that
some entries might wind up being NULL. */
char *signal_names[NSIG + 2] = {
[0] "EXIT",
[SIGHUP] "SIGHUP",
[SIGINT] "SIGINT",
[SIGQUIT] "SIGQUIT",
[SIGILL] "SIGILL",
[SIGCHLD] "SIGCHLD",
[SIGABRT] "SIGABRT",
[SIGPIPE] "SIGPIPE",
[SIGFPE] "SIGFPE",
[SIGKILL] "SIGKILL",
[SIGSTOP] "SIGSTOP",
[SIGSEGV] "SIGSEGV",
[SIGCONT] "SIGCONT",
[SIGTSTP] "SIGTSTP",
[SIGALRM] "SIGALRM",
[SIGTERM] "SIGTERM",
[SIGTTIN] "SIGTTIN",
[SIGTTOU] "SIGTTOU",
[SIGUSR1] "SIGUSR1",
[SIGUSR2] "SIGUSR2",
[SIGWINCH] "SIGWINCH",
[SIGKILLTHR] "SIGKILLTHR",
[NSIG] "DEBUG",
[NSIG + 1] (char *)0x0,
};

View file

@ -14,6 +14,7 @@ bash_cv_sys_restartable_syscalls=${bash_cv_sys_restartable_syscalls='no'}
ac_cv_sizeof_char_p=${ac_cv_sizeof_char_p='4'} ac_cv_sizeof_char_p=${ac_cv_sizeof_char_p='4'}
ac_cv_sizeof_int=${ac_cv_sizeof_int='4'} ac_cv_sizeof_int=${ac_cv_sizeof_int='4'}
ac_cv_sizeof_long=${ac_cv_sizeof_long='4'} ac_cv_sizeof_long=${ac_cv_sizeof_long='4'}
ac_cv_sizeof_double=${ac_cv_sizeof_double='8'}
bash_cv_dup2_broken=${bash_cv_dup2_broken='no'} bash_cv_dup2_broken=${bash_cv_dup2_broken='no'}
bash_cv_pgrp_pipe=${bash_cv_pgrp_pipe='no'} bash_cv_pgrp_pipe=${bash_cv_pgrp_pipe='no'}
@ -36,4 +37,6 @@ bash_cv_func_strcoll_broken=${bash_cv_func_strcoll_broken='no'}
bash_cv_type_int32_t=${bash_cv_type_int32_t='int'} bash_cv_type_int32_t=${bash_cv_type_int32_t='int'}
bash_cv_type_u_int32_t=${bash_cv_type_u_int32_t='int'} bash_cv_type_u_int32_t=${bash_cv_type_u_int32_t='int'}
ac_cv_type_bits64_t=${ac_cv_type_bits64_t='no'}
# end of cross-build/cygwin32.cache # end of cross-build/cygwin32.cache

169
cross-build/opennt.cache Normal file
View file

@ -0,0 +1,169 @@
# This file is a shell script that caches the results of configure
# tests run on this system so they can be shared between configure
# scripts and configure runs. It is not useful on other systems.
# If it contains results you don't want to keep, you may remove or edit it.
#
# By default, configure uses ./config.cache as the cache file,
# creating it if it does not exist already. You can give configure
# the --cache-file=FILE option to use a different cache file; that is
# what configure does when it calls configure scripts in
# subdirectories, so they share the cache.
# Giving --cache-file=/dev/null disables caching, for debugging configure.
# config.status only pays attention to the cache file if you give it the
# --recheck option to rerun configure.
#
ac_cv_c_bigendian=${ac_cv_c_bigendian=no}
ac_cv_decl_sys_siglist=${ac_cv_decl_sys_siglist=no}
ac_cv_func___setostype=${ac_cv_func___setostype=no}
ac_cv_func_alloca_works=${ac_cv_func_alloca_works=yes}
ac_cv_func_bcopy=${ac_cv_func_bcopy=yes}
ac_cv_func_bindtextdomain=${ac_cv_func_bindtextdomain=no}
ac_cv_func_bzero=${ac_cv_func_bzero=yes}
ac_cv_func_confstr=${ac_cv_func_confstr=yes}
ac_cv_func_dlclose=${ac_cv_func_dlclose=no}
ac_cv_func_dlopen=${ac_cv_func_dlopen=no}
ac_cv_func_dlsym=${ac_cv_func_dlsym=no}
ac_cv_func_dup2=${ac_cv_func_dup2=yes}
ac_cv_func_getcwd=${ac_cv_func_getcwd=yes}
ac_cv_func_getdtablesize=${ac_cv_func_getdtablesize=no}
ac_cv_func_getgroups=${ac_cv_func_getgroups=yes}
ac_cv_func_gethostname=${ac_cv_func_gethostname=yes}
ac_cv_func_getpagesize=${ac_cv_func_getpagesize=yes}
ac_cv_func_getpeername=${ac_cv_func_getpeername=yes}
ac_cv_func_getpgrp_void=${ac_cv_func_getpgrp_void=yes}
ac_cv_func_getrlimit=${ac_cv_func_getrlimit=no}
ac_cv_func_getrusage=${ac_cv_func_getrusage=no}
ac_cv_func_gettext=${ac_cv_func_gettext=no}
ac_cv_func_gettimeofday=${ac_cv_func_gettimeofday=yes}
ac_cv_func_killpg=${ac_cv_func_killpg=yes}
ac_cv_func_lstat=${ac_cv_func_lstat=no}
ac_cv_func_memmove=${ac_cv_func_memmove=yes}
ac_cv_func_mkfifo=${ac_cv_func_mkfifo=yes}
ac_cv_func_putenv=${ac_cv_func_putenv=yes}
ac_cv_func_rename=${ac_cv_func_rename=yes}
ac_cv_func_sbrk=${ac_cv_func_sbrk=no}
ac_cv_func_select=${ac_cv_func_select=yes}
ac_cv_func_setdtablesize=${ac_cv_func_setdtablesize=no}
ac_cv_func_setenv=${ac_cv_func_setenv=yes}
ac_cv_func_setlinebuf=${ac_cv_func_setlinebuf=yes}
ac_cv_func_setlocale=${ac_cv_func_setlocale=yes}
ac_cv_func_setvbuf_reversed=${ac_cv_func_setvbuf_reversed=no}
ac_cv_func_siginterrupt=${ac_cv_func_siginterrupt=no}
ac_cv_func_strcasecmp=${ac_cv_func_strcasecmp=yes}
ac_cv_func_strchr=${ac_cv_func_strchr=yes}
ac_cv_func_strcoll_works=${ac_cv_func_strcoll_works=yes}
ac_cv_func_strerror=${ac_cv_func_strerror=yes}
ac_cv_func_strtod=${ac_cv_func_strtod=yes}
ac_cv_func_strtol=${ac_cv_func_strtol=yes}
ac_cv_func_strtoul=${ac_cv_func_strtoul=yes}
ac_cv_func_sysconf=${ac_cv_func_sysconf=yes}
ac_cv_func_tcgetattr=${ac_cv_func_tcgetattr=yes}
ac_cv_func_tcgetpgrp=${ac_cv_func_tcgetpgrp=yes}
ac_cv_func_textdomain=${ac_cv_func_textdomain=no}
ac_cv_func_times=${ac_cv_func_times=yes}
ac_cv_func_tzset=${ac_cv_func_tzset=yes}
ac_cv_func_ulimit=${ac_cv_func_ulimit=no}
ac_cv_func_uname=${ac_cv_func_uname=yes}
ac_cv_func_vprintf=${ac_cv_func_vprintf=yes}
ac_cv_func_wait3=${ac_cv_func_wait3=no}
ac_cv_func_wait3_rusage=${ac_cv_func_wait3_rusage=no}
ac_cv_func_waitpid=${ac_cv_func_waitpid=yes}
ac_cv_header_alloca_h=${ac_cv_header_alloca_h=no}
ac_cv_header_dirent_dirent_h=${ac_cv_header_dirent_dirent_h=yes}
ac_cv_header_dlfcn_h=${ac_cv_header_dlfcn_h=no}
ac_cv_header_libintl_h=${ac_cv_header_libintl_h=no}
ac_cv_header_limits_h=${ac_cv_header_limits_h=yes}
ac_cv_header_locale_h=${ac_cv_header_locale_h=yes}
ac_cv_header_memory_h=${ac_cv_header_memory_h=yes}
ac_cv_header_minix_config_h=${ac_cv_header_minix_config_h=no}
ac_cv_header_stat_broken=${ac_cv_header_stat_broken=no}
ac_cv_header_stdarg_h=${ac_cv_header_stdarg_h=yes}
ac_cv_header_stdc=${ac_cv_header_stdc=yes}
ac_cv_header_stdlib_h=${ac_cv_header_stdlib_h=yes}
ac_cv_header_string_h=${ac_cv_header_string_h=yes}
ac_cv_header_sys_file_h=${ac_cv_header_sys_file_h=yes}
ac_cv_header_sys_param_h=${ac_cv_header_sys_param_h=yes}
ac_cv_header_sys_pte_h=${ac_cv_header_sys_pte_h=no}
ac_cv_header_sys_ptem_h=${ac_cv_header_sys_ptem_h=no}
ac_cv_header_sys_resource_h=${ac_cv_header_sys_resource_h=no}
ac_cv_header_sys_select_h=${ac_cv_header_sys_select_h=no}
ac_cv_header_sys_socket_h=${ac_cv_header_sys_socket_h=yes}
ac_cv_header_sys_stream_h=${ac_cv_header_sys_stream_h=no}
ac_cv_header_sys_time_h=${ac_cv_header_sys_time_h=yes}
ac_cv_header_sys_times_h=${ac_cv_header_sys_times_h=yes}
ac_cv_header_sys_wait_h=${ac_cv_header_sys_wait_h=yes}
ac_cv_header_termcap_h=${ac_cv_header_termcap_h=no}
ac_cv_header_termio_h=${ac_cv_header_termio_h=no}
ac_cv_header_termios_h=${ac_cv_header_termios_h=yes}
ac_cv_header_time=${ac_cv_header_time=yes}
ac_cv_header_unistd_h=${ac_cv_header_unistd_h=yes}
ac_cv_header_varargs_h=${ac_cv_header_varargs_h=no}
ac_cv_lib_dir_opendir=${ac_cv_lib_dir_opendir=no}
ac_cv_lib_dl_dlopen=${ac_cv_lib_dl_dlopen=no}
ac_cv_lib_intl_bindtextdomain=${ac_cv_lib_intl_bindtextdomain=no}
ac_cv_lib_termcap_tgetent=${ac_cv_lib_termcap_tgetent=yes}
ac_cv_path_install=${ac_cv_path_install='//C/OpenNT21b3/bin/install -c'}
ac_cv_prog_AR=${ac_cv_prog_AR=ar}
ac_cv_prog_CC=${ac_cv_prog_CC=gcc}
ac_cv_prog_CPP=${ac_cv_prog_CPP='cc -E'}
ac_cv_prog_RANLIB=${ac_cv_prog_RANLIB=:}
ac_cv_prog_cc_cross=${ac_cv_prog_cc_cross=no}
ac_cv_prog_cc_g=${ac_cv_prog_cc_g=yes}
ac_cv_prog_cc_works=${ac_cv_prog_cc_works=yes}
ac_cv_prog_gcc=${ac_cv_prog_gcc=yes}
ac_cv_prog_gcc_traditional=${ac_cv_prog_gcc_traditional=no}
ac_cv_prog_make_make_set=${ac_cv_prog_make_make_set=yes}
ac_cv_sizeof_char_p=${ac_cv_sizeof_char_p=4}
ac_cv_sizeof_double=${ac_cv_sizeof_double=8}
ac_cv_sizeof_int=${ac_cv_sizeof_int=4}
ac_cv_sizeof_long=${ac_cv_sizeof_long=4}
ac_cv_sys_interpreter=${ac_cv_sys_interpreter=yes}
ac_cv_sys_restartable_syscalls=${ac_cv_sys_restartable_syscalls=no}
ac_cv_type_getgroups=${ac_cv_type_getgroups=gid_t}
ac_cv_type_mode_t=${ac_cv_type_mode_t=yes}
ac_cv_type_off_t=${ac_cv_type_off_t=yes}
ac_cv_type_pid_t=${ac_cv_type_pid_t=yes}
ac_cv_type_signal=${ac_cv_type_signal=void}
ac_cv_type_size_t=${ac_cv_type_size_t=yes}
ac_cv_type_time_t=${ac_cv_type_time_t=yes}
ac_cv_type_uid_t=${ac_cv_type_uid_t=yes}
bash_cv_can_redecl_getpw=${bash_cv_can_redecl_getpw=yes}
bash_cv_decl_under_sys_siglist=${bash_cv_decl_under_sys_siglist=no}
bash_cv_dev_fd=${bash_cv_dev_fd=absent}
bash_cv_dirent_has_d_fileno=${bash_cv_dirent_has_d_fileno=no}
bash_cv_dirent_has_dino=${bash_cv_dirent_has_dino=yes}
bash_cv_dup2_broken=${bash_cv_dup2_broken=no}
bash_cv_fionread_in_ioctl=${bash_cv_fionread_in_ioctl=yes}
bash_cv_func_lstat=${bash_cv_func_lstat=no}
bash_cv_func_sigsetjmp=${bash_cv_func_sigsetjmp=present}
bash_cv_func_strcoll_broken=${bash_cv_func_strcoll_broken=no}
bash_cv_getcwd_calls_popen=${bash_cv_getcwd_calls_popen=no}
bash_cv_getenv_redef=${bash_cv_getenv_redef=yes}
bash_cv_have_strsignal=${bash_cv_have_strsignal=yes}
bash_cv_job_control_missing=${bash_cv_job_control_missing=present}
bash_cv_mail_dir=${bash_cv_mail_dir=/usr/spool/mail}
bash_cv_must_reinstall_sighandlers=${bash_cv_must_reinstall_sighandlers=no}
bash_cv_opendir_not_robust=${bash_cv_opendir_not_robust=no}
bash_cv_pgrp_pipe=${bash_cv_pgrp_pipe=no}
bash_cv_printf_declared=${bash_cv_printf_declared=yes}
bash_cv_sbrk_declared=${bash_cv_sbrk_declared=no}
bash_cv_signal_vintage=${bash_cv_signal_vintage=posix}
bash_cv_speed_t_in_sys_types=${bash_cv_speed_t_in_sys_types=no}
bash_cv_struct_timeval=${bash_cv_struct_timeval=yes}
bash_cv_struct_winsize_header=${bash_cv_struct_winsize_header=ioctl_h}
bash_cv_struct_winsize_in_ioctl=${bash_cv_struct_winsize_in_ioctl=yes}
bash_cv_sys_errlist=${bash_cv_sys_errlist=yes}
bash_cv_sys_named_pipes=${bash_cv_sys_named_pipes=present}
bash_cv_sys_siglist=${bash_cv_sys_siglist=yes}
bash_cv_termcap_lib=${bash_cv_termcap_lib=libtermcap}
bash_cv_termio_ldisc=${bash_cv_termio_ldisc=no}
bash_cv_termios_ldisc=${bash_cv_termios_ldisc=no}
bash_cv_tiocgwinsz_in_ioctl=${bash_cv_tiocgwinsz_in_ioctl=yes}
bash_cv_tiocstat_in_ioctl=${bash_cv_tiocstat_in_ioctl=no}
bash_cv_type_clock_t=${bash_cv_type_clock_t=yes}
bash_cv_type_quad_t=${bash_cv_type_quad_t=yes}
bash_cv_type_rlimit=${bash_cv_type_rlimit=long}
bash_cv_type_sigset_t=${bash_cv_type_sigset_t=yes}
bash_cv_ulimit_maxfds=${bash_cv_ulimit_maxfds=no}
bash_cv_under_sys_siglist=${bash_cv_under_sys_siglist=no}
bash_cv_void_sighandler=${bash_cv_void_sighandler=yes}

View file

@ -0,0 +1,45 @@
# This file is a shell script that caches the results of configure
# tests for x86 BeOS so they don't need to be done when cross-compiling.
# AC_FUNC_GETPGRP should also define GETPGRP_VOID
ac_cv_func_getpgrp_void=${ac_cv_func_getpgrp_void='yes'}
# AC_FUNC_SETVBUF_REVERSED should not define anything else
ac_cv_func_setvbuf_reversed=${ac_cv_func_setvbuf_reversed='no'}
# on BeOS, system calls do not restart
ac_cv_sys_restartable_syscalls=${ac_cv_sys_restartable_syscalls='no'}
bash_cv_sys_restartable_syscalls=${bash_cv_sys_restartable_syscalls='no'}
ac_cv_func_tcgetattr=${ac_cv_func_tcgetattr='yes'}
# x86 BeOS is little endian
ac_cv_c_bigendian=${ac_cv_c_bigendian='no'}
ac_cv_sizeof_char_p=${ac_cv_sizeof_char_p='4'}
ac_cv_sizeof_int=${ac_cv_sizeof_int='4'}
ac_cv_sizeof_long=${ac_cv_sizeof_long='4'}
ac_cv_sizeof_double=${ac_cv_sizeof_double='8'}
bash_cv_dev_fd=${bash_cv_dev_fd='absent'}
bash_cv_dup2_broken=${bash_cv_dup2_broken='no'}
bash_cv_pgrp_pipe=${bash_cv_pgrp_pipe='no'}
bash_cv_type_rlimit=${bash_cv_type_rlimit='long'}
bash_cv_decl_under_sys_siglist=${bash_cv_decl_under_sys_siglist='no'}
bash_cv_under_sys_siglist=${bash_cv_under_sys_siglist='no'}
bash_cv_sys_siglist=${bash_cv_sys_siglist='yes'}
bash_cv_opendir_not_robust=${bash_cv_opendir_not_robust='no'}
bash_cv_getenv_redef=${bash_cv_getenv_redef='yes'}
bash_cv_printf_declared=${bash_cv_printf_declared='yes'}
bash_cv_ulimit_maxfds=${bash_cv_ulimit_maxfds='no'}
bash_cv_getcwd_calls_popen=${bash_cv_getcwd_calls_popen='no'}
bash_cv_must_reinstall_sighandlers=${bash_cv_must_reinstall_sighandlers='no'}
bash_cv_job_control_missing=${bash_cv_job_control_missing='present'}
bash_cv_sys_named_pipes=${bash_cv_sys_named_pipes='present'}
bash_cv_func_sigsetjmp=${bash_cv_func_sigsetjmp='missing'}
bash_cv_mail_dir=${bash_cv_mail_dir='unknown'}
bash_cv_func_strcoll_broken=${bash_cv_func_strcoll_broken='no'}
bash_cv_type_int32_t=${bash_cv_type_int32_t='int'}
bash_cv_type_u_int32_t=${bash_cv_type_u_int32_t='int'}
ac_cv_type_bits64_t=${ac_cv_type_bits64_t='no'}
# end of cross-build/x86-beos.cache

View file

@ -169,7 +169,7 @@ dispose_command (command)
} }
default: default:
programming_error ("dispose_command: bad command type `%d'", command->type); command_error ("dispose_command", CMDERR_BADTYPE, command->type, 0);
break; break;
} }
free (command); free (command);

306
doc/FAQ
View file

@ -1,4 +1,4 @@
This is the Bash FAQ, version 2.13, for Bash version 2.02. This is the Bash FAQ, version 3.0, for Bash version 2.03.
This document contains a set of frequently-asked questions concerning This document contains a set of frequently-asked questions concerning
Bash, the GNU Bourne-Again Shell. Bash is a freely-available command Bash, the GNU Bourne-Again Shell. Bash is a freely-available command
@ -20,87 +20,87 @@ Contents:
Section A: The Basics Section A: The Basics
1) What is it? A1) What is it?
2) What's the latest version? A2) What's the latest version?
3) Where can I get it? A3) Where can I get it?
4) On what machines will bash run? A4) On what machines will bash run?
5) Will bash run on operating systems other than Unix? A5) Will bash run on operating systems other than Unix?
6) How can I build bash with gcc? A6) How can I build bash with gcc?
7) How can I make bash my login shell? A7) How can I make bash my login shell?
8) I just changed my login shell to bash, and now I can't FTP into my A8) I just changed my login shell to bash, and now I can't FTP into my
machine. Why not? machine. Why not?
9) What's the `POSIX 1003.2 standard'? A9) What's the `POSIX 1003.2 standard'?
10) What is the bash `posix mode'? A10) What is the bash `posix mode'?
Section B: The latest version Section B: The latest version
11) What's new in version 2.02? B1) What's new in version 2.03?
12) Are there any user-visible incompatibilities between bash-2.02 and B2) Are there any user-visible incompatibilities between bash-2.03 and
bash-1.14.7? bash-1.14.7?
Section C: Differences from other Unix shells Section C: Differences from other Unix shells
13) How does bash differ from sh, the Bourne shell? C1) How does bash differ from sh, the Bourne shell?
14) How does bash differ from the Korn shell, version ksh88? C2) How does bash differ from the Korn shell, version ksh88?
15) Which new features in ksh-93 are not in bash, and which are? C3) Which new features in ksh-93 are not in bash, and which are?
Section D: Why does bash do some things differently than other Unix shells? Section D: Why does bash do some things differently than other Unix shells?
16) Why does bash run a different version of `command' than D1) Why does bash run a different version of `command' than
`which command' says it will? `which command' says it will?
17) Why doesn't bash treat brace expansions exactly like csh? D2) Why doesn't bash treat brace expansions exactly like csh?
18) Why doesn't bash have csh variable modifiers? D3) Why doesn't bash have csh variable modifiers?
19) How can I make my csh aliases work when I convert to bash? D4) How can I make my csh aliases work when I convert to bash?
20) How can I pipe standard output and standard error from one command to D5) How can I pipe standard output and standard error from one command to
another, like csh does with `|&'? another, like csh does with `|&'?
21) Now that I've converted from ksh to bash, are there equivalents to D6) Now that I've converted from ksh to bash, are there equivalents to
ksh features like autoloaded functions and the `whence' command? ksh features like autoloaded functions and the `whence' command?
Section E: How can I get bash to do certain things, and why does bash do Section E: How can I get bash to do certain things, and why does bash do
things the way it does? things the way it does?
22) Why is the bash builtin `test' slightly different from /bin/test? E1) Why is the bash builtin `test' slightly different from /bin/test?
23) Why does bash sometimes say `Broken pipe'? E2) Why does bash sometimes say `Broken pipe'?
24) How can I get bash to read and display eight-bit characters? E3) How can I get bash to read and display eight-bit characters?
25) How do I write a function `x' to replace builtin command `x', but E4) How do I write a function `x' to replace builtin command `x', but
still invoke the command from within the function? still invoke the command from within the function?
26) When I have terminal escape sequences in my prompt, why does bash E5) When I have terminal escape sequences in my prompt, why does bash
wrap lines at the wrong column? wrap lines at the wrong column?
27) How can I find the value of a shell variable whose name is the value E6) How can I find the value of a shell variable whose name is the value
of another shell variable? of another shell variable?
28) If I pipe the output of a command into `read variable', why doesn't E7) 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? the output show up in $variable when the read command finishes?
29) I have a bunch of shell scripts that use backslash-escaped characters E8) I have a bunch of shell scripts that use backslash-escaped characters
in arguments to `echo'. Bash doesn't interpret these characters. Why in arguments to `echo'. Bash doesn't interpret these characters. Why
not, and how can I make it understand them? not, and how can I make it understand them?
30) Why doesn't a while or for loop get suspended when I type ^Z? E9) Why doesn't a while or for loop get suspended when I type ^Z?
31) How can I make the bash `time' reserved word print timing output that E10) How can I make the bash `time' reserved word print timing output that
looks like the output from my system's /usr/bin/time? looks like the output from my system's /usr/bin/time?
Section F: Things to watch out for on certain Unix versions Section F: Things to watch out for on certain Unix versions
32) Why can't I use command line editing in my `cmdtool'? F1) Why can't I use command line editing in my `cmdtool'?
33) I built bash on Solaris 2. Why do globbing expansions and filename F2) I built bash on Solaris 2. Why do globbing expansions and filename
completion chop off the first few characters of each filename? completion chop off the first few characters of each filename?
34) Why does bash dump core after I interrupt username completion or F3) Why does bash dump core after I interrupt username completion or
`~user' tilde expansion on a machine running NIS? `~user' tilde expansion on a machine running NIS?
35) I'm running SVR4.2. Why is the line erased every time I type `@'? F4) I'm running SVR4.2. Why is the line erased every time I type `@'?
36) Why does bash report syntax errors when my C News scripts use a F5) Why does bash report syntax errors when my C News scripts use a
redirection before a subshell command? redirection before a subshell command?
Section G: Where do I go from here? Section G: Where do I go from here?
37) How do I report bugs in bash, and where should I look for fixes and G1) How do I report bugs in bash, and where should I look for fixes and
advice? advice?
38) What kind of bash documentation is there? G2) What kind of bash documentation is there?
39) What's coming in future versions? G3) What's coming in future versions?
40) What's on the bash `wish list'? G4) What's on the bash `wish list'?
41) When will the next release appear? G5) When will the next release appear?
---------- ----------
Section A: The Basics Section A: The Basics
1) What is it? A1) What is it?
Bash is a Unix command interpreter (shell). It is an implementation of Bash is a Unix command interpreter (shell). It is an implementation of
the Posix 1003.2 shell standard, and resembles the Korn and System V the Posix 1003.2 shell standard, and resembles the Korn and System V
@ -118,26 +118,26 @@ Bash was originally written by Brian Fox of the Free Software
Foundation. The current developer and maintainer is Chet Ramey Foundation. The current developer and maintainer is Chet Ramey
of Case Western Reserve University. of Case Western Reserve University.
2) What's the latest version? A2) What's the latest version?
The latest version is 2.02, first made available on Monday, 20 April, 1998. The latest version is 2.03, first made available on Friday, 19 Feburary 1999.
3) Where can I get it? A3) Where can I get it?
Bash is the GNU project's shell, and so is available from the Bash is the GNU project's shell, and so is available from the
master GNU archive site, prep.ai.mit.edu, and its mirrors. The master GNU archive site, ftp.gnu.org, and its mirrors. The
latest version is also available for FTP from ftp.cwru.edu. latest version is also available for FTP from ftp.cwru.edu.
The following URLs tell how to get version 2.02: The following URLs tell how to get version 2.03:
ftp://prep.ai.mit.edu/pub/gnu/bash-2.02.tar.gz ftp://ftp.gnu.org/pub/gnu/bash-2.03.tar.gz
ftp://ftp.cwru.edu/pub/bash/bash-2.02.tar.gz ftp://ftp.cwru.edu/pub/bash/bash-2.03.tar.gz
Formatted versions of the documentation are available with the URLs: Formatted versions of the documentation are available with the URLs:
ftp://prep.ai.mit.edu/pub/gnu/bash-doc-2.02.tar.gz ftp://ftp.gnu.org/pub/gnu/bash-doc-2.03.tar.gz
ftp://ftp.cwru.edu/pub/bash/bash-doc-2.02.tar.gz ftp://ftp.cwru.edu/pub/bash/bash-doc-2.03.tar.gz
4) On what machines will bash run? A4) On what machines will bash run?
Bash has been ported to nearly every version of UNIX. All you Bash has been ported to nearly every version of UNIX. All you
should have to do to build it on a machine for which a port should have to do to build it on a machine for which a port
@ -147,10 +147,10 @@ itself accordingly, using a script created by GNU autoconf.
More information appears in the file `INSTALL' in the distribution. More information appears in the file `INSTALL' in the distribution.
5) Will bash run on operating systems other than Unix? A5) Will bash run on operating systems other than Unix?
Configuration specifics for Unix-like systems such as QNX and Configuration specifics for Unix-like systems such as QNX and
LynxOS are included in the distribution. Bash-2.02 should LynxOS are included in the distribution. Bash-2.03 should
compile and run on Minix 2.0 (patches were contributed), but I 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 don't believe anyone has built bash-2.x on earlier Minix versions
yet. yet.
@ -162,12 +162,12 @@ project. For more information about the project, look at the URL
http://www.cygnus.com/misc/gnu-win32 http://www.cygnus.com/misc/gnu-win32
Cygnus has ported bash-1.14.7, and their port is part of the current Cygnus originally ported bash-1.14.7, and that port was part of their
gnu-win32 release. Cygnus has also done a port of bash-2.01 to the early GNU-Win32 releases. Cygnus has also done a port of bash-2.01 to the
GNU-Win32 environment, and it should be available as part of their next GNU-Win32 environment, and it is available as part of their current
release. release. (They may have upgraded by now.)
Bash-2.02 should require no local Cygnus changes to build and run under Bash-2.03 should require no local Cygnus changes to build and run under
GNU-WIN32. GNU-WIN32.
The Cygnus port works only on Intel machines. There is a port of bash The Cygnus port works only on Intel machines. There is a port of bash
@ -175,9 +175,19 @@ 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 ftp://ftp.gnustep.org//pub/win32/bash-alpha-nt-1.01.tar.gz
Softway Systems has ported bash-2.01.1 to their Interix (nee OpenNT) Softway Systems has ported bash-2.01 to their Interix (nee OpenNT)
system, a Unix subsystem for NT that replaces the Microsoft POSIX system, a Unix subsystem for NT that replaces the Microsoft POSIX
subsystem. Check out http://www.interix.com for more information. 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 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 the DJGPP project. For more information on the project, see
@ -201,12 +211,12 @@ ftp://hobbes.nmsu.edu/pub/os2/util/shell/bash-2.0(253).zip
I haven't looked at either, but the second appears to be a binary-only I haven't looked at either, but the second appears to be a binary-only
distribution. Beware. distribution. Beware.
6) How can I build bash with gcc? A6) How can I build bash with gcc?
Bash configures to use gcc by default if it is available. Read the Bash configures to use gcc by default if it is available. Read the
file INSTALL in the distribution for more information. file INSTALL in the distribution for more information.
7) How can I make bash my login shell? A7) How can I make bash my login shell?
Some machines let you use `chsh' to change your login shell. Other Some machines let you use `chsh' to change your login shell. Other
systems use `passwd -s' or `passwd -e'. If one of these works for systems use `passwd -s' or `passwd -e'. If one of these works for
@ -252,7 +262,7 @@ This will cause login shells to replace themselves with bash running as
a login shell. Once you have this working, you can copy your initialization a login shell. Once you have this working, you can copy your initialization
code from ~/.profile to ~/.bash_profile. code from ~/.profile to ~/.bash_profile.
8) I just changed my login shell to bash, and now I can't FTP into my A8) I just changed my login shell to bash, and now I can't FTP into my
machine. Why not? machine. Why not?
You must add the full pathname to bash to the file /etc/shells. As You must add the full pathname to bash to the file /etc/shells. As
@ -262,7 +272,7 @@ this before you can make bash your login shell.
Most versions of ftpd use this file to prohibit `special' users Most versions of ftpd use this file to prohibit `special' users
such as `uucp' and `news' from using FTP. such as `uucp' and `news' from using FTP.
9) What's the `POSIX 1003.2 standard'? A9) What's the `POSIX 1003.2 standard'?
POSIX is a name originally coined by Richard Stallman for a POSIX is a name originally coined by Richard Stallman for a
family of open system standards based on UNIX. There are a family of open system standards based on UNIX. There are a
@ -297,7 +307,7 @@ line editing. Only vi-style line editing commands have been
standardized; emacs editing commands were left out due to standardized; emacs editing commands were left out due to
objections. objections.
10) What is the bash `posix mode'? A10) What is the bash `posix mode'?
Although bash is an implementation of the POSIX.2 shell Although bash is an implementation of the POSIX.2 shell
specification, there are areas where the bash default behavior specification, there are areas where the bash default behavior
@ -314,9 +324,29 @@ Reference Manual.
Section B: The latest version Section B: The latest version
11) What's new in version 2.02? B1) What's new in version 2.03?
Bash-2.02 has a number of new features. Here's a short list: Bash-2.03 has a 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
folks.
a new shopt option, `restricted_shell', so that startup files can test
whether or not the shell was started in restricted mode
filename generation is now performed on the words between ( and ) in
compound array assignments (this is really a bug fix)
OLDPWD is now auto-exported, as POSIX.2 requires
ENV and BASH_ENV are read-only variables in a restricted shell
Bash may now be linked against an already-installed Readline library,
as long as the Readline library is version 4 or newer
All shells begun with the `--login' option will source the login shell
startup files, even if the shell is not interactive
There are lots of changes to the version of the Readline library released
along with Bash-2.03. For a complete list of the changes, read the file
CHANGES in the Bash-2.03 distribution.
Bash-2.02 contained the following new features:
a new version of malloc (based on the old GNU malloc code in previous a new version of malloc (based on the old GNU malloc code in previous
bash versions) that is more page-oriented, more conservative bash versions) that is more page-oriented, more conservative
@ -382,15 +412,15 @@ grammar tighter and smaller (66 reduce-reduce conflicts gone)
lots of code now smaller and faster lots of code now smaller and faster
test suite greatly expanded test suite greatly expanded
12) Are there any user-visible incompatibilities between bash-2.02 and B2) Are there any user-visible incompatibilities between bash-2.03 and
bash-1.14.7? bash-1.14.7?
There are a few incompatibilities between version 1.14.7 and version 2.02. There are a few incompatibilities between version 1.14.7 and version 2.03.
They are detailed in the file COMPAT in the bash-2.02 distribution. They are detailed in the file COMPAT in the bash-2.03 distribution.
Section C: Differences from other Unix shells Section C: Differences from other Unix shells
13) How does bash differ from sh, the Bourne shell? C1) How does bash differ from sh, the Bourne shell?
This is a non-comprehensive list of features that differentiate bash This is a non-comprehensive list of features that differentiate bash
from the SVR4.2 shell. The bash manual page explains these more from the SVR4.2 shell. The bash manual page explains these more
@ -481,11 +511,12 @@ Implementation differences:
bash allows multiple option arguments when invoked (e.g. -x -v); bash allows multiple option arguments when invoked (e.g. -x -v);
sh allows only a single option argument (`sh -x -v' attempts sh allows only a single option argument (`sh -x -v' attempts
to open a file named `-v', and, on SunOS 4.1.4, dumps core. to open a file named `-v', and, on SunOS 4.1.4, dumps core.
On Solaris 2, sh goes into an infinite loop.) On Solaris 2.4 and earlier versions, sh goes into an infinite
loop.)
sh exits a script if any builtin fails; bash exits only if one of sh exits a script if any builtin fails; bash exits only if one of
the POSIX.2 `special' builtins fails the POSIX.2 `special' builtins fails
14) How does bash differ from the Korn shell, version ksh88? C2) How does bash differ from the Korn shell, version ksh88?
Things bash has or uses that ksh88 does not: Things bash has or uses that ksh88 does not:
long invocation options long invocation options
@ -541,9 +572,9 @@ Implementation differences:
bash has exported functions bash has exported functions
bash command search finds functions before builtins bash command search finds functions before builtins
15) Which new features in ksh-93 are not in bash, and which are? C3) Which new features in ksh-93 are not in bash, and which are?
New things in ksh-93 not in bash-2.02: New things in ksh-93 not in bash-2.03:
associative arrays associative arrays
floating point arithmetic floating point arithmetic
++, --, comma arithmetic operators ++, --, comma arithmetic operators
@ -564,7 +595,7 @@ New things in ksh-93 not in bash-2.02:
read -t/-d read -t/-d
`.' can execute shell functions `.' can execute shell functions
New things in ksh-93 present in bash-2.02: New things in ksh-93 present in bash-2.03:
?: arithmetic operator ?: arithmetic operator
expansions: ${!param}, ${param:offset[:len]}, ${param/pat[/str]} expansions: ${!param}, ${param:offset[:len]}, ${param/pat[/str]}
compound array assignment compound array assignment
@ -588,16 +619,37 @@ New things in ksh-93 present in bash-2.02:
Section D: Why does bash do some things differently than other Unix shells? Section D: Why does bash do some things differently than other Unix shells?
16) Why does bash run a different version of `command' than D1) Why does bash run a different version of `command' than
`which command' says it will? `which command' says it will?
`which' is actually a csh script that assumes you're running csh. On many systems, `which' is actually a csh script that assumes
It reads the csh startup files from your home directory and uses you're running csh. In tcsh, `which' and its cousin `where'
those to determine which `command' will be invoked. Since bash are builtins. On other Unix systems, `which' is a perl script
doesn't use any of those startup files, there's a good chance that uses the PATH environment variable.
that your bash environment differs from your csh environment.
17) Why doesn't bash treat brace expansions exactly like csh? The csh script version reads the csh startup files from your
home directory and uses those to determine which `command' will
be invoked. Since bash doesn't use any of those startup files,
there's a good chance that your bash environment differs from
your csh environment. The bash `type' builtin does everything
`which' does, and will report correct results for the running
shell. If you're really wedded to the name `which', try adding
the following function definition to your .bashrc:
which()
{
builtin type -p "$@"
}
If you're moving from tcsh and would like to bring `where' along
as well, use this function:
where()
{
builtin type -a "$@"
}
D2) Why doesn't bash treat brace expansions exactly like csh?
The only difference between bash and csh brace expansion is that The only difference between bash and csh brace expansion is that
bash requires a brace expression to contain at least one unquoted bash requires a brace expression to contain at least one unquoted
@ -608,7 +660,7 @@ compatibility.
Bash, ksh, zsh, and pd-ksh all implement brace expansion this way. Bash, ksh, zsh, and pd-ksh all implement brace expansion this way.
18) Why doesn't bash have csh variable modifiers? D3) Why doesn't bash have csh variable modifiers?
Posix has specified a more powerful, albeit somewhat more cryptic, Posix has specified a more powerful, albeit somewhat more cryptic,
mechanism cribbed from ksh, and bash implements it. mechanism cribbed from ksh, and bash implements it.
@ -663,7 +715,7 @@ Given
$b:e ${b##*.} xxx $b:e ${b##*.} xxx
19) How can I make my csh aliases work when I convert to bash? 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. Bash uses a different syntax to support aliases than csh does.
The details can be found in the documentation. We have provided The details can be found in the documentation. We have provided
@ -706,7 +758,7 @@ simply `cshtobash' to convert your normal interactive
environment, or as `cshtobash ~/.login' to convert your login environment, or as `cshtobash ~/.login' to convert your login
environment. environment.
20) How can I pipe standard output and standard error from one command to D5) How can I pipe standard output and standard error from one command to
another, like csh does with `|&'? another, like csh does with `|&'?
Use Use
@ -716,7 +768,7 @@ The key is to remember that piping is performed before redirection, so
file descriptor 1 points to the pipe when it is duplicated onto file file descriptor 1 points to the pipe when it is duplicated onto file
descriptor 2. descriptor 2.
21) Now that I've converted from ksh to bash, are there equivalents to D6) Now that I've converted from ksh to bash, are there equivalents to
ksh features like autoloaded functions and the `whence' command? ksh features like autoloaded functions and the `whence' command?
There are features in ksh-88 that do not have direct bash equivalents. There are features in ksh-88 that do not have direct bash equivalents.
@ -735,7 +787,7 @@ read var?prompt read -p prompt var
Section E: How can I get bash to do certain things, and why does bash do Section E: How can I get bash to do certain things, and why does bash do
things the way it does? things the way it does?
22) Why is the bash builtin `test' slightly different from /bin/test? E1) Why is the bash builtin `test' slightly different from /bin/test?
The specific example used here is [ ! x -o x ], which is false. The specific example used here is [ ! x -o x ], which is false.
@ -764,7 +816,7 @@ of the 3 Arg case.
As you can see, the test becomes (not (x or x)), which is false. As you can see, the test becomes (not (x or x)), which is false.
23) Why does bash sometimes say `Broken pipe'? E2) Why does bash sometimes say `Broken pipe'?
If a sequence of commands appears in a pipeline, and one of the If a sequence of commands appears in a pipeline, and one of the
reading commands finishes before the writer has finished, the reading commands finishes before the writer has finished, the
@ -779,7 +831,11 @@ will try to write on a pipe without a reader. In that case, bash
will print `Broken pipe' to stderr when ps is killed by a will print `Broken pipe' to stderr when ps is killed by a
SIGPIPE. SIGPIPE.
24) How can I get bash to read and display eight-bit characters? You can build a version of bash that will not report SIGPIPE errors
by uncommenting the definition of DONT_REPORT_SIGPIPE in the file
config-top.h.
E3) How can I get bash to read and display eight-bit characters?
This is a process requiring several steps. This is a process requiring several steps.
@ -813,7 +869,7 @@ this. These variables can be set in your .inputrc or using the bash
The `set' commands between the single quotes may also be placed The `set' commands between the single quotes may also be placed
in ~/.inputrc. in ~/.inputrc.
25) How do I write a function `x' to replace builtin command `x', but E4) How do I write a function `x' to replace builtin command `x', but
still invoke the command from within the function? still invoke the command from within the function?
This is why the `command' and `builtin' builtins exist. The This is why the `command' and `builtin' builtins exist. The
@ -834,7 +890,7 @@ something like the following:
This could also be written using `command' instead of `builtin'; This could also be written using `command' instead of `builtin';
the version above is marginally more efficient. the version above is marginally more efficient.
26) When I have terminal escape sequences in my prompt, why does bash E5) When I have terminal escape sequences in my prompt, why does bash
wrap lines at the wrong column? wrap lines at the wrong column?
Readline, the line editing library that bash uses, does not know Readline, the line editing library that bash uses, does not know
@ -850,10 +906,10 @@ characters in the prompt strings take up no screen space.
Use the \[ escape to begin a sequence of non-printing characters, Use the \[ escape to begin a sequence of non-printing characters,
and the \] escape to signal the end of such a sequence. and the \] escape to signal the end of such a sequence.
27) How can I find the value of a shell variable whose name is the value E6) How can I find the value of a shell variable whose name is the value
of another shell variable? of another shell variable?
Bash-2.02 supports this directly. You can use Versions of Bash newer than Bash-2.0 support this directly. You can use
${!var} ${!var}
@ -875,13 +931,13 @@ parameter:
The expansion of the quoted portions of this expression will be The expansion of the quoted portions of this expression will be
deferred until `eval' runs, while the `$#' will be expanded deferred until `eval' runs, while the `$#' will be expanded
before `eval' is executed. In bash-2.02, before `eval' is executed. In versions of bash later than bash-2.0,
echo ${!#} echo ${!#}
does the same thing. does the same thing.
28) If I pipe the output of a command into `read variable', why doesn't E7) 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? the output show up in $variable when the read command finishes?
This has to do with the parent-child relationship between Unix This has to do with the parent-child relationship between Unix
@ -937,7 +993,7 @@ this.
This is the general approach -- in most cases you will not need to This is the general approach -- in most cases you will not need to
set $IFS to a different value. set $IFS to a different value.
29) I have a bunch of shell scripts that use backslash-escaped characters E8) I have a bunch of shell scripts that use backslash-escaped characters
in arguments to `echo'. Bash doesn't interpret these characters. Why in arguments to `echo'. Bash doesn't interpret these characters. Why
not, and how can I make it understand them? not, and how can I make it understand them?
@ -957,7 +1013,7 @@ configure with the --enable-usg-echo-default option to turn this
on. Be aware that this will cause some of the tests run when you on. Be aware that this will cause some of the tests run when you
type `make tests' to fail. type `make tests' to fail.
30) Why doesn't a while or for loop get suspended when I type ^Z? E9) Why doesn't a while or for loop get suspended when I type ^Z?
This is a consequence of how job control works on Unix. The only This is a consequence of how job control works on Unix. The only
thing that can be suspended is the process group. This is a single thing that can be suspended is the process group. This is a single
@ -972,8 +1028,8 @@ 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 within parentheses, which will force the loop into a subshell that
may be stopped (and subsequently restarted) as a single unit. may be stopped (and subsequently restarted) as a single unit.
31) How can I make the bash `time' reserved word print timing output that E10) How can I make the bash `time' reserved word print timing output that
looks like the output from my system's /usr/bin/time? looks like the output from my system's /usr/bin/time?
The bash command timing code looks for a variable `TIMEFORMAT' and The bash command timing code looks for a variable `TIMEFORMAT' and
uses its value as a format string to decide how to display the uses its value as a format string to decide how to display the
@ -1006,7 +1062,7 @@ The ksh format can be emulated with:
Section F: Things to watch out for on certain Unix versions Section F: Things to watch out for on certain Unix versions
32) Why can't I use command line editing in my `cmdtool'? F1) Why can't I use command line editing in my `cmdtool'?
The problem is `cmdtool' and bash fighting over the input. When The problem is `cmdtool' and bash fighting over the input. When
scrolling is enabled in a cmdtool window, cmdtool puts the tty in scrolling is enabled in a cmdtool window, cmdtool puts the tty in
@ -1034,7 +1090,7 @@ The bash command-line editing should behave better in the new
cmdtool. If this works, you can put the assignment to TERMCAP cmdtool. If this works, you can put the assignment to TERMCAP
in your bashrc file. in your bashrc file.
33) I built bash on Solaris 2. Why do globbing expansions and filename F2) I built bash on Solaris 2. Why do globbing expansions and filename
completion chop off the first few characters of each filename? completion chop off the first few characters of each filename?
This is the consequence of building bash on SunOS 5 and linking This is the consequence of building bash on SunOS 5 and linking
@ -1054,7 +1110,7 @@ If you have installed the Sun C compiler, you may also need to
put /usr/ccs/bin and /opt/SUNWspro/bin into your $PATH before put /usr/ccs/bin and /opt/SUNWspro/bin into your $PATH before
/usr/ucb. /usr/ucb.
34) Why does bash dump core after I interrupt username completion or F3) Why does bash dump core after I interrupt username completion or
`~user' tilde expansion on a machine running NIS? `~user' tilde expansion on a machine running NIS?
This is a famous and long-standing bug in the SunOS YP (sorry, NIS) This is a famous and long-standing bug in the SunOS YP (sorry, NIS)
@ -1077,7 +1133,7 @@ times; that's probably why this has never been fixed. You can
run configure with the `--without-gnu-malloc' option to use run configure with the `--without-gnu-malloc' option to use
the C library malloc and avoid the problem. the C library malloc and avoid the problem.
35) I'm running SVR4.2. Why is the line erased every time I type `@'? F4) I'm running SVR4.2. Why is the line erased every time I type `@'?
The `@' character is the default `line kill' character in most The `@' character is the default `line kill' character in most
versions of System V, including SVR4.2. You can change this versions of System V, including SVR4.2. You can change this
@ -1088,7 +1144,7 @@ change the line kill character to control-u, type
where the `^' and `U' can be two separate characters. where the `^' and `U' can be two separate characters.
36) Why does bash report syntax errors when my C News scripts use a F5) Why does bash report syntax errors when my C News scripts use a
redirection before a subshell command? redirection before a subshell command?
The actual command in question is something like The actual command in question is something like
@ -1100,7 +1156,7 @@ is, in fact, a syntax error. Redirections may only precede `simple
commands'. A subshell construct such as the above is one of the shell's commands'. A subshell construct such as the above is one of the shell's
`compound commands'. A redirection may only follow a compound command. `compound commands'. A redirection may only follow a compound command.
The file CWRU/sh-redir-hack in the bash-2.02 distribution is an The file CWRU/sh-redir-hack in the bash-2.03 distribution is an
(unofficial) patch to parse.y that will modify the grammar to (unofficial) patch to parse.y that will modify the grammar to
support this construct. It will not apply with `patch'; you must support this construct. It will not apply with `patch'; you must
modify parse.y by hand. Note that if you apply this, you must modify parse.y by hand. Note that if you apply this, you must
@ -1109,7 +1165,7 @@ number of reduce/reduce conflicts into the shell grammar.
Section G: Where do I go from here? Section G: Where do I go from here?
37) How do I report bugs in bash, and where should I look for fixes and G1) How do I report bugs in bash, and where should I look for fixes and
advice? advice?
Use the `bashbug' script to report bugs. It is built and Use the `bashbug' script to report bugs. It is built and
@ -1117,7 +1173,7 @@ installed at the same time as bash. It provides a standard
template for reporting a problem and automatically includes template for reporting a problem and automatically includes
information about your configuration and build environment. information about your configuration and build environment.
`bashbug' sends its reports to bug-bash@prep.ai.mit.edu, which `bashbug' sends its reports to bug-bash@gnu.org, which
is a large mailing list gatewayed to the usenet newsgroup gnu.bash.bug. is a large mailing list gatewayed to the usenet newsgroup gnu.bash.bug.
Bug fixes, answers to questions, and announcements of new releases Bug fixes, answers to questions, and announcements of new releases
@ -1125,24 +1181,23 @@ are all posted to gnu.bash.bug. Discussions concerning bash features
and problems also take place there. and problems also take place there.
To reach the bash maintainers directly, send mail to To reach the bash maintainers directly, send mail to
bash-maintainers@prep.ai.mit.edu. bash-maintainers@gnu.org.
38) What kind of bash documentation is there? G2) What kind of bash documentation is there?
First, look in the doc directory in the bash distribution. It should First, look in the doc directory in the bash distribution. It should
contain at least the following files: contain at least the following files:
bash.1 an extensive, thorough Unix-style manual page bash.1 an extensive, thorough Unix-style manual page
builtins.1 a manual page covering just bash builtin commands builtins.1 a manual page covering just bash builtin commands
bashref.texi a reference manual in GNU info format bashref.texi a reference manual in GNU tex`info format
bash.html an HTML version of the manual page bashref.info an info version of the reference manual
bashref.html an HTML version of the reference manual
FAQ this file FAQ this file
article.ms text of an article written for The Linux Journal article.ms text of an article written for The Linux Journal
readline.3 a man page describing readline readline.3 a man page describing readline
Postscript files created from the above source are available in Postscript, HTML, and ASCII files created from the above source are
the documentation distribution. available in the documentation distribution.
There is additional documentation available for anonymous FTP from host There is additional documentation available for anonymous FTP from host
ftp.cwru.edu in the `pub/bash' directory. ftp.cwru.edu in the `pub/bash' directory.
@ -1158,14 +1213,14 @@ A second edition of this book is available, published in January, 1998.
The ISBN number is 1-56592-347-2. Look for it in the same fine bookstores The ISBN number is 1-56592-347-2. Look for it in the same fine bookstores
or on the web. or on the web.
39) What's coming in future versions? G3) What's coming in future versions?
These are features I plan to include in a future version of bash. 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.02) a bash debugger (a minimally-tested version is included with bash-2.02)
Programmable completion a la zsh Programmable completion a la zsh/tcsh
40) What's on the bash `wish list' for future versions? G4) What's on the bash `wish list' for future versions?
These are features that may or may not appear in a future version of bash. These are features that may or may not appear in a future version of bash.
@ -1177,14 +1232,17 @@ timeouts for the `read' builtin
the ksh-93 ${!prefix*} and ${!prefix@} operators the ksh-93 ${!prefix*} and ${!prefix@} operators
arithmetic ++ and -- prefix and postfix operators arithmetic ++ and -- prefix and postfix operators
date-stamped command history date-stamped command history
a way to bind readline editing key sequences to shell commands
a mechanism to open network connections and assign them to file descriptors
using redirection (like ksh /dev/{tcp,udp})
41) When will the next release appear? G5) When will the next release appear?
The next version will appear sometime in 1998. Never make The next version will appear sometime in 1999. Never make
predictions. predictions.
This document is Copyright 1995, 1996, 1998 by Chester Ramey. This document is Copyright 1995-1999 by Chester Ramey.
Permission is hereby granted, without written agreement and Permission is hereby granted, without written agreement and
without license or royalty fees, to use, copy, and distribute without license or royalty fees, to use, copy, and distribute

View file

@ -134,7 +134,7 @@ have access to all of the shell facilities.
Help Help
Bash includes a built-in help factility. Bash includes a built-in help facility.
Shell Optional Behavior Shell Optional Behavior

View file

@ -1,5 +1,6 @@
# This Makefile is for the Bash/documentation directory -*- text -*-. # This Makefile is for the Bash/documentation directory -*- text -*-.
# #
SHELL = @MAKE_SHELL@
RM = rm -f RM = rm -f
topdir = @top_srcdir@ topdir = @top_srcdir@
@ -84,11 +85,17 @@ RLUSER = $(RL_LIBDIR)/doc/rluser.texinfo
all: ps info dvi text html all: ps info dvi text html
nodvi: ps info text html nodvi: ps info text html
ps: bash.ps bashbug.ps readline.ps article.ps builtins.ps PSFILES = bash.ps bashbug.ps readline.ps article.ps builtins.ps
dvi: bashref.dvi bashref.ps DVIFILES = bashref.dvi bashref.ps
info: bashref.info INFOFILES = bashref.info
text: bash.0 bashbug.0 builtins.0 readline.0 MAN0FILES = bash.0 bashbug.0 builtins.0 readline.0
html: bashref.html bash.html HTMLFILES = bashref.html bash.html
ps: ${PSFILES}
dvi: ${DVIFILES}
info: ${INFOFILES}
text: ${MAN0FILES}
html: ${HTMLFILES}
bashref.dvi: $(srcdir)/bashref.texi $(HSUSER) $(RLUSER) bashref.dvi: $(srcdir)/bashref.texi $(HSUSER) $(RLUSER)
TEXINPUTS=.:$(TEXINPUTDIR):$$TEXINPUTS $(TEXI2DVI) $(srcdir)/bashref.texi TEXINPUTS=.:$(TEXINPUTDIR):$$TEXINPUTS $(TEXI2DVI) $(srcdir)/bashref.texi
@ -101,7 +108,7 @@ bashref.info: $(srcdir)/bashref.texi $(HSUSER) $(RLUSER)
$(MAKEINFO) --no-split -I$(TEXINPUTDIR) $(srcdir)/bashref.texi $(MAKEINFO) --no-split -I$(TEXINPUTDIR) $(srcdir)/bashref.texi
bashref.html: bashref.texi $(HSUSER) $(RLUSER) bashref.html: bashref.texi $(HSUSER) $(RLUSER)
$(TEXI2HTML) -I $(TEXINPUTDIR) $(srcdir)/bashref.texi $(TEXI2HTML) -menu -monolithic -I $(TEXINPUTDIR) $(srcdir)/bashref.texi
bash.dvi: bash.texinfo $(HSUSER) $(RLUSER) bash.dvi: bash.texinfo $(HSUSER) $(RLUSER)
TEXINPUTS=.:$(TEXINPUTDIR):$$TEXINPUTS $(TEXI2DVI) bash.texinfo TEXINPUTS=.:$(TEXINPUTDIR):$$TEXINPUTS $(TEXI2DVI) bash.texinfo
@ -125,7 +132,9 @@ article.ps: article.ms
$(MAN2HTML): ${topdir}/support/man2html.c $(MAN2HTML): ${topdir}/support/man2html.c
-( cd ${BUILD_DIR}/support ; ${MAKE} ${MFLAGS} man2html) -( cd ${BUILD_DIR}/support ; ${MAKE} ${MFLAGS} man2html)
faq: faq.news faq.news2 faq.mail faq.version CREATED_FAQ = faq.news faq.news2 faq.mail faq.version
faq: ${CREATED_FAQ}
faq.version: FAQ.version FAQ faq.version: FAQ.version FAQ
sh mkfaqvers FAQ.version > $@ sh mkfaqvers FAQ.version > $@
@ -143,15 +152,16 @@ faq.mail: FAQ FAQ.headers.mail faq.version
cat FAQ.headers.mail faq.version FAQ > $@ cat FAQ.headers.mail faq.version FAQ > $@
clean: clean:
$(RM) *.aux *.cp *.fn *.ky *.log *.pg *.toc *.tp *.vr *.cps \ $(RM) *.aux *.bak *.cp *.fn *.ky *.log *.pg *.toc *.tp *.vr *.cps \
*.pgs *.bt *.bts *.rw *.rws *.fns *.kys *.tps *.vrs *.o \ *.pgs *.bt *.bts *.rw *.rws *.fns *.kys *.tps *.vrs *.o
core rluser.texinfo hsuser.texinfo ${RM} core *.core
distclean mostlyclean: clean distclean mostlyclean: clean
$(RM) Makefile $(RM) Makefile
maintainer-clean: clean maintainer-clean: clean
$(RM) *.0 *.ps *.dvi *.info *.txt ${RM} ${PSFILES} ${DVIFILES} ${INFOFILES} ${MAN0FILES} ${HTMLFILES}
${RM} ${CREATED_FAQ}
$(RM) Makefile $(RM) Makefile
installdirs: installdirs:
@ -166,7 +176,7 @@ install: info installdirs
# uncomment the next line to install the readline man page # uncomment the next line to install the readline man page
# -$(INSTALL_DATA) $(srcdir)/readline.3 $(man3dir)/readline.${man3ext} # -$(INSTALL_DATA) $(srcdir)/readline.3 $(man3dir)/readline.${man3ext}
# uncomment the next line to install the builtins man page # uncomment the next line to install the builtins man page
# $(INSTALL_DATA) builtins.1 $(man1dir)/bash_builtins.${man1ext} # $(INSTALL_DATA) $(srcdir)/builtins.1 $(man1dir)/bash_builtins.${man1ext}
-$(INSTALL_DATA) $(srcdir)/bashref.info $(infodir)/bash.info -$(INSTALL_DATA) $(srcdir)/bashref.info $(infodir)/bash.info
# run install-info if it is present to update the info directory # run install-info if it is present to update the info directory
if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then \ if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then \

View file

@ -1,11 +1,12 @@
This directory contains the bash documentation. This directory contains the bash documentation.
FAQ - a set of frequently-asked questions about Bash with answers FAQ - a set of frequently-asked questions about Bash with answers
INTRO - a short introduction to bash
article.ms - an article I wrote about bash for The Linux Journal article.ms - an article I wrote about bash for The Linux Journal
bash.1 - the bash man page bash.1 - the bash man page
builtins.1 - a man page that documents the builtins, extracted from bash.1 builtins.1 - a man page that documents the builtins, extracted from bash.1
features.texi - the `bash reference manual' bashref.texi - the `bash reference manual'
features.info - the `bash reference manual' processed by `makeinfo' bashref.info - the `bash reference manual' processed by `makeinfo'
readline.3 - the readline man page readline.3 - the readline man page
The `.ps' files are postscript versions of the above. The `.html' The `.ps' files are postscript versions of the above. The `.html'

View file

@ -6,11 +6,11 @@
.\" Case Western Reserve University .\" Case Western Reserve University
.\" chet@ins.CWRU.Edu .\" chet@ins.CWRU.Edu
.\" .\"
.\" Last Change: Wed Apr 1 12:16:09 EST 1998 .\" Last Change: Wed Jan 20 16:47:14 EST 1999
.\" .\"
.\" bash_builtins, strip all but Built-Ins section .\" bash_builtins, strip all but Built-Ins section
.if \n(zZ=1 .ig zZ .if \n(zZ=1 .ig zZ
.TH BASH 1 "1998 Apr 1" GNU .TH BASH 1 "1999 Jan 20" GNU
.\" .\"
.\" There's some problem with having a `@' .\" There's some problem with having a `@'
.\" in a tagged paragraph with the BSD man macros. .\" in a tagged paragraph with the BSD man macros.
@ -50,8 +50,8 @@ bash \- GNU Bourne-Again SHell
[options] [options]
[file] [file]
.SH COPYRIGHT .SH COPYRIGHT
.if n Bash is Copyright (C) 1989, 1991, 1993, 1995, 1996 by the Free Software Foundation, Inc. .if n Bash is Copyright (C) 1989-1999 by the Free Software Foundation, Inc.
.if t Bash is Copyright \(co 1989, 1991, 1993, 1995, 1996 by the Free Software Foundation, Inc. .if t Bash is Copyright \(co 1989-1999 by the Free Software Foundation, Inc.
.SH DESCRIPTION .SH DESCRIPTION
.B Bash .B Bash
is an \fBsh\fR-compatible command language interpreter that is an \fBsh\fR-compatible command language interpreter that
@ -260,7 +260,8 @@ section.
.PP .PP
When When
.B bash .B bash
is invoked as an interactive login shell, it first reads and is invoked as an interactive login shell, or as a non-interactive shell
with the \fB\-\-login\fP option, it first reads and
executes commands from the file \fI/etc/profile\fP, if that executes commands from the file \fI/etc/profile\fP, if that
file exists. file exists.
After reading that file, it looks for \fI~/.bash_profile\fP, After reading that file, it looks for \fI~/.bash_profile\fP,
@ -313,7 +314,8 @@ it tries to mimic the startup behavior of historical versions of
.B sh .B sh
as closely as possible, as closely as possible,
while conforming to the POSIX standard as well. while conforming to the POSIX standard as well.
When invoked as an interactive login shell, it first attempts to When invoked as an interactive login shell, or a non-interactive
shell with the \fB\-\-login\fP option, it first attempts to
read and execute commands from read and execute commands from
.I /etc/profile .I /etc/profile
and and
@ -338,7 +340,7 @@ files, the
option has no effect. option has no effect.
A non-interactive shell invoked with the name A non-interactive shell invoked with the name
.B sh .B sh
does not attempt to read any startup files. does not attempt to read any other startup files.
When invoked as When invoked as
.BR sh , .BR sh ,
.B bash .B bash
@ -375,6 +377,14 @@ option may be used to inhibit this behavior, and the
option may be used to force another file to be read, but option may be used to force another file to be read, but
\fIrshd\fP does not generally invoke the shell with those options \fIrshd\fP does not generally invoke the shell with those options
or allow them to be specified. or allow them to be specified.
.PP
If the shell is started with the effective user (group) id not equal to the
real user (group) id, and the \fB\-p\fP option is not supplied, no startup
files are read, shell functions are not inherited from the environment,
the \fBSHELLOPTS\fP variable, if it appears in the environment, is ignored,
and the effective user id is set to the real user id.
If the \fB\-p\fP option is supplied at invocation, the startup behavior is
the same, but the effective user id is not reset.
.SH DEFINITIONS .SH DEFINITIONS
.PP .PP
The following definitions are used throughout the rest of this The following definitions are used throughout the rest of this
@ -646,7 +656,7 @@ operators do not execute \fIexpression2\fP if the value of
\fIexpression1\fP is sufficient to determine the return value of \fIexpression1\fP is sufficient to determine the return value of
the entire conditional expression. the entire conditional expression.
.TP .TP
\fBfor\fP \fIname\fP [ \fBin\fP \fIword\fP; ] \fBdo\fP \fIlist\fP ; \fBdone\fP \fBfor\fP \fIname\fP [ \fBin\fP \fIword\fP ] ; \fBdo\fP \fIlist\fP ; \fBdone\fP
The list of words following \fBin\fP is expanded, generating a list The list of words following \fBin\fP is expanded, generating a list
of items. The variable \fIname\fP is set to each element of this list of items. The variable \fIname\fP is set to each element of this list
in turn, and \fIlist\fP is executed each time. If the \fBin\fP in turn, and \fIlist\fP is executed each time. If the \fBin\fP
@ -659,7 +669,7 @@ The return status is the exit status of the last command that executes.
If the expansion of the items following \fBin\fP results in an empty If the expansion of the items following \fBin\fP results in an empty
list, no commands are executed, and the return status is 0. list, no commands are executed, and the return status is 0.
.TP .TP
\fBselect\fP \fIname\fP [ \fBin\fP \fIword\fP; ] \fBdo\fP \fIlist\fP ; \fBdone\fP \fBselect\fP \fIname\fP [ \fBin\fP \fIword\fP ] ; \fBdo\fP \fIlist\fP ; \fBdone\fP
The list of words following \fBin\fP is expanded, generating a list The list of words following \fBin\fP is expanded, generating a list
of items. The set of expanded words is printed on the standard of items. The set of expanded words is printed on the standard
error, each preceded by a number. If the \fBin\fP error, each preceded by a number. If the \fBin\fP
@ -2095,9 +2105,9 @@ In the first form, only the first match is replaced.
The second form causes all matches of \fIpattern\fP to be The second form causes all matches of \fIpattern\fP to be
replaced with \fIstring\fP. replaced with \fIstring\fP.
If \fIpattern\fP begins with \fB#\fP, it must match at the beginning If \fIpattern\fP begins with \fB#\fP, it must match at the beginning
of \fIstring\fP. of the expanded value of \fIparameter\fP.
If \fIpattern\fP begins with \fB%\fP, it must match at the end If \fIpattern\fP begins with \fB%\fP, it must match at the end
of \fIstring\fP. of the expanded value of \fIparameter\fP.
If \fIstring\fP is null, matches of \fIpattern\fP are deleted If \fIstring\fP is null, matches of \fIpattern\fP are deleted
and the \fB/\fP following \fIpattern\fP may be omitted. and the \fB/\fP following \fIpattern\fP may be omitted.
If If
@ -2985,6 +2995,9 @@ True if \fIfile\fP exists and is a regular file.
.B \-g \fIfile\fP .B \-g \fIfile\fP
True if \fIfile\fP exists and is set-group-id. True if \fIfile\fP exists and is set-group-id.
.TP .TP
.B \-h \fIfile\fP
True if \fIfile\fP exists and is a symbolic link.
.TP
.B \-k \fIfile\fP .B \-k \fIfile\fP
True if \fIfile\fP exists and its ``sticky'' bit is set. True if \fIfile\fP exists and its ``sticky'' bit is set.
.TP .TP
@ -4032,6 +4045,12 @@ regardless of what the terminal claims it can support. The name
.B meta\-flag .B meta\-flag
is a synonym for this variable. is a synonym for this variable.
.TP .TP
.B isearch\-terminators (``C\-[C\-J'')
The string of characters that should terminate an incremental
search without subsequently executing the character as a command.
If this variable has not been given a value, the characters
\fIESC\fP and \fIC\-J\fP will terminate an incremental search.
.TP
.B keymap (emacs) .B keymap (emacs)
Set the current readline keymap. The set of valid keymap names is Set the current readline keymap. The set of valid keymap names is
\fIemacs, emacs\-standard, emacs\-meta, emacs\-ctlx, vi, \fIemacs, emacs\-standard, emacs\-meta, emacs\-ctlx, vi,
@ -4159,8 +4178,10 @@ As each character of the search string is typed, readline displays
the next entry from the history matching the string typed so far. the next entry from the history matching the string typed so far.
An incremental search requires only as many characters as needed to An incremental search requires only as many characters as needed to
find the desired history entry. find the desired history entry.
The Escape character is used to terminate an incremental search. The characters present in the value of the \fIisearch-terminators\fP
Control-J will also terminate the search. variable are used to terminate an incremental search.
If that variable has not been assigned a value the Escape and
Control-J characters will terminate an incremental search.
Control-G will abort an incremental search and restore the original Control-G will abort an incremental search and restore the original
line. line.
When the search is terminated, the history entry containing the When the search is terminated, the history entry containing the
@ -4341,6 +4362,11 @@ then return
Delete the character behind the cursor. When given a numeric argument, Delete the character behind the cursor. When given a numeric argument,
save the deleted text on the kill ring. save the deleted text on the kill ring.
.TP .TP
.B forward\-backward\-delete\-char
Delete the character under the cursor, unless the cursor is at the
end of the line, in which case the character behind the cursor is
deleted. By default, this is not bound to a key.
.TP
.B quoted\-insert (C\-q, C\-v) .B quoted\-insert (C\-q, C\-v)
Add the next character typed to the line verbatim. This is Add the next character typed to the line verbatim. This is
how to insert characters like \fBC\-q\fP, for example. how to insert characters like \fBC\-q\fP, for example.
@ -4487,6 +4513,13 @@ through the list.
This command is intended to be bound to \fBTAB\fP, but is unbound This command is intended to be bound to \fBTAB\fP, but is unbound
by default. by default.
.TP .TP
.B delete\-char\-or\-list
Deletes the character under the cursor if not at the beginning or
end of the line (like \fBdelete-char\fP).
If at the end of the line, behaves identically to
\fBpossible-completions\fP.
This command is unbound by default.
.TP
.B complete\-filename (M\-/) .B complete\-filename (M\-/)
Attempt filename completion on the text before point. Attempt filename completion on the text before point.
.TP .TP
@ -4588,7 +4621,7 @@ Undo all changes made to this line. This is like executing the
.B undo .B undo
command enough times to return the line to its initial state. command enough times to return the line to its initial state.
.TP .TP
.B tilde\-expand (M\-~) .B tilde\-expand (M\-&)
Perform tilde expansion on the current word. Perform tilde expansion on the current word.
.TP .TP
.B set\-mark (C\-@, M\-<space>) .B set\-mark (C\-@, M\-<space>)
@ -6210,13 +6243,17 @@ The characters in
.SM .SM
.B IFS .B IFS
are used to split the line into words. are used to split the line into words.
The backslash character (\fB\e\fP) may be used to remove any special
meaning for the next character read and for line continuation.
Options, if supplied, have the following meanings: Options, if supplied, have the following meanings:
.RS .RS
.PD 0 .PD 0
.TP .TP
.B \-r .B \-r
A backslash-newline pair is not ignored, and Backslash does not act as an escape character.
the backslash is considered to be part of the line. The backslash is considered to be part of the line.
In particular, a backslash-newline pair may not be used as a line
continuation.
.TP .TP
.B \-p .B \-p
Display \fIprompt\fP, without a Display \fIprompt\fP, without a
@ -6487,11 +6524,16 @@ Turn on
.I privileged .I privileged
mode. In this mode, the mode. In this mode, the
.B $ENV .B $ENV
file is not processed, shell functions are not inherited from the and
environment, and the variable .B $BASH_ENV
The \fBSHELLOPTS\fP variable, if it appears in the environment, is ignored. files are not processed, shell functions are not inherited from the
This is enabled automatically on startup if the effective user (group) environment, and the \fBSHELLOPTS\fP variable, if it appears in the
id is not equal to the real user (group) id. environment, is ignored.
If the shell is started with the effective user (group) id not equal to the
real user (group) id, and the \fB\-p\fP option is not supplied, these actions
are taken and the effective user id is set to the real user id.
If the \fB\-p\fP option is supplied at startup, the effective user id is
not reset.
Turning this option off causes the effective user Turning this option off causes the effective user
and group ids to be set to the real user and group ids. and group ids to be set to the real user and group ids.
.TP 8 .TP 8
@ -6794,6 +6836,15 @@ being expanded as described in
.B PROMPTING .B PROMPTING
above. This option is enabled by default. above. This option is enabled by default.
.TP 8 .TP 8
.B restricted_shell
The shell sets this option if it is started in restricted mode (see
.SM
.B "RESTRICTED SHELL"
below).
The value may not be changed.
This is not reset when the startup files are executed, allowing
the startup files to discover whether or not a shell is restricted.
.TP 8
.B shift_verbose .B shift_verbose
If set, the If set, the
.B shift .B shift
@ -7232,9 +7283,11 @@ with the exception that the following are disallowed or not performed:
changing directories with \fBcd\fP changing directories with \fBcd\fP
.IP \(bu .IP \(bu
setting or unsetting the values of setting or unsetting the values of
.B SHELL .BR SHELL ,
.BR PATH ,
.BR ENV ,
or or
.B PATH .B BASH_ENV
.IP \(bu .IP \(bu
specifying command names containing specifying command names containing
.B / .B /
@ -7313,6 +7366,9 @@ The personal initialization file, executed for login shells
.FN ~/.bashrc .FN ~/.bashrc
The individual per-interactive-shell startup file The individual per-interactive-shell startup file
.TP .TP
.FN ~/.bash_logout
The individual login shell cleanup file, executed when a login shell exits
.TP
.FN ~/.inputrc .FN ~/.inputrc
Individual \fIreadline\fP initialization file Individual \fIreadline\fP initialization file
.PD .PD

View file

@ -1,4 +1,4 @@
.TH BASHBUG 1 "1995 August 10" GNU .TH BASHBUG 1 "1998 July 30" GNU
.SH NAME .SH NAME
bashbug \- report a bug in bash bashbug \- report a bug in bash
.SH SYNOPSIS .SH SYNOPSIS
@ -14,7 +14,7 @@ invokes the editor specified by the environment variable
on a temporary copy of the bug report format outline. The user must on a temporary copy of the bug report format outline. The user must
fill in the appropriate fields and exit the editor. fill in the appropriate fields and exit the editor.
.B bashbug .B bashbug
then mails the completed report to \fIbug-bash@prep.ai.mit.edu\fP, or then mails the completed report to \fIbug-bash@gnu.org\fP, or
\fIaddress\fP. If the report cannot be mailed, it is saved in the \fIaddress\fP. If the report cannot be mailed, it is saved in the
file \fIdead.bashbug\fP in the invoking user's home directory. file \fIdead.bashbug\fP in the invoking user's home directory.
.PP .PP

View file

@ -9,11 +9,11 @@ END-INFO-DIR-ENTRY
This text is a brief description of the features that are present in This text is a brief description of the features that are present in
the Bash shell. the Bash shell.
This is Edition 2.2, last updated 1 April 1998, This is Edition 2.3, last updated 20 January 1999,
of `The GNU Bash Reference Manual', of `The GNU Bash Reference Manual',
for `Bash', Version 2.02. for `Bash', Version 2.03.
Copyright (C) 1991, 1993, 1996, 1997 Free Software Foundation, Inc. Copyright (C) 1991-1999 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice this manual provided the copyright notice and this permission notice
@ -38,8 +38,8 @@ Bash Features
This text is a brief description of the features that are present in This text is a brief description of the features that are present in
the Bash shell. the Bash shell.
This is Edition 2.2, last updated 1 April 1998, of `The GNU Bash This is Edition 2.3, last updated 20 January 1999, of `The GNU Bash
Reference Manual', for `Bash', Version 2.02. Reference Manual', for `Bash', Version 2.03.
Copyright (C) 1991, 1993, 1996 Free Software Foundation, Inc. Copyright (C) 1991, 1993, 1996 Free Software Foundation, Inc.
@ -1232,15 +1232,16 @@ parameter that is unset.
against its value is replaced with STRING. In the first form, against its value is replaced with STRING. In the first form,
only the first match is replaced. The second form causes all only the first match is replaced. The second form causes all
matches of PATTERN to be replaced with STRING. If PATTERN begins matches of PATTERN to be replaced with STRING. If PATTERN begins
with `#', it must match at the beginning of STRING. If PATTERN with `#', it must match at the beginning of the expanded value of
begins with `%', it must match at the end of STRING. If STRING is PARAMETER. If PATTERN begins with `%', it must match at the end
null, matches of PATTERN are deleted and the `/' following PATTERN of the expanded value of PARAMETER. If STRING is null, matches of
may be omitted. If PARAMETER is `@' or `*', the substitution PATTERN are deleted and the `/' following PATTERN may be omitted.
operation is applied to each positional parameter in turn, and the If PARAMETER is `@' or `*', the substitution operation is applied
expansion is the resultant list. If PARAMETER is an array to each positional parameter in turn, and the expansion is the
variable subscripted with `@' or `*', the substitution operation resultant list. If PARAMETER is an array variable subscripted
is applied to each member of the array in turn, and the expansion with `@' or `*', the substitution operation is applied to each
is the resultant list. member of the array in turn, and the expansion is the resultant
list.
 
File: bashref.info, Node: Command Substitution, Next: Arithmetic Expansion, Prev: Shell Parameter Expansion, Up: Shell Expansions File: bashref.info, Node: Command Substitution, Next: Arithmetic Expansion, Prev: Shell Parameter Expansion, Up: Shell Expansions
@ -1982,14 +1983,16 @@ standard.
The return status is zero. The return status is zero.
`.' `.'
. FILENAME . FILENAME [ARGUMENTS]
Read and execute commands from the FILENAME argument in the Read and execute commands from the FILENAME argument in the
current shell context. If FILENAME does not contain a slash, the current shell context. If FILENAME does not contain a slash, the
`$PATH' variable is used to find FILENAME. The current directory `$PATH' variable is used to find FILENAME. The current directory
is searched if FILENAME is not found in `$PATH'. The return is searched if FILENAME is not found in `$PATH'. If any ARGUMENTS
status is the exit status of the last command executed, or zero if are supplied, they become the positional parameters when FILENAME
no commands are executed. If FILENAME is not found, or cannot be is executed. Otherwise the positional parameters are unchanged.
read, the return status is non-zero. The return status is the exit status of the last command executed,
or zero if no commands are executed. If FILENAME is not found, or
cannot be read, the return status is non-zero.
`break' `break'
break [N] break [N]
@ -2762,8 +2765,9 @@ of the files exist but cannot be read, Bash reports an error. Tildes
are expanded in file names as described above under Tilde Expansion are expanded in file names as described above under Tilde Expansion
(*note Tilde Expansion::.). (*note Tilde Expansion::.).
When Bash is invoked as an interactive login shell, it first reads When Bash is invoked as an interactive login shell, or as a
and executes commands from the file `/etc/profile', if that file exists. non-interactive shell with the `--login' option, it first reads and
executes commands from the file `/etc/profile', if that file exists.
After reading that file, it looks for `~/.bash_profile', After reading that file, it looks for `~/.bash_profile',
`~/.bash_login', and `~/.profile', in that order, and reads and `~/.bash_login', and `~/.profile', in that order, and reads and
executes commands from the first one that exists and is readable. The executes commands from the first one that exists and is readable. The
@ -2798,16 +2802,17 @@ name.
behavior of historical versions of `sh' as closely as possible, while behavior of historical versions of `sh' as closely as possible, while
conforming to the POSIX standard as well. conforming to the POSIX standard as well.
When invoked as an interactive login shell, it first attempts to read When invoked as an interactive login shell, or as a non-interactive
and execute commands from `/etc/profile' and `~/.profile', in that shell with the `--login' option, it first attempts to read and execute
order. The `--noprofile' option may be used to inhibit this behavior. commands from `/etc/profile' and `~/.profile', in that order. The
When invoked as an interactive shell with the name `sh', Bash looks for `--noprofile' option may be used to inhibit this behavior. When
the variable `ENV', expands its value if it is defined, and uses the invoked as an interactive shell with the name `sh', Bash looks for the
variable `ENV', expands its value if it is defined, and uses the
expanded value as the name of a file to read and execute. Since a expanded value as the name of a file to read and execute. Since a
shell invoked as `sh' does not attempt to read and execute commands shell invoked as `sh' does not attempt to read and execute commands
from any other startup files, the `--rcfile' option has no effect. A from any other startup files, the `--rcfile' option has no effect. A
non-interactive shell invoked with the name `sh' does not attempt to non-interactive shell invoked with the name `sh' does not attempt to
read any startup files. read any other startup files.
When invoked as `sh', Bash enters POSIX mode after the startup files When invoked as `sh', Bash enters POSIX mode after the startup files
are read. are read.
@ -2827,6 +2832,14 @@ may be used to force another file to be read, but `rshd' does not
generally invoke the shell with those options or allow them to be generally invoke the shell with those options or allow them to be
specified. specified.
If Bash is started with the effective user (group) id not equal to
the real user (group) id, and the `-p' option is not supplied, no
startup files are read, shell functions are not inherited from the
environment, the `SHELLOPTS' variable, if it appears in the
environment, is ignored, and the effective user id is set to the real
user id. If the `-p' option is supplied at invocation, the startup
behavior is the same, but the effective user id is not reset.
 
File: bashref.info, Node: Is This Shell Interactive?, Next: Bash Builtins, Prev: Bash Startup Files, Up: Bash Features File: bashref.info, Node: Is This Shell Interactive?, Next: Bash Builtins, Prev: Bash Startup Files, Up: Bash Features
@ -3126,15 +3139,18 @@ been extended in Bash.
assigned to the last NAME. If there are fewer words read from the assigned to the last NAME. If there are fewer words read from the
standard input than names, the remaining names are assigned empty standard input than names, the remaining names are assigned empty
values. The characters in the value of the `IFS' variable are values. The characters in the value of the `IFS' variable are
used to split the line into words. If no names are supplied, the used to split the line into words. The backslash character `\'
may be used to remove any special meaning for the next character
read and for line continuation. If no names are supplied, the
line read is assigned to the variable `REPLY'. The return code is line read is assigned to the variable `REPLY'. The return code is
zero, unless end-of-file is encountered. Options, if supplied, zero, unless end-of-file is encountered. Options, if supplied,
have the following meanings: have the following meanings:
`-r' `-r'
If this option is given, a backslash-newline pair is not If this option is given, backslash does not act as an escape
ignored, and the backslash is considered to be part of the character. The backslash is considered to be part of the
line. line. In particular, a backslash-newline pair may not be
used as a line continuation.
`-p PROMPT' `-p PROMPT'
Display PROMPT, without a trailing newline, before attempting Display PROMPT, without a trailing newline, before attempting
@ -3287,6 +3303,13 @@ been extended in Bash.
expansion after being expanded (*note Printing a Prompt::.). expansion after being expanded (*note Printing a Prompt::.).
This option is enabled by default. This option is enabled by default.
`restricted_shell'
The shell sets this option if it is started in restricted mode
(*note The Restricted Shell::.). The value may not be
changed. This is not reset when the startup files are
executed, allowing the startup files to discover whether or
not a shell is restricted.
`shift_verbose' `shift_verbose'
If this is set, the `shift' builtin prints an error message If this is set, the `shift' builtin prints an error message
when the shift count exceeds the number of positional when the shift count exceeds the number of positional
@ -3527,11 +3550,14 @@ The Set Builtin
Turn on privileged mode. In this mode, the `$BASH_ENV' and Turn on privileged mode. In this mode, the `$BASH_ENV' and
`$ENV' files are not processed, shell functions are not `$ENV' files are not processed, shell functions are not
inherited from the environment, and the `SHELLOPTS' variable, inherited from the environment, and the `SHELLOPTS' variable,
if it appears in the environment, is ignored. This is if it appears in the environment, is ignored. If the shell
enabled automatically on startup if the effective user is started with the effective user (group) id not equal to the
(group) id is not equal to the real user (group) id. Turning real user (group) id, and the `-p' option is not supplied,
this option off causes the effective user and group ids to be these actions are taken and the effective user id is set to
set to the real user and group ids. the real user id. If the `-p' option is supplied at startup,
the effective user id is not reset. Turning this option off
causes the effective user and group ids to be set to the real
user and group ids.
`-t' `-t'
Exit after reading and executing one command. Exit after reading and executing one command.
@ -3640,6 +3666,9 @@ checked.
`-g FILE' `-g FILE'
True if FILE exists and its set-group-id bit is set. True if FILE exists and its set-group-id bit is set.
`-h FILE'
True if FILE exists and is a symbolic link.
`-k FILE' `-k FILE'
True if FILE exists and its "sticky" bit is set. True if FILE exists and its "sticky" bit is set.
@ -4450,7 +4479,8 @@ the standard shell. A restricted shell behaves identically to `bash'
with the exception that the following are disallowed: with the exception that the following are disallowed:
* Changing directories with the `cd' builtin. * Changing directories with the `cd' builtin.
* Setting or unsetting the values of the `SHELL' or `PATH' variables. * Setting or unsetting the values of the `SHELL', `PATH', `ENV', or
`BASH_ENV' variables.
* Specifying command names containing slashes. * Specifying command names containing slashes.
@ -5346,18 +5376,19 @@ string. There are two search modes: INCREMENTAL and NON-INCREMENTAL.
search string. As each character of the search string is typed, search string. As each character of the search string is typed,
Readline displays the next entry from the history matching the string Readline displays the next entry from the history matching the string
typed so far. An incremental search requires only as many characters typed so far. An incremental search requires only as many characters
as needed to find the desired history entry. The <ESC> character is as needed to find the desired history entry. The characters present in
used to terminate an incremental search. <C-j> will also terminate the the value of the ISEARCH-TERMINATORS variable are used to terminate an
search. <C-g> will abort an incremental search and restore the incremental search. If that variable has not been assigned a value,
original line. When the search is terminated, the history entry the <ESC> and <C-J> characters will terminate an incremental search.
containing the search string becomes the current line. To find other <C-g> will abort an incremental search and restore the original line.
matching entries in the history list, type <C-s> or <C-r> as When the search is terminated, the history entry containing the search
appropriate. This will search backward or forward in the history for string becomes the current line. To find other matching entries in the
the next entry matching the search string typed so far. Any other key history list, type <C-s> or <C-r> as appropriate. This will search
sequence bound to a Readline command will terminate the search and backward or forward in the history for the next entry matching the
execute that command. For instance, a <RET> will terminate the search search string typed so far. Any other key sequence bound to a Readline
and accept the line, thereby executing the command from the history command will terminate the search and execute that command. For
list. instance, a <RET> will terminate the search and accept the line,
thereby executing the command from the history list.
Non-incremental searches read the entire search string before Non-incremental searches read the entire search string before
starting to search for matching history lines. The search string may be starting to search for matching history lines. The search string may be
@ -5471,6 +5502,20 @@ Variable Settings
longer than the width of the screen, instead of wrapping onto longer than the width of the screen, instead of wrapping onto
a new screen line. By default, this variable is set to `off'. a new screen line. By default, this variable is set to `off'.
`input-meta'
If set to `on', Readline will enable eight-bit input (it will
not strip the eighth bit from the characters it reads),
regardless of what the terminal claims it can support. The
default value is `off'. The name `meta-flag' is a synonym
for this variable.
`isearch-terminators'
The string of characters that should terminate an incremental
search without subsequently executing the character as a
command (*note Searching::.). If this variable has not been
given a value, the characters <ESC> and <C-J> will terminate
an incremental search.
`keymap' `keymap'
Sets Readline's idea of the current keymap for key binding Sets Readline's idea of the current keymap for key binding
commands. Acceptable `keymap' names are `emacs', commands. Acceptable `keymap' names are `emacs',
@ -5489,13 +5534,6 @@ Variable Settings
asterisk (`*') at the start of history lines which have been asterisk (`*') at the start of history lines which have been
modified. This variable is `off' by default. modified. This variable is `off' by default.
`input-meta'
If set to `on', Readline will enable eight-bit input (it will
not strip the eighth bit from the characters it reads),
regardless of what the terminal claims it can support. The
default value is `off'. The name `meta-flag' is a synonym
for this variable.
`output-meta' `output-meta'
If set to `on', Readline will display characters with the If set to `on', Readline will display characters with the
eighth bit set directly rather than as a meta-prefixed escape eighth bit set directly rather than as a meta-prefixed escape
@ -5929,6 +5967,11 @@ Commands For Changing Text
Delete the character behind the cursor. A numeric argument means Delete the character behind the cursor. A numeric argument means
to kill the characters instead of deleting them. to kill the characters instead of deleting them.
`forward-backward-delete-char ()'
Delete the character under the cursor, unless the cursor is at the
end of the line, in which case the character behind the cursor is
deleted. By default, this is not bound to a key.
`quoted-insert (C-q, C-v)' `quoted-insert (C-q, C-v)'
Add the next character typed to the line verbatim. This is how to Add the next character typed to the line verbatim. This is how to
insert key sequences like <C-q>, for example. insert key sequences like <C-q>, for example.
@ -6083,6 +6126,12 @@ Letting Readline Type For You
This command is intended to be bound to `TAB', but is unbound by This command is intended to be bound to `TAB', but is unbound by
default. default.
`delete-char-or-list ()'
Deletes the character under the cursor if not at the beginning or
end of the line (like `delete-char'). If at the end of the line,
behaves identically to `possible-completions'. This command is
unbound by default.
`complete-filename (M-/)' `complete-filename (M-/)'
Attempt filename completion on the text before point. Attempt filename completion on the text before point.
@ -6180,7 +6229,7 @@ Some Miscellaneous Commands
Undo all changes made to this line. This is like executing the Undo all changes made to this line. This is like executing the
`undo' command enough times to get back to the beginning. `undo' command enough times to get back to the beginning.
`tilde-expand (M-~)' `tilde-expand (M-&)'
Perform tilde expansion on the current word. Perform tilde expansion on the current word.
`set-mark (C-@)' `set-mark (C-@)'
@ -6562,6 +6611,11 @@ that the Bash `configure' recognizes.
for which this should be turned off, and `configure' disables this for which this should be turned off, and `configure' disables this
option automatically for a number of systems. option automatically for a number of systems.
`--with-installed-readline'
Define this to make bash link with a locally-installed version of
Readline rather than the version in lib/readline. This works only
with readline 4.0 and later versions.
`--with-purify' `--with-purify'
Define this to use the Purify memory allocation checker from Pure Define this to use the Purify memory allocation checker from Pure
Software. Software.
@ -6857,6 +6911,7 @@ Parameter and Variable Index
* IGNOREEOF: Bash Variables. * IGNOREEOF: Bash Variables.
* input-meta: Readline Init File Syntax. * input-meta: Readline Init File Syntax.
* INPUTRC: Bash Variables. * INPUTRC: Bash Variables.
* isearch-terminators: Readline Init File Syntax.
* keymap: Readline Init File Syntax. * keymap: Readline Init File Syntax.
* LANG: Bash Variables. * LANG: Bash Variables.
* LC_ALL: Bash Variables. * LC_ALL: Bash Variables.
@ -6923,6 +6978,7 @@ Function Index
* copy-forward-word (): Commands For Killing. * copy-forward-word (): Commands For Killing.
* copy-region-as-kill (): Commands For Killing. * copy-region-as-kill (): Commands For Killing.
* delete-char (C-d): Commands For Text. * delete-char (C-d): Commands For Text.
* delete-char-or-list (): Commands For Completion.
* delete-horizontal-space (): Commands For Killing. * delete-horizontal-space (): Commands For Killing.
* digit-argument (M-0, M-1, ... M--): Numeric Arguments. * digit-argument (M-0, M-1, ... M--): Numeric Arguments.
* do-uppercase-version (M-a, M-b, M-X, ...): Miscellaneous Commands. * do-uppercase-version (M-a, M-b, M-X, ...): Miscellaneous Commands.
@ -6934,6 +6990,7 @@ Function Index
* end-of-history (M->): Commands For History. * end-of-history (M->): Commands For History.
* end-of-line (C-e): Commands For Moving. * end-of-line (C-e): Commands For Moving.
* exchange-point-and-mark (C-x C-x): Miscellaneous Commands. * exchange-point-and-mark (C-x C-x): Miscellaneous Commands.
* forward-backward-delete-char (): Commands For Text.
* forward-char (C-f): Commands For Moving. * forward-char (C-f): Commands For Moving.
* forward-search-history (C-s): Commands For History. * forward-search-history (C-s): Commands For History.
* forward-word (M-f): Commands For Moving. * forward-word (M-f): Commands For Moving.
@ -6960,7 +7017,6 @@ Function Index
* self-insert (a, b, A, 1, !, ...): Commands For Text. * self-insert (a, b, A, 1, !, ...): Commands For Text.
* set-mark (C-@): Miscellaneous Commands. * set-mark (C-@): Miscellaneous Commands.
* start-kbd-macro (C-x (): Keyboard Macros. * start-kbd-macro (C-x (): Keyboard Macros.
* tilde-expand (M-~): Miscellaneous Commands.
* transpose-chars (C-t): Commands For Text. * transpose-chars (C-t): Commands For Text.
* transpose-words (M-t): Commands For Text. * transpose-words (M-t): Commands For Text.
* undo (C-_, C-x C-u): Miscellaneous Commands. * undo (C-_, C-x C-u): Miscellaneous Commands.
@ -7092,120 +7148,120 @@ Concept Index
 
Tag Table: Tag Table:
Node: Top1197 Node: Top1187
Node: Introduction3153 Node: Introduction3146
Node: What is Bash?3378 Node: What is Bash?3371
Node: What is a shell?4472 Node: What is a shell?4465
Node: Definitions6494 Node: Definitions6487
Node: Basic Shell Features9155 Node: Basic Shell Features9148
Node: Shell Syntax10378 Node: Shell Syntax10371
Node: Shell Operation10667 Node: Shell Operation10660
Node: Quoting11961 Node: Quoting11954
Node: Escape Character12986 Node: Escape Character12979
Node: Single Quotes13458 Node: Single Quotes13451
Node: Double Quotes13787 Node: Double Quotes13780
Node: ANSI-C Quoting14685 Node: ANSI-C Quoting14678
Node: Locale Translation15554 Node: Locale Translation15547
Node: Comments15975 Node: Comments15968
Node: Shell Commands16589 Node: Shell Commands16582
Node: Simple Commands17100 Node: Simple Commands17093
Node: Pipelines17659 Node: Pipelines17652
Node: Lists19186 Node: Lists19179
Node: Looping Constructs20641 Node: Looping Constructs20634
Node: Conditional Constructs22246 Node: Conditional Constructs22239
Node: Command Grouping28184 Node: Command Grouping28177
Node: Shell Functions29561 Node: Shell Functions29554
Node: Shell Parameters31525 Node: Shell Parameters31518
Node: Positional Parameters32851 Node: Positional Parameters32844
Node: Special Parameters33600 Node: Special Parameters33593
Node: Shell Expansions36221 Node: Shell Expansions36214
Node: Brace Expansion38144 Node: Brace Expansion38137
Node: Tilde Expansion39705 Node: Tilde Expansion39698
Node: Shell Parameter Expansion42037 Node: Shell Parameter Expansion42030
Node: Command Substitution48379 Node: Command Substitution48426
Node: Arithmetic Expansion49653 Node: Arithmetic Expansion49700
Node: Process Substitution50498 Node: Process Substitution50545
Node: Word Splitting51392 Node: Word Splitting51439
Node: Filename Expansion52844 Node: Filename Expansion52891
Node: Pattern Matching54808 Node: Pattern Matching54855
Node: Quote Removal57197 Node: Quote Removal57244
Node: Redirections57483 Node: Redirections57530
Node: Executing Commands63553 Node: Executing Commands63600
Node: Simple Command Expansion64220 Node: Simple Command Expansion64267
Node: Command Search and Execution66143 Node: Command Search and Execution66190
Node: Command Execution Environment68146 Node: Command Execution Environment68193
Node: Environment70600 Node: Environment70647
Node: Exit Status72257 Node: Exit Status72304
Node: Signals73454 Node: Signals73501
Node: Shell Scripts75349 Node: Shell Scripts75396
Node: Bourne Shell Features77385 Node: Bourne Shell Features77432
Node: Bourne Shell Builtins78115 Node: Bourne Shell Builtins78162
Node: Bourne Shell Variables92056 Node: Bourne Shell Variables92273
Node: Other Bourne Shell Features93761 Node: Other Bourne Shell Features93978
Node: Major Differences From The Bourne Shell94504 Node: Major Differences From The Bourne Shell94721
Node: Bash Features106693 Node: Bash Features106910
Node: Invoking Bash107796 Node: Invoking Bash108013
Node: Bash Startup Files111981 Node: Bash Startup Files112198
Node: Is This Shell Interactive?115540 Node: Is This Shell Interactive?116342
Node: Bash Builtins116511 Node: Bash Builtins117313
Node: The Set Builtin137351 Node: The Set Builtin138717
Node: Bash Conditional Expressions143960 Node: Bash Conditional Expressions145533
Node: Bash Variables147033 Node: Bash Variables148666
Node: Shell Arithmetic159463 Node: Shell Arithmetic161096
Node: Aliases161511 Node: Aliases163144
Node: Alias Builtins164086 Node: Alias Builtins165719
Node: Arrays164702 Node: Arrays166335
Node: The Directory Stack167723 Node: The Directory Stack169356
Node: Printing a Prompt171073 Node: Printing a Prompt172706
Node: The Restricted Shell172736 Node: The Restricted Shell174369
Node: Bash POSIX Mode174072 Node: Bash POSIX Mode175730
Node: Job Control178233 Node: Job Control179891
Node: Job Control Basics178699 Node: Job Control Basics180357
Node: Job Control Builtins182898 Node: Job Control Builtins184556
Node: Job Control Variables187190 Node: Job Control Variables188848
Node: Using History Interactively188340 Node: Using History Interactively189998
Node: Bash History Facilities189019 Node: Bash History Facilities190677
Node: Bash History Builtins191360 Node: Bash History Builtins193018
Node: History Interaction194728 Node: History Interaction196386
Node: Event Designators197280 Node: Event Designators198938
Node: Word Designators198207 Node: Word Designators199865
Node: Modifiers199456 Node: Modifiers201114
Node: Command Line Editing200773 Node: Command Line Editing202431
Node: Introduction and Notation201433 Node: Introduction and Notation203091
Node: Readline Interaction202471 Node: Readline Interaction204129
Node: Readline Bare Essentials203663 Node: Readline Bare Essentials205321
Node: Readline Movement Commands205203 Node: Readline Movement Commands206861
Node: Readline Killing Commands206168 Node: Readline Killing Commands207826
Node: Readline Arguments207883 Node: Readline Arguments209541
Node: Searching208857 Node: Searching210515
Node: Readline Init File210475 Node: Readline Init File212263
Node: Readline Init File Syntax211514 Node: Readline Init File Syntax213302
Node: Conditional Init Constructs220379 Node: Conditional Init Constructs222508
Node: Sample Init File222817 Node: Sample Init File224946
Node: Bindable Readline Commands225986 Node: Bindable Readline Commands228115
Node: Commands For Moving226736 Node: Commands For Moving228865
Node: Commands For History227583 Node: Commands For History229712
Node: Commands For Text230412 Node: Commands For Text232541
Node: Commands For Killing232146 Node: Commands For Killing234508
Node: Numeric Arguments234295 Node: Numeric Arguments236657
Node: Commands For Completion235421 Node: Commands For Completion237783
Node: Keyboard Macros238991 Node: Keyboard Macros241615
Node: Miscellaneous Commands239549 Node: Miscellaneous Commands242173
Node: Readline vi Mode243869 Node: Readline vi Mode246493
Node: Installing Bash244747 Node: Installing Bash247371
Node: Basic Installation245824 Node: Basic Installation248448
Node: Compilers and Options248734 Node: Compilers and Options251358
Node: Compiling For Multiple Architectures249468 Node: Compiling For Multiple Architectures252092
Node: Installation Names251125 Node: Installation Names253749
Node: Specifying the System Type251850 Node: Specifying the System Type254474
Node: Sharing Defaults252554 Node: Sharing Defaults255178
Node: Operation Controls253219 Node: Operation Controls255843
Node: Optional Features254124 Node: Optional Features256748
Node: Reporting Bugs260319 Node: Reporting Bugs263158
Node: Builtin Index261390 Node: Builtin Index264229
Node: Reserved Word Index264793 Node: Reserved Word Index267632
Node: Variable Index266251 Node: Variable Index269090
Node: Function Index271456 Node: Function Index274363
Node: Concept Index275885 Node: Concept Index278853
 
End Tag Table End Tag Table

View file

@ -5,13 +5,13 @@
@c %**end of header @c %**end of header
@ignore @ignore
last change: Wed Mar 25 11:36:48 EST 1998 Last Change: Wed Jan 20 16:46:26 EST 1999
@end ignore @end ignore
@set EDITION 2.2 @set EDITION 2.3
@set VERSION 2.02 @set VERSION 2.03
@set UPDATED 1 April 1998 @set UPDATED 20 January 1999
@set UPDATE-MONTH April 1998 @set UPDATE-MONTH January 1999
@iftex @iftex
@finalout @finalout
@ -36,7 +36,7 @@ This is Edition @value{EDITION}, last updated @value{UPDATED},
of @cite{The GNU Bash Reference Manual}, of @cite{The GNU Bash Reference Manual},
for @code{Bash}, Version @value{VERSION}. for @code{Bash}, Version @value{VERSION}.
Copyright (C) 1991, 1993, 1996, 1997 Free Software Foundation, Inc. Copyright (C) 1991-1999 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice this manual provided the copyright notice and this permission notice
@ -64,13 +64,13 @@ by the Free Software Foundation.
@titlepage @titlepage
@title Bash Reference Manual @title Bash Reference Manual
@subtitle Reference Documentation for Bash @subtitle Reference Documentation for Bash
@subtitle Edition @value{EDITION}, for @code{bash} Version @value{VERSION}. @subtitle Edition @value{EDITION}, for @code{Bash} Version @value{VERSION}.
@subtitle @value{UPDATED} @subtitle @value{UPDATE-MONTH}
@author Chet Ramey, Case Western Reserve University @author Chet Ramey, Case Western Reserve University
@author Brian Fox, Free Software Foundation @author Brian Fox, Free Software Foundation
@page @page
@vskip 0pt plus 1filll @vskip 0pt plus 1filll
Copyright @copyright{} 1991, 1993, 1996 Free Software Foundation, Inc. Copyright @copyright{} 1991-1999 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice this manual provided the copyright notice and this permission notice
@ -1428,9 +1428,9 @@ In the first form, only the first match is replaced.
The second form causes all matches of @var{pattern} to be The second form causes all matches of @var{pattern} to be
replaced with @var{string}. replaced with @var{string}.
If @var{pattern} begins with @samp{#}, it must match at the beginning If @var{pattern} begins with @samp{#}, it must match at the beginning
of @var{string}. of the expanded value of @var{parameter}.
If @var{pattern} begins with @samp{%}, it must match at the end If @var{pattern} begins with @samp{%}, it must match at the end
of @var{string}. of the expanded value of @var{parameter}.
If @var{string} is null, matches of @var{pattern} are deleted If @var{string} is null, matches of @var{pattern} are deleted
and the @code{/} following @var{pattern} may be omitted. and the @code{/} following @var{pattern} may be omitted.
If @var{parameter} is @samp{@@} or @samp{*}, If @var{parameter} is @samp{@@} or @samp{*},
@ -2285,13 +2285,16 @@ The return status is zero.
@item . @item .
@btindex . @btindex .
@example @example
. @var{filename} . @var{filename} [@var{arguments}]
@end example @end example
Read and execute commands from the @var{filename} argument in the Read and execute commands from the @var{filename} argument in the
current shell context. If @var{filename} does not contain a slash, current shell context. If @var{filename} does not contain a slash,
the @code{$PATH} variable is used to find the @code{$PATH} variable is used to find
@var{filename}. The current directory is searched if @var{filename} @var{filename}. The current directory is searched if @var{filename}
is not found in @code{$PATH}. is not found in @code{$PATH}.
If any @var{arguments} are supplied, they become the positional
parameters when @var{filename} is executed. Otherwise the positional
parameters are unchanged.
The return status is the exit status of the last command executed, or The return status is the exit status of the last command executed, or
zero if no commands are executed. If @var{filename} is not found, or zero if no commands are executed. If @var{filename} is not found, or
cannot be read, the return status is non-zero. cannot be read, the return status is non-zero.
@ -3245,7 +3248,8 @@ If any of the files exist but cannot be read, Bash reports an error.
Tildes are expanded in file names as described above under Tildes are expanded in file names as described above under
Tilde Expansion (@pxref{Tilde Expansion}). Tilde Expansion (@pxref{Tilde Expansion}).
When Bash is invoked as an interactive login shell, it first reads and When Bash is invoked as an interactive login shell, or as a
non-interactive shell with the @samp{--login} option, it first reads and
executes commands from the file @file{/etc/profile}, if that file exists. executes commands from the file @file{/etc/profile}, if that file exists.
After reading that file, it looks for @file{~/.bash_profile}, After reading that file, it looks for @file{~/.bash_profile},
@file{~/.bash_login}, and @file{~/.profile}, in that order, and reads @file{~/.bash_login}, and @file{~/.profile}, in that order, and reads
@ -3285,7 +3289,8 @@ If Bash is invoked with the name @code{sh}, it tries to mimic the
startup behavior of historical versions of @code{sh} as closely as startup behavior of historical versions of @code{sh} as closely as
possible, while conforming to the @sc{POSIX} standard as well. possible, while conforming to the @sc{POSIX} standard as well.
When invoked as an interactive login shell, it first attempts to read When invoked as an interactive login shell, or as a non-interactive
shell with the @samp{--login} option, it first attempts to read
and execute commands from @file{/etc/profile} and @file{~/.profile}, in and execute commands from @file{/etc/profile} and @file{~/.profile}, in
that order. that order.
The @samp{--noprofile} option may be used to inhibit this behavior. The @samp{--noprofile} option may be used to inhibit this behavior.
@ -3296,7 +3301,7 @@ Since a shell invoked as @code{sh} does not attempt to read and execute
commands from any other startup files, the @samp{--rcfile} option has commands from any other startup files, the @samp{--rcfile} option has
no effect. no effect.
A non-interactive shell invoked with the name @code{sh} does not attempt A non-interactive shell invoked with the name @code{sh} does not attempt
to read any startup files. to read any other startup files.
When invoked as @code{sh}, Bash enters @sc{POSIX} mode after When invoked as @code{sh}, Bash enters @sc{POSIX} mode after
the startup files are read. the startup files are read.
@ -3319,6 +3324,14 @@ The @samp{--norc} option may be used to inhibit this behavior, and the
@code{rshd} does not generally invoke the shell with those options or @code{rshd} does not generally invoke the shell with those options or
allow them to be specified. allow them to be specified.
If Bash is started with the effective user (group) id not equal to the
real user (group) id, and the @code{-p} option is not supplied, no startup
files are read, shell functions are not inherited from the environment,
the @code{SHELLOPTS} variable, if it appears in the environment, is ignored,
and the effective user id is set to the real user id.
If the @code{-p} option is supplied at invocation, the startup behavior is
the same, but the effective user id is not reset.
@node Is This Shell Interactive? @node Is This Shell Interactive?
@section Is This Shell Interactive? @section Is This Shell Interactive?
@cindex interactive shell @cindex interactive shell
@ -3676,6 +3689,8 @@ If there are fewer words read from the standard input than names,
the remaining names are assigned empty values. the remaining names are assigned empty values.
The characters in the value of the @code{IFS} variable The characters in the value of the @code{IFS} variable
are used to split the line into words. are used to split the line into words.
The backslash character @samp{\} may be used to remove any special
meaning for the next character read and for line continuation.
If no names are supplied, the line read is assigned to the If no names are supplied, the line read is assigned to the
variable @code{REPLY}. variable @code{REPLY}.
The return code is zero, unless end-of-file is encountered. The return code is zero, unless end-of-file is encountered.
@ -3683,8 +3698,10 @@ Options, if supplied, have the following meanings:
@table @code @table @code
@item -r @item -r
If this option is given, a backslash-newline pair is not ignored, and If this option is given, backslash does not act as an escape
the backslash is considered to be part of the line. character. The backslash is considered to be part of the line.
In particular, a backslash-newline pair may not be used as a line
continuation.
@item -p @var{prompt} @item -p @var{prompt}
Display @var{prompt}, without a Display @var{prompt}, without a
@ -3853,6 +3870,13 @@ If set, prompt strings undergo variable and parameter expansion after
being expanded (@pxref{Printing a Prompt}). being expanded (@pxref{Printing a Prompt}).
This option is enabled by default. This option is enabled by default.
@item restricted_shell
The shell sets this option if it is started in restricted mode
(@pxref{The Restricted Shell}).
The value may not be changed.
This is not reset when the startup files are executed, allowing
the startup files to discover whether or not a shell is restricted.
@item shift_verbose @item shift_verbose
If this is set, the @code{shift} If this is set, the @code{shift}
builtin prints an error message when the shift count exceeds the builtin prints an error message when the shift count exceeds the
@ -4120,9 +4144,12 @@ In this mode, the @code{$BASH_ENV} and @code{$ENV} files are not
processed, shell functions are not inherited from the environment, processed, shell functions are not inherited from the environment,
and the @code{SHELLOPTS} variable, if it appears in the environment, and the @code{SHELLOPTS} variable, if it appears in the environment,
is ignored. is ignored.
This is enabled automatically If the shell is started with the effective user (group) id not equal to the
on startup if the effective user (group) id is not equal to the real real user (group) id, and the @code{-p} option is not supplied, these actions
user (group) id. Turning this option off causes the effective user are taken and the effective user id is set to the real user id.
If the @code{-p} option is supplied at startup, the effective user id is
not reset.
Turning this option off causes the effective user
and group ids to be set to the real user and group ids. and group ids to be set to the real user and group ids.
@item -t @item -t
@ -4235,6 +4262,9 @@ True if @var{file} exists and is a regular file.
@item -g @var{file} @item -g @var{file}
True if @var{file} exists and its set-group-id bit is set. True if @var{file} exists and its set-group-id bit is set.
@item -h @var{file}
True if @var{file} exists and is a symbolic link.
@item -k @var{file} @item -k @var{file}
True if @var{file} exists and its "sticky" bit is set. True if @var{file} exists and its "sticky" bit is set.
@ -5101,8 +5131,8 @@ with the exception that the following are disallowed:
@item @item
Changing directories with the @code{cd} builtin. Changing directories with the @code{cd} builtin.
@item @item
Setting or unsetting the values of the @code{SHELL} or @code{PATH} Setting or unsetting the values of the @code{SHELL}, @code{PATH},
variables. @code{ENV}, or @code{BASH_ENV} variables.
@item @item
Specifying command names containing slashes. Specifying command names containing slashes.
@item @item
@ -5815,6 +5845,11 @@ The @file{NOTES} file contains a list of systems for
which this should be turned off, and @code{configure} disables this which this should be turned off, and @code{configure} disables this
option automatically for a number of systems. option automatically for a number of systems.
@item --with-installed-readline
Define this to make bash link with a locally-installed version of Readline
rather than the version in lib/readline. This works only with readline 4.0
and later versions.
@item --with-purify @item --with-purify
Define this to use the Purify memory allocation checker from Pure Define this to use the Purify memory allocation checker from Pure
Software. Software.

View file

@ -6,9 +6,9 @@
.\" Case Western Reserve University .\" Case Western Reserve University
.\" chet@ins.CWRU.Edu .\" chet@ins.CWRU.Edu
.\" .\"
.\" Last Change: Thu Feb 19 10:26:47 EST 1998 .\" Last Change: Thu Dec 31 10:16:30 EST 1998
.\" .\"
.TH READLINE 3 "1998 Feb 19" GNU .TH READLINE 3 "1998 Dec 31" GNU
.\" .\"
.\" File Name macro. This used to be `.PN', for Path Name, .\" File Name macro. This used to be `.PN', for Path Name,
.\" but Sun doesn't seem to like that very much. .\" but Sun doesn't seem to like that very much.
@ -22,6 +22,7 @@ readline \- get a line from a user with editing
.LP .LP
.nf .nf
.ft B .ft B
#include <stdio.h>
#include <readline.h> #include <readline.h>
#include <history.h> #include <history.h>
.ft .ft
@ -380,6 +381,19 @@ When set to \fBOn\fP, makes readline use a single line for display,
scrolling the input horizontally on a single screen line when it scrolling the input horizontally on a single screen line when it
becomes longer than the screen width rather than wrapping to a new line. becomes longer than the screen width rather than wrapping to a new line.
.TP .TP
.B input\-meta (Off)
If set to \fBOn\fP, readline will enable eight-bit input (that is,
it will not strip the high bit from the characters it reads),
regardless of what the terminal claims it can support. The name
.B meta\-flag
is a synonym for this variable.
.TP
.B isearch\-terminators (``C\-[C\-J'')
The string of characters that should terminate an incremental
search without subsequently executing the character as a command.
If this variable has not been given a value, the characters
\fIESC\fP and \fIC\-J\fP will terminate an incremental search.
.TP
.B keymap (emacs) .B keymap (emacs)
Set the current readline keymap. The set of legal keymap names is Set the current readline keymap. The set of legal keymap names is
\fIemacs, emacs-standard, emacs-meta, emacs-ctlx, vi, vi-move, \fIemacs, emacs-standard, emacs-meta, emacs-ctlx, vi, vi-move,
@ -400,11 +414,6 @@ appended.
If set to \fBOn\fP, history lines that have been modified are displayed If set to \fBOn\fP, history lines that have been modified are displayed
with a preceding asterisk (\fB*\fP). with a preceding asterisk (\fB*\fP).
.TP .TP
.B meta\-flag (Off)
If set to \fBOn\fP, readline will enable eight-bit input (that is,
it will not strip the high bit from the characters it reads),
regardless of what the terminal claims it can support.
.TP
.B output\-meta (Off) .B output\-meta (Off)
If set to \fBOn\fP, readline will display characters with the If set to \fBOn\fP, readline will display characters with the
eighth bit set directly rather than as a meta-prefixed escape eighth bit set directly rather than as a meta-prefixed escape
@ -509,8 +518,10 @@ As each character of the search string is typed, readline displays
the next entry from the history matching the string typed so far. the next entry from the history matching the string typed so far.
An incremental search requires only as many characters as needed to An incremental search requires only as many characters as needed to
find the desired history entry. find the desired history entry.
The Escape character is used to terminate an incremental search. The characters present in the value of the \fIisearch-terminators\fP
Control-J will also terminate the search. variable are used to terminate an incremental search.
If that variable has not been assigned a value the Escape and
Control-J characters will terminate an incremental search.
Control-G will abort an incremental search and restore the original Control-G will abort an incremental search and restore the original
line. line.
When the search is terminated, the history entry containing the When the search is terminated, the history entry containing the
@ -647,6 +658,11 @@ the last character typed was not bound to \fBBdelete\-char\fP, then return
Delete the character behind the cursor. When given a numeric argument, Delete the character behind the cursor. When given a numeric argument,
save the deleted text on the kill ring. save the deleted text on the kill ring.
.TP .TP
.B forward\-backward\-delete\-char
Delete the character under the cursor, unless the cursor is at the
end of the line, in which case the character behind the cursor is
deleted. By default, this is not bound to a key.
.TP
.B quoted\-insert (C\-q, C\-v) .B quoted\-insert (C\-q, C\-v)
Add the next character that you type to the line verbatim. This is Add the next character that you type to the line verbatim. This is
how to insert characters like \fBC\-q\fP, for example. how to insert characters like \fBC\-q\fP, for example.
@ -798,6 +814,13 @@ of matches; a negative argument may be used to move backward
through the list. through the list.
This command is intended to be bound to \fBTAB\fP, but is unbound This command is intended to be bound to \fBTAB\fP, but is unbound
by default. by default.
.TP
.B delete\-char\-or\-list
Deletes the character under the cursor if not at the beginning or
end of the line (like \fBdelete-char\fP).
If at the end of the line, behaves identically to
\fBpossible-completions\fP.
This command is unbound by default.
.PD .PD
.SS Keyboard Macros .SS Keyboard Macros
.PP .PP
@ -847,7 +870,7 @@ Undo all changes made to this line. This is like executing the
.B undo .B undo
command enough times to return the line to its initial state. command enough times to return the line to its initial state.
.TP .TP
.B tilde\-expand (M\-~) .B tilde\-expand (M\-&)
Perform tilde expansion on the current word. Perform tilde expansion on the current word.
.TP .TP
.B set\-mark (C\-@, M-<space>) .B set\-mark (C\-@, M-<space>)

29
error.c
View file

@ -496,3 +496,32 @@ trace (format, va_alist)
#endif /* 0 */ #endif /* 0 */
#endif /* USE_VARARGS */ #endif /* USE_VARARGS */
static char *cmd_error_table[] = {
"unknown command error", /* CMDERR_DEFAULT */
"bad command type", /* CMDERR_BADTYPE */
"bad connector", /* CMDERR_BADCONN */
"bad jump", /* CMDERR_BADJUMP */
0
};
void
command_error (func, code, e, flags)
const char *func;
int code, e, flags; /* flags currently unused */
{
if (code > CMDERR_LAST)
code = CMDERR_DEFAULT;
programming_error ("%s: %s: %d", func, cmd_error_table[code], e);
}
char *
command_errstr (code)
int code;
{
if (code > CMDERR_LAST)
code = CMDERR_DEFAULT;
return (cmd_error_table[code]);
}

View file

@ -50,4 +50,9 @@ extern void internal_error __P((const char *, ...));
/* Report an internal warning. */ /* Report an internal warning. */
extern void internal_warning __P((const char *, ...)); extern void internal_warning __P((const char *, ...));
/* Report an error having to do with command parsing or execution. */
extern void command_error __P((const char *, int, int, int));
extern char *command_errstr __P((int));
#endif /* !_ERROR_H_ */ #endif /* !_ERROR_H_ */

26
eval.c
View file

@ -41,6 +41,10 @@
#include "input.h" #include "input.h"
#include "execute_cmd.h" #include "execute_cmd.h"
#if defined (HISTORY)
# include "bashhist.h"
#endif
extern int yyparse (); extern int yyparse ();
extern int EOF_reached; extern int EOF_reached;
@ -105,7 +109,7 @@ reader_loop ()
break; break;
default: default:
programming_error ("reader_loop: bad jump: code %d", code); command_error ("reader_loop", CMDERR_BADJUMP, code, 0);
} }
} }
@ -161,7 +165,7 @@ static sighandler
alrm_catcher(i) alrm_catcher(i)
int i; int i;
{ {
printf ("%ctimed out waiting for input: auto-logout\n", '\07'); printf ("\007timed out waiting for input: auto-logout\n");
jump_to_top_level (EXITPROG); jump_to_top_level (EXITPROG);
SIGRETURN (0); SIGRETURN (0);
} }
@ -269,6 +273,17 @@ parse_string_to_word_list (s, whom)
{ {
WORD_LIST *wl; WORD_LIST *wl;
COMMAND *saved_global; COMMAND *saved_global;
#if defined (HISTORY)
int old_remember_on_history, old_history_expansion_inhibited;
#endif
#if defined (HISTORY)
old_remember_on_history = remember_on_history;
# if defined (BANG_HISTORY)
old_history_expansion_inhibited = history_expansion_inhibited;
# endif
bash_history_disable ();
#endif
push_stream (1); push_stream (1);
@ -293,5 +308,12 @@ parse_string_to_word_list (s, whom)
pop_stream (); pop_stream ();
#if defined (HISTORY)
remember_on_history = old_remember_on_history;
# if defined (BANG_HISTORY)
history_expansion_inhibited = old_history_expansion_inhibited;
# endif /* BANG_HISTORY */
#endif /* HISTORY */
return (wl); return (wl);
} }

View file

@ -0,0 +1,125 @@
#From: Mark Kennedy <mtk@ny.ubs.com>
#Message-ID: <35E2B899.63A02DF5@ny.ubs.com>
#Date: Tue, 25 Aug 1998 09:14:01 -0400
#To: chet@nike.ins.cwru.edu
#Subject: a newer version of the ksh-style 'autoload'
#enclosed you'll find 'autoload.v3', a version of the autoloader
#that emulates the ksh semantics of delaying the resolution (and loading) of the function
#until its first use. i took the liberty of simplifying the code a bit although it still uses the
#same functional breakdown. i recently went through the exercise of converting
#my ksh-based environment to bash (a very, very pleasant experience)
#and this popped out.
# the psuedo-ksh autoloader.
# The first cut of this was by Bill Trost, trost@reed.bitnet.
# The second cut came from Chet Ramey, chet@ins.CWRU.Edu
# The third cut came from Mark Kennedy, mtk@ny.ubs.com. 1998/08/25
unset _AUTOLOADS
_aload()
{
local func
for func; do
eval $func '()
{
local f=$(_autoload_resolve '$func')
if [[ $f ]]; then
. $f
'$func' "$@"
return $?
else
return 1
fi
}'
_autoload_addlist $func
done
}
_autoload_addlist()
{
local func
for func in ${_AUTOLOADS[@]}; do
[[ $func = "$1" ]] && return
done
_AUTOLOADS[${#_AUTOLOADS[@]}]=$1
}
_autoload_dump()
{
local func
for func in ${_AUTOLOADS[@]}; do
[[ $1 ]] && echo -n "autoload "
echo $func
done
}
_autoload_remove_one()
{
local func
local -a NEW_AUTOLOADS
for func in ${_AUTOLOADS[@]}; do
[[ $func != "$1" ]] && NEW_AUTOLOADS[${#NEW_AUTOLOADS[@]}]=$func
done
_AUTOLOADS=( ${NEW_AUTOLOADS[@]} )
}
_autoload_remove()
{
local victim func
for victim; do
for func in ${_AUTOLOADS[@]}; do
[[ $victim = "$func" ]] && unset -f $func && continue 2
done
echo "autoload: $func: not an autoloaded function" >&2
done
for func; do
_autoload_remove_one $func
done
}
_autoload_resolve()
{
if [[ ! "$FPATH" ]]; then
echo "autoload: FPATH not set or null" >&2
return
fi
local p
for p in $( (IFS=':'; set -- ${FPATH}; echo "$@") ); do
p=${p:-.}
if [ -f $p/$1 ]; then echo $p/$1; return; fi
done
echo "autoload: $1: function source file not found" >&2
}
autoload()
{
if (( $# == 0 )) ; then _autoload_dump; return; fi
local opt OPTIND
while getopts pu opt
do
case $opt in
p) _autoload_dump printable; return;;
u) shift $((OPTIND-1)); _autoload_remove "$@"; return;;
*) echo "autoload: usage: autoload [-pu] [function ...]" >&2; return;;
esac
done
shift $(($OPTIND-1))
_aload "$@"
}

View file

@ -23,6 +23,17 @@ inet2hex ()
hex2inet () hex2inet ()
{ {
local x1 x2 x3 x4 local x1 x2 x3 x4
local rev
OPTIND=1
while getopts "r" o
do
case "$o" in
r) rev=true;;
*) echo "hex2inet: usage: hex2inet [0x]XXXXXXXX" >&2 ; exit 2;;
esac
done
shift $(( $OPTIND - 1 ))
case "$1" in case "$1" in
0x*) h=${1#??} ;; 0x*) h=${1#??} ;;
@ -40,5 +51,10 @@ hex2inet ()
x3=$(( 0x${h:4:2} )) x3=$(( 0x${h:4:2} ))
x4=$(( 0x${h:6:2} )) x4=$(( 0x${h:6:2} ))
printf "%d.%d.%d.%d\n" $x1 $x2 $x3 $x4 if [ -z "$rev" ] ; then
printf "%d.%d.%d.%d\n" $x1 $x2 $x3 $x4
else
printf "%d.%d.%d.%d\n" $x4 $x3 $x2 $x1
fi
return 0
} }

View file

@ -8,19 +8,19 @@
lowercase() lowercase()
{ {
for file; do for file; do
filename=${file##*/} filename=${file##*/}
case "$filename" in case "$filename" in
*/*) dirname=${file%/*} ;; */*) dirname=${file%/*} ;;
*) dirname=.;; *) dirname=.;;
esac esac
nf=$(echo $filename | tr A-Z a-z) nf=$(echo $filename | tr A-Z a-z)
newname="${dirname}/${nf}" newname="${dirname}/${nf}"
if [ "$nf" != "$filename" ]; then if [ "$nf" != "$filename" ]; then
mv "$file" "$newname" mv "$file" "$newname"
echo "$0: $file -> $newname" echo "lowercase: $file -> $newname"
else else
echo "$0: $file not changed." echo "lowercase: $file not changed."
fi fi
done done
} }

View file

@ -0,0 +1,12 @@
# From psamuels@jake.niar.twsu.edu (Peter Samuelson)
# posted to usenet, Message-ID: <6rtp8j$2a0$1@jake.niar.twsu.edu>
repeat ()
{
local i max; # note that you can use \$i in the command string
max=$1; shift;
i=1; while ((i <= max)); do
eval "$@"; ((i = i + 1));
done;
}

37
examples/functions/seq2 Normal file
View file

@ -0,0 +1,37 @@
# Generate a sequence from m to n, m defaults to 1.
seq ()
{
declare -i lo hi i # makes local
local _SEQ INIT COMPARE STEP
case "$1" in
-r) INIT='i=$hi _SEQ=""' COMPARE='let "i >= $lo"' STEP='let i-=1' ; shift ;;
*) INIT='i=$lo _SEQ=""' COMPARE='let "i <= $hi"' STEP='let i+=1' ;;
esac
case $# in
1) lo=1 hi="$1" ;;
2) lo=$1 hi=$2 ;;
*) echo seq: usage: seq [-r] [low] high 1>&2 ; return 2 ;;
esac
# equivalent to the as-yet-unimplemented
# for (( "$INIT" ; "$COMPARE" ; "$STEP" )); do _SEQ="${_SEQ}$i "; done
eval "$INIT"
while eval "$COMPARE"; do
_SEQ="${_SEQ}$i "
eval "$STEP"
done
echo "${_SEQ# }"
return 0
}
# like the APL `iota' function (or at least how I remember it :-)
iota()
{
case $# in
1) seq 1 "$1"; return $?;;
*) echo "iota: usage: iota high" 1>&2; return 2;;
esac
}

44
examples/functions/which Normal file
View file

@ -0,0 +1,44 @@
#
# which - emulation of `which' as it appears in FreeBSD
#
# usage: which [-as] command [command...]
#
which()
{
local aflag sflag ES a
OPTIND=1
while builtin getopts as opt ; do
case "$opt" in
a) aflag=-a ;;
s) sflag=1 ;;
?) echo "which: usage: which [-as] command [command ...]" >&2
exit 2 ;;
esac
done
(( $OPTIND > 1 )) && shift $(( $OPTIND - 1 ))
# without command arguments, exit with status 1
ES=1
# exit status is 0 if all commands are found, 1 if any are not found
for command; do
# if $command is a function, make sure we add -a so type
# will look in $PATH after finding the function
a=$aflag
case "$(builtin type -t $command)" in
"function") a=-a;;
esac
if [ -n "$sflag" ]; then
builtin type -p $a $command >/dev/null 2>&1
else
builtin type -p $a $command
fi
ES=$?
done
return $ES
}

View file

@ -1,8 +1,6 @@
# #
# Simple makefile for the sample loadable builtins # Simple makefile for the sample loadable builtins
# #
# This includes some boilerplate definitions added by configure, but will
# still need hand-editing
# #
# Include some boilerplate Gnu makefile definitions. # Include some boilerplate Gnu makefile definitions.
prefix = @prefix@ prefix = @prefix@
@ -22,123 +20,148 @@ VPATH = .:@srcdir@
CC = @CC@ CC = @CC@
RM = rm -f RM = rm -f
SHELL = /bin/sh SHELL = @MAKE_SHELL@
# SunOS 4 host_os = @host_os@
#PICFLAG = -pic host_cpu = @host_cpu@
# Some versions of gcc, esp. on NetBSD and FreeBSD host_vendor = @host_vendor@
PICFLAG = -fpic
# Linux -- could also be -fpic
#PICFLAG = -fPIC
# SunOS 5
#PICFLAG = -K pic
# SVR4, SVR4.2, Irix
#PICFLAG = -K PIC
# BSD/OS 2.1, BSD/OS 3.x
#PICFLAG =
# AIX 4.2
#PICFLAG = -K
# SunOS 4, BSD/OS 2.1, BSD/OS 3.x, SVR4.2, SVR4, Linux, AIX 4.2, etc. CFLAGS = @CFLAGS@
LD = ld
# SunOS 5, Linux
#LD = ${CC}
# SunOS 4
#LDOPT = -assert pure-text
# OSF/1, Digital UNIX
#LDOPT = -shared -soname $@ -expect_unresolved '*'
# SunOS 5 using sun cc
#LDOPT = -dy -z text -G -i -h $@
# SunOS 5 using gcc with Sun ld
#LDOPT = -shared -Wl,-dy -Wl,-G -Wl,-i
# SVR4, SVR4.2
#LDOPT = -dy -z text -G -h $@
# NetBSD, FreeBSD -- might also need -r
LDOPT = -x -Bshareable
# Linux
#LDOPT = -shared
# BSD/OS 2.1, BSD/OS 3.x
#LDOPT = -r
# AIX 4.2
#LDOPT = -bdynamic -bnoentry -bexpall -G
# other libraries to link the shared object against
# BSD/OS 2.1
#LDLIBS = -lc_s.2.1.0
# BSD/OS 3.0, BSD/OS 3.1
#LDLIBS = -lc_s.3.0.0
#
# These values are generated for configure by ${topdir}/support/shobj-conf.
# If your system is not supported by that script, but includes facilities for
# dynamic loading of shared objects, please update the script and send the
# changes to bash-maintainers@gnu.org.
#
SHOBJ_CC = @SHOBJ_CC@
SHOBJ_CFLAGS = @SHOBJ_CFLAGS@
SHOBJ_LD = @SHOBJ_LD@
SHOBJ_LDFLAGS = @SHOBJ_LDFLAGS@
SHOBJ_XLDFLAGS = @SHOBJ_XLDFLAGS@
SHOBJ_LIBS = @SHOBJ_LIBS@
SHOBJ_STATUS = @SHOBJ_STATUS@
INC = -I. -I.. -I$(topdir) -I$(topdir)/lib -I$(topdir)/builtins \ INC = -I. -I.. -I$(topdir) -I$(topdir)/lib -I$(topdir)/builtins \
-I$(BUILD_DIR) -I$(BUILD_DIR)/lib -I$(BUILD_DIR)/builtins -I$(BUILD_DIR) -I$(BUILD_DIR)/lib -I$(BUILD_DIR)/builtins
.c.o: .c.o:
$(CC) $(PICFLAG) $(CFLAGS) $(INC) -c -o $@ $< $(SHOBJ_CC) $(SHOBJ_CFLAGS) $(CFLAGS) $(INC) -c -o $@ $<
ALLPROG = print truefalse sleep pushd finfo logname basename dirname \ ALLPROG = print truefalse sleep pushd finfo logname basename dirname \
tty pathchk tee head rmdir sprintf tty pathchk tee head mkdir rmdir sprintf printenv id whoami \
uname sync push ln unlink
OTHERPROG = necho getconf hello cat OTHERPROG = necho getconf hello cat
all: $(ALLPROG) all: $(SHOBJ_STATUS)
others: $(OTHERPROG)
everything: all others supported: $(ALLPROG)
others: $(OTHERPROG)
unsupported:
@echo "Your system (${host_os}) is not supported by the"
@echo "${topdir}/support/shobj-conf script."
@echo "If your operating system provides facilities for dynamic"
@echo "loading of shared objects using the dlopen(3) interface,"
@echo "please update the script and re-run configure.
@echo "Please send the changes you made to bash-maintainers@gnu.org"
@echo "for inclusion in future bash releases."
everything: supported others
sprintf: sprintf.o sprintf: sprintf.o
$(LD) $(LDOPT) -o $@ sprintf.o $(LDLIBS) $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ sprintf.o $(SHOBJ_LIBS)
print: print.o print: print.o
$(LD) $(LDOPT) -o $@ print.o $(LDLIBS) $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ print.o $(SHOBJ_LIBS)
necho: necho.o necho: necho.o
$(LD) $(LDOPT) -o $@ necho.o $(LDLIBS) $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ necho.o $(SHOBJ_LIBS)
getconf: getconf.o getconf: getconf.o
$(LD) $(LDOPT) -o $@ getconf.o $(LDLIBS) $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ getconf.o $(SHOBJ_LIBS)
hello: hello.o hello: hello.o
$(LD) $(LDOPT) -o $@ hello.o $(LDLIBS) $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ hello.o $(SHOBJ_LIBS)
truefalse: truefalse.o truefalse: truefalse.o
$(LD) $(LDOPT) -o $@ truefalse.o $(LDLIBS) $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ truefalse.o $(SHOBJ_LIBS)
sleep: sleep.o sleep: sleep.o
$(LD) $(LDOPT) -o $@ sleep.o $(LDLIBS) $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ sleep.o $(SHOBJ_LIBS)
pushd: pushd.o
$(LD) $(LDOPT) -o $@ pushd.o $(LDLIBS)
finfo: finfo.o finfo: finfo.o
$(LD) $(LDOPT) -o $@ finfo.o $(LDLIBS) $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ finfo.o $(SHOBJ_LIBS)
cat: cat.o cat: cat.o
$(LD) $(LDOPT) -o $@ cat.o $(LDLIBS) $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ cat.o $(SHOBJ_LIBS)
logname: logname.o logname: logname.o
$(LD) $(LDOPT) -o $@ logname.o $(LDLIBS) $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ logname.o $(SHOBJ_LIBS)
basename: basename.o basename: basename.o
$(LD) $(LDOPT) -o $@ basename.o $(LDLIBS) $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ basename.o $(SHOBJ_LIBS)
dirname: dirname.o dirname: dirname.o
$(LD) $(LDOPT) -o $@ dirname.o $(LDLIBS) $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ dirname.o $(SHOBJ_LIBS)
tty: tty.o tty: tty.o
$(LD) $(LDOPT) -o $@ tty.o $(LDLIBS) $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ tty.o $(SHOBJ_LIBS)
pathchk: pathchk.o pathchk: pathchk.o
$(LD) $(LDOPT) -o $@ pathchk.o $(LDLIBS) $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ pathchk.o $(SHOBJ_LIBS)
tee: tee.o tee: tee.o
$(LD) $(LDOPT) -o $@ tee.o $(LDLIBS) $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ tee.o $(SHOBJ_LIBS)
mkdir: mkdir.o
$(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ mkdir.o $(SHOBJ_LIBS)
rmdir: rmdir.o rmdir: rmdir.o
$(LD) $(LDOPT) -o $@ rmdir.o $(LDLIBS) $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ rmdir.o $(SHOBJ_LIBS)
head: head.o head: head.o
$(LD) $(LDOPT) -o $@ head.o $(LDLIBS) $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ head.o $(SHOBJ_LIBS)
printenv: printenv.o
$(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ printenv.o $(SHOBJ_LIBS)
id: id.o
$(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ id.o $(SHOBJ_LIBS)
whoami: whoami.o
$(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ whoami.o $(SHOBJ_LIBS)
uname: uname.o
$(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ uname.o $(SHOBJ_LIBS)
sync: sync.o
$(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ sync.o $(SHOBJ_LIBS)
push: push.o
$(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ push.o $(SHOBJ_LIBS)
ln: ln.o
$(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ ln.o $(SHOBJ_LIBS)
unlink: unlink.o
$(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ unlink.o $(SHOBJ_LIBS)
# pushd is a special case. We use the same source that the builtin version
# uses, with special compilation options.
#
pushd.c: ${topdir}/builtins/pushd.def
$(RM) $@
${BUILD_DIR}/builtins/mkbuiltins -D ${topdir}/builtins ${topdir}/builtins/pushd.def
pushd.o: pushd.c
$(RM) $@
$(SHOBJ_CC) -DPUSHD_AND_POPD -DLOADABLE_BUILTIN $(SHOBJ_CFLAGS) $(CFLAGS) $(INC) -c -o $@ $<
pushd: pushd.o
$(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ pushd.o $(SHOBJ_LIBS)
clean: clean:
$(RM) $(ALLPROG) $(OTHERPROG) *.o $(RM) $(ALLPROG) $(OTHERPROG) *.o
@ -146,12 +169,11 @@ clean:
mostlyclean: clean mostlyclean: clean
distclean maintainer-clean: clean distclean maintainer-clean: clean
$(RM) Makefile $(RM) Makefile pushd.c
print.o: print.c print.o: print.c
truefalse.o: truefalse.c truefalse.o: truefalse.c
sleep.o: sleep.c sleep.o: sleep.c
pushd.o: pushd.c
finfo.o: finfo.c finfo.o: finfo.c
logname.o: logname.c logname.o: logname.c
basename.o: basename.c basename.o: basename.c
@ -166,4 +188,10 @@ necho.o: necho.c
getconf.o: getconf.c getconf.o: getconf.c
hello.o: hello.c hello.o: hello.c
cat.o: cat.c cat.o: cat.c
printenv.o: printenv.c
id.o: id.c
whoami.o: whoami.c
uname.o: uname.c
sync.o: sync.c
push.o: push.c
mkdir.o: mkdir.c

View file

@ -10,13 +10,18 @@ of the shell.
All of the new builtins in ksh93 that bash didn't already have All of the new builtins in ksh93 that bash didn't already have
are included here, as is the ksh `print' builtin. are included here, as is the ksh `print' builtin.
Compile with cc and whatever pic options you need (look in the The configure script in the top-level source directory uses the
Makefile for a few common settings) support/shobj-conf script to set the right values in the Makefile,
so you should not need to change the Makefile. If your system
is not supported by support/shobj-conf, and it has the necessary
facilities for building shared objects and support for the
dlopen/dlsyn/dlclose/dlerror family of functions, please make
the necessary changes to support/shobj-conf and send the changes
to bash-maintainers@gnu.org.
load with ld and whatever shared object options you need (again, Loadable builtins are loaded into a running shell with
look in the Makefile)
then enable -f filename builtin-name enable -f filename builtin-name
enable uses a simple reference-counting scheme to avoid unloading a enable uses a simple reference-counting scheme to avoid unloading a
shared object that implements more than one loadable builtin before shared object that implements more than one loadable builtin before
@ -24,4 +29,5 @@ all loadable builtins implemented in the object are removed.
Many of the details needed by builtin writers are found in hello.c, Many of the details needed by builtin writers are found in hello.c,
the canonical example. There is no real `builtin writers' programming the canonical example. There is no real `builtin writers' programming
guide'. guide'. The file template.c provides a template to use for creating
new loadable builtins.

View file

@ -58,7 +58,7 @@ dirname_builtin (list)
if (string[slen] == '/') if (string[slen] == '/')
break; break;
if (slen >= 0) if (slen < 0)
{ {
fputs (".\n", stdout); fputs (".\n", stdout);
return (EXECUTION_SUCCESS); return (EXECUTION_SUCCESS);

View file

@ -196,6 +196,13 @@ int m;
obits[i++] = 'x'; obits[i++] = 'x';
obits[i] = '\0'; obits[i] = '\0';
if (m & S_ISUID)
ubits[2] = (m & S_IXUSR) ? 's' : 'S';
if (m & S_ISGID)
gbits[2] = (m & S_IXGRP) ? 's' : 'S';
if (m & S_ISVTX)
obits[2] = (m & S_IXOTH) ? 't' : 'T';
printf ("u=%s,g=%s,o=%s", ubits, gbits, obits); printf ("u=%s,g=%s,o=%s", ubits, gbits, obits);
} }
@ -217,6 +224,10 @@ int mode;
printf("S_IFLNK "); printf("S_IFLNK ");
if (S_ISSOCK(mode)) if (S_ISSOCK(mode))
printf("S_IFSOCK "); printf("S_IFSOCK ");
#ifdef S_ISWHT
if (S_ISWHT(mode))
printf("S_ISWHT ");
#endif
perms(getperm(mode)); perms(getperm(mode));
printf("\n"); printf("\n");
} }

View file

@ -3,19 +3,21 @@
/* See Makefile for compilation details. */ /* See Makefile for compilation details. */
#include "config.h" #include <config.h>
#if defined (HAVE_UNISTD_H) #if defined (HAVE_UNISTD_H)
# include <unistd.h> # include <unistd.h>
#endif #endif
#include <stdio.h> #include <stdio.h>
#include "builtins.h" #include "builtins.h"
#include "shell.h" #include "shell.h"
#include "bashgetopt.h"
/* A builtin `xxx' is normally implemented with an `xxx_builtin' function. /* A builtin `xxx' is normally implemented with an `xxx_builtin' function.
If you're converting a command that uses the normal Unix argc/argv If you're converting a command that uses the normal Unix argc/argv
calling convention, use argv = word_list_to_argv (list, &argc) and call calling convention, use argv = make_builtin_argv (list, &argc) and call
the original `main' something like `xxx_main'. Look at cat.c for an the original `main' something like `xxx_main'. Look at cat.c for an
example. example.
@ -41,7 +43,6 @@ hello_builtin (list)
which is printed by `help xxx'. It must end with a NULL. */ which is printed by `help xxx'. It must end with a NULL. */
char *hello_doc[] = { char *hello_doc[] = {
"this is the long doc for the sample hello builtin", "this is the long doc for the sample hello builtin",
"which is a bare-bones echo",
(char *)NULL (char *)NULL
}; };
@ -53,7 +54,7 @@ struct builtin hello_struct = {
hello_builtin, /* function implementing the builtin */ hello_builtin, /* function implementing the builtin */
BUILTIN_ENABLED, /* initial flags for builtin */ BUILTIN_ENABLED, /* initial flags for builtin */
hello_doc, /* array of long documentation strings. */ hello_doc, /* array of long documentation strings. */
"hello [args]", /* usage synopsis; becomes short_doc */ "hello", /* usage synopsis; becomes short_doc */
0 /* reserved for internal use */ 0 /* reserved for internal use */
}; };

308
examples/loadables/id.c Normal file
View file

@ -0,0 +1,308 @@
/*
* id - POSIX.2 user identity
*
* (INCOMPLETE -- supplementary groups for other users not yet done)
*
* usage: id [-Ggu] [-nr] [user]
*
* The default output format looks something like:
* uid=xxx(chet) gid=xx groups=aa(aname), bb(bname), cc(cname)
*/
#include <config.h>
#include <stdio.h>
#include "bashtypes.h"
#include <pwd.h>
#include <grp.h>
#include "bashansi.h"
#ifdef HAVE_LIMITS_H
# include <limits.h>
#else
# include <sys/param.h>
#endif
#if !defined (HAVE_GETPW_DECLS)
extern struct passwd *getpwuid ();
#endif
extern struct group *getgrgid ();
#include "shell.h"
#include "builtins.h"
#include "stdc.h"
#include "common.h"
#include "bashgetopt.h"
#define ID_ALLGROUPS 0x001 /* -G */
#define ID_GIDONLY 0x002 /* -g */
#define ID_USENAME 0x004 /* -n */
#define ID_USEREAL 0x008 /* -r */
#define ID_USERONLY 0x010 /* -u */
#define ID_FLAGSET(s) ((id_flags & (s)) != 0)
static int id_flags;
static uid_t ruid, euid;
static gid_t rgid, egid;
static char *id_user;
static int inituser ();
static int id_pruser ();
static int id_prgrp ();
static int id_prgroups ();
static int id_prall ();
int
id_builtin (list)
WORD_LIST *list;
{
int opt;
char *user;
id_flags = 0;
reset_internal_getopt ();
while ((opt = internal_getopt (list, "Ggnru")) != -1)
{
switch (opt)
{
case 'G': id_flags |= ID_ALLGROUPS; break;
case 'g': id_flags |= ID_GIDONLY; break;
case 'n': id_flags |= ID_USENAME; break;
case 'r': id_flags |= ID_USEREAL; break;
case 'u': id_flags |= ID_USERONLY; break;
default:
builtin_usage ();
return (EX_USAGE);
}
}
list = loptend;
user = list ? list->word->word : (char *)NULL;
/* Check for some invalid option combinations */
opt = ID_FLAGSET (ID_ALLGROUPS) + ID_FLAGSET (ID_GIDONLY) + ID_FLAGSET (ID_USERONLY);
if (opt > 1 || (opt == 0 && ((id_flags & (ID_USEREAL|ID_USENAME)) != 0)))
{
builtin_usage ();
return (EX_USAGE);
}
if (list && list->next)
{
builtin_usage ();
return (EX_USAGE);
}
if (inituser (user) < 0)
return (EXECUTION_FAILURE);
opt = 0;
if (id_flags & ID_USERONLY)
opt += id_pruser ((id_flags & ID_USEREAL) ? ruid : euid);
else if (id_flags & ID_GIDONLY)
opt += id_prgrp ((id_flags & ID_USEREAL) ? rgid : egid);
else if (id_flags & ID_ALLGROUPS)
opt += id_prgroups (user);
else
opt += id_prall (user);
putchar ('\n');
fflush (stdout);
return (opt == 0 ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
}
static int
inituser (uname)
char *uname;
{
struct passwd *pwd;
if (uname)
{
pwd = getpwnam (uname);
if (pwd == 0)
{
builtin_error ("%s: no such user", uname);
return -1;
}
ruid = euid = pwd->pw_uid;
rgid = egid = pwd->pw_gid;
}
else
{
ruid = current_user.uid;
euid = current_user.euid;
rgid = current_user.gid;
egid = current_user.egid;
}
return 0;
}
/* Print the name or value of user ID UID. */
static int
id_pruser (uid)
int uid;
{
struct passwd *pwd = NULL;
int r;
r = 0;
if (id_flags & ID_USENAME)
{
pwd = getpwuid (uid);
if (pwd == NULL)
r = 1;
}
if (pwd)
printf ("%s", pwd->pw_name);
else
printf ("%u", (unsigned) uid);
return r;
}
/* Print the name or value of group ID GID. */
static int
id_prgrp (gid)
int gid;
{
struct group *grp = NULL;
int r;
r = 0;
if (id_flags & ID_USENAME)
{
grp = getgrgid (gid);
if (grp == NULL)
r = 1;
}
if (grp)
printf ("%s", grp->gr_name);
else
printf ("%u", (unsigned) gid);
return r;
}
static int
id_prgroups (uname)
char *uname;
{
int *glist, ng, i, r;
r = 0;
id_prgrp (rgid);
if (egid != rgid)
{
putchar (' ');
id_prgrp (egid);
}
if (uname)
{
builtin_error ("supplementary groups for other users not yet implemented");
glist = (int *)NULL;
ng = 0;
r = 1;
}
else
glist = get_group_array (&ng);
for (i = 0; i < ng; i++)
if (glist[i] != rgid && glist[i] != egid)
{
putchar (' ');
id_prgrp (glist[i]);
}
return r;
}
static int
id_prall (uname)
char *uname;
{
int r, i, ng, *glist;
struct passwd *pwd;
struct group *grp;
r = 0;
printf ("uid=%u", (unsigned) ruid);
pwd = getpwuid (ruid);
if (pwd == NULL)
r = 1;
else
printf ("(%s)", pwd->pw_name);
printf (" gid=%u", (unsigned) rgid);
grp = getgrgid (rgid);
if (grp == NULL)
r = 1;
else
printf ("(%s)", grp->gr_name);
if (euid != ruid)
{
printf (" euid=%u", (unsigned) euid);
pwd = getpwuid (euid);
if (pwd == NULL)
r = 1;
else
printf ("(%s)", pwd->pw_name);
}
if (egid != rgid)
{
printf (" egid=%u", (unsigned) egid);
grp = getgrgid (egid);
if (grp == NULL)
r = 1;
else
printf ("(%s)", grp->gr_name);
}
if (uname)
{
builtin_error ("supplementary groups for other users not yet implemented");
glist = (int *)NULL;
ng = 0;
r = 1;
}
else
glist = get_group_array (&ng);
if (ng > 0)
printf (" groups=");
for (i = 0; i < ng; i++)
{
if (i > 0)
printf (", ");
printf ("%u", (unsigned) glist[i]);
grp = getgrgid (glist[i]);
if (grp == NULL)
r = 1;
else
printf ("(%s)", grp->gr_name);
}
return r;
}
char *id_doc[] = {
"return information about user identity",
(char *)NULL
};
struct builtin id_struct = {
"id",
id_builtin,
BUILTIN_ENABLED,
id_doc,
"id [user]\n\tid -G [-n] [user]\n\tid -g [-nr] [user]\n\tid -u [-nr] [user]",
0
};

203
examples/loadables/ln.c Normal file
View file

@ -0,0 +1,203 @@
/* ln - make links */
/* See Makefile for compilation details. */
#include "config.h"
#include "bashtypes.h"
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif
#include "posixstat.h"
#include <stdio.h>
#include <errno.h>
#include "builtins.h"
#include "shell.h"
#include "bashgetopt.h"
#if !defined (errno)
extern int errno;
#endif
#define LN_SYMLINK 0x01
#define LN_UNLINK 0x02
static Function *linkfn;
static int dolink ();
ln_builtin (list)
WORD_LIST *list;
{
int rval, opt, flags;
WORD_LIST *l;
char *sdir;
struct stat sb;
flags = 0;
reset_internal_getopt ();
while ((opt = internal_getopt (list, "fs")) != -1)
{
switch (opt)
{
case 'f':
flags |= LN_UNLINK;
break;
case 's':
flags |= LN_SYMLINK;
break;
default:
builtin_usage ();
return (EX_USAGE);
}
}
list = loptend;
if (list == 0)
{
builtin_usage ();
return (EX_USAGE);
}
linkfn = (flags & LN_SYMLINK) ? symlink : link;
if (list->next == 0) /* ln target, equivalent to ln target . */
return (dolink (list->word->word, ".", flags));
if (list->next->next == 0) /* ln target source */
return (dolink (list->word->word, list->next->word->word, flags));
/* ln target1 target2 ... directory */
/* find last argument: target directory, and make sure it's an existing
directory. */
for (l = list; l->next; l = l->next)
;
sdir = l->word->word;
if (stat(sdir, &sb) < 0)
{
builtin_error ("%s", sdir);
return (EXECUTION_FAILURE);
}
if (S_ISDIR (sb.st_mode) == 0)
{
builtin_usage ();
return (EX_USAGE);
}
for (rval = EXECUTION_SUCCESS; list != l; list = list->next)
rval += dolink (list->word->word, sdir, flags);
return rval;
}
static char *
mkdirpath (dir, file)
char *dir, *file;
{
int dlen, flen;
char *ret;
dlen = strlen (dir);
flen = strlen (file);
ret = xmalloc (2 + dlen + flen);
strcpy (ret, dir);
if (ret[dlen - 1] != '/')
ret[dlen++] = '/';
strcpy (ret + dlen, file);
return ret;
}
#if defined (HAVE_LSTAT)
# define LSTAT lstat
#else
# define LSTAT stat
#endif
static int
dolink (src, dst, flags)
char *src, *dst;
int flags;
{
struct stat ssb, dsb;
int exists;
char *dst_path, *p;
/* If we're not doing symlinks, the source must exist and not be a
directory. */
if ((flags & LN_SYMLINK) == 0)
{
if (stat (src, &ssb) != 0)
{
builtin_error ("%s: %s", src, strerror (errno));
return (EXECUTION_FAILURE);
}
if (S_ISDIR (ssb.st_mode))
{
errno = EISDIR;
builtin_error ("%s: %s", src, strerror (errno));
return (EXECUTION_FAILURE);
}
}
/* If the destination is a directory, create the final filename by appending
the basename of the source to the destination. */
dst_path = 0;
if ((stat (dst, &dsb) == 0) && S_ISDIR (dsb.st_mode))
{
if ((p = strrchr (src, '/')) == 0)
p = src;
else
p++;
dst_path = mkdirpath (dst, p);
dst = dst_path;
}
exists = LSTAT (dst, &dsb) == 0;
/* If -f was specified, and the destination exists, unlink it. */
if ((flags & LN_UNLINK) && exists && unlink (dst) != 0)
{
builtin_error ("%s: cannot unlink: %s", dst, strerror (errno));
FREE (dst_path);
return (EXECUTION_FAILURE);
}
/* Perform the link. */
if ((*linkfn) (src, dst) != 0)
{
builtin_error ("cannot link %s to %s: %s", dst, src, strerror (errno));
FREE (dst_path);
return (EXECUTION_FAILURE);
}
FREE (dst_path);
return (EXECUTION_SUCCESS);
}
char *ln_doc[] = {
"Create a new directory entry with the same modes as the original",
"file. The -f option means to unlink any existing file, permitting",
"the link to occur. The -s option means to create a symbolic link.",
"By default, ln makes hard links.",
(char *)NULL
};
/* The standard structure describing a builtin command. bash keeps an array
of these structures. */
struct builtin ln_struct = {
"ln", /* builtin name */
ln_builtin, /* function implementing the builtin */
BUILTIN_ENABLED, /* initial flags for builtin */
ln_doc, /* array of long documentation strings. */
"ln [-fs] file1 [file2] OR ln [-fs] file ... directory", /* usage synopsis; becomes short_doc */
0 /* reserved for internal use */
};

216
examples/loadables/mkdir.c Normal file
View file

@ -0,0 +1,216 @@
/* mkdir - make directories */
/* See Makefile for compilation details. */
#include <config.h>
#include "bashtypes.h"
#include "posixstat.h"
#include <errno.h>
#include <stdio.h>
#include "bashansi.h"
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif
#include "builtins.h"
#include "shell.h"
#include "bashgetopt.h"
#if !defined (errno)
extern int errno;
#endif
#define ISOCTAL(c) ((c) >= '0' && (c) <= '7')
extern int parse_symbolic_mode ();
static int make_path ();
static int original_umask;
int
mkdir_builtin (list)
WORD_LIST *list;
{
int opt, pflag, omode, rval, octal, nmode, parent_mode, um;
char *mode;
WORD_LIST *l;
reset_internal_getopt ();
pflag = 0;
mode = (char *)NULL;
while ((opt = internal_getopt(list, "m:p")) != -1)
switch (opt)
{
case 'p':
pflag = 1;
break;
case 'm':
mode = list_optarg;
break;
default:
builtin_usage();
return (EX_USAGE);
}
list = loptend;
if (list == 0)
{
builtin_usage ();
return (EX_USAGE);
}
if (mode == NULL)
omode = S_IRWXU | S_IRWXG | S_IRWXO; /* a=rwx */
else if (ISOCTAL (*mode)) /* octal number */
{
omode = read_octal (mode);
if (omode < 0)
{
builtin_error ("invalid file mode: %s", mode);
return (EXECUTION_FAILURE);
}
octal = 1;
}
else if (mode)
{
/* initial bits are a=rwx; the mode argument modifies them */
omode = parse_symbolic_mode (mode, S_IRWXU | S_IRWXG | S_IRWXO);
if (omode < 0)
{
builtin_error ("invalid file mode: %s", mode);
return (EXECUTION_FAILURE);
}
octal = 0;
}
/* Make the new mode */
original_umask = umask (0);
umask (original_umask);
nmode = (S_IRWXU | S_IRWXG | S_IRWXO) & ~original_umask;
parent_mode = nmode | (S_IWRITE|S_IEXEC); /* u+wx */
/* Adjust new mode based on mode argument */
nmode &= omode;
for (rval = EXECUTION_SUCCESS, l = list; l; l = l->next)
{
if (pflag && make_path (l->word->word, nmode, parent_mode))
{
rval = EXECUTION_FAILURE;
continue;
}
else if (pflag == 0 && mkdir (l->word->word, nmode) < 0)
{
builtin_error ("cannot create directory `%s': %s", l->word->word, strerror (errno));
rval = EXECUTION_FAILURE;
}
}
return rval;
}
/* Make all the directories leading up to PATH, then create PATH. Note that
this changes the process's umask; make sure that all paths leading to a
return reset it to ORIGINAL_UMASK */
static int
make_path (path, nmode, parent_mode)
char *path;
int nmode, parent_mode;
{
int oumask;
struct stat sb;
char *p, *npath;
if (stat (path, &sb) == 0)
{
if (S_ISDIR (sb.st_mode) == 0)
{
builtin_error ("`%s': file exists but is not a directory", path);
return 1;
}
if (chmod (path, nmode))
{
builtin_error ("%s: %s", path, strerror (errno));
return 1;
}
return 0;
}
oumask = umask (0);
npath = savestring (path); /* So we can write to it. */
/* Check whether or not we need to do anything with intermediate dirs. */
/* Skip leading slashes. */
p = npath;
while (*p == '/')
p++;
while (p = strchr (p, '/'))
{
*p = '\0';
if (stat (npath, &sb) != 0)
{
if (mkdir (npath, parent_mode))
{
builtin_error ("cannot create directory `%s': %s", npath, strerror (errno));
umask (original_umask);
free (npath);
return 1;
}
}
else if (S_ISDIR (sb.st_mode) == 0)
{
builtin_error ("`%s': file exists but is not a directory", npath);
umask (original_umask);
free (npath);
return 1;
}
*p++ = '/'; /* restore slash */
while (*p == '/')
p++;
}
/* Create the final directory component. */
if (stat (npath, &sb) && mkdir (npath, nmode))
{
builtin_error ("cannot create directory `%s': %s", npath, strerror (errno));
umask (original_umask);
free (npath);
return 1;
}
umask (original_umask);
free (npath);
return 0;
}
char *mkdir_doc[] = {
"Make directories. Create the directories named as arguments, in",
"the order specified, using mode rwxrwxrwx as modified by the current",
"umask (see `help umask'). The -m option causes the file permission",
"bits of the final directory to be MODE. The MODE argument may be",
"an octal number or a symbolic mode like that used by chmod(1). If",
"a symbolic mode is used, the operations are interpreted relative to",
"an initial mode of \"a=rwx\". The -p option causes any required",
"intermediate directories in PATH to be created. The directories",
"are created with permssion bits of rwxrwxrwx as modified by the current",
"umask, plus write and search permissions for the owner. mkdir",
"returns 0 if the directories are created successfully, and non-zero",
"if an error occurs.",
(char *)NULL
};
struct builtin mkdir_struct = {
"mkdir",
mkdir_builtin,
BUILTIN_ENABLED,
mkdir_doc,
"mkdir [-p] [-m mode] directory [directory ...]",
0
};

View file

@ -22,7 +22,7 @@ char *necho_doc[] = {
(char *)NULL (char *)NULL
}; };
struct builtin echo_struct = { struct builtin necho_struct = {
"echo", "echo",
necho_builtin, necho_builtin,
BUILTIN_ENABLED, BUILTIN_ENABLED,

View file

@ -170,8 +170,7 @@ portable_chars_only (path)
for (p = path; *p; ++p) for (p = path; *p; ++p)
if (portable_chars[(const unsigned char) *p] == 0) if (portable_chars[(const unsigned char) *p] == 0)
{ {
error (0, 0, "path `%s' contains nonportable character `%c'", builtin_error ("path `%s' contains nonportable character `%c'", path, *p);
path, *p);
return 0; return 0;
} }
return 1; return 1;
@ -212,7 +211,7 @@ dir_ok (path)
if (!S_ISDIR (stats.st_mode)) if (!S_ISDIR (stats.st_mode))
{ {
error (0, 0, "`%s' is not a directory", path); builtin_error ("`%s' is not a directory", path);
return 0; return 0;
} }
@ -324,7 +323,7 @@ validate_path (path, portability)
name_max = _POSIX_NAME_MAX; name_max = _POSIX_NAME_MAX;
if (length > name_max) if (length > name_max)
{ {
error (0, 0, "name `%s' has length %d; exceeds limit of %d", builtin_error ("name `%s' has length %d; exceeds limit of %d",
start, length, name_max); start, length, name_max);
free (parent); free (parent);
return 1; return 1;
@ -350,7 +349,7 @@ validate_path (path, portability)
free (parent); free (parent);
if (strlen (path) > path_max) if (strlen (path) > path_max)
{ {
error (0, 0, "path `%s' has length %d; exceeds limit of %d", builtin_error ("path `%s' has length %d; exceeds limit of %d",
path, strlen (path), path_max); path, strlen (path), path_max);
return 1; return 1;
} }

View file

@ -0,0 +1,71 @@
/*
* printenv -- minimal builtin clone of BSD printenv(1).
*
* usage: printenv [varname]
*
*/
#include <config.h>
#include <stdio.h>
#include "builtins.h"
#include "shell.h"
#include "bashgetopt.h"
extern char **export_env;
int
printenv_builtin (list)
WORD_LIST *list;
{
register char **envp;
int opt;
SHELL_VAR *var;
reset_internal_getopt ();
while ((opt = internal_getopt (list, "")) != -1)
{
switch (opt)
{
default:
builtin_usage ();
return (EX_USAGE);
}
}
list = loptend;
/* printenv */
if (list == 0)
{
maybe_make_export_env (); /* this allows minimal code */
for (envp = export_env; *envp; envp++)
printf ("%s\n", *envp);
return (EXECUTION_SUCCESS);
}
/* printenv varname */
var = find_variable (list->word->word);
if (var == 0 || (exported_p (var) == 0))
return (EXECUTION_FAILURE);
if (function_p (var))
print_var_function (var);
else
print_var_value (var, 0);
return (EXECUTION_SUCCESS);
}
char *printenv_doc[] = {
"print values of environment variables",
(char *)NULL
};
struct builtin printenv_struct = {
"printenv",
printenv_builtin,
BUILTIN_ENABLED,
printenv_doc,
"printenv [varname]",
0
};

View file

@ -1,608 +0,0 @@
/* pushd.c, created from pushd.def. */
#include <config.h>
#include <stdio.h>
#include <sys/param.h>
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif
#include "bashansi.h"
#include <errno.h>
#include <tilde/tilde.h>
#include "shell.h"
#include "builtins.h"
#include "maxpath.h"
#include "common.h"
#if !defined (errno)
extern int errno;
#endif /* !errno */
static char *m_badarg = "%s: bad argument";
/* The list of remembered directories. */
static char **pushd_directory_list = (char **)NULL;
/* Number of existing slots in this list. */
static int directory_list_size;
/* Offset to the end of the list. */
static int directory_list_offset;
static void pushd_error ();
static void clear_directory_stack ();
static int cd_to_string ();
static int change_to_temp ();
static int get_dirstack_index ();
static void add_dirstack_element ();
#define NOCD 0x01
#define ROTATE 0x02
#define LONGFORM 0x04
#define CLEARSTAK 0x08
int
pushd_builtin (list)
WORD_LIST *list;
{
char *temp, *current_directory, *top;
int j, flags;
long num;
char direction;
/* If there is no argument list then switch current and
top of list. */
if (list == 0)
{
if (directory_list_offset == 0)
{
builtin_error ("no other directory");
return (EXECUTION_FAILURE);
}
current_directory = get_working_directory ("pushd");
if (current_directory == 0)
return (EXECUTION_FAILURE);
j = directory_list_offset - 1;
temp = pushd_directory_list[j];
pushd_directory_list[j] = current_directory;
j = change_to_temp (temp);
free (temp);
return j;
}
for (flags = 0; list; list = list->next)
{
if (ISOPTION (list->word->word, 'n'))
{
flags |= NOCD;
}
else if (ISOPTION (list->word->word, '-'))
{
list = list->next;
break;
}
else if (list->word->word[0] == '-' && list->word->word[1] == '\0')
/* Let `pushd -' work like it used to. */
break;
else if (((direction = list->word->word[0]) == '+') || direction == '-')
{
if (legal_number (list->word->word + 1, &num) == 0)
{
builtin_error (m_badarg, list->word->word);
builtin_usage ();
return (EXECUTION_FAILURE);
}
if (direction == '-')
num = directory_list_offset - num;
if (num > directory_list_offset || num < 0)
{
pushd_error (directory_list_offset, list->word->word);
return (EXECUTION_FAILURE);
}
flags |= ROTATE;
}
else if (*list->word->word == '-')
{
bad_option (list->word->word);
builtin_usage ();
return (EXECUTION_FAILURE);
}
else
break;
}
if (flags & ROTATE)
{
/* Rotate the stack num times. Remember, the current
directory acts like it is part of the stack. */
temp = get_working_directory ("pushd");
if (num == 0)
{
j = ((flags & NOCD) == 0) ? change_to_temp (temp) : EXECUTION_SUCCESS;
free (temp);
return j;
}
do
{
top = pushd_directory_list[directory_list_offset - 1];
for (j = directory_list_offset - 2; j > -1; j--)
pushd_directory_list[j + 1] = pushd_directory_list[j];
pushd_directory_list[j + 1] = temp;
temp = top;
num--;
}
while (num);
j = ((flags & NOCD) == 0) ? change_to_temp (temp) : EXECUTION_SUCCESS;
free (temp);
return j;
}
if (list == 0)
return (EXECUTION_SUCCESS);
/* Change to the directory in list->word->word. Save the current
directory on the top of the stack. */
current_directory = get_working_directory ("pushd");
if (current_directory == 0)
return (EXECUTION_FAILURE);
j = ((flags & NOCD) == 0) ? cd_builtin (list) : EXECUTION_SUCCESS;
if (j == EXECUTION_SUCCESS)
{
add_dirstack_element ((flags & NOCD) ? savestring (list->word->word) : current_directory);
dirs_builtin ((WORD_LIST *)NULL);
if (flags & NOCD)
free (current_directory);
return (EXECUTION_SUCCESS);
}
else
{
free (current_directory);
return (EXECUTION_FAILURE);
}
}
/* Pop the directory stack, and then change to the new top of the stack.
If LIST is non-null it should consist of a word +N or -N, which says
what element to delete from the stack. The default is the top one. */
int
popd_builtin (list)
WORD_LIST *list;
{
register int i;
long which;
int flags;
char direction;
char *which_word;
which_word = (char *)NULL;
for (flags = 0, which = 0L, direction = '+'; list; list = list->next)
{
if (ISOPTION (list->word->word, 'n'))
{
flags |= NOCD;
}
else if (ISOPTION (list->word->word, '-'))
{
list = list->next;
break;
}
else if (((direction = list->word->word[0]) == '+') || direction == '-')
{
if (legal_number (list->word->word + 1, &which) == 0)
{
builtin_error (m_badarg, list->word->word);
builtin_usage ();
return (EXECUTION_FAILURE);
}
which_word = list->word->word;
}
else if (*list->word->word == '-')
{
bad_option (list->word->word);
builtin_usage ();
return (EXECUTION_FAILURE);
}
else
break;
}
if (which > directory_list_offset || (directory_list_offset == 0 && which == 0))
{
pushd_error (directory_list_offset, which_word ? which_word : "");
return (EXECUTION_FAILURE);
}
/* Handle case of no specification, or top of stack specification. */
if ((direction == '+' && which == 0) ||
(direction == '-' && which == directory_list_offset))
{
i = ((flags & NOCD) == 0) ? cd_to_string (pushd_directory_list[directory_list_offset - 1])
: EXECUTION_SUCCESS;
if (i != EXECUTION_SUCCESS)
return (i);
free (pushd_directory_list[--directory_list_offset]);
}
else
{
/* Since an offset other than the top directory was specified,
remove that directory from the list and shift the remainder
of the list into place. */
i = (direction == '+') ? directory_list_offset - which : which;
free (pushd_directory_list[i]);
directory_list_offset--;
/* Shift the remainder of the list into place. */
for (; i < directory_list_offset; i++)
pushd_directory_list[i] = pushd_directory_list[i + 1];
}
dirs_builtin ((WORD_LIST *)NULL);
return (EXECUTION_SUCCESS);
}
/* Print the current list of directories on the directory stack. */
int
dirs_builtin (list)
WORD_LIST *list;
{
int flags, desired_index, index_flag, vflag;
long i;
char *temp, *w;
for (flags = vflag = index_flag = 0, desired_index = -1, w = ""; list; list = list->next)
{
if (ISOPTION (list->word->word, 'l'))
{
flags |= LONGFORM;
}
else if (ISOPTION (list->word->word, 'c'))
{
flags |= CLEARSTAK;
}
else if (ISOPTION (list->word->word, 'v'))
{
vflag |= 2;
}
else if (ISOPTION (list->word->word, 'p'))
{
vflag |= 1;
}
else if (ISOPTION (list->word->word, '-'))
{
list = list->next;
break;
}
else if (*list->word->word == '+' || *list->word->word == '-')
{
int sign;
if (legal_number (w = list->word->word + 1, &i) == 0)
{
builtin_error (m_badarg, list->word->word);
builtin_usage ();
return (EXECUTION_FAILURE);
}
sign = (*list->word->word == '+') ? 1 : -1;
desired_index = get_dirstack_index (i, sign, &index_flag);
}
else
{
bad_option (list->word->word);
builtin_usage ();
return (EXECUTION_FAILURE);
}
}
if (flags & CLEARSTAK)
{
clear_directory_stack ();
return (EXECUTION_SUCCESS);
}
if (index_flag && (desired_index < 0 || desired_index > directory_list_offset))
{
pushd_error (directory_list_offset, w);
return (EXECUTION_FAILURE);
}
#define DIRSTACK_FORMAT(temp) \
(flags & LONGFORM) ? temp : polite_directory_format (temp)
/* The first directory printed is always the current working directory. */
if (index_flag == 0 || (index_flag == 1 && desired_index == 0))
{
temp = get_working_directory ("dirs");
if (temp == 0)
temp = savestring ("<no current directory>");
if (vflag & 2)
printf ("%2d %s", 0, DIRSTACK_FORMAT (temp));
else
printf ("%s", DIRSTACK_FORMAT (temp));
free (temp);
if (index_flag)
{
putchar ('\n');
return EXECUTION_SUCCESS;
}
}
#define DIRSTACK_ENTRY(i) \
(flags & LONGFORM) ? pushd_directory_list[i] \
: polite_directory_format (pushd_directory_list[i])
/* Now print the requested directory stack entries. */
if (index_flag)
{
if (vflag & 2)
printf ("%2d %s", directory_list_offset - desired_index,
DIRSTACK_ENTRY (desired_index));
else
printf ("%s", DIRSTACK_ENTRY (desired_index));
}
else
for (i = directory_list_offset - 1; i >= 0; i--)
if (vflag >= 2)
printf ("\n%2d %s", directory_list_offset - (int)i, DIRSTACK_ENTRY (i));
else
printf ("%s%s", (vflag & 1) ? "\n" : " ", DIRSTACK_ENTRY (i));
putchar ('\n');
fflush (stdout);
return (EXECUTION_SUCCESS);
}
static void
pushd_error (offset, arg)
int offset;
char *arg;
{
if (offset == 0)
builtin_error ("directory stack empty");
else if (arg)
builtin_error ("%s: bad directory stack index", arg);
else
builtin_error ("bad directory stack index");
}
static void
clear_directory_stack ()
{
register int i;
for (i = 0; i < directory_list_offset; i++)
free (pushd_directory_list[i]);
directory_list_offset = 0;
}
/* Switch to the directory in NAME. This uses the cd_builtin to do the work,
so if the result is EXECUTION_FAILURE then an error message has already
been printed. */
static int
cd_to_string (name)
char *name;
{
WORD_LIST *tlist;
int result;
tlist = make_word_list (make_word (name), NULL);
result = cd_builtin (tlist);
dispose_words (tlist);
return (result);
}
static int
change_to_temp (temp)
char *temp;
{
int tt;
tt = temp ? cd_to_string (temp) : EXECUTION_FAILURE;
if (tt == EXECUTION_SUCCESS)
dirs_builtin ((WORD_LIST *)NULL);
return (tt);
}
static void
add_dirstack_element (dir)
char *dir;
{
int j;
if (directory_list_offset == directory_list_size)
{
j = (directory_list_size += 10) * sizeof (char *);
pushd_directory_list = (char **)xrealloc (pushd_directory_list, j);
}
pushd_directory_list[directory_list_offset++] = dir;
}
static int
get_dirstack_index (ind, sign, indexp)
int ind, sign, *indexp;
{
if (indexp)
*indexp = sign > 0 ? 1 : 2;
/* dirs +0 prints the current working directory. */
/* dirs -0 prints last element in directory stack */
if (ind == 0 && sign > 0)
return 0;
else if (ind == directory_list_offset)
{
if (indexp)
*indexp = sign > 0 ? 2 : 1;
return 0;
}
else
return (sign > 0 ? directory_list_offset - ind : ind);
}
char *
get_dirstack_element (ind, sign)
int ind, sign;
{
int i;
i = get_dirstack_index (ind, sign, (int *)NULL);
return (i < 0 || i > directory_list_offset) ? (char *)NULL
: pushd_directory_list[i];
}
void
set_dirstack_element (ind, sign, value)
int ind, sign;
char *value;
{
int i;
i = get_dirstack_index (ind, sign, (int *)NULL);
if (ind == 0 || i < 0 || i > directory_list_offset)
return;
free (pushd_directory_list[i]);
pushd_directory_list[i] = savestring (value);
}
WORD_LIST *
get_directory_stack ()
{
register int i;
WORD_LIST *ret;
char *d, *t;
for (ret = (WORD_LIST *)NULL, i = 0; i < directory_list_offset; i++)
{
d = polite_directory_format (pushd_directory_list[i]);
ret = make_word_list (make_word (d), ret);
}
/* Now the current directory. */
d = get_working_directory ("dirstack");
i = 0; /* sentinel to decide whether or not to free d */
if (d == 0)
d = ".";
else
{
t = polite_directory_format (d);
/* polite_directory_format sometimes returns its argument unchanged.
If it does not, we can free d right away. If it does, we need to
mark d to be deleted later. */
if (t != d)
{
free (d);
d = t;
}
else /* t == d, so d is what we want */
i = 1;
}
ret = make_word_list (make_word (d), ret);
if (i)
free (d);
return ret; /* was (REVERSE_LIST (ret, (WORD_LIST *)); */
}
static char *dirs_doc[] = {
"Display the list of currently remembered directories. Directories",
"find their way onto the list with the `pushd' command; you can get",
"back up through the list with the `popd' command.",
"",
"The -l flag specifies that `dirs' should not print shorthand versions",
"of directories which are relative to your home directory. This means",
"that `~/bin' might be displayed as `/homes/bfox/bin'. The -v flag",
"causes `dirs' to print the directory stack with one entry per line,",
"prepending the directory name with its position in the stack. The -p",
"flag does the same thing, but the stack position is not prepended.",
"The -c flag clears the directory stack by deleting all of the elements.",
"",
"+N displays the Nth entry counting from the left of the list shown by",
" dirs when invoked without options, starting with zero.",
"",
"-N displays the Nth entry counting from the right of the list shown by",
" dirs when invoked without options, starting with zero.",
(char *)NULL
};
static char *pushd_doc[] = {
"Adds a directory to the top of the directory stack, or rotates",
"the stack, making the new top of the stack the current working",
"directory. With no arguments, exchanges the top two directories.",
"",
"+N Rotates the stack so that the Nth directory (counting",
" from the left of the list shown by `dirs', starting with"
" zero) is at the top.",
"",
"-N Rotates the stack so that the Nth directory (counting",
" from the right of the list shown by `dirs', starting with"
" zero) is at the top.",
"",
"-n suppress the normal change of directory when adding directories",
" to the stack, so only the stack is manipulated.",
"",
"dir adds DIR to the directory stack at the top, making it the",
" new current working directory.",
"",
"You can see the directory stack with the `dirs' command.",
(char *)NULL
};
static char *popd_doc[] = {
"Removes entries from the directory stack. With no arguments,",
"removes the top directory from the stack, and cd's to the new",
"top directory.",
"",
"+N removes the Nth entry counting from the left of the list",
" shown by `dirs', starting with zero. For example: `popd +0'",
" removes the first directory, `popd +1' the second.",
"",
"-N removes the Nth entry counting from the right of the list",
" shown by `dirs', starting with zero. For example: `popd -0'",
" removes the last directory, `popd -1' the next to last.",
"",
"-n suppress the normal change of directory when removing directories",
" from the stack, so only the stack is manipulated.",
"",
"You can see the directory stack with the `dirs' command.",
(char *)NULL
};
struct builtin pushd_struct = {
"pushd",
pushd_builtin,
BUILTIN_ENABLED,
pushd_doc,
"pushd [+N | -N] [-n] [dir]",
0
};
struct builtin popd_struct = {
"popd",
popd_builtin,
BUILTIN_ENABLED,
popd_doc,
"popd [+N | -N] [-n]",
0
};
struct builtin dirs_struct = {
"dirs",
dirs_builtin,
BUILTIN_ENABLED,
dirs_doc,
"dirs [-clpv] [+N] [-N]",
0
};

View file

@ -60,6 +60,8 @@ long sec, usec;
/* /*
* An incredibly simplistic floating point converter. * An incredibly simplistic floating point converter.
*/ */
static int multiplier[7] = { 1, 100000, 10000, 1000, 100, 10, 1 };
static int static int
convert(s, sp, usp) convert(s, sp, usp)
char *s; char *s;
@ -95,18 +97,11 @@ long *sp, *usp;
} }
/* Now convert to millionths */ /* Now convert to millionths */
if (n == 1) usec *= multiplier[n];
usec *= 100000;
else if (n == 2) if (n == 6 && p[6] && isdigit(p[6]) && p[6] >= '5')
usec *= 10000;
else if (n == 3)
usec *= 1000;
else if (n == 4)
usec *= 100;
else if (n == 5)
usec *= 10;
else if (n == 6 && p[6] && isdigit(p[6]) && p[6] >= '5')
usec++; /* round up 1 */ usec++; /* round up 1 */
RETURN(1); RETURN(1);
} }

32
examples/loadables/sync.c Normal file
View file

@ -0,0 +1,32 @@
/* sync - sync the disks by forcing pending filesystem writes to complete */
#include <config.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "builtins.h"
#include "shell.h"
#include "bashgetopt.h"
sync_builtin (list)
WORD_LIST *list;
{
sync();
return (EXECUTION_SUCCESS);
}
char *sync_doc[] = {
"force completion of pending disk writes",
(char *)NULL
};
struct builtin sync_struct = {
"sync", /* builtin name */
sync_builtin, /* function implementing the builtin */
BUILTIN_ENABLED, /* initial flags for builtin */
sync_doc, /* array of long documentation strings. */
"sync", /* usage synopsis; becomes short_doc */
0 /* reserved for internal use */
};

View file

@ -0,0 +1,56 @@
/* template - example template for loadable builtin */
/* See Makefile for compilation details. */
#include <config.h>
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif
#include "bashansi.h"
#include <stdio.h>
#include <errno.h>
#include "builtins.h"
#include "shell.h"
#include "bashgetopt.h"
#if !defined (errno)
extern int errno;
#endif
extern char *strerror ();
template_builtin (list)
WORD_LIST *list;
{
int opt, rval;
rval = EXECUTION_SUCCESS;
reset_internal_getopt ();
while ((opt = internal_getopt (list, "")) != -1)
{
switch (opt)
{
default:
builtin_usage ();
return (EX_USAGE);
}
}
list = loptend;
return (rval);
}
char *template_doc[] = {
(char *)NULL
};
struct builtin template_struct = {
"template", /* builtin name */
template_builtin, /* function implementing the builtin */
BUILTIN_ENABLED, /* initial flags for builtin */
template_doc, /* array of long documentation strings. */
"template", /* usage synopsis; becomes short_doc */
0 /* reserved for internal use */
};

139
examples/loadables/uname.c Normal file
View file

@ -0,0 +1,139 @@
/*
* uname - print system information
*
* usage: uname [-amnrsv]
*
*/
#include <config.h>
#include <stdio.h>
#include "bashtypes.h"
#if defined (HAVE_UNAME)
# include <sys/utsname.h>
#else
struct utsname {
char sysname[32];
char nodename[32];
char release[32];
char version[32];
char machine[32];
};
#endif
#include <errno.h>
#include "builtins.h"
#include "shell.h"
#include "bashgetopt.h"
#define FLAG_SYSNAME 0x01 /* -s */
#define FLAG_NODENAME 0x02 /* -n */
#define FLAG_RELEASE 0x04 /* -r */
#define FLAG_VERSION 0x08 /* -v */
#define FLAG_MACHINE 0x10 /* -m, -p */
#define FLAG_ALL 0x1f
#ifndef errno
extern int errno;
#endif
static void uprint();
static int uname_flags;
uname_builtin (list)
WORD_LIST *list;
{
int opt, r;
struct utsname uninfo;
uname_flags = 0;
reset_internal_getopt ();
while ((opt = internal_getopt (list, "amnprsv")) != -1)
{
switch (opt)
{
case 'a':
uname_flags |= FLAG_ALL;
break;
case 'm':
case 'p':
uname_flags |= FLAG_MACHINE;
break;
case 'n':
uname_flags |= FLAG_NODENAME;
break;
case 'r':
uname_flags |= FLAG_RELEASE;
break;
case 's':
uname_flags |= FLAG_SYSNAME;
break;
case 'v':
uname_flags |= FLAG_VERSION;
break;
default:
builtin_usage ();
return (EX_USAGE);
}
}
list = loptend;
if (list)
{
builtin_usage ();
return (EX_USAGE);
}
if (uname_flags == 0)
uname_flags = FLAG_SYSNAME;
/* Only ancient systems will not have uname(2). */
#ifdef HAVE_UNAME
if (uname (&uninfo) < 0)
{
builtin_error ("cannot get system name: %s", strerror (errno));
return (EXECUTION_FAILURE);
}
#else
builtin_error ("cannot get system information: uname(2) not available");
return (EXECUTION_FAILURE);
#endif
uprint (FLAG_SYSNAME, uninfo.sysname);
uprint (FLAG_NODENAME, uninfo.nodename);
uprint (FLAG_RELEASE, uninfo.release);
uprint (FLAG_VERSION, uninfo.version);
uprint (FLAG_MACHINE, uninfo.machine);
return (EXECUTION_SUCCESS);
}
static void
uprint (flag, info)
int flag;
char *info;
{
if (uname_flags & flag)
{
uname_flags &= ~flag;
printf ("%s%c", info, uname_flags ? ' ' : '\n');
}
}
char *uname_doc[] = {
"display information about the system",
(char *)NULL
};
struct builtin uname_struct = {
"uname",
uname_builtin,
BUILTIN_ENABLED,
uname_doc,
"uname [-amnrsv]",
0
};

View file

@ -0,0 +1,52 @@
/* unlink - remove a directory entry */
/* Should only be used to remove directories by a superuser prepared to let
fsck clean up the file system. */
#include <config.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <stdio.h>
#include <errno.h>
#include "builtins.h"
#include "shell.h"
#ifndef errno
extern int errno;
#endif
unlink_builtin (list)
WORD_LIST *list;
{
if (list == 0)
{
builtin_usage ();
return (EX_USAGE);
}
if (unlink (list->word->word) != 0)
{
builtin_error ("%s: cannot unlink: %s", list->word->word, strerror (errno));
return (EXECUTION_FAILURE);
}
return (EXECUTION_SUCCESS);
}
char *unlink_doc[] = {
"Remove a directory entry.",
(char *)NULL
};
struct builtin unlink_struct = {
"unlink", /* builtin name */
unlink_builtin, /* function implementing the builtin */
BUILTIN_ENABLED, /* initial flags for builtin */
unlink_doc, /* array of long documentation strings. */
"unlink name", /* usage synopsis; becomes short_doc */
0 /* reserved for internal use */
};

View file

@ -0,0 +1,52 @@
/*
* whoami - print out username of current user
*/
#include <config.h>
#include <stdio.h>
#include "builtins.h"
#include "shell.h"
#include "bashgetopt.h"
whoami_builtin (list)
WORD_LIST *list;
{
int opt;
reset_internal_getopt ();
while ((opt = internal_getopt (list, "")) != -1)
{
switch (opt)
{
default:
builtin_usage ();
return (EX_USAGE);
}
}
list = loptend;
if (list)
{
builtin_usage ();
return (EX_USAGE);
}
if (current_user.user_name == 0)
get_current_user_info ();
printf ("%s\n", current_user.user_name);
return (EXECUTION_SUCCESS);
}
char *whoami_doc[] = {
"display name of current user",
(char *)NULL
};
struct builtin whoami_struct = {
"whoami",
whoami_builtin,
BUILTIN_ENABLED,
whoami_doc,
"whoami",
0
};

View file

@ -1,8 +1,8 @@
#! /bin/bash #! /bin/bash
# #
# alias-conv.sh - convert csh aliases to bash aliases and functions # aliasconv.bash - convert csh aliases to bash aliases and functions
# #
# usage: alias-conv.sh # usage: aliasconv.bash
# #
# Chet Ramey # Chet Ramey
# chet@po.cwru.edu # chet@po.cwru.edu
@ -27,7 +27,11 @@ mkalias ()
} }
EOF EOF
sed "s/^\([a-zA-Z0-9_-]*\)$T\(.*\)$/mkalias \1 '\2'/" >>/tmp/cb$$.1 # the first thing we want to do is to protect single quotes in the alias,
# since they whole thing is going to be surrounded by single quotes when
# passed to mkalias
sed -e "s:':\\'\\\'\\':" -e "s/^\([a-zA-Z0-9_-]*\)$T\(.*\)$/mkalias \1 '\2'/" >>/tmp/cb$$.1
$BASH /tmp/cb$$.1 | sed -e 's/\$cwd/\$PWD/g' \ $BASH /tmp/cb$$.1 | sed -e 's/\$cwd/\$PWD/g' \
-e 's/\$term/\$TERM/g' \ -e 's/\$term/\$TERM/g' \

View file

@ -1,8 +1,8 @@
#! /bin/bash #! /bin/bash
# #
# alias-conv.sh - convert csh aliases to bash aliases and functions # aliasconv.sh - convert csh aliases to bash aliases and functions
# #
# usage: alias-conv.sh # usage: aliasconv.sh
# #
# Chet Ramey # Chet Ramey
# chet@po.cwru.edu # chet@po.cwru.edu
@ -27,7 +27,11 @@ mkalias ()
} }
EOF EOF
sed "s/^\([a-zA-Z0-9_-]*\)$T\(.*\)$/mkalias \1 '\2'/" >>/tmp/cb$$.1 # the first thing we want to do is to protect single quotes in the alias,
# since they whole thing is going to be surrounded by single quotes when
# passed to mkalias
sed -e "s:':\\'\\\'\\':" -e "s/^\([a-zA-Z0-9_-]*\)$T\(.*\)$/mkalias \1 '\2'/" >>/tmp/cb$$.1
sh /tmp/cb$$.1 | sed -e 's/\$cwd/\$PWD/g' \ sh /tmp/cb$$.1 | sed -e 's/\$cwd/\$PWD/g' \
-e 's/\$term/\$TERM/g' \ -e 's/\$term/\$TERM/g' \

View file

@ -90,6 +90,11 @@ ash_lk(){ echo " $1 " | fgrep " $2 " >&- 2>&-; }
ash_pr(){ echo $* | tr ' ' '\012' | pr -5 -t -w75 -l$[ ( $# + 4 ) / 5 ]; } ash_pr(){ echo $* | tr ' ' '\012' | pr -5 -t -w75 -l$[ ( $# + 4 ) / 5 ]; }
ash_rm(){ echo " $1 " | sed -e "s/ $2 / /" -e 's/^ //' -e 's/ $//'; } ash_rm(){ echo " $1 " | sed -e "s/ $2 / /" -e 's/^ //' -e 's/ $//'; }
# enable history, bang history expansion, and emacs editing
set -o history
set -o histexpand
set -o emacs
cd cd
LIM=.limbo # $HOME/$LIM contains "destroyed" objects LIM=.limbo # $HOME/$LIM contains "destroyed" objects
mkdir $LIM >&- 2>&- mkdir $LIM >&- 2>&-
@ -164,8 +169,7 @@ do room=`pwd`
prev=$room prev=$room
fi fi
echo -n '-advsh> ' # prompt read -e -p '-advsh> ' verb obj x # prompt is '-advsh> '
read verb obj x
if [ $? != 0 ] if [ $? != 0 ]
then verb=quit # EOF then verb=quit # EOF
fi fi

View file

@ -737,6 +737,13 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
commands, this causes the last simple command in commands, this causes the last simple command in
the function to be waited for twice. */ the function to be waited for twice. */
exec_result = wait_for (last_made_pid); exec_result = wait_for (last_made_pid);
#if defined (RECYCLES_PIDS)
/* LynxOS, for one, recycles pids very quickly -- so quickly
that a new process may have the same pid as the last one
created. This has been reported to fix the problem. */
if (exec_result == 0)
last_made_pid = NO_PID;
#endif
} }
} }
@ -863,8 +870,7 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
break; break;
default: default:
programming_error command_error ("execute_command", CMDERR_BADTYPE, command->type, 0);
("execute_command: bad command type `%d'", command->type);
} }
if (my_undo_list) if (my_undo_list)
@ -905,7 +911,10 @@ difftimeval (d, t1, t2)
d->tv_usec += 1000000; d->tv_usec += 1000000;
d->tv_sec -= 1; d->tv_sec -= 1;
if (d->tv_sec < 0) /* ??? -- BSD/OS does this */ if (d->tv_sec < 0) /* ??? -- BSD/OS does this */
d->tv_sec = 0; {
d->tv_sec = 0;
d->tv_usec = 0;
}
} }
return d; return d;
} }
@ -916,7 +925,7 @@ addtimeval (d, t1, t2)
{ {
d->tv_sec = t1->tv_sec + t2->tv_sec; d->tv_sec = t1->tv_sec + t2->tv_sec;
d->tv_usec = t1->tv_usec + t2->tv_usec; d->tv_usec = t1->tv_usec + t2->tv_usec;
if (d->tv_usec > 1000000) if (d->tv_usec >= 1000000)
{ {
d->tv_usec -= 1000000; d->tv_usec -= 1000000;
d->tv_sec += 1; d->tv_sec += 1;
@ -1472,7 +1481,7 @@ execute_connection (command, asynchronous, pipe_in, pipe_out, fds_to_close)
break; break;
default: default:
programming_error ("execute_connection: bad connector `%d'", command->value.Connection->connector); command_error ("execute_connection", CMDERR_BADCONN, command->value.Connection->connector, 0);
jump_to_top_level (DISCARD); jump_to_top_level (DISCARD);
exec_result = EXECUTION_FAILURE; exec_result = EXECUTION_FAILURE;
} }
@ -2062,7 +2071,7 @@ execute_arith_command (arith_command)
result = 0; result = 0;
this_command_name = "(("; this_command_name = "(("; /* )) */
/* If we're in a function, update the line number information. */ /* If we're in a function, update the line number information. */
if (variable_context) if (variable_context)
line_number = arith_command->line - function_line_number; line_number = arith_command->line - function_line_number;
@ -2092,7 +2101,7 @@ static int
execute_cond_node (cond) execute_cond_node (cond)
COND_COM *cond; COND_COM *cond;
{ {
int result, invert, patmatch; int result, invert, patmatch, flags;
char *arg1, *arg2, *print2; char *arg1, *arg2, *print2;
invert = (cond->flags & CMD_INVERT_RETURN); invert = (cond->flags & CMD_INVERT_RETURN);
@ -2124,8 +2133,9 @@ execute_cond_node (cond)
} }
else if (cond->type == COND_BINARY) else if (cond->type == COND_BINARY)
{ {
patmatch = (cond->op->word[1] == '=') && (cond->op->word[2] == '\0') && patmatch = ((cond->op->word[1] == '=') && (cond->op->word[2] == '\0') &&
(cond->op->word[0] == '!' || cond->op->word[0] == '='); (cond->op->word[0] == '!' || cond->op->word[0] == '=') ||
(cond->op->word[0] == '=' && cond->op->word[1] == '\0'));
arg1 = cond_expand_word (cond->left->op, 0); arg1 = cond_expand_word (cond->left->op, 0);
if (arg1 == 0) if (arg1 == 0)
@ -2147,7 +2157,7 @@ execute_cond_node (cond)
} }
else else
{ {
programming_error ("execute_cond_node: %d: unknown conditional command type", cond->type); command_error ("execute_cond_node", CMDERR_BADTYPE, cond->type, 0);
jump_to_top_level (DISCARD); jump_to_top_level (DISCARD);
result = EXECUTION_FAILURE; result = EXECUTION_FAILURE;
} }
@ -2262,7 +2272,7 @@ fix_assignment_words (words)
for (w = words; w; w = w->next) for (w = words; w; w = w->next)
if (w->word->flags & W_ASSIGNMENT) if (w->word->flags & W_ASSIGNMENT)
w->word->flags |= W_NOSPLIT; w->word->flags |= (W_NOSPLIT|W_NOGLOB);
} }
/* The meaty part of all the executions. We have to start hacking the /* The meaty part of all the executions. We have to start hacking the
@ -2277,7 +2287,7 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close)
WORD_LIST *words, *lastword; WORD_LIST *words, *lastword;
char *command_line, *lastarg, *temp; char *command_line, *lastarg, *temp;
int first_word_quoted, result, builtin_is_special, already_forked, dofork; int first_word_quoted, result, builtin_is_special, already_forked, dofork;
pid_t old_last_command_subst_pid; pid_t old_last_command_subst_pid, old_last_async_pid;
Function *builtin; Function *builtin;
SHELL_VAR *func; SHELL_VAR *func;
@ -2297,6 +2307,7 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close)
simple_command->words ? (simple_command->words->word->flags & W_QUOTED): 0; simple_command->words ? (simple_command->words->word->flags & W_QUOTED): 0;
old_last_command_subst_pid = last_command_subst_pid; old_last_command_subst_pid = last_command_subst_pid;
old_last_async_pid = last_asynchronous_pid;
already_forked = dofork = 0; already_forked = dofork = 0;
@ -2327,6 +2338,7 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close)
do_piping (pipe_in, pipe_out); do_piping (pipe_in, pipe_out);
pipe_in = pipe_out = -1; pipe_in = pipe_out = -1;
last_asynchronous_pid = old_last_async_pid;
subshell_environment = async ? SUBSHELL_ASYNC : SUBSHELL_FORK; subshell_environment = async ? SUBSHELL_ASYNC : SUBSHELL_FORK;
} }
else else
@ -2770,11 +2782,14 @@ execute_subshell_builtin_or_function (words, redirects, builtin, var,
struct fd_bitmap *fds_to_close; struct fd_bitmap *fds_to_close;
int flags; int flags;
{ {
int result, r; int result, r, jobs_hack;
/* A subshell is neither a login shell nor interactive. */ /* A subshell is neither a login shell nor interactive. */
login_shell = interactive = 0; login_shell = interactive = 0;
jobs_hack = (builtin == jobs_builtin) &&
((subshell_environment & SUBSHELL_ASYNC) == 0 || pipe_out != NO_PIPE);
subshell_environment = SUBSHELL_ASYNC; subshell_environment = SUBSHELL_ASYNC;
maybe_make_export_env (); /* XXX - is this needed? */ maybe_make_export_env (); /* XXX - is this needed? */
@ -2785,8 +2800,7 @@ execute_subshell_builtin_or_function (words, redirects, builtin, var,
the shell itself. */ the shell itself. */
/* Allow the output of `jobs' to be piped. */ /* Allow the output of `jobs' to be piped. */
if (builtin == jobs_builtin && !async && if (jobs_hack)
(pipe_out != NO_PIPE || pipe_in != NO_PIPE))
kill_current_pipeline (); kill_current_pipeline ();
else else
without_job_control (); without_job_control ();
@ -2898,6 +2912,10 @@ execute_builtin_or_function (words, builtin, var, redirects,
void void
setup_async_signals () setup_async_signals ()
{ {
#if defined (__BEOS__)
set_signal_handler (SIGHUP, SIG_IGN); /* they want csh-like behavior */
#endif
#if defined (JOB_CONTROL) #if defined (JOB_CONTROL)
if (job_control == 0) if (job_control == 0)
#endif #endif

View file

@ -49,6 +49,7 @@ extern void disable_priv_mode __P((void));
extern void unbind_args __P((void)); extern void unbind_args __P((void));
#if defined (RESTRICTED_SHELL) #if defined (RESTRICTED_SHELL)
extern int shell_is_restricted __P((char *));
extern int maybe_make_restricted __P((char *)); extern int maybe_make_restricted __P((char *));
#endif #endif
@ -116,6 +117,7 @@ extern char *getcwd __P((char *, size_t));
#endif #endif
/* Declarations for functions defined in lib/sh/itos.c */ /* Declarations for functions defined in lib/sh/itos.c */
extern char *inttostr __P((int, char *, int));
extern char *itos __P((int)); extern char *itos __P((int));
/* Declarations for functions defined in lib/sh/oslib.c */ /* Declarations for functions defined in lib/sh/oslib.c */

View file

@ -129,7 +129,8 @@ int interactive_comments = 1;
disallows: changing directories, command or path names containing `/', disallows: changing directories, command or path names containing `/',
unsetting or resetting the values of $PATH and $SHELL, and any type of unsetting or resetting the values of $PATH and $SHELL, and any type of
output redirection. */ output redirection. */
int restricted = 0; int restricted = 0; /* currently restricted */
int restricted_shell = 0; /* shell was started in restricted mode. */
#endif /* RESTRICTED_SHELL */ #endif /* RESTRICTED_SHELL */
/* Non-zero means that this shell is running in `privileged' mode. This /* Non-zero means that this shell is running in `privileged' mode. This

View file

@ -61,6 +61,7 @@ extern int history_expansion;
#if defined (RESTRICTED_SHELL) #if defined (RESTRICTED_SHELL)
extern int restricted; extern int restricted;
extern int restricted_shell;
#endif /* RESTRICTED_SHELL */ #endif /* RESTRICTED_SHELL */
extern int *find_flag __P((int)); extern int *find_flag __P((int));

View file

@ -152,6 +152,13 @@ timeval_to_secs (tvp, sp, sfp)
*sfp = (*sfp * 1000) / 1000000; *sfp = (*sfp * 1000) / 1000000;
if (rest >= 500) if (rest >= 500)
*sfp += 1; *sfp += 1;
/* Sanity check */
if (*sfp >= 1000)
{
*sp += 1;
*sfp -= 1000;
}
} }
/* Print the contents of a struct timeval * in a standard way to stdio /* Print the contents of a struct timeval * in a standard way to stdio
@ -189,6 +196,13 @@ clock_t_to_secs (t, sp, sfp)
*sfp = (*sfp * 1000) / clk_tck; *sfp = (*sfp * 1000) / clk_tck;
*sp = t / clk_tck; *sp = t / clk_tck;
/* Sanity check */
if (*sfp >= 1000)
{
*sp += 1;
*sfp -= 1000;
}
} }
/* Print the time defined by a time_t (returned by the `times' and `time' /* Print the time defined by a time_t (returned by the `times' and `time'
@ -347,8 +361,16 @@ unset_nodelay_mode (fd)
fcntl (fd, F_SETFL, flags); fcntl (fd, F_SETFL, flags);
} }
/* There is a bug in the NeXT 2.1 rlogind that causes opens /* There is a bug in the NeXT 2.1 rlogind that causes opens
of /dev/tty to fail. */ of /dev/tty to fail. */
#if defined (__BEOS__)
/* On BeOS, opening in non-blocking mode exposes a bug in BeOS, so turn it
into a no-op. This should probably go away in the future. */
# undef O_NONBLOCK
# define O_NONBLOCK 0
#endif /* __BEOS__ */
void void
check_dev_tty () check_dev_tty ()
{ {
@ -620,11 +642,21 @@ canonicalize_pathname (path)
result[1] = '\0'; result[1] = '\0';
} }
#if 1 /* If the result starts with `//', but the original path does not, we
/* Turn `//' into `/' -- XXX experimental */ can turn the // into /. */
if (result[0] == '/' && result[1] == '/' && result[2] == '\0') if ((result[0] == '/' && result[1] == '/' && result[2] != '/') &&
result[1] = '\0'; (path[0] != '/' || path[1] != '/' || path[2] == '/'))
#endif {
char *r2;
if (result[2] == '\0') /* short-circuit for bare `//' */
result[1] = '\0';
else
{
r2 = savestring (result + 1);
free (result);
result = r2;
}
}
return (result); return (result);
} }
@ -742,7 +774,8 @@ full_pathname (file)
return ((char *)NULL); return ((char *)NULL);
} }
dlen = strlen (current_dir); dlen = strlen (current_dir);
current_dir[dlen++] = '/'; if (current_dir[0] == '/' && dlen > 1)
current_dir[dlen++] = '/';
/* Turn /foo/./bar into /foo/bar. */ /* Turn /foo/./bar into /foo/bar. */
if (file[0] == '.' && file[1] == '/') if (file[0] == '.' && file[1] == '/')
@ -1054,7 +1087,41 @@ get_group_list (ngp)
nbuf = itos ((int)group_array[i]); nbuf = itos ((int)group_array[i]);
group_vector[i] = nbuf; group_vector[i] = nbuf;
} }
if (ngp) if (ngp)
*ngp = ngroups; *ngp = ngroups;
return group_vector; return group_vector;
} }
int *
get_group_array (ngp)
int *ngp;
{
int i;
static int *group_iarray = (int *)NULL;
if (group_iarray)
{
if (ngp)
*ngp = ngroups;
return (group_iarray);
}
if (ngroups == 0)
initialize_group_array ();
if (ngroups <= 0)
{
if (ngp)
*ngp = 0;
return (int *)NULL;
}
group_iarray = (int *)xmalloc (ngroups * sizeof (int));
for (i = 0; i < ngroups; i++)
group_iarray[i] = (int)group_array[i];
if (ngp)
*ngp = ngroups;
return group_iarray;
}

View file

@ -221,5 +221,6 @@ extern char *bash_tilde_expand __P((char *));
extern int group_member __P((gid_t)); extern int group_member __P((gid_t));
extern char **get_group_list __P((int *)); extern char **get_group_list __P((int *));
extern int *get_group_array __P((int *));
#endif /* _GENERAL_H_ */ #endif /* _GENERAL_H_ */

View file

@ -67,6 +67,9 @@ make_hash_table (buckets)
/* Return the location of the bucket which should contain the data /* Return the location of the bucket which should contain the data
for STRING. TABLE is a pointer to a HASH_TABLE. */ for STRING. TABLE is a pointer to a HASH_TABLE. */
/* A possibly better distribution may be obtained by initializing i to
~0UL and using i = (i * 33) + *string++ as the step */
#define ALL_ONES (~((unsigned long) 0)) #define ALL_ONES (~((unsigned long) 0))
#define BITS(h, n) ((unsigned long)(h) & ~(ALL_ONES << (n))) #define BITS(h, n) ((unsigned long)(h) & ~(ALL_ONES << (n)))

156
jobs.c
View file

@ -107,6 +107,10 @@
extern int errno; extern int errno;
#endif /* !errno */ #endif /* !errno */
#if !defined (CHILD_MAX)
# define CHILD_MAX 32
#endif
/* Take care of system dependencies that must be handled when waiting for /* Take care of system dependencies that must be handled when waiting for
children. The arguments to the WAITPID macro match those to the Posix.1 children. The arguments to the WAITPID macro match those to the Posix.1
waitpid() function. */ waitpid() function. */
@ -543,12 +547,7 @@ cleanup_dead_jobs ()
BLOCK_CHILD (set, oset); BLOCK_CHILD (set, oset);
for (i = 0; i < job_slots; i++) for (i = 0; i < job_slots; i++)
#if 0
if (jobs[i] && DEADJOB (i) && IS_NOTIFIED (i) &&
(interactive_shell || (find_last_pid (i) != last_asynchronous_pid)))
#else
if (jobs[i] && DEADJOB (i) && IS_NOTIFIED (i)) if (jobs[i] && DEADJOB (i) && IS_NOTIFIED (i))
#endif
delete_job (i, 0); delete_job (i, 0);
UNBLOCK_CHILD (oset); UNBLOCK_CHILD (oset);
@ -1150,9 +1149,9 @@ make_child (command, async_p)
{ {
/* In the child. Give this child the right process group, set the /* In the child. Give this child the right process group, set the
signals to the default state for a new process. */ signals to the default state for a new process. */
pid_t mine; pid_t mypid;
mine = getpid (); mypid = getpid ();
#if defined (BUFFERED_INPUT) #if defined (BUFFERED_INPUT)
/* Close default_buffered_input if it's > 0. We don't close it if it's /* Close default_buffered_input if it's > 0. We don't close it if it's
0 because that's the file descriptor used when redirecting input, 0 because that's the file descriptor used when redirecting input,
@ -1169,7 +1168,7 @@ make_child (command, async_p)
process group. */ process group. */
if (pipeline_pgrp == 0) /* This is the first child. */ if (pipeline_pgrp == 0) /* This is the first child. */
pipeline_pgrp = mine; pipeline_pgrp = mypid;
/* Check for running command in backquotes. */ /* Check for running command in backquotes. */
if (pipeline_pgrp == shell_pgrp) if (pipeline_pgrp == shell_pgrp)
@ -1185,12 +1184,18 @@ make_child (command, async_p)
this would have for the first child) is an error. Section this would have for the first child) is an error. Section
B.4.3.3, p. 237 also covers this, in the context of job control B.4.3.3, p. 237 also covers this, in the context of job control
shells. */ shells. */
if (setpgid (mine, pipeline_pgrp) < 0) if (setpgid (mypid, pipeline_pgrp) < 0)
sys_error ("child setpgid (%d to %d)", mine, pipeline_pgrp); sys_error ("child setpgid (%d to %d)", mypid, pipeline_pgrp);
#if defined (PGRP_PIPE) #if defined (PGRP_PIPE)
if (pipeline_pgrp == mine) if (pipeline_pgrp == mypid)
{ {
#endif #endif
/* XXX - By convention (and assumption above), if
pipeline_pgrp == shell_pgrp, we are making a child for
command substitution.
In this case, we don't want to give the terminal to the
shell's process group (we could be in the middle of a
pipeline, for example). */
if (async_p == 0 && pipeline_pgrp != shell_pgrp) if (async_p == 0 && pipeline_pgrp != shell_pgrp)
give_terminal_to (pipeline_pgrp); give_terminal_to (pipeline_pgrp);
@ -1471,16 +1476,13 @@ wait_for_single_pid (pid)
r = wait_for (pid); r = wait_for (pid);
/* POSIX.2: if we just waited for $!, we can remove the job from the /* POSIX.2: if we just waited for a job, we can remove it from the jobs
jobs table. */ table. */
if (pid == last_asynchronous_pid) BLOCK_CHILD (set, oset);
{ job = find_job (pid);
BLOCK_CHILD (set, oset); if (job != NO_JOB && jobs[job] && DEADJOB (job))
job = find_job (pid); jobs[job]->flags |= J_NOTIFIED;
if (job != NO_JOB && jobs[job] && DEADJOB (job)) UNBLOCK_CHILD (oset);
jobs[job]->flags |= J_NOTIFIED;
UNBLOCK_CHILD (oset);
}
return r; return r;
} }
@ -1521,6 +1523,11 @@ wait_for_background_pids ()
break; break;
} }
} }
/* POSIX.2 says the shell can discard the statuses of all completed jobs if
`wait' is called with no arguments. */
mark_dead_jobs_as_notified (1);
cleanup_dead_jobs ();
} }
/* Make OLD_SIGINT_HANDLER the SIGINT signal handler. */ /* Make OLD_SIGINT_HANDLER the SIGINT signal handler. */
@ -1722,7 +1729,27 @@ wait_for (pid)
termination_state = process_exit_status (child->status); termination_state = process_exit_status (child->status);
if (job == NO_JOB || IS_JOBCONTROL (job)) if (job == NO_JOB || IS_JOBCONTROL (job))
give_terminal_to (shell_pgrp); {
/* XXX - under what circumstances is a job not present in the jobs
table (job == NO_JOB)?
1. command substitution
In the case of command substitution, at least, it's probably not
the right thing to give the terminal to the shell's process group,
even though there is code in subst.c:command_substitute to work
around it.
Things that don't:
$PROMPT_COMMAND execution
process substitution
*/
#if 0
if (job == NO_JOB)
itrace("wait_for: job == NO_JOB, giving the terminal to shell_pgrp (%d)", shell_pgrp);
#endif
give_terminal_to (shell_pgrp);
}
/* If the command did not exit cleanly, or the job is just /* If the command did not exit cleanly, or the job is just
being stopped, then reset the tty state back to what it being stopped, then reset the tty state back to what it
@ -1775,13 +1802,7 @@ wait_for (pid)
sure we turn on the notify bit so we don't get an unwanted sure we turn on the notify bit so we don't get an unwanted
message about the job's termination, and so delete_job really message about the job's termination, and so delete_job really
clears the slot in the jobs table. */ clears the slot in the jobs table. */
#if 0
if (DEADJOB (job))
jobs[job]->flags |= J_NOTIFIED;
cleanup_dead_jobs ();
#else
notify_and_cleanup (); notify_and_cleanup ();
#endif
} }
} }
@ -1810,15 +1831,12 @@ wait_for_job (job)
pid = last_pid (job); pid = last_pid (job);
r = wait_for (pid); r = wait_for (pid);
/* POSIX.2: if we just waited for $!, we can remove the job from the /* POSIX.2: we can remove the job from the jobs table if we just waited
jobs table. */ for it. */
if (pid == last_asynchronous_pid) BLOCK_CHILD (set, oset);
{ if (job != NO_JOB && jobs[job] && DEADJOB (job))
BLOCK_CHILD (set, oset); jobs[job]->flags |= J_NOTIFIED;
if (job != NO_JOB && jobs[job] && DEADJOB (job)) UNBLOCK_CHILD (oset);
jobs[job]->flags |= J_NOTIFIED;
UNBLOCK_CHILD (oset);
}
return r; return r;
} }
@ -1844,7 +1862,7 @@ notify_and_cleanup ()
void void
reap_dead_jobs () reap_dead_jobs ()
{ {
mark_dead_jobs_as_notified (); mark_dead_jobs_as_notified (0);
cleanup_dead_jobs (); cleanup_dead_jobs ();
} }
@ -2488,23 +2506,25 @@ notify_of_job_status ()
s = jobs[job]->pipe->status; s = jobs[job]->pipe->status;
termsig = WTERMSIG (s); termsig = WTERMSIG (s);
/* POSIX.2 says we have to hang onto the statuses of at most the
last CHILD_MAX background processes if the shell is running a
script. If the shell is not interactive, don't print anything
unless the job was killed by a signal. */
if (startup_state == 0 && WIFSIGNALED (s) == 0 &&
((DEADJOB (job) && IS_FOREGROUND (job) == 0) || STOPPED (job)))
continue;
/* If job control is disabled, don't print the status messages. /* If job control is disabled, don't print the status messages.
Mark dead jobs as notified so that they get cleaned up. If Mark dead jobs as notified so that they get cleaned up. If
startup_state == 2, we were started to run `-c command', so startup_state == 2, we were started to run `-c command', so
don't print anything. If the shell is not interactive, don't don't print anything. */
print anything unless the job was killed by a signal. */ if ((job_control == 0 && interactive_shell) || startup_state == 2)
if ((job_control == 0 && interactive_shell) || startup_state == 2 ||
(startup_state == 0 && WIFSIGNALED (s) == 0))
{ {
#if 0
if (DEADJOB (job))
#else
/* POSIX.2 compatibility: if the shell is not interactive, /* POSIX.2 compatibility: if the shell is not interactive,
hang onto the job corresponding to the last asynchronous hang onto the job corresponding to the last asynchronous
pid until the user has been notified of its status or does pid until the user has been notified of its status or does
a `wait'. */ a `wait'. */
if (DEADJOB (job) && (interactive_shell || (find_last_pid (job) != last_asynchronous_pid))) if (DEADJOB (job) && (interactive_shell || (find_last_pid (job) != last_asynchronous_pid)))
#endif
jobs[job]->flags |= J_NOTIFIED; jobs[job]->flags |= J_NOTIFIED;
continue; continue;
} }
@ -2516,9 +2536,7 @@ notify_of_job_status ()
{ {
case JDEAD: case JDEAD:
if (interactive_shell == 0 && termsig && WIFSIGNALED (s) && if (interactive_shell == 0 && termsig && WIFSIGNALED (s) &&
#if 1
termsig != SIGINT && termsig != SIGINT &&
#endif
#if defined (DONT_REPORT_SIGPIPE) #if defined (DONT_REPORT_SIGPIPE)
termsig != SIGPIPE && termsig != SIGPIPE &&
#endif #endif
@ -2943,24 +2961,48 @@ nohup_all_jobs (running_only)
} }
/* Mark all dead jobs as notified, so delete_job () cleans them out /* Mark all dead jobs as notified, so delete_job () cleans them out
of the job table properly. */ of the job table properly. POSIX.2 says we need to save the
status of the last CHILD_MAX jobs, so we count the number of dead
jobs and mark only enough as notified to save CHILD_MAX statuses. */
static void static void
mark_dead_jobs_as_notified () mark_dead_jobs_as_notified (force)
int force;
{ {
register int i; register int i, ndead;
sigset_t set, oset; sigset_t set, oset;
if (job_slots) if (job_slots)
{ {
BLOCK_CHILD (set, oset); BLOCK_CHILD (set, oset);
/* Count the number of dead jobs */
for (i = ndead = 0; force == 0 && i < job_slots; i++)
{
if (jobs[i] && DEADJOB (i))
ndead++;
}
/* Don't do anything if the number of jobs is less than CHILD_MAX and
we're not forcing a cleanup. */
if (force == 0 && ndead <= CHILD_MAX)
{
UNBLOCK_CHILD (oset);
return;
}
/* Mark enough dead jobs as notified that we keep CHILD_MAX jobs in
the list. This isn't exactly right yet; changes need to be made
to stop_pipeline so we don't mark the newer jobs after we've
created CHILD_MAX slots in the jobs array. */
for (i = 0; i < job_slots; i++) for (i = 0; i < job_slots; i++)
#if 0 {
if (jobs[i] && DEADJOB (i)) if (jobs[i] && DEADJOB (i) && (interactive_shell || (find_last_pid (i) != last_asynchronous_pid)))
#else {
if (jobs[i] && DEADJOB (i) && (interactive_shell || (find_last_pid (i) != last_asynchronous_pid))) jobs[i]->flags |= J_NOTIFIED;
#endif if (force == 0 && --ndead <= CHILD_MAX)
jobs[i]->flags |= J_NOTIFIED; break;
}
}
UNBLOCK_CHILD (oset); UNBLOCK_CHILD (oset);
} }

View file

@ -16,10 +16,13 @@ INSTALL_DATA = @INSTALL_DATA@
CC = @CC@ CC = @CC@
RANLIB = @RANLIB@ RANLIB = @RANLIB@
AR = @AR@ AR = @AR@
ARFLAGS = @ARFLAGS@
RM = rm RM = rm
CP = cp CP = cp
MV = mv MV = mv
SHELL = @MAKE_SHELL@
CFLAGS = @CFLAGS@ CFLAGS = @CFLAGS@
LOCAL_CFLAGS = @LOCAL_CFLAGS@ LOCAL_CFLAGS = @LOCAL_CFLAGS@
CPPFLAGS = @CPPFLAGS@ CPPFLAGS = @CPPFLAGS@
@ -66,7 +69,7 @@ all: $(LIBRARY_NAME)
$(LIBRARY_NAME): $(OBJECTS) $(LIBRARY_NAME): $(OBJECTS)
$(RM) -f $@ $(RM) -f $@
$(AR) cr $@ $(OBJECTS) $(AR) $(ARFLAGS) $@ $(OBJECTS)
-test -n "$(RANLIB)" && $(RANLIB) $@ -test -n "$(RANLIB)" && $(RANLIB) $@
what-tar: what-tar:

View file

@ -25,10 +25,17 @@
#include "collsyms.h" #include "collsyms.h"
#include <ctype.h> #include <ctype.h>
#if defined (HAVE_STRING_H)
# include <string.h>
#else
# include <strings.h>
#endif /* HAVE_STRING_H */
static int gmatch (); static int gmatch ();
static char *brackmatch (); static char *brackmatch ();
#ifdef EXTENDED_GLOB #ifdef EXTENDED_GLOB
static int extmatch (); static int extmatch ();
static char *patscan ();
#endif #endif
#if !defined (isascii) #if !defined (isascii)
@ -155,11 +162,17 @@ gmatch (string, se, pattern, pe, flags)
sc = n < se ? *n : '\0'; sc = n < se ? *n : '\0';
#ifdef EXTENDED_GLOB #ifdef EXTENDED_GLOB
/* extmatch () will handle recursively calling gmatch, so we can
just return what extmatch() returns. */
if ((flags & FNM_EXTMATCH) && *p == '(' && if ((flags & FNM_EXTMATCH) && *p == '(' &&
(c == '+' || c == '*' || c == '?' || c == '@' || c == '!')) /* ) */ (c == '+' || c == '*' || c == '?' || c == '@' || c == '!')) /* ) */
/* extmatch () will handle recursively calling gmatch, so we can {
just return what extmatch() returns. */ int lflags;
return (extmatch (c, n, se, p, pe, flags)); /* If we're not matching the start of the string, we're not
concerned about the special cases for matching `.' */
lflags = (n == string) ? flags : (flags & ~FNM_PERIOD);
return (extmatch (c, n, se, p, pe, lflags));
}
#endif #endif
switch (c) switch (c)
@ -226,7 +239,23 @@ gmatch (string, se, pattern, pe, flags)
#ifdef EXTENDED_GLOB #ifdef EXTENDED_GLOB
/* Handle ******(patlist) */ /* Handle ******(patlist) */
if ((flags & FNM_EXTMATCH) && c == '*' && *p == '(') /*)*/ if ((flags & FNM_EXTMATCH) && c == '*' && *p == '(') /*)*/
return (extmatch (c, n, se, p, pe, flags)); {
char *newn;
/* We need to check whether or not the extended glob
pattern matches the remainder of the string.
If it does, we match the entire pattern. */
for (newn = n; newn < se; ++newn)
{
if (extmatch (c, newn, se, p, pe, flags) == 0)
return (0);
}
/* We didn't match the extended glob pattern, but
that's OK, since we can match 0 or more occurrences.
We need to skip the glob pattern and see if we
match the rest of the string. */
newn = patscan (p, pe, 0);
p = newn;
}
#endif #endif
if (p == pe) if (p == pe)
break; break;
@ -245,11 +274,24 @@ gmatch (string, se, pattern, pe, flags)
c1 = (unsigned char)((flags & FNM_NOESCAPE) == 0 && c == '\\') ? *p : c; c1 = (unsigned char)((flags & FNM_NOESCAPE) == 0 && c == '\\') ? *p : c;
c1 = FOLD (c1); c1 = FOLD (c1);
for (--p; n < se; ++n) for (--p; n < se; ++n)
/* Only call fnmatch if the first character indicates a {
possible match. */ /* Only call fnmatch if the first character indicates a
if ((c == '[' || FOLD (*n) == c1) && possible match. We can check the first character if
gmatch (n, se, p, pe, flags & ~FNM_PERIOD) == 0) we're not doing an extended glob match. */
return (0); if ((flags & FNM_EXTMATCH) == 0 && c != '[' && FOLD (*n) != c1)
continue;
/* If we're doing an extended glob match and the pattern is not
one of the extended glob patterns, we can check the first
character. */
if ((flags & FNM_EXTMATCH) && p[1] != '(' && /*)*/
strchr ("?*+@!", *p) == 0 && c != '[' && FOLD (*n) != c1)
continue;
/* Otherwise, we just recurse. */
if (gmatch (n, se, p, pe, flags & ~FNM_PERIOD) == 0)
return (0);
}
return FNM_NOMATCH; return FNM_NOMATCH;
} }

View file

@ -19,6 +19,8 @@ Cambridge, MA 02139, USA. */
#ifndef _FNMATCH_H #ifndef _FNMATCH_H
#define _FNMATCH_H 1 #define _FNMATCH_H 1
#include "stdc.h"
/* We #undef these before defining them because some losing systems /* We #undef these before defining them because some losing systems
(HP-UX A.08.07 for example) define these in <unistd.h>. */ (HP-UX A.08.07 for example) define these in <unistd.h>. */
#undef FNM_PATHNAME #undef FNM_PATHNAME
@ -41,6 +43,6 @@ Cambridge, MA 02139, USA. */
/* Match STRING against the filename pattern PATTERN, /* Match STRING against the filename pattern PATTERN,
returning zero if it matches, FNM_NOMATCH if not. */ returning zero if it matches, FNM_NOMATCH if not. */
extern int fnmatch(); extern int fnmatch __P((char *, char *, int));
#endif /* _FNMATCH_H */ #endif /* _FNMATCH_H */

View file

@ -75,9 +75,9 @@
# define REAL_DIR_ENTRY(dp) (dp->d_ino != 0) # define REAL_DIR_ENTRY(dp) (dp->d_ino != 0)
#endif /* _POSIX_SOURCE */ #endif /* _POSIX_SOURCE */
#if !defined (HAVE_BCOPY) #if !defined (HAVE_BCOPY) && !defined (bcopy)
# define bcopy(s, d, n) ((void) memcpy ((d), (s), (n))) # define bcopy(s, d, n) ((void) memcpy ((d), (s), (n)))
#endif /* !HAVE_BCOPY */ #endif /* !HAVE_BCOPY && !bcopy */
#if defined (SHELL) #if defined (SHELL)
# include "posixstat.h" # include "posixstat.h"
@ -251,7 +251,7 @@ glob_vector (pat, dir)
register struct dirent *dp; register struct dirent *dp;
struct globval *lastlink; struct globval *lastlink;
register struct globval *nextlink; register struct globval *nextlink;
register char *nextname; register char *nextname, *npat;
unsigned int count; unsigned int count;
int lose, skip; int lose, skip;
register char **name_vector; register char **name_vector;
@ -297,32 +297,32 @@ glob_vector (pat, dir)
dirlen = strlen (dir); dirlen = strlen (dir);
nextname = (char *)malloc (dirlen + strlen (pat) + 2); nextname = (char *)malloc (dirlen + strlen (pat) + 2);
if (nextname == 0) npat = (char *)malloc (strlen (pat) + 1);
if (nextname == 0 || npat == 0)
lose = 1; lose = 1;
else else
{ {
strcpy (npat, pat);
dequote_pathname (npat);
strcpy (nextname, dir); strcpy (nextname, dir);
nextname[dirlen++] = '/'; nextname[dirlen++] = '/';
strcpy (nextname + dirlen, pat); strcpy (nextname + dirlen, npat);
if (GLOB_TESTNAME (nextname) >= 0) if (GLOB_TESTNAME (nextname) >= 0)
{ {
free (nextname); free (nextname);
nextlink = (struct globval *)alloca (sizeof (struct globval)); nextlink = (struct globval *)alloca (sizeof (struct globval));
nextlink->next = (struct globval *)0; nextlink->next = (struct globval *)0;
nextname = (char *) malloc (strlen (pat) + 1); lastlink = nextlink;
if (nextname == 0) nextlink->name = npat;
lose = 1; count = 1;
else
{
lastlink = nextlink;
nextlink->name = nextname;
strcpy (nextname, pat);
count = 1;
}
} }
else else
free (nextname); {
free (nextname);
free (npat);
}
} }
skip = 1; skip = 1;
@ -379,6 +379,16 @@ glob_vector (pat, dir)
if (REAL_DIR_ENTRY (dp) == 0) if (REAL_DIR_ENTRY (dp) == 0)
continue; continue;
/* If a leading dot need not be explicitly matched, and the pattern
doesn't start with a `.', don't match `.' or `..' */
#define dname dp->d_name
if (noglob_dot_filenames == 0 && pat[0] != '.' &&
(pat[0] != '\\' || pat[1] != '.') &&
(dname[0] == '.' &&
(dname[1] == '\0' || (dname[1] == '.' && dname[2] == '\0'))))
#undef dname
continue;
/* If a dot must be explicity matched, check to see if they do. */ /* If a dot must be explicity matched, check to see if they do. */
if (noglob_dot_filenames && dp->d_name[0] == '.' && pat[0] != '.' && if (noglob_dot_filenames && dp->d_name[0] == '.' && pat[0] != '.' &&
(pat[0] != '\\' || pat[1] != '.')) (pat[0] != '\\' || pat[1] != '.'))

View file

@ -13,10 +13,13 @@ INSTALL_DATA = @INSTALL_DATA@
CC = @CC@ CC = @CC@
RANLIB = @RANLIB@ RANLIB = @RANLIB@
AR = @AR@ AR = @AR@
ARFLAGS = @ARFLAGS@
RM = rm -f RM = rm -f
CP = cp CP = cp
MV = mv MV = mv
SHELL = @MAKE_SHELL@
PROFILE_FLAGS = PROFILE_FLAGS =
CFLAGS = @CFLAGS@ CFLAGS = @CFLAGS@
@ -63,32 +66,32 @@ all: malloc
malloc: ${MALLOC_OBJS} malloc: ${MALLOC_OBJS}
${RM} libmalloc.a ${RM} libmalloc.a
${AR} cr libmalloc.a ${MALLOC_OBJS} ${AR} ${ARFLAGS} libmalloc.a ${MALLOC_OBJS}
-test -n "$(RANLIB)" && $(RANLIB) libmalloc.a -test -n "$(RANLIB)" && $(RANLIB) libmalloc.a
nmalloc: ${NMALLOC_OBJS} nmalloc: ${NMALLOC_OBJS}
${RM} libmalloc.a ${RM} libmalloc.a
${AR} cr libmalloc.a ${NMALLOC_OBJS} ${AR} ${ARFLAGS} libmalloc.a ${NMALLOC_OBJS}
-test -n "$(RANLIB)" && $(RANLIB) libmalloc.a -test -n "$(RANLIB)" && $(RANLIB) libmalloc.a
nmalloc2: ${NMALLOC2_OBJS} nmalloc2: ${NMALLOC2_OBJS}
${RM} libmalloc.a ${RM} libmalloc.a
${AR} cr libmalloc.a ${NMALLOC2_OBJS} ${AR} ${ARFLAGS} libmalloc.a ${NMALLOC2_OBJS}
-test -n "$(RANLIB)" && $(RANLIB) libmalloc.a -test -n "$(RANLIB)" && $(RANLIB) libmalloc.a
gmalloc: ${GMALLOC_OBJS} gmalloc: ${GMALLOC_OBJS}
${RM} libmalloc.a ${RM} libmalloc.a
${AR} cr libmalloc.a ${GMALLOC_OBJS} ${AR} ${ARFLAGS} libmalloc.a ${GMALLOC_OBJS}
-test -n "$(RANLIB)" && $(RANLIB) libmalloc.a -test -n "$(RANLIB)" && $(RANLIB) libmalloc.a
ngmalloc: ${NGMALLOC_OBJS} ngmalloc: ${NGMALLOC_OBJS}
${RM} libmalloc.a ${RM} libmalloc.a
${AR} cr libmalloc.a ${NGMALLOC_OBJS} ${AR} ${ARFLAGS} libmalloc.a ${NGMALLOC_OBJS}
-test -n "$(RANLIB)" && $(RANLIB) libmalloc.a -test -n "$(RANLIB)" && $(RANLIB) libmalloc.a
stubmalloc: ${STUB_OBJS} stubmalloc: ${STUB_OBJS}
${RM} libmalloc.a ${RM} libmalloc.a
${AR} cr libmalloc.a ${STUB_OBJS} ${AR} ${ARFLAGS} libmalloc.a ${STUB_OBJS}
-test -n "$(RANLIB)" && $(RANLIB) libmalloc.a -test -n "$(RANLIB)" && $(RANLIB) libmalloc.a
alloca.o: $(srcdir)/$(ALLOCA_SOURCE) alloca.o: $(srcdir)/$(ALLOCA_SOURCE)

View file

@ -184,7 +184,7 @@ struct bucket_stats {
enough room in the block for the new size. Range checking is always enough room in the block for the new size. Range checking is always
done. */ done. */
union mhead { union mhead {
double mh_align; bits64_t mh_align; /* 8 */
struct { struct {
char mi_alloc; /* ISALLOC or ISFREE */ /* 1 */ char mi_alloc; /* ISALLOC or ISFREE */ /* 1 */
char mi_index; /* index in nextf[] */ /* 1 */ char mi_index; /* index in nextf[] */ /* 1 */
@ -200,8 +200,8 @@ union mhead {
/* Access free-list pointer of a block. /* Access free-list pointer of a block.
It is stored at block + sizeof (char *). It is stored at block + sizeof (char *).
This is not a field in the mhead structure This is not a field in the minfo structure member of union mhead
because we want sizeof (struct mhead) because we want sizeof (union mhead)
to describe the overhead for when the block is in use, to describe the overhead for when the block is in use,
and we do not want the free-list pointer to count in that. */ and we do not want the free-list pointer to count in that. */
@ -490,6 +490,8 @@ morecore_done:
#else #else
# if defined (HAVE_POSIX_SIGNALS) # if defined (HAVE_POSIX_SIGNALS)
sigprocmask (SIG_SETMASK, &oset, (sigset_t *)NULL); sigprocmask (SIG_SETMASK, &oset, (sigset_t *)NULL);
# else
; /* nothing to do, but need a null statement before the brace */
# endif # endif
#endif /* HAVE_BSD_SIGNALS */ #endif /* HAVE_BSD_SIGNALS */
} }

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