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

This commit is contained in:
Jari Aalto 1997-06-05 14:59:13 +00:00
parent ccc6cda312
commit d166f04881
304 changed files with 14702 additions and 13012 deletions

View File

@ -1 +0,0 @@
2.0

View File

@ -1 +0,0 @@
0

408
AUTHORS Normal file
View File

@ -0,0 +1,408 @@
#
# Master author manifest for bash
#
# Any files appearing in the bash distribution not listed in this file
# were created by Chet Ramey.
#
# Filename authors (first is original author)
#
README Brian Fox, Chet Ramey
INSTALL Brian Fox, Chet Ramey
COPYING Brian Fox, Chet Ramey
MANIFEST Brian Fox, Chet Ramey
configure Chet Ramey
Makefile.in Brian Fox, Chet Ramey
configure.in Chet Ramey
aclocal.m4 Chet Ramey
config.h.top Chet Ramey
config.h.bot Chet Ramey
config.h.in Chet Ramey
array.c Chet Ramey
print_cmd.c Brian Fox, Chet Ramey
general.c Brian Fox, Chet Ramey
variables.c Brian Fox, Chet Ramey
make_cmd.c Brian Fox, Chet Ramey
copy_cmd.c Brian Fox, Chet Ramey
unwind_prot.c Brian Fox, Chet Ramey
dispose_cmd.c Brian Fox, Chet Ramey
getcwd.c Roland McGrath, Brian Fox, Chet Ramey
bashhist.c Chet Ramey
hash.c Brian Fox, Chet Ramey
parse.y Brian Fox, Chet Ramey
subst.c Brian Fox, Chet Ramey
shell.c Brian Fox, Chet Ramey
sig.c Chet Ramey
trap.c Brian Fox, Chet Ramey
siglist.c Brian Fox, Chet Ramey
version.c Brian Fox, Chet Ramey
flags.c Brian Fox, Chet Ramey
jobs.c Brian Fox, Chet Ramey
input.c Chet Ramey
mailcheck.c Brian Fox, Chet Ramey
pathexp.c Chet Ramey
test.c Brian Fox, Chet Ramey
expr.c Chet Ramey, Brian Fox
alias.c Brian Fox, Chet Ramey
execute_cmd.c Brian Fox, Chet Ramey
bashline.c Brian Fox, Chet Ramey
braces.c Brian Fox, Chet Ramey
bracecomp.c Brian Fox, Chet Ramey, Tom Tromey
nojobs.c Brian Fox, Chet Ramey
vprint.c Chet Ramey
oslib.c Chet Ramey
error.c Brian Fox, Chet Ramey
xmalloc.c Brian Fox, Chet Ramey
alias.h Brian Fox, Chet Ramey
array.h Chet Ramey
builtins.h Brian Fox, Chet Ramey
parser.h Brian Fox, Chet Ramey
variables.h Brian Fox, Chet Ramey
machines.h Brian Fox, Chet Ramey
jobs.h Brian Fox, Chet Ramey
maxpath.h Brian Fox, Chet Ramey
pathexp.h Chet Ramey
mailcheck.h Chet Ramey
filecntl.h Brian Fox, Chet Ramey
hash.h Brian Fox, Chet Ramey
quit.h Brian Fox, Chet Ramey
flags.h Brian Fox, Chet Ramey
shell.h Brian Fox, Chet Ramey
bashjmp.h Chet Ramey
sig.h Chet Ramey
trap.h Brian Fox, Chet Ramey
general.h Brian Fox, Chet Ramey
unwind_prot.h Brian Fox, Chet Ramey
input.h Brian Fox, Chet Ramey
error.h Brian Fox, Chet Ramey
command.h Brian Fox, Chet Ramey
externs.h Chet Ramey
siglist.h Chet Ramey
subst.h Brian Fox, Chet Ramey
dispose_cmd.h Brian Fox, Chet Ramey
bashansi.h Brian Fox, Chet Ramey
make_cmd.h Brian Fox, Chet Ramey
bashhist.h Chet Ramey
bashline.h Chet Ramey
execute_cmd.h Chet Ramey
bashtypes.h Chet Ramey
bashtty.h Chet Ramey
pathnames.h Chet Ramey
y.tab.c Brian Fox, Chet Ramey
y.tab.h Brian Fox, Chet Ramey
parser-built Brian Fox, Chet Ramey
posixstat.h Brian Fox, Chet Ramey
stdc.h Chet Ramey
ansi_stdlib.h Brian Fox, Chet Ramey
memalloc.h Chet Ramey
builtins/ChangeLog Brian Fox, Chet Ramey
builtins/Makefile.in Brian Fox, Chet Ramey
builtins/alias.def Brian Fox, Chet Ramey
builtins/bind.def Brian Fox, Chet Ramey
builtins/break.def Brian Fox, Chet Ramey
builtins/builtin.def Brian Fox, Chet Ramey
builtins/cd.def Brian Fox, Chet Ramey
builtins/colon.def Brian Fox, Chet Ramey
builtins/command.def Brian Fox, Chet Ramey
builtins/common.c Brian Fox, Chet Ramey
builtins/declare.def Brian Fox, Chet Ramey
builtins/echo.def Brian Fox, Chet Ramey
builtins/enable.def Brian Fox, Chet Ramey
builtins/eval.def Brian Fox, Chet Ramey
builtins/exec.def Brian Fox, Chet Ramey
builtins/exit.def Brian Fox, Chet Ramey
builtins/fc.def Brian Fox, Chet Ramey
builtins/fg_bg.def Brian Fox, Chet Ramey
builtins/getopt.c Roland McGrath, Brian Fox, Chet Ramey
builtins/getopt.h Roland McGrath, Brian Fox, Chet Ramey
builtins/getopts.def Brian Fox, Chet Ramey
builtins/hash.def Brian Fox, Chet Ramey
builtins/hashcom.h Brian Fox, Chet Ramey
builtins/help.def Brian Fox, Chet Ramey
builtins/let.def Chet Ramey, Brian Fox
builtins/history.def Brian Fox, Chet Ramey
builtins/jobs.def Brian Fox, Chet Ramey
builtins/kill.def Brian Fox, Chet Ramey
builtins/mkbuiltins.c Brian Fox, Chet Ramey
builtins/pushd.def Brian Fox, Chet Ramey
builtins/read.def Brian Fox, Chet Ramey
builtins/reserved.def Brian Fox, Chet Ramey
builtins/return.def Brian Fox, Chet Ramey
builtins/set.def Brian Fox, Chet Ramey
builtins/setattr.def Brian Fox, Chet Ramey
builtins/shift.def Brian Fox, Chet Ramey
builtins/shopt.def Chet Ramey
builtins/source.def Brian Fox, Chet Ramey
builtins/suspend.def Brian Fox, Chet Ramey
builtins/test.def Brian Fox, Chet Ramey
builtins/times.def Brian Fox, Chet Ramey
builtins/trap.def Brian Fox, Chet Ramey
builtins/type.def Brian Fox, Chet Ramey
builtins/ulimit.def Chet Ramey, Brian Fox
builtins/umask.def Brian Fox, Chet Ramey
builtins/wait.def Brian Fox, Chet Ramey
builtins/psize.c Chet Ramey, Brian Fox
builtins/psize.sh Chet Ramey, Brian Fox
builtins/inlib.def Chet Ramey
builtins/bashgetopt.c Chet Ramey
builtins/common.h Chet Ramey
builtins/bashgetopt.h Chet Ramey
lib/doc-support/texindex.c bug-texinfo@prep.ai.mit.edu, Chet Ramey
lib/doc-support/Makefile.in Chet Ramey
lib/doc-support/getopt.h Roland McGrath
lib/doc-support/getopt.c Roland McGrath
lib/doc-support/getopt1.c Roland McGrath
lib/glob/ChangeLog Brian Fox, Chet Ramey
lib/glob/Makefile.in Brian Fox, Chet Ramey
lib/glob/fnmatch.c Roland McGrath, Brian Fox, Chet Ramey
lib/glob/fnmatch.h Roland McGrath, Brian Fox, Chet Ramey
lib/glob/glob.c Richard Stallman, Roland McGrath, Brian Fox, Chet Ramey
lib/glob/glob.h Chet Ramey
lib/glob/ndir.h Doug Gwyn, Richard Stallman
lib/glob/doc/Makefile.in Brian Fox, Chet Ramey
lib/glob/doc/glob.texi Brian Fox, Chet Ramey
lib/malloc/Makefile.in Chet Ramey
lib/malloc/alloca.c Doug Gwyn, Richard Stallman, Brian Fox, Chet Ramey
lib/malloc/getpagesize.h Brian Fox, Chet Ramey
lib/malloc/malloc.c Chris Kingsley, Mike Muuss, Richard Stallman, Brian Fox, Chet Ramey
lib/malloc/gmalloc.c Mike Haertel, Roland McGrath
lib/malloc/stub.c Chet Ramey
lib/malloc/i386-alloca.s Richard Stallman
lib/malloc/x386-alloca.s Chip Salzenberg, Richard Stallman
lib/malloc/xmalloc.c Brian Fox, Chet Ramey
lib/posixheaders/posixstat.h Brian Fox, Chet Ramey
lib/posixheaders/ansi_stdlib.h Brian Fox, Chet Ramey
lib/posixheaders/stdc.h Chet Ramey
lib/posixheaders/memalloc.h Chet Ramey
lib/posixheaders/filecntl.h Brian Fox, Chet Ramey
lib/readline/Makefile.in Brian Fox, Chet Ramey
lib/readline/COPYING Brian Fox, Chet Ramey
lib/readline/ChangeLog Brian Fox, Chet Ramey
lib/readline/readline.c Brian Fox, Chet Ramey
lib/readline/vi_mode.c Brian Fox, Chet Ramey
lib/readline/emacs_keymap.c Brian Fox, Chet Ramey
lib/readline/vi_keymap.c Brian Fox, Chet Ramey
lib/readline/funmap.c Brian Fox, Chet Ramey
lib/readline/keymaps.c Brian Fox, Chet Ramey
lib/readline/xmalloc.c Brian Fox, Chet Ramey
lib/readline/search.c Brian Fox, Chet Ramey
lib/readline/isearch.c Brian Fox, Chet Ramey
lib/readline/parens.c Brian Fox, Chet Ramey
lib/readline/rltty.c Brian Fox, Chet Ramey
lib/readline/complete.c Brian Fox, Chet Ramey
lib/readline/bind.c Brian Fox, Chet Ramey
lib/readline/display.c Brian Fox, Chet Ramey
lib/readline/signals.c Brian Fox, Chet Ramey
lib/readline/kill.c Brian Fox, Chet Ramey
lib/readline/undo.c Brian Fox, Chet Ramey
lib/readline/input.c Brian Fox, Chet Ramey
lib/readline/macro.c Brian Fox, Chet Ramey
lib/readline/util.c Brian Fox, Chet Ramey
lib/readline/callback.c Chet Ramey
lib/readline/readline.h Brian Fox, Chet Ramey
lib/readline/chardefs.h Brian Fox, Chet Ramey
lib/readline/keymaps.h Brian Fox, Chet Ramey
lib/readline/rldefs.h Brian Fox, Chet Ramey
lib/readline/posixstat.h Brian Fox, Chet Ramey
lib/readline/ansi_stdlib.h Brian Fox, Chet Ramey
lib/readline/memalloc.h Chet Ramey
lib/readline/rlconf.h Chet Ramey
lib/readline/rltty.h Chet Ramey
lib/readline/history.c Brian Fox, Chet Ramey
lib/readline/histexpand.c Brian Fox, Chet Ramey
lib/readline/histfile.c Brian Fox, Chet Ramey
lib/readline/histsearch.c Brian Fox, Chet Ramey
lib/readline/history.h Brian Fox, Chet Ramey
lib/readline/histlib.h Brian Fox, Chet Ramey
lib/readline/tilde.c Brian Fox, Chet Ramey
lib/readline/tilde.h Brian Fox, Chet Ramey
lib/readline/doc/texindex.c bug-texinfo@prep.ai.mit.edu, Chet Ramey
lib/readline/doc/Makefile Brian Fox, Chet Ramey
lib/readline/doc/rlman.texinfo Brian Fox, Chet Ramey
lib/readline/doc/rltech.texinfo Brian Fox, Chet Ramey
lib/readline/doc/rluser.texinfo Brian Fox, Chet Ramey
lib/readline/doc/hist.texinfo Brian Fox, Chet Ramey
lib/readline/doc/hstech.texinfo Brian Fox, Chet Ramey
lib/readline/doc/hsuser.texinfo Brian Fox, Chet Ramey
lib/readline/examples/Makefile Brian Fox
lib/readline/examples/fileman.c Brian Fox
lib/readline/examples/manexamp.c Brian Fox
lib/readline/examples/histexamp.c Brian Fox, Chet Ramey
lib/readline/examples/rltest.c Brian Fox, Chet Ramey
lib/readline/examples/Inputrc Brian Fox, Chet Ramey
lib/termcap/Makefile.in David MacKenzie, Chet Ramey
lib/termcap/termcap.c David MacKenzie
lib/termcap/termcap.h David MacKenzie
lib/termcap/tparam.c David MacKenzie
lib/termcap/version.c David MacKenzie
lib/termcap/grot/termcap.info David MacKenzie
lib/termcap/grot/termcap.info-1 David MacKenzie
lib/termcap/grot/termcap.info-2 David MacKenzie
lib/termcap/grot/termcap.info-3 David MacKenzie
lib/termcap/grot/termcap.info-4 David MacKenzie
lib/termcap/grot/NEWS David MacKenzie
lib/termcap/grot/INSTALL David MacKenzie
lib/termcap/grot/ChangeLog David MacKenzie
lib/termcap/grot/texinfo.tex David MacKenzie
lib/termcap/grot/termcap.texi David MacKenzie
lib/termcap/grot/Makefile.in David MacKenzie
lib/termcap/grot/configure David MacKenzie
lib/termcap/grot/configure.in David MacKenzie
lib/termcap/grot/COPYING David MacKenzie
lib/termcap/grot/README David MacKenzie
lib/tilde/ChangeLog Brian Fox, Chet Ramey
lib/tilde/Makefile.in Brian Fox, Chet Ramey
lib/tilde/doc/tilde.texi Brian Fox, Chet Ramey
lib/tilde/doc/Makefile Brian Fox, Chet Ramey
lib/tilde/tilde.c Brian Fox, Chet Ramey
lib/tilde/tilde.h Brian Fox, Chet Ramey
lib/tilde/memalloc.h Brian Fox, Chet Ramey
CWRU/misc/open-files.c Chet Ramey
CWRU/misc/sigs.c Chet Ramey
CWRU/misc/pid.c Chet Ramey
CWRU/misc/sigstat.c Chet Ramey
CWRU/misc/bison Chet Ramey
CWRU/misc/aux-machine-desc Chet Ramey
CWRU/PLATFORMS Chet Ramey
CWRU/README Chet Ramey
CWRU/CWRU.CHANGES.051093 Chet Ramey
CWRU/POSIX.NOTES Chet Ramey
CWRU/CWRU.CHANGES.071193 Chet Ramey
CWRU/CWRU.CHANGES.090393 Chet Ramey
doc/Makefile.in Brian Fox, Chet Ramey
doc/bash.1 Chet Ramey
doc/builtins.1 Chet Ramey
doc/bash.ps Chet Ramey
doc/bash.txt Chet Ramey
doc/readline.3 Chet Ramey
doc/readline.ps Chet Ramey
doc/readline.txt Chet Ramey
doc/texinfo.tex Richard Stallman
doc/features.texi Brian Fox, Chet Ramey
doc/features.ps Brian Fox, Chet Ramey
doc/features.info Brian Fox, Chet Ramey
doc/features.dvi Brian Fox, Chet Ramey
doc/bash_builtins.1 Chet Ramey
doc/bash_builtins.ps Chet Ramey
doc/bash_builtins.txt Chet Ramey
doc/bash_builtins.readme Chet Ramey
doc/article.ms Chet Ramey
doc/FAQ Chet Ramey
support/cat-s Brian Fox, Chet Ramey
support/mksysdefs Brian Fox, Chet Ramey
support/mkversion.c Brian Fox, Chet Ramey
support/mksignames.c Brian Fox, Chet Ramey
support/getcppsyms.c Brian Fox, Chet Ramey
support/cppmagic Brian Fox, Chet Ramey
support/pagesize.sh Chet Ramey, Brian Fox
support/pagesize.c Chet Ramey, Brian Fox
support/bash.xbm Brian Fox
support/FAQ Brian Fox
support/PORTING Brian Fox
support/mklinks Brian Fox
support/fixlinks Chet Ramey
support/mkdirs Chet Ramey
support/clone-bash Chet Ramey
support/bashbug.sh Chet Ramey
support/mkmachtype Chet Ramey
support/recho.c Chet Ramey
support/config.guess Per Bothner, Chet Ramey
support/config.sub Richard Stallman, Chet Ramey
support/install.sh MIT X Consortium (X11R5)
support/endian.c Chet Ramey
support/printenv Chet Ramey
examples/precedence-tester Brian Fox, Chet Ramey
examples/functions/substr Brian Fox, Chet Ramey
examples/functions/kshenv Chet Ramey
examples/functions/autoload Chet Ramey
examples/functions/csh-compat Brian Fox, Chet Ramey
examples/functions/shcat Chet Ramey
examples/functions/substr2 Chet Ramey
examples/functions/term Chet Ramey
examples/functions/whatis Chet Ramey
examples/functions/whence Chet Ramey
examples/functions/func Chet Ramey
examples/functions/dirname Brian Fox, Noah Friedman
examples/functions/basename Brian Fox, Noah Friedman
examples/functions/exitstat Noah Friedman, Roland McGrath
examples/functions/external Noah Friedman
examples/functions/fact Brian Fox
examples/functions/manpage Tom Tromey
examples/functions/fstty Chet Ramey
examples/functions/jj.bash Chet Ramey
examples/functions/notify.bash Chet Ramey
examples/scripts/shprompt Chet Ramey
examples/scripts/adventure.sh Chet Ramey, Doug Gwyn
examples/scripts/bcsh.sh Chris Robertson, Chet Ramey
examples/startup-files/Bashrc Brian Fox
examples/startup-files/Bash_aliases Brian Fox
examples/startup-files/Bash_profile Brian Fox
examples/startup-files/bash-profile Brian Fox
examples/startup-files/bashrc Chet Ramey
examples/suncmd.termcap Brian Fox, Chet Ramey
examples/alias-conv.sh Brian Fox, Chet Ramey
tests/README Chet Ramey
tests/arith.tests Chet Ramey
tests/arith.right Chet Ramey
tests/array.tests Chet Ramey
tests/array.right Chet Ramey
tests/dollar-at.sh Chet Ramey
tests/dollar-star.sh Chet Ramey
tests/dollar.right Chet Ramey
tests/exp-tests Chet Ramey
tests/exp.right Chet Ramey
tests/glob-test Chet Ramey
tests/glob.right Chet Ramey
tests/ifs-test-1.sh Chet Ramey
tests/ifs-test-2.sh Chet Ramey
tests/ifs-test-3.sh Chet Ramey
tests/ifs.1.right Chet Ramey
tests/ifs.2.right Chet Ramey
tests/ifs.3.right Chet Ramey
tests/input-line.sh Chet Ramey
tests/input-line.sub Chet Ramey
tests/input.right Chet Ramey
tests/minus-e Chet Ramey
tests/minus-e.right Chet Ramey
tests/new-exp.tests Chet Ramey
tests/new-exp.right Chet Ramey
tests/prec.right Chet Ramey
tests/precedence Chet Ramey
tests/run-all Chet Ramey
tests/run-dollars Chet Ramey
tests/run-exp-tests Chet Ramey
tests/run-glob-test Chet Ramey
tests/run-ifs-tests Chet Ramey
tests/run-input-test Chet Ramey
tests/run-minus-e Chet Ramey
tests/run-new-exp Chet Ramey
tests/run-precedence Chet Ramey
tests/run-set-e-test Chet Ramey
tests/run-strip Chet Ramey
tests/run-varenv Chet Ramey
tests/set-e-test Chet Ramey
tests/set-e.right Chet Ramey
tests/strip.tests Chet Ramey
tests/strip.right Chet Ramey
tests/tilde-tests Chet Ramey
tests/tilde.right Chet Ramey
tests/varenv.right Chet Ramey
tests/varenv.sh Chet Ramey
tests/misc/chld-trap.sh Chet Ramey
tests/misc/dot-test-1.sh Chet Ramey
tests/misc/dot-test-1.sub Chet Ramey
tests/misc/gotest Chet Ramey
tests/misc/perf-script Chet Ramey
tests/misc/redir.t1.sh Chet Ramey
tests/misc/redir.t2.sh Chet Ramey
tests/misc/redir.t3.sh Chet Ramey
tests/misc/redir.t3.sub Chet Ramey
tests/misc/redir.t4.sh Chet Ramey
tests/misc/run.r1.sh Chet Ramey
tests/misc/run.r2.sh Chet Ramey
tests/misc/run.r3.sh Chet Ramey
tests/misc/sigint.t1.sh Chet Ramey
tests/misc/sigint.t2.sh Chet Ramey
tests/misc/sigint.t3.sh Chet Ramey
tests/misc/sigint.t4.sh Chet Ramey
tests/misc/test-minus-e.1 Chet Ramey
tests/misc/test-minus-e.2 Chet Ramey

398
CHANGES
View File

@ -1,3 +1,401 @@
This document details the changes between this version, bash-2.01-release,
and the previous version, bash-2.01-beta2.
1. Changes to Bash
a. The `distclean' target should remove the `printenv' executable if it
has been created.
b. The test suite was changed slightly to ensure that the error messages
are printed in English.
c. A bug that caused the shell to dump core when a filename containing a
`/' was passed to `hash' was fixed.
d. Pathname canonicalization now leaves a leading `//' intact, as POSIX.1
requires.
e. A memory leak when completing commands was fixed.
f. A memory leak that occurred when checking the hash table for commands
with relative paths was fixed.
------------------------------------------------------------------------------
This document details the changes between this version, bash-2.01-beta2,
and the previous version, bash-2.01-beta1.
1. Changes to Bash
a. The `ulimit' builtin translates RLIM_INFINITY to the hard limit only if
the current (soft) limit is less than or equal to the hard limit.
b. Fixed a bug that caused the bash emulation of strcasecmp to produce
incorrect results.
c. A bug that caused memory to be freed twice when a trap handler resets
the trap more than once was fixed.
d. A bug that caused machines where sizeof (pointer) > sizeof (int) to
fail (and possibly dump core) when trying to unwind-protect a null
pointer was fixed.
e. The startup files should not be run with job control enabled. This fix
allows SIGINT to once again interrupt startup file execution.
f. Bash should not change the SIGPROF handler if it is set to something
other than SIG_DFL.
g. The completion code that provides bash-specific completions for readline
now quotes characters that the readline code would treat as word break
characters if they appear in a file name.
h. The completion code now correctly quotes filenames containing a `!',
even if the user attempted to use double quotes when attempting
completion.
i. A bug that caused the shell to dump core when `disown' was called without
arguments and there was no current job was fixed.
j. A construct like $((foo);bar) is now processed as a command substitution
rather than as a bad arithmetic substitution.
k. A couple of bugs that caused `fc' to not obey the `cmdhist' and `lithist'
shell options when editing and re-executing a series of commands were
fixed.
l. A fix was made to the grammar -- the list of commands between `do' and
`done' in the body of a `for' command should be treated the same as a
while loop.
2. Changes to Readline
a. A couple of bugs that caused the history search functions to attempt to
free a NULL pointer were fixed.
b. If the C library provides setlocale(3), readline does not need to look
at various environment variables to decide whether or not to go into
eight-bit mode automatically -- just check whether the current locale
is not `C' or `POSIX'.
c. If the filename completion function finds that a directory was not closed
by a previous (interrupted) completion, it closes the directory with
closedir().
3. New Features in Bash
a. New bindable readline commands: history-and-alias-expand-line and
alias-expand-line. The code was always in there, there was just no
way to execute it.
------------------------------------------------------------------------------
This document details the changes between this version, bash-2.01-beta1,
and the previous version, bash-2.01-alpha1.
1. Changes to Bash
a. Fixed a problem that could cause file descriptors used for process
substitution to conflict with those used explicitly in redirections.
b. Made it easier to regenerate configure if the user changes configure.in.
c. ${GROUPS[0]} should always be the primary group, even on systems without
multiple groups.
d. Spelling correction is no longer enabled by default.
e. Fixes to quoting problems in `bashbug'.
f. OS-specific configuration changes were made for: Irix 6.
g. OS-specific code changes were made for: QNX.
h. A more meaningful message is now printed when the file in /tmp for a
here document cannot be created.
i. Many changes to the shell's variable initialization code to speed
non-interactive startup.
j. Changes to the non-job-control code so that it does not try to open
/dev/tty.
k. The output of `set' and `export' is once again sorted, as POSIX wants.
l. Fixed a problem caused by a recursive call reparsing the value of
$SHELLOPTS.
m. The tilde code no longer calls getenv() when it's compiled as part of
the shell, which should eliminate problems on systems that cannot
redefine getenv(), like the NeXT OS.
n. Fixed a problem that caused `bash -o' or `bash +o' to not list all
the shell options.
o. Fixed `ulimit' to convert RLIM_INFINITY to the appropriate hard limit
only if the hard limit is greater than the current (soft) limit.
p. Fixed a problem that arose when building bash in a different directory
than the source and y.tab.[ch] were remade with something other than
bison. This came up most often on NetBSD.
q. Fixed a problem with completion -- it thought that `pwd`/[TAB] indicated
an unfinished command completion (`/), which generated errors.
r. The bash special tilde expansions (~-, ~+) are now attempted before
calling the standard tilde expansion code, which should eliminate the
problems people have been seeing with this on Solaris 2.5.1.
s. Added support for <stdarg.h> to places where it was missing.
t. Changed the code that reads the output of a command substitution to not
go through stdio. This reduces the memory requirements and is faster.
u. A number of changes to speed up export environment creation were made.
v. A number of memory leaks were fixed as the result of running the test
scripts through Purify.
w. Fixed a bug that caused subshells forked to interpret executable
scripts without a leading `#!' to not reinitialize the values of
the shell options.
2. Changes to Readline
a. History library has less `#ifdef SHELL' code -- abstracted stuff out
into application-specific function hooks.
b. Readline no longer calls getenv() if it's compiled as part of the shell,
which should eliminate problems on systems that cannot redefine getenv(),
like the NeXT OS.
c. Fixed translation of ESC when `untranslating' macro values.
d. The region kill operation now fixes the mark if it ends up beyond the
boundaries of the line after the region is deleted.
3. New Features in Bash
a. New argument for `configure': `--with-curses'. This can be used to
override the selection of the termcap library on systems where it is
deficient.
------------------------------------------------------------------------------
This document details the changes between this version, bash-2.01-alpha1,
and the previous version, bash-2.0-release.
1. Changes to Bash
a. System-specific configuration changes for: FreeBSD, SunOS4, Irix,
MachTen, QNX 4.2, Harris Night Hawk, SunOS5.
b. System-specific code changes were made for: Linux, 4.4 BSD, QNX 4.2,
HP-UX, AIX 4.2.
c. A bug that caused the exec builtin to fail because the full pathname of
the command could not be found was fixed.
d. The code that performs output redirections is now more resistant to
race conditions and possible security exploits.
e. A bug that caused the shell to dump core when performing pattern
substitutions on variable values was fixed.
f. More hosts are now recognized by the auto-configuration mechanism
(OpenBSD, QNX, others).
g. Assignments to read-only variables that attempt to convert them to
arrays are now errors.
h. A bug that caused shell scripts using array assignments in POSIX mode
to exit after the assignment was performed was fixed.
i. The substring expansion code is now more careful about running off the
ends of the expanded variable value.
j. A bug that caused completion to fail if a backquoted command substitution
appeared anywhere on the line was fixed.
k. The `source' builtin no longer turns off history if it has been enabled
in a non-interactive shell.
l. A bug that caused the shell to crash when `disown' was given a pid
instead of a job number was fixed.
m. The `cd' spelling correction code will not try to change to `.' if no
directory entries match a single-character argument.
n. A bad variable name supplied to `declare', `export', or `readonly' no
longer causes a non-interactive shell in POSIX mode to exit.
o. Some fixes were made to the test suite to handle peculiarities of
various Unix versions.
p. The bash completion code now quotes characters that readline would
treat as word breaks for completion but are not shell metacharacters.
q. Bad options supplied at invocation now cause a usage message to be
displayed.
r. Fixes were made to the code that handles DEBUG traps so that the trap
string is not freed inappropriately.
s. Some changes were made to the bash debugger in examples/bashdb -- it
should be closer to working now.
t. A problem that caused the default filename used for mail checking to be
wrong was fixed.
u. A fix was made to the `echo' builtin so that NUL characters printed with
`echo -e' do not cause the output to be truncated.
v. A fix was made to the job control code so that the shell behaves better
when monitor mode is enabled in a non-interactive shell.
w. Bash no longer catches all of the terminating signals in a non-
interactive shell until a trap is set on EXIT, which should result in
quicker startup.
x. A fix was made to the command timing code so that `time' can be used in
a loop.
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
command.
z. A fix was made to the globbing code so that it correctly matches quoted
filenames beginning with a `.'.
aa. A bug in `fc' that caused some multi-line commands to not be stored as
one command in the history when they were re-executed after editing
(with `fc -e') was fixed.
bb. The `ulimit' builtin now attempts to catch some classes of integer
overflows.
cc. The command-oriented-history code no longer attempts to add `;'
inappropriately when a newline appears while reading a $(...) command
substitution.
dd. A bug that caused the shell to dump core when `help --' was executed
was fixed.
ee. A bug that caused the shell to crash when an unset variable appeared
in the body of a here document after `set -u' had been executed was
fixed.
ff. Implicit input redirections from /dev/null for asynchronous commands
are now handled better.
gg. A bug that caused the shell to fail to compile when configured with
`--disable-readline' was fixed.
hh. The globbing code should now be interruptible.
ii. Bash now notices when the `kill' builtin is used to send SIGCONT to a
stopped job and adjusts the data structures accordingly, as if `bg' had
been executed instead.
jj. A bug that caused the shell to crash when mixing calls to `getopts'
and `shift' on the same set of positional parameters was fixed.
kk. The command printing code now preserves the `-p' flag to `time'.
ll. The command printing code now handles here documents better when there
are other redirections associated with the command.
mm. The special glibc environment variable (NNN_GNU_nonoption_argv_flags_)
is no longer placed into the environment of executed commands -- users
of glibc had too many problems with it.
nn. Reorganized the code that generates signames.h. The signal_names list
is now more complete but may be slightly different (SIGABRT is favored
over SIGIOT, for example). The preferred signal names are those
listed in the POSIX.2 standard.
oo. `bashbug' now uses a filename shorter than 14 characters for its
temporary file, and asks for confirmation before sending the bug
report.
pp. A bug that caused TAB completion in vi editing mode to not be turned
off when `set -o posix' was executed or back on when `set +o posix'
was executed was fixed.
qq. A bug in the brace expansion code that caused brace expansions appearing
in new-style $(...) command substitutions to be inappropriately expanded
was fixed.
rr. A bug in the readline hook shell-expand-line that could cause memory to
be inappropriately freed was fixed.
ss. A bug that caused some arithmetic expressions containing `&&' and `||'
to be parsed with the wrong precedence has been fixed.
tt. References to unbound variables after `set -u' has been executed now
cause the shell to exit immediately, as they should.
uu. A bug that caused the shell to exit inappropriately when `set -e' had
been executed and a command's return status was being inverted with the
`!' reserved word was fixed.
vv. A bug that could occasionally cause the shell to crash with a
divide-by-zero error when timing a command was fixed.
ww. A bug that caused parameter pattern substitution to leave stray
backslashes in the replacement string when the expression is in
double quotes was fixed.
xx. The `break' and `continue' builtins now break out of all loops when an
invalid count argument is supplied.
yy. Fixed a bug that caused PATH to be set to the empty string if
`command -p' is executed with PATH unset.
zz. Fixed `kill -l signum' to print the signal name without the `SIG' prefix,
as POSIX specifies.
aaa. Fixed a bug that caused the shell to crash while setting $SHELLOPTS
if there were no shell options set.
bbb. Fixed `export -p' and `readonly -p' so that when the shell is in POSIX
mode, their output is as POSIX.2 specifies.
ccc. Fixed a bug in `readonly' so that `readonly -a avar=(...)' actually
creates an array variable.
ddd. Fixed a bug that prevented `time' from correctly timing background
pipelines.
2. Changes to Readline
a. A bug that caused an extra newline to be printed when the cursor was on
an otherwise empty line was fixed.
b. An instance of memory being used after it was freed was corrected.
c. The redisplay code now works when the prompt is longer than the screen
width.
d. `dump-macros' is now a bindable name, as it should have been all along.
e. Non-printable characters are now expanded when displaying macros and
their values.
f. The `dump-variables' and `dump-macros' commands now output a leading
newline if they're called as the result of a key sequence, rather
than directly by an application.
3. New Features in Bash
a. There is a new builtin array variable: GROUPS, the set of groups to which
the user belongs. This is used by the test suite.
4. New Features in Readline
a. If a key sequence bound to `universal-argument' is read while reading a
numeric argument started with `universal-argument', it terminates the
argument but is otherwise ignored. This provides a way to insert multiple
instances of a digit string, and is how GNU emacs does it.
------------------------------------------------------------------------------
This document details the changes between this version, bash-2.0-release,
and the previous version, bash-2.0-beta3.

39
COMPAT
View File

@ -1,7 +1,7 @@
This document details the incompatibilites between this version of bash,
bash-2.0, and the previous version, bash-1.14. These were discovered
by alpha and beta testers, so they will likely be encountered by a
significant number of users.
bash-2.01, and the previous widely-available version, bash-1.14. These
were discovered by alpha and beta testers, so they will likely be
encountered by a significant number of users.
1. Bash now uses a new quoting syntax, $"...", to do locale-specific
string translation. Users who have relied on the (undocumented)
@ -71,8 +71,33 @@ significant number of users.
command_oriented_history, glob_dot_filenames, allow_null_glob_expansion,
nolinks, hostname_completion_file, noclobber, no_exit_on_failed_exec, and
cdable_vars. Most of them are now implemented with the new `shopt'
builtin; others were already implemented by `set'.
builtin; others were already implemented by `set'. Here is a list of
correspondences:
MAIL_WARNING shopt mailwarn
notify set -o notify
history_control HISTCONTROL
command_oriented_history shopt cmdhist
glob_dot_filenames shopt dotglob
allow_null_glob_expansion shopt nullglob
nolinks set -o physical
hostname_completion_file HOSTFILE
noclobber set -o noclobber
no_exit_on_failed_exec shopt execfail
cdable_vars shopt cdable_vars
8. `ulimit' now sets both hard and soft limits and reports the soft limit
by default (when neither -H nor -S is specified). This is compatible
with versions of sh and ksh that implement `ulimit'. The bash-1.14
behavior of, for example,
ulimit -c 0
can be obtained with
ulimit -S -c 0
It may be useful to define an alias:
alias ulimit="ulimit -S"
8. The `ulimit' builtins now sets both hard and soft limits and reports the
soft limit by default (when neither -H nor -S is specified). This is
compatible with versions of sh and ksh that implement `ulimit'.

View File

@ -6,10 +6,13 @@ By chet:
SunOS 4.1.4
SunOS 5.5
BSDI BSD/OS 2.1
Motorola SVR3.2
FreeBSD 2.1.5
FreeBSD 2.1.7
NetBSD 1.2
AIX 4.2
AIX 4.1.4
HP/UX 9.05, 10.01, 10.10, 10.20
Linux 2.0.29 (libc 5.3.12)
Linux 2.0.4 (libc 5.3.12)
By other testers:

View File

@ -77,6 +77,9 @@ The following list is what's changed when `POSIX mode' is in effect:
20. Assignment statements preceding POSIX.2 `special' builtins persist
in the shell environment after the builtin completes.
21. The `export' and `readonly' builtin commands display their output
in the format required by POSIX.2.
There is other POSIX.2 behavior that Bash does not implement.
Specifically:

File diff suppressed because it is too large Load Diff

114
INSTALL
View File

@ -1,7 +1,7 @@
Basic Installation
==================
These are generic installation instructions for Bash.
These are installation instructions for Bash.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
@ -24,7 +24,15 @@ they can be considered for the next release.
The file `configure.in' is used to create `configure' by a program
called Autoconf. You only need `configure.in' if you want to change it
or regenerate `configure' using a newer version of Autoconf. If you do
this, make sure you are using Autoconf version 2.9 or newer.
this, make sure you are using Autoconf version 2.10 or newer.
If you need to change `configure.in' or regenerate `configure', you
will need to create two files: `_distribution' and `_patchlevel'.
`_distribution' should contain the major and minor version numbers of
the Bash distribution, for example `2.01'. `_patchlevel' should
contain the patch level of the Bash distribution, `0' for example. The
script `support/mkconffiles' has been provided to automate the creation
of these files.
The simplest way to compile Bash is:
@ -179,21 +187,27 @@ configure Bash without a feature that is enabled by default, use
Here is a complete list of the `--enable-' and `--with-' options that
the Bash `configure' recognizes.
`--with-gnu-malloc'
Use the GNU version of `malloc' in `lib/malloc/malloc.c'. This is
not the same `malloc' that appears in GNU libc, but an older
version derived from the 4.2 BSD `malloc'. This `malloc' is very
fast, but wastes a lot of space. This option is enabled by
default. The `NOTES' file contains a list of systems for which
this should be turned off.
`--with-afs'
Define if you are using the Andrew File System from Transarc.
`--with-curses'
Use the curses library instead of the termcap library. This should
be supplied if your system has an inadequate or incomplete termcap
database.
`--with-glibc-malloc'
Use the GNU libc version of `malloc' in `lib/malloc/gmalloc.c'.
This is somewhat slower than the default `malloc', but wastes
considerably less space.
`--with-afs'
Define if you are using the Andrew File System from Transarc.
`--with-gnu-malloc'
Use the GNU version of `malloc' in `lib/malloc/malloc.c'. This is
not the same `malloc' that appears in GNU libc, but an older
version derived from the 4.2 BSD `malloc'. This `malloc' is very
fast, but wastes a lot of space. This option is enabled by
default. The `NOTES' file contains a list of systems for which
this should be turned off, and `configure' disables this option
automatically for a number of systems.
`--with-purify'
Define this to use the Purify memory allocation checker from Pure
@ -211,32 +225,48 @@ All of the following options except for `disabled-builtins' and
`usg-echo-default' are enabled by default, unless the operating system
does not provide the necessary support.
`--enable-job-control'
This enables job control features, if the OS supports them.
`--enable-alias'
Allow alias expansion and include the `alias' and `unalias'
builtins.
`--enable-readline'
Include support for command-line editing and history with the Bash
version of the Readline library.
`--enable-history'
Include command history and the `fc' and `history' builtin
commands.
`--enable-array-variables'
Include support for one-dimensional array shell variables.
`--enable-bang-history'
Include support for `csh'-like history substitution.
`--enable-brace-expansion'
Include `csh'-like brace expansion ( `b{a,b}c' ==> `bac bbc' ).
`--enable-command-timing'
Include support for recognizing `time' as a reserved word and for
displaying timing statistics for the pipeline following `time'.
This allows pipelines as well as shell builtins and functions to
be timed.
`--enable-directory-stack'
Include support for a `csh'-like directory stack and the `pushd',
`popd', and `dirs' builtins.
`--enable-restricted'
Include support for a "restricted shell". If this is enabled,
Bash, when called as `rbash', enters a restricted mode. See *Note
The Restricted Shell::, for a description of restricted mode.
`--enable-disabled-builtins'
Allow builtin commands to be invoked via `builtin xxx' even after
`xxx' has been disabled using `enable -n xxx'. See *Note Bash
Builtins::, for details of the `builtin' and `enable' builtin
commands.
`--enable-dparen-arithmetic'
Include support for the `ksh' `((...))' command.
`--enable-help-builtin'
Include the `help' builtin, which displays help on shell builtins
and variables.
`--enable-history'
Include command history and the `fc' and `history' builtin
commands.
`--enable-job-control'
This enables job control features, if the OS supports them.
`--enable-process-substitution'
This enables process substitution (*note Process Substitution::.)
@ -247,35 +277,19 @@ does not provide the necessary support.
characters in the `$PS1', `$PS2', `$PS3', and `$PS4' prompt
strings.
`--enable-readline'
Include support for command-line editing and history with the Bash
version of the Readline library.
`--enable-restricted'
Include support for a "restricted shell". If this is enabled,
Bash, when called as `rbash', enters a restricted mode. See *Note
The Restricted Shell::, for a description of restricted mode.
`--enable-select'
Include the `ksh' `select' builtin, which allows the generation of
simple menus.
`--enable-help-builtin'
Include the `help' builtin, which displays help on shell builtins
and variables.
`--enable-array-variables'
Include support for one-dimensional array shell variables.
`--enable-dparen-arithmetic'
Include support for the `ksh' `((...))' command.
`--enable-brace-expansion'
Include `csh'-like brace expansion ( `b{a,b}c' ==> `bac bbc' ).
`--enable-disabled-builtins'
Allow builtin commands to be invoked via `builtin xxx' even after
`xxx' has been disabled using `enable -n xxx'. See *Note Bash
Builtins::, for details of the `builtin' and `enable' builtin
commands.
`--enable-command-timing'
Include support for recognizing `time' as a reserved word and for
displaying timing statistics for the pipeline following `time'.
This allows pipelines as well as shell builtins and functions to
be timed.
`--enable-usg-echo-default'
Make the `echo' builtin expand backslash-escaped characters by
default, without requiring the `-e' option. This makes the Bash

104
MANIFEST
View File

@ -40,6 +40,7 @@ MANIFEST f
NEWS f
NOTES f
README f
AUTHORS f
configure.in f
configure f
Makefile.in f
@ -62,6 +63,7 @@ unwind_prot.c f
dispose_cmd.c f
getcwd.c f
bashhist.c f
hashcmd.c f
hashlib.c f
parse.y f
pathexp.c f
@ -112,10 +114,10 @@ externs.h f
siglist.h f
subst.h f
dispose_cmd.h f
hashcmd.h f
bashansi.h f
bashtty.h f
bashjmp.h f
bashwait.h f
bashintl.h f
make_cmd.h f
execute_cmd.h f
@ -125,7 +127,10 @@ pathnames.h f
y.tab.c f
y.tab.h f
posixdir.h f
posixjmp.h f
posixstat.h f
posixwait.h f
unionwait.h f
stdc.h f
ansi_stdlib.h f
memalloc.h f
@ -154,7 +159,6 @@ builtins/getopt.c f
builtins/getopt.h f
builtins/getopts.def f
builtins/hash.def f
builtins/hashcom.h f
builtins/help.def f
builtins/let.def f
builtins/history.def f
@ -203,6 +207,7 @@ lib/malloc/stub.c f
lib/malloc/i386-alloca.s f
lib/malloc/x386-alloca.s f
lib/posixheaders/posixdir.h f
lib/posixheaders/posixjmp.h f
lib/posixheaders/posixstat.h f
lib/posixheaders/ansi_stdlib.h f
lib/posixheaders/stdc.h f
@ -240,6 +245,7 @@ lib/readline/macro.c f
lib/readline/input.c f
lib/readline/callback.c f
lib/readline/nls.c f
lib/readline/shell.c f
lib/readline/tilde.c f
lib/readline/tilde.h f
lib/readline/rldefs.h f
@ -252,6 +258,7 @@ lib/readline/history.h f
lib/readline/histlib.h f
lib/readline/chardefs.h f
lib/readline/posixdir.h f
lib/readline/posixjmp.h f
lib/readline/posixstat.h f
lib/readline/ansi_stdlib.h f
lib/readline/doc/Makefile f
@ -266,6 +273,7 @@ lib/readline/examples/fileman.c f
lib/readline/examples/manexamp.c f
lib/readline/examples/histexamp.c f
lib/readline/examples/rltest.c f
lib/readline/examples/rl.c f
lib/readline/examples/Inputrc f
lib/termcap/Makefile.in f
lib/termcap/termcap.c f
@ -318,11 +326,13 @@ doc/builtins.1 f
doc/article.ms f
support/config.guess f
support/config.sub f
support/printenv f 755
support/printenv.sh f 755
support/printenv.c f
support/bash.xbm f
support/mkclone f 755
support/mkconffiles f 755
support/mkdirs f 755
support/mkversion.c f
support/mkversion.sh f 755
support/mksignames.c f
support/bashbug.sh f
support/recho.c f
@ -332,6 +342,7 @@ support/fixlinks f 755
support/install.sh f 755
support/texi2dvi f
support/texi2html f
support/xenix-link.sh f 755
examples/bashdb/PERMISSION f
examples/bashdb/README f
examples/bashdb/bashdb f
@ -386,6 +397,7 @@ examples/functions/seq f
examples/functions/mhfold f
examples/functions/repeat2 f
examples/functions/lowercase f
examples/functions/xalias.bash f
examples/scripts/shprompt f
examples/scripts/adventure.sh f
examples/scripts/precedence f
@ -393,7 +405,9 @@ examples/scripts/bcsh.sh f
examples/scripts/inpath f
examples/scripts/nohup.bash f
examples/scripts/vtree2 f
examples/scripts/vtree3 f
examples/scripts/scrollbar f
examples/scripts/spin.bash f
examples/scripts/zprintf f
examples/startup-files/README f
examples/startup-files/Bashrc f
@ -412,15 +426,48 @@ tests/array.tests f
tests/array.right f
tests/braces-tests f
tests/braces.right f
tests/builtins.tests f
tests/builtins.right f
tests/builtins.sub1 f
tests/source.sub1 f
tests/source.sub2 f
tests/source.sub3 f
tests/source.sub4 f
tests/dirstack.tests f
tests/dirstack.right f
tests/dollar-at.sh f
tests/dollar-star.sh f
tests/dollar.right f
tests/errors.tests f
tests/errors.right f
tests/execscript f
tests/execscript.right f
tests/execscript.sub f 755
tests/execscript.sub2 f
tests/execscript.sub3 f
tests/execscript.sub4 f
tests/exp-tests f
tests/exp.right f
tests/func.tests f
tests/func.right f
tests/getopts.tests f
tests/getopts.right f
tests/getopts.sub1 f
tests/getopts.sub2 f
tests/getopts.sub3 f
tests/getopts.sub4 f
tests/getopts.sub5 f
tests/getopts.sub6 f
tests/getopts.sub7 f
tests/glob-test f
tests/glob.right f
tests/heredoc.tests f
tests/heredoc.right f
tests/histexpand.tests f
tests/histexpand.right f
tests/history.tests f
tests/history.right f
tests/history.list f
tests/ifs-test-1.sh f
tests/ifs-test-2.sh f
tests/ifs-test-3.sh f
@ -430,11 +477,12 @@ tests/ifs.3.right f
tests/input-line.sh f
tests/input-line.sub f
tests/input.right f
tests/minus-e f
tests/minus-e.right f
tests/jobs.tests f
tests/jobs.right f
tests/more-exp.tests f
tests/more-exp.right f
tests/new-exp.tests f
tests/new-exp.sub1 f
tests/new-exp.right f
tests/nquote.tests f
tests/nquote.right f
@ -446,19 +494,39 @@ tests/quote.tests f
tests/quote.right f
tests/read.tests f
tests/read.right f
tests/redir.tests f
tests/redir.right f
tests/redir1.sub f
tests/redir2.sub f
tests/redir3.sub f
tests/redir3.in1 f
tests/redir3.in2 f
tests/redir4.sub f
tests/redir4.in1 f
tests/rhs-exp.tests f
tests/rhs-exp.right f
tests/rsh.tests f
tests/rsh.right f
tests/run-all f
tests/run-minimal f
tests/run-arith f
tests/run-array f
tests/run-braces f
tests/run-builtins f
tests/run-dirstack f
tests/run-dollars f
tests/run-errors f
tests/run-execscript f
tests/run-exp-tests f
tests/run-func f
tests/run-getopts f
tests/run-glob-test f
tests/run-heredoc f
tests/run-histexpand f
tests/run-history f
tests/run-ifs-tests f
tests/run-input-test f
tests/run-minus-e f
tests/run-jobs f
tests/run-more-exp f
tests/run-new-exp f
tests/run-nquote f
@ -466,11 +534,15 @@ tests/run-posix2 f
tests/run-precedence f
tests/run-quote f
tests/run-read f
tests/run-redir f
tests/run-rhs-exp f
tests/run-rsh f
tests/run-set-e-test f
tests/run-strip f
tests/run-test f
tests/run-tilde f
tests/run-trap f
tests/run-type f
tests/run-varenv f
tests/set-e-test f
tests/set-e.right f
@ -480,21 +552,19 @@ tests/test-tests f
tests/test.right f
tests/tilde-tests f
tests/tilde.right f
tests/trap.tests f
tests/trap.right f
tests/trap.sub1 f 755
tests/type.tests f
tests/type.right f
tests/varenv.right f
tests/varenv.sh f
tests/misc/chld-trap.sh f
tests/misc/dot-test-1.sh f
tests/misc/dot-test-1.sub f
tests/misc/gotest f
tests/version f
tests/version.mini f
tests/misc/haertel.perftest f
tests/misc/perf-script f
tests/misc/redir.t1.sh f
tests/misc/redir.t2.sh f
tests/misc/redir.t3.sh f
tests/misc/redir.t3.sub f
tests/misc/redir.t4.sh f
tests/misc/run.r1.sh f
tests/misc/run.r2.sh f
tests/misc/run.r3.sh f
tests/misc/sigint.t1.sh f
tests/misc/sigint.t2.sh f
tests/misc/sigint.t3.sh f

View File

@ -1,3 +1,5 @@
# Makefile for bash-2.01, version 2.32
#
# Make sure the first target in the makefile is the right one
all: .made
@ -39,6 +41,8 @@ INSTALL_DATA = @INSTALL_DATA@
COMPRESS = gzip
COMPRESS_EXT = .gz
TESTSCRIPT = @TESTSCRIPT@
#If you have purify, and want to use it, uncomment this definition or
# run the make as `make PURIFY=purify'
# or run configure with the --with-purify argument.
@ -50,31 +54,29 @@ PURIFY = @PURIFY@
$(RM) $@
$(CC) $(CCFLAGS) -c $<
# The name of this program.
# The name of this program and some version information.
Program = bash
Version = @BASHVERS@
PatchLevel = @BASHPATCH@
RELSTATUS = release
Machine = @host_cpu@
OS = @host_os@
MACHTYPE = @host@
RELSTATUS = release
THIS_SH = $(BUILD_DIR)/$(Program)
# PROFILE_FLAGS is either -pg, to generate profiling info for use
# with gprof, or nothing (the default).
PROFILE_FLAGS=
# set to alloca.o if we are using the C alloca in lib/malloc
ALLOCA = @ALLOCA@
ALLOCA_SOURCE = @ALLOCA_SOURCE@
ALLOCA_OBJECT = @ALLOCA_OBJECT@
# The GNU coding standards don't recognize the possibility that
# other information besides optimization and debugging might be
# passed to cc. A different name should have been used.
CFLAGS = @CFLAGS@
LOCAL_CFLAGS = @LOCAL_CFLAGS@
DEFS = @DEFS@
LOCAL_DEFS = @LOCAL_DEFS@
LOCAL_LIBS = @LOCAL_LIBS@
LIBS = $(BUILTINS_LIB) $(LIBRARIES) $(LOCAL_LIBS) @LIBS@
LDFLAGS = @LDFLAGS@ $(LOCAL_LDFLAGS) $(PROFILE_FLAGS) $(CFLAGS)
@ -82,7 +84,7 @@ LOCAL_LDFLAGS = @LOCAL_LDFLAGS@
SYSTEM_FLAGS = -DPROGRAM='"$(Program)"' -DHOSTTYPE='"$(Machine)"' -DOSTYPE='"$(OS)"' -DMACHTYPE='"$(MACHTYPE)"'
CCFLAGS = $(PROFILE_FLAGS) $(SYSTEM_FLAGS) -DSHELL \
CCFLAGS = $(PROFILE_FLAGS) $(SYSTEM_FLAGS) $(LOCAL_DEFS) \
$(DEFS) $(LOCAL_CFLAGS) $(CPPFLAGS) $(INCLUDES) $(CFLAGS)
INCLUDES = -I. -I$(srcdir) -I$(LIBSRC)
@ -132,6 +134,7 @@ READLINE_SOURCE = $(RL_LIBSRC)/rldefs.h $(RL_LIBSRC)/rlconf.h \
$(RL_LIBSRC)/undo.c $(RL_LIBSRC)/macro.c \
$(RL_LIBSRC)/terminal.c $(RL_LIBSRC)/nls.c \
$(RL_LIBSRC)/input.c $(RL_LIBSRC)/xmalloc.c \
$(RL_LIBSRC)/shell.c \
$(RL_LIBSRC)/histexpand.c $(RL_LIBSRC)/history.c \
$(RL_LIBSRC)/histsearch.c $(RL_LIBSRC)/histfile.c
@ -145,6 +148,7 @@ READLINE_OBJ = $(RL_LIBDIR)/readline.o $(RL_LIBDIR)/funmap.o \
$(RL_LIBDIR)/kill.o $(RL_LIBDIR)/undo.o $(RL_LIBDIR)/nls.o \
$(RL_LIBDIR)/macro.o $(RL_LIBDIR)/input.o \
$(RL_LIBDIR)/terminal.o $(RL_LIBDIR)/callback.o \
$(RL_LIBDIR)/shell.o \
$(RL_LIBDIR)/history.o $(RL_LIBDIR)/histexpand.o \
$(RL_LIBDIR)/histsearch.o $(RL_LIBDIR)/histfile.o
@ -160,9 +164,11 @@ HISTORY_DEP = @HISTORY_DEP@
# The source, object and documentation of the history library.
HISTORY_SOURCE = $(HIST_LIBSRC)/history.c $(HIST_LIBSRC)/histexpand.c \
$(HIST_LIBSRC)/histsearch.c $(HIST_LIBSRC)/histfile.c \
$(HIST_LIBSRC)/shell.c \
$(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/histlib.h
HISTORY_OBJ = $(HIST_LIBDIR)/history.o $(HIST_LIBDIR)/histexpand.o \
$(HIST_LIBDIR)/histsearch.o $(HIST_LIBDIR)/histfile.o
$(HIST_LIBDIR)/histsearch.o $(HIST_LIBDIR)/histfile.o \
$(HIST_LIBDIR)/shell.o
# You only need termcap (or curses) if you are linking with GNU Readline.
TERM_LIBSRC = $(LIBSRC)/termcap
@ -204,15 +210,18 @@ TILDE_SOURCE = $(TILDE_LIBSRC)/tilde.c $(TILDE_LIBSRC)/tilde.h
TILDE_OBJ = $(TILDE_LIBDIR)/tilde.o
# Our malloc.
MALLOC_TARGET = @MALLOC_TARGET@
# set to alloca.o if we are using the C alloca in lib/malloc
ALLOCA = @ALLOCA@
ALLOC_LIBSRC = $(LIBSRC)/malloc
ALLOC_LIBDIR = $(dot)/$(LIBSUBDIR)/malloc
ALLOC_ABSSRC = ${topdir}/$(ALLOC_LIBDIR)
ALLOCA_DEP = $(ALLOC_LIBDIR)/@ALLOCA@
MALLOC_OBJ = $(ALLOC_LIBDIR)/@MALLOC@
MALLOC_SRC = @MALLOC_SRC@
MALLOC_CFLAGS = -Drcheck -Dbotch=programming_error
MALLOC_SOURCE = ${ALLOC_LIBSRC}/${MALLOC_SRC}
MALLOC_CFLAGS = -DRCHECK -Dbotch=programming_error
MALLOC_LIB = -lmalloc
MALLOC_LIBRARY = $(ALLOC_LIBDIR)/libmalloc.a
@ -221,11 +230,10 @@ MALLOC_DEP = $(MALLOC_LIBRARY)
ALLOC_HEADERS = $(ALLOC_LIBSRC)/getpagesize.h
$(MALLOC_LIBRARY): $(MALLOC_SRC)
@$(RM) $@
$(MALLOC_LIBRARY): ${MALLOC_SOURCE}
@(cd $(ALLOC_LIBDIR) && \
$(MAKE) $(MFLAGS) \
MALLOC_CFLAGS="$(MALLOC_CFLAGS)" libmalloc.a ) || exit 1
MALLOC_CFLAGS="$(MALLOC_CFLAGS)" ${MALLOC_TARGET} ) || exit 1
BASHPOSIX_LIB = $(LIBSRC)/posixheaders
BASHPOSIX_SUPPORT = $(BASHPOSIX_LIB)/posixstat.h $(BASHPOSIX_LIB)/ansi_stdlib.h \
@ -247,18 +255,20 @@ LIBRARY_LDFLAGS = $(READLINE_LDFLAGS) $(HISTORY_LDFLAGS) $(TILDE_LDFLAGS) \
# The main source code for the Bourne Again SHell.
CSOURCES = shell.c eval.c parse.y general.c make_cmd.c print_cmd.c y.tab.c \
dispose_cmd.c execute_cmd.c variables.c $(GLOBC) version.c \
expr.c copy_cmd.c flags.c subst.c hashlib.c mailcheck.c \
test.c trap.c jobs.c nojobs.c $(ALLOC_FILES) braces.c \
expr.c copy_cmd.c flags.c subst.c hashcmd.c hashlib.c mailcheck.c \
test.c trap.c alias.c jobs.c nojobs.c $(ALLOC_FILES) braces.c \
vprint.c input.c bashhist.c array.c sig.c pathexp.c oslib.c \
unwind_prot.c siglist.c getcwd.c $(RL_SUPPORT_SRC) error.c \
unwind_prot.c siglist.c getcwd.c bashline.c bracecomp.c error.c \
list.c stringlib.c locale.c xmalloc.c
HSOURCES = shell.h flags.h trap.h hashlib.h jobs.h builtins.h alias.c y.tab.h \
HSOURCES = shell.h flags.h trap.h hashcmd.h hashlib.h jobs.h builtins.h \
general.h variables.h config.h $(ALLOC_HEADERS) alias.h maxpath.h \
quit.h posixstat.h filecntl.h unwind_prot.h \
quit.h posixdir.h posixstat.h filecntl.h unwind_prot.h ansi_stdlib.h \
command.h input.h error.h bashansi.h dispose_cmd.h make_cmd.h \
subst.h externs.h siglist.h bashhist.h bashline.h bashtypes.h \
array.h sig.h mailcheck.h bashtty.h
array.h sig.h mailcheck.h bashtty.h bashintl.h bashjmp.h ${GRAM_H} \
posixwait.h execute_cmd.h memalloc.h parser.h pathexp.h pathnames.h \
posixjmp.h stdc.h unionwait.h $(BASHPOSIX_SUPPORT)
SOURCES = $(CSOURCES) $(HSOURCES) $(BUILTIN_DEFS)
@ -268,8 +278,8 @@ JOBS_O = @JOBS_O@
# Matching object files.
OBJECTS = shell.o eval.o y.tab.o general.o make_cmd.o print_cmd.o $(GLOBO) \
dispose_cmd.o execute_cmd.o variables.o copy_cmd.o error.o \
expr.o flags.o $(JOBS_O) subst.o hashlib.o mailcheck.o test.o \
trap.o input.o unwind_prot.o pathexp.o sig.o version.o \
expr.o flags.o $(JOBS_O) subst.o hashcmd.o hashlib.o mailcheck.o \
trap.o input.o unwind_prot.o pathexp.o sig.o test.o version.o \
alias.o array.o braces.o bracecomp.o bashhist.o bashline.o \
getcwd.o siglist.o vprint.o oslib.o list.o stringlib.o \
locale.o xmalloc.o
@ -296,8 +306,7 @@ BUILTIN_DEFS = $(DEFSRC)/alias.def $(DEFSRC)/bind.def $(DEFSRC)/break.def \
$(DEFSRC)/pushd.def $(DEFSRC)/shopt.def
BUILTIN_C_SRC = $(DEFSRC)/mkbuiltins.c $(DEFSRC)/common.c \
$(DEFSRC)/evalstring.c $(DEFSRC)/evalfile.c \
$(DEFSRC)/bashgetopt.c $(GETOPT_SOURCE) \
$(DEFSRC)/hashcom.h
$(DEFSRC)/bashgetopt.c $(GETOPT_SOURCE)
BUILTIN_C_OBJ = $(DEFDIR)/common.o $(DEFDIR)/evalstring.o \
$(DEFDIR)/evalfile.o $(DEFDIR)/bashgetopt.o
BUILTIN_OBJS = $(DEFDIR)/alias.o $(DEFDIR)/bind.o $(DEFDIR)/break.o \
@ -317,22 +326,23 @@ BUILTIN_OBJS = $(DEFDIR)/alias.o $(DEFDIR)/bind.o $(DEFDIR)/break.o \
GETOPT_SOURCE = $(DEFSRC)/getopt.c $(DEFSRC)/getopt.h
PSIZE_SOURCE = $(DEFSRC)/psize.sh $(DEFSRC)/psize.c
BUILTINS_LIBRARY = builtins/libbuiltins.a
BUILTINS_LIBRARY = $(DEFDIR)/libbuiltins.a
BUILTINS_LIB = -lbuiltins
BUILTINS_LDFLAGS = -L$(DEFDIR)
BUILTINS_DEP = $(BUILTINS_LIBRARY)
# Documentation for the shell.
DOCSRC = $(srcdir)/doc
DOCDIR = ./doc
DOCDIR = $(dot)/doc
SIGNAMES_SUPPORT = $(SUPPORT_SRC)mksignames.c
SUPPORT_SRC = $(srcdir)/support/
SDIR = ./support/
SDIR = $(dot)/support/
CREATED_SUPPORT = signames.h recho zecho tests/recho tests/zecho \
tests/printenv mksignames mkversion
TESTS_SUPPORT = recho zecho printenv
CREATED_SUPPORT = signames.h recho zecho printenv tests/recho tests/zecho \
tests/printenv mksignames
CREATED_CONFIGURE = config.h config.cache config.status config.log \
stamp-h
CREATED_MAKEFILES = Makefile builtins/Makefile doc/Makefile \
@ -344,32 +354,28 @@ CREATED_MAKEFILES = Makefile builtins/Makefile doc/Makefile \
.NOEXPORT:
.made: $(Program) bashbug
cp .machine .made
@echo "$(Program) last made for a $(Machine) running $(OS)" >.made
$(Program): .build $(OBJECTS) $(BUILTINS_DEP) $(LIBDEP) $(srcdir)/.distribution
$(Program): .build $(OBJECTS) $(BUILTINS_DEP) $(LIBDEP)
$(RM) $@
$(PURIFY) $(CC) $(LDFLAGS) $(BUILTINS_LDFLAGS) $(LIBRARY_LDFLAGS) -o $(Program) $(OBJECTS) $(LIBS)
ls -l $(Program)
size $(Program)
.build: $(SOURCES) config.h Makefile mkversion version.h .machine
.build: $(SOURCES) config.h Makefile version.h
@echo
@echo " ***********************************************************"
@echo " * *"
@echo " * Making Bash-`cat $(srcdir)/.distribution`.`cat $(srcdir)/.patchlevel`-$(RELSTATUS) for a $(Machine) running $(OS)"
@echo " * Making Bash-$(Version).$(PatchLevel)-$(RELSTATUS) for a $(Machine) running $(OS)"
@echo " * *"
@echo " ***********************************************************"
@echo
.machine: $(SOURCES) config.h Makefile mkversion version.h
@echo "$(Program) last made for a $(Machine) running $(OS)" >.machine
bashbug: $(SUPPORT_SRC)bashbug.sh mkversion config.h Makefile
@sed -e "s:!MACHINE!:$(Machine):" -e "s:!OS!:$(OS):" \
-e "s:!CFLAGS!:$(CCFLAGS):" -e "s:!CC!:$(CC):" \
-e "s:!RELEASE!:`cat $(srcdir)/.distribution`:" \
-e "s:!PATCHLEVEL!:`cat $(srcdir)/.patchlevel`:" \
-e "s:!MACHTYPE!:$(MACHTYPE):" -e "s:!RELSTATUS!:$(RELSTATUS):" \
bashbug: $(SUPPORT_SRC)bashbug.sh config.h Makefile
@sed -e "s%!MACHINE!%$(Machine)%" -e "s%!OS!%$(OS)%" \
-e "s%!CFLAGS!%$(CCFLAGS)%" -e "s%!CC!%$(CC)%" \
-e "s%!RELEASE!%$(Version)%" -e "s%!PATCHLEVEL!%$(PatchLevel)%" \
-e "s%!MACHTYPE!%$(MACHTYPE)%" -e "s%!RELSTATUS!%$(RELSTATUS)%" \
$(SUPPORT_SRC)bashbug.sh > $@
@chmod a+rx bashbug
@ -378,19 +384,21 @@ strip: $(Program) .made
ls -l $(Program)
size $(Program)
version.h: $(SOURCES) config.h Makefile mkversion .patchlevel .distribution
if ./mkversion -dir $(srcdir) -build -status $(RELSTATUS); then mv -f newversion.h version.h; fi
version.h: $(SOURCES) config.h Makefile
if $(SHELL) $(SUPPORT_SRC)mkversion.sh -b -s $(RELSTATUS) -d $(Version) -p $(PatchLevel) -o newversion.h; \
then mv newversion.h version.h; fi;
# old rules
y.tab.o: y.tab.c parser-built
y.tab.c: parser-built
y.tab.h: parser-built
parser-built: parse.y command.h stdc.h input.h
$(RM) $@
-if test -f y.tab.h; then mv -f y.tab.h old-y.tab.h; fi
GRAM_H = parser-built
y.tab.o: y.tab.c ${GRAM_H} command.h stdc.h input.h
${GRAM_H}: y.tab.h
@-if test -f y.tab.h ; then \
cmp -s $@ y.tab.h 2>/dev/null || cp -p y.tab.h $@; \
fi
y.tab.c y.tab.h: parse.y
# -if test -f y.tab.h; then mv -f y.tab.h old-y.tab.h; fi
$(YACC) -d $(srcdir)/parse.y
-if cmp -s old-y.tab.h y.tab.h; then mv old-y.tab.h y.tab.h; fi
touch $@
# -if cmp -s old-y.tab.h y.tab.h; then mv old-y.tab.h y.tab.h; else cp -p y.tab.h ${GRAM_H}; fi
# experimental new rules - work with GNU make but not BSD (or OSF) make
#y.tab.o: y.tab.c y.tab.h
@ -402,7 +410,7 @@ parser-built: parse.y command.h stdc.h input.h
$(READLINE_LIBRARY): config.h $(READLINE_SOURCE)
@echo making $@ in ${RL_LIBDIR}
@(cd ${RL_LIBDIR} && \
$(MAKE) $(MFLAGS) APP_CFLAGS=-DSHELL libreadline.a) || exit 1
$(MAKE) $(MFLAGS) libreadline.a) || exit 1
$(HISTORY_LIBRARY): config.h $(HISTORY_SOURCE)
@echo making $@ in ${HIST_LIBDIR}
@ -420,8 +428,8 @@ $(TILDE_LIBRARY): config.h $(TILDE_SOURCE)
$(MAKE) $(MFLAGS) libtilde.a) || exit 1
$(TERMCAP_LIBRARY): config.h ${TERMCAP_SOURCE}
@echo making $@ in ${TERMCAP_LIBDIR}
@(cd ${TERMCAP_LIBDIR} && \
@echo making $@ in ${TERM_LIBDIR}
@(cd ${TERM_LIBDIR} && \
$(MAKE) $(MFLAGS) libtermcap.a) || exit 1
mksignames: $(SUPPORT_SRC)mksignames.c
@ -435,20 +443,20 @@ $(BUILTINS_LIBRARY): $(BUILTIN_DEFS) $(BUILTIN_C_SRC) config.h memalloc.h
@(cd $(DEFDIR) && $(MAKE) $(MFLAGS) libbuiltins.a ) || exit 1
# these require special rules to circumvent make builtin rules
builtins/common.o: $(BUILTIN_SRCDIR)/common.c
${DEFDIR}/common.o: $(BUILTIN_SRCDIR)/common.c
@(cd $(DEFDIR) && $(MAKE) $(MFLAGS) common.o) || exit 1
builtins/bashgetopt.o: $(BUILTIN_SRCDIR)/bashgetopt.c
${DEFDIR}/bashgetopt.o: $(BUILTIN_SRCDIR)/bashgetopt.c
@(cd $(DEFDIR) && $(MAKE) $(MFLAGS) bashgetopt.o) || exit 1
builtins/builtext.h: $(BUILTIN_DEFS)
${DEFDIR}/builtext.h: $(BUILTIN_DEFS)
@(cd $(DEFDIR) && $(MAKE) $(MFLAGS) builtext.h ) || exit 1
# For the justification of the following Makefile rules, see node
# `Automatic Remaking' in GNU Autoconf documentation.
Makefile: config.status $(srcdir)/Makefile.in
CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
Makefile makefile: config.status $(srcdir)/Makefile.in
CONFIG_FILES=Makefile CONFIG_HEADERS= $(SHELL) ./config.status
Makefiles makefiles: config.status $(srcdir)/Makefile.in
@for mf in $(CREATED_MAKEFILES); do \
@ -467,14 +475,11 @@ config.status: $(srcdir)/configure
#$(srcdir)/configure: $(srcdir)/configure.in $(srcdir)/aclocal.m4
# cd $(srcdir) && autoconf
mkversion: $(SUPPORT_SRC)mkversion.c
$(CC) $(CCFLAGS) -I.. -o $@ $(SUPPORT_SRC)mkversion.c
newversion: mkversion
$(RM) .build
./mkversion -dir $(srcdir) -dist
mv -f newversion.h version.h
$(MAKE) -f $(srcdir)/Makefile $(MFLAGS) srcdir=$(srcdir)
#newversion: mkversion
# $(RM) .build
# ./mkversion -dir $(srcdir) -dist
# mv -f newversion.h version.h
# $(MAKE) -f $(srcdir)/Makefile $(MFLAGS) srcdir=$(srcdir)
doc documentation: force
@(cd $(DOCDIR) ; $(MAKE) $(MFLAGS) )
@ -519,7 +524,7 @@ uninstall: .made
.PHONY: basic-clean clean realclean maintainer-clean distclean mostlyclean
basic-clean:
$(RM) $(OBJECTS) $(Program) bashbug
$(RM) .build .made .machine version.h
$(RM) .build .made version.h
clean: basic-clean
( cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ )
@ -557,7 +562,7 @@ distclean: basic-clean
maintainer-clean: basic-clean
@echo This command is intended for maintainers to use.
@echo It deletes files that may require special tools to rebuild.
$(RM) y.tab.c y.tab.h parser-built tags TAGS
$(RM) y.tab.c y.tab.h parser-built.h tags TAGS
( cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ )
( cd builtins && $(MAKE) $(MFLAGS) $@ )
-(cd $(RL_LIBDIR) && $(MAKE) $(MFLAGS) $@)
@ -570,16 +575,19 @@ maintainer-clean: basic-clean
$(RM) $(CREATED_SUPPORT) Makefile
recho: $(SUPPORT_SRC)recho.c
@$(CC) -o $@ $(SUPPORT_SRC)recho.c
@$(CC) $(CCFLAGS) -o $@ $(SUPPORT_SRC)recho.c
zecho: $(SUPPORT_SRC)zecho.c
@$(CC) -o $@ $(SUPPORT_SRC)zecho.c
@$(CC) $(CCFLAGS) -o $@ $(SUPPORT_SRC)zecho.c
tests check: force $(Program) recho zecho
printenv: $(SUPPORT_SRC)printenv.c
@$(CC) $(CCFLAGS) -o $@ $(SUPPORT_SRC)printenv.c
test tests check: force $(Program) $(TESTS_SUPPORT)
@-test -d tests || mkdir tests
@cp recho zecho $(SUPPORT_SRC)printenv tests
@cp $(TESTS_SUPPORT) tests
@( cd $(srcdir)/tests && \
PATH=$$PATH:$(BUILD_DIR)/tests THIS_SH=$(THIS_SH) sh run-all )
PATH=$$PATH:$(BUILD_DIR)/tests THIS_SH=$(THIS_SH) sh ${TESTSCRIPT} )
symlinks:
$(SHELL) $(SUPPORT_SRC)fixlinks -s $(srcdir)
@ -587,9 +595,14 @@ symlinks:
dist: force
@echo Bash distributions are created using $(srcdir)/support/mkdist.
@echo Here is a sample of the necessary commands:
@echo $(Program) $(srcdir)/support/mkdist -m $(srcdir)/MANIFEST -s $(srcdir) -r ${Program} `cat $(srcdir)/.distribution`
@echo tar cf $(Program)-`cat $(srcdir)/.distribution`.tar ${Program}-`cat $(srcdir)/.distribution`
@echo gzip $(Program)-`cat $(srcdir)/.distribution`.tar
@echo $(Program) $(srcdir)/support/mkdist -m $(srcdir)/MANIFEST -s $(srcdir) -r ${Program} $(Version)
@echo tar cf $(Program)-$(Version).tar ${Program}-$(Version)
@echo gzip $(Program)-$(Version).tar
depend: depends
sdepend: force
$(Program) $(SUPPORT_SRC)mkdep -c ${CC} -- ${CCFLAGS} ${CSOURCES}
############################ DEPENDENCIES ###############################
@ -601,146 +614,238 @@ y.tab.o: config.h.top
jobs.o: config.h.top
nojobs.o: config.h.top
execute_cmd.o: config.h.top
builtins/break.o: config.h.top
builtins/common.o: config.h.top
builtins/echo.o: config.h.top
variables.o: config.h.top
builtins/command.o: config.h.top
builtins/common.o: config.h.top
builtins/break.o: config.h.top
builtins/echo.o: config.h.top
builtins/evalstring.o: config.h.top
builtins/exit.o: config.h.top
builtins/kill.o: config.h.top
copy_cmd.o: shell.h bashjmp.h sig.h command.h stdc.h hashlib.h
copy_cmd.o: general.h variables.h config.h memalloc.h quit.h
copy_cmd.o: dispose_cmd.h make_cmd.h subst.h externs.h
dispose_cmd.o: shell.h bashjmp.h sig.h command.h stdc.h
dispose_cmd.o: general.h variables.h config.h memalloc.h quit.h
dispose_cmd.o: dispose_cmd.h make_cmd.h subst.h externs.h
error.o: error.h
execute_cmd.o: shell.h bashjmp.h sig.h command.h stdc.h y.tab.h posixstat.h
execute_cmd.o: general.h variables.h config.h memalloc.h quit.h hashlib.h jobs.h
execute_cmd.o: unwind_prot.h siglist.h builtins/builtext.h config.h flags.h
execute_cmd.o: dispose_cmd.h make_cmd.h subst.h externs.h bashtypes.h
execute_cmd.o: pathexp.h
expr.o: shell.h bashjmp.h sig.h command.h stdc.h hashlib.h
expr.o: general.h variables.h config.h memalloc.h quit.h
expr.o: dispose_cmd.h make_cmd.h subst.h externs.h
flags.o: flags.h stdc.h config.h memalloc.h general.h quit.h
general.o: shell.h bashjmp.h sig.h command.h stdc.h maxpath.h
general.o: general.h variables.h config.h memalloc.h quit.h unwind_prot.h
general.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
getcwd.o: config.h config.h.bot bashtypes.h maxpath.h posixstat.h
hashlib.o: shell.h bashjmp.h sig.h command.h stdc.h hashlib.h
hashlib.o: general.h variables.h config.h memalloc.h quit.h
hashlib.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
jobs.o: shell.h bashjmp.h sig.h command.h stdc.h hashlib.h trap.h jobs.h
jobs.o: general.h variables.h config.h memalloc.h quit.h bashtty.h siglist.h
jobs.o: dispose_cmd.h make_cmd.h subst.h externs.h builtins/builtext.h
jobs.o: unwind_prot.h
mailcheck.o: posixstat.h maxpath.h variables.h
mailcheck.o: hashlib.h quit.h mailcheck.h
make_cmd.o: shell.h bashjmp.h sig.h command.h stdc.h flags.h input.h
make_cmd.o: general.h variables.h config.h memalloc.h quit.h bashtypes.h
make_cmd.o: dispose_cmd.h make_cmd.h subst.h externs.h
y.tab.o: shell.h bashjmp.h sig.h command.h stdc.h flags.h maxpath.h alias.h
y.tab.o: general.h variables.h config.h memalloc.h quit.h mailcheck.h parser.h
y.tab.o: dispose_cmd.h make_cmd.h subst.h externs.h bashtypes.h bashline.h
y.tab.o: builtins/builtext.h
print_cmd.o: shell.h bashjmp.h sig.h command.h stdc.h y.tab.h
print_cmd.o: general.h variables.h config.h memalloc.h quit.h
print_cmd.o: dispose_cmd.h make_cmd.h subst.h externs.h unwind_prot.h
shell.o: shell.h bashjmp.h sig.h command.h stdc.h flags.h stdc.h
shell.o: general.h variables.h config.h memalloc.h quit.h
shell.o: dispose_cmd.h make_cmd.h subst.h externs.h mailcheck.h
shell.o: posixstat.h filecntl.h jobs.h input.h
subst.o: shell.h bashjmp.h sig.h command.h stdc.h flags.h jobs.h siglist.h
subst.o: general.h variables.h config.h memalloc.h quit.h bashtypes.h
subst.o: dispose_cmd.h make_cmd.h subst.h externs.h execute_cmd.h
subst.o: ${DEFSRC}/getopt.h pathexp.h bashline.h
pathexp.o: config.h shell.h bashjmp.h command.h stdc.h general.h
pathexp.o: error.h variables.h quit.h maxpath.h unwind_prot.h dispose_cmd.h
pathexp.o: make_cmd.h subst.h sig.h pathnames.h externs.h
pathexp.o: $(GLOB_LIBSRC)/glob.h $(GLOB_LIBSRC)/fnmatch.h
test.o: posixstat.h
trap.o: trap.h shell.h bashjmp.h sig.h command.h stdc.h hashlib.h unwind_prot.h
trap.o: general.h variables.h config.h memalloc.h quit.h signames.h
trap.o: dispose_cmd.h make_cmd.h subst.h externs.h
unwind_prot.o: config.h memalloc.h general.h unwind_prot.h sig.h
variables.o: shell.h bashjmp.h sig.h command.h stdc.h hashlib.h flags.h
variables.o: config.h memalloc.h general.h variables.h quit.h mailcheck.h
variables.o: execute_cmd.h dispose_cmd.h make_cmd.h subst.h externs.h
sig.o: shell.h bashjmp.h sig.h command.h stdc.h hashlib.h flags.h
sig.o: config.h memalloc.h general.h variables.h quit.h
sig.o: bashtypes.h jobs.h bashline.h unwind_prot.h
version.o: version.h .build
oslib.o: config.h bashtypes.h posixstat.h filecntl.h bashansi.h maxpath.h
oslib.o: shell.h bashjmp.h sig.h command.h stdc.h mailcheck.h
oslib.o: general.h error.h variables.h quit.h unwind_prot.h dispose_cmd.h
oslib.o: make_cmd.h subst.h pathnames.h externs.h
xmalloc.o: config.h ansi_stdlib.h general.h error.h
eval.o: config.h bashansi.h shell.h trap.h flags.h builtins/common.h
# shell basics
copy_cmd.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
copy_cmd.o: general.h bashtypes.h variables.h array.h hashlib.h
copy_cmd.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
copy_cmd.o: make_cmd.h subst.h sig.h pathnames.h externs.h
dispose_cmd.o: bashansi.h ansi_stdlib.h
dispose_cmd.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h
dispose_cmd.o: error.h general.h bashtypes.h variables.h array.h hashlib.h
dispose_cmd.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
dispose_cmd.o: make_cmd.h subst.h sig.h pathnames.h externs.h
getcwd.o: config.h bashtypes.h bashansi.h
getcwd.o: maxpath.h posixstat.h posixdir.h memalloc.h
error.o: config.h bashtypes.h bashansi.h ansi_stdlib.h flags.h stdc.h error.h
error.o: command.h general.h externs.h input.h bashhist.h
eval.o: config.h bashansi.h ansi_stdlib.h trap.h flags.h ${DEFSRC}/common.h
eval.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
eval.o: general.h bashtypes.h variables.h array.h hashlib.h
eval.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
eval.o: make_cmd.h subst.h sig.h pathnames.h externs.h
eval.o: input.h execute_cmd.h
eval.o: bashjmp.h command.h general.h error.h variables.h quit.h
eval.o: maxpath.h unwind_prot.h dispose_cmd.h make_cmd.h subst.h
eval.o: sig.h pathnames.h externs.h
execute_cmd.o: config.h bashtypes.h filecntl.h posixstat.h bashansi.h ansi_stdlib.h
execute_cmd.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
execute_cmd.o: general.h bashtypes.h variables.h array.h hashlib.h
execute_cmd.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
execute_cmd.o: make_cmd.h subst.h sig.h pathnames.h externs.h
execute_cmd.o: memalloc.h ${GRAM_H} flags.h builtins.h jobs.h quit.h siglist.h
execute_cmd.o: execute_cmd.h trap.h pathexp.h $(DEFSRC)/common.h
execute_cmd.o: ${DEFDIR}/builtext.h ${GLOB_LIBSRC}/fnmatch.h
expr.o: config.h bashansi.h ansi_stdlib.h
expr.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
expr.o: general.h bashtypes.h variables.h array.h hashlib.h
expr.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
expr.o: make_cmd.h subst.h sig.h pathnames.h externs.h
flags.o: config.h flags.h
flags.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
flags.o: general.h bashtypes.h variables.h array.h hashlib.h
flags.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
flags.o: make_cmd.h subst.h sig.h pathnames.h externs.h
general.o: config.h bashtypes.h posixstat.h filecntl.h bashansi.h ansi_stdlib.h
general.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
general.o: general.h bashtypes.h variables.h array.h hashlib.h
general.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
general.o: make_cmd.h subst.h sig.h pathnames.h externs.h
general.o: maxpath.h
hashcmd.o: config.h posixstat.h bashtypes.h bashansi.h ansi_stdlib.h
hashcmd.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
hashcmd.o: general.h bashtypes.h variables.h array.h hashcmd.h
hashcmd.o: execute_cmd.h stdc.h
hashlib.o: config.h bashansi.h ansi_stdlib.h
hashlib.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
hashlib.o: general.h bashtypes.h variables.h array.h hashlib.h
hashlib.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
hashlib.o: make_cmd.h subst.h sig.h pathnames.h externs.h
input.o: config.h bashtypes.h filecntl.h posixstat.h bashansi.h ansi_stdlib.h
input.o: command.h stdc.h general.h input.h error.h externs.h
list.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
list.o: general.h bashtypes.h variables.h array.h hashlib.h
list.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
list.o: make_cmd.h subst.h sig.h pathnames.h externs.h
locale.o: config.h bashtypes.h bashintl.h bashansi.h ansi_stdlib.h
locale.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
locale.o: general.h bashtypes.h variables.h array.h hashlib.h
locale.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
locale.o: make_cmd.h subst.h sig.h pathnames.h externs.h
mailcheck.o: config.h bashtypes.h posixstat.h bashansi.h ansi_stdlib.h
mailcheck.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
mailcheck.o: general.h bashtypes.h variables.h array.h hashlib.h
mailcheck.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
mailcheck.o: make_cmd.h subst.h sig.h pathnames.h externs.h
mailcheck.o: execute_cmd.h mailcheck.h
make_cmd.o: config.h bashtypes.h filecntl.h bashansi.h
make_cmd.o: command.h stdc.h general.h error.h flags.h make_cmd.h
make_cmd.o: variables.h array.h hashlib.h subst.h input.h externs.h
make_cmd.o: jobs.h quit.h siglist.h
oslib.o: config.h bashtypes.h posixstat.h filecntl.h bashansi.h maxpath.h
oslib.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
oslib.o: general.h bashtypes.h variables.h array.h hashlib.h
oslib.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
oslib.o: make_cmd.h subst.h sig.h pathnames.h externs.h
y.tab.o: config.h bashtypes.h bashansi.h ansi_stdlib.h memalloc.h
y.tab.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
y.tab.o: general.h bashtypes.h variables.h array.h hashlib.h
y.tab.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
y.tab.o: make_cmd.h subst.h sig.h pathnames.h externs.h
y.tab.o: trap.h flags.h parser.h input.h mailcheck.h $(DEFSRC)/common.h
y.tab.o: $(DEFDIR)/builtext.h bashline.h bashhist.h jobs.h siglist.h alias.h
pathexp.o: config.h bashtypes.h bashansi.h ansi_stdlib.h
pathexp.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
pathexp.o: general.h bashtypes.h variables.h array.h hashlib.h
pathexp.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
pathexp.o: make_cmd.h subst.h sig.h pathnames.h externs.h
pathexp.o: pathexp.h flags.h
pathexp.o: $(GLOB_LIBSRC)/glob.h $(GLOB_LIBSRC)/fnmatch.h
print_cmd.o: config.h bashansi.h ansi_stdlib.h
print_cmd.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
print_cmd.o: general.h bashtypes.h variables.h array.h hashlib.h
print_cmd.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
print_cmd.o: make_cmd.h subst.h sig.h pathnames.h externs.h
print_cmd.o: ${GRAM_H} $(DEFSRC)/common.h
shell.o: config.h bashtypes.h posixstat.h bashansi.h ansi_stdlib.h filecntl.h
shell.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
shell.o: general.h bashtypes.h variables.h array.h hashlib.h
shell.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
shell.o: make_cmd.h subst.h sig.h pathnames.h externs.h
shell.o: flags.h trap.h mailcheck.h builtins.h $(DEFSRC)/common.h
shell.o: jobs.h siglist.h input.h execute_cmd.h bashhist.h
shell.o: ${GLOB_LIBSRC}/fnmatch.h
sig.o: config.h bashtypes.h
sig.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
sig.o: general.h bashtypes.h variables.h array.h hashlib.h
sig.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
sig.o: make_cmd.h subst.h sig.h pathnames.h externs.h
sig.o: jobs.h siglist.h trap.h $(DEFSRC)/common.h bashline.h bashhist.h
siglist.o: config.h bashtypes.h siglist.h trap.h
stringlib.o: bashtypes.h
stringlib.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
stringlib.o: general.h bashtypes.h variables.h array.h hashlib.h
stringlib.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
stringlib.o: make_cmd.h subst.h sig.h pathnames.h externs.h
subst.o: config.h bashtypes.h bashansi.h ansi_stdlib.h posixstat.h
subst.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
subst.o: general.h bashtypes.h variables.h array.h hashlib.h
subst.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
subst.o: make_cmd.h subst.h sig.h pathnames.h externs.h
subst.o: flags.h jobs.h siglist.h execute_cmd.h filecntl.h trap.h pathexp.h
subst.o: mailcheck.h input.h $(DEFSRC)/getopt.h $(DEFSRC)/common.h
subst.o: bashline.h bashhist.h ${GLOB_LIBSRC}/fnmatch.h
test.o: bashtypes.h posixstat.h filecntl.h
test.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
test.o: general.h bashtypes.h variables.h array.h hashlib.h
test.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
test.o: make_cmd.h subst.h sig.h pathnames.h externs.h
test.o: ${DEFSRC}/common.h
trap.o: config.h bashtypes.h trap.h bashansi.h ansi_stdlib.h
trap.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
trap.o: general.h bashtypes.h variables.h array.h hashlib.h
trap.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
trap.o: make_cmd.h subst.h sig.h pathnames.h externs.h
trap.o: signames.h $(DEFSRC)/common.h
unwind_prot.o: config.h bashtypes.h bashansi.h ansi_stdlib.h command.h stdc.h
unwind_prot.o: general.h unwind_prot.h quit.h sig.h
variables.o: config.h bashtypes.h posixstat.h bashansi.h ansi_stdlib.h
variables.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
variables.o: general.h bashtypes.h variables.h array.h hashlib.h
variables.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
variables.o: make_cmd.h subst.h sig.h pathnames.h externs.h
varibales.o: flags.h execute_cmd.h mailcheck.h input.h $(DEFSRC)/common.h
variables.o: bashhist.h
version.o: version.h .build
vprint.o: config.h
xmalloc.o: config.h bashtypes.h ansi_stdlib.h error.h
locale.o: bashintl.h bashansi.h config.h bashtypes.h shell.h
locale.o: bashjmp.h command.h general.h error.h variables.h quit.h
locale.o: maxpath.h unwind_prot.h dispose_cmd.h make_cmd.h subst.h
locale.o: sig.h pathnames.h externs.h
# job control
jobs.o: config.h bashtypes.h trap.h filecntl.h input.h bashtty.h
jobs.o: bashansi.h ansi_stdlib.h
jobs.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
jobs.o: general.h bashtypes.h variables.h array.h hashlib.h
jobs.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
jobs.o: make_cmd.h subst.h sig.h pathnames.h externs.h
jobs.o: jobs.h flags.h $(DEFSRC)/common.h $(DEFDIR)/builtext.h
nojobs.o: config.h bashtypes.h filecntl.h bashjmp.h posixjmp.h
nojobs.o: command.h stdc.h general.h jobs.h quit.h siglist.h externs.h
nojobs.o: sig.h error.h bashtty.h input.h
alias.o: ansi_stdlib.h
bashline.o: ansi_stdlib.h
variables.o: ansi_stdlib.h
shell.o: ansi_stdlib.h
error.o: ansi_stdlib.h
hash.o: ansi_stdlib.h
signames.o: ansi_stdlib.h
expr.o: ansi_stdlib.h
general.o: ansi_stdlib.h
input.o: ansi_stdlib.h
# shell features that may be compiled in
jobs.o: jobs.c
nojobs.o: nojobs.c
array.o: config.h bashansi.h ansi_stdlib.h
array.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
array.o: general.h bashtypes.h variables.h array.h hashlib.h
array.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
array.o: make_cmd.h subst.h sig.h pathnames.h externs.h
array.o: $(DEFSRC)/common.h
braces.o: config.h bashansi.h ansi_stdlib.h
braces.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
braces.o: general.h bashtypes.h variables.h array.h hashlib.h
braces.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
braces.o: make_cmd.h subst.h sig.h pathnames.h externs.h
alias.o: config.h bashansi.h ansi_stdlib.h command.h stdc.h
alias.o: general.h bashtypes.h externs.h alias.h
array.o: general.h shell.h bashjmp.h sig.h variables.h quit.h config.h
array.o: command.h error.h maxpath.h unwind_prot.h dispose_cmd.h memalloc.h
array.o: make_cmd.h subst.h externs.h
array.o: array.h stdc.h $(DEFSRC)/common.h
# library support files
braces.o: general.h shell.h bashjmp.h sig.h variables.h quit.h config.h
braces.o: dispose_cmd.h make_cmd.h subst.h externs.h memalloc.h
braces.o: maxpath.h unwind_prot.h command.h stdc.h
bracecomp.o: bracecomp.c
bracecomp.o: shell.h bashjmp.h sig.h command.h hashlib.h builtins.h general.h
bashhist.o: config.h bashtypes.h bashansi.h ansi_stdlib.h posixstat.h
bashhist.o: filecntl.h
bashhist.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
bashhist.o: general.h bashtypes.h variables.h array.h hashlib.h
bashhist.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
bashhist.o: make_cmd.h subst.h sig.h pathnames.h externs.h
bashhist.o: flags.h input.h parser.h pathexp.h $(DEFSRC)/common.h bashline.h
bashhist.o: $(GLOB_LIBSRC)/fnmatch.h
bashline.o: config.h bashtypes.h posixstat.h bashansi.h ansi_stdlib.h
bashline.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
bashline.o: general.h bashtypes.h variables.h array.h hashlib.h
bashline.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
bashline.o: make_cmd.h subst.h sig.h pathnames.h externs.h
bashline.o: builtins.h bashhist.h bashline.h execute_cmd.h pathexp.h
bashline.o: $(DEFSRC)/common.h $(GLOB_LIBSRC)/glob.h alias.h
bracecomp.o: config.h bashansi.h ansi_stdlib.h
bracecomp.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
bracecomp.o: general.h bashtypes.h variables.h array.h hashlib.h
bracecomp.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
bracecomp.o: make_cmd.h subst.h sig.h pathnames.h externs.h
bracecomp.o: shell.h bashjmp.h posixjmp.h sig.h command.h hashlib.h builtins.h general.h
bracecomp.o: quit.h alias.h config.h variables.h
bracecomp.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
bracecomp.o: $(RL_LIBSRC)/readline.h
bashline.o: shell.h bashjmp.h sig.h command.h stdc.h hashlib.h builtins.h
bashline.o: general.h variables.h config.h memalloc.h quit.h alias.h
bashline.o: dispose_cmd.h make_cmd.h subst.h externs.h config.h bashline.h
bashline.o: $(GLOB_LIBSRC)/glob.h pathexp.h execute_cmd.h
# library dependencies
bashhist.o: config.h bashansi.h posixstat.h filecntl.h parser.h
bashhist.o: shell.h bashjmp.h sig.h command.h stdc.h hashlib.h builtins.h
bashhist.o: general.h variables.h memalloc.h quit.h alias.h execute_cmd.h
bashhist.o: dispose_cmd.h make_cmd.h subst.h externs.h flags.h
bashline.o: $(RL_LIBSRC)/chardefs.h $(RL_LIBSRC)/readline.h
bashline.o: $(RL_LIBSRC)/rlconf.h
bashline.o: $(RL_LIBSRC)/keymaps.h
y.tab.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/chardefs.h
y.tab.o: $(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)/readline.h
y.tab.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/chardefs.h $(RL_LIBSRC)/readline.h
subst.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/chardefs.h $(RL_LIBSRC)/readline.h
shell.o: $(HIST_LIBSRC)/history.h
subst.o: $(HIST_LIBSRC)/history.h
bashline.o: $(HIST_LIBSRC)/history.h
bashhist.o: $(HIST_LIBSRC)/history.h
y.tab.o: $(HIST_LIBSRC)/history.h
subst.o: $(GLOB_LIBSRC)/fnmatch.h
execute_cmd.o: $(GLOB_LIBSRC)/fnmatch.h
bashhist.o: $(GLOB_LIBSRC)/fnmatch.h
execute_cmd.o: $(TILDE_LIBSRC)/tilde.h
general.o: $(TILDE_LIBSRC)/tilde.h
mailcheck.o: $(TILDE_LIBSRC)/tilde.h
@ -748,147 +853,182 @@ shell.o: $(TILDE_LIBSRC)/tilde.h
subst.o: $(TILDE_LIBSRC)/tilde.h
variables.o: $(TILDE_LIBSRC)/tilde.h
builtins/common.o: shell.h bashjmp.h sig.h command.h config.h memalloc.h
builtins/common.o: variables.h input.h $(DEFSRC)/hashcom.h siglist.h
# XXX - dependencies checked through here
# builtin c sources
builtins/bashgetopt.o: config.h bashansi.h ansi_stdlib.h
builtins/bashgetopt.o: shell.h config.h bashjmp.h command.h general.h error.h
builtins/bashgetopt.o: variables.h quit.h maxpath.h unwind_prot.h dispose_cmd.h
builtins/bashgetopt.o: make_cmd.h subst.h sig.h pathnames.h externs.h
builtins/bashgetopt.o: $(DEFSRC)/common.h
builtins/common.o: bashtypes.h posixstat.h bashansi.h ansi_stdlib.h
builtins/common.o: shell.h config.h bashjmp.h posixjmp.h sig.h command.h
builtins/common.o: memalloc.h variables.h input.h siglist.h
builtins/common.o: quit.h unwind_prot.h maxpath.h jobs.h builtins.h
builtins/common.o: dispose_cmd.h make_cmd.h subst.h externs.h bashhist.h
builtins/common.o: execute_cmd.h stdc.h general.h error.h unwind_prot.h
builtins/common.o: execute_cmd.h stdc.h general.h error.h pathnames.h
builtins/common.o: ${DEFDIR}/builtext.h
builtins/evalfile.o: bashtypes.h posixstat.h filecntl.h bashansi.h ansi_stdlib.h
builtins/evalfile.o: shell.h config.h bashjmp.h command.h general.h error.h
builtins/evalfile.o: variables.h quit.h maxpath.h unwind_prot.h dispose_cmd.h
builtins/evalfile.o: make_cmd.h subst.h sig.h pathnames.h externs.h
builtins/evalfile.o: jobs.h builtins.h flags.h input.h execute_cmd.h
builtins/evalfile.o: bashhist.h $(DEFSRC)/common.h
builtins/evalstring.o: config.h bashansi.h ansi_stdlib.h
builtins/evalstring.o: shell.h bashjmp.h posixjmp.h sig.h command.h siglist.h
builtins/evalstring.o: memalloc.h variables.h input.h
builtins/evalstring.o: quit.h unwind_prot.h maxpath.h jobs.h builtins.h
builtins/evalstring.o: dispose_cmd.h make_cmd.h subst.h externs.h
builtins/evalstring.o: jobs.h builtins.h flags.h input.h execute_cmd.h
builtins/evalstring.o: bashhist.h $(DEFSRC)/common.h
builtins/getopt.o: config.h memalloc.h
builtins/getopt.o: shell.h bashjmp.h command.h general.h error.h
builtins/getopt.o: variables.h quit.h maxpath.h unwind_prot.h dispose_cmd.h
builtins/getopt.o: make_cmd.h subst.h sig.h pathnames.h externs.h
builtins/getopt.o: $(DEFSRC)/getopt.h
builtins/mkbuiltins.o: config.h bashtypes.h posixstat.h filecntl.h
builtins/mkbuiltins.o: bashansi.h ansi_stdlib.h
# builtin def files
builtins/alias.o: command.h config.h memalloc.h error.h general.h maxpath.h
builtins/alias.o: quit.h $(DEFSRC)/common.h
builtins/alias.o: shell.h bashjmp.h sig.h command.h stdc.h unwind_prot.h
builtins/alias.o: shell.h bashjmp.h posixjmp.h sig.h command.h stdc.h unwind_prot.h
builtins/alias.o: dispose_cmd.h make_cmd.h subst.h externs.h variables.h
builtins/bind.o: command.h config.h memalloc.h error.h general.h maxpath.h
builtins/bind.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
builtins/bind.o: shell.h bashjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/bind.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/bind.o: $(DEFSRC)/bashgetopt.h
builtins/break.o: command.h config.h memalloc.h error.h general.h maxpath.h
builtins/break.o: shell.h bashjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/break.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/break.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
builtins/builtin.o: command.h config.h memalloc.h error.h general.h maxpath.h
builtins/builtin.o: quit.h $(DEFSRC)/common.h
builtins/builtin.o: shell.h bashjmp.h sig.h unwind_prot.h variables.h
builtins/builtin.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
builtins/builtin.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
builtins/cd.o: command.h config.h memalloc.h error.h general.h maxpath.h
builtins/cd.o: shell.h bashjmp.h sig.h unwind_prot.h variables.h
builtins/cd.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
builtins/cd.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
builtins/cd.o: $(DEFSRC)/common.h quit.h
builtins/command.o: command.h config.h memalloc.h error.h general.h maxpath.h
builtins/command.o: quit.h $(DEFSRC)/bashgetopt.h
builtins/command.o: shell.h bashjmp.h sig.h unwind_prot.h variables.h
builtins/command.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
builtins/command.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
builtins/declare.o: command.h config.h memalloc.h error.h general.h maxpath.h
builtins/declare.o: shell.h bashjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/declare.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/declare.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
builtins/echo.o: command.h config.h memalloc.h error.h general.h maxpath.h
builtins/echo.o: shell.h bashjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/echo.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/echo.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
builtins/enable.o: command.h config.h memalloc.h error.h general.h maxpath.h
builtins/enable.o: shell.h bashjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/enable.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/enable.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
builtins/eval.o: command.h config.h memalloc.h error.h general.h maxpath.h
builtins/eval.o: shell.h bashjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/eval.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/eval.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
builtins/exec.o: bashtypes.h
builtins/exec.o: command.h config.h memalloc.h error.h general.h maxpath.h
builtins/exec.o: shell.h bashjmp.h sig.h unwind_prot.h variables.h
builtins/exec.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
builtins/exec.o: dispose_cmd.h make_cmd.h subst.h externs.h execute_cmd.h
builtins/exec.o: flags.h quit.h $(DEFSRC)/common.h stdc.h
builtins/exit.o: bashtypes.h
builtins/exit.o: command.h config.h memalloc.h error.h general.h maxpath.h
builtins/exit.o: shell.h bashjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/exit.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/exit.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
builtins/fc.o: builtins.h command.h stdc.h
builtins/fc.o: bashtypes.h posixstat.h
builtins/fc.o: bashansi.h ansi_stdlib.h builtins.h command.h stdc.h
builtins/fc.o: command.h config.h memalloc.h error.h general.h maxpath.h
builtins/fc.o: flags.h unwind_prot.h variables.h shell.h bashjmp.h sig.h
builtins/fc.o: flags.h unwind_prot.h variables.h shell.h bashjmp.h posixjmp.h sig.h
builtins/fc.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h quit.h
builtins/fc.o: $(DEFSRC)/bashgetopt.h bashhist.h
builtins/fg_bg.o: bashtypes.h
builtins/fg_bg.o: command.h config.h memalloc.h error.h general.h maxpath.h
builtins/fg_bg.o: shell.h bashjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/fg_bg.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/fg_bg.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
builtins/getopts.o: command.h config.h memalloc.h error.h general.h maxpath.h
builtins/getopts.o: shell.h bashjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/getopts.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/getopts.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
builtins/hash.o: bashtypes.h
builtins/hash.o: builtins.h command.h execute_cmd.h stdc.h $(DEFSRC)/common.h
builtins/hash.o: command.h config.h memalloc.h error.h general.h maxpath.h
builtins/hash.o: shell.h bashjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/hash.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/help.o: command.h config.h memalloc.h error.h general.h maxpath.h
builtins/help.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
builtins/help.o: shell.h bashjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/help.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/help.o: $(GLOB_LIBSRC)/glob.h
builtins/history.o: bashtypes.h
builtins/history.o: command.h config.h memalloc.h error.h general.h maxpath.h
builtins/history.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
builtins/history.o: filecntl.h shell.h bashjmp.h sig.h unwind_prot.h
builtins/history.o: filecntl.h shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h
builtins/history.o: bashhist.h variables.h
builtins/inlib.o: command.h config.h memalloc.h error.h general.h maxpath.h
builtins/inlib.o: shell.h bashjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/inlib.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/inlib.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
builtins/jobs.o: command.h config.h memalloc.h error.h general.h maxpath.h
builtins/jobs.o: quit.h $(DEFSRC)/bashgetopt.h
builtins/jobs.o: shell.h bashjmp.h sig.h unwind_prot.h variables.h
builtins/jobs.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
builtins/jobs.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
builtins/kill.o: command.h config.h memalloc.h error.h general.h maxpath.h
builtins/kill.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
builtins/kill.o: shell.h bashjmp.h sig.h trap.h unwind_prot.h variables.h
builtins/kill.o: shell.h bashjmp.h posixjmp.h sig.h trap.h unwind_prot.h variables.h
builtins/let.o: command.h config.h memalloc.h error.h general.h maxpath.h
builtins/let.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
builtins/let.o: shell.h bashjmp.h sig.h unwind_prot.h variables.h
builtins/let.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
builtins/pushd.o: command.h config.h memalloc.h error.h general.h maxpath.h
builtins/pushd.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
builtins/pushd.o: shell.h bashjmp.h sig.h unwind_prot.h variables.h
builtins/pushd.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
builtins/pushd.o: $(DEFSRC)/common.h
builtins/read.o: command.h config.h memalloc.h error.h general.h maxpath.h
builtins/read.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
builtins/read.o: shell.h bashjmp.h sig.h unwind_prot.h variables.h
builtins/read.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
builtins/return.o: command.h config.h memalloc.h error.h general.h maxpath.h
builtins/return.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
builtins/return.o: shell.h bashjmp.h sig.h unwind_prot.h variables.h
builtins/return.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
builtins/set.o: command.h config.h memalloc.h error.h general.h maxpath.h
builtins/set.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
builtins/set.o: shell.h bashjmp.h sig.h unwind_prot.h variables.h flags.h
builtins/set.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h flags.h
builtins/setattr.o: command.h config.h memalloc.h error.h general.h maxpath.h
builtins/setattr.o: quit.h $(DEFSRC)/common.h $(DEFSRC)/bashgetopt.h
builtins/setattr.o: shell.h bashjmp.h sig.h unwind_prot.h variables.h
builtins/setattr.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
builtins/setattr.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
builtins/shift.o: command.h config.h memalloc.h error.h general.h maxpath.h
builtins/shift.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
builtins/shift.o: shell.h bashjmp.h sig.h unwind_prot.h variables.h
builtins/shift.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
builtins/shift.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
builtins/shopt.o: command.h config.h memalloc.h error.h general.h
builtins/shopt.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h
builtins/shopt.o: shell.h bashjmp.h posixjmp.h unwind_prot.h variables.h maxpath.h
builtins/shopt.o: $(DEFSRC)/common.h $(DEFSRC)/bashgetopt.h
builtins/source.o: command.h config.h memalloc.h error.h general.h maxpath.h
builtins/source.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
builtins/source.o: shell.h bashjmp.h sig.h unwind_prot.h variables.h
builtins/source.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
builtins/suspend.o: command.h config.h memalloc.h error.h general.h maxpath.h
builtins/suspend.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
builtins/suspend.o: shell.h bashjmp.h sig.h unwind_prot.h variables.h
builtins/suspend.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
builtins/test.o: command.h config.h memalloc.h error.h general.h maxpath.h
builtins/test.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
builtins/test.o: shell.h bashjmp.h sig.h unwind_prot.h variables.h
builtins/test.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
builtins/times.o: command.h config.h memalloc.h error.h general.h maxpath.h
builtins/times.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
builtins/times.o: shell.h bashjmp.h sig.h unwind_prot.h variables.h
builtins/times.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
builtins/trap.o: command.h config.h memalloc.h error.h general.h maxpath.h
builtins/trap.o: quit.h $(DEFSRC)/common.h
builtins/trap.o: shell.h bashjmp.h sig.h unwind_prot.h variables.h
builtins/trap.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
builtins/trap.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
builtins/type.o: command.h config.h memalloc.h error.h general.h maxpath.h
builtins/type.o: quit.h $(DEFSRC)/common.h execute_cmd.h
builtins/type.o: shell.h bashjmp.h sig.h unwind_prot.h variables.h
builtins/type.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
builtins/type.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
builtins/ulimit.o: command.h config.h memalloc.h error.h general.h maxpath.h
builtins/ulimit.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
builtins/ulimit.o: shell.h bashjmp.h sig.h unwind_prot.h variables.h
builtins/ulimit.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
builtins/umask.o: command.h config.h memalloc.h error.h general.h maxpath.h
builtins/umask.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
builtins/umask.o: shell.h bashjmp.h sig.h unwind_prot.h variables.h
builtins/umask.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
builtins/wait.o: command.h config.h memalloc.h error.h general.h maxpath.h
builtins/wait.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
builtins/wait.o: shell.h bashjmp.h sig.h unwind_prot.h variables.h
builtins/shopt.o: command.h config.h memalloc.h error.h general.h
builtins/shopt.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h
builtins/shopt.o: shell.h bashjmp.h unwind_prot.h variables.h maxpath.h
builtins/shopt.o: $(DEFSRC)/common.h $(DEFSRC)/bashgetopt.h
builtins/bashgetopt.o: bashansi.h ansi_stdlib.h
builtins/mkbuiltins.o: bashansi.h ansi_stdlib.h
builtins/fc.o: bashansi.h ansi_stdlib.h
builtins/wait.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
# builtin library dependencies
builtins/bind.o: $(RL_LIBSRC)/chardefs.h $(RL_LIBSRC)/readline.h
builtins/bind.o: $(RL_LIBSRC)/keymaps.h

17
NEWS
View File

@ -1,3 +1,20 @@
This is a terse description of the new features added to bash-2.01 since
the release of bash-2.0. As always, the manual page (doc/bash.1) is the
place to look for complete descriptions.
1. New Features in Bash
a. There is a new builtin array variable: GROUPS, the set of groups to which
the user belongs. This is used by the test suite.
2. New Features in Readline
a. If a key sequence bound to `universal-argument' is read while reading a
numeric argument started with `universal-argument', it terminates the
argument but is otherwise ignored. This provides a way to insert multiple
instances of a digit string, and is how GNU emacs does it.
-------------------------------------------------------------------------------
This is a terse description of the new features added to bash-2.0 since
the release of bash-1.14.7. As always, the manual page (doc/bash.1) is
the place to look for complete descriptions.

117
NOTES
View File

@ -1,5 +1,5 @@
Platform-Specific Configuration Notes
=====================================
Platform-Specific Configuration and Operation Notes
===================================================
1. configure --without-gnu-malloc on:
@ -10,7 +10,7 @@ Platform-Specific Configuration Notes
all machines running SunOS YP code: SunOS4, SunOS5, HP/UX
linux (optional)
linux (optional, but don't do it if you're using Doug Lea's malloc)
QNX 4.2
other OSF/1 machines (KSR/1, HP, IBM AIX/ESA)
@ -32,11 +32,108 @@ being built and linked against, but there is only a stub file in the archive.)
3. Bash cannot be built in a directory separate from the source directory
using configure --srcdir=... unless the version of `make' you're using
does $VPATH handling right. The SunOS make, for one, does not seem to
do it right. The script support/mkclone can be used to create a
`build tree' using symlinks to get around this.
does $VPATH handling right. The script support/mkclone can be used to
create a `build tree' using symlinks to get around this.
4. I've had reports that username completion (as well as tilde expansion
and \u prompt expansion) does not work on IRIX 5.3 when linking with
-lnsl. This is only a problem when you're running NIS, since
apparently -lnsl supports only /etc/passwd and not the NIS functions
for retrieving usernames and passwords. Editing the Makefile after
configure runs and removing the `-lnsl' from the assignment to `LIBS'
fixes the problem.
5. There is a problem with Red Hat Linux's `makewhatis' script.
Running `makewhatis' with bash-2.0 results in error messages
like this:
/usr/sbin/makewhatis: cd: manpath: No such file or directory
/usr/sbin/makewhatis: manpath/whatis: No such file or directory
chmod: manpath/whatis: No such file or directory
/usr/sbin/makewhatis: cd: catpath: No such file or directory
/usr/sbin/makewhatis: catpath/whatis: No such file or directory
chmod: catpath/whatis: No such file or directory
The problem is with `makewhatis'. Red Hat (and possibly other
Linux distributors) uses a construct like this in the code:
eval path=$"$pages"path
to do indirect variable expansion. This `happened to work' in
bash-1.14 and previous versions, but that was more an accident
of implementation than anything else -- it was never supported
and certainly is not portable.
Bash-2.0 has a new feature that gives a new meaning to $"...".
This is explained more completely in item 1 in the COMPAT file.
The three lines in the `makewhatis' script that need to be changed
look like this:
eval $topath=$"$topath":$name
[...]
eval path=$"$pages"path
[...]
eval path=$"$pages"path
The portable way to write this code is
eval $topath="\$$topath":$name
eval path="\$$pages"path
eval path="\$$pages"path
You could also experiment with another new bash feature: ${!var}.
This does indirect variable expansion, making the use of eval
unnecessary.
6. There is a problem with syslogd on many Linux distributions (Red Hat
and Slackware are two that I have received reports about). syslogd
sends a SIGINT to its parent process, which is waiting for the daemon
to finish its initialization. The parent process then dies due to
the SIGINT, and bash reports it, causing unexpected console output
while the system is booting that looks something like
starting daemons: syslogd/etc/rc.d/rc.M: line 29: 38 Interrupt ${NET}/syslogd
Bash-2.0 reports events such as processes dying in scripts due to
signals when the standard output is a tty. Bash-1.14.x and previous
versions did not report such events.
This should probably be reported as a bug to whatever Linux distributor
people see the problem on. In my opinion, syslogd should be changed to
use some other method of communication, or the wrapper function (which
appeared to be `daemon' when I looked at it some time ago) or script
(which appeared to be `syslog') should catch SIGINT, since it's an
expected event, and exit cleanly.
7. Several people have reported that `dip' (a program for SLIP/PPP
on Linux) does not work with bash-2.0 installed as /bin/sh.
I don't run any Linux boxes myself, and do not have the dip
code handy to look at, but the `problem' with bash-2.0, as
it has been related to me, is that bash requires the `-p'
option to be supplied at invocation if it is to run setuid
or setgid.
This means, among other things, that setuid or setgid programs
which call system(3) (a horrendously bad practice in any case)
relinquish their setuid/setgid status in the child that's forked
to execute /bin/sh.
The following is an *unofficial* patch to bash-2.0 that causes it
to not require `-p' to run setuid or setgid if invoked as `sh'.
It has been reported to work on Linux. It will make your system
vulnerable to bogus system(3) calls in setuid executables.
--- ../bash-2.0.orig/shell.c Wed Dec 18 14:16:30 1996
+++ shell.c Fri Mar 7 13:12:03 1997
@@ -347,7 +347,7 @@
if (posixly_correct)
posix_initialize (posixly_correct);
- if (running_setuid && privileged_mode == 0)
+ if (running_setuid && privileged_mode == 0 && act_like_sh == 0)
disable_priv_mode ();
/* Need to get the argument to a -c option processed in the
4. I've had reports that username completion does not work on IRIX 5.3
when linking with -lnsl. This is only a problem when you're running
NIS. Editing the Makefile after configure runs and removing the
`-lnsl' from the assignment to `LIBS' fixes the problem.

43
README
View File

@ -1,26 +1,30 @@
Introduction
============
This is GNU Bash, version 2.0. Bash is the GNU Project's Bourne
This is GNU Bash, version 2.01. Bash is the GNU Project's Bourne
Again SHell, a complete implementation of the POSIX.2 shell spec,
but also with interactive command line editing, job control on
architectures that support it, csh-like features such as history
substitution and brace expansion, and a slew of other features.
For more information on the features of Bash that are new to this
type of shell, see the file `doc/features.texi'. There is also a
large man page. The manual page is the definitive description of
the shell's features.
type of shell, see the file `doc/bashref.texi'. There is also a
large Unix-style man page. The man page is the definitive description
of the shell's features.
See the file CWRU/POSIX.NOTES for a discussion of how Bash differs
from the POSIX.2 spec and a description of the Bash `posix mode'.
There are some user-visible incompatibilities between this version
of Bash and the previous version, bash-1.14. For details, see the
file COMPAT.
of Bash and the previous widely-distributed version, bash-1.14.
For details, see the file COMPAT. The NEWS file tersely lists
features that are new in this release.
Bash is free software, distributed under the terms of the GNU Public
License, version 2. For more information, see the file COPYING.
A number of frequently-asked questions are answered in the file
`doc/FAQ'.
To compile Bash, try typing `./configure', then `make'. Bash
auto-configures the build process, so no further intervention
should be necessary. Bash builds with `gcc' by default if it is
@ -39,12 +43,13 @@ platform-specific installation and configuration information.
If you are a csh user and wish to convert your csh aliases to Bash
aliases, you may wish to use the script `examples/misc/alias-conv.sh'
as a starting point.
as a starting point. The script `examples/misc/cshtobash' is a
more ambitious script that attempts to do a more complete job.
Reporting Bugs
==============
Bug reports for 2.0 should be sent to:
Bug reports for bash-2.01 should be sent to:
bug-bash@prep.ai.mit.edu
@ -52,15 +57,19 @@ using the `bashbug' program that is built and installed at the same
time as bash.
The discussion list `bug-bash@prep.ai.mit.edu' often contains
information about new ports of Bash, or discussions of new
features or behavior changes that people would like. This
mailing list is also available as a usenet newsgroup:
gnu.bash.bug.
information about new ports of Bash, or discussions of new features or
behavior changes that people would like. This mailing list is also
available as a usenet newsgroup: gnu.bash.bug.
When you send a bug report to bug-bash@prep.ai.mit.edu, please include:
When you send a bug report, please use the `bashbug' program that is
built at the same time as bash. If bash fails to build, try building
bashbug directly with `make bashbug'. If you cannot build `bashbug',
please send mail to bug-bash@prep.ai.mit.edu with the following
information:
* the version number of Bash
* the machine and OS that it is running on (see .machine or .made)
* the version number and release status of Bash (e.g., 2.01-release)
* the machine and OS that it is running on (look at the file
`.made' in the bash build directory)
* a list of the compilation flags or the contents of `config.h', if
appropriate
* a description of the bug
@ -69,8 +78,8 @@ When you send a bug report to bug-bash@prep.ai.mit.edu, please include:
The `bashbug' program includes much of this automatically.
If you would like to contact the Bash maintainers directly, send mail to
bash-maintainers@prep.ai.mit.edu.
If you would like to contact the Bash maintainers directly, send mail
to bash-maintainers@prep.ai.mit.edu.
While the Bash maintainers do not promise to fix all bugs, we would
like this shell to be the best that we can make it.

133
aclocal.m4 vendored
View File

@ -3,20 +3,6 @@ dnl Bash specific tests
dnl
dnl Some derived from PDKSH 5.1.3 autoconf tests
dnl
dnl check whether cc can create executables
dnl
AC_DEFUN(BASH_CC_WORKS,
[AC_CACHE_CHECK(whether CC works at all, bash_cv_prog_cc_works,
[AC_TRY_RUN([main() { exit(0); }],
bash_cv_prog_cc_works=yes, bash_cv_prog_cc_works=no,
bash_cv_prog_cc_works=no)
]
)
if test "$bash_cv_prog_cc_works" = "no"; then
AC_MSG_ERROR([Installation or configuration problem: C compiler cannot create executables])
fi
])
dnl
dnl Check if dup2() does not clear the close on exec flag
dnl
@ -497,7 +483,7 @@ if test $bash_cv_termcap_lib = gnutermcap; then
LDFLAGS="$LDFLAGS -L./lib/termcap"
TERMCAP_LIB="./lib/termcap/libtermcap.a"
TERMCAP_DEP="./lib/termcap/libtermcap.a"
elif test $bash_cv_termcap_lib = libtermcap; then
elif test $bash_cv_termcap_lib = libtermcap && test -z "$prefer_curses"; then
TERMCAP_LIB=-ltermcap
TERMCAP_DEP=
elif test $bash_cv_termcap_lib = libncurses; then
@ -604,6 +590,39 @@ AC_DEFINE(STRUCT_DIRENT_HAS_D_INO)
fi
])
AC_DEFUN(BASH_STRUCT_DIRENT_D_FILENO,
[AC_REQUIRE([AC_HEADER_DIRENT])
AC_MSG_CHECKING(if struct dirent has a d_fileno member)
AC_CACHE_VAL(bash_cv_dirent_has_d_fileno,
[AC_TRY_COMPILE([
#include <stdio.h>
#include <sys/types.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif /* HAVE_UNISTD_H */
#if defined(HAVE_DIRENT_H)
# include <dirent.h>
#else
# define dirent direct
# ifdef HAVE_SYS_NDIR_H
# include <sys/ndir.h>
# endif /* SYSNDIR */
# ifdef HAVE_SYS_DIR_H
# include <sys/dir.h>
# endif /* SYSDIR */
# ifdef HAVE_NDIR_H
# include <ndir.h>
# endif
#endif /* HAVE_DIRENT_H */
],[
struct dirent d; int z; z = d.d_fileno;
], bash_cv_dirent_has_d_fileno=yes, bash_cv_dirent_has_d_fileno=no)])
AC_MSG_RESULT($bash_cv_dirent_has_d_fileno)
if test $bash_cv_dirent_has_d_fileno = yes; then
AC_DEFINE(STRUCT_DIRENT_HAS_D_FILENO)
fi
])
AC_DEFUN(BASH_REINSTALL_SIGHANDLERS,
[AC_REQUIRE([AC_TYPE_SIGNAL])
AC_REQUIRE([BASH_SIGNAL_CHECK])
@ -834,6 +853,18 @@ AC_DEFINE(GWINSZ_IN_SYS_IOCTL)
fi
])
AC_DEFUN(BASH_STRUCT_WINSIZE,
[AC_MSG_CHECKING(for struct winsize in sys/ioctl.h)
AC_CACHE_VAL(bash_cv_struct_winsize_in_ioctl,
[AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/ioctl.h>], [struct winsize x;],
bash_cv_struct_winsize_in_ioctl=yes,bash_cv_struct_winsize_in_ioctl=no)])
AC_MSG_RESULT($bash_cv_struct_winsize_in_ioctl)
if test $bash_cv_struct_winsize_in_ioctl = yes; then
AC_DEFINE(STRUCT_WINSIZE_IN_SYS_IOCTL)
fi
])
AC_DEFUN(BASH_HAVE_TIOCSTAT,
[AC_MSG_CHECKING(for TIOCSTAT in sys/ioctl.h)
AC_CACHE_VAL(bash_cv_tiocstat_in_ioctl,
@ -858,6 +889,23 @@ AC_DEFINE(FIONREAD_IN_SYS_IOCTL)
fi
])
dnl
dnl See if speed_t is declared in <sys/types.h>. Some versions of linux
dnl require a definition of speed_t each time <termcap.h> is included,
dnl but you can only get speed_t if you include <termios.h> (on some
dnl versions) or <sys/types.h> (on others).
dnl
AC_DEFUN(BASH_MISC_SPEED_T,
[AC_MSG_CHECKING(for speed_t in sys/types.h)
AC_CACHE_VAL(bash_cv_speed_t_in_sys_types,
[AC_TRY_COMPILE([#include <sys/types.h>], [speed_t x;],
bash_cv_speed_t_in_sys_types=yes,bash_cv_speed_t_in_sys_types=no)])
AC_MSG_RESULT($bash_cv_speed_t_in_sys_types)
if test $bash_cv_speed_t_in_sys_types = yes; then
AC_DEFINE(SPEED_T_IN_SYS_TYPES)
fi
])
AC_DEFUN(BASH_CHECK_GETPW_FUNCS,
[AC_MSG_CHECKING(whether programs are able to redeclare getpw functions)
AC_CACHE_VAL(bash_cv_can_redecl_getpw,
@ -892,6 +940,13 @@ elif test $bash_cv_dev_fd = "whacky"; then
fi
])
dnl
dnl Check for the presence of getpeername (the only networking function
dnl bash currently requires) in libsocket. If libsocket is present,
dnl check for libnsl and add it to LIBS if it's there, since most
dnl systems with libsocket require linking with libnsl as well.
dnl This should only be called if getpeername was not found in libc.
dnl
AC_DEFUN(BASH_CHECK_SOCKLIB,
[
if test "X$bash_cv_have_socklib" = "X"; then
@ -991,3 +1046,51 @@ if test $bash_cv_kernel_rlimit = yes; then
AC_DEFINE(RLIMIT_NEEDS_KERNEL)
fi
])
AC_DEFUN(BASH_FUNC_STRCOLL,
[
AC_MSG_CHECKING(whether or not strcoll and strcmp differ)
AC_CACHE_VAL(bash_cv_func_strcoll_broken,
[AC_TRY_RUN([
#include <stdio.h>
#if defined (HAVE_LOCALE_H)
#include <locale.h>
#endif
main(c, v)
int c;
char *v[];
{
int r1, r2;
char *deflocale, *defcoll;
#ifdef HAVE_SETLOCALE
deflocale = setlocale(LC_ALL, "");
defcoll = setlocale(LC_COLLATE, "");
#endif
#ifdef HAVE_STRCOLL
/* These two values are taken from tests/glob-test. */
r1 = strcoll("abd", "aXd");
#else
r1 = 0;
#endif
r2 = strcmp("abd", "aXd");
/* These two should both be greater than 0. It is permissible for
a system to return different values, as long as the sign is the
same. */
/* Exit with 1 (failure) if these two values are both > 0, since
this tests whether strcoll(3) is broken with respect to strcmp(3)
in the default locale. */
exit (r1 > 0 && r2 > 0);
}
], bash_cv_func_strcoll_broken=yes, bash_cv_func_strcoll_broken=no,
AC_MSG_ERROR(cannot check strcoll if cross compiling))
])
AC_MSG_RESULT($bash_cv_func_strcoll_broken)
if test $bash_cv_func_strcoll_broken = yes; then
AC_DEFINE(STRCOLL_BROKEN)
fi
])

View File

@ -151,6 +151,7 @@ remove_alias (name)
{
free_alias_data (elt->data);
free (elt->key); /* alias name */
free (elt); /* XXX */
return (aliases->nentries);
}
return (-1);
@ -164,7 +165,7 @@ delete_all_aliases ()
return;
flush_hash_table (aliases, free_alias_data);
free (aliases);
dispose_hash_table (aliases);
aliases = (HASH_TABLE *)NULL;
}
@ -247,6 +248,10 @@ alias_expand_word (s)
return (r ? savestring (r->value) : (char *)NULL);
}
/* Readline support functions -- expand all aliases in a line. */
#if defined (READLINE)
/* Return non-zero if CHARACTER is a member of the class of characters
that are self-delimiting in the shell (this really means that these
characters delimit tokens). */
@ -529,4 +534,5 @@ alias_expand (string)
command_word = 0;
}
}
#endif /* READLINE */
#endif /* ALIAS */

16
array.c
View File

@ -17,6 +17,8 @@
#endif
#include <stdio.h>
#include "bashansi.h"
#include "shell.h"
#include "array.h"
#include "builtins/common.h"
@ -123,6 +125,7 @@ ARRAY *a;
return(a1);
}
#ifdef INCLUDE_UNUSED
/*
* Make and return a new array composed of the elements in array A from
* S to E, inclusive.
@ -146,6 +149,7 @@ ARRAY_ELEMENT *s, *e;
a->num_elements = a->max_index = i;
return a;
}
#endif
ARRAY_ELEMENT *
copy_array_element(ae)
@ -392,6 +396,7 @@ register char *s1, *s2;
}
#endif
#if defined (INCLUDE_UNUSED) || defined (TEST_ARRAY)
/*
* Return an array consisting of elements in S, separated by SEP
*/
@ -410,6 +415,7 @@ char *s, *sep;
a = word_list_to_array (w);
return (a);
}
#endif
/* Convenience routines for the shell to translate to and from the form used
by the rest of the code. */
@ -549,7 +555,7 @@ main()
array_add_element(a, 12, "twelve");
array_add_element(a, 42, "forty-two");
print_array(a);
s = array_to_string (a, " ");
s = array_to_string (a, " ", 0);
printf("s = %s\n", s);
copy_of_a = string_to_array(s, " ");
printf("copy_of_a:");
@ -563,7 +569,7 @@ main()
destroy_array_element(ae);
array_add_element(a, 16, "sixteen");
print_array(a);
s = array_to_string (a, " ");
s = array_to_string (a, " ", 0);
printf("s = %s\n", s);
copy_of_a = string_to_array(s, " ");
printf("copy_of_a:");
@ -576,7 +582,7 @@ main()
array_add_element(a, 0, "zero");
array_add_element(a, 134, "");
print_array(a);
s = array_to_string (a, ":");
s = array_to_string (a, ":", 0);
printf("s = %s\n", s);
copy_of_a = string_to_array(s, ":");
printf("copy_of_a:");
@ -586,9 +592,9 @@ main()
free(s);
new_a = copy_array(a);
print_array(new_a);
s = array_to_string (new_a, ":");
s = array_to_string (new_a, ":", 0);
printf("s = %s\n", s);
copy_of_a = string_to_array(s, ":");
copy_of_a = string_to_array(s, ":", 0);
printf("copy_of_a:");
print_array(copy_of_a);
dispose_array(copy_of_a);

View File

@ -32,12 +32,14 @@
#include "bashansi.h"
#include "posixstat.h"
#include "filecntl.h"
#include "shell.h"
#include "flags.h"
#include "input.h"
#include "parser.h" /* for the struct dstack stuff. */
#include "pathexp.h" /* for the struct ignorevar stuff */
#include "builtins/common.h"
#include <readline/history.h>
#include <glob/fnmatch.h>
@ -49,6 +51,8 @@
extern int errno;
#endif
extern int glob_pattern_p ();
static int histignore_item_func ();
static struct ignorevar histignore =
@ -124,6 +128,11 @@ int force_append_history;
Value of 2 means save all lines that do not match the last line saved. */
int history_control;
/* Set to 1 if the last command was added to the history list successfully
as a separate history entry; set to 0 if the line was ignored or added
to a previous entry as part of command-oriented-history processing. */
int hist_last_line_added;
#if defined (READLINE)
/* If non-zero, and readline is being used, the user is offered the
chance to re-edit a failed history expansion. */
@ -133,7 +142,8 @@ int history_reediting;
line with history substitution. Reload it into the editing buffer
instead and let the user further edit and confirm with a newline. */
int hist_verify;
#endif
#endif /* READLINE */
/* Variables declared in other files used here. */
extern int interactive;
@ -144,15 +154,36 @@ extern struct dstack dstack;
extern char *extract_colon_unit ();
extern char *history_delimiting_chars ();
extern void maybe_add_history (); /* forward declaration */
extern void bash_add_history (); /* forward declaration */
static void bash_add_history ();
static int history_should_ignore ();
/* Is the history expansion starting at string[i] one that should not
be expanded? */
static int
bash_history_inhibit_expansion (string, i)
char *string;
int i;
{
/* The shell uses ! as a pattern negation character in globbing [...]
expressions, so let those pass without expansion. */
if (i > 0 && (string[i - 1] == '[') && member (']', string + i + 1))
return (1);
/* The shell uses ! as the indirect expansion character, so let those
expansions pass as well. */
else if (i > 1 && string[i - 1] == '{' && string[i - 2] == '$' &&
member ('}', string + i + 1))
return (1);
else
return (0);
}
void
bash_initialize_history ()
{
history_quotes_inhibit_expansion = 1;
history_search_delimiter_chars = ";&()|<>";
history_inhibit_expansion_function = bash_history_inhibit_expansion;
}
void
@ -164,6 +195,7 @@ bash_history_reinit (interact)
history_expansion_inhibited = 1;
#endif
remember_on_history = interact != 0;
history_inhibit_expansion_function = bash_history_inhibit_expansion;
}
void
@ -182,6 +214,7 @@ bash_history_enable ()
#if defined (BANG_HISTORY)
history_expansion_inhibited = 0;
#endif
history_inhibit_expansion_function = bash_history_inhibit_expansion;
sv_history_control ("HISTCONTROL");
sv_histignore ("HISTIGNORE");
}
@ -211,6 +244,7 @@ load_history ()
}
}
#ifdef INCLUDE_UNUSED
/* Write the existing history out to the history file. */
void
save_history ()
@ -233,6 +267,7 @@ save_history ()
sv_histsize ("HISTFILESIZE");
}
}
#endif
int
maybe_append_history (filename)
@ -365,7 +400,11 @@ pre_process_line (line, print_changes, addit)
{
if (expanded < 0)
internal_error (history_value);
#if defined (READLINE)
else if (hist_verify == 0)
#else
else
#endif
fprintf (stderr, "%s\n", history_value);
}
@ -403,8 +442,10 @@ pre_process_line (line, print_changes, addit)
if (addit && remember_on_history && *return_value)
maybe_add_history (return_value);
#if 0
if (expanded == 0)
return_value = savestring (line);
#endif
return (return_value);
}
@ -417,7 +458,7 @@ maybe_add_history (line)
int should_add;
HIST_ENTRY *temp;
should_add = 0;
should_add = hist_last_line_added = 0;
/* Don't use the value of history_control to affect the second
and subsequent lines of a multi-line command when
@ -461,7 +502,7 @@ maybe_add_history (line)
remembering; when non-zero, and LINE is not the first line of a
complete parser construct, append LINE to the last history line instead
of adding it as a new line. */
static void
void
bash_add_history (line)
char *line;
{
@ -512,6 +553,7 @@ bash_add_history (line)
if (add_it)
{
hist_last_line_added = 1;
add_history (line);
history_lines_this_session++;
}

View File

@ -27,6 +27,7 @@ extern int history_lines_in_file;
extern int history_expansion;
extern int history_control;
extern int command_oriented_history;
extern int hist_last_line_added;
# if defined (BANG_HISTORY)
extern int history_expansion_inhibited;
@ -43,6 +44,7 @@ extern int maybe_save_shell_history ();
extern char *pre_process_line ();
extern int history_number ();
extern void maybe_add_history ();
extern void bash_add_history ();
extern void setup_history_ignore ();

View File

@ -3,19 +3,7 @@
#ifndef _BASHJMP_H_
#define _BASHJMP_H_
#include <setjmp.h>
/* This *must* be included *after* config.h */
#if defined (HAVE_POSIX_SIGSETJMP)
# define procenv_t sigjmp_buf
# undef setjmp
# define setjmp(x) sigsetjmp((x), 1)
# undef longjmp
# define longjmp(x, n) siglongjmp((x), (n))
#else
# define procenv_t jmp_buf
#endif
#include "posixjmp.h"
extern procenv_t top_level;
extern procenv_t subshell_top_level;

View File

@ -56,6 +56,11 @@ extern void bash_brace_completion ();
static void shell_expand_line ();
static void display_shell_version (), operate_and_get_next ();
static void history_expand_line (), bash_ignore_filenames ();
#ifdef ALIAS
static void alias_expand_line ();
#endif
static void history_and_alias_expand_line ();
static void cleanup_expansion_error (), set_up_new_line ();
/* Helper functions for Readline. */
static int bash_directory_completion_hook ();
@ -194,6 +199,11 @@ initialize_readline ()
rl_add_defun ("history-expand-line", (Function *)history_expand_line, -1);
rl_bind_key_in_map ('^', (Function *)history_expand_line, emacs_meta_keymap);
#ifdef ALIAS
rl_add_defun ("alias-expand-line", (Function *)alias_expand_line, -1);
rl_add_defun ("history-and-alias-expand-line", (Function *)history_and_alias_expand_line, -1);
#endif
/* Backwards compatibility. */
rl_add_defun ("insert-last-argument", rl_yank_last_arg, -1);
@ -285,7 +295,7 @@ initialize_readline ()
enable_hostname_completion (perform_hostname_completion);
/* characters that need to be quoted when appearing in filenames. */
rl_filename_quote_characters = " \t\n\\\"'@<>=;|&()#$`?*[!";
rl_filename_quote_characters = " \t\n\\\"'@<>=;|&()#$`?*[!:";
rl_filename_quoting_function = bash_quote_filename;
rl_filename_dequoting_function = bash_dequote_filename;
rl_char_is_quoted_p = char_is_quoted;
@ -592,13 +602,13 @@ vi_edit_and_execute_command (count, c)
the end of the history because fc ignores the last command (assumes
it's supposed to deal with the command before the `fc'). */
using_history ();
add_history (rl_line_buffer);
add_history ("");
bash_add_history (rl_line_buffer);
bash_add_history ("");
history_lines_this_session++;
using_history ();
command = savestring (VI_EDIT_COMMAND);
}
parse_and_execute (command, "v", -1);
parse_and_execute (command, "v", SEVAL_NOHIST);
rl_line_buffer[0] = '\0'; /* XXX */
}
#endif /* VI_MODE */
@ -688,8 +698,18 @@ attempt_shell_completion (text, start, end)
assignments. */
}
/* Special handling for command substitution. */
if (*text == '`' && unclosed_pair (rl_line_buffer, start, "`"))
/* Check that we haven't incorrectly flagged a closed command substitution
as indicating we're in a command position. */
if (in_command_position && rl_line_buffer[ti] == '`' && *text != '`' &&
unclosed_pair (rl_line_buffer, 0, "`") == 0)
in_command_position = 0;
/* Special handling for command substitution. If *TEXT is a backquote,
it can be the start or end of an old-style command substitution, or
unmatched. If it's unmatched, both calls to unclosed_pair will
succeed. */
if (*text == '`' && unclosed_pair (rl_line_buffer, start, "`") &&
unclosed_pair (rl_line_buffer, end, "`"))
matches = completion_matches (text, command_subst_completion_function);
/* Variable name? */
@ -928,7 +948,7 @@ command_word_completion_function (hint_text, state)
}
else
{
int match;
int match, freetemp;
char *temp;
if (absolute_program (hint))
@ -948,6 +968,7 @@ command_word_completion_function (hint_text, state)
}
else
temp = savestring (val);
freetemp = 1;
}
else
{
@ -956,12 +977,12 @@ command_word_completion_function (hint_text, state)
if (temp)
{
temp++;
match = strncmp (temp, hint, hint_len) == 0;
freetemp = match = strncmp (temp, hint, hint_len) == 0;
if (match)
temp = savestring (temp);
}
else
match = 0;
freetemp = match = 0;
}
/* If we have found a match, and it is an executable file or a
@ -974,12 +995,15 @@ command_word_completion_function (hint_text, state)
}
else
{
if (freetemp)
free (temp);
free (val);
goto inner;
}
}
}
/* Completion inside an unterminated command substitution. */
static char *
command_subst_completion_function (text, state)
char *text;
@ -1148,19 +1172,23 @@ history_expand_line_internal (line)
char *new_line;
new_line = pre_process_line (line, 0, 0);
return new_line;
return (new_line == line) ? savestring (line) : new_line;
}
#if defined (ALIAS)
/* Perform alias expansion on LINE and return the new line. */
static char *
alias_expand_line_internal (line)
char *line;
/* Expand aliases in the current readline line. */
static void
alias_expand_line (ignore)
int ignore;
{
char *alias_line;
char *new_line;
alias_line = alias_expand (line);
return alias_line;
new_line = alias_expand (rl_line_buffer);
if (new_line)
set_up_new_line (new_line);
else
cleanup_expansion_error ();
}
#endif
@ -1173,7 +1201,8 @@ cleanup_expansion_error ()
fprintf (rl_outstream, "\r\n");
to_free = pre_process_line (rl_line_buffer, 1, 0);
free (to_free);
if (to_free != rl_line_buffer)
free (to_free);
putc ('\r', rl_outstream);
rl_forced_update_display ();
}
@ -1244,6 +1273,8 @@ history_and_alias_expand_line (ignore)
char *new_line;
new_line = pre_process_line (rl_line_buffer, 0, 0);
if (new_line == rl_line_buffer)
new_line = savestring (new_line);
#if defined (ALIAS)
if (new_line)
@ -1272,6 +1303,8 @@ shell_expand_line (ignore)
WORD_LIST *expanded_string;
new_line = pre_process_line (rl_line_buffer, 0, 0);
if (new_line == rl_line_buffer)
new_line = savestring (new_line);
#if defined (ALIAS)
if (new_line)
@ -1296,7 +1329,9 @@ shell_expand_line (ignore)
/* If there is variable expansion to perform, do that as a separate
operation to be undone. */
expanded_string = expand_string (rl_line_buffer, 0);
new_line = savestring (rl_line_buffer);
expanded_string = expand_string (new_line, 0);
FREE (new_line);
if (expanded_string == 0)
{
new_line = xmalloc (1);
@ -1862,7 +1897,44 @@ bash_dequote_filename (text, quote_char)
return ret;
}
/* Quote a filename using double quotes. */
/* Quote characters that the readline completion code would treat as
word break characters with backslashes. Pass backslash-quoted
characters through without examination. */
static char *
quote_word_break_chars (text)
char *text;
{
char *ret, *r, *s;
int l;
l = strlen (text);
ret = xmalloc ((2 * l) + 1);
for (s = text, r = ret; *s; s++)
{
/* Pass backslash-quoted characters through, including the backslash. */
if (*s == '\\')
{
*r++ = '\\';
*r++ = *++s;
if (*s == '\0')
break;
continue;
}
/* OK, we have an unquoted character. Check its presence in
rl_completer_word_break_characters. */
if (strchr (rl_completer_word_break_characters, *s))
*r++ = '\\';
*r++ = *s;
}
*r = '\0';
return ret;
}
/* Quote a filename using double quotes, single quotes, or backslashes
depending on the value of completion_quoting_style. If we're
completing using backslashes, we need to quote some additional
characters (those that readline treats as word breaks), so we call
quote_word_break_chars on the result. */
static char *
bash_quote_filename (s, rtype, qcp)
char *s;
@ -1896,6 +1968,13 @@ bash_quote_filename (s, rtype, qcp)
else if (*qcp == '\0' && history_expansion && cs == COMPLETE_DQUOTE &&
history_expansion_inhibited == 0 && strchr (mtext, '!'))
cs = COMPLETE_BSQUOTE;
if (*qcp == '"' && history_expansion && cs == COMPLETE_DQUOTE &&
history_expansion_inhibited == 0 && strchr (mtext, '!'))
{
cs = COMPLETE_BSQUOTE;
*qcp = '\0';
}
#endif
switch (cs)
@ -1914,6 +1993,15 @@ bash_quote_filename (s, rtype, qcp)
if (mtext != s)
free (mtext);
/* We may need to quote additional characters: those that readline treats
as word breaks that are not quoted by backslash_quote. */
if (rtext && cs == COMPLETE_BSQUOTE)
{
mtext = quote_word_break_chars (rtext);
free (rtext);
rtext = mtext;
}
/* Leave the opening quote intact. The readline completion code takes
care of avoiding doubled opening quotes. */
rlen = strlen (rtext);

View File

@ -31,11 +31,7 @@
# include <unistd.h>
#endif
#if defined (HAVE_STRING_H)
# include <string.h>
#else /* !HAVE_STRING_H */
# include <strings.h>
#endif /* !HAVE_STRING_H */
#include "bashansi.h"
#include "shell.h"
#include <readline/readline.h>
@ -103,7 +99,7 @@ really_munge_braces (array, real_start, real_end, gcd_zero)
top level, and there isn't a consistent prefix. */
result_size += 1;
result = xrealloc (result, result_size);
strcpy (result, "{");
result[0] = '{'; result[1] = '\0';
flag++;
}

View File

@ -28,11 +28,7 @@
# include <unistd.h>
#endif
#if defined (HAVE_STRING_H)
# include <string.h>
#else /* !HAVE_STRING_H */
# include <strings.h>
#endif /* !HAVE_STRING_H */
#include "bashansi.h"
#if defined (SHELL)
# include "shell.h"
@ -41,6 +37,10 @@
#include "general.h"
#define brace_whitespace(c) (!(c) || (c) == ' ' || (c) == '\t' || (c) == '\n')
#if defined (SHELL)
extern char *extract_command_subst ();
#endif
/* Basic idea:
Segregate the text into 3 sections: preamble (stuff before an open brace),
@ -210,6 +210,10 @@ brace_gobbler (text, indx, satisfy)
int satisfy;
{
register int i, c, quoted, level, pass_next;
#if defined (SHELL)
int si;
char *t;
#endif
level = quoted = pass_next = 0;
@ -242,6 +246,18 @@ brace_gobbler (text, indx, satisfy)
continue;
}
#if defined (SHELL)
/* Pass new-style command substitutions through unchanged. */
if (c == '$' && text[i+1] == '(') /* ) */
{
si = i + 2;
t = extract_command_subst (text, &si);
i = si;
free (t);
continue;
}
#endif
if (c == satisfy && level == 0 && quoted == 0)
{
/* We ignore an open brace surrounded by whitespace, and also

View File

@ -1,29 +1,31 @@
# This Makefile for building libbuiltins.a is in -*- text -*- for Emacs.
#
MKBUILTINS = mkbuiltins
RANLIB = @RANLIB@
CFLAGS = @CFLAGS@
LOCAL_CFLAGS = @LOCAL_CFLAGS@
CPPFLAGS = @CPPFLAGS@
SHELL = /bin/sh
RANLIB = @RANLIB@
CC = @CC@
AR = @AR@
RM = rm -f
CP = cp
LIBS = @LIBS@
srcdir = @srcdir@
VPATH = .:@srcdir@
topdir = @top_srcdir@
includedir = @includedir@
PROFILE_FLAGS =
CFLAGS = @CFLAGS@
LOCAL_CFLAGS = @LOCAL_CFLAGS@
CPPFLAGS = @CPPFLAGS@
DEFS = @DEFS@
LOCAL_DEFS = @LOCAL_DEFS@
LIBS = @LIBS@
INCLUDES = -I. -I.. -I$(topdir) -I$(topdir)/lib -I$(srcdir)
CCFLAGS = $(DEFS) $(SYSTEM_FLAGS) $(CPPFLAGS) ${INCLUDES} $(LOCAL_CFLAGS) $(CFLAGS)
CCFLAGS = ${PROFILE_FLAGS} $(DEFS) $(LOCAL_DEFS) $(SYSTEM_FLAGS) $(CPPFLAGS) \
${INCLUDES} $(LOCAL_CFLAGS) $(CFLAGS)
MKBUILTINS = mkbuiltins
DIRECTDEFINE = -D $(srcdir)
# xxx this is bad style
@ -158,13 +160,57 @@ wait.o: wait.def
getopts.o: getopts.def
reserved.o: reserved.def
common.o: $(topdir)/shell.h $(topdir)/command.h ../config.h
common.o: $(topdir)/memalloc.h $(topdir)/general.h
common.o: $(topdir)/variables.h $(topdir)/input.h $(srcdir)/hashcom.h
common.o: $(topdir)/bashhist.h $(topdir)/quit.h $(topdir)/unwind_prot.h
common.o: $(topdir)/maxpath.h $(topdir)/jobs.h $(topdir)/builtins.h
common.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
common.o: $(topdir)/execute_cmd.h $(topdir)/error.h $(topdir)/externs.h
# C files
bashgetopt.o: ../config.h $(topdir)/bashansi.h $(topdir)/ansi_stdlib.h
bashgetopt.o: $(topdir)/shell.h $(topdir)/bashjmp.h
bashgetopt.o: $(topdir)/command.h $(topdir)/general.h $(topdir)/error.h
bashgetopt.o: $(topdir)/variables.h $(topdir)/quit.h $(topdir)/maxpath.h
bashgetopt.o: $(topdir)/unwind_prot.h $(topdir)/dispose_cmd.h
bashgetopt.o: $(topdir)/make_cmd.h $(topdir)/subst.h $(topdir)/sig.h
bashgetopt.o: $(topdir)/pathnames.h $(topdir)/externs.h $(srcdir)/common.h
common.o: $(topdir)/bashtypes.h $(topdir)/posixstat.h $(topdir)/bashansi.h $(topdir)/ansi_stdlib.h
common.o: $(topdir)/shell.h ../config.h $(topdir)/bashjmp.h $(topdir)/posixjmp.h
common.o: $(topdir)/sig.h $(topdir)/command.h
common.o: $(topdir)/general.h $(topdir)/stdc.h $(topdir)/memalloc.h
common.o: $(topdir)/variables.h $(topdir)/input.h
common.o: $(topdir)/siglist.h $(topdir)/bashhist.h $(topdir)/quit.h
common.o: $(topdir)/unwind_prot.h $(topdir)/maxpath.h $(topdir)/jobs.h
common.o: $(topdir)/builtins.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
common.o: $(topdir)/subst.h $(topdir)/execute_cmd.h $(topdir)/error.h
common.o: $(topdir)/externs.h $(topdir)/pathnames.h ./builtext.h
evalfile.o: $(topdir)/bashtypes.h $(topdir)/posixstat.h $(topdir)/filecntl.h
evalfile.o: $(topdir)/bashansi.h $(topdir)/ansi_stdlib.h
evalfile.o: $(topdir)/shell.h ../config.h $(topdir)/bashjmp.h
evalfile.o: $(topdir)/command.h $(topdir)/general.h $(topdir)/error.h
evalfile.o: $(topdir)/variables.h $(topdir)/quit.h $(topdir)/maxpath.h
evalfile.o: $(topdir)/unwind_prot.h $(topdir)/dispose_cmd.h
evalfile.o: $(topdir)/make_cmd.h $(topdir)/subst.h $(topdir)/sig.h
evalfile.o: $(topdir)/pathnames.h $(topdir)/externs.h
evalfile.o: $(topdir)/jobs.h $(topdir)/builtins.h $(topdir)/flags.h
evalfile.o: $(topdir)/input.h $(topdir)/execute_cmd.h
evalfile.o: $(topdir)/bashhist.h $(srcdir)/common.h
evalstring.o: ../config.h $(topdir)/bashansi.h $(topdir)/ansi_stdlib.h
evalstring.o: $(topdir)/shell.h $(topdir)/bashjmp.h $(topdir)/posixjmp.h
evalstring.o: $(topdir)/sig.h $(topdir)/command.h $(topdir)/siglist.h
evalstring.o: $(topdir)/memalloc.h $(topdir)/variables.h $(topdir)/input.h
evalstring.o: $(topdir)/quit.h $(topdir)/unwind_prot.h
evalstring.o: $(topdir)/maxpath.h $(topdir)/jobs.h $(topdir)/builtins.h
evalstring.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
evalstring.o: $(topdir)/externs.h $(topdir)/jobs.h $(topdir)/builtins.h
evalstring.o: $(topdir)/flags.h $(topdir)/input.h $(topdir)/execute_cmd.h
evalstring.o: $(topdir)/bashhist.h $(srcdir)/common.h
getopt.o: ../config.h $(topdir)/memalloc.h
getopt.o: $(topdir)/shell.h $(topdir)/bashjmp.h $(topdir)/command.h
getopt.o: $(topdir)/general.h $(topdir)/error.h $(topdir)/variables.h
getopt.o: $(topdir)/quit.h $(topdir)/maxpath.h $(topdir)/unwind_prot.h
getopt.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
getopt.o: $(topdir)/sig.h $(topdir)/pathnames.h $(topdir)/externs.h
getopt.o: $(srcdir)/getopt.h
mkbuiltins.o: ../config.h $(topdir)/bashtypes.h $(topdir)/posixstat.h
mkbuiltins.o: $(topdir)/filecntl.h
mkbuiltins.o: $(topdir)/bashansi.h $(topdir)/ansi_stdlib.h
# def files
alias.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
alias.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/maxpath.h
alias.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
@ -217,18 +263,21 @@ eval.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
eval.o: $(topdir)/subst.h $(topdir)/externs.h
eval.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
eval.o: $(topdir)/maxpath.h
exec.o: $(topdir)/bashtypes.h
exec.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
exec.o: $(topdir)/error.h $(topdir)/general.h
exec.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
exec.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/flags.h
exec.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
exec.o: $(srcdir)/common.h $(topdir)/execute_cmd.h $(topdir)/maxpath.h
exit.o: $(topdir)/bashtypes.h
exit.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
exit.o: $(topdir)/error.h $(topdir)/general.h
exit.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
exit.o: $(topdir)/subst.h $(topdir)/externs.h
exit.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
exit.o: $(topdir)/maxpath.h
exit.o: $(topdir)/maxpath.h ./builtext.h
fc.o: $(topdir)/bashtypes.h $(topdir)/posixstat.h
fc.o: $(topdir)/builtins.h $(topdir)/command.h $(srcdir)/bashgetopt.h
fc.o: $(topdir)/bashhist.h
fc.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h $(topdir)/error.h
@ -236,6 +285,8 @@ fc.o: $(topdir)/general.h $(topdir)/maxpath.h
fc.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
fc.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/shell.h
fc.o: $(topdir)/flags.h $(topdir)/unwind_prot.h $(topdir)/variables.h
fc.o: $(topdir)/bashansi.h $(topdir)/ansi_stdlib.h
fg_bg.o: $(topdir)/bashtypes.h
fg_bg.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
fg_bg.o: $(topdir)/error.h $(topdir)/general.h
fg_bg.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
@ -257,6 +308,7 @@ help.o: $(topdir)/error.h $(topdir)/general.h
help.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
help.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/maxpath.h
help.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
history.o: $(topdir)/bashtypes.h
history.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
history.o: $(topdir)/error.h $(topdir)/general.h
history.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
@ -288,7 +340,7 @@ pushd.o: $(topdir)/error.h $(topdir)/general.h
pushd.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
pushd.o: $(topdir)/subst.h $(topdir)/externs.h
pushd.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
pushd.o: $(topdir)/maxpath.h $(srcdir)/common.h
pushd.o: $(topdir)/maxpath.h $(srcdir)/common.h ./builtext.h
read.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
read.o: $(topdir)/error.h $(topdir)/general.h
read.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
@ -345,7 +397,7 @@ type.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
type.o: $(topdir)/error.h $(topdir)/general.h
type.o: $(topdir)/quit.h $(srcdir)/common.h $(topdir)/maxpath.h
type.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
type.o: $(topdir)/externs.h
type.o: $(topdir)/externs.h $(topdir)/hashcmd.h
type.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
ulimit.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
ulimit.o: $(topdir)/error.h $(topdir)/general.h
@ -368,8 +420,5 @@ shopt.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
shopt.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/maxpath.h
shopt.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
shopt.o: $(srcdir)/common.h $(srcdir)/bashgetopt.h
bashgetopt.o: $(topdir)/bashansi.h $(topdir)/ansi_stdlib.h
mkbuiltins.o: $(topdir)/bashansi.h $(topdir)/ansi_stdlib.h
fc.o: $(topdir)/bashansi.h $(topdir)/ansi_stdlib.h
#bind.o: $(RL_LIBSRC)chardefs.h $(RL_LIBSRC)readline.h $(RL_LIBSRC)keymaps.h

View File

@ -40,6 +40,8 @@ $END
# include <unistd.h>
#endif
# include "../bashansi.h"
# include <stdio.h>
# include "../shell.h"
# include "../alias.h"

View File

@ -57,13 +57,17 @@ break_builtin (list)
{
int newbreak;
if (!check_loop_level ())
if (check_loop_level () == 0)
return (EXECUTION_FAILURE);
newbreak = get_numeric_arg (list);
newbreak = get_numeric_arg (list, 1);
if (newbreak <= 0)
return (EXECUTION_FAILURE);
{
builtin_error ("loop count must be > 0");
breaking = loop_level;
return (EXECUTION_FAILURE);
}
if (newbreak > loop_level)
newbreak = loop_level;
@ -88,13 +92,17 @@ continue_builtin (list)
{
int newcont;
if (!check_loop_level ())
if (check_loop_level () == 0)
return (EXECUTION_FAILURE);
newcont = get_numeric_arg (list);
newcont = get_numeric_arg (list, 1);
if (newcont <= 0)
return (EXECUTION_FAILURE);
{
builtin_error ("loop count must be > 0");
breaking = loop_level;
return (EXECUTION_FAILURE);
}
if (newcont > loop_level)
newcont = loop_level;
@ -110,7 +118,7 @@ static int
check_loop_level ()
{
#if defined (BREAK_COMPLAINS)
if (!loop_level)
if (loop_level == 0)
builtin_error ("only meaningful in a `for', `while', or `until' loop");
#endif /* BREAK_COMPLAINS */

View File

@ -49,13 +49,16 @@ extern int errno;
#endif /* !errno */
extern int posixly_correct, interactive;
extern int array_needs_making;
extern char *bash_getcwd_errstr;
static int change_to_directory ();
static char *cdspell ();
static int spname (), mindist (), spdist ();
int cdspelling = 1;
/* Change this to 1 to get cd spelling correction by default. */
int cdspelling = 0;
int cdable_vars;
@ -118,8 +121,9 @@ static int
bindpwd (no_symlinks)
int no_symlinks;
{
char *dirname;
int old_symlinks;
char *dirname, *pwdvar;
int old_symlinks, old_anm;
SHELL_VAR *tvar;
if (no_symlinks)
{
@ -132,7 +136,22 @@ bindpwd (no_symlinks)
dirname = get_working_directory ("cd");
bind_variable ("OLDPWD", get_string_value ("PWD"));
bind_variable ("PWD", dirname);
old_anm = array_needs_making;
tvar = bind_variable ("PWD", dirname);
/* This is an efficiency hack. If PWD is exported, we will need to
remake the exported environment every time we change directories.
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))
{
pwdvar = xmalloc (strlen (dirname) + 5); /* 5 = "PWD" + '=' + '\0' */
strcpy (pwdvar, "PWD=");
strcpy (pwdvar + 4, dirname);
add_or_supercede_exported_var (pwdvar, 0);
array_needs_making = 0;
}
FREE (dirname);
return (EXECUTION_SUCCESS);
@ -547,6 +566,9 @@ mindist(dir, guess, best)
}
(void)closedir(fd);
/* Don't return `.' */
if (best[0] == '.' && best[1] == '\0')
dist = 3;
return dist;
}

View File

@ -117,13 +117,10 @@ command_builtin (list)
if (use_standard_path)
{
old_path = get_string_value ("PATH");
/* If old_path is NULL, $PATH is unset. If so, we want to make sure
it's unset after this command completes. */
if (old_path)
old_path = savestring (old_path);
else
{
old_path = xmalloc (1);
old_path[0] = '\0';
}
add_unwind_protect ((Function *)restore_path, old_path);
standard_path = get_standard_path ();
@ -162,8 +159,13 @@ static void
restore_path (var)
char *var;
{
bind_variable ("PATH", var);
free (var);
if (var)
{
bind_variable ("PATH", var);
free (var);
}
else
unbind_variable ("PATH");
}
/* Return a value for PATH that is guaranteed to find all of the standard

View File

@ -23,7 +23,7 @@
#endif
#include <stdio.h>
#include <sys/types.h>
#include "../bashtypes.h"
#include "../posixstat.h"
#include <signal.h>
@ -45,9 +45,9 @@
#include "../input.h"
#include "../execute_cmd.h"
#include "../trap.h"
#include "hashcom.h"
#include "bashgetopt.h"
#include "common.h"
#include "builtext.h"
#include <tilde/tilde.h>
#if defined (HISTORY)
@ -59,14 +59,16 @@ extern int indirection_level, startup_state, subshell_environment;
extern int line_number;
extern int last_command_exit_value;
extern int running_trap;
extern int hashing_enabled;
extern int variable_context;
extern int posixly_correct;
extern char *this_command_name, *shell_name;
extern COMMAND *global_command;
extern HASH_TABLE *hashed_filenames;
extern char *bash_getcwd_errstr;
/* Used by some builtins and the mainline code. */
Function *last_shell_builtin = (Function *)NULL;
Function *this_shell_builtin = (Function *)NULL;
/* **************************************************************** */
/* */
/* Error reporting, usage, and option processing */
@ -317,10 +319,13 @@ set_dollar_vars_changed ()
/* Read a numeric arg for this_command_name, the name of the shell builtin
that wants it. LIST is the word list that the arg is to come from.
Accept only the numeric argument; report an error if other arguments
follow. */
follow. If FATAL is true, call throw_to_top_level, which exits the
shell; if not, call jump_to_top_level (DISCARD), which aborts the
current command. */
int
get_numeric_arg (list)
get_numeric_arg (list, fatal)
WORD_LIST *list;
int fatal;
{
long count = 1;
@ -332,7 +337,10 @@ get_numeric_arg (list)
if (!arg || (legal_number (arg, &count) == 0))
{
builtin_error ("bad non-numeric arg `%s'", list->word->word);
throw_to_top_level ();
if (fatal)
throw_to_top_level ();
else
jump_to_top_level (DISCARD);
}
no_args (list->next);
}
@ -360,80 +368,6 @@ read_octal (string)
return (result);
}
/* **************************************************************** */
/* */
/* Command name hashing */
/* */
/* **************************************************************** */
/* Return the full pathname that FILENAME hashes to. If FILENAME
is hashed, but (data->flags & HASH_CHKDOT) is non-zero, check
./FILENAME and return that if it is executable. */
char *
find_hashed_filename (filename)
char *filename;
{
register BUCKET_CONTENTS *item;
char *path, *dotted_filename, *tail;
int same;
if (hashing_enabled == 0)
return ((char *)NULL);
item = find_hash_item (filename, hashed_filenames);
if (item == NULL)
return ((char *)NULL);
/* If this filename is hashed, but `.' comes before it in the path,
see if ./filename is executable. If the hashed value is not an
absolute pathname, see if ./`hashed-value' exists. */
path = pathdata(item)->path;
if (pathdata(item)->flags & (HASH_CHKDOT|HASH_RELPATH))
{
tail = (pathdata(item)->flags & HASH_RELPATH) ? path : filename;
dotted_filename = xmalloc (3 + strlen (tail));
dotted_filename[0] = '.'; dotted_filename[1] = '/';
strcpy (dotted_filename + 2, tail);
if (executable_file (dotted_filename))
return (dotted_filename);
free (dotted_filename);
#if 0
if (pathdata(item)->flags & HASH_RELPATH)
return ((char *)NULL);
#endif
/* Watch out. If this file was hashed to "./filename", and
"./filename" is not executable, then return NULL. */
/* Since we already know "./filename" is not executable, what
we're really interested in is whether or not the `path'
portion of the hashed filename is equivalent to the current
directory, but only if it starts with a `.'. (This catches
./. and so on.) same_file () tests general Unix file
equivalence -- same device and inode. */
if (*path == '.')
{
same = 0;
tail = (char *)strrchr (path, '/');
if (tail)
{
*tail = '\0';
same = same_file (".", path, (struct stat *)NULL, (struct stat *)NULL);
*tail = '/';
}
return same ? (char *)NULL : path;
}
}
return (path);
}
/* **************************************************************** */
/* */
/* Manipulating the current working directory */
@ -635,7 +569,13 @@ display_signal_list (list, forcecols)
list = list->next;
continue;
}
#if defined (JOB_CONTROL)
/* POSIX.2 says that `kill -l signum' prints the signal name without
the `SIG' prefix. */
printf ("%s\n", (this_shell_builtin == kill_builtin) ? name + 3 : name);
#else
printf ("%s\n", name);
#endif
}
else
{
@ -852,6 +792,9 @@ backslash_quote (string)
*r++ = c;
break;
case '#': /* comment char */
#if 0
case '~': /* tilde expansion */
#endif
if (s == string)
*r++ = '\\';
/* FALLTHROUGH */

View File

@ -25,6 +25,11 @@
#define ISOPTION(s, c) (s[0] == '-' && !s[2] && s[1] == c)
/* Flag values for parse_and_execute () */
#define SEVAL_NONINT 0x01
#define SEVAL_INTERACT 0x02
#define SEVAL_NOHIST 0x04
extern void builtin_error __P((const char *, ...));
extern void builtin_usage ();
extern void bad_option ();
@ -69,18 +74,15 @@ extern char *double_quote ();
extern char *backslash_quote ();
extern int contains_shell_metas ();
/* Functions from hash.def */
extern void initialize_filename_hashing ();
extern void flush_hashed_filenames ();
extern char *find_hashed_filename ();
extern void remove_hashed_filename ();
extern void remember_filename ();
/* Functions from set.def */
extern void initialize_shell_options ();
extern void list_minus_o_opts ();
extern int set_minus_o_option ();
extern int minus_o_option_value ();
extern void reset_shell_options ();
/* Functions from shopt.def */
extern void reset_shopt_options ();
/* Functions from type.def */
extern int describe_command ();

View File

@ -268,7 +268,8 @@ declare_internal (list, local_var)
{
if (offset) /* declare -f [-rix] foo=bar */
{
builtin_error ("Can't use `-f' to make functions");
builtin_error ("cannot use `-f' to make functions");
free (name);
return (EXECUTION_FAILURE);
}
else /* declare -f [-rx] name [name...] */

View File

@ -26,6 +26,8 @@ $PRODUCES echo.c
# include <unistd.h>
#endif
#include "../bashansi.h"
#include <stdio.h>
#include "../shell.h"
@ -72,8 +74,8 @@ int
echo_builtin (list)
WORD_LIST *list;
{
int display_return, do_v9, i;
char *temp;
int display_return, do_v9, i, len;
char *temp, *s;
#if defined (DEFAULT_ECHO_TO_USG)
/* System V machines already have a /bin/sh with a v9 behaviour. We
@ -130,13 +132,21 @@ just_echo:
while (list)
{
i = 0;
temp = do_v9 ? ansicstr (list->word->word, STRLEN (list->word->word), &i)
i = len = 0;
temp = do_v9 ? ansicstr (list->word->word, STRLEN (list->word->word), &i, &len)
: list->word->word;
if (temp)
{
printf ("%s", temp);
if (do_v9)
{
for (s = temp; len > 0; len--)
putchar (*s++);
}
else
printf ("%s", temp);
#if defined (SunOS5)
fflush (stdout); /* Fix for bug in SunOS 5.5 printf(3) */
#endif
}
if (do_v9 && temp)
free (temp);

View File

@ -238,7 +238,10 @@ enable_shell_command (name, disable_p)
}
#if defined (HAVE_DLOPEN) && defined (HAVE_DLSYM)
#include <dlfcn.h>
#if defined (HAVE_DLFCN_H)
# include <dlfcn.h>
#endif
static int
dyn_load_builtin (list, flags, filename)
@ -359,7 +362,11 @@ delete_builtin (b)
struct builtin *new_shell_builtins;
/* XXX - funky pointer arithmetic - XXX */
#ifdef __STDC__
ind = b - shell_builtins;
#else
ind = ((int)b - (int)shell_builtins) / sizeof (struct builtin);
#endif
size = num_shell_builtins * sizeof (struct builtin);
new_shell_builtins = (struct builtin *)xmalloc (size);

View File

@ -34,8 +34,7 @@ $END
#include "../shell.h"
#include "bashgetopt.h"
extern int parse_and_execute ();
#include "common.h"
/* Parse the string that these words make, and execute the command found. */
int
@ -46,5 +45,5 @@ eval_builtin (list)
return (EX_USAGE);
/* Note that parse_and_execute () frees the string it is passed. */
return (list ? parse_and_execute (string_list (list), "eval", -1) : EXECUTION_SUCCESS);
return (list ? parse_and_execute (string_list (list), "eval", SEVAL_NOHIST) : EXECUTION_SUCCESS);
}

View File

@ -22,7 +22,7 @@
# include <unistd.h>
#endif
#include <sys/types.h>
#include "../bashtypes.h"
#include "../posixstat.h"
#include "../filecntl.h"
@ -55,6 +55,7 @@ extern int errno;
#define FEVAL_UNWINDPROT 0x004
#define FEVAL_NONINT 0x008
#define FEVAL_LONGJMP 0x010
#define FEVAL_HISTORY 0x020
extern int interactive, interactive_shell, posixly_correct;
extern int indirection_level, startup_state, subshell_environment;
@ -71,7 +72,7 @@ _evalfile (filename, flags)
{
volatile int old_interactive;
procenv_t old_return_catch;
int return_val, fd, result;
int return_val, fd, result, pflags;
char *string;
struct stat finfo;
VFunction *errfunc;
@ -151,6 +152,9 @@ file_error_and_exit:
return_catch_flag++;
sourcelevel++;
/* set the flags to be passed to parse_and_execute */
pflags = (flags & FEVAL_HISTORY) ? 0 : SEVAL_NOHIST;
if (flags & FEVAL_BUILTIN)
result = EXECUTION_SUCCESS;
@ -164,7 +168,7 @@ file_error_and_exit:
result = return_catch_value;
}
else
result = parse_and_execute (string, filename, -1);
result = parse_and_execute (string, filename, pflags);
if (flags & FEVAL_UNWINDPROT)
run_unwind_frame ("_evalfile");
@ -197,6 +201,20 @@ maybe_execute_file (fname, force_noninteractive)
return result;
}
#if defined (HISTORY)
int
fc_execute_file (filename)
char *filename;
{
int flags;
/* We want these commands to show up in the history list if
remember_on_history is set. */
flags = FEVAL_ENOENTOK|FEVAL_HISTORY;
return (_evalfile (filename, flags));
}
#endif /* HISTORY */
int
source_file (filename)
char *filename;

View File

@ -40,6 +40,8 @@
#include "common.h"
extern void run_trap_cleanup ();
extern int interactive, interactive_shell;
extern int indirection_level, startup_state, subshell_environment;
extern int line_number;
@ -62,14 +64,19 @@ parse_and_execute_cleanup ()
}
/* Parse and execute the commands in STRING. Returns whatever
execute_command () returns. This frees STRING. INTERACT is
the new value for `interactive' while the commands are being
executed. A value of -1 means don't change it. */
execute_command () returns. This frees STRING. FLAGS is a
flags word; look in common.h for the possible values. Actions
are:
(flags & SEVAL_NONINT) -> interactive = 0;
(flags & SEVAL_INTERACT) -> interactive = 1;
(flags & SEVAL_NOHIST) -> call bash_history_disable ()
*/
int
parse_and_execute (string, from_file, interact)
parse_and_execute (string, from_file, flags)
char *string;
char *from_file;
int interact;
int flags;
{
int code;
volatile int should_jump_to_top_level, last_result;
@ -83,17 +90,17 @@ parse_and_execute (string, from_file, interact)
unwind_protect_jmp_buf (top_level);
unwind_protect_int (indirection_level);
unwind_protect_int (line_number);
if (interact != -1 && interactive != interact)
if (flags & (SEVAL_NONINT|SEVAL_INTERACT))
unwind_protect_int (interactive);
#if defined (HISTORY)
unwind_protect_int (remember_on_history); /* can be used in scripts */
# if defined (BANG_HISTORY)
if (interactive_shell)
{
unwind_protect_int (remember_on_history);
# if defined (BANG_HISTORY)
unwind_protect_int (history_expansion_inhibited);
# endif /* BANG_HISTORY */
}
# endif /* BANG_HISTORY */
#endif /* HISTORY */
add_unwind_protect (pop_stream, (char *)NULL);
@ -104,11 +111,12 @@ parse_and_execute (string, from_file, interact)
parse_and_execute_level++;
push_stream (1); /* reset the line number */
indirection_level++;
if (interact != -1)
interactive = interact;
if (flags & (SEVAL_NONINT|SEVAL_INTERACT))
interactive = (flags & SEVAL_NONINT) ? 0 : 1;
#if defined (HISTORY)
bash_history_disable ();
if (flags & SEVAL_NOHIST)
bash_history_disable ();
#endif /* HISTORY */
code = should_jump_to_top_level = 0;
@ -177,6 +185,7 @@ parse_and_execute (string, from_file, interact)
bitmap = new_fd_bitmap (FD_BITMAP_SIZE);
begin_unwind_frame ("pe_dispose");
add_unwind_protect (dispose_fd_bitmap, bitmap);
add_unwind_protect (dispose_command, command); /* XXX */
global_command = (COMMAND *)NULL;

View File

@ -36,7 +36,7 @@ $END
#include <config.h>
#include <sys/types.h>
#include "../bashtypes.h"
#include "../posixstat.h"
#include <signal.h>
#include <errno.h>
@ -65,7 +65,7 @@ $END
extern int errno;
#endif /* !errno */
extern int interactive, subshell_environment;
extern int interactive, interactive_shell, subshell_environment;
extern REDIRECT *redirection_undo_list;
int no_exit_on_failed_exec;
@ -90,7 +90,7 @@ exec_builtin (list)
{
int exit_value = EXECUTION_FAILURE;
int cleanenv, login, opt;
char *argv0, *command, **args, **env, *newname;
char *argv0, *command, **args, **env, *newname, *com2;
cleanenv = login = 0;
argv0 = (char *)NULL;
@ -143,7 +143,13 @@ exec_builtin (list)
goto failed_exec;
}
command = full_pathname (command);
com2 = full_pathname (command);
if (com2)
{
if (command != args[0])
free (command);
command = com2;
}
if (argv0)
{
@ -172,7 +178,8 @@ exec_builtin (list)
}
#if defined (HISTORY)
maybe_save_shell_history ();
if (interactive_shell && subshell_environment == 0)
maybe_save_shell_history ();
#endif /* HISTORY */
restore_original_signals ();
@ -201,6 +208,9 @@ failed_exec:
if (subshell_environment || (interactive == 0 && no_exit_on_failed_exec == 0))
exit_shell (exit_value);
if (args)
free_array (args);
initialize_traps ();
reinitialize_signals ();

View File

@ -30,7 +30,7 @@ $END
#include <config.h>
#include <sys/types.h>
#include "../bashtypes.h"
#include <stdio.h>
#if defined (HAVE_UNISTD_H)
@ -45,6 +45,8 @@ $END
extern int interactive, login_shell;
extern int last_command_exit_value;
extern Function *this_shell_builtin;
extern Function *last_shell_builtin;
static int exit_or_logout ();
static int sourced_logout;
@ -82,10 +84,6 @@ logout_builtin (list)
return (exit_or_logout (list));
}
/* Clean up work for exiting or logging out. */
Function *last_shell_builtin = (Function *)NULL;
Function *this_shell_builtin = (Function *)NULL;
static int
exit_or_logout (list)
WORD_LIST *list;
@ -121,7 +119,7 @@ exit_or_logout (list)
/* Get return value if present. This means that you can type
`logout 5' to a shell, and it returns 5. */
exit_value = list ? get_numeric_arg (list) : last_command_exit_value;
exit_value = list ? get_numeric_arg (list, 1) : last_command_exit_value;
/* Run our `~/.bash_logout' file if it exists, and this is a login shell. */
if (login_shell && sourced_logout++ == 0)

View File

@ -50,8 +50,8 @@ $END
#if defined (HISTORY)
#include <sys/param.h>
#include "bashtypes.h"
#include "posixstat.h"
#include "../bashtypes.h"
#include "../posixstat.h"
#include <sys/file.h>
#if defined (HAVE_UNISTD_H)
@ -77,9 +77,13 @@ extern int errno;
#endif /* !errno */
extern int echo_input_at_read;
extern int current_command_line_count;
extern int literal_history;
extern int unlink ();
extern int fc_execute_file ();
/* **************************************************************** */
/* */
/* The K*rn shell style fc command (Fix Command) */
@ -252,7 +256,7 @@ fc_builtin (list)
fprintf (stderr, "%s\n", command);
fc_replhist (command); /* replace `fc -s' with command */
return (parse_and_execute (command, "fc", -1));
return (parse_and_execute (command, "fc", SEVAL_NOHIST));
}
/* This is the second form of the command (the list-or-edit-and-rerun
@ -266,9 +270,11 @@ fc_builtin (list)
("fc blah..." and so on) is already part of the history list by
the time we get to this point. This just skips over that command
and makes the last command that this deals with be the last command
the user entered before the fc. */
the user entered before the fc. We need to check whether the
line was actually added (HISTIGNORE may have caused it to not be),
so we check hist_last_line_added. */
last_hist = i - 2;
last_hist = i - 1 - hist_last_line_added;
if (list)
{
@ -317,6 +323,7 @@ fc_builtin (list)
else
{
numbering = 0;
/* XXX - this is raceable */
sprintf (fn, "/tmp/bash%d", (int)time ((time_t *) 0) + (int)getpid ());
stream = fopen (fn, "w");
@ -354,7 +361,7 @@ fc_builtin (list)
command = (char *)xmalloc (3 + strlen (FC_EDIT_COMMAND) + strlen (fn));
sprintf (command, "%s %s", FC_EDIT_COMMAND, fn);
}
retval = parse_and_execute (command, "fc", -1);
retval = parse_and_execute (command, "fc", SEVAL_NOHIST);
if (retval != EXECUTION_SUCCESS)
{
unlink (fn);
@ -375,10 +382,18 @@ fc_builtin (list)
retval = EXECUTION_SUCCESS;
first = 1;
#if 1
/* 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.,
if this is called by vi_edit_and_execute_command) may have already
called bash_history_disable. */
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')
@ -390,23 +405,36 @@ fc_builtin (list)
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
fc_addhist (line);
{
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 maybe_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. */
begin_unwind_frame ("fc builtin");
add_unwind_protect (unlink, fn);
unwind_protect_int (echo_input_at_read);
echo_input_at_read = 1;
retval = maybe_execute_file (fn, 0);
retval = fc_execute_file (fn);
run_unwind_frame ("fc builtin");
@ -447,8 +475,10 @@ fc_gethnum (command, hlist)
("fc blah..." and so on) is already part of the history list by
the time we get to this point. This just skips over that command
and makes the last command that this deals with be the last command
the user entered before the fc. */
i -= 2;
the user entered before the fc. We need to check whether the
line was actually added (HISTIGNORE may have caused it to not be),
so we check hist_last_line_added. */
i -= 1 + hist_last_line_added;
/* No specification defaults to most recent command. */
if (command == NULL)

View File

@ -32,7 +32,7 @@ $END
#include <config.h>
#include <sys/types.h>
#include "../bashtypes.h"
#include <signal.h>
#if defined (HAVE_UNISTD_H)

View File

@ -115,7 +115,7 @@ sh_getopt (argc, argv, optstring)
sh_optarg = 0;
if (sh_optind > argc || sh_optind < 0)
if (sh_optind >= argc || sh_optind < 0) /* XXX was sh_optind > argc */
{
sh_optind = argc;
return (EOF);
@ -144,7 +144,7 @@ sh_getopt (argc, argv, optstring)
if (nextchar == 0 || *nextchar == '\0')
{
/* If we have done all the ARGV-elements, stop the scan. */
if (sh_optind == argc)
if (sh_optind >= argc)
return EOF;
temp = argv[sh_optind];

View File

@ -17,8 +17,8 @@
/* XXX THIS HAS BEEN MODIFIED FOR INCORPORATION INTO BASH XXX */
#ifndef _GETOPT_H
#define _GETOPT_H 1
#ifndef _SH_GETOPT_H
#define _SH_GETOPT_H 1
/* For communication from `getopt' to the caller.
When `getopt' finds an option that takes an argument,
@ -57,4 +57,4 @@ extern int sh_badopt;
extern int sh_getopt ();
extern void sh_getopt_restore_state ();
#endif /* _GETOPT_H */
#endif /* _SH_GETOPT_H */

View File

@ -292,7 +292,10 @@ getopts_builtin (list)
int ac, ret;
if (list == 0)
return EXECUTION_FAILURE;
{
builtin_usage ();
return EX_USAGE;
}
reset_internal_getopt ();
while ((ret = internal_getopt (list, "")) != -1)

View File

@ -33,9 +33,6 @@ $END
#include <config.h>
#include <sys/types.h>
#include "../posixstat.h"
#include <stdio.h>
#if defined (HAVE_UNISTD_H)
@ -46,9 +43,9 @@ $END
#include "../shell.h"
#include "../builtins.h"
#include "../flags.h"
#include "../execute_cmd.h"
#include "hashcom.h"
#include "../flags.h"
#include "../hashcmd.h"
#include "common.h"
#include "bashgetopt.h"
@ -58,54 +55,6 @@ extern char *this_command_name;
static int add_hashed_command ();
static int print_hashed_commands ();
static int hashing_initialized = 0;
HASH_TABLE *hashed_filenames;
void
initialize_filename_hashing ()
{
if (hashing_initialized == 0)
{
hashed_filenames = make_hash_table (FILENAME_HASH_BUCKETS);
hashing_initialized = 1;
}
}
static void
free_filename_data (data)
char *data;
{
free (((PATH_DATA *)data)->path);
free (data);
}
void
flush_hashed_filenames ()
{
flush_hash_table (hashed_filenames, free_filename_data);
}
/* Remove FILENAME from the table of hashed commands. */
void
remove_hashed_filename (filename)
char *filename;
{
register BUCKET_CONTENTS *item;
if (hashing_enabled == 0)
return;
item = remove_hash_item (filename, hashed_filenames);
if (item)
{
if (item->data)
free_filename_data (item->data);
free (item->key);
free (item);
}
}
/* Print statistics on the current state of hashed commands. If LIST is
not empty, then rehash (or hash in the first place) the specified
commands. */
@ -161,56 +110,16 @@ hash_builtin (list)
word = list->word->word;
if (pathname)
remember_filename (word, pathname, 0, 0);
else
{
if (absolute_program (word))
{
list = list->next;
continue;
}
if (add_hashed_command (word))
opt = EXECUTION_FAILURE;
}
else if (absolute_program (word))
continue;
else if (add_hashed_command (word, 0))
opt = EXECUTION_FAILURE;
}
fflush (stdout);
return (opt);
}
/* Place FILENAME (key) and FULL_PATHNAME (data->path) into the
hash table. CHECK_DOT if non-null is for future calls to
find_hashed_filename (); it means that this file was found
in a directory in $PATH that is not an absolute pathname.
FOUND is the initial value for times_found. */
void
remember_filename (filename, full_pathname, check_dot, found)
char *filename, *full_pathname;
int check_dot, found;
{
register BUCKET_CONTENTS *item;
if (hashing_enabled == 0)
return;
item = add_hash_item (filename, hashed_filenames);
if (item->data)
free (pathdata(item)->path);
else
{
item->key = savestring (filename);
item->data = xmalloc (sizeof (PATH_DATA));
}
pathdata(item)->path = savestring (full_pathname);
pathdata(item)->flags = 0;
if (check_dot)
pathdata(item)->flags |= HASH_CHKDOT;
if (*full_pathname != '/')
pathdata(item)->flags |= HASH_RELPATH;
item->times_found = found;
}
static int
add_hashed_command (word, quiet)
char *word;
@ -244,6 +153,9 @@ print_hashed_commands ()
BUCKET_CONTENTS *item_list;
int bucket, any_printed;
if (hashed_filenames == 0)
return (0);
for (bucket = any_printed = 0; bucket < hashed_filenames->nbuckets; bucket++)
{
item_list = get_hash_bucket (bucket, hashed_filenames);

View File

@ -46,7 +46,10 @@ $END
#include <glob/fnmatch.h>
#include <glob/glob.h>
static void show_builtin_command_help ();
extern void builtin_error ();
extern void builtin_usage ();
static void show_builtin_command_help ();
/* Print out a list of the known functions in the shell, and what they do.
If LIST is supplied, print out the list which matches for each pattern
@ -59,13 +62,6 @@ help_builtin (list)
char *pattern, *name;
int plen, match_found;
if (list == 0)
{
show_shell_version (0);
show_builtin_command_help ();
return (EXECUTION_SUCCESS);
}
/* Placeholder for future options. */
reset_internal_getopt ();
while ((i = internal_getopt (list, "")) != -1)
@ -79,6 +75,13 @@ help_builtin (list)
}
list = loptend;
if (list == 0)
{
show_shell_version (0);
show_builtin_command_help ();
return (EXECUTION_SUCCESS);
}
/* We should consider making `help bash' do something. */
if (glob_pattern_p (list->word->word))

View File

@ -45,7 +45,7 @@ $END
#include <config.h>
#if defined (HISTORY)
#include <sys/types.h>
#include "../bashtypes.h"
#include <sys/file.h>
#include "../posixstat.h"
#include "../filecntl.h"
@ -193,7 +193,7 @@ display_history (list)
if (list)
{
limited = 1;
limit = get_numeric_arg (list);
limit = get_numeric_arg (list, 0);
}
else
limited = limit = 0;
@ -259,7 +259,7 @@ push_history (list)
{
char *s;
if (delete_last_history () == 0)
if (hist_last_line_added && delete_last_history () == 0)
return;
s = string_list (list);
maybe_add_history (s); /* Obeys HISTCONTROL setting. */
@ -274,7 +274,7 @@ expand_and_print_history (list)
char *s;
int r, result;
if (delete_last_history () == 0)
if (hist_last_line_added && delete_last_history () == 0)
return EXECUTION_FAILURE;
result = EXECUTION_SUCCESS;
while (list)

View File

@ -237,14 +237,28 @@ disown_builtin (list)
list = loptend;
retval = EXECUTION_SUCCESS;
#if 0
/* For the future `disown -a' */
if (list == 0)
{
if (nohup_only)
nohup_all_jobs ();
else
delete_all_jobs ();
return (EXECUTION_SUCCESS);
}
#endif
do
{
BLOCK_CHILD (set, oset);
job = get_job_spec (list);
job = (list && all_digits(list->word->word))
? get_job_by_pid (atoi(list->word->word), 0)
: get_job_spec (list);
if (job == NO_JOB || jobs == 0 || jobs[job] == 0)
{
builtin_error ("no such job %s", list->word->word);
builtin_error ("%s: no such job", list ? list->word->word : "current");
retval = EXECUTION_FAILURE;
}
else if (nohup_only)
@ -257,6 +271,7 @@ disown_builtin (list)
list = list->next;
}
while (list);
return (retval);
}
#endif /* JOB_CONTROL */

View File

@ -56,6 +56,7 @@ extern int errno;
#if defined (JOB_CONTROL)
extern int interactive;
extern int job_control;
extern int posixly_correct;
#if !defined (CONTINUE_AFTER_KILL_ERROR)
@ -166,7 +167,7 @@ kill_builtin (list)
builtin_error ("%s: no such pid", list->word->word);
CONTINUE_OR_FAIL;
}
else if (interactive)
else if (interactive || job_control)
/* Posix.2 says you can kill without job control active (4.32.4) */
{ /* Must be a job spec. Check it out. */
int job;

View File

@ -75,6 +75,7 @@ let_builtin (list)
WORD_LIST *list;
{
long ret;
int expok;
if (list == 0)
{
@ -83,17 +84,22 @@ let_builtin (list)
}
for (; list; list = list->next)
ret = evalexp (list->word->word);
{
ret = evalexp (list->word->word, &expok);
if (expok == 0)
return (EXECUTION_FAILURE);
}
return ((ret == 0L) ? EXECUTION_FAILURE : EXECUTION_SUCCESS);
}
#ifdef INCLUDE_UNUSED
int
exp_builtin (list)
WORD_LIST *list;
{
char *exp;
int ret;
int ret, expok;
if (list == 0)
{
@ -102,7 +108,8 @@ exp_builtin (list)
}
exp = string_list (list);
ret = evalexp (exp);
free (exp);
return ((ret == 0L) ? EXECUTION_FAILURE : EXECUTION_SUCCESS);
ret = evalexp (exp, &expok);
(void)free (exp);
return (((ret == 0L) || (expok == 0)) ? EXECUTION_FAILURE : EXECUTION_SUCCESS);
}
#endif

View File

@ -25,23 +25,17 @@ Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
# include <unistd.h>
#endif
#include "../bashansi.h"
#include "../config.h"
#include <stdio.h>
#include <sys/types.h>
#include "../bashtypes.h"
#include <sys/file.h>
#include <sys/stat.h>
#include "../posixstat.h"
#include "../filecntl.h"
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif /* HAVE_UNISTD_H */
#if defined (HAVE_STRING_H)
# include <string.h>
#else /* !HAVE_STRING_H */
# include <strings.h>
#endif /* !HAVE_STRING_H */
#include "../bashansi.h"
#include <stdio.h>
#define DOCFILE "builtins.texi"
@ -351,9 +345,9 @@ array_add (element, array)
(array->array, (array->size += array->growth_rate) * array->width);
#if defined (HAVE_BCOPY)
bcopy (&element, &(array->array[array->sindex]), array->width);
bcopy (&element, (char *) &(array->array[array->sindex]), array->width);
array->sindex++;
bzero (&(array->array[array->sindex]), array->width);
bzero ((char *) &(array->array[array->sindex]), array->width);
#else
array->array[array->sindex++] = element;
array->array[array->sindex] = (char *)NULL;

View File

@ -28,7 +28,7 @@
#endif
#include <stdio.h>
#include <sys/types.h>
#include "../bashtypes.h"
#include <signal.h>
#include <errno.h>
@ -47,6 +47,7 @@ sigpipe (sig)
exit (0);
}
int
main (argc, argv)
int argc;
char **argv;
@ -66,4 +67,5 @@ main (argc, argv)
n = write (1, buf, 128);
nw += n;
}
return (0);
}

View File

@ -30,10 +30,12 @@ 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') is at the top.
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) is at the top.
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.
@ -257,6 +259,8 @@ pushd_builtin (list)
{
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
@ -277,7 +281,9 @@ popd_builtin (list)
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'))
@ -297,6 +303,7 @@ popd_builtin (list)
builtin_usage ();
return (EXECUTION_FAILURE);
}
which_word = list->word->word;
}
else if (*list->word->word == '-')
{
@ -310,7 +317,7 @@ popd_builtin (list)
if (which > directory_list_offset || (directory_list_offset == 0 && which == 0))
{
pushd_error (directory_list_offset, list ? list->word->word : "");
pushd_error (directory_list_offset, which_word ? which_word : "");
return (EXECUTION_FAILURE);
}

View File

@ -164,7 +164,7 @@ read_builtin (list)
{
if (rlbuf && rlbuf[rlind] == '\0')
{
free (rlbuf);
xfree (rlbuf);
rlbuf = (char *)0;
}
if (rlbuf == 0)
@ -247,13 +247,28 @@ read_builtin (list)
assign_array_var_from_word_list (var, alist);
dispose_words (alist);
}
free (input_string);
xfree (input_string);
return (retval);
}
#endif /* ARRAY_VARS */
if (!list)
/* If there are no variables, save the text of the line read to the
variable $REPLY. ksh93 strips leading and trailing IFS whitespace,
so that `read x ; echo "$x"' and `read ; echo "$REPLY"' behave the
same way, but I believe that the difference in behaviors is useful
enough to not do it. Without the bash behavior, there is no way
to read a line completely without interpretation or modification.
If you disagree, change the occurrences of `#if 0' to `#if 1' below. */
if (list == 0)
{
#if 0
orig_input_string = input_string;
for (t = input_string; ifs_chars && *ifs_chars && spctabnl(*t) && issep(*t); t++)
;
input_string = t;
input_string = strip_trailing_ifs_whitespace (input_string, ifs_chars, saw_escape);
#endif
if (saw_escape)
{
t = dequote_string (input_string);
@ -263,7 +278,11 @@ read_builtin (list)
else
var = bind_variable ("REPLY", input_string);
var->attributes &= ~att_invisible;
#if 0
free (orig_input_string);
#else
free (input_string);
#endif
return (retval);
}

View File

@ -48,7 +48,7 @@ int
return_builtin (list)
WORD_LIST *list;
{
return_catch_value = list ? get_numeric_arg (list) : last_command_exit_value;
return_catch_value = list ? get_numeric_arg (list, 1) : last_command_exit_value;
if (return_catch_flag)
longjmp (return_catch, 1);

View File

@ -78,6 +78,9 @@ $SHORT_DOC set [--abefhkmnptuvxBCHP] [-o option] [arg ...]
#if defined (BANG_HISTORY)
histexpand same as -H
#endif /* BANG_HISTORY */
#if defined (HISTORY)
history enable command history
#endif
ignoreeof the shell will not exit upon reading EOF
interactive-comments
allow comments to appear in interactive commands
@ -110,12 +113,12 @@ $SHORT_DOC set [--abefhkmnptuvxBCHP] [-o option] [arg ...]
#if defined (BRACE_EXPANSION)
-B the shell will perform brace expansion
#endif /* BRACE_EXPANSION */
-C If set, disallow existing regular files to be overwritten
by redirection of output.
#if defined (BANG_HISTORY)
-H Enable ! style history substitution. This flag is on
by default.
#endif /* BANG_HISTORY */
-C If set, disallow existing regular files to be overwritten
by redirection of output.
-P If set, do not follow symbolic links when executing commands
such as cd which change the current directory.
@ -127,6 +130,7 @@ ARGs are given, all shell variables are printed.
$END
static int set_ignoreeof ();
static int set_posix_mode ();
#if defined (READLINE)
static int set_edit_mode ();
@ -183,7 +187,7 @@ struct {
#endif
{ "ignoreeof", &ignoreeof, set_ignoreeof, (Function *)NULL },
{ "interactive-comments", &interactive_comments, (Function *)NULL, (Function *)NULL },
{ "posix", &posixly_correct, (Function *)NULL, (Function *)NULL },
{ "posix", &posixly_correct, set_posix_mode, (Function *)NULL },
#if defined (READLINE)
{ "emacs", (int *)NULL, set_edit_mode, get_edit_mode },
{ "vi", (int *)NULL, set_edit_mode, get_edit_mode },
@ -283,6 +287,20 @@ set_ignoreeof (on_or_off, option_name)
return 0;
}
static int
set_posix_mode (on_or_off, option_name)
int on_or_off;
char *option_name;
{
posixly_correct = on_or_off == FLAG_ON;
if (posixly_correct == 0)
unbind_variable ("POSIXLY_CORRECT");
else
bind_variable ("POSIXLY_CORRECT", "y");
sv_strict_posix ("POSIXLY_CORRECT");
return (0);
}
#if defined (READLINE)
/* Magic. This code `knows' how readline handles rl_editing_mode. */
static int
@ -435,7 +453,9 @@ set_shellopts ()
vptr += strlen (binary_o_options[i].name);
value[vptr++] = ':';
}
value[--vptr] = '\0'; /* cut off trailing colon */
if (vptr)
vptr--; /* cut off trailing colon */
value[vptr] = '\0';
v = find_variable ("SHELLOPTS");
if (v)
@ -465,15 +485,34 @@ void
initialize_shell_options ()
{
char *temp;
SHELL_VAR *var;
var = find_variable ("SHELLOPTS");
/* set up any shell options we may have inherited. */
if (temp = get_string_value ("SHELLOPTS"))
parse_shellopts (temp);
if (var && imported_p (var))
{
temp = (array_p (var)) ? (char *)NULL : savestring (value_cell (var));
if (temp)
{
parse_shellopts (temp);
free (temp);
}
}
/* Set up the $SHELLOPTS variable. */
set_shellopts ();
}
/* Reset the values of the -o options that are not also shell flags. */
void
reset_shell_options ()
{
#if defined (HISTORY)
remember_on_history = 1;
#endif
ignoreeof = posixly_correct = 0;
}
/* Set some flags from the word values in the input list. If LIST is empty,
then print out the values of the variables instead. If LIST contains
non-flags, then set $1 - $9 to the successive words of LIST. */
@ -691,6 +730,12 @@ unset_builtin (list)
}
#endif
if (legal_identifier (name) == 0)
{
builtin_error ("`%s': not a valid identifier", name);
NEXT_VARIABLE ();
}
var = unset_function ? find_function (name) : find_variable (name);
if (var && !unset_function && non_unsettable_p (var))

View File

@ -34,8 +34,17 @@ $PRODUCES setattr.c
#include "common.h"
#include "bashgetopt.h"
extern int posixly_correct;
extern int array_needs_making;
extern char *this_command_name;
extern Function *this_shell_builtin;
#ifdef ARRAY_VARS
extern int declare_builtin ();
#endif
#define READONLY_OR_EXPORT \
(this_shell_builtin == readonly_builtin || this_shell_builtin == export_builtin)
$BUILTIN export
$FUNCTION export_builtin
@ -94,6 +103,10 @@ set_or_show_attributes (list, attribute, nodefs)
register SHELL_VAR *var;
int assign, undo, functions_only, arrays_only, any_failed, assign_error, opt;
char *name;
#if defined (ARRAY_VARS)
WORD_LIST *nlist, *tlist;
WORD_DESC *w;
#endif
undo = functions_only = arrays_only = any_failed = assign_error = 0;
/* Read arguments from the front of the list. */
@ -159,7 +172,10 @@ set_or_show_attributes (list, attribute, nodefs)
if (legal_identifier (name) == 0)
{
builtin_error ("`%s': not a valid identifier", name);
assign_error++;
if (assign)
assign_error++;
else
any_failed++;
list = list->next;
continue;
}
@ -167,6 +183,24 @@ set_or_show_attributes (list, attribute, nodefs)
if (assign) /* xxx [-np] name=value */
{
name[assign] = '=';
#if defined (ARRAY_VARS)
/* Let's try something here. Turn readonly -a xxx=yyy into
declare -ra xxx=yyy and see what that gets us. */
if (arrays_only)
{
tlist = list->next;
list->next = (WORD_LIST *)NULL;
w = make_word ("-ra");
nlist = make_word_list (w, list);
opt = declare_builtin (nlist);
if (opt != EXECUTION_SUCCESS)
assign_error++;
list->next = tlist;
dispose_word (w);
free (nlist);
}
else
#endif
/* This word has already been expanded once with command
and parameter expansion. Call do_assignment_no_expand (),
which does not do command or parameter substitution. If
@ -212,7 +246,7 @@ set_or_show_attributes (list, attribute, nodefs)
continue;
#endif
if ((var->attributes & attribute) && invisible_p (var) == 0)
show_var_attributes (var, nodefs);
show_var_attributes (var, READONLY_OR_EXPORT, nodefs);
}
free (variable_list);
}
@ -223,43 +257,70 @@ set_or_show_attributes (list, attribute, nodefs)
: EXECUTION_FAILURE));
}
/* Show the attributes for shell variable VAR. If NODEFS is non-zero,
don't show function definitions along with the name. If PATTR is
non-zero, it indicates we're being called from `export' or `readonly'.
In POSIX mode, this prints the name of the calling builtin (`export'
or `readonly') instead of `declare', and doesn't print function defs
when called by `export' or `readonly'. */
int
show_var_attributes (var, nodefs)
show_var_attributes (var, pattr, nodefs)
SHELL_VAR *var;
int nodefs;
int pattr, nodefs;
{
char flags[6], *x;
int i;
i = 0;
/* pattr == 0 means we are called from `declare'. */
if (pattr == 0 || posixly_correct == 0)
{
#if defined (ARRAY_VARS)
if (array_p (var))
flags[i++] = 'a';
if (array_p (var))
flags[i++] = 'a';
#endif
if (function_p (var))
flags[i++] = 'f';
if (function_p (var))
flags[i++] = 'f';
if (integer_p (var))
flags[i++] = 'i';
if (integer_p (var))
flags[i++] = 'i';
if (readonly_p (var))
flags[i++] = 'r';
if (readonly_p (var))
flags[i++] = 'r';
if (exported_p (var))
flags[i++] = 'x';
if (exported_p (var))
flags[i++] = 'x';
}
else
{
#if defined (ARRAY_VARS)
if (array_p (var))
flags[i++] = 'a';
#endif
if (function_p (var))
flags[i++] = 'f';
}
flags[i] = '\0';
printf ("declare -%s ", i ? flags : "-");
if (pattr == 0 || posixly_correct == 0)
printf ("declare -%s ", i ? flags : "-");
else if (i)
printf ("%s -%s ", this_command_name, flags);
else
printf ("%s ", this_command_name);
#if defined (ARRAY_VARS)
if (array_p (var))
print_array_assignment (var, 1);
else
#endif
if (nodefs)
/* force `readline' and `export' to not print out function definitions
when in POSIX mode. */
if (nodefs || (function_p (var) && pattr != 0 && posixly_correct))
printf ("%s\n", var->name);
else if (function_p (var))
printf ("%s\n", named_function_string (var->name, function_cell (var), 1));
@ -285,7 +346,7 @@ show_name_attributes (name, nodefs)
if (var && invisible_p (var) == 0)
{
show_var_attributes (var, nodefs);
show_var_attributes (var, READONLY_OR_EXPORT, nodefs);
return (0);
}
else

View File

@ -53,7 +53,7 @@ shift_builtin (list)
register int count;
WORD_LIST *temp;
times = get_numeric_arg (list);
times = get_numeric_arg (list, 0);
if (times == 0)
return (EXECUTION_SUCCESS);

View File

@ -61,15 +61,17 @@ extern int cdspelling, expand_aliases;
extern int check_window_size;
#if defined (HISTORY)
extern int hist_verify, literal_history, command_oriented_history;
extern int literal_history, command_oriented_history;
extern int force_append_history;
#endif
#if defined (READLINE)
extern int history_reediting, perform_hostname_completion;
extern int hist_verify, history_reediting, perform_hostname_completion;
extern void enable_hostname_completion ();
#endif
extern void set_shellopts ();
static int set_interactive_comments ();
static struct {
@ -92,9 +94,9 @@ static struct {
#endif
#if defined (HISTORY)
{ "histappend", &force_append_history, (Function *)NULL },
{ "histverify", &hist_verify, (Function *)NULL },
#endif
#if defined (READLINE)
{ "histverify", &hist_verify, (Function *)NULL },
{ "hostcomplete", &perform_hostname_completion, (Function *)enable_hostname_completion },
#endif
{ "interactive_comments", &interactive_comments, set_interactive_comments },
@ -178,6 +180,29 @@ shopt_builtin (list)
return (rval);
}
/* Reset the options managed by `shopt' to the values they would have at
shell startup. */
void
reset_shopt_options ()
{
allow_null_glob_expansion = glob_dot_filenames = 0;
cdable_vars = mail_warning = 0;
no_exit_on_failed_exec = print_shift_error = 0;
check_hashed_filenames = cdspelling = expand_aliases = check_window_size = 0;
source_uses_path = promptvars = 1;
#if defined (HISTORY)
literal_history = force_append_history = 0;
command_oriented_history = 1;
#endif
#if defined (READLINE)
hist_verify = history_reediting = 0;
perform_hostname_completion = 1;
#endif
}
static int
find_shopt (name)
char *name;

View File

@ -46,7 +46,10 @@ $END
extern int job_control;
static SigHandler *old_cont, *old_stop;
static SigHandler *old_cont;
#if 0
static SigHandler *old_stop;
#endif
/* Continue handler. */
sighandler

View File

@ -23,17 +23,17 @@ $PRODUCES trap.c
$BUILTIN trap
$FUNCTION trap_builtin
$SHORT_DOC trap [arg] [signal_spec] or trap -l
$SHORT_DOC trap [arg] [signal_spec ...] or trap -l
The command ARG is to be read and executed when the shell receives
signal(s) SIGNAL_SPEC. If ARG is absent all specified signals are
reset to their original values. If ARG is the null string each
SIGNAL_SPEC is ignored by the shell and by the commands it invokes.
If SIGNAL_SPEC is EXIT (0) the command ARG is executed on exit from
the shell. If SIGNAL_SPEC is DEBUG, ARG is executed after every
If a SIGNAL_SPEC is EXIT (0) the command ARG is executed on exit from
the shell. If a SIGNAL_SPEC is DEBUG, ARG is executed after every
command. If ARG is `-p' then the trap commands associated with
each SIGNAL_SPEC are displayed. If no arguments are supplied or if
only `-p' is given, trap prints the list of commands associated with
each signal number. SIGNAL_SPEC is either a signal name in <signal.h>
each signal number. Each SIGNAL_SPEC is either a signal name in <signal.h>
or a signal number. `trap -l' prints a list of signal names and their
corresponding numbers. Note that a signal can be sent to the shell
with "kill -signal $$".
@ -115,7 +115,8 @@ trap_builtin (list)
operation = SET;
first_arg = list->word->word;
if (first_arg && *first_arg && signal_object_p (first_arg))
if (first_arg && *first_arg && (*first_arg != '-' || first_arg[1]) &&
signal_object_p (first_arg))
operation = REVERT;
else
{

View File

@ -57,6 +57,7 @@ $END
#include "../shell.h"
#include "../execute_cmd.h"
#include "../hashcmd.h"
#if defined (ALIAS)
#include "../alias.h"
@ -307,6 +308,7 @@ describe_command (command, verbose, all)
else if (verbose == 3 || verbose == 4)
printf ("%s\n", full_path);
free (full_path);
return (1);
}
}

View File

@ -35,7 +35,7 @@ option is given, it is interpreted as follows:
-c the maximum size of core files created
-d the maximum size of a process's data segment
-f the maximum size of files created by the shell
-l the maximum size a process may lock into memory
-l the maximum size a process may lock into memory
-m the maximum resident set size
-n the maximum number of open file descriptors
-p the pipe buffer size
@ -215,6 +215,17 @@ static ULCMD *cmdlist;
static int ncmd;
static int cmdlistsz;
#if !defined (HAVE_RESOURCE) && !defined (HAVE_ULIMIT)
long
ulimit (cmd, newlim)
int cmd;
long newlim;
{
errno = EINVAL;
return -1;
}
#endif /* !HAVE_RESOURCE && !HAVE_ULIMIT */
static int
_findlim (opt)
int opt;
@ -368,6 +379,12 @@ ulimit_internal (cmd, cmdarg, mode, multiple)
block_factor = (limit == RLIM_INFINITY) ? 1 : limits[limind].block_factor;
real_limit = limit * block_factor;
if (real_limit < 0 || (real_limit == 0 && limit != 0))
{
builtin_error ("limit out of range: %d", limit);
return (EXECUTION_FAILURE);
}
if (set_limit (limind, real_limit, mode) < 0)
{
builtin_error ("cannot modify limit: %s", strerror (errno));
@ -444,6 +461,9 @@ set_limit (ind, newlim, mode)
case RLIMIT_FILESIZE:
#if !defined (HAVE_RESOURCE)
return (ulimit (2, newlim / 512L));
#else
errno = EINVAL;
return -1;
#endif
case RLIMIT_OPENFILES:
@ -462,8 +482,9 @@ set_limit (ind, newlim, mode)
#if defined (HAVE_RESOURCE)
if (getrlimit (limits[ind].parameter, &limit) < 0)
return -1;
val = (current_user.euid != 0 && newlim == RLIM_INFINITY)
? limit.rlim_max : newlim;
val = (current_user.euid != 0 && newlim == RLIM_INFINITY &&
(limit.rlim_cur <= limit.rlim_max))
? limit.rlim_max : newlim;
if (mode & LIMIT_SOFT)
limit.rlim_cur = val;
if (mode & LIMIT_HARD)

View File

@ -64,6 +64,7 @@ umask_builtin (list)
WORD_LIST *list;
{
int print_symbolically, opt, umask_value;
mode_t umask_arg;
print_symbolically = 0;
reset_internal_getopt ();
@ -105,19 +106,20 @@ umask_builtin (list)
if (umask_value == -1)
return (EXECUTION_FAILURE);
}
umask (umask_value);
umask_arg = (mode_t)umask_value;
umask (umask_arg);
if (print_symbolically)
print_symbolic_umask (umask_value);
print_symbolic_umask (umask_arg);
}
else /* Display the UMASK for this user. */
{
umask_value = umask (022);
umask (umask_value);
umask_arg = umask (022);
umask (umask_arg);
if (print_symbolically)
print_symbolic_umask (umask_value);
print_symbolic_umask (umask_arg);
else
printf ("%03o\n", umask_value);
printf ("%03o\n", umask_arg);
}
fflush (stdout);
@ -128,7 +130,7 @@ umask_builtin (list)
printed if the corresponding bit is clear in the umask. */
static void
print_symbolic_umask (um)
int um;
mode_t um;
{
char ubits[4], gbits[4], obits[4]; /* u=rwx,g=rwx,o=rwx */
int i;
@ -267,9 +269,12 @@ symbolic_umask (list)
umc |= perm;
break;
#if 0
/* No other values are possible. */
default:
builtin_error ("bad symbolic mode operator: %c", op);
return (-1);
#endif
}
if (!*s)

View File

@ -50,9 +50,12 @@ $END
# include <unistd.h>
#endif
#include "../bashansi.h"
#include "../shell.h"
#include "../jobs.h"
#include "common.h"
#include "bashgetopt.h"
extern int interrupt_immediately;
@ -71,6 +74,8 @@ wait_builtin (list)
if (no_options (list))
return (EX_USAGE);
if (list != loptend)
list = loptend;
begin_unwind_frame ("wait_builtin");
unwind_protect_int (interrupt_immediately);

View File

@ -37,6 +37,7 @@ enum r_instruction {
#define AMBIGUOUS_REDIRECT -1
#define NOCLOBBER_REDIRECT -2
#define RESTRICTED_REDIRECT -3 /* can only happen in restricted shells. */
#define HEREDOC_REDIRECT -4 /* here-doc temp file can't be created */
#define OUTPUT_REDIRECT(ri) \
(ri == r_output_direction || ri == r_input_output || ri == r_err_and_out)
@ -121,6 +122,8 @@ typedef struct element {
#define CMD_NO_FORK 0x40 /* Don't fork; just call execve */
#define CMD_TIME_PIPELINE 0x80 /* Time a pipeline */
#define CMD_TIME_POSIX 0x100 /* time -p; use POSIX.2 time output spec. */
#define CMD_AMPERSAND 0x200 /* command & */
#define CMD_STDIN_REDIR 0x400 /* async command needs implicit </dev/null */
/* What a command looks like. */
typedef struct command {

View File

@ -61,3 +61,7 @@
# define USE_VARARGS
# endif
#endif
#if defined (STRCOLL_BROKEN)
# undef HAVE_STRCOLL
#endif

View File

@ -300,6 +300,12 @@
#undef STRUCT_DIRENT_HAS_D_INO
#undef STRUCT_DIRENT_HAS_D_FILENO
#undef STRUCT_WINSIZE_IN_SYS_IOCTL
#undef SPEED_T_IN_SYS_TYPES
#undef CAN_REDEFINE_GETENV
#undef MUST_REINSTALL_SIGHANDLERS
@ -415,6 +421,9 @@
/* Define if you have the <dirent.h> header file. */
#undef HAVE_DIRENT_H
/* Define if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define if you have the <limits.h> header file. */
#undef HAVE_LIMITS_H
@ -500,6 +509,10 @@
<sys/resource.h>? */
#undef RLIMIT_NEEDS_KERNEL
/* Do strcoll(3) and strcmp(3) give different results in the default locale? */
#undef STRCOLL_BROKEN
#include "config.h.bot"
#endif /* _CONFIG_H_ */

View File

@ -27,6 +27,10 @@
without this option. */
#define V9_ECHO
/* Define DONT_REPORT_SIGPIPE if you don't want to see `Broken pipe' messages
when a job like `cat jobs.c | exit 1' is executed. */
/* #define DONT_REPORT_SIGPIPE */
/* The default value of the PATH variable. */
#ifndef DEFAULT_PATH_VALUE
#define DEFAULT_PATH_VALUE \

1728
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -1,17 +1,18 @@
dnl
dnl Configure script for bash-2.0
dnl Configure script for bash-2.01
dnl
dnl report bugs to chet@po.cwru.edu
dnl
dnl Process this file with autoconf to produce a configure script.
dnl checks for version info
AC_REVISION([for Bash 2.0, version 1.14, from autoconf version] AC_ACVERSION)dnl
AC_REVISION([for Bash 2.01, version 1.26, from autoconf version] AC_ACVERSION)dnl
AC_INIT(shell.h)
AC_CONFIG_HEADER(config.h)
dnl make sure we are using a recent autoconf version
AC_PREREQ(2.8)
AC_PREREQ(2.10)
dnl where to find install.sh, config.sub, and config.guess
AC_CONFIG_AUX_DIR(./support)
@ -24,7 +25,9 @@ dnl configure defaults
opt_gnu_malloc=yes
opt_glibc_malloc=no
opt_purify=no
opt_purecov=no
opt_afs=no
opt_curses=no
dnl some systems should be configured without gnu malloc by default
dnl and some need a special compiler or loader
@ -35,40 +38,56 @@ alpha-*) opt_gnu_malloc=no ;; # alpha running osf/1 or linux
*-osf1*) opt_gnu_malloc=no ;; # other osf/1 machines
sparc-svr4*) opt_gnu_malloc=no ;; # sparc SVR4, SVR4.2
sparc-netbsd*) opt_gnu_malloc=no ;; # needs 8-byte alignment
*-sgi-irix6*) opt_gnu_malloc=no ;; # needs 8-byte alignment
sparc-linux*) opt_gnu_malloc=no ;; # sparc running linux; requires ELF
*-freebsd*) opt_gnu_malloc=no ;; # they claim it's better
*-aix*) opt_gnu_malloc=no ;; # AIX machines
*-nextstep*) opt_gnu_malloc=no ;; # NeXT machines running NeXTstep
*-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
*-bsdi2.1) opt_gnu_malloc=no ; : ${CC:=shlicc2} ;; # for loadable builtins
esac
dnl arguments to configure
dnl packages
AC_ARG_WITH(gnu-malloc, --with-gnu-malloc use the GNU version of malloc,opt_gnu_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(purify, --with-purify configure to postprocess with purify, opt_purify=$withval)
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(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(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)
dnl test for glibc malloc first because it can override the default
if test "$opt_glibc_malloc" = yes; then
MALLOC=gmalloc.o MALLOC_SRC='$(ALLOC_LIBSRC)/gmalloc.c'
MALLOC_TARGET=gmalloc
MALLOC_SRC=gmalloc.c
elif test "$opt_gnu_malloc" = yes; then
MALLOC=malloc.o MALLOC_SRC='$(ALLOC_LIBSRC)/malloc.c'
MALLOC_TARGET=malloc
MALLOC_SRC=malloc.c
else
MALLOC= MALLOC_SRC=
MALLOC_TARGET=stubmalloc
MALLOC_SRC=stub.c
fi
if test "$opt_purify" = yes; then
PURIFY=purify
PURIFY="purify "
else
PURIFY=
fi
if test "$opt_purecov" = yes; then
PURIFY="${PURIFY}purecov"
fi
if test "$opt_afs" = yes; then
AC_DEFINE(AFS)
fi
if test "$opt_curses" = yes; then
prefer_curses=yes
fi
dnl optional shell features in config.h.in
opt_minimal_config=no
@ -103,22 +122,22 @@ if test $opt_minimal_config = yes; then
opt_brace_expansion=no opt_disabled_builtins=no opt_command_timing=no
fi
AC_ARG_ENABLE(job-control, --enable-job-control enable job control features, opt_job_control=$enableval)
AC_ARG_ENABLE(alias, --enable-alias enable shell aliases, opt_alias=$enableval)
AC_ARG_ENABLE(readline, --enable-readline turn on command line editing, opt_readline=$enableval)
AC_ARG_ENABLE(history, --enable-history turn on command history, opt_history=$enableval)
AC_ARG_ENABLE(array-variables, --enable-array-variables include shell array variables, opt_array_variables=$enableval)
AC_ARG_ENABLE(bang-history, --enable-bang-history turn on csh-style history substitution, opt_bang_history=$enableval)
AC_ARG_ENABLE(brace-expansion, --enable-brace-expansion include brace expansion, opt_brace_expansion=$enableval)
AC_ARG_ENABLE(command-timing, --enable-command-timing enable the time reserved word and command timing, opt_command_timing=$enableval)
AC_ARG_ENABLE(directory-stack, --enable-directory-stack enable builtins pushd/popd/dirs, opt_dirstack=$enableval)
AC_ARG_ENABLE(restricted, --enable-restricted enable a restricted shell, opt_restricted=$enableval)
AC_ARG_ENABLE(disabled-builtins, --enable-disabled-builtins allow disabled builtins to still be invoked, opt_disabled_builtins=$enableval)
AC_ARG_ENABLE(dparen-arithmetic, [--enable-dparen-arithmetic include ((...)) command], opt_dparen_arith=$enableval)
AC_ARG_ENABLE(help-builtin, --enable-help-builtin include the help builtin, opt_help=$enableval)
AC_ARG_ENABLE(history, --enable-history turn on command history, opt_history=$enableval)
AC_ARG_ENABLE(job-control, --enable-job-control enable job control features, opt_job_control=$enableval)
AC_ARG_ENABLE(process-substitution, --enable-process-substitution enable process substitution, opt_process_subst=$enableval)
AC_ARG_ENABLE(prompt-string-decoding, --enable-prompt-string-decoding turn on escape character decoding in prompts, opt_prompt_decoding=$enableval)
AC_ARG_ENABLE(readline, --enable-readline turn on command line editing, opt_readline=$enableval)
AC_ARG_ENABLE(restricted, --enable-restricted enable a restricted shell, opt_restricted=$enableval)
AC_ARG_ENABLE(select, --enable-select include select command, opt_select=$enableval)
AC_ARG_ENABLE(help-builtin, --enable-help-builtin include the help builtin, opt_help=$enableval)
AC_ARG_ENABLE(array-variables, --enable-array-variables include shell array variables, opt_array_variables=$enableval)
AC_ARG_ENABLE(dparen-arithmetic, [--enable-dparen-arithmetic include ((...)) command], opt_dparen_arith=$enableval)
AC_ARG_ENABLE(brace-expansion, --enable-brace-expansion include brace expansion, opt_brace_expansion=$enableval)
AC_ARG_ENABLE(disabled-builtins, --enable-disabled-builtins allow disabled builtins to still be invoked, opt_disabled_builtins=$enableval)
AC_ARG_ENABLE(command-timing, --enable-command-timing enable the time reserved word and command timing, opt_command_timing=$enableval)
AC_ARG_ENABLE(usg-echo-default, --enable-usg-echo-default make the echo builtin expand escape sequences by default, opt_usg_echo=$enableval)
dnl opt_job_control is handled later, after BASH_JOB_CONTROL_MISSING runs
@ -184,25 +203,36 @@ if test $opt_usg_echo = yes ; then
AC_DEFINE(DEFAULT_ECHO_TO_USG)
fi
if test "$opt_minimal_config" = yes; then
TESTSCRIPT=run-minimal
else
TESTSCRIPT=run-all
fi
dnl now substitute in the values generated by arguments
AC_SUBST(TESTSCRIPT)
AC_SUBST(PURIFY)
AC_SUBST(MALLOC)
AC_SUBST(MALLOC_TARGET)
AC_SUBST(MALLOC_SRC)
AC_SUBST(READLINE_LIB)
AC_SUBST(READLINE_DEP)
AC_SUBST(HISTORY_LIB)
AC_SUBST(HISTORY_DEP)
echo "Beginning configuration for bash-2.0"
dnl Use GNU m4 macros to get the distribution and patchlevel information
dnl into configure without requiring the files to be distributed
[BASHVERS=]dnl
esyscmd(cat _distribution)dnl
[BASHPATCH=]dnl
esyscmd(cat _patchlevel)dnl
echo "Beginning configuration for bash-$BASHVERS"
dnl compilation checks
AC_PROG_CC
AC_ISC_POSIX
AC_MINIX
dnl See whether cc works at all
BASH_CC_WORKS
dnl We want these before the checks, so the checks can modify their values.
test -z "$CFLAGS" && CFLAGS=-g auto_cflags=1
@ -285,7 +315,7 @@ AC_HEADER_DIRENT
AC_HEADER_TIME
AC_CHECK_HEADERS(unistd.h stdlib.h stdarg.h varargs.h limits.h string.h \
memory.h locale.h termcap.h termio.h termios.h)
memory.h locale.h termcap.h termio.h termios.h dlfcn.h)
AC_CHECK_HEADERS(sys/ptem.h sys/pte.h sys/stream.h sys/select.h sys/file.h \
sys/resource.h sys/param.h sys/socket.h \
sys/time.h sys/times.h sys/wait.h)
@ -293,7 +323,10 @@ AC_CHECK_HEADERS(sys/ptem.h sys/pte.h sys/stream.h sys/select.h sys/file.h \
dnl libraries
dnl this is reportedly no longer necessary for irix[56].?
dnl AC_CHECK_LIB(sun, getpwent)
BASH_CHECK_SOCKLIB
dnl check for getpeername in the socket library only if it's not in libc
if test "$ac_cv_func_getpeername" = no; then
BASH_CHECK_SOCKLIB
fi
dnl system types
AC_TYPE_GETGROUPS
@ -332,20 +365,31 @@ if test "$ac_cv_func_lstat" = "no"; then
BASH_FUNC_LSTAT
fi
dnl behavior of system calls and library functions
BASH_DUP2_CLOEXEC_CHECK
BASH_PGRP_SYNC
BASH_SIGNAL_CHECK
dnl checking for the presence of certain library symbols
BASH_SYS_ERRLIST
BASH_SYS_SIGLIST
BASH_UNDER_SYS_SIGLIST
BASH_SIGNAL_CHECK
dnl various system types
BASH_TYPE_SIGHANDLER
BASH_CHECK_TYPE(clock_t, [#include <sys/times.h>], long)
BASH_CHECK_TYPE(sigset_t, [#include <signal.h>], int)
BASH_CHECK_TYPE(quad_t, , long, HAVE_QUAD_T)
BASH_RLIMIT_TYPE
dnl presence and contents of structures used by system calls
BASH_STRUCT_TERMIOS_LDISC
BASH_STRUCT_TERMIO_LDISC
BASH_STRUCT_DIRENT_D_INO
BASH_STRUCT_DIRENT_D_FILENO
BASH_STRUCT_WINSIZE
dnl presence and behavior of C library functions
BASH_FUNC_STRSIGNAL
BASH_FUNC_OPENDIR_CHECK
BASH_FUNC_PRINTF
@ -354,26 +398,38 @@ BASH_FUNC_GETENV
BASH_FUNC_GETCWD
BASH_FUNC_SBRK_DECLARED
BASH_FUNC_POSIX_SETJMP
BASH_FUNC_STRCOLL
dnl presence and behavior of OS functions
BASH_REINSTALL_SIGHANDLERS
BASH_JOB_CONTROL_MISSING
BASH_SYS_NAMED_PIPES
dnl presence of certain CPP defines
BASH_HAVE_TIOCGWINSZ
BASH_HAVE_TIOCSTAT
BASH_HAVE_FIONREAD
BASH_CHECK_GETPW_FUNCS
BASH_CHECK_DEV_FD
dnl miscellaneous
BASH_MISC_SPEED_T
BASH_CHECK_GETPW_FUNCS
dnl special checks
case "$host_os" in
hpux*) BASH_KERNEL_RLIMIT_CHECK ;;
esac
if test "$opt_readline" = yes; then
dnl yuck
case "$host_os" in
aix*) prefer_curses=yes ;;
esac
BASH_CHECK_LIB_TERMCAP
fi
AC_SUBST(TERMCAP_LIB)
AC_SUBST(TERMCAP_DEP)
dnl special checks
BASH_CHECK_DEV_FD
BASH_DEFAULT_MAIL_DIR
if test "$bash_cv_job_control_missing" = missing; then
@ -389,6 +445,11 @@ fi
AC_SUBST(JOBS_O)
dnl Defines that we want to propagate to the Makefiles in subdirectories,
dnl like glob and readline
LOCAL_DEFS=-DSHELL
dnl use this section to possibly define more cpp variables, specify local
dnl libraries, and specify any additional local cc flags
dnl
@ -404,9 +465,12 @@ isc*) LOCAL_CFLAGS=-Disc386;;
sco3.2v5*) LOCAL_CFLAGS="-DWAITPID_BROKEN -DNO_MEMSCRAMBLE -DPATH_MAX=1024" ;;
sco3.2v4*) LOCAL_CFLAGS="-DMUST_UNBLOCK_CHLD -DNO_MEMSCRAMBLE -DPATH_MAX=1024" ;;
sco3.2*) LOCAL_CFLAGS=-DMUST_UNBLOCK_CHLD ;;
sunos4*) LOCAL_CFLAGS=-DSunOS4;;
linux*) LOCAL_LDFLAGS=-rdynamic ;; # allow dynamic loading
aix4.2*) LOCAL_LDFLAGS="-bexpall -brtl";;# allow dynamic loading
sunos4*) LOCAL_CFLAGS=-DSunOS4 ;;
solaris2.5*) LOCAL_CFLAGS=-DSunOS5 ;;
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" ;;
powerux) LOCAL_LIBS="-lgen" ;;
esac
case "$host_cpu" in
@ -443,15 +507,19 @@ AC_SUBST(BUILD_DIR)
AC_SUBST(YACC)
AC_SUBST(AR)
AC_SUBST(BASHVERS)
AC_SUBST(BASHPATCH)
AC_SUBST(host_cpu)
AC_SUBST(host_os)
AC_SUBST(LOCAL_LIBS)
AC_SUBST(LOCAL_CFLAGS)
AC_SUBST(LOCAL_LDFLAGS)
AC_SUBST(LOCAL_DEFS)
AC_SUBST(ALLOCA_SOURCE)
AC_SUBST(ALLOCA_OBJECT)
#AC_SUBST(ALLOCA_SOURCE)
#AC_SUBST(ALLOCA_OBJECT)
AC_OUTPUT([Makefile builtins/Makefile lib/readline/Makefile lib/glob/Makefile \
lib/malloc/Makefile lib/termcap/Makefile lib/tilde/Makefile \

View File

@ -28,12 +28,6 @@
# include <unistd.h>
#endif
#if defined (HAVE_STRING_H)
# include <string.h>
#else /* !HAVE_STRING_H */
# include <strings.h>
#endif /* !HAVE_STRING_H */
#include "shell.h"
WORD_DESC *
@ -119,6 +113,10 @@ copy_redirect (redirect)
case r_duplicating_output_word:
new_redirect->redirectee.filename = copy_word (redirect->redirectee.filename);
break;
case r_duplicating_input:
case r_duplicating_output:
case r_close_this:
break;
}
return (new_redirect);
}

View File

@ -175,18 +175,24 @@ dispose_words (list)
}
}
/* How to dispose of an array of pointers to char. */
#ifdef INCLUDE_UNUSED
/* How to dispose of an array of pointers to char. This is identical to
free_array in stringlib.c. */
void
dispose_word_array (array)
char **array;
{
register int count;
if (array == 0)
return;
for (count = 0; array[count]; count++)
free (array[count]);
free (array);
}
#endif
/* How to dispose of an list of redirections. A REDIRECT. */
void

262
doc/FAQ
View File

@ -1,4 +1,4 @@
This is the Bash FAQ, version 2.1, for Bash version 2.0.
This is the Bash FAQ, version 2.5, for Bash version 2.01.
This document contains a set of frequently-asked questions concerning
Bash, the GNU Bourne-Again Shell. Bash is a freely-available command
@ -24,77 +24,78 @@ Section A: The Basics
2) What's the latest version?
3) Where can I get it?
4) On what machines will bash run?
5) How can I build bash with gcc?
6) How can I make bash my login shell?
7) I just changed my login shell to bash, and now I can't FTP into my
5) Will bash run on operating systems other than Unix?
6) How can I build bash with gcc?
7) 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
machine. Why not?
8) What's the `POSIX 1003.2 standard'?
9) What is the bash `posix mode'?
9) What's the `POSIX 1003.2 standard'?
10) What is the bash `posix mode'?
Section B: The latest version
10) What's new in version 2.0?
11) Are there any user-visible incompatibilities between bash-2.0 and
11) What's new in version 2.01?
12) Are there any user-visible incompatibilities between bash-2.01 and
bash-1.14.7?
Section C: Differences from other Unix shells
12) How does bash differ from sh, the Bourne shell?
13) How does bash differ from the Korn shell, version ksh88?
14) Which new features in ksh-93 are not in bash, and which are?
13) How does bash differ from sh, the Bourne shell?
14) How does bash differ from the Korn shell, version ksh88?
15) 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?
15) Why does bash run a different version of `command' than
16) Why does bash run a different version of `command' than
`which command' says it will?
16) Why doesn't bash treat brace expansions exactly like csh?
17) Why doesn't bash have csh variable modifiers?
18) How can I make my csh aliases work when I convert to bash?
19) How can I pipe standard output and standard error from one command to
17) Why doesn't bash treat brace expansions exactly like csh?
18) Why doesn't bash have csh variable modifiers?
19) 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
another, like csh does with `|&'?
20) Now that I've converted from ksh to bash, are there equivalents to
21) Now that I've converted from ksh to bash, are there equivalents to
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
things the way it does?
21) Why is the bash builtin `test' slightly different from /bin/test?
22) Why does bash sometimes say `Broken pipe'?
23) How can I get bash to read and display eight-bit characters?
24) How do I write a function `x' to replace builtin command `x', but
22) Why is the bash builtin `test' slightly different from /bin/test?
23) Why does bash sometimes say `Broken pipe'?
24) 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
still invoke the command from within the function?
25) When I have terminal escape sequences in my prompt, why does bash
26) When I have terminal escape sequences in my prompt, why does bash
wrap lines at the wrong column?
26) How can I find the value of a shell variable whose name is the value
27) How can I find the value of a shell variable whose name is the value
of another shell variable?
27) If I pipe the output of a command into `read variable', why doesn't
28) 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?
28) I have a bunch of shell scripts that use backslash-escaped characters
29) I have a bunch of shell scripts that use backslash-escaped characters
in arguments to `echo'. Bash doesn't interpret these characters. Why
not, and how can I make it understand them?
29) Why doesn't a while or for loop get suspended when I type ^Z?
30) How can I make the bash `time' reserved word print timing output that
30) 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
looks like the output from my system's /usr/bin/time?
Section F: Things to watch out for on certain Unix versions
31) Why can't I use command line editing in my `cmdtool'?
32) I built bash on Solaris 2. Why do globbing expansions and filename
32) Why can't I use command line editing in my `cmdtool'?
33) I built bash on Solaris 2. Why do globbing expansions and filename
completion chop off the first few characters of each filename?
33) Why does bash dump core after I interrupt username completion or
34) Why does bash dump core after I interrupt username completion or
`~user' tilde expansion on a machine running NIS?
34) I'm running SVR4.2. Why is the line erased every time I type `@'?
35) Why does bash report syntax errors when my C News scripts use a
35) 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
redirection before a subshell command?
Section G: Where do I go from here?
36) How do I report bugs in bash, and where should I look for fixes and
37) How do I report bugs in bash, and where should I look for fixes and
advice?
37) What kind of bash documentation is there?
38) What's coming in future versions?
39) What's on the bash `wish list'?
40) When will the next release appear?
38) What kind of bash documentation is there?
39) What's coming in future versions?
40) What's on the bash `wish list'?
41) When will the next release appear?
----------
Section A: The Basics
@ -119,7 +120,7 @@ of Case Western Reserve University.
2) What's the latest version?
The latest version is 2.0, first made available on December 23, 1996.
The latest version is 2.01, first made available on June 6, 1997.
3) Where can I get it?
@ -127,15 +128,15 @@ 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
latest version is also available for FTP from slc2.ins.cwru.edu,
the maintainer's machine. The following URLs tell how to get
version 2.0:
version 2.01:
ftp://prep.ai.mit.edu/pub/gnu/bash-2.0.tar.gz
ftp://slc2.ins.cwru.edu/pub/dist/bash-2.0.tar.gz
ftp://prep.ai.mit.edu/pub/gnu/bash-2.01.tar.gz
ftp://slc2.ins.cwru.edu/pub/dist/bash-2.01.tar.gz
Formatted versions of the documentation are available with the URLs:
ftp://prep.ai.mit.edu/pub/gnu/bash-doc-2.0.tar.gz
ftp://slc2.ins.cwru.edu/pub/dist/bash-doc-2.0.tar.gz
ftp://prep.ai.mit.edu/pub/gnu/bash-doc-2.01.tar.gz
ftp://slc2.ins.cwru.edu/pub/dist/bash-doc-2.01.tar.gz
4) On what machines will bash run?
@ -147,12 +148,49 @@ itself accordingly, using a script created by GNU autoconf.
More information appears in the file `INSTALL' in the distribution.
5) How can I build bash with gcc?
5) Will bash run on operating systems other than Unix?
Configuration specifics for Unix-like systems such as QNX and
LynxOS are included in the distribution. Previous versions of
bash have been ported to Minix, but I don't believe anyone has
built bash-2.x on Minix yet.
Bash has been ported to versions of Windows implementing the Win32
programming interface. This includes Windows 95 and Windows NT.
The port was done by Cygnus Solutions as part of their GNU-Win32
project. For more information about the project, look at the URL
http://www.cygnus.com/misc/gnu-win32
Cygnus has ported bash-1.14.7. Maybe someday they (or I) will port
bash-2.01 (or later) to the GNU-Win32 environment.
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
http://www.delorie.com/djgpp/
I picked up a binary of bash-1.14.7 that is purported to work with
the DJGPP V2 environment from
ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bsh1147b.zip
The corresponding source is
ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bsh1147s.zip
A port of bash-1.12 is available for OS/2 from
ftp://hobbes.nmsu.edu/os2/unix/bash_112.zip
I haven't looked at it.
6) How can I build bash with gcc?
Bash configures to use gcc by default if it is available. Read the
file INSTALL in the distribution for more information.
6) How can I make bash my login shell?
7) How can I make bash my login shell?
Some machines let you use `chsh' to change your login shell. Other
systems use `passwd -s'. If one of these works for you, that's all
@ -182,18 +220,23 @@ like
to ensure that bash is exec'd only when the csh is interactive.
If your login shell is sh or ksh, you have to do two things. First, add
a line similar to the above to ~/.profile:
If your login shell is sh or ksh, you have to do two things.
[ -f /usr/gnu/bin/bash ] && exec /usr/gnu/bin/bash --login
Next, create an empty file in your home directory named `.bash_profile'.
First, create an empty file in your home directory named `.bash_profile'.
The existence of this file will prevent the exec'd bash from trying to
read ~/.profile, and re-execing itself over and over again. ~/.bash_profile
is the file bash tries to read initialization commands from when it is
invoked as a login shell.
is the first file bash tries to read initialization commands from when
it is invoked as a login shell.
7) I just changed my login shell to bash, and now I can't FTP into my
Next, add a line similar to the above to ~/.profile:
[ -f /usr/gnu/bin/bash ] && exec /usr/gnu/bin/bash --login
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
code from ~/.profile to ~/.bash_profile.
8) I just changed my login shell to bash, and now I can't FTP into my
machine. Why not?
You must add the full pathname to bash to the file /etc/shells. As
@ -203,7 +246,7 @@ this before you can make bash your login shell.
Most versions of ftpd use this file to prohibit `special' users
such as `uucp' and `news' from using FTP.
8) What's the `POSIX 1003.2 standard'?
9) What's the `POSIX 1003.2 standard'?
POSIX is a name originally coined by Richard Stallman for a
family of open system standards based on UNIX. There are a
@ -238,7 +281,7 @@ line editing. Only vi-style line editing commands have been
standardized; emacs editing commands were left out due to
objections.
9) What is the bash `posix mode'?
10) What is the bash `posix mode'?
Although bash is an implementation of the POSIX.2 shell
specification, there are areas where the bash default behavior
@ -255,10 +298,16 @@ Reference Manual.
Section B: The latest version
10) What's new in version 2.0?
11) What's new in version 2.01?
This version contains extensive changes and new features. Here's a
short list:
Bash-2.01 contains only a few new features.
new `GROUPS' builtin array variable containing the user's group list
new bindable readline commands: history-and-alias-expand-line and
alias-expand-line
Bash-2.0 contains extensive changes and new features from bash-1.14.7.
Here's a short list:
new `time' reserved word to time pipelines, shell builtins, and
shell functions
@ -295,15 +344,15 @@ grammar tighter and smaller (66 reduce-reduce conflicts gone)
lots of code now smaller and faster
test suite greatly expanded
11) Are there any user-visible incompatibilities between bash-2.0 and
12) Are there any user-visible incompatibilities between bash-2.01 and
bash-1.14.7?
There are a few incompatibilities between version 1.14.7 and version 2.0.
They are detailed in the file COMPAT in the bash-2.0 distribution.
There are a few incompatibilities between version 1.14.7 and version 2.01.
They are detailed in the file COMPAT in the bash-2.01 distribution.
Section C: Differences from other Unix shells
12) How does bash differ from sh, the Bourne shell?
13) How does bash differ from sh, the Bourne shell?
This is a non-comprehensive list of features that differentiate bash
from the SVR4.2 shell. The bash manual page explains these more
@ -370,7 +419,6 @@ Things sh has that bash does not:
includes `stop' builtin (bash can use alias stop='kill -s STOP')
`newgrp' builtin
turns on job control if called as `jsh'
ulimit attempts to set both soft & hard limits if -S/-H not given
$TIMEOUT (like bash $TMOUT)
`^' is a synonym for `|'
new SVR4.2 sh builtins: mldmode, priv
@ -386,11 +434,12 @@ Implementation differences:
sh does not allow traps on SIGALRM or SIGCHLD
bash allows multiple option arguments when invoked (e.g. -x -v);
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.)
sh exits a script if any builtin fails; bash exits only if one of
the POSIX.2 `special' builtins fails
13) How does bash differ from the Korn shell, version ksh88?
14) How does bash differ from the Korn shell, version ksh88?
Things bash has or uses that ksh88 does not:
long invocation options
@ -438,15 +487,14 @@ Things ksh88 has or uses that bash does not:
Implementation differences:
ksh runs last command of a pipeline in parent shell context
ksh ulimit sets hard and soft limits by default
bash has brace expansion by default (ksh88 compile-time option)
bash has fixed startup file for all interactive shells; ksh reads $ENV
bash has exported functions
bash command search finds functions before builtins
14) Which new features in ksh-93 are not in bash, and which are?
15) Which new features in ksh-93 are not in bash, and which are?
New things in ksh-93 not in bash-2.0:
New things in ksh-93 not in bash-2.01:
associative arrays
floating point arithmetic
++, --, comma arithmetic operators
@ -466,11 +514,10 @@ New things in ksh-93 not in bash-2.0:
`fc' has been renamed to `hist'
read -t/-d
`.' can execute shell functions
ENV processed only for interactive shells
New things in ksh-93 present in bash-2.0:
New things in ksh-93 present in bash-2.01:
?: arithmetic operator
expansions: ${!param}, ${param:len[:offset]}, ${param/pat[/str]}
expansions: ${!param}, ${param:offset[:len]}, ${param/pat[/str]}
compound array assignment
the `!' reserved word
loadable builtins -- but ksh uses `builtin' while bash uses `enable'
@ -488,10 +535,11 @@ New things in ksh-93 present in bash-2.0:
unalias -a
command and arithmetic substitution performed on PS1, PS4, and ENV
command name completion
ENV processed only for interactive shells
Section D: Why does bash do some things differently than other Unix shells?
15) Why does bash run a different version of `command' than
16) Why does bash run a different version of `command' than
`which command' says it will?
`which' is actually a csh script that assumes you're running csh.
@ -500,7 +548,7 @@ 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.
16) Why doesn't bash treat brace expansions exactly like csh?
17) Why doesn't bash treat brace expansions exactly like csh?
The only difference between bash and csh brace expansion is that
bash requires a brace expression to contain at least one unquoted
@ -511,7 +559,7 @@ compatibility.
Bash, ksh, zsh, and pd-ksh all implement brace expansion this way.
17) Why doesn't bash have csh variable modifiers?
18) Why doesn't bash have csh variable modifiers?
Posix has specified a more powerful, albeit somewhat more cryptic,
mechanism cribbed from ksh, and bash implements it.
@ -566,7 +614,7 @@ Given
$b:e ${b##*.} xxx
18) How can I make my csh aliases work when I convert to bash?
19) How can I make my csh aliases work when I convert to bash?
Bash uses a different syntax to support aliases than csh does.
The details can be found in the documentation. We have provided
@ -609,7 +657,7 @@ simply `cshtobash' to convert your normal interactive
environment, or as `cshtobash ~/.login' to convert your login
environment.
19) How can I pipe standard output and standard error from one command to
20) How can I pipe standard output and standard error from one command to
another, like csh does with `|&'?
Use
@ -619,7 +667,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
descriptor 2.
20) Now that I've converted from ksh to bash, are there equivalents to
21) Now that I've converted from ksh to bash, are there equivalents to
ksh features like autoloaded functions and the `whence' command?
There are features in ksh-88 that do not have direct bash equivalents.
@ -642,7 +690,7 @@ read var?prompt read -p prompt var
Section E: How can I get bash to do certain things, and why does bash do
things the way it does?
21) Why is the bash builtin `test' slightly different from /bin/test?
22) Why is the bash builtin `test' slightly different from /bin/test?
The specific example used here is [ ! x -o x ], which is false.
@ -671,7 +719,7 @@ of the 3 Arg case.
As you can see, the test becomes (not (x or x)), which is false.
22) Why does bash sometimes say `Broken pipe'?
23) Why does bash sometimes say `Broken pipe'?
If a sequence of commands appears in a pipeline, and one of the
reading commands finishes before the writer has finished, the
@ -686,7 +734,7 @@ 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
SIGPIPE.
23) How can I get bash to read and display eight-bit characters?
24) How can I get bash to read and display eight-bit characters?
This is a process requiring several steps.
@ -720,7 +768,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
in ~/.inputrc.
24) How do I write a function `x' to replace builtin command `x', but
25) How do I write a function `x' to replace builtin command `x', but
still invoke the command from within the function?
This is why the `command' and `builtin' builtins exist. The
@ -741,7 +789,7 @@ something like the following:
This could also be written using `command' instead of `builtin';
the version above is marginally more efficient.
25) When I have terminal escape sequences in my prompt, why does bash
26) When I have terminal escape sequences in my prompt, why does bash
wrap lines at the wrong column?
Readline, the line editing library that bash uses, does not know
@ -757,10 +805,10 @@ characters in the prompt strings take up no screen space.
Use the \[ escape to begin a sequence of non-printing characters,
and the \] escape to signal the end of such a sequence.
26) How can I find the value of a shell variable whose name is the value
27) How can I find the value of a shell variable whose name is the value
of another shell variable?
Bash-2.0 supports this directly. You can use
Bash-2.01 supports this directly. You can use
${!var}
@ -782,13 +830,13 @@ parameter:
The expansion of the quoted portions of this expression will be
deferred until `eval' runs, while the `$#' will be expanded
before `eval' is executed. In bash-2.0,
before `eval' is executed. In bash-2.01,
echo ${!#}
does the same thing.
27) If I pipe the output of a command into `read variable', why doesn't
28) If I pipe the output of a command into `read variable', why doesn't
the output show up in $variable when the read command finishes?
This has to do with the parent-child relationship between Unix
@ -844,7 +892,7 @@ this.
This is the general approach -- in most cases you will not need to
set $IFS to a different value.
28) I have a bunch of shell scripts that use backslash-escaped characters
29) I have a bunch of shell scripts that use backslash-escaped characters
in arguments to `echo'. Bash doesn't interpret these characters. Why
not, and how can I make it understand them?
@ -864,7 +912,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
type `make tests' to fail.
29) Why doesn't a while or for loop get suspended when I type ^Z?
30) 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
thing that can be suspended is the process group. This is a single
@ -879,7 +927,7 @@ If you want to be able to stop the entire loop, you need to put it
within parentheses, which will force the loop into a subshell that
may be stopped (and subsequently restarted) as a single unit.
30) How can I make the bash `time' reserved word print timing output that
31) How can I make the bash `time' reserved word print timing output that
looks like the output from my system's /usr/bin/time?
The bash command timing code looks for a variable `TIMEFORMAT' and
@ -913,7 +961,7 @@ The ksh format can be emulated with:
Section F: Things to watch out for on certain Unix versions
31) Why can't I use command line editing in my `cmdtool'?
32) Why can't I use command line editing in my `cmdtool'?
The problem is `cmdtool' and bash fighting over the input. When
scrolling is enabled in a cmdtool window, cmdtool puts the tty in
@ -941,7 +989,7 @@ The bash command-line editing should behave better in the new
cmdtool. If this works, you can put the assignment to TERMCAP
in your bashrc file.
32) I built bash on Solaris 2. Why do globbing expansions and filename
33) I built bash on Solaris 2. Why do globbing expansions and filename
completion chop off the first few characters of each filename?
This is the consequence of building bash on SunOS 5 and linking
@ -961,7 +1009,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
/usr/ucb.
33) Why does bash dump core after I interrupt username completion or
34) Why does bash dump core after I interrupt username completion or
`~user' tilde expansion on a machine running NIS?
This is a famous and long-standing bug in the SunOS YP (sorry, NIS)
@ -984,7 +1032,7 @@ times; that's probably why this has never been fixed. You can
run configure with the `--without-gnu-malloc' option to use
the C library malloc and avoid the problem.
34) I'm running SVR4.2. Why is the line erased every time I type `@'?
35) I'm running SVR4.2. Why is the line erased every time I type `@'?
The `@' character is the default `line kill' character in most
versions of System V, including SVR4.2. You can change this
@ -995,7 +1043,7 @@ change the line kill character to control-u, type
where the `^' and `U' can be two separate characters.
35) Why does bash report syntax errors when my C News scripts use a
36) Why does bash report syntax errors when my C News scripts use a
redirection before a subshell command?
The actual command in question is something like
@ -1007,7 +1055,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
`compound commands'. A redirection may only follow a compound command.
The file CWRU/sh-redir-hack in the bash-2.0 distribution is an
The file CWRU/sh-redir-hack in the bash-2.01 distribution is an
(unofficial) patch to parse.y that will modify the grammar to
support this construct. It will not apply with `patch'; you must
modify parse.y by hand. Note that if you apply this, you must
@ -1016,7 +1064,7 @@ number of reduce/reduce conflicts into the shell grammar.
Section G: Where do I go from here?
36) How do I report bugs in bash, and where should I look for fixes and
37) How do I report bugs in bash, and where should I look for fixes and
advice?
Use the `bashbug' script to report bugs. It is built and
@ -1034,7 +1082,7 @@ and problems also take place there.
To reach the bash maintainers directly, send mail to
bash-maintainers@prep.ai.mit.edu.
37) What kind of bash documentation is there?
38) What kind of bash documentation is there?
First, look in the doc directory in the bash distribution. It should
contain at least the following files:
@ -1056,19 +1104,23 @@ slc2.ins.cwru.edu in the `pub/bash' directory.
Cameron Newham and Bill Rosenblatt have written a book on bash, published
by O'Reilly and Associates. The book is based on Bill Rosenblatt's Korn
Shell book. The title is ``Learning the Bash Shell''. The ISBN number is
1-56592-147-X. Look for it in fine bookstores near you. This book covers
bash-1.14, but has an appendix describing some of the new features in
bash-2.0.
Shell book. The title is ``Learning the Bash Shell'', and the ISBN number
is 1-56592-147-X. Look for it in fine bookstores near you. This book
covers bash-1.14, but has an appendix describing some of the new features
in bash-2.0. There are rumors of a second edition of this book, describing
bash-2.0 (and 2.01). I do not know what ORA's publication schedule for
this edition is.
38) What's coming in future versions?
39) What's coming in future versions?
These are features I plan to include in a future version of bash.
POSIX.2-style globbing character classes ([:alpha:], [:alnum:], etc.)
a bash debugger (an incomplete, untested version is included with bash-2.0)
POSIX.2-style globbing equivalence classes
POSIX.2-style globbing collating symbols
a bash debugger (a minimally-tested version is included with bash-2.01)
39) What's on the bash `wish list' for future versions?
40) 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.
@ -1084,7 +1136,7 @@ timeouts for the `read' builtin
the ksh-93 ${!prefix*} and ${!prefix@} operators
arithmetic ++ and -- prefix and postfix operators
40) When will the next release appear?
41) When will the next release appear?
The next version will appear sometime in 1997. Never make predictions.

View File

@ -148,14 +148,20 @@ installdirs:
install: info installdirs
-$(INSTALL_DATA) $(srcdir)/bash.1 $(man1dir)/bash.${man1ext}
-$(INSTALL_DATA) $(srcdir)/bashbug.1 $(man1dir)/bashbug.${man1ext}
-$(INSTALL_DATA) $(srcdir)/readline.3 $(man3dir)/readline.${man3ext}
-$(INSTALL_DATA) $(srcdir)/bashref.info $(infodir)/bash.info
# uncomment the next line to install the readline man page
# -$(INSTALL_DATA) $(srcdir)/readline.3 $(man3dir)/readline.${man3ext}
# uncomment the next line to install the builtins man page
# $(INSTALL_DATA) builtins.1 $(man1dir)/bash_builtins.${man1ext}
-$(INSTALL_DATA) $(srcdir)/bashref.info $(infodir)/bash.info
# run install-info if it is present to update the info directory
if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then \
install-info --dir-file=$(infodir)/dir $(infodir)/bash.info; \
else true; fi
uninstall:
$(RM) $(man1dir)/bash.${man1ext} $(man1dir)/bashbug.${man1ext}
$(RM) $(man3dir)/readline.${man3ext} $(infodir)/bash.info
-$(RM) $(man1dir)/bash.${man1ext} $(man1dir)/bashbug.${man1ext}
-$(RM) $(man3dir)/readline.${man3ext}
$(RM) $(infodir)/bash.info
# for use by chet
inst: bashref.texi

View File

@ -6,11 +6,11 @@
.\" Case Western Reserve University
.\" chet@ins.CWRU.Edu
.\"
.\" Last Change: Mon Nov 25 15:36:20 EST 1996
.\" Last Change: Mon May 19 12:45:24 EDT 1997
.\"
.\" bash_builtins, strip all but Built-Ins section
.if \n(zZ=1 .ig zZ
.TH BASH 1 "1996 Nov 25" GNU
.TH BASH 1 "1997 May 19" GNU
.\"
.\" There's some problem with having a `@'
.\" in a tagged paragraph with the BSD man macros.
@ -256,8 +256,9 @@ section.
.PP
When
.B bash
is invoked as a login shell, it first reads and executes commands
from the file \fI/etc/profile\fP, if that file exists.
is invoked as an interactive login shell, it first reads and
executes commands from the file \fI/etc/profile\fP, if that
file exists.
After reading that file, it looks for \fI~/.bash_profile\fP,
\fI~/.bash_login\fP, and \fI~/.profile\fP, in that order, and reads
and executes commands from the first one that exists and is readable.
@ -623,7 +624,7 @@ is the exit status of the last command executed in
.IR list ,
or zero if no commands were executed.
.TP
\fBcase\fP \fIword\fP \fBin\fP [ \fIpattern\fP [ \fB|\fP \fIpattern\fP ] \
\fBcase\fP \fIword\fP \fBin\fP [ ( \fIpattern\fP [ \fB|\fP \fIpattern\fP ] \
... ) \fIlist\fP ;; ] ... \fBesac\fP
A \fBcase\fP command first expands \fIword\fP, and tries to match
it against each \fIpattern\fP in turn, using the same matching rules
@ -902,7 +903,11 @@ is the first character of the value of the
variable. If
.SM
.B IFS
is null or unset, the parameters are separated by spaces.
is unset, the parameters are separated by spaces.
If
.SM
.B IFS
is null, the parameters are joined without intervening separators.
.TP
.B @
Expands to the positional parameters, starting from one. When the
@ -999,6 +1004,10 @@ Expands to the user ID of the current user, initialized at shell startup.
Expands to the effective user ID of the current user, initialized at
shell startup.
.TP
.B GROUPS
An array variable containing the list of groups of which the current
user is a member.
.TP
.B BASH
Expands to the full file name used to invoke this instance of
.BR bash .
@ -1221,14 +1230,14 @@ specified by the
command. A sample value is
``.:~:/usr''.
.TP
.B ENV
.B BASH_ENV
If this parameter is set when \fBbash\fP is executing a shell script,
its value is interpreted as a filename containing commands to
initialize the shell, as in
.IR .bashrc .
The value of
.SM
.B ENV
.B BASH_ENV
is subjected to parameter expansion, command substitution, and arithmetic
expansion before being interpreted as a file name.
.SM
@ -3130,7 +3139,7 @@ below).
.SH READLINE
This is the library that handles reading input when using an interactive
shell, unless the
.B \-noediting
.B \-\-noediting
option is given at shell invocation.
By default, the line editing commands are similar to those of emacs.
A vi-style line editing interface is also available.
@ -3668,11 +3677,22 @@ word expansions. See
below for a description of history expansion.
.TP
.B history\-expand\-line (M\-^)
Perform history expansion on the current line. See
Perform history expansion on the current line.
See
.SM
.B HISTORY EXPANSION
below for a description of history expansion.
.TP
.B alias\-expand\-line
Perform alias expansion on the current line.
See
.SM
.B ALIASES
above for a description of alias expansion.
.TP
.B history\-and\-alias\-expand\-line
Perform history and alias expansion on the current line.
.TP
.B insert\-last\-argument (M\-.\^, M\-_\^)
A synonym for \fByank\-last\-arg\fP.
.TP
@ -3794,9 +3814,18 @@ Add this digit to the argument already accumulating, or start a new
argument. M\-\- starts a negative argument.
.TP
.B universal\-argument
Each time this is executed, the argument count is multiplied by four.
This is another way to specify an argument.
If this command is followed by one or more digits, optionally with a
leading minus sign, those digits define the argument.
If the command is followed by digits, executing
.B universal\-argument
again ends the numeric argument, but is otherwise ignored.
As a special case, if this command is immediately followed by a
character that is neither a digit or minus sign, the argument count
for the next command is multiplied by four.
The argument count is initially one, so executing this function the
first time makes the argument count four.
first time makes the argument count four, a second time makes the
argument count sixteen, and so on.
.PD
.SS Completing
.PP
@ -3980,7 +4009,7 @@ Display version information about the current instance of
.PD
.SH HISTORY
When the
.B -o history
.B \-o history
option to the
.B set
builtin is enabled, the shell provides access to the
@ -5494,12 +5523,15 @@ Arguments, if supplied, have the following meanings:
\fB+\fP\fIn\fP
Rotates the stack so that the \fIn\fPth directory
(counting from the left of the list shown by
.BR dirs )
.BR dirs ,
starting with zero)
is at the top.
.TP
\fB\-\fP\fIn\fP
Rotates the stack so that the \fIn\fPth directory
(counting from the right) is at the top.
(counting from the right of the list shown by
.BR dirs ,
starting with zero) is at the top.
.TP
.B \-n
Suppresses the normal change of directory when adding directories
@ -6006,7 +6038,7 @@ The errors checked for are transposed characters,
a missing character, and one character too many.
If a correction is found, the corrected file name is printed,
and the command proceeds.
This option is enabled by default, but is only used by interactive shells.
This option is only used by interactive shells.
.TP 8
.B checkhash
If set, \fBbash\fP checks that a command found in the hash
@ -6303,7 +6335,7 @@ may be positive or negative integers.
Print the accumulated user and system times for the shell and
for processes run from the shell. The return status is 0.
.TP
\fBtrap\fP [\fB\-lp\fP] [\fIarg\fP] [\fIsigspec\fP]
\fBtrap\fP [\fB\-lp\fP] [\fIarg\fP] [\fIsigspec\fP ...]
The command
.I arg
is to be read and executed when the shell receives
@ -6315,11 +6347,12 @@ is absent or
.BR \- ,
all specified signals are
reset to their original values (the values they had
upon entrance to the shell). If
upon entrance to the shell).
If
.I arg
is the null string this
signal is ignored by the shell and by the
commands it invokes.
is the null string the signal specified by each
.I sigspec
is ignored by the shell and by the commands it invokes.
If
.I arg
is
@ -6333,16 +6366,18 @@ only
is given,
.B trap
prints the list of commands associated with each signal number.
Each
.I sigspec
is either
a signal name defined in <\fIsignal.h\fP>, or a signal number. If
a signal name defined in <\fIsignal.h\fP>, or a signal number.
If a
.I sigspec
is
.SM
.B EXIT
(0) the command
.I arg
is executed on exit from the shell. If
is executed on exit from the shell. If a
.I sigspec
is
.SM
@ -6359,7 +6394,8 @@ option causes the shell to print a list of signal names and
their corresponding numbers.
Signals ignored upon entry to the shell cannot be trapped or reset.
Trapped signals are reset to their original values in a child
process when it is created. The return status is false if any
process when it is created.
The return status is false if any
.I sigspec
is invalid; otherwise
.B trap
@ -6723,8 +6759,7 @@ that you have.
Once you have determined that a bug actually exists, use the
.I bashbug
command to submit a bug report.
If you have a fix, you are welcome to mail that
as well!
If you have a fix, you are encouraged to mail that as well!
Suggestions and `philosophical' bug reports may be mailed
to \fPbug-bash\fP@\fIprep.ai.MIT.Edu\fP or posted to the Usenet
newsgroup

View File

@ -4,9 +4,9 @@ input file ./bashref.texi.
This text is a brief description of the features that are present in
the Bash shell.
This is Edition 2.0, last updated 25 November 1996,
This is Edition 2.0, last updated 19 May 1997,
of `The GNU Bash Reference Manual',
for `Bash', Version 2.0.
for `Bash', Version 2.01.
Copyright (C) 1991, 1993, 1996 Free Software Foundation, Inc.
@ -33,8 +33,8 @@ Bash Features
This text is a brief description of the features that are present in
the Bash shell.
This is Edition 2.0, last updated 25 November 1996, of `The GNU Bash
Reference Manual', for `Bash', Version 2.0.
This is Edition 2.0, last updated 19 May 1997, of `The GNU Bash
Reference Manual', for `Bash', Version 2.01.
Copyright (C) 1991, 1993, 1996 Free Software Foundation, Inc.
@ -205,8 +205,8 @@ Definitions
descended from it, that are all in the same process group.
`job control'
A mechanism by which users can selectively start and stop execution
of processes.
A mechanism by which users can selectively stop (suspend) and
restart (resume) execution of processes.
`metacharacter'
A character that, when unquoted, separates words. A metacharacter
@ -612,7 +612,7 @@ Conditional Constructs
`case'
The syntax of the `case' command is:
`case WORD in [PATTERN [| PATTERN]...) COMMANDS ;;]... esac'
`case WORD in [ ( PATTERN [| PATTERN]...) COMMANDS ;;]... esac'
Selectively execute COMMANDS based upon WORD matching PATTERN.
The `|' is used to separate multiple patterns.
@ -634,7 +634,7 @@ Conditional Constructs
(( EXPRESSION ))
The EXPRESSION is evaluated according to the rules described below
((*note Arithmetic Evaluation::.). If the value of the expression
(*note Arithmetic Evaluation::.). If the value of the expression
is non-zero, the return status is 0; otherwise the return status
is 1. This is exactly equivalent to
let "EXPRESSION"
@ -673,8 +673,8 @@ the list may be redirected to a single stream.
difference between these two constructs due to historical reasons. The
braces are `reserved words', so they must be separated from the LIST by
`blank's. The parentheses are `operators', and are recognized as
separate tokens by the shell even if they are not separated from `list'
by whitespace.
separate tokens by the shell even if they are not separated from the
LIST by whitespace.
The exit status of both of these constructs is the exit status of
LIST.
@ -701,7 +701,7 @@ status of the last command executed in the body.
When a function is executed, the arguments to the function become
the positional parameters during its execution (*note Positional
Parameters::.). The special parameter `#' that gives the number of
Parameters::.). The special parameter `#' that expands to the number of
positional parameters is updated to reflect the change. Positional
parameter `0' is unchanged.
@ -783,8 +783,9 @@ only be referenced; assignment to them is not allowed.
with the value of each parameter separated by the first character
of the `IFS' special variable. That is, `"$*"' is equivalent to
`"$1C$2C..."', where C is the first character of the value of the
`IFS' variable. If `IFS' is null or unset, the parameters are
separated by spaces.
`IFS' variable. If `IFS' is unset, the parameters are separated
by spaces. If `IFS' is null, the parameters are joined without
intervening separators.
`@'
Expands to the positional parameters, starting from one. When the
@ -880,7 +881,7 @@ parameter, variable, and arithemtic expansion and command substitution.
Only brace expansion, word splitting, and filename expansion can
change the number of words of the expansion; other expansions expand a
single word to a single word. The only exceptions to this are the
expansions of `"$@"' (*note Special Parameters::.) and `"${[@]}"'
expansions of `"$@"' (*note Special Parameters::.) and `"${NAME[@]}"'
(*note Arrays::.).
After all expansions, `quote removal' (*note Quote Removal::.) is
@ -907,9 +908,9 @@ name.
If the first character of PARAMETER is an exclamation point, a level
of variable indirection is introduced. Bash uses the value of the
variable formed from the rest of PARAMETER as the name of the variable;
this variable is then expanded and that value used in the rest of the
substitution, rather than the value of PARAMETER itself. This is known
as `indirect expansion'.
this variable is then expanded and that value is used in the rest of
the substitution, rather than the value of PARAMETER itself. This is
known as `indirect expansion'.
In each of the cases below, WORD is subject to tilde expansion,
parameter expansion, command substitution, and arithmetic expansion.
@ -1654,20 +1655,21 @@ standard.
children.
`trap'
trap [-lp] [ARG] [SIGSPEC]
trap [-lp] [ARG] [SIGSPEC ...]
The commands in ARG are to be read and executed when the shell
receives signal SIGSPEC. If ARG is absent or equal to `-', all
specified signals are reset to the values they had when the shell
was started. If ARG is the null string, then SIGSPEC is ignored by
the shell and commands it invokes. If ARG is `-p', the shell
displays the trap commands associated with each SIGSPEC. If no
arguments are supplied, or only `-p' is given, `trap' prints the
list of commands associated with each signal number. SIGSPEC is
either a signal name such as `SIGINT' or a signal number. If
SIGSPEC is `0' or `EXIT', ARG is executed when the shell exits.
If SIGSPEC is `DEBUG', the command ARG is executed after every
simple command. The `-l' option causes the shell to print a list
of signal names and their corresponding numbers.
was started. If ARG is the null string, then the signal specified
by each SIGSPEC is ignored by the shell and commands it invokes.
If ARG is `-p', the shell displays the trap commands associated
with each SIGSPEC. If no arguments are supplied, or only `-p' is
given, `trap' prints the list of commands associated with each
signal number. Each SIGSPEC is either a signal name such as
`SIGINT' (with or without the `SIG' prefix) or a signal number.
If a SIGSPEC is `0' or `EXIT', ARG is executed when the shell
exits. If a SIGSPEC is `DEBUG', the command ARG is executed after
every simple command. The `-l' option causes the shell to print a
list of signal names and their corresponding numbers.
Signals ignored upon entry to the shell cannot be trapped or reset.
Trapped signals are reset to their original values in a child
@ -1826,7 +1828,7 @@ translation of the characters between the double quotes. The `-D' and
`--dump-strings' invocation options list the translatable strings found
in a script (*note Locale Translation::.).
The expansion `${var:'LENGTH`[:'OFFSET`]}', which expands to the
The expansion `${var:'OFFSET`[:'LENGTH`]}', which expands to the
substring of `var''s value of length LENGTH, optionally beginning at
OFFSET, is present (*note Shell Parameter Expansion::.).
@ -1842,10 +1844,10 @@ Parameter Expansion::.).
Bash has process substitution (*note Process Substitution::.).
Bash automatically assigns variables that provide information about
the current user (`UID' and `EUID'), the current host (`HOSTTYPE',
`OSTYPE', `MACHTYPE', and `HOSTNAME'), and the instance of Bash that is
running (`BASH', `BASH_VERSION', and `BASH_VERSINFO'. *Note Bash
Variables::, for details.
the current user (`UID', `EUID', and `GROUPS'), the current host
(`HOSTTYPE', `OSTYPE', `MACHTYPE', and `HOSTNAME'), and the instance of
Bash that is running (`BASH', `BASH_VERSION', and `BASH_VERSINFO'.
*Note Bash Variables::, for details.
The `IFS' variable is used to split only the results of expansion,
not all words (*note Word Splitting::.). This closes a longstanding
@ -1858,9 +1860,9 @@ shell security hole.
`local' builtin, and thus useful recursive functions may be written.
Variable assignments preceding commands affect only that command,
even builtins and functions. In `sh', all variable assignments
preceding commands are global unless the command is executed from the
file system.
even builtins and functions (*note Environment::.). In `sh', all
variable assignments preceding commands are global unless the command
is executed from the file system.
Bash performs filename expansion on filenames specified as operands
to output redirection operators.
@ -1932,16 +1934,17 @@ shell input, a `-n' option to remove various variable attributes, and
`name=value' arguments to set variable attributes and values
simultaneously.
The Bash `cd' and `pwd' builtins each take `-L' and `-P' builtins to
switch between logical and physical modes.
The Bash `cd' and `pwd' builtins (*note Bourne Shell Builtins::.)
each take `-L' and `-P' builtins to switch between logical and physical
modes.
The Bash `type' builtin is more extensive and gives more information
about the names it finds.
about the names it finds (*note Bash Builtins::.).
Bash implements a `csh'-like directory stack, and provides the
`pushd', `popd', and `dirs' builtins to manipulate it. Bash also makes
the directory stack visible as the value of the `DIRSTACK' shell
variable.
`pushd', `popd', and `dirs' builtins to manipulate it (*note C Shell
Builtins::.). Bash also makes the directory stack visible as the value
of the `DIRSTACK' shell variable.
The Bash restricted mode is more useful (*note The Restricted
Shell::.); the SVR4.2 shell restricted mode is too limited.
@ -1979,10 +1982,10 @@ from many of the limitations of the SVR4.2 shell. For instance:
`SIGSEGV' blocked (e.g., by using the `system()' C library
function call), the shell misbehaves badly.
* In a questionable attempt at security, the SVR4.2 shell will alter
its real and effective UID and GID if they are less than some
threshold value, commonly 100. This can lead to unexpected
results.
* In a questionable attempt at security, the SVR4.2 shell, when
invoked without the `-p' option, will alter its real and effective
UID and GID if they are less than some magic threshold value,
commonly 100. This can lead to unexpected results.
* The SVR4.2 shell does not allow users to trap `SIGALRM' or
`SIGCHLD'.
@ -1999,7 +2002,7 @@ from many of the limitations of the SVR4.2 shell. For instance:
* The SVR4.2 shell exits a script if any builtin fails; Bash exits a
script only if one of the POSIX.2 special builtins fails, and only
for certain failures, as enumerated in the `POSIX.2' standard.
for certain failures, as enumerated in the POSIX.2 standard.
* The SVR4.2 shell behaves differently when invoked as `jsh' (it
turns on job control).
@ -2108,13 +2111,13 @@ to `csh'.
`+N'
Brings the Nth directory (counting from the left of the list
printed by `dirs') to the top of the list by rotating the
stack.
printed by `dirs', starting with zero) to the top of the list
by rotating the stack.
`-N'
Brings the Nth directory (counting from the right of the list
printed by `dirs') to the top of the list by rotating the
stack.
printed by `dirs', starting with zero) to the top of the list
by rotating the stack.
`-n'
Suppresses the normal change of directory when adding
@ -2288,10 +2291,10 @@ saved in the variable `REPLY'.
completes.
Bash also has adopted command timing from the Korn shell. If the
`time' reserved word precedes a pipeline or simple command, timing
statistics for the pipeline are displayed when it completes. The
statistics currently consist of elapsed (wall-clock) time and user and
system time consumed by the command's execution.
`time' reserved word precedes a pipeline, which may consist of a single
command, timing statistics for the pipeline are displayed when it
completes. The statistics currently consist of elapsed (wall-clock)
time and user and system time consumed by the command's execution.
The use of `time' as a reserved word permits the timing of shell
builtins, shell functions, and pipelines. An external `time' command
@ -2389,12 +2392,6 @@ Korn Shell Variables
The line number in the script or shell function currently
executing.
`ENV'
If this variable is set when Bash is invoked to execute a shell
script, its value is expanded and used as the name of a startup
file to read before executing the script. *Note Bash Startup
Files::.
`FCEDIT'
The editor used as a default by the `fc' builtin command.
@ -2609,17 +2606,18 @@ File: bashref.info, Node: Bash Startup Files, Next: Is This Shell Interactive?
Bash Startup Files
==================
This section describs how bash executes its startup files. If any
of the files exist but cannot be read, bash reports an error. Tildes
This section describs how Bash executes its startup files. If any
of the files exist but cannot be read, Bash reports an error. Tildes
are expanded in file names as described above under Tilde Expansion
(*note Tilde Expansion::.).
When Bash is invoked as a login shell, it first reads and executes
commands from the file `/etc/profile', if that file exists. After
reading that file, it looks for `~/.bash_profile', `~/.bash_login', and
`~/.profile', in that order, and reads and executes commands from the
first one that exists and is readable. The `--noprofile' option may be
used when the shell is started to inhibit this behavior.
When Bash is invoked as an interactive login shell, it first reads
and executes commands from the file `/etc/profile', if that file exists.
After reading that file, it looks for `~/.bash_profile',
`~/.bash_login', and `~/.profile', in that order, and reads and
executes commands from the first one that exists and is readable. The
`--noprofile' option may be used when the shell is started to inhibit
this behavior.
When a login shell exits, Bash reads and executes commands from the
file `~/.bash_logout', if it exists.
@ -2667,7 +2665,7 @@ are read.
line option, it follows the POSIX standard for startup files. In this
mode, the `ENV' variable is expanded and commands are read and executed
from the file whose name is the expanded value. No other startup files
are read. This is done by both interactive and non-interactive shells.
are read. This is done by interactive shells only.
Bash attempts to determine when it is being run by the remote shell
daemon, usually `rshd'. If Bash determines it is being run by rshd, it
@ -2699,6 +2697,14 @@ Thus:
echo This shell is interactive
fi
Alternatively, you may test the value of the `-' special parameter.
It contains `i' when the shell is interactive. For example:
case "$-" in
*i*) echo This shell is interactive ;;
*) echo This shell is not interactive ;;
esac

File: bashref.info, Node: Bash Builtins, Next: The Set Builtin, Prev: Is This Shell Interactive?, Up: Bash Features
@ -2764,9 +2770,9 @@ been extended in Bash.
`builtin'
builtin [SHELL-BUILTIN [ARGS]]
Run a shell builtin. This is useful when you wish to rename a
shell builtin to be a function, but need the functionality of the
builtin within the function itself.
Run a shell builtin. This is useful when you wish to define a
shell function with the same name as a shell builtin, but need the
functionality of the builtin within the function itself.
`command'
command [-pVv] COMMAND [ARGS ...]
@ -2974,7 +2980,7 @@ been extended in Bash.
are transposed characters, a missing character, and a
character too many. If a correction is found, the corrected
path is printed, and the command proceeds. This option is
enabled by default, but is only used by interactive shells.
only used by interactive shells.
`checkhash'
If this is set, Bash checks that a command found in the hash
@ -3018,7 +3024,8 @@ been extended in Bash.
`hostcomplete'
If set, and Readline is being used, Bash will attempt to
perform hostname completion when a word beginning with `@' is
being completed (*note Commands For Completion::.).
being completed (*note Commands For Completion::.). This
option is enabled by default.
`interactive_comments'
Allow a word beginning with `#' to cause that word and all
@ -3249,10 +3256,10 @@ The Set Builtin
same as `-x'.
`-p'
Turn on privileged mode. In this mode, the `$ENV' file is
not processed, and shell functions are not inherited from the
environment. This is enabled automatically on startup if the
effective user (group) id is not equal to the real user
Turn on privileged mode. In this mode, the `$BASH_ENV' file
is not processed, and shell functions are not inherited from
the environment. This is enabled automatically on startup if
the effective user (group) id is not equal to the real user
(group) id. Turning this option off causes the effective user
and group ids to be set to the real user and group ids.
@ -3484,6 +3491,12 @@ Bash Variables
These variables are set or used by Bash, but other shells do not
normally treat them specially.
`BASH_ENV'
If this variable is set when Bash is invoked to execute a shell
script, its value is expanded and used as the name of a startup
file to read before executing the script. *Note Bash Startup
Files::.
`TIMEFORMAT'
The value of this parameter is used as a format string specifying
how the timing information for pipelines prefixed with the `time'
@ -3518,9 +3531,9 @@ normally treat them specially.
fraction is included.
If this variable is not set, bash acts as if it had the value
`$'\nreal\t%3lR\nuser\t%3lU\nsys\t%3lS''. If the value is null,
no timing information is displayed. A trailing newline is added
when the format string is displayed.
`$'\nreal\t%3lR\nuser\t%3lU\nsys\t%3lS''.
If the value is null, no timing information is displayed. A
trailing newline is added when the format string is displayed.
`HISTCONTROL'
Set to a value of `ignorespace', it means don't enter lines which
@ -3603,6 +3616,10 @@ normally treat them specially.
`EUID'
The numeric effective user id of the current user.
`GROUPS'
An array variable containing the list of groups of which the
current user is a member.
`PPID'
The process id of the shell's parent process.
@ -3691,8 +3708,8 @@ normally treat them specially.
`SHLVL'
Incremented by one each time a new instance of Bash is started.
This is intended to be an account of how deeply your Bash shells
are nested.
This is intended to be a count of how deeply your Bash shells are
nested.
`OPTERR'
If set to the value 1, Bash displays error messages generated by
@ -3706,9 +3723,13 @@ normally treat them specially.
This variable overrides the value of `LANG' and any other `LC_'
variable specifying a locale category.
`LC_COLLATE'
This variable determines the collation order used when sorting the
results of filename expansion (*note Filename Expansion::.).
`LC_MESSAGES'
This variable determines the locale used to translate double-quoted
strings preceded by a `$'.
strings preceded by a `$' (*note Locale Translation::.).
`IGNOREEOF'
Controls the action of the shell on receipt of an `EOF' character
@ -4110,6 +4131,9 @@ specified by POSIX.2 in areas where the Bash default differs.
20. Assignment statements preceding POSIX.2 `special' builtins persist
in the shell environment after the builtin completes.
21. The `export' and `readonly' builtin commands display their output
in the format required by POSIX.2.
There is other POSIX.2 behavior that Bash does not implement.
Specifically:
@ -4264,10 +4288,11 @@ Job Control Builtins
kill [-s SIGSPEC] [-n SIGNUM] [-SIGSPEC] JOBSPEC
kill -l [SIGSPEC]
Send a signal specified by SIGSPEC or SIGNUM to the process named
by JOBSPEC. SIGSPEC is either a signal name such as `SIGINT' or a
signal number; SIGNUM is a signal number. If SIGSPEC and SIGNUM
are not present, `SIGTERM' is used. The `-l' option lists the
signal names, or the signal name corresponding to SIGSPEC.
by JOBSPEC. SIGSPEC is either a signal name such as `SIGINT'
(with or without the `SIG' prefix) or a signal number; SIGNUM is a
signal number. If SIGSPEC and SIGNUM are not present, `SIGTERM'
is used. The `-l' option lists the signal names, or the signal
name corresponding to SIGSPEC.
`wait'
wait [JOBSPEC|PID]
@ -4304,12 +4329,12 @@ Job Control Variables
This variable controls how the shell interacts with the user and
job control. If this variable exists then single word simple
commands without redirects are treated as candidates for resumption
of an existing job. There is no ambiguity allowed; if you have
more than one job beginning with the string that you have typed,
then the most recently accessed job will be selected. The name of
a stopped job, in this context, is the command line used to start
it. If this variable is set to the value `exact', the string
supplied must match the name of a stopped job exactly; if set to
of an existing job. There is no ambiguity allowed; if there is
more than one job beginning with the string typed, then the most
recently accessed job will be selected. The name of a stopped
job, in this context, is the command line used to start it. If
this variable is set to the value `exact', the string supplied
must match the name of a stopped job exactly; if set to
`substring', the string supplied needs to match a substring of the
name of a stopped job. The `substring' value provides
functionality analogous to the `%?' job ID (*note Job Control
@ -5094,31 +5119,31 @@ binding, variable assignment, and conditional syntax.
#
# Arrow keys in keypad mode
#
#"\M-OD" backward-char
#"\M-OC" forward-char
#"\M-OA" previous-history
#"\M-OB" next-history
#"\M-OD": backward-char
#"\M-OC": forward-char
#"\M-OA": previous-history
#"\M-OB": next-history
#
# Arrow keys in ANSI mode
#
"\M-[D" backward-char
"\M-[C" forward-char
"\M-[A" previous-history
"\M-[B" next-history
"\M-[D": backward-char
"\M-[C": forward-char
"\M-[A": previous-history
"\M-[B": next-history
#
# Arrow keys in 8 bit keypad mode
#
#"\M-\C-OD" backward-char
#"\M-\C-OC" forward-char
#"\M-\C-OA" previous-history
#"\M-\C-OB" next-history
#"\M-\C-OD": backward-char
#"\M-\C-OC": forward-char
#"\M-\C-OA": previous-history
#"\M-\C-OB": next-history
#
# Arrow keys in 8 bit ANSI mode
#
#"\M-\C-[D" backward-char
#"\M-\C-[C" forward-char
#"\M-\C-[A" previous-history
#"\M-\C-[B" next-history
#"\M-\C-[D": backward-char
#"\M-\C-[C": forward-char
#"\M-\C-[A": previous-history
#"\M-\C-[B": next-history
C-q: quoted-insert
@ -5410,10 +5435,17 @@ Specifying Numeric Arguments
argument. M- starts a negative argument.
`universal-argument ()'
Each time this is executed, the argument count is multiplied by
four. The argument count is initially one, so executing this
function the first time makes the argument count four. By
default, this is not bound to a key.
This is another way to specify an argument. If this command is
followed by one or more digits, optionally with a leading minus
sign, those digits define the argument. If the command is
followed by digits, executing `universal-argument' again ends the
numeric argument, but is otherwise ignored. As a special case, if
this command is immediately followed by a character that is
neither a digit or minus sign, the argument count for the next
command is multiplied by four. The argument count is initially
one, so executing this function the first time makes the argument
count four, a second time makes the argument count sixteen, and so
on. By default, this is not bound to a key.

File: bashref.info, Node: Commands For Completion, Next: Keyboard Macros, Prev: Numeric Arguments, Up: Bindable Readline Commands
@ -5606,6 +5638,12 @@ Some Miscellaneous Commands
`history-expand-line (M-^)'
Perform history expansion on the current line.
`alias-expand-line'
Perform alias expansion on the current line (*note Aliases::.).
`history-and-alias-expand-line'
Perform history and alias expansion on the current line.
`insert-last-argument (M-., M-_)'
A synonym for `yank-last-arg'.
@ -5652,7 +5690,7 @@ OS/2, Windows 95, and Windows NT.
* Menu:
* Basic Installation:: Generic installation instructions.
* Basic Installation:: Installation instructions.
* Compilers and Options:: How to set special options for various
systems.
@ -5679,7 +5717,7 @@ File: bashref.info, Node: Basic Installation, Next: Compilers and Options, Up
Basic Installation
==================
These are generic installation instructions for Bash.
These are installation instructions for Bash.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
@ -5702,7 +5740,15 @@ they can be considered for the next release.
The file `configure.in' is used to create `configure' by a program
called Autoconf. You only need `configure.in' if you want to change it
or regenerate `configure' using a newer version of Autoconf. If you do
this, make sure you are using Autoconf version 2.9 or newer.
this, make sure you are using Autoconf version 2.10 or newer.
If you need to change `configure.in' or regenerate `configure', you
will need to create two files: `_distribution' and `_patchlevel'.
`_distribution' should contain the major and minor version numbers of
the Bash distribution, for example `2.01'. `_patchlevel' should
contain the patch level of the Bash distribution, `0' for example. The
script `support/mkconffiles' has been provided to automate the creation
of these files.
The simplest way to compile Bash is:
@ -5880,21 +5926,27 @@ configure Bash without a feature that is enabled by default, use
Here is a complete list of the `--enable-' and `--with-' options
that the Bash `configure' recognizes.
`--with-gnu-malloc'
Use the GNU version of `malloc' in `lib/malloc/malloc.c'. This is
not the same `malloc' that appears in GNU libc, but an older
version derived from the 4.2 BSD `malloc'. This `malloc' is very
fast, but wastes a lot of space. This option is enabled by
default. The `NOTES' file contains a list of systems for which
this should be turned off.
`--with-afs'
Define if you are using the Andrew File System from Transarc.
`--with-curses'
Use the curses library instead of the termcap library. This should
be supplied if your system has an inadequate or incomplete termcap
database.
`--with-glibc-malloc'
Use the GNU libc version of `malloc' in `lib/malloc/gmalloc.c'.
This is somewhat slower than the default `malloc', but wastes
considerably less space.
`--with-afs'
Define if you are using the Andrew File System from Transarc.
`--with-gnu-malloc'
Use the GNU version of `malloc' in `lib/malloc/malloc.c'. This is
not the same `malloc' that appears in GNU libc, but an older
version derived from the 4.2 BSD `malloc'. This `malloc' is very
fast, but wastes a lot of space. This option is enabled by
default. The `NOTES' file contains a list of systems for which
this should be turned off, and `configure' disables this option
automatically for a number of systems.
`--with-purify'
Define this to use the Purify memory allocation checker from Pure
@ -5912,32 +5964,48 @@ enabled using `enable-FEATURE'.
`usg-echo-default' are enabled by default, unless the operating system
does not provide the necessary support.
`--enable-job-control'
This enables job control features, if the OS supports them.
`--enable-alias'
Allow alias expansion and include the `alias' and `unalias'
builtins.
`--enable-readline'
Include support for command-line editing and history with the Bash
version of the Readline library.
`--enable-history'
Include command history and the `fc' and `history' builtin
commands.
`--enable-array-variables'
Include support for one-dimensional array shell variables.
`--enable-bang-history'
Include support for `csh'-like history substitution.
`--enable-brace-expansion'
Include `csh'-like brace expansion ( `b{a,b}c' ==> `bac bbc' ).
`--enable-command-timing'
Include support for recognizing `time' as a reserved word and for
displaying timing statistics for the pipeline following `time'.
This allows pipelines as well as shell builtins and functions to
be timed.
`--enable-directory-stack'
Include support for a `csh'-like directory stack and the `pushd',
`popd', and `dirs' builtins.
`--enable-restricted'
Include support for a "restricted shell". If this is enabled,
Bash, when called as `rbash', enters a restricted mode. See *Note
The Restricted Shell::, for a description of restricted mode.
`--enable-disabled-builtins'
Allow builtin commands to be invoked via `builtin xxx' even after
`xxx' has been disabled using `enable -n xxx'. See *Note Bash
Builtins::, for details of the `builtin' and `enable' builtin
commands.
`--enable-dparen-arithmetic'
Include support for the `ksh' `((...))' command.
`--enable-help-builtin'
Include the `help' builtin, which displays help on shell builtins
and variables.
`--enable-history'
Include command history and the `fc' and `history' builtin
commands.
`--enable-job-control'
This enables job control features, if the OS supports them.
`--enable-process-substitution'
This enables process substitution (*note Process Substitution::.)
@ -5948,35 +6016,19 @@ does not provide the necessary support.
characters in the `$PS1', `$PS2', `$PS3', and `$PS4' prompt
strings.
`--enable-readline'
Include support for command-line editing and history with the Bash
version of the Readline library.
`--enable-restricted'
Include support for a "restricted shell". If this is enabled,
Bash, when called as `rbash', enters a restricted mode. See *Note
The Restricted Shell::, for a description of restricted mode.
`--enable-select'
Include the `ksh' `select' builtin, which allows the generation of
simple menus.
`--enable-help-builtin'
Include the `help' builtin, which displays help on shell builtins
and variables.
`--enable-array-variables'
Include support for one-dimensional array shell variables.
`--enable-dparen-arithmetic'
Include support for the `ksh' `((...))' command.
`--enable-brace-expansion'
Include `csh'-like brace expansion ( `b{a,b}c' ==> `bac bbc' ).
`--enable-disabled-builtins'
Allow builtin commands to be invoked via `builtin xxx' even after
`xxx' has been disabled using `enable -n xxx'. See *Note Bash
Builtins::, for details of the `builtin' and `enable' builtin
commands.
`--enable-command-timing'
Include support for recognizing `time' as a reserved word and for
displaying timing statistics for the pipeline following `time'.
This allows pipelines as well as shell builtins and functions to
be timed.
`--enable-usg-echo-default'
Make the `echo' builtin expand backslash-escaped characters by
default, without requiring the `-e' option. This makes the Bash
@ -6000,7 +6052,7 @@ of Bash that you have.
Once you have determined that a bug actually exists, use the
`bashbug' command to submit a bug report. If you have a fix, you are
welcome to mail that as well! Suggestions and `philosophical' bug
encouraged to mail that as well! Suggestions and `philosophical' bug
reports may be mailed to `bug-bash@prep.ai.MIT.Edu' or posted to the
Usenet newsgroup `gnu.bash.bug'.
@ -6132,6 +6184,7 @@ Parameter and Variable Index
* _: Special Parameters.
* auto_resume: Job Control Variables.
* BASH: Bash Variables.
* BASH_ENV: Bash Variables.
* BASH_VERSINFO: Bash Variables.
* BASH_VERSION: Bash Variables.
* bell-style: Readline Init File Syntax.
@ -6143,12 +6196,12 @@ Parameter and Variable Index
* disable-completion: Readline Init File Syntax.
* editing-mode: Readline Init File Syntax.
* enable-keypad: Readline Init File Syntax.
* ENV: Korn Shell Variables.
* EUID: Bash Variables.
* expand-tilde: Readline Init File Syntax.
* FCEDIT: Korn Shell Variables.
* FIGNORE: Bash Variables.
* GLOBIGNORE: Bash Variables.
* GROUPS: Bash Variables.
* histchars: Bash Variables.
* HISTCMD: Bash Variables.
* HISTCONTROL: Bash Variables.
@ -6169,6 +6222,7 @@ Parameter and Variable Index
* keymap: Readline Init File Syntax.
* LANG: Bash Variables.
* LC_ALL: Bash Variables.
* LC_COLLATE: Bash Variables.
* LC_MESSAGES: Bash Variables.
* LINENO: Korn Shell Variables.
* MACHTYPE: Bash Variables.
@ -6391,123 +6445,123 @@ Concept Index

Tag Table:
Node: Top1009
Node: Introduction3117
Node: What is Bash?3342
Node: What is a shell?4426
Node: Definitions6307
Node: Basic Shell Features8947
Node: Shell Syntax10468
Node: Shell Operation10758
Node: Quoting11992
Node: Escape Character13027
Node: Single Quotes13458
Node: Double Quotes13787
Node: ANSI-C Quoting14483
Node: Locale Translation15215
Node: Comments15636
Node: Simple Commands16160
Node: Pipelines16749
Node: Lists17820
Node: Looping Constructs19095
Node: Conditional Constructs20272
Node: Command Grouping22337
Node: Shell Functions23721
Node: Shell Parameters25489
Node: Positional Parameters26812
Node: Special Parameters27506
Node: Shell Expansions29998
Node: Shell Parameter Expansion31998
Node: Command Substitution38003
Node: Process Substitution39003
Node: Word Splitting39909
Node: Filename Expansion41361
Node: Quote Removal43727
Node: Redirections44013
Node: Executing Commands49754
Node: Command Search and Execution50209
Node: Environment51943
Node: Exit Status53579
Node: Signals54596
Node: Shell Scripts55807
Node: Bourne Shell Features57676
Node: Bourne Shell Builtins58346
Node: Bourne Shell Variables66619
Node: Other Bourne Shell Features68156
Node: Major Differences From The Bourne Shell68913
Node: Csh Features79111
Node: Brace Expansion80029
Node: Tilde Expansion81584
Node: C Shell Builtins82216
Node: C Shell Variables86732
Node: Korn Shell Features87140
Node: Korn Shell Constructs87868
Node: Korn Shell Builtins89562
Node: Korn Shell Variables91720
Node: Aliases93505
Node: Alias Builtins95969
Node: Bash Features96585
Node: Invoking Bash97576
Node: Bash Startup Files101441
Node: Is This Shell Interactive?105024
Node: Bash Builtins105755
Node: The Set Builtin121569
Node: Bash Conditional Expressions126939
Node: Bash Variables131590
Node: Shell Arithmetic141103
Node: Arithmetic Evaluation141571
Node: Arithmetic Expansion143601
Node: Arithmetic Builtins144405
Node: Arrays144876
Node: Printing a Prompt147903
Node: The Restricted Shell149501
Node: Bash POSIX Mode150731
Node: Job Control154303
Node: Job Control Basics154768
Node: Job Control Builtins158911
Node: Job Control Variables161794
Node: Using History Interactively162955
Node: Bash History Facilities163544
Node: History Interaction165942
Node: Event Designators168504
Node: Word Designators169427
Node: Modifiers170676
Node: Command Line Editing171993
Node: Introduction and Notation172653
Node: Readline Interaction173661
Node: Readline Bare Essentials174849
Node: Readline Movement Commands176378
Node: Readline Killing Commands177268
Node: Readline Arguments178970
Node: Searching179943
Node: Readline Init File181579
Node: Readline Init File Syntax182635
Node: Conditional Init Constructs190424
Node: Sample Init File192705
Node: Bindable Readline Commands195722
Node: Commands For Moving196472
Node: Commands For History197319
Node: Commands For Text199992
Node: Commands For Killing201734
Node: Numeric Arguments203760
Node: Commands For Completion204386
Node: Keyboard Macros207348
Node: Miscellaneous Commands207906
Node: Readline vi Mode211937
Node: Installing Bash212813
Node: Basic Installation213890
Node: Compilers and Options216389
Node: Compiling For Multiple Architectures217123
Node: Installation Names218780
Node: Specifying the System Type219502
Node: Sharing Defaults220213
Node: Operation Controls220878
Node: Optional Features221783
Node: Reporting Bugs226408
Node: Builtin Index227485
Node: Reserved Word Index230898
Node: Variable Index232206
Node: Function Index237285
Node: Concept Index241643
Node: Top1005
Node: Introduction3109
Node: What is Bash?3334
Node: What is a shell?4418
Node: Definitions6299
Node: Basic Shell Features8960
Node: Shell Syntax10481
Node: Shell Operation10771
Node: Quoting12005
Node: Escape Character13040
Node: Single Quotes13471
Node: Double Quotes13800
Node: ANSI-C Quoting14496
Node: Locale Translation15228
Node: Comments15649
Node: Simple Commands16173
Node: Pipelines16762
Node: Lists17833
Node: Looping Constructs19108
Node: Conditional Constructs20285
Node: Command Grouping22352
Node: Shell Functions23738
Node: Shell Parameters25511
Node: Positional Parameters26834
Node: Special Parameters27528
Node: Shell Expansions30094
Node: Shell Parameter Expansion32098
Node: Command Substitution38106
Node: Process Substitution39106
Node: Word Splitting40012
Node: Filename Expansion41464
Node: Quote Removal43830
Node: Redirections44116
Node: Executing Commands49857
Node: Command Search and Execution50312
Node: Environment52046
Node: Exit Status53682
Node: Signals54699
Node: Shell Scripts55910
Node: Bourne Shell Features57779
Node: Bourne Shell Builtins58449
Node: Bourne Shell Variables66803
Node: Other Bourne Shell Features68340
Node: Major Differences From The Bourne Shell69097
Node: Csh Features79457
Node: Brace Expansion80375
Node: Tilde Expansion81930
Node: C Shell Builtins82562
Node: C Shell Variables87118
Node: Korn Shell Features87526
Node: Korn Shell Constructs88254
Node: Korn Shell Builtins89969
Node: Korn Shell Variables92127
Node: Aliases93686
Node: Alias Builtins96150
Node: Bash Features96766
Node: Invoking Bash97757
Node: Bash Startup Files101622
Node: Is This Shell Interactive?105197
Node: Bash Builtins106180
Node: The Set Builtin122035
Node: Bash Conditional Expressions127410
Node: Bash Variables132061
Node: Shell Arithmetic142095
Node: Arithmetic Evaluation142563
Node: Arithmetic Expansion144593
Node: Arithmetic Builtins145397
Node: Arrays145868
Node: Printing a Prompt148895
Node: The Restricted Shell150493
Node: Bash POSIX Mode151723
Node: Job Control155407
Node: Job Control Basics155872
Node: Job Control Builtins160015
Node: Job Control Variables162938
Node: Using History Interactively164085
Node: Bash History Facilities164674
Node: History Interaction167072
Node: Event Designators169634
Node: Word Designators170557
Node: Modifiers171806
Node: Command Line Editing173123
Node: Introduction and Notation173783
Node: Readline Interaction174791
Node: Readline Bare Essentials175979
Node: Readline Movement Commands177508
Node: Readline Killing Commands178398
Node: Readline Arguments180100
Node: Searching181073
Node: Readline Init File182709
Node: Readline Init File Syntax183765
Node: Conditional Init Constructs191554
Node: Sample Init File193835
Node: Bindable Readline Commands196868
Node: Commands For Moving197618
Node: Commands For History198465
Node: Commands For Text201138
Node: Commands For Killing202880
Node: Numeric Arguments204906
Node: Commands For Completion206030
Node: Keyboard Macros208992
Node: Miscellaneous Commands209550
Node: Readline vi Mode213766
Node: Installing Bash214642
Node: Basic Installation215711
Node: Compilers and Options218636
Node: Compiling For Multiple Architectures219370
Node: Installation Names221027
Node: Specifying the System Type221749
Node: Sharing Defaults222460
Node: Operation Controls223125
Node: Optional Features224030
Node: Reporting Bugs228913
Node: Builtin Index229993
Node: Reserved Word Index233406
Node: Variable Index234714
Node: Function Index239899
Node: Concept Index244257

End Tag Table

View File

@ -5,13 +5,13 @@
@c %**end of header
@ignore
last change: Mon Nov 25 11:47:06 EST 1996
last change: Mon May 19 12:55:22 EDT 1997
@end ignore
@set EDITION 2.0
@set VERSION 2.0
@set UPDATED 25 November 1996
@set UPDATE-MONTH November 1996
@set VERSION 2.01
@set UPDATED 19 May 1997
@set UPDATE-MONTH May 1997
@iftex
@finalout
@ -272,8 +272,8 @@ from it, that are all in the same process group.
@item job control
@cindex job control
A mechanism by which users can selectively start and stop execution
of processes.
A mechanism by which users can selectively stop (suspend) and restart
(resume) execution of processes.
@item metacharacter
@cindex metacharacter
@ -717,7 +717,7 @@ has a non-zero exit status, then execute @var{alternate-consequents}.
The syntax of the @code{case} command is:
@example
@code{case @var{word} in [@var{pattern} [| @var{pattern}]@dots{}) @var{commands} ;;]@dots{} esac}
@code{case @var{word} in [ ( @var{pattern} [| @var{pattern}]@dots{}) @var{commands} ;;]@dots{} esac}
@end example
Selectively execute @var{commands} based upon @var{word} matching
@ -744,7 +744,7 @@ echo " legs."
@end example
The @var{expression} is evaluated according to the rules described
below ((@pxref{Arithmetic Evaluation}).
below (@pxref{Arithmetic Evaluation}).
If the value of the expression is non-zero, the return status is 0;
otherwise the return status is 1. This is exactly equivalent to
@example
@ -794,7 +794,7 @@ between these two constructs due to historical reasons. The braces
are @code{reserved words}, so they must be separated from the @var{list}
by @code{blank}s. The parentheses are @code{operators}, and are
recognized as separate tokens by the shell even if they are not separated
from @code{list} by whitespace.
from the @var{list} by whitespace.
The exit status of both of these constructs is the exit status of
@var{list}.
@ -825,10 +825,9 @@ the exit status of the last command executed in the body.
When a function is executed, the arguments to the
function become the positional parameters
during its execution (@pxref{Positional Parameters}).
The special parameter
@samp{#} that gives the number of positional parameters
is updated to reflect the change. Positional parameter @code{0}
is unchanged.
The special parameter @samp{#} that expands to the number of
positional parameters is updated to reflect the change.
Positional parameter @code{0} is unchanged.
If the builtin command @code{return}
is executed in a function, the function completes and
@ -919,8 +918,11 @@ of the @code{IFS}
special variable. That is, @code{"$*"} is equivalent
to @code{"$1@var{c}$2@var{c}@dots{}"}, where @var{c}
is the first character of the value of the @code{IFS}
variable. If @code{IFS}
is null or unset, the parameters are separated by spaces.
variable.
If @code{IFS} is unset, the parameters are separated by spaces.
If @code{IFS} is null, the parameters are joined without intervening
separators.
@item @@
Expands to the positional parameters, starting from one. When the
@ -1020,7 +1022,7 @@ Only brace expansion, word splitting, and filename expansion
can change the number of words of the expansion; other expansions
expand a single word to a single word.
The only exceptions to this are the expansions of
@code{"$@@"} (@pxref{Special Parameters}) and @code{"$@{[@@]@}"}
@code{"$@@"} (@pxref{Special Parameters}) and @code{"$@{@var{name}[@@]@}"}
(@pxref{Arrays}).
After all expansions, @code{quote removal} (@pxref{Quote Removal})
@ -1050,7 +1052,7 @@ If the first character of @var{parameter} is an exclamation point,
a level of variable indirection is introduced.
Bash uses the value of the variable formed from the rest of
@var{parameter} as the name of the variable; this variable is then
expanded and that value used in the rest of the substitution, rather
expanded and that value is used in the rest of the substitution, rather
than the value of @var{parameter} itself.
This is known as @code{indirect expansion}.
@ -1953,21 +1955,23 @@ Print out the user and system times used by the shell and its children.
@item trap
@btindex trap
@example
trap [-lp] [@var{arg}] [@var{sigspec}]
trap [-lp] [@var{arg}] [@var{sigspec} @dots{}]
@end example
The commands in @var{arg} are to be read and executed when the
shell receives signal @var{sigspec}. If @var{arg} is absent or
equal to @samp{-}, all specified signals are reset to the values
they had when the shell was started.
If @var{arg} is the null string, then @var{sigspec} is ignored by
the shell and commands it invokes.
If @var{arg} is the null string, then the signal specified by
each @var{sigspec} is ignored by the shell and commands it invokes.
If @var{arg} is @samp{-p}, the shell displays the trap commands
associated with each @var{sigspec}. If no arguments are supplied, or
only @samp{-p} is given, @code{trap} prints the list of commands
associated with each signal number. @var{sigspec} is either a signal
name such as @code{SIGINT} or a signal number. If @var{sigspec} is
@code{0} or @code{EXIT}, @var{arg} is executed when the shell exits.
If @var{sigspec} is @code{DEBUG}, the command @var{arg} is executed
associated with each signal number.
Each @var{sigspec} is either a signal name such as @code{SIGINT} (with
or without the @code{SIG} prefix) or a signal number.
If a @var{sigspec}
is @code{0} or @code{EXIT}, @var{arg} is executed when the shell exits.
If a @var{sigspec} is @code{DEBUG}, the command @var{arg} is executed
after every simple command.
The @samp{-l} option causes the shell to print a list of signal names
and their corresponding numbers.
@ -2136,7 +2140,7 @@ quotes. The @samp{-D} and @samp{--dump-strings} invocation options
list the translatable strings found in a script
(@pxref{Locale Translation}).
The expansion @code{$@{var:}@var{length}@code{[:}@var{offset}@code{]@}},
The expansion @code{$@{var:}@var{offset}@code{[:}@var{length}@code{]@}},
which expands to the substring of @code{var}'s value of length
@var{length}, optionally beginning at @var{offset}, is present
(@pxref{Shell Parameter Expansion}).
@ -2155,7 +2159,7 @@ Bash can expand positional parameters beyond @code{$9} using
Bash has process substitution (@pxref{Process Substitution}).
Bash automatically assigns variables that provide information about the
current user (@code{UID} and @code{EUID}), the current host
current user (@code{UID}, @code{EUID}, and @code{GROUPS}), the current host
(@code{HOSTTYPE}, @code{OSTYPE}, @code{MACHTYPE}, and @code{HOSTNAME}),
and the instance of Bash that is running (@code{BASH},
@code{BASH_VERSION}, and @code{BASH_VERSINFO}. @xref{Bash Variables},
@ -2172,7 +2176,8 @@ Bash functions are permitted to have local variables using the
@code{local} builtin, and thus useful recursive functions may be written.
Variable assignments preceding commands affect only that command, even
builtins and functions. In @code{sh}, all variable assignments
builtins and functions (@pxref{Environment}).
In @code{sh}, all variable assignments
preceding commands are global unless the command is executed from the
file system.
@ -2249,14 +2254,16 @@ used as shell input, a @samp{-n} option to remove various variable
attributes, and @samp{name=value} arguments to set variable attributes
and values simultaneously.
The Bash @code{cd} and @code{pwd} builtins each take @samp{-L} and
@samp{-P} builtins to switch between logical and physical modes.
The Bash @code{cd} and @code{pwd} builtins (@pxref{Bourne Shell Builtins})
each take @samp{-L} and @samp{-P} builtins to switch between logical and
physical modes.
The Bash @code{type} builtin is more extensive and gives more information
about the names it finds.
about the names it finds (@pxref{Bash Builtins}).
Bash implements a @code{csh}-like directory stack, and provides the
@code{pushd}, @code{popd}, and @code{dirs} builtins to manipulate it.
@code{pushd}, @code{popd}, and @code{dirs} builtins to manipulate it
(@pxref{C Shell Builtins}).
Bash also makes the directory stack visible as the value of the
@code{DIRSTACK} shell variable.
@ -2304,10 +2311,11 @@ trapping @code{SIGSEGV}. If the shell is started from a process with
function call), the shell misbehaves badly.
@item
In a questionable attempt at security, the @sc{SVR4.2} shell
will alter its real
In a questionable attempt at security, the @sc{SVR4.2} shell,
when invoked without the @samp{-p} option, will alter its real
and effective @sc{UID} and @sc{GID} if they are less than some
threshold value, commonly 100. This can lead to unexpected results.
magic threshold value, commonly 100.
This can lead to unexpected results.
@item
The @sc{SVR4.2} shell does not allow users to trap @code{SIGALRM} or
@ -2330,7 +2338,7 @@ with a @samp{-}.
@item
The @sc{SVR4.2} shell exits a script if any builtin fails; Bash exits
a script only if one of the @sc{POSIX.2} special builtins fails, and
only for certain failures, as enumerated in the @code{POSIX.2} standard.
only for certain failures, as enumerated in the @sc{POSIX.2} standard.
@item
The @sc{SVR4.2} shell behaves differently when invoked as @code{jsh}
@ -2454,12 +2462,12 @@ arguments, exchanges the top two directories.
@table @code
@item +@var{N}
Brings the @var{N}th directory (counting from the left of the
list printed by @code{dirs}) to the top of the list by rotating
the stack.
list printed by @code{dirs}, starting with zero) to the top of
the list by rotating the stack.
@item -@var{N}
Brings the @var{N}th directory (counting from the right of the
list printed by @code{dirs}) to the top of the list by rotating
the stack.
list printed by @code{dirs}, starting with zero) to the top of
the list by rotating the stack.
@item -n
Suppresses the normal change of directory when adding directories
to the stack, so that only the stack is manipulated.
@ -2644,8 +2652,9 @@ The @var{commands} are executed after each selection until a
point the @code{select} command completes.
Bash also has adopted command timing from the Korn shell. If the
@code{time} reserved word precedes a pipeline or simple command,
timing statistics for the pipeline are displayed when it completes.
@code{time} reserved word precedes a pipeline, which may consist
of a single command, timing statistics for the pipeline are displayed
when it completes.
The statistics currently consist of elapsed (wall-clock) time and
user and system time consumed by the command's execution.
@ -2751,11 +2760,6 @@ not arrive.
@item LINENO
The line number in the script or shell function currently executing.
@item ENV
If this variable is set when Bash is invoked to execute a shell
script, its value is expanded and used as the name of a startup file
to read before executing the script. @xref{Bash Startup Files}.
@item FCEDIT
The editor used as a default by the @code{fc} builtin command.
@ -2992,12 +2996,12 @@ in the script. If no commands are executed, the exit status is 0.
@section Bash Startup Files
@cindex startup files
This section describs how bash executes its startup files.
If any of the files exist but cannot be read, bash reports an error.
This section describs how Bash executes its startup files.
If any of the files exist but cannot be read, Bash reports an error.
Tildes are expanded in file names as described above under
Tilde Expansion (@pxref{Tilde Expansion}).
When Bash is invoked as a login shell, it first reads and
When Bash is invoked as an interactive login shell, it first reads and
executes commands from the file @file{/etc/profile}, if that file exists.
After reading that file, it looks for @file{~/.bash_profile},
@file{~/.bash_login}, and @file{~/.profile}, in that order, and reads
@ -3059,7 +3063,7 @@ for startup files.
In this mode, the @code{ENV} variable is expanded and commands are read
and executed from the file whose name is the expanded value.
No other startup files are read.
This is done by both interactive and non-interactive shells.
This is done by interactive shells only.
Bash attempts to determine when it is being run by the remote shell
daemon, usually @code{rshd}. If Bash determines it is being run by
@ -3093,6 +3097,16 @@ else
fi
@end example
Alternatively, you may test the value of the @samp{-} special parameter.
It contains @code{i} when the shell is interactive. For example:
@example
case "$-" in
*i*) echo This shell is interactive ;;
*) echo This shell is not interactive ;;
esac
@end example
@node Bash Builtins
@section Bash Builtin Commands
@ -3173,9 +3187,9 @@ Remove any current binding for @var{keyseq}
@example
builtin [@var{shell-builtin} [@var{args}]]
@end example
Run a shell builtin. This is useful when you wish to rename a
shell builtin to be a function, but need the functionality of the
builtin within the function itself.
Run a shell builtin. This is useful when you wish to define a
shell function with the same name as a shell builtin, but need the
functionality of the builtin within the function itself.
@item command
@btindex command
@ -3423,7 +3437,7 @@ The errors checked for are transposed characters,
a missing character, and a character too many.
If a correction is found, the corrected path is printed,
and the command proceeds.
This option is enabled by default, but is only used by interactive shells.
This option is only used by interactive shells.
@item checkhash
If this is set, Bash checks that a command found in the hash
@ -3470,7 +3484,8 @@ the Readline editing buffer, allowing further modification.
@item hostcomplete
If set, and Readline is being used, Bash will attempt to perform
hostname completion when a word beginning with @samp{@@} is being
completed (@pxref{Commands For Completion}).
completed (@pxref{Commands For Completion}). This option is enabled
by default.
@item interactive_comments
Allow a word beginning with @samp{#}
@ -3718,7 +3733,7 @@ same as @code{-x}.
@item -p
Turn on privileged mode.
In this mode, the @code{$ENV}
In this mode, the @code{$BASH_ENV}
file is not processed, and shell functions
are not inherited from the environment. This is enabled automatically
on startup if the effective user (group) id is not equal to the real
@ -3962,6 +3977,11 @@ do not normally treat them specially.
@vtable @code
@item BASH_ENV
If this variable is set when Bash is invoked to execute a shell
script, its value is expanded and used as the name of a startup file
to read before executing the script. @xref{Bash Startup Files}.
@item TIMEFORMAT
The value of this parameter is used as a format string specifying
how the timing information for pipelines prefixed with the @code{time}
@ -4002,7 +4022,9 @@ the form @var{MM}m@var{SS}.@var{FF}s.
The value of @var{p} determines whether or not the fraction is included.
If this variable is not set, bash acts as if it had the value
@example
@code{$'\nreal\t%3lR\nuser\t%3lU\nsys\t%3lS'}.
@end example
If the value is null, no timing information is displayed.
A trailing newline is added when the format string is displayed.
@ -4086,6 +4108,10 @@ The numeric real user id of the current user.
@item EUID
The numeric effective user id of the current user.
@item GROUPS
An array variable containing the list of groups of which the current
user is a member.
@item PPID
The process id of the shell's parent process.
@ -4184,7 +4210,7 @@ The value of @code{MACHTYPE}.
@item SHLVL
Incremented by one each time a new instance of Bash is started. This is
intended to be an account of how deeply your Bash shells are nested.
intended to be a count of how deeply your Bash shells are nested.
@item OPTERR
If set to the value 1, Bash displays error messages
@ -4198,9 +4224,13 @@ selected with a variable starting with @code{LC_}.
This variable overrides the value of @code{LANG} and any other
@code{LC_} variable specifying a locale category.
@item LC_COLLATE
This variable determines the collation order used when sorting the
results of filename expansion (@pxref{Filename Expansion}).
@item LC_MESSAGES
This variable determines the locale used to translate double-quoted
strings preceded by a @samp{$}.
strings preceded by a @samp{$} (@pxref{Locale Translation}).
@item IGNOREEOF
Controls the action of the shell on receipt of an @code{EOF} character
@ -4608,14 +4638,6 @@ the POSIX.2 standard, and include things like passing incorrect options,
redirection errors, variable assignment errors for assignments preceding
the command name, and so on.
@ignore
@item
The environment passed to executed commands is not sorted. Neither is
the output of @code{set}. This is not strictly Posix.2 behavior, but
@code{sh} does it this way. @code{ksh} does not. It's not necessary to
sort the environment; no program should rely on it being sorted.
@end ignore
@item
If the @code{cd} builtin finds a directory to change to
using @code{$CDPATH}, the
@ -4641,6 +4663,10 @@ Process substitution is not available.
Assignment statements preceding @sc{POSIX.2} @code{special} builtins
persist in the shell environment after the builtin completes.
@item
The @code{export} and @code{readonly} builtin commands display their
output in the format required by @sc{POSIX.2}.
@end enumerate
There is other @sc{POSIX.2} behavior that Bash does not implement.
@ -4826,9 +4852,10 @@ kill [-s @var{sigspec}] [-n @var{signum}] [-@var{sigspec}] @var{jobspec}
kill -l [@var{sigspec}]
@end example
Send a signal specified by @var{sigspec} or @var{signum} to the process
named by @var{jobspec}. @var{sigspec} is either a signal name such as
@code{SIGINT} or a signal number; @var{signum} is a signal number. If
@var{sigspec} and @var{signum} are not present, @code{SIGTERM} is used.
named by @var{jobspec}.
@var{sigspec} is either a signal name such as @code{SIGINT} (with or without
the @code{SIG} prefix) or a signal number; @var{signum} is a signal number.
If @var{sigspec} and @var{signum} are not present, @code{SIGTERM} is used.
The @samp{-l} option lists the signal names, or the signal name
corresponding to @var{sigspec}.
@ -4878,8 +4905,8 @@ supplied process @sc{ID}s.
This variable controls how the shell interacts with the user and
job control. If this variable exists then single word simple
commands without redirects are treated as candidates for resumption
of an existing job. There is no ambiguity allowed; if you have
more than one job beginning with the string that you have typed, then
of an existing job. There is no ambiguity allowed; if there is
more than one job beginning with the string typed, then
the most recently accessed job will be selected.
The name of a stopped job, in this context, is the command line
used to start it. If this variable is set to the value @samp{exact},
@ -4912,7 +4939,7 @@ version of Unix (and, someday, @sc{GNU}). Other independent ports exist for
@sc{OS/2}, Windows 95, and Windows @sc{NT}.
@menu
* Basic Installation:: Generic installation instructions.
* Basic Installation:: Installation instructions.
* Compilers and Options:: How to set special options for various
systems.
@ -4941,7 +4968,7 @@ version of Unix (and, someday, @sc{GNU}). Other independent ports exist for
@cindex Bash installation
@cindex Bash configuration
These are generic installation instructions for Bash.
These are installation instructions for Bash.
The @code{configure} shell script attempts to guess correct
values for various system-dependent variables used during
@ -4969,8 +4996,17 @@ The file @file{configure.in} is used to create @code{configure}
by a program called Autoconf. You only need
@file{configure.in} if you want to change it or regenerate
@code{configure} using a newer version of Autoconf. If
you do this, make sure you are using Autoconf version 2.9 or
newer.
you do this, make sure you are using Autoconf version 2.10 or
newer.
If you need to change @file{configure.in} or regenerate
@code{configure}, you will need to create two files:
@file{_distribution} and @file{_patchlevel}. @file{_distribution}
should contain the major and minor version numbers of the Bash
distribution, for example @samp{2.01}. @file{_patchlevel} should
contain the patch level of the Bash distribution, @samp{0} for
example. The script @file{support/mkconffiles} has been provided
to automate the creation of these files.
The simplest way to compile Bash is:
@ -5153,6 +5189,19 @@ Here is a complete list of the @samp{--enable-} and
@samp{--with-} options that the Bash @code{configure} recognizes.
@table @code
@item --with-afs
Define if you are using the Andrew File System from Transarc.
@item --with-curses
Use the curses library instead of the termcap library. This should
be supplied if your system has an inadequate or incomplete termcap
database.
@item --with-glibc-malloc
Use the @sc{GNU} libc version of @code{malloc} in
@file{lib/malloc/gmalloc.c}. This is somewhat slower than the
default @code{malloc}, but wastes considerably less space.
@item --with-gnu-malloc
Use the @sc{GNU} version of
@code{malloc} in @file{lib/malloc/malloc.c}. This is not the same
@ -5160,15 +5209,8 @@ Use the @sc{GNU} version of
derived from the 4.2 @sc{BSD} @code{malloc}. This @code{malloc} is
very fast, but wastes a lot of space. This option is enabled by
default. The @file{NOTES} file contains a list of systems for
which this should be turned off.
@item --with-glibc-malloc
Use the @sc{GNU} libc version of @code{malloc} in
@file{lib/malloc/gmalloc.c}. This is somewhat slower than the
default @code{malloc}, but wastes considerably less space.
@item --with-afs
Define if you are using the Andrew File System from Transarc.
which this should be turned off, and @code{configure} disables this
option automatically for a number of systems.
@item --with-purify
Define this to use the Purify memory allocation checker from Pure
@ -5190,32 +5232,48 @@ enabled by default, unless the operating system does not provide the
necessary support.
@table @code
@item --enable-job-control
This enables job control features, if the @sc{OS} supports them.
@item --enable-alias
Allow alias expansion and include the @code{alias} and @code{unalias}
builtins.
@item --enable-readline
Include support for command-line editing and history with the Bash
version of the Readline library.
@item --enable-history
Include command history and the @code{fc} and @code{history}
builtin commands.
@item --enable-array-variables
Include support for one-dimensional array shell variables.
@item --enable-bang-history
Include support for @code{csh}-like history substitution.
@item --enable-brace-expansion
Include @code{csh}-like brace expansion
( @code{b@{a,b@}c} @expansion{} @code{bac bbc} ).
@item --enable-command-timing
Include support for recognizing @code{time} as a reserved word and for
displaying timing statistics for the pipeline following @code{time}. This
allows pipelines as well as shell builtins and functions to be timed.
@item --enable-directory-stack
Include support for a @code{csh}-like directory stack and the
@code{pushd}, @code{popd}, and @code{dirs} builtins.
@item --enable-restricted
Include support for a @dfn{restricted shell}. If this is enabled, Bash,
when called as @code{rbash}, enters a restricted mode. See
@ref{The Restricted Shell}, for a description of restricted mode.
@item --enable-disabled-builtins
Allow builtin commands to be invoked via @samp{builtin xxx}
even after @code{xxx} has been disabled using @samp{enable -n xxx}.
See @ref{Bash Builtins}, for details of the @code{builtin} and
@code{enable} builtin commands.
@item --enable-dparen-arithmetic
Include support for the @code{ksh} @code{((@dots{}))} command.
@item --enable-help-builtin
Include the @code{help} builtin, which displays help on shell builtins and
variables.
@item --enable-history
Include command history and the @code{fc} and @code{history}
builtin commands.
@item --enable-job-control
This enables job control features, if the @sc{OS} supports them.
@item --enable-process-substitution
This enables process substitution (@pxref{Process Substitution}) if
@ -5226,35 +5284,19 @@ Turn on the interpretation of a number of backslash-escaped characters
in the @code{$PS1}, @code{$PS2}, @code{$PS3}, and @code{$PS4} prompt
strings.
@item --enable-readline
Include support for command-line editing and history with the Bash
version of the Readline library.
@item --enable-restricted
Include support for a @dfn{restricted shell}. If this is enabled, Bash,
when called as @code{rbash}, enters a restricted mode. See
@ref{The Restricted Shell}, for a description of restricted mode.
@item --enable-select
Include the @code{ksh} @code{select} builtin, which allows the
generation of simple menus.
@item --enable-help-builtin
Include the @code{help} builtin, which displays help on shell builtins and
variables.
@item --enable-array-variables
Include support for one-dimensional array shell variables.
@item --enable-dparen-arithmetic
Include support for the @code{ksh} @code{((@dots{}))} command.
@item --enable-brace-expansion
Include @code{csh}-like brace expansion
( @code{b@{a,b@}c} @expansion{} @code{bac bbc} ).
@item --enable-disabled-builtins
Allow builtin commands to be invoked via @samp{builtin xxx}
even after @code{xxx} has been disabled using @samp{enable -n xxx}.
See @ref{Bash Builtins}, for details of the @code{builtin} and
@code{enable} builtin commands.
@item --enable-command-timing
Include support for recognizing @code{time} as a reserved word and for
displaying timing statistics for the pipeline following @code{time}. This
allows pipelines as well as shell builtins and functions to be timed.
@item --enable-usg-echo-default
Make the @code{echo} builtin expand backslash-escaped characters by default,
without requiring the @samp{-e} option. This makes the Bash @code{echo}
@ -5280,7 +5322,7 @@ version of Bash that you have.
Once you have determined that a bug actually exists, use the
@code{bashbug} command to submit a bug report.
If you have a fix, you are welcome to mail that as well!
If you have a fix, you are encouraged to mail that as well!
Suggestions and `philosophical' bug reports may be mailed
to @code{bug-bash@@prep.ai.MIT.Edu} or posted to the Usenet
newsgroup @code{gnu.bash.bug}.

View File

@ -6,9 +6,9 @@
.\" Case Western Reserve University
.\" chet@ins.CWRU.Edu
.\"
.\" Last Change: Mon Jul 8 13:07:48 EDT 1996
.\" Last Change: Wed Feb 5 14:13:22 EST 1997
.\"
.TH READLINE 3 "1996 July 8" GNU
.TH READLINE 3 "1997 Feb 5" GNU
.\"
.\" File Name macro. This used to be `.PN', for Path Name,
.\" but Sun doesn't seem to like that very much.
@ -682,9 +682,18 @@ Add this digit to the argument already accumulating, or start a new
argument. M\-\- starts a negative argument.
.TP
.B universal\-argument
Each time this is executed, the argument count is multiplied by four.
This is another way to specify an argument.
If this command is followed by one or more digits, optionally with a
leading minus sign, those digits define the argument.
If the command is followed by digits, executing
.B universal\-argument
again ends the numeric argument, but is otherwise ignored.
As a special case, if this command is immediately followed by a
character that is neither a digit or minus sign, the argument count
for the next command is multiplied by four.
The argument count is initially one, so executing this function the
first time makes the argument count four.
first time makes the argument count four, a second time makes the
argument count sixteen, and so on.
.PD
.SS Completing
.PP

View File

@ -19,8 +19,7 @@
#include "config.h"
#include <stdio.h>
#include <sys/types.h>
#include "bashtypes.h"
#include <fcntl.h>
#if defined (HAVE_UNISTD_H)
@ -35,6 +34,8 @@
# endif
#endif
#include <stdio.h>
#include <errno.h>
#if !defined (errno)
extern int errno;
@ -234,7 +235,7 @@ programming_error (format, va_alist)
}
#endif
fprintf (stderr, "Tell %s to fix this someday.\n", the_current_maintainer);
fprintf (stderr, "Report this to %s\n", the_current_maintainer);
fprintf (stderr, "Stopping myself...");
fflush (stderr);

3
eval.c
View File

@ -43,7 +43,7 @@ extern int yyparse ();
extern int EOF_reached;
extern int indirection_level, interactive, interactive_shell;
extern int subshell_environment, running_under_emacs;
extern int last_command_exit_value;
extern int last_command_exit_value, stdin_redir;
extern int need_here_doc;
extern int current_command_number, current_command_line_count, line_number;
extern char *ps1_prompt, **prompt_string_pointer;
@ -128,6 +128,7 @@ reader_loop ()
current_command_number++;
executing = 1;
stdin_redir = 0;
execute_command (current_command);
exec_done:

View File

@ -25,5 +25,9 @@ _libdir=.
_dbgfile=$_tmpdir/bashdb$$ #temp file for script being debugged
cat $_libdir/bashdb.pre $_guineapig > $_dbgfile
exec bash $_dbgfile $_guineapig $_tmpdir $_libdir "$@"
if [ -f "$BASH" ]; then
exec $BASH $_dbgfile $_guineapig $_tmpdir $_libdir "$@"
else
exec bash $_dbgfile $_guineapig $_tmpdir $_libdir "$@"
fi
# end of bashdb

View File

@ -13,6 +13,7 @@ _steptrap() {
let " $_trace" &&
_msg "$PS4, line $_curline: ${_lines[$(($_curline-$_firstline+1))]}"
# if in step mode, decrement counter
let " $_steps >= 0" && let _steps="$_steps - 1"
@ -87,7 +88,7 @@ _at_linenumbp() {
if [ -z "${_linebp}" ]; then
return 1
fi
echo "${curline}" | egrep -s "(${linebp%\|})" >/dev/null 2>&1
echo "${_curline}" | egrep "(${_linebp%\|})" >/dev/null 2>&1
return $?
}
@ -95,11 +96,12 @@ _at_linenumbp() {
# search string brkpts to see if next line in script matches.
_at_stringbp() {
local l;
if [ -z "$_stringbp" ]; then
return 1;
fi
l=${_lines[$_curline-$_firstline+1]}
echo "${l} | egrep -s "*(${stringbp%\|})*" >/dev/null 2>&1
echo "${l}" | egrep "*(${_stringbp%\|})*" >/dev/null 2>&1
return $?
}
@ -132,9 +134,9 @@ _setbp() {
# list brkpts and break condition.
_listbp() {
_msg "Breakpoints at lines:"
_msg "$(echo $_linebp | tr '|' ' ')"
_msg "${_linebp//\|/ }"
_msg "Breakpoints at strings:"
_msg "$(echo $_stringbp | tr '|' ' ')"
_msg "${_stringbp//\|/ }"
_msg "Break on condition:"
_msg "$_brcond"
}

View File

@ -11,7 +11,7 @@ set -o history
set +H
# prompt for trace line
PS4=$1
PS4="${1}"
_dbgfile=$0
_guineapig=$1

View File

@ -0,0 +1,21 @@
# xalias - convert csh alias commands to bash functions
# from Mohit Aron <aron@cs.rice.edu>
# posted to usenet as <4i5p17$bnu@larry.rice.edu>
function xalias ()
{
if [ "x$2" = "x" ]
then
declare -f $1
else
echo $2 | egrep -q '(\!|#)'
if [ $? -eq 0 ]
then
comm=$(echo $2 | sed 's/\\!\*/\"$\@\"/g
s/\\!:\([1-9]\)/\"$\1\"/g
s/#/\\#/g')
else
comm="$2 \"\$@\""
fi
eval function $1 \(\) "{" command "$comm" "; }"
fi
}

View File

@ -166,6 +166,8 @@ pushd_builtin (list)
{
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
@ -186,7 +188,9 @@ popd_builtin (list)
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'))
@ -206,6 +210,7 @@ popd_builtin (list)
builtin_usage ();
return (EXECUTION_FAILURE);
}
which_word = list->word->word;
}
else if (*list->word->word == '-')
{
@ -219,7 +224,7 @@ popd_builtin (list)
if (which > directory_list_offset || (directory_list_offset == 0 && which == 0))
{
pushd_error (directory_list_offset, list ? list->word->word : "");
pushd_error (directory_list_offset, which_word ? which_word : "");
return (EXECUTION_FAILURE);
}
@ -538,10 +543,12 @@ static char *pushd_doc[] = {
"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') is at the top.",
" 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) is at the top.",
" 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.",

View File

@ -0,0 +1,21 @@
#!/bin/bash
#
# spin.bash -- provide a `spinning wheel' to show progress
#
# Chet Ramey
# chet@po.cwru.edu
#
bs=$'\b'
chars="|${bs} \\${bs} -${bs} /${bs}"
# Infinite loop for demo. purposes
while :
do
for letter in $chars
do
echo -n ${letter}
done
done
exit 0

View File

@ -6,6 +6,7 @@
# usage: vtree [-a] [dir]
#
# Original posted to Usenet sometime in February, 1996
# I believe that the original author is Brian S. Hiles <bsh29256@atc.fhda.edu>
#
usage()
{
@ -32,10 +33,10 @@ do
echo -n "$PWD"
du $andfiles | sort +1f | sed \
's/\([^ ]*\) \(.*\)/\2 (\1)/
'"s#^$1##"'
s#[^/]*/\([^/]*\)$#|____\1#
s#[^/]*/#| #g'
-e 's/\([^ ]*\) \(.*\)/\2 (\1)/' \
-e "s#^$1##" \
-e 's#[^/]*/\([^/]*\)$#|____\1#' \
-e 's#[^/]*/#| #g'
[ $# -gt 1 ] && echo
shift

99
examples/scripts/vtree3 Normal file
View File

@ -0,0 +1,99 @@
#!/bin/ksh
#
# Name: dirtree
# Programmer:
# Hemant T. Shah
# Life Insurance Data Processing
# July 12 1994
#
# Description:
# Print directory tree structure as follows:
# |___Mail
# |___scheduler
# |___cics_scripts
# |___tar_msdos
# |___awk
# |___attributes
# |___tmp
# |___News
# |___dosscsi
# |___FAQ_xterminal
# |___shell_history.Z
# |___FAQ_AIX
# |___aix_ftp_site
# |___hp_software
# |___dnload
# |___telnet.h
# |___msdos
# |___tnetd.tar.Z
# |___aix
# |___hp
# |___xkey.c
#
# Conversion to bash v2 syntax done by Chet Ramey
# - removed command substitutions calling `basename'
#
ProgramName=${0##*/}
Path="."
ShowAll=1
ShowDir=0
ExpandDirectory()
{
local object # Local variable
cd "$1"
for object in $PWD/.??* $PWD/*
do
if [ -d $object ]; # It is a directory
then
echo "${indent}|___${object##*/}/"
indent="${indent}! " # Add to indentation
if [ -x $object ];
then
ExpandDirectory $object
fi
indent=${indent%????} # Remove from indentation
elif [ -e $object ]; then
if (( ShowAll == 1 ));
then
echo "${indent}|___${object##*/}"
fi
fi
done
}
usage()
{
echo -e "Usage: $ProgramName [-h] [-f] [-d] [path] "
echo -e "\t-h ... display this help message."
echo -e "\t-f path ... shows all files and directories below path (default)."
echo -e "\t-d path ... shows all directories only below path."
}
while getopts "fd" opt
do
case $opt in
f) ShowAll=1 ;;
d) ShowDir=1 ;;
*) usage ; exit 2;;
esac
done
shift $(( $OPTIND - 1 ))
Path=${1:-.}
if [ ! -d "$Path" ]; then
echo "$0: error: specified path is not a directory." >&2
exit 1
fi
echo "!$Path/"
ExpandDirectory $Path

View File

@ -40,8 +40,18 @@
# include <limits.h>
#endif
#if defined (HAVE_SYS_TIME_H)
/* Some systems require this, mostly for the definition of `struct timezone'.
For example, Dynix/ptx has that definition in <time.h> rather than
sys/time.h */
#if defined (TIME_WITH_SYS_TIME)
# include <sys/time.h>
# include <time.h>
#else
# if defined (HAVE_SYS_TIME_H)
# include <sys/time.h>
# else
# include <time.h>
# endif
#endif
#if defined (HAVE_SYS_RESOURCE_H)
@ -62,7 +72,7 @@ extern int errno;
#include "memalloc.h"
#include "shell.h"
#include "y.tab.h"
#include <y.tab.h> /* use <...> so we pick it up from the build directory */
#include "flags.h"
#include "builtins.h"
#include "hashlib.h"
@ -70,6 +80,7 @@ extern int errno;
#include "execute_cmd.h"
#include "trap.h"
#include "pathexp.h"
#include "hashcmd.h"
#include "builtins/common.h"
#include "builtins/builtext.h" /* list of builtins */
@ -92,7 +103,7 @@ extern int errno;
extern int posixly_correct;
extern int executing, breaking, continuing, loop_level;
extern int interactive, interactive_shell, login_shell, expand_aliases;
extern int parse_and_execute_level, running_trap;
extern int parse_and_execute_level, running_trap, trap_line_number;
extern int command_string_index, variable_context, line_number;
extern int dot_found_in_search;
extern int already_making_children;
@ -121,7 +132,9 @@ static int execute_for_command ();
#if defined (SELECT_COMMAND)
static int execute_select_command ();
#endif
#if defined (COMMAND_TIMING)
static int time_command ();
#endif
static int execute_case_command ();
static int execute_while_command (), execute_until_command ();
static int execute_while_or_until ();
@ -138,8 +151,9 @@ static int execute_intern_function ();
/* The line number that the currently executing function starts on. */
static int function_line_number;
/* Set to 1 if fd 0 was the subject of redirection to a subshell. */
static int stdin_redir;
/* Set to 1 if fd 0 was the subject of redirection to a subshell. Global
so that reader_loop can set it to zero before executing a command. */
int stdin_redir;
/* The name of the command that is currently being executed.
`test' needs this, for example. */
@ -150,8 +164,15 @@ static COMMAND *currently_executing_command;
struct stat SB; /* used for debugging */
static int special_builtin_failed;
/* Spare redirector used when translating [N]>&WORD or [N]<&WORD to a new
redirection and when creating the redirection undo list. */
static REDIRECTEE rd;
/* Set to errno when a here document cannot be created for some reason.
Used to print a reasonable error message. */
static int heredoc_errno;
/* The file name which we would try to execute, except that it isn't
possible to execute it. This is the first file that matches the
name that we are looking for while we are searching $PATH for a
@ -186,7 +207,8 @@ int check_hashed_filenames;
struct fd_bitmap *current_fds_to_close = (struct fd_bitmap *)NULL;
#define FD_BITMAP_DEFAULT_SIZE 32
#define FD_BITMAP_DEFAULT_SIZE 32L
/* Functions to allocate and deallocate the structures used to pass
information from the shell to its children about file descriptors
to close. */
@ -242,7 +264,10 @@ executing_line_number ()
if (executing && variable_context == 0 && currently_executing_command &&
currently_executing_command->type == cm_simple)
return currently_executing_command->value.Simple->line;
return line_number;
else if (running_trap)
return trap_line_number;
else
return line_number;
}
/* Execute the command passed in COMMAND. COMMAND is exactly what
@ -359,6 +384,56 @@ open_files ()
fprintf (stderr, "\n");
}
static int
stdin_redirects (redirs)
REDIRECT *redirs;
{
REDIRECT *rp;
int n;
for (n = 0, rp = redirs; rp; rp = rp->next)
switch (rp->instruction)
{
case r_input_direction:
case r_inputa_direction:
case r_input_output:
case r_reading_until:
case r_deblank_reading_until:
n++;
break;
case r_duplicating_input:
case r_duplicating_input_word:
case r_close_this:
n += (rp->redirector == 0);
break;
case r_output_direction:
case r_appending_to:
case r_duplicating_output:
case r_err_and_out:
case r_output_force:
case r_duplicating_output_word:
break;
}
return n;
}
static void
async_redirect_stdin ()
{
int fd;
fd = open ("/dev/null", O_RDONLY);
if (fd > 0)
{
dup2 (fd, 0);
close (fd);
}
else if (fd < 0)
internal_error ("cannot redirect standard input from /dev/null: %s", strerror (errno));
}
#define DESCRIBE_PID(pid) do { if (interactive) describe_pid (pid); } while (0)
/* Execute the command passed in COMMAND, perhaps doing it asynchrounously.
@ -382,7 +457,7 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
struct fd_bitmap *fds_to_close;
{
int exec_result, invert, ignore_return, was_debug_trap;
REDIRECT *my_undo_list, *exec_undo_list, *rp;
REDIRECT *my_undo_list, *exec_undo_list;
pid_t last_pid;
if (command == 0 || breaking || continuing || read_but_dont_execute)
@ -393,17 +468,14 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
if (running_trap == 0)
currently_executing_command = command;
#if defined (COMMAND_TIMING)
if (command->flags & CMD_TIME_PIPELINE)
{
exec_result = time_command (command, asynchronous, pipe_in, pipe_out, fds_to_close);
if (running_trap == 0)
currently_executing_command = (COMMAND *)NULL;
return (exec_result);
}
#endif /* COMMAND_TIMING */
invert = (command->flags & CMD_INVERT_RETURN) != 0;
/* If we're inverting the return value and `set -e' has been executed,
we don't want a failing command to inadvertently cause the shell
to exit. */
if (exit_immediately_on_error && invert) /* XXX */
command->flags |= CMD_IGNORE_RETURN; /* XXX */
exec_result = EXECUTION_SUCCESS;
/* If a command was being explicitly run in a subshell, or if it is
@ -422,7 +494,11 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
asynchronous);
if (paren_pid == 0)
{
int user_subshell, return_code, function_value;
int user_subshell, return_code, function_value, should_redir_stdin;
should_redir_stdin = (asynchronous && (command->flags & CMD_STDIN_REDIR) &&
pipe_in == NO_PIPE &&
stdin_redirects (command->redirects) == 0);
user_subshell = (command->flags & CMD_WANT_SUBSHELL) != 0;
command->flags &= ~(CMD_FORCE_SUBSHELL | CMD_WANT_SUBSHELL | CMD_INVERT_RETURN);
@ -485,29 +561,19 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
sh compatibility, but I'm not sure it's the right thing to do. */
if (user_subshell)
{
for (rp = command->redirects; rp; rp = rp->next)
switch (rp->instruction)
{
case r_input_direction:
case r_inputa_direction:
case r_input_output:
case r_reading_until:
case r_deblank_reading_until:
stdin_redir++;
break;
case r_duplicating_input:
case r_duplicating_input_word:
case r_close_this:
stdin_redir += (rp->redirector == 0);
break;
}
stdin_redir = stdin_redirects (command->redirects);
restore_default_signal (0);
}
if (fds_to_close)
close_fd_bitmap (fds_to_close);
/* If this is an asynchronous command (command &), we want to
redirect the standard input from /dev/null in the absence of
any specific redirection involving stdin. */
if (should_redir_stdin && stdin_redir == 0)
async_redirect_stdin ();
/* Do redirections, then dispose of them before recursive call. */
if (command->redirects)
{
@ -589,6 +655,27 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
}
}
#if defined (COMMAND_TIMING)
if (command->flags & CMD_TIME_PIPELINE)
{
if (asynchronous)
{
command->flags |= CMD_FORCE_SUBSHELL;
exec_result = execute_command_internal (command, 1, pipe_in, pipe_out, fds_to_close);
}
else
{
exec_result = time_command (command, asynchronous, pipe_in, pipe_out, fds_to_close);
if (running_trap == 0)
currently_executing_command = (COMMAND *)NULL;
}
return (exec_result);
}
#endif /* COMMAND_TIMING */
if (shell_control_structure (command->type) && command->redirects)
stdin_redir = stdin_redirects (command->redirects);
/* Handle WHILE FOR CASE etc. with redirections. (Also '&' input
redirection.) */
if (do_redirections (command->redirects, 1, 1, 0) != 0)
@ -642,6 +729,8 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
if (ignore_return && command->value.Simple)
command->value.Simple->flags |= CMD_IGNORE_RETURN;
if (command->flags & CMD_STDIN_REDIR)
command->value.Simple->flags |= CMD_STDIN_REDIR;
exec_result =
execute_simple_command (command->value.Simple, pipe_in, pipe_out,
asynchronous, fds_to_close);
@ -885,7 +974,7 @@ timeval_to_cpu (rt, ut, st)
t2.tv_sec /= 10;
}
return (t1.tv_sec / t2.tv_sec);
return ((t2.tv_sec == 0) ? 0 : t1.tv_sec / t2.tv_sec);
}
#endif /* HAVE_GETRUSAGE && HAVE_GETTIMEOFDAY */
@ -1058,7 +1147,7 @@ time_command (command, asynchronous, pipe_in, pipe_out, fds_to_close)
int asynchronous, pipe_in, pipe_out;
struct fd_bitmap *fds_to_close;
{
int rv, posix_time;
int rv, posix_time, old_flags;
long rs, us, ss;
int rsf, usf, ssf;
int cpu;
@ -1088,8 +1177,10 @@ time_command (command, asynchronous, pipe_in, pipe_out, fds_to_close)
posix_time = (command->flags & CMD_TIME_POSIX);
old_flags = command->flags;
command->flags &= ~(CMD_TIME_PIPELINE|CMD_TIME_POSIX);
rv = execute_command_internal (command, asynchronous, pipe_in, pipe_out, fds_to_close);
command->flags = old_flags;
#if defined (HAVE_GETRUSAGE) && defined (HAVE_GETTIMEOFDAY)
gettimeofday (&after, &dtz);
@ -1121,7 +1212,7 @@ time_command (command, asynchronous, pipe_in, pipe_out, fds_to_close)
sys = (after.tms_stime - before.tms_stime) + (after.tms_cstime - before.tms_cstime);
clock_t_to_secs (sys, &ss, &ssf);
cpu = ((user + sys) * 10000) / real;
cpu = (real == 0) ? 0 : ((user + sys) * 10000) / real;
# else
rs = us = ss = 0L;
@ -1259,7 +1350,10 @@ execute_connection (command, asynchronous, pipe_in, pipe_out, fds_to_close)
int asynchronous, pipe_in, pipe_out;
struct fd_bitmap *fds_to_close;
{
REDIRECT *tr, *tl, *rp;
#if 0
REDIRECT *tr, *tl;
#endif
REDIRECT *rp;
COMMAND *tc, *second;
int ignore_return, exec_result;
@ -1275,8 +1369,9 @@ execute_connection (command, asynchronous, pipe_in, pipe_out, fds_to_close)
rp = tc->redirects;
if (ignore_return && tc)
if (ignore_return)
tc->flags |= CMD_IGNORE_RETURN;
tc->flags |= CMD_AMPERSAND;
/* If this shell was compiled without job control support, if
the shell is not running interactively, if we are currently
@ -1289,20 +1384,20 @@ execute_connection (command, asynchronous, pipe_in, pipe_out, fds_to_close)
if (!stdin_redir)
#endif /* JOB_CONTROL */
{
#if 0
rd.filename = make_bare_word ("/dev/null");
tr = make_redirection (0, r_inputa_direction, rd);
tr->next = tc->redirects;
tc->redirects = tr;
#endif
tc->flags |= CMD_STDIN_REDIR;
}
exec_result = execute_command_internal (tc, 1, pipe_in, pipe_out, fds_to_close);
#if defined (JOB_CONTROL)
if ((!interactive_shell || subshell_environment || !job_control) && !stdin_redir)
#else
if (!stdin_redir)
#endif /* JOB_CONTROL */
if (tc->flags & CMD_STDIN_REDIR)
{
#if 0
/* Remove the redirection we added above. It matters,
especially for loops, which call execute_command ()
multiple times with the same command. */
@ -1316,6 +1411,8 @@ execute_connection (command, asynchronous, pipe_in, pipe_out, fds_to_close)
tl->next = (REDIRECT *)NULL;
dispose_redirects (tr);
#endif
tc->flags &= ~CMD_STDIN_REDIR;
}
second = command->value.Connection->second;
@ -1473,6 +1570,7 @@ execute_for_command (for_command)
else
{
run_unwind_frame ("for");
loop_level--;
return (EXECUTION_FAILURE);
}
}
@ -2076,7 +2174,7 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close)
command_string_index = 0;
print_simple_command (simple_command);
command_line = xmalloc (1 + strlen (the_printed_command));
strcpy (command_line, the_printed_command);
strcpy (command_line, the_printed_command); /* XXX memory leak on errors */
first_word_quoted =
simple_command->words ? (simple_command->words->word->flags & W_QUOTED): 0;
@ -2239,7 +2337,13 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close)
restore_original_signals ();
if (async)
setup_async_signals ();
{
if ((simple_command->flags & CMD_STDIN_REDIR) &&
pipe_in == NO_PIPE &&
(stdin_redirects (simple_command->redirects) == 0))
async_redirect_stdin ();
setup_async_signals ();
}
execute_subshell_builtin_or_function
(words, simple_command->redirects, builtin, func,
@ -2289,7 +2393,7 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close)
execute_disk_command (words, simple_command->redirects, command_line,
pipe_in, pipe_out, async, fds_to_close,
(simple_command->flags & CMD_NO_FORK));
simple_command->flags);
return_result:
bind_lastarg (lastarg);
@ -2330,7 +2434,7 @@ execute_builtin (builtin, words, flags, subshell)
WORD_LIST *words;
int flags, subshell;
{
int old_e_flag, result;
int old_e_flag, result, eval_unwind;
old_e_flag = exit_immediately_on_error;
/* The eval builtin calls parse_and_execute, which does not know about
@ -2344,12 +2448,15 @@ execute_builtin (builtin, words, flags, subshell)
begin_unwind_frame ("eval_builtin");
unwind_protect_int (exit_immediately_on_error);
exit_immediately_on_error = 0;
eval_unwind = 1;
}
else
eval_unwind = 0;
/* The temporary environment for a builtin is supposed to apply to
all commands executed by that builtin. Currently, this is a
problem only with the `source' builtin. */
if (builtin == source_builtin)
problem only with the `source' and `eval' builtins. */
if (builtin == source_builtin || builtin == eval_builtin)
{
if (subshell == 0)
begin_unwind_frame ("builtin_env");
@ -2369,18 +2476,18 @@ execute_builtin (builtin, words, flags, subshell)
result = ((*builtin) (words->next));
if (subshell == 0 && builtin == source_builtin)
if (subshell == 0 && (builtin == source_builtin || builtin == eval_builtin))
{
/* In POSIX mode, if any variable assignments precede the `.' builtin,
they persist after the builtin completes, since `.' is a special
builtin. */
/* In POSIX mode, if any variable assignments precede the `.' or
`eval' builtin, they persist after the builtin completes, since `.'
and `eval' are special builtins. */
if (posixly_correct && builtin_env)
merge_builtin_env ();
dispose_builtin_env ();
discard_unwind_frame ("builtin_env");
}
if (subshell == 0 && builtin == eval_builtin && (flags & CMD_IGNORE_RETURN))
if (eval_unwind)
{
exit_immediately_on_error += old_e_flag;
discard_unwind_frame ("eval_builtin");
@ -2425,6 +2532,7 @@ execute_function (var, words, flags, fds_to_close, async, subshell)
{
debug_trap = savestring (debug_trap);
add_unwind_protect (set_debug_trap, debug_trap);
/* XXX - small memory leak here -- hard to fix */
}
restore_default_signal (DEBUG_TRAP);
}
@ -2652,17 +2760,19 @@ setup_async_signals ()
this gnarly hair, for no good reason. */
static void
execute_disk_command (words, redirects, command_line, pipe_in, pipe_out,
async, fds_to_close, nofork)
async, fds_to_close, cmdflags)
WORD_LIST *words;
REDIRECT *redirects;
char *command_line;
int pipe_in, pipe_out, async;
struct fd_bitmap *fds_to_close;
int nofork; /* Don't fork, just exec, if no pipes */
int cmdflags;
{
char *pathname, *command, **args;
int nofork;
int pid;
nofork = (cmdflags & CMD_NO_FORK); /* Don't fork, just exec, if no pipes */
pathname = words->word->word;
#if defined (RESTRICTED_SHELL)
@ -2696,9 +2806,12 @@ execute_disk_command (words, redirects, command_line, pipe_in, pipe_out,
{
int old_interactive;
#if 0
/* This has been disabled for the time being. */
#if !defined (ARG_MAX) || ARG_MAX >= 10240
if (posixly_correct == 0)
put_gnu_argv_flags_into_env ((int)getpid (), glob_argv_flags);
#endif
#endif
/* Cancel traps, in trap.c. */
@ -2708,7 +2821,13 @@ execute_disk_command (words, redirects, command_line, pipe_in, pipe_out,
by make_child to ensure that SIGINT and SIGQUIT are ignored
in asynchronous children. */
if (async)
setup_async_signals ();
{
if ((cmdflags & CMD_STDIN_REDIR) &&
pipe_in == NO_PIPE &&
(stdin_redirects (redirects) == 0))
async_redirect_stdin ();
setup_async_signals ();
}
do_piping (pipe_in, pipe_out);
@ -2845,6 +2964,48 @@ execute_shell_script (sample, sample_len, command, args, env)
}
#endif /* !HAVE_HASH_BANG_EXEC */
static void
initialize_subshell ()
{
#if defined (ALIAS)
/* Forget about any aliases that we knew of. We are in a subshell. */
delete_all_aliases ();
#endif /* ALIAS */
#if defined (HISTORY)
/* Forget about the history lines we have read. This is a non-interactive
subshell. */
history_lines_this_session = 0;
#endif
#if defined (JOB_CONTROL)
/* Forget about the way job control was working. We are in a subshell. */
without_job_control ();
set_sigchld_handler ();
#endif /* JOB_CONTROL */
/* Reset the values of the shell flags and options. */
reset_shell_flags ();
reset_shell_options ();
reset_shopt_options ();
/* If we're not interactive, close the file descriptor from which we're
reading the current shell script. */
#if defined (BUFFERED_INPUT)
if (interactive_shell == 0 && default_buffered_input >= 0)
{
close_buffered_fd (default_buffered_input);
default_buffered_input = bash_input.location.buffered_fd = -1;
}
#else
if (interactive_shell == 0 && default_input)
{
fclose (default_input);
default_input = (FILE *)NULL;
}
#endif
}
#if defined (HAVE_SETOSTYPE) && defined (_POSIX_SOURCE)
# define SETOSTYPE(x) __setostype(x)
#else
@ -2877,7 +3038,7 @@ shell_execve (command, args, env)
errno = i;
file_error (command);
}
return (EX_NOEXEC); /* XXX Posix.2 says that exit status is 126 */
return ((i == ENOENT) ? EX_NOTFOUND : EX_NOEXEC); /* XXX Posix.2 says that exit status is 126 */
}
/* This file is executable.
@ -2918,44 +3079,12 @@ shell_execve (command, args, env)
}
}
larray = array_len (args) + 1;
#if defined (ALIAS)
/* Forget about any aliases that we knew of. We are in a subshell. */
delete_all_aliases ();
#endif /* ALIAS */
#if defined (HISTORY)
/* Forget about the history lines we have read. This is a non-interactive
subshell. */
history_lines_this_session = 0;
#endif
#if defined (JOB_CONTROL)
/* Forget about the way job control was working. We are in a subshell. */
without_job_control ();
set_sigchld_handler ();
#endif /* JOB_CONTROL */
/* If we're not interactive, close the file descriptor from which we're
reading the current shell script. */
#if defined (BUFFERED_INPUT)
if (interactive_shell == 0 && default_buffered_input >= 0)
{
close_buffered_fd (default_buffered_input);
default_buffered_input = bash_input.location.buffered_fd = -1;
}
#else
if (interactive_shell == 0 && default_input)
{
fclose (default_input);
default_input = (FILE *)NULL;
}
#endif
initialize_subshell ();
set_sigint_handler ();
/* Insert the name of this shell into the argument list. */
larray = array_len (args) + 1;
args = (char **)xrealloc ((char *)args, (1 + larray) * sizeof (char *));
for (i = larray - 1; i; i--)
@ -3021,6 +3150,7 @@ execute_intern_function (name, function)
return (EXECUTION_SUCCESS);
}
#if defined (INCLUDE_UNUSED)
#if defined (PROCESS_SUBSTITUTION)
void
close_all_files ()
@ -3035,6 +3165,7 @@ close_all_files ()
close (i);
}
#endif /* PROCESS_SUBSTITUTION */
#endif
static void
close_pipes (in, out)
@ -3115,6 +3246,10 @@ redirection_error (temp, error)
break;
#endif /* RESTRICTED_SHELL */
case HEREDOC_REDIRECT:
internal_error ("cannot create temp file for here document: %s", strerror (heredoc_errno));
break;
default:
internal_error ("%s: %s", filename, strerror (error));
break;
@ -3210,6 +3345,9 @@ redirection_expand (word)
return (result);
}
/* Write the text of the here document pointed to by REDIRECTEE to the file
descriptor FD, which is already open to a temp file. Return 0 if the
write is successful, otherwise return errno. */
static int
write_here_document (fd, redirectee)
int fd;
@ -3279,7 +3417,117 @@ write_here_document (fd, redirectee)
return 0;
}
/* Do the specific redirection requested. Returns errno in case of error.
/* Create a temporary file holding the text of the here document pointed to
by REDIRECTEE, and return a file descriptor open for reading to the temp
file. Return -1 on any error, and make sure errno is set appropriately. */
static int
here_document_to_fd (redirectee)
WORD_DESC *redirectee;
{
char filename[24];
int r, fd;
/* Make the filename for the temp file. */
sprintf (filename, "/tmp/t%d-sh", (int)time ((time_t *) 0) + (int)getpid ());
/* Make sure we open it exclusively. */
fd = open (filename, O_TRUNC | O_WRONLY | O_CREAT | O_EXCL, 0600);
if (fd < 0)
return (fd);
errno = r = 0; /* XXX */
/* write_here_document returns 0 on success, errno on failure. */
if (redirectee->word)
r = write_here_document (fd, redirectee);
close (fd);
if (r)
{
unlink (filename);
errno = r;
return (-1);
}
/* XXX - this is raceable */
/* Make the document really temporary. Also make it the input. */
fd = open (filename, O_RDONLY, 0600);
if (fd < 0)
{
r = errno;
unlink (filename);
errno = r;
return -1;
}
if (unlink (filename) < 0)
{
r = errno;
close (fd);
errno = r;
return (-1);
}
return (fd);
}
/* Open FILENAME with FLAGS in noclobber mode, hopefully avoiding most
race conditions and avoiding the problem where the file is replaced
between the stat(2) and open(2). */
static int
noclobber_open (filename, flags, ri)
char *filename;
int flags;
enum r_instruction ri;
{
int r, fd;
struct stat finfo, finfo2;
/* If the file exists and is a regular file, return an error
immediately. */
r = stat (filename, &finfo);
if (r == 0 && (S_ISREG (finfo.st_mode)))
return (NOCLOBBER_REDIRECT);
/* If the file was not present (r != 0), make sure we open it
exclusively so that if it is created before we open it, our open
will fail. Make sure that we do not truncate an existing file.
Note that we don't turn on O_EXCL unless the stat failed -- if
the file was not a regular file, we leave O_EXCL off. */
flags &= ~O_TRUNC;
if (r != 0)
{
fd = open (filename, flags|O_EXCL, 0666);
return ((fd < 0 && errno == EEXIST) ? NOCLOBBER_REDIRECT : fd);
}
fd = open (filename, flags, 0666);
/* If the open failed, return the file descriptor right away. */
if (fd < 0)
return (errno == EEXIST ? NOCLOBBER_REDIRECT : fd);
/* OK, the open succeeded, but the file may have been changed from a
non-regular file to a regular file between the stat and the open.
We are assuming that the O_EXCL open handles the case where FILENAME
did not exist and is symlinked to an existing file between the stat
and open. */
/* If we can open it and fstat the file descriptor, and neither check
revealed that it was a regular file, and the file has not been replaced,
return the file descriptor. */
if ((fstat (fd, &finfo2) == 0) && (S_ISREG (finfo2.st_mode) == 0) &&
r == 0 && (S_ISREG (finfo.st_mode) == 0) &&
same_file (filename, filename, &finfo, &finfo2))
return fd;
/* The file has been replaced. badness. */
close (fd);
errno = EEXIST;
return (NOCLOBBER_REDIRECT);
}
/* Do the specific redirection requested. Returns errno or one of the
special redirection errors (*_REDIRECT) in case of error, 0 on success.
If FOR_REAL is zero, then just do whatever is neccessary to produce the
appropriate side effects. REMEMBERING, if non-zero, says to remember
how to undo each redirection. If SET_CLEXEC is non-zero, then
@ -3294,7 +3542,6 @@ do_redirection_internal (redirect, for_real, remembering, set_clexec)
char *redirectee_word;
enum r_instruction ri;
REDIRECT *new_redirect;
struct stat finfo;
redirectee = redirect->redirectee.filename;
redir_fd = redirect->redirectee.dest;
@ -3402,25 +3649,11 @@ do_redirection_internal (redirect, for_real, remembering, set_clexec)
#endif /* RESTRICTED_SHELL */
/* If we are in noclobber mode, you are not allowed to overwrite
existing files. Check first. */
existing files. Check before opening. */
if (noclobber && OUTPUT_REDIRECT (ri))
{
r = stat (redirectee_word, &finfo);
if (r == 0 && (S_ISREG (finfo.st_mode)))
{
free (redirectee_word);
return (NOCLOBBER_REDIRECT);
}
/* If the file was not present, make sure we open it exclusively
so that if it is created before we open it, our open will fail. */
if (r != 0)
redirect->flags |= O_EXCL;
fd = open (redirectee_word, redirect->flags, 0666);
if (fd < 0 && errno == EEXIST)
fd = noclobber_open (redirectee_word, redirect->flags, ri);
if (fd == NOCLOBBER_REDIRECT)
{
free (redirectee_word);
return (NOCLOBBER_REDIRECT);
@ -3507,34 +3740,12 @@ do_redirection_internal (redirect, for_real, remembering, set_clexec)
the new input. Place it in a temporary file. */
if (redirectee)
{
char filename[24];
/* Make the filename for the temp file. */
sprintf (filename, "/tmp/t%d-sh", (int)getpid ());
fd = open (filename, O_TRUNC | O_WRONLY | O_CREAT, 0666);
if (fd < 0)
return (errno);
errno = r = 0; /* XXX */
if (redirectee->word)
r = write_here_document (fd, redirectee);
close (fd);
if (r)
return (r);
/* Make the document really temporary. Also make it the input. */
fd = open (filename, O_RDONLY, 0666);
fd = here_document_to_fd (redirectee);
if (fd < 0)
return (errno);
if (unlink (filename) < 0)
{
r = errno;
close (fd);
return (r);
heredoc_errno = errno;
return (HEREDOC_REDIRECT);
}
if (for_real)
@ -3622,6 +3833,10 @@ do_redirection_internal (redirect, for_real, remembering, set_clexec)
#endif /* !BUFFERED_INPUT */
}
break;
case r_duplicating_input_word:
case r_duplicating_output_word:
break;
}
return (0);
}
@ -3715,7 +3930,6 @@ file_status (name)
char *name;
{
struct stat finfo;
static int user_id = -1;
/* Determine whether this file exists or not. */
if (stat (name, &finfo) < 0)
@ -3739,12 +3953,10 @@ file_status (name)
/* Find out if the file is actually executable. By definition, the
only other criteria is that the file has an execute bit set that
we can use. */
if (user_id == -1)
user_id = current_user.euid;
/* Root only requires execute permission for any of owner, group or
others to be able to exec a file. */
if (user_id == 0)
if (current_user.euid == (uid_t)0)
{
int bits;
@ -3757,7 +3969,7 @@ file_status (name)
}
/* If we are the owner of the file, the owner execute bit applies. */
if (user_id == finfo.st_uid && X_BIT (u_mode_bits (finfo.st_mode)))
if (current_user.euid == finfo.st_uid && X_BIT (u_mode_bits (finfo.st_mode)))
return (FS_EXISTS | FS_EXECABLE);
/* If we are in the owning group, the group permissions apply. */
@ -3890,6 +4102,9 @@ get_next_path_element (path_list, path_index_pointer)
return (path);
}
/* Look for PATHNAME in $PATH. Returns either the hashed command
corresponding to PATHNAME or the first instance of PATHNAME found
in $PATH. Returns a newly-allocated string. */
char *
search_for_command (pathname)
char *pathname;
@ -3921,12 +4136,13 @@ search_for_command (pathname)
if ((st ^ (FS_EXISTS | FS_EXECABLE)) != 0)
{
remove_hashed_filename (pathname);
free (hashed_file);
hashed_file = (char *)NULL;
}
}
if (hashed_file)
command = savestring (hashed_file);
command = hashed_file;
else if (absolute_program (pathname))
/* A command containing a slash is not looked up in PATH or saved in
the hash table. */

149
expr.c
View File

@ -130,7 +130,7 @@ static int noeval; /* set to 1 if no assignment to be done */
static procenv_t evalbuf;
static void readtok (); /* lexical analyzer */
static long expassign (), exp0 (), exp1 (), exp2 (), exp3 (),
static long subexpr (), expassign (), exp0 (), exp1 (), exp2 (), exp3 (),
exp4 (), exp5 (), expshift (), expland (), explor (),
expband (), expbor (), expbxor (), expcond ();
static long strlong ();
@ -158,8 +158,6 @@ pushexp ()
{
EXPR_CONTEXT *context;
context = (EXPR_CONTEXT *)xmalloc (sizeof (EXPR_CONTEXT));
if (expr_depth >= MAX_EXPR_RECURSION_LEVEL)
evalerror ("expression recursion level exceeded");
@ -170,6 +168,8 @@ pushexp ()
* sizeof (EXPR_CONTEXT *));
}
context = (EXPR_CONTEXT *)xmalloc (sizeof (EXPR_CONTEXT));
context->curtok = curtok;
context->lasttok = lasttok;
context->expression = expression;
@ -199,7 +199,11 @@ popexp ()
free (context);
}
/* Evaluate EXPR, and return the arithmetic result.
/* Evaluate EXPR, and return the arithmetic result. If VALIDP is
non-null, a zero is stored into the location to which it points
if the expression is invalid, non-zero otherwise. If a non-zero
value is returned in *VALIDP, the return value of evalexp() may
be used.
The `while' loop after the longjmp is caught relies on the above
implementation of pushexp and popexp leaving in expr_stack[0] the
@ -209,49 +213,80 @@ popexp ()
safe to let the loop terminate when expr_depth == 0, without freeing up
any of the expr_depth[0] stuff. */
long
evalexp (expr)
evalexp (expr, validp)
char *expr;
int *validp;
{
long val = 0L;
long val;
#if 0
procenv_t old_evalbuf;
char *p;
#endif
for (p = expr; p && *p && cr_whitespace (*p); p++)
;
if (p == NULL || *p == '\0')
return (0);
val = 0L;
#if 0
/* Save the value of evalbuf to protect it around possible recursive
calls to evalexp (). */
COPY_PROCENV (evalbuf, old_evalbuf);
#endif
if (setjmp (evalbuf))
{
if (tokstr) /* Clean up local allocation. */
free (tokstr);
FREE (tokstr);
FREE (expression);
tokstr = expression = (char *)NULL;
if (expression)
free (expression);
while (--expr_depth)
while (--expr_depth > 0)
{
if (expr_stack[expr_depth]->tokstr)
free (expr_stack[expr_depth]->tokstr);
if (expr_stack[expr_depth]->expression)
free (expr_stack[expr_depth]->expression);
free (expr_stack[expr_depth]);
}
jump_to_top_level (DISCARD);
free (expr_stack[expr_depth]); /* free the allocated EXPR_CONTEXT */
if (validp)
*validp = 0;
return (0L);
}
val = subexpr (expr);
#if 0
/* Restore the value of evalbuf so that any subsequent longjmp calls
will have a valid location to jump to. */
COPY_PROCENV (old_evalbuf, evalbuf);
#endif
if (validp)
*validp = 1;
return (val);
}
static long
subexpr (expr)
char *expr;
{
long val;
char *p;
for (p = expr; p && *p && cr_whitespace (*p); p++)
;
if (p == NULL || *p == '\0')
return (0L);
pushexp ();
curtok = lasttok = 0;
expression = savestring (expr);
tp = expression;
tokstr = (char *)NULL;
tokval = 0l;
tokval = 0L;
readtok ();
@ -260,18 +295,12 @@ evalexp (expr)
if (curtok != 0)
evalerror ("syntax error in expression");
if (tokstr)
free (tokstr);
if (expression)
free (expression);
FREE (tokstr);
FREE (expression);
popexp ();
/* Restore the value of evalbuf so that any subsequent longjmp calls
will have a valid location to jump to. */
COPY_PROCENV (old_evalbuf, evalbuf);
return (val);
return val;
}
/* Bind/create a shell variable with the name LHS to the RHS.
@ -362,6 +391,7 @@ expassign ()
lvalue |= value;
break;
default:
free (lhs);
evalerror ("bug: bad expassign token");
break;
}
@ -373,7 +403,7 @@ expassign ()
bind_int_variable (lhs, rhs);
free (rhs);
free (lhs);
free (tokstr);
FREE (tokstr);
tokstr = (char *)NULL; /* For freeing on errors. */
}
return (value);
@ -384,6 +414,9 @@ static long
expcond ()
{
long cval, val1, val2, rval;
int set_noeval;
set_noeval = 0;
rval = cval = explor ();
if (curtok == QUES) /* found conditional expr */
{
@ -391,23 +424,30 @@ expcond ()
if (curtok == 0 || curtok == COL)
evalerror ("expression expected");
if (cval == 0)
noeval++;
{
set_noeval = 1;
noeval++;
}
#if 0
val1 = explor ();
#else
val1 = expassign ();
#endif
if (cval == 0)
if (set_noeval)
noeval--;
if (curtok != COL)
evalerror ("`:' expected for conditional expression");
readtok ();
if (curtok == 0)
evalerror ("expression expected");
set_noeval = 0;
if (cval)
noeval++;
{
set_noeval = 1;
noeval++;
}
val2 = explor ();
if (cval)
if (set_noeval)
noeval--;
rval = cval ? val1 : val2;
lasttok = COND;
@ -420,18 +460,24 @@ static long
explor ()
{
register long val1, val2;
int set_noeval;
val1 = expland ();
while (curtok == LOR)
{
set_noeval = 0;
if (val1 != 0)
{
noeval++;
set_noeval = 1;
}
readtok ();
if (val1 != 0)
noeval++;
val2 = expland ();
if (val1 != 0)
if (set_noeval)
noeval--;
val1 = val1 || val2;
lasttok = LOR;
}
return (val1);
@ -442,18 +488,24 @@ static long
expland ()
{
register long val1, val2;
int set_noeval;
val1 = expbor ();
while (curtok == LAND)
{
set_noeval = 0;
if (val1 == 0)
{
set_noeval = 1;
noeval++;
}
readtok ();
if (val1 == 0)
noeval++;
val2 = expbor ();
if (val1 == 0)
if (set_noeval)
noeval--;
val1 = val1 && val2;
lasttok = LAND;
}
return (val1);
@ -556,7 +608,7 @@ exp4 ()
val1 = val1 >= val2;
else if (op == LT)
val1 = val1 < val2;
else if (op == GT)
else /* (op == GT) */
val1 = val1 > val2;
}
return (val1);
@ -762,7 +814,12 @@ readtok ()
value = get_string_value (tokstr);
#endif
tokval = (value && *value) ? evalexp (value) : 0;
tokval = (value && *value) ? subexpr (value) : 0;
#if defined (ARRAY_VARS)
if (e == ']')
FREE (value); /* get_array_value returns newly-allocated memory */
#endif
*cp = c;
lasttok = curtok;
@ -960,14 +1017,18 @@ main (argc, argv)
{
register int i;
long v;
int expok;
if (setjmp (top_level))
exit (0);
for (i = 1; i < argc; i++)
{
v = evalexp (argv[i]);
printf ("'%s' -> %ld\n", argv[i], v);
v = evalexp (argv[i], &expok);
if (expok == 0)
fprintf (stderr, "%s: expression error\n", argv[i]);
else
printf ("'%s' -> %ld\n", argv[i], v);
}
exit (0);
}

View File

@ -27,11 +27,11 @@
#include "stdc.h"
/* Functions from expr.c. */
extern long evalexp __P((char *));
extern long evalexp __P((char *, int *));
/* Functions from getcwd.c */
#if !defined (HAVE_GETCWD)
extern char *getcwd ();
extern char *getcwd __P((char *, size_t));
#endif
/* Functions from print_cmd.c. */
@ -45,18 +45,20 @@ extern void xtrace_print_word_list __P((WORD_LIST *));
/* Functions from shell.c. */
extern int exit_shell __P((int));
extern void disable_priv_mode __P((void));
extern void unbind_args __P((void));
#if defined (RESTRICTED_SHELL)
extern int maybe_make_restricted __P((char *));
#endif
extern void get_current_user_info __P((void));
/* Functions from eval.c. */
extern int reader_loop __P((void));
extern int parse_command __P((void));
extern int read_command __P((void));
/* Functions from test.c. */
extern int group_member ();
extern int test_command ();
/* Functions from braces.c. */
@ -115,7 +117,7 @@ extern int setlinebuf ();
#endif
/* Declarations for functions defined in stringlib.c */
extern char *ansicstr __P((char *, int, int *));
extern char *ansicstr __P((char *, int, int *, int *));
extern int find_name_in_array __P((char *, char **));
extern int array_len __P((char **));
extern void free_array_members __P((char **));
@ -128,7 +130,7 @@ extern WORD_LIST *argv_to_word_list __P((char **, int, int));
extern char *strsub __P((char *, char *, char *, int));
extern void strip_leading __P((char *));
extern void strip_trailing __P((char *, int));
extern void strip_trailing __P((char *, int, int));
extern char *strindex __P((char *, char *));
extern void xbcopy __P((char *, char *, int));

50
flags.c
View File

@ -32,6 +32,10 @@ Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
extern int set_job_control ();
#endif
#if defined (RESTRICTED_SHELL)
extern char *shell_name;
#endif
/* **************************************************************** */
/* */
/* The Standard Sh Flags. */
@ -238,12 +242,26 @@ change_flag (flag, on_or_off)
{
#if defined (JOB_CONTROL)
case 'm':
set_job_control (on_or_off == '-');
set_job_control (on_or_off == FLAG_ON);
break;
#endif /* JOB_CONTROL */
#if defined (RESTRICTED_SHELL)
case 'r':
if (on_or_off == FLAG_ON)
maybe_make_restricted (shell_name);
break;
#endif
#if defined (BANG_HISTORY)
case 'H':
if (on_or_off == FLAG_ON)
bash_initialize_history ();
break;
#endif
case 'p':
if (on_or_off == '+')
if (on_or_off == FLAG_OFF)
disable_priv_mode ();
break;
@ -268,3 +286,31 @@ which_set_flags ()
temp[string_index] = '\0';
return (temp);
}
void
reset_shell_flags ()
{
mark_modified_vars = exit_immediately_on_error = disallow_filename_globbing = 0;
place_keywords_in_env = read_but_dont_execute = just_one_command = 0;
noclobber = unbound_vars_is_error = echo_input_at_read = 0;
echo_command_at_execute = jobs_m_flag = forced_interactive = 0;
no_symbolic_links = no_invisible_vars = privileged_mode = 0;
hashing_enabled = interactive_comments = 1;
#if defined (JOB_CONTROL)
asynchronous_notification = 0;
#endif
#if defined (BANG_HISTORY)
history_expansion = 1;
#endif
#if defined (BRACE_EXPANSION)
brace_expansion = 1;
#endif
#if defined (RESTRICTED_SHELL)
restricted = 0;
#endif
}

View File

@ -66,6 +66,7 @@ extern int restricted;
extern int *find_flag __P((int));
extern int change_flag __P((int, int));
extern char *which_set_flags __P((void));
extern void reset_shell_flags __P((void));
/* A macro for efficiency. */
#define change_flag_char(flag, on_or_off) change_flag (flag, on_or_off)

186
general.c
View File

@ -89,12 +89,10 @@ char *
itos (i)
int i;
{
char *buf, *p, *ret;
char buf[MAX_INT_LEN], *p, *ret;
int negative = 0;
unsigned int ui;
buf = xmalloc (MAX_INT_LEN);
if (i < 0)
{
negative++;
@ -114,7 +112,6 @@ itos (i)
*p-- = '-';
ret = savestring (p + 1);
free (buf);
return (ret);
}
@ -439,14 +436,14 @@ check_dev_tty ()
int tty_fd;
char *tty;
tty_fd = open ("/dev/tty", O_RDWR);
tty_fd = open ("/dev/tty", O_RDWR|O_NONBLOCK);
if (tty_fd < 0)
{
tty = (char *)ttyname (fileno (stdin));
if (tty == 0)
return;
tty_fd = open (tty, O_RDWR);
tty_fd = open (tty, O_RDWR|O_NONBLOCK);
}
close (tty_fd);
}
@ -482,18 +479,25 @@ same_file (path1, path2, stp1, stp2)
allowed in the shell process, to avoid the user stepping on it with
redirection and causing us extra work. If CHECK_NEW is non-zero,
we check whether or not the file descriptors are in use before
duplicating FD onto them. */
duplicating FD onto them. MAXFD says where to start checking the
file descriptors. If it's less than 20, we get the maximum value
available from getdtablesize(2). */
int
move_to_high_fd (fd, check_new)
int fd, check_new;
move_to_high_fd (fd, check_new, maxfd)
int fd, check_new, maxfd;
{
int script_fd, nfds, ignore;
nfds = getdtablesize ();
if (nfds <= 0)
nfds = 20;
if (nfds > 256)
nfds = 256;
if (maxfd < 20)
{
nfds = getdtablesize ();
if (nfds <= 0)
nfds = 20;
if (nfds > 256)
nfds = 256;
}
else
nfds = maxfd;
for (nfds--; check_new && nfds > 3; nfds--)
if (fcntl (nfds, F_GETFD, &ignore) == -1)
@ -607,11 +611,12 @@ canonicalize_pathname (path)
while (result[i] == '/')
i++;
#if !defined (apollo)
#if 0
if ((start + 1) != i)
#else
/* Leave a leading `//' alone, as POSIX requires. */
if ((start + 1) != i && (start != 0 || i != 2))
#endif /* apollo */
#endif
{
strcpy (result + start + 1, result + i);
i = start + 1;
@ -709,11 +714,11 @@ make_absolute (string, dot_path)
char *result;
int result_len;
if (!dot_path || *string == '/')
if (dot_path == 0 || *string == '/')
result = savestring (string);
else
{
if (dot_path && dot_path[0])
if (dot_path[0])
{
result_len = strlen (dot_path);
result = xmalloc (2 + result_len + strlen (string));
@ -801,6 +806,7 @@ full_pathname (file)
disposer = file;
/* XXX - this should probably be just PATH_MAX or PATH_MAX + 1 */
current_dir = xmalloc (2 + PATH_MAX + strlen (file));
if (getcwd (current_dir, PATH_MAX) == 0)
{
@ -906,9 +912,9 @@ extract_colon_unit (string, p_index)
/* If tilde_expand hasn't been able to expand the text, perhaps it
is a special shell expansion. This function is installed as the
tilde_expansion_failure_hook. It knows how to expand ~- and ~+. */
tilde_expansion_preexpansion_hook. It knows how to expand ~- and ~+. */
static char *
bash_tilde_expansion_failure_hook (text)
bash_special_tilde_expansions (text)
char *text;
{
char *result;
@ -917,9 +923,9 @@ bash_tilde_expansion_failure_hook (text)
if (text[1] == '\0')
{
if (*text == '+')
result = get_string_value ("PWD");
result = get_string_value ("PWD");
else if (*text == '-')
result = get_string_value ("OLDPWD");
result = get_string_value ("OLDPWD");
}
return (result ? savestring (result) : (char *)NULL);
@ -933,8 +939,8 @@ tilde_initialize ()
{
static int times_called = 0;
/* Tell the tilde expander that we want a crack if it fails. */
tilde_expansion_failure_hook = (CPFunction *)bash_tilde_expansion_failure_hook;
/* Tell the tilde expander that we want a crack first. */
tilde_expansion_preexpansion_hook = (CPFunction *)bash_special_tilde_expansions;
/* Tell the tilde expander about special strings which start a tilde
expansion, and the special strings that end one. Only do this once.
@ -967,3 +973,135 @@ bash_tilde_expand (s)
interrupt_immediately = old_immed;
return (ret);
}
/* **************************************************************** */
/* */
/* Functions to manipulate and search the group list */
/* */
/* **************************************************************** */
static int ngroups, maxgroups;
/* The set of groups that this user is a member of. */
static GETGROUPS_T *group_array = (GETGROUPS_T *)NULL;
#if !defined (NOGROUP)
# define NOGROUP (gid_t) -1
#endif
#if defined (HAVE_SYSCONF) && defined (_SC_NGROUPS_MAX)
# define getmaxgroups() sysconf(_SC_NGROUPS_MAX)
#else
# if defined (NGROUPS_MAX)
# define getmaxgroups() NGROUPS_MAX
# else /* !NGROUPS_MAX */
# if defined (NGROUPS)
# define getmaxgroups() NGROUPS
# else /* !NGROUPS */
# define getmaxgroups() 64
# endif /* !NGROUPS */
# endif /* !NGROUPS_MAX */
#endif /* !HAVE_SYSCONF || !SC_NGROUPS_MAX */
static void
initialize_group_array ()
{
register int i;
if (maxgroups == 0)
maxgroups = getmaxgroups ();
ngroups = 0;
group_array = (GETGROUPS_T *)xrealloc (group_array, maxgroups * sizeof (GETGROUPS_T));
#if defined (HAVE_GETGROUPS)
ngroups = getgroups (maxgroups, group_array);
#endif
/* If getgroups returns nothing, or the OS does not support getgroups(),
make sure the groups array includes at least the current gid. */
if (ngroups == 0)
{
group_array[0] = current_user.gid;
ngroups = 1;
}
/* If the primary group is not in the groups array, add it as group_array[0]
and shuffle everything else up 1, if there's room. */
for (i = 0; i < ngroups; i++)
if (current_user.gid == (gid_t)group_array[i])
break;
if (i == ngroups && ngroups < maxgroups)
{
for (i = ngroups; i > 0; i--)
group_array[i] = group_array[i - 1];
group_array[0] = current_user.gid;
ngroups++;
}
}
/* Return non-zero if GID is one that we have in our groups list. */
int
group_member (gid)
gid_t gid;
{
#if defined (HAVE_GETGROUPS)
register int i;
#endif
/* Short-circuit if possible, maybe saving a call to getgroups(). */
if (gid == current_user.gid || gid == current_user.egid)
return (1);
#if defined (HAVE_GETGROUPS)
if (ngroups == 0)
initialize_group_array ();
/* In case of error, the user loses. */
if (ngroups <= 0)
return (0);
/* Search through the list looking for GID. */
for (i = 0; i < ngroups; i++)
if (gid == (gid_t)group_array[i])
return (1);
#endif
return (0);
}
char **
get_group_list (ngp)
int *ngp;
{
static char **group_vector = (char **)NULL;
register int i;
char *nbuf;
if (group_vector)
{
if (ngp)
*ngp = ngroups;
return group_vector;
}
if (ngroups == 0)
initialize_group_array ();
if (ngroups <= 0)
{
if (ngp)
*ngp = 0;
return (char **)NULL;
}
group_vector = (char **)xmalloc (ngroups * sizeof (char *));
for (i = 0; i < ngroups; i++)
{
nbuf = itos ((int)group_array[i]);
group_vector[i] = nbuf;
}
if (ngp)
*ngp = ngroups;
return group_vector;
}

View File

@ -23,6 +23,14 @@
#include "stdc.h"
#include "bashtypes.h"
#if defined (HAVE_STRING_H)
# include <string.h>
#else
# include <strings.h>
#endif /* !HAVE_STRING_H */
/* Generic pointer type. */
#if defined (__STDC__)
# define PTR_T void *
@ -39,12 +47,6 @@
# endif /* !__STDC__ */
#endif /* !NULL */
#if defined (HAVE_STRING_H)
# include <string.h>
#else
# include <strings.h>
#endif /* !HAVE_STRING_H */
#define pointer_to_int(x) (int)((long)(x))
extern char *xmalloc (), *xrealloc ();
@ -197,7 +199,7 @@ extern int check_identifier __P((WORD_DESC *, int));
extern void unset_nodelay_mode __P((int));
extern void check_dev_tty __P((void));
extern int same_file (); /* too many problems with prototype */
extern int move_to_high_fd __P((int, int));
extern int move_to_high_fd __P((int, int, int));
extern int check_binary_file __P((unsigned char *, int));
extern char *canonicalize_pathname __P((char *));
@ -213,4 +215,11 @@ extern char *extract_colon_unit __P((char *, int *));
extern void tilde_initialize __P((void));
extern char *bash_tilde_expand __P((char *));
#if defined (__STDC__) && defined (gid_t)
extern int group_member __P((int));
#else
extern int group_member __P((gid_t));
#endif
extern char **get_group_list __P((int *));
#endif /* _GENERAL_H_ */

View File

@ -38,17 +38,7 @@
#include "maxpath.h"
#include "memalloc.h"
#if defined (HAVE_STDLIB_H)
# include <stdlib.h>
#else
# include "ansi_stdlib.h"
#endif /* !HAVE_STDLIB_H */
#if defined (HAVE_STRING_H)
# include <string.h>
#else
# include <strings.h>
#endif /* !HAVE_STRING_H */
#include "bashansi.h"
#if !defined (errno)
extern int errno;

191
hashcmd.c Normal file
View File

@ -0,0 +1,191 @@
/* hashcmd.c - functions for managing a hash table mapping command names to
full pathnames. */
/* Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <config.h>
#include "bashtypes.h"
#include "posixstat.h"
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif
#include "bashansi.h"
#include "shell.h"
#include "execute_cmd.h"
#include "hashcmd.h"
extern int hashing_enabled;
static int hashing_initialized = 0;
HASH_TABLE *hashed_filenames;
void
initialize_filename_hashing ()
{
if (hashing_initialized == 0)
{
hashed_filenames = make_hash_table (FILENAME_HASH_BUCKETS);
hashing_initialized = 1;
}
}
static void
free_filename_data (data)
char *data;
{
free (((PATH_DATA *)data)->path);
free (data);
}
void
flush_hashed_filenames ()
{
if (hashed_filenames)
flush_hash_table (hashed_filenames, free_filename_data);
}
/* Remove FILENAME from the table of hashed commands. */
void
remove_hashed_filename (filename)
char *filename;
{
register BUCKET_CONTENTS *item;
if (hashing_enabled == 0 || hashed_filenames == 0)
return;
item = remove_hash_item (filename, hashed_filenames);
if (item)
{
if (item->data)
free_filename_data (item->data);
free (item->key);
free (item);
}
}
/* Place FILENAME (key) and FULL_PATHNAME (data->path) into the
hash table. CHECK_DOT if non-null is for future calls to
find_hashed_filename (); it means that this file was found
in a directory in $PATH that is not an absolute pathname.
FOUND is the initial value for times_found. */
void
remember_filename (filename, full_pathname, check_dot, found)
char *filename, *full_pathname;
int check_dot, found;
{
register BUCKET_CONTENTS *item;
if (hashing_enabled == 0)
return;
if (hashed_filenames == 0 || hashing_initialized == 0)
initialize_filename_hashing ();
item = add_hash_item (filename, hashed_filenames);
if (item->data)
free (pathdata(item)->path);
else
{
item->key = savestring (filename);
item->data = xmalloc (sizeof (PATH_DATA));
}
pathdata(item)->path = savestring (full_pathname);
pathdata(item)->flags = 0;
if (check_dot)
pathdata(item)->flags |= HASH_CHKDOT;
if (*full_pathname != '/')
pathdata(item)->flags |= HASH_RELPATH;
item->times_found = found;
}
/* Return the full pathname that FILENAME hashes to. If FILENAME
is hashed, but (data->flags & HASH_CHKDOT) is non-zero, check
./FILENAME and return that if it is executable. This always
returns a newly-allocated string; the caller is responsible
for freeing it. */
char *
find_hashed_filename (filename)
char *filename;
{
register BUCKET_CONTENTS *item;
char *path, *dotted_filename, *tail;
int same;
if (hashing_enabled == 0 || hashed_filenames == 0)
return ((char *)NULL);
item = find_hash_item (filename, hashed_filenames);
if (item == NULL)
return ((char *)NULL);
/* If this filename is hashed, but `.' comes before it in the path,
see if ./filename is executable. If the hashed value is not an
absolute pathname, see if ./`hashed-value' exists. */
path = pathdata(item)->path;
if (pathdata(item)->flags & (HASH_CHKDOT|HASH_RELPATH))
{
tail = (pathdata(item)->flags & HASH_RELPATH) ? path : filename;
dotted_filename = xmalloc (3 + strlen (tail));
dotted_filename[0] = '.'; dotted_filename[1] = '/';
strcpy (dotted_filename + 2, tail);
if (executable_file (dotted_filename))
return (dotted_filename);
free (dotted_filename);
#if 0
if (pathdata(item)->flags & HASH_RELPATH)
return ((char *)NULL);
#endif
/* Watch out. If this file was hashed to "./filename", and
"./filename" is not executable, then return NULL. */
/* Since we already know "./filename" is not executable, what
we're really interested in is whether or not the `path'
portion of the hashed filename is equivalent to the current
directory, but only if it starts with a `.'. (This catches
./. and so on.) same_file () tests general Unix file
equivalence -- same device and inode. */
if (*path == '.')
{
same = 0;
tail = (char *)strrchr (path, '/');
if (tail)
{
*tail = '\0';
same = same_file (".", path, (struct stat *)NULL, (struct stat *)NULL);
*tail = '/';
}
return same ? (char *)NULL : savestring (path);
}
}
return (savestring (path));
}

View File

@ -1,4 +1,4 @@
/* hashcom.h - Common defines for hashing filenames. */
/* hashcmd.h - Common defines for hashing filenames. */
/* Copyright (C) 1993 Free Software Foundation, Inc.
@ -18,7 +18,7 @@
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "../hashlib.h"
#include "hashlib.h"
#define FILENAME_HASH_BUCKETS 631
@ -33,3 +33,9 @@ typedef struct {
#define HASH_CHKDOT 0x02 /* check `.' since it was earlier in $PATH */
#define pathdata(x) ((PATH_DATA *)(x)->data)
extern void initialize_filename_hashing ();
extern void flush_hashed_filenames ();
extern void remove_hashed_filename ();
extern void remember_filename ();
extern char *find_hashed_filename ();

View File

@ -20,22 +20,14 @@ Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "config.h"
#if defined (HAVE_STRING_H)
# include <string.h>
#else /* !HAVE_STRING_H */
# include <strings.h>
#endif /* !HAVE_STRING_H */
#if defined (HAVE_STDLIB_H)
# include <stdlib.h>
#else
# include "ansi_stdlib.h"
#endif /* HAVE_STDLIB_H */
#include "bashansi.h"
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif
#include <stdio.h>
#include "shell.h"
#include "hashlib.h"
@ -201,6 +193,9 @@ flush_hash_table (table, free_data)
int i;
register BUCKET_CONTENTS *bucket, *item;
if (table == 0)
return;
for (i = 0; i < table->nbuckets; i++)
{
bucket = table->bucket_array[i];
@ -221,6 +216,15 @@ flush_hash_table (table, free_data)
}
}
/* Free the hash table pointed to by TABLE. */
void
dispose_hash_table (table)
HASH_TABLE *table;
{
free (table->bucket_array);
free (table);
}
/* Return the bucket_contents list of bucket BUCKET in TABLE. If
TABLE doesn't have BUCKET buckets, return NULL. */
#undef get_hash_bucket
@ -235,6 +239,34 @@ get_hash_bucket (bucket, table)
return (BUCKET_CONTENTS *)NULL;
}
/* #ifdef DEBUG */
print_table_stats (table, name)
HASH_TABLE *table;
char *name;
{
register int slot, bcount;
register BUCKET_CONTENTS *bc;
if (name == 0)
name = "unknown hash table";
fprintf (stderr, "%s: %d buckets; %d items\n", name, table->nbuckets, table->nentries);
/* Print out a count of how many strings hashed to each bucket, so we can
see how even the distribution is. */
for (slot = 0; slot < table->nbuckets; slot++)
{
bc = get_hash_bucket (slot, table);
fprintf (stderr, "\tslot %3d: ", slot);
for (bcount = 0; bc; bc = bc->next)
bcount++;
fprintf (stderr, "%d\n", bcount);
}
}
/* #endif */
#ifdef TEST_HASHING
#undef NULL
@ -284,25 +316,8 @@ main ()
}
}
printf ("You have entered %d (%d) items. The distribution is:\n",
table->nentries, count);
/* Print out a count of how many strings hashed to each bucket, so we can
see how even the distribution is. */
for (count = 0; count < table->nbuckets; count++)
{
int bcount;
register BUCKET_CONTENTS *list = get_hash_bucket (count, table);
printf ("slot %3d: ", count);
bcount = 0;
for (bcount = 0; list; list = list->next)
bcount++;
printf ("%d\n", bcount);
}
exit (0);
print_table_stats (table, "hash test");
exit (0);
}
#endif /* TEST_HASHING */

View File

@ -41,6 +41,7 @@ extern BUCKET_CONTENTS *remove_hash_item ();
extern BUCKET_CONTENTS *add_hash_item ();
extern BUCKET_CONTENTS *get_hash_bucket ();
extern void flush_hash_table ();
extern void dispose_hash_table ();
/* Redefine the function as a macro for speed. */
#define get_hash_bucket(bucket, table) \
@ -49,7 +50,7 @@ extern void flush_hash_table ();
(BUCKET_CONTENTS *)NULL)
/* Default number of buckets in the hash table. */
#define DEFAULT_HASH_BUCKETS 107
#define DEFAULT_HASH_BUCKETS 53 /* was 107 */
#if !defined (NULL)
# if defined (__STDC__)

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