]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
commit bash-20061221 snapshot
authorChet Ramey <chet.ramey@case.edu>
Wed, 7 Dec 2011 14:01:57 +0000 (09:01 -0500)
committerChet Ramey <chet.ramey@case.edu>
Wed, 7 Dec 2011 14:01:57 +0000 (09:01 -0500)
101 files changed:
CWRU/CWRU.chlog
CWRU/CWRU.chlog~
Makefile.in
Makefile.in.save1 [new file with mode: 0644]
Makefile.in~ [new file with mode: 0644]
aclocal.m4
aclocal.m4~
arrayfunc.c
arrayfunc.c~ [new file with mode: 0644]
autom4te.cache/output.1
autom4te.cache/requests
autom4te.cache/traces.1
bashline.c~ [new file with mode: 0644]
braces.c
braces.c~ [new file with mode: 0644]
builtins/cd.def
builtins/cd.def~
builtins/common.c
builtins/common.c~
builtins/complete.def
builtins/complete.def~
builtins/exit.def
builtins/exit.def~
builtins/help.def
builtins/help.def.save1 [new file with mode: 0644]
builtins/help.def.save2 [new file with mode: 0644]
builtins/reserved.def
builtins/set.def
builtins/set.def~
builtins/shopt.def
builtins/shopt.def~
builtins/ulimit.def
builtins/ulimit.def~
configure
configure.in
configure.in.save1 [new file with mode: 0644]
configure.in~ [new file with mode: 0644]
doc/bash.1
doc/bash.1~
doc/bashref.texi
doc/bashref.texi.orig
doc/bashref.texi.save1 [new file with mode: 0644]
doc/bashref.texi~
doc/version.texi
doc/version.texi~
error.c
error.c~
execute_cmd.c
execute_cmd.c~
expr.c
expr.c~
flags.c
flags.c~ [new file with mode: 0644]
flags.h
flags.h~ [new file with mode: 0644]
general.c
general.c~
jobs.h
lib/glob/glob.h
lib/glob/glob.h~ [new file with mode: 0644]
lib/malloc/malloc.c
lib/malloc/malloc.c~
lib/readline/bind.c
lib/readline/bind.c~ [new file with mode: 0644]
lib/readline/complete.c
lib/readline/complete.c~
lib/readline/doc/rltech.texi
lib/readline/doc/rltech.texi~ [new file with mode: 0644]
lib/readline/doc/rluser.texi
lib/readline/doc/rluser.texi~
lib/readline/doc/version.texi
lib/readline/doc/version.texi~ [new file with mode: 0644]
lib/readline/funmap.c
lib/readline/funmap.c~ [new file with mode: 0644]
lib/readline/isearch.c
lib/readline/isearch.c~ [new file with mode: 0644]
lib/readline/readline.h
lib/readline/readline.h~ [new file with mode: 0644]
lib/readline/rlprivate.h
lib/readline/rlprivate.h~
lib/readline/terminal.c
lib/readline/terminal.c~ [new file with mode: 0644]
lib/readline/util.c
lib/readline/util.c~ [new file with mode: 0644]
lib/readline/vi_mode.c
lib/readline/vi_mode.c~ [new file with mode: 0644]
parse.y
parse.y~
pcomplete.c
pcomplete.c~ [new file with mode: 0644]
redir.c
redir.c~ [new file with mode: 0644]
shell.c
shell.c~
subst.c
subst.c~
tests/RUN-ONE-TEST
variables.c
variables.c~ [new file with mode: 0644]
version.c
version.c~

index f337054e3ffb9e3d66548b12b3031bdc811a2b66..8aa212d11a257a84a442de19f7d22baab7d7db40 100644 (file)
@@ -14048,3 +14048,129 @@ builtins/{common,evalfile}.c
 {error,expr,jobs,mksyntax,nojobs,shell,subst,version,siglist}.c
        - add gettextizing marks to untranslated strings
          From Benno Schulenberg <bensberg@justemail.net>
+
+                                  12/19
+                                  -----
+builtins/common.c
+       - change display_signal_list (used by `trap -l' and `kill -l') to use
+         five columns instead of 4 to display signal names
+
+builtins/help.def
+       - use the true terminal width instead of assuming 80 when displaying
+         help topics, leaving two characters of whitespace between horizontal
+         descriptions instead of 1
+       - change to print in columns with entries sorted down rather than across
+         (that is, like `ls' rather than `ls -x').  Change inspired by Benno 
+         Schulenberg <bensberg@justemail.net>
+
+jobs.h
+       - give values to the JOB_STATE enumerations so they can be used as
+         bitmasks, too
+
+                                  12/22
+                                  -----
+doc/{bash.1,bashref.texi}
+       - change description of `set' to make it clearer that you can use
+         `+' to turn off options
+       - clarify in the description of word splitting that sequences of
+         IFS whitespace at the beginning or end of the string are ignored
+
+                                  12/26
+                                  -----
+doc/bashref.texi
+       - move `shopt' builtin to its own section; change internal references
+         from `Bash Builtins' to the new shopt builtin
+       - new section for builtins that modify shell behavior in `Shell
+         Builtin Commands'; move set and shopt to new section.  Changes
+         inspired by Benno Schulenberg <bensberg@justemail.net>
+
+{redir,subst}.c
+       - add MT_USETMPDIR flag to calls to sh_mktmpfd and sh_mktmpname.  Bug
+         reported by Eric Blake <ebb9@byu.net>
+
+{configure,Makefile}.in
+       - changes so that the pathname for DEBUGGER_START_FILE is substituted
+         into pathnames.h at make time (allowing more flexibility in setting
+         `prefix' or `datadir') instead of at configure time.  Suggested by
+         Nick Brown <nickbroon@blueyonder.co.uk>
+
+shell.c
+       - declaration for  have_devfd; initialized from HAVE_DEV_FD
+       - declaration for check_jobs_at_exit; initialized to 0
+       - declaration for autocd; initialized to 0
+
+variables.c
+       - new dynamic variable, BASHPID, always set from return value from
+         getpid() (changes even when $$ doesn't change).  Idea from Bruce
+         Korb <bruce.corb@3pardata.com>
+
+builtins/exit.def
+       - if check_jobs_at_exit is non-zero, list jobs if there are any stopped
+         or running background jobs; don't exit shell if any running jobs
+
+execute_cmd.c
+       - in execute_simple_command, if the first word of a simple command is
+         a directory name (after looking for builtins, so `.' isn't caught)
+         that isn't found in $PATH, and `autocd' is non-zero, prefix a "cd"
+         to the command words
+
+builtins/shopt.def
+       - new `checkjobs' option, changes value of check_jobs_at_exit
+       - new `autocd' option, changes value of autocd
+
+pcomplete.c
+       - add COMP_TYPE, set to rl_completion_type, to list of variables set
+         by bind_compfunc_variables and unset by unbind_compfunc_variables
+
+doc/{bash.1,bashref.texi}
+       - document BASHPID
+       - document new shopt `checkjobs' option
+       - document new shopt `autocd' option
+       - document COMP_TYPE completion variable
+
+                                  12/29
+                                  -----
+aclocal.m4
+       - in BASH_SYS_SIGLIST, check HAVE_DECL_SYS_SIGLIST instead of the
+         obsolete and no-longer-supported SYS_SIGLIST_DECLARED
+
+                                  12/30
+                                  -----
+lib/readline/vi_mode.c
+       - add ` (backquote) to the list of vi motion characters
+       - in rl_vi_delete_to, rl_vi_change_to, and rl_vi_yank_to, don't delete
+         character under the cursor if the motion command moves the cursor
+         backward, so add F and T to the commands that don't cause the
+         mark to be adjusted
+       - add ` to the characters that don't cause the mark to be adjusted
+         when used as a motion command, since it's defined to behave that way
+       - when a motion character that may adjust the mark moves point
+         backward, don't adjust the mark so the character under the cursor
+         isn't deleted
+
+lib/readline/complete.c
+       - add variable rl_sort_completion_matches; allows application to
+         inhibit match list sorting
+       - add variable rl_completion_invoking_key; allows applications to
+         discover the key that invoked rl_complete or rl_menu_complete
+
+lib/readline/readline.h
+       - extern declarations for rl_completion_invoking_key and
+         rl_sort_completion_matches
+
+lib/readline/doc/rltech.texi
+       - documented rl_completion_invoking_key and rl_sort_completion_matches
+
+pcomplete.c
+       - export variable COMP_KEY to completion functions; initialized from
+         rl_completion_invoking_key; unset along with rest of completion
+         variables
+
+doc/{bash.1,bashref.texi},lib/readline/doc/rluser.texi
+       - document COMP_KEY
+
+[many files]
+       - changes to make variables and function parameters `const' for better
+         text sharing.  Changes originally from Andreas Mohr
+         <andi@rhlx01.fht-esslingen.de>
+
index 8c3b8c01cbb8fa5bc49572f2db062f08df4e59dd..1d331b89e570c85f3fbec90925362a734648b4c4 100644 (file)
@@ -14045,6 +14045,131 @@ doc/{bash.1,bashref.texi}
 
 builtins/{break,exit,fg_bg,hash,jobs,type,ulimit}.def
 builtins/{common,evalfile}.c
-{error,expr,jobs,mksyntax,nojobs,shell,subst,version}.c
+{error,expr,jobs,mksyntax,nojobs,shell,subst,version,siglist}.c
        - add gettextizing marks to untranslated strings
          From Benno Schulenberg <bensberg@justemail.net>
+
+                                  12/19
+                                  -----
+builtins/common.c
+       - change display_signal_list (used by `trap -l' and `kill -l') to use
+         five columns instead of 4 to display signal names
+
+builtins/help.def
+       - use the true terminal width instead of assuming 80 when displaying
+         help topics, leaving two characters of whitespace between horizontal
+         descriptions instead of 1
+       - change to print in columns with entries sorted down rather than across
+         (that is, like `ls' rather than `ls -x').  Change inspired by Benno 
+         Schulenberg <bensberg@justemail.net>
+
+jobs.h
+       - give values to the JOB_STATE enumerations so they can be used as
+         bitmasks, too
+
+                                  12/22
+                                  -----
+doc/{bash.1,bashref.texi}
+       - change description of `set' to make it clearer that you can use
+         `+' to turn off options
+       - clarify in the description of word splitting that sequences of
+         IFS whitespace at the beginning or end of the string are ignored
+
+                                  12/26
+                                  -----
+doc/bashref.texi
+       - move `shopt' builtin to its own section; change internal references
+         from `Bash Builtins' to the new shopt builtin
+       - new section for builtins that modify shell behavior in `Shell
+         Builtin Commands'; move set and shopt to new section.  Changes
+         inspired by Benno Schulenberg <bensberg@justemail.net>
+
+{redir,subst}.c
+       - add MT_USETMPDIR flag to calls to sh_mktmpfd and sh_mktmpname.  Bug
+         reported by Eric Blake <ebb9@byu.net>
+
+{configure,Makefile}.in
+       - changes so that the pathname for DEBUGGER_START_FILE is substituted
+         into pathnames.h at make time (allowing more flexibility in setting
+         `prefix' or `datadir') instead of at configure time.  Suggested by
+         Nick Brown <nickbroon@blueyonder.co.uk>
+
+shell.c
+       - declaration for  have_devfd; initialized from HAVE_DEV_FD
+       - declaration for check_jobs_at_exit; initialized to 0
+       - declaration for autocd; initialized to 0
+
+variables.c
+       - new dynamic variable, BASHPID, always set from return value from
+         getpid() (changes even when $$ doesn't change).  Idea from Bruce
+         Korb <bruce.corb@3pardata.com>
+
+builtins/exit.def
+       - if check_jobs_at_exit is non-zero, list jobs if there are any stopped
+         or running background jobs; don't exit shell if any running jobs
+
+execute_cmd.c
+       - in execute_simple_command, if the first word of a simple command is
+         a directory name (after looking for builtins, so `.' isn't caught)
+         that isn't found in $PATH, and `autocd' is non-zero, prefix a "cd"
+         to the command words
+
+builtins/shopt.def
+       - new `checkjobs' option, changes value of check_jobs_at_exit
+       - new `autocd' option, changes value of autocd
+
+pcomplete.c
+       - add COMP_TYPE, set to rl_completion_type, to list of variables set
+         by bind_compfunc_variables and unset by unbind_compfunc_variables
+
+doc/{bash.1,bashref.texi}
+       - document BASHPID
+       - document new shopt `checkjobs' option
+       - document new shopt `autocd' option
+       - document COMP_TYPE completion variable
+
+                                  12/29
+                                  -----
+aclocal.m4
+       - in BASH_SYS_SIGLIST, check HAVE_DECL_SYS_SIGLIST instead of the
+         obsolete and no-longer-supported SYS_SIGLIST_DECLARED
+
+                                  12/30
+                                  -----
+lib/readline/vi_mode.c
+       - add ` (backquote) to the list of vi motion characters
+       - in rl_vi_delete_to, rl_vi_change_to, and rl_vi_yank_to, don't delete
+         character under the cursor if the motion command moves the cursor
+         backward, so add F and T to the commands that don't cause the
+         mark to be adjusted
+       - add ` to the characters that don't cause the mark to be adjusted
+         when used as a motion command, since it's defined to behave that way
+       - when a motion character that may adjust the mark moves point
+         backward, don't adjust the mark so the character under the cursor
+         isn't deleted
+
+lib/readline/complete.c
+       - add variable rl_sort_completion_matches; allows application to
+         inhibit match list sorting
+       - add variable rl_completion_invoking_key; allows applications to
+         discover the key that invoked rl_complete or rl_menu_complete
+
+lib/readline/readline.h
+       - extern declarations for rl_completion_invoking_key and
+         rl_sort_completion_matches
+
+lib/readline/doc/rltech.texi
+       - documented rl_completion_invoking_key and rl_sort_completion_matches
+
+pcomplete.c
+       - export variable COMP_KEY to completion functions; initialized from
+         rl_completion_invoking_key; unset along with rest of completion
+         variables
+
+doc/{bash.1,bashref.texi},lib/readline/doc/rluser.texi
+       - document COMP_KEY
+
+[many files]
+       - changes to make variables and function parameters `const' for better
+         text sharing
+
index e89181814da3bf9f75a100ff09f04aee1119add3..7e6356ade5b6283f03e782259859141a9d320a75 100644 (file)
@@ -78,6 +78,8 @@ INSTALLMODE2 = -m 0555
 
 TESTSCRIPT = @TESTSCRIPT@
 
+DEBUGGER_START_FILE = @DEBUGGER_START_FILE@
+
 #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.
@@ -670,9 +672,6 @@ ${DEFDIR}/builtext.h: $(BUILTIN_DEFS)
 Makefile makefile:     config.status $(srcdir)/Makefile.in
        CONFIG_FILES=Makefile CONFIG_HEADERS= $(SHELL) ./config.status
 
-pathnames.h:           config.status $(srcdir)/Makefile.in
-       CONFIG_HEADERS= $(SHELL) ./config.status
-
 Makefiles makefiles:   config.status $(srcdir)/Makefile.in
        @for mf in $(CREATED_MAKEFILES); do \
                CONFIG_FILES=$$mf CONFIG_HEADERS= $(SHELL) ./config.status ; \
@@ -686,6 +685,15 @@ stamp-h:   config.status $(srcdir)/config.h.in $(srcdir)/config-top.h $(srcdir)/co
 config.status: $(srcdir)/configure
        $(SHELL) ./config.status --recheck
 
+pathnames.h:           Makefile $(srcdir)/pathnames.h.in
+       @sed -e 's|@DEBUGGER_START_FILE\@|${DEBUGGER_START_FILE}|g' $(srcdir)/pathnames.h.in > pathnames.tmp
+       @if test -f $@; then \
+               cmp -s pathnames.tmp $@ || mv pathnames.tmp $@; \
+       else \
+               mv pathnames.tmp $@; \
+       fi
+       @${RM} pathnames.tmp
+
 # comment out for distribution
 $(srcdir)/configure:   $(srcdir)/configure.in $(srcdir)/aclocal.m4 $(srcdir)/config.h.in
        cd $(srcdir) && autoconf
diff --git a/Makefile.in.save1 b/Makefile.in.save1
new file mode 100644 (file)
index 0000000..e891818
--- /dev/null
@@ -0,0 +1,1461 @@
+# Makefile for bash-3.1, version 2.159
+#
+# Copyright (C) 1996-2005 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
+
+# Make sure the first target in the makefile is the right one
+all: .made
+
+PACKAGE = @PACKAGE_NAME@
+VERSION = @PACKAGE_VERSION@
+
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+
+# Include some boilerplate Gnu makefile definitions.
+prefix = @prefix@
+
+exec_prefix = @exec_prefix@
+bindir = @bindir@
+libdir = @libdir@
+infodir = @infodir@
+includedir = @includedir@
+datadir = @datadir@
+localedir = $(datadir)/locale
+
+mandir = @mandir@
+manpfx = man
+
+man1ext = .1
+man1dir = $(mandir)/$(manpfx)1
+man3ext = .3
+man3dir = $(mandir)/$(manpfx)3
+
+htmldir = @htmldir@
+
+# Support an alternate destination root directory for package building
+DESTDIR =
+
+topdir = @top_srcdir@
+BUILD_DIR = @BUILD_DIR@
+top_builddir = @BUILD_DIR@
+srcdir = @srcdir@
+VPATH = .:@srcdir@
+
+@SET_MAKE@
+CC = @CC@
+CC_FOR_BUILD = @CC_FOR_BUILD@
+YACC = @YACC@
+SHELL = @MAKE_SHELL@
+CP = cp
+RM = rm -f
+AR = @AR@
+ARFLAGS = @ARFLAGS@
+RANLIB = @RANLIB@
+SIZE = @SIZE@
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALLMODE= -m 0755
+INSTALLMODE2 = -m 0555
+
+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.
+PURIFY = @PURIFY@
+
+# Here is a rule for making .o files from .c files that does not
+# force the type of the machine (like -M_MACHINE) into the flags.
+.c.o:
+       $(RM) $@
+       $(CC) $(CCFLAGS) -c $<
+
+EXEEXT = @EXEEXT@
+OBJEXT = @OBJEXT@
+
+# The name of this program and some version information.
+VERSPROG = bashversion$(EXEEXT)
+VERSOBJ = bashversion.$(OBJEXT)
+
+Program = bash$(EXEEXT)
+Version = @BASHVERS@
+PatchLevel = `$(BUILD_DIR)/$(VERSPROG) -p`
+RELSTATUS = @RELSTATUS@
+
+Machine = @host_cpu@
+OS = @host_os@
+VENDOR = @host_vendor@
+MACHTYPE = @host@
+
+# comment out for release
+DEBUG = @DEBUG@
+MALLOC_DEBUG = @MALLOC_DEBUG@
+
+THIS_SH = $(BUILD_DIR)/$(Program)
+
+# PROFILE_FLAGS is either -pg, to generate profiling info for use
+# with gprof, or nothing (the default).
+PROFILE_FLAGS= @PROFILE_FLAGS@
+
+CFLAGS = @CFLAGS@
+CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@ @CROSS_COMPILE@
+CPPFLAGS = @CPPFLAGS@
+CPPFLAGS_FOR_BUILD = @CPPFLAGS_FOR_BUILD@
+LOCAL_CFLAGS = @LOCAL_CFLAGS@ ${DEBUG} ${MALLOC_DEBUG}
+DEFS = @DEFS@
+LOCAL_DEFS = @LOCAL_DEFS@
+
+LOCALE_DEFS = -DLOCALEDIR='"$(localedir)"' -DPACKAGE='"$(PACKAGE)"'
+
+LOCAL_LIBS = @LOCAL_LIBS@
+LIBS = $(BUILTINS_LIB) $(LIBRARIES) @LIBS@
+LIBS_FOR_BUILD = 
+
+STATIC_LD = @STATIC_LD@
+LOCAL_LDFLAGS = @LOCAL_LDFLAGS@
+
+SYSTEM_FLAGS = -DPROGRAM='"$(Program)"' -DCONF_HOSTTYPE='"$(Machine)"' -DCONF_OSTYPE='"$(OS)"' -DCONF_MACHTYPE='"$(MACHTYPE)"' -DCONF_VENDOR='"$(VENDOR)"' $(LOCALE_DEFS)
+
+BASE_CCFLAGS = $(PROFILE_FLAGS) $(SYSTEM_FLAGS) $(LOCAL_DEFS) \
+         $(DEFS) $(LOCAL_CFLAGS) $(INCLUDES)
+
+CCFLAGS = $(BASE_CCFLAGS) $(CPPFLAGS) $(CFLAGS)
+
+CCFLAGS_FOR_BUILD = $(BASE_CCFLAGS) $(CPPFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD)
+
+LDFLAGS = @LDFLAGS@ $(STATIC_LD) $(LOCAL_LDFLAGS) $(PROFILE_FLAGS) $(CFLAGS)
+LDFLAGS_FOR_BUILD = $(LDFLAGS)
+
+INCLUDES = -I. @RL_INCLUDE@ -I$(srcdir) -I$(BASHINCDIR) -I$(LIBSRC) $(INTL_INC)
+
+# Maybe add: -Wextra
+GCC_LINT_FLAGS = -O -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wno-parentheses \
+                -Wcast-align -Wstrict-prototypes -Wconversion -Wformat \
+                -Wformat-nonliteral -Wmissing-braces -Wuninitialized \
+                -Wmissing-declarations  -Winline \
+                -Wmissing-prototypes -Wtraditional -Wredundant-decls -pedantic
+
+GCC_LINT_CFLAGS = $(BASE_CCFLAGS) $(CPPFLAGS) $(GCC_LINT_FLAGS)
+
+#
+# Support libraries
+# 
+
+dot = .
+
+LIBSUBDIR = lib
+LIBSRC = $(srcdir)/$(LIBSUBDIR)
+
+LIBBUILD = ${BUILD_DIR}/${LIBSUBDIR}
+
+SUBDIR_INCLUDES = -I. @RL_INCLUDE@ -I$(topdir) -I$(topdir)/$(LIBSUBDIR)
+
+BUILD_INCLUDED_LIBINTL = @BUILD_INCLUDED_LIBINTL@
+USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@
+
+# the bash library
+# the library is a mix of functions that the C library does not provide on
+# some platforms and general shell utility functions
+SH_LIBSRC = $(LIBSRC)/sh
+SH_LIBDIR = $(dot)/${LIBSUBDIR}/sh
+SH_ABSSRC = ${topdir}/${SH_LIBSRC}
+
+SHLIB_SOURCE = ${SH_LIBSRC}/clktck.c ${SH_LIBSRC}/getcwd.c \
+               ${SH_LIBSRC}/getenv.c ${SH_LIBSRC}/oslib.c \
+               ${SH_LIBSRC}/setlinebuf.c \
+               ${SH_LIBSRC}/strcasecmp.c ${SH_LIBSRC}/strerror.c \
+               ${SH_LIBSRC}/strtod.c ${SH_LIBSRC}/strtol.c \
+               ${SH_LIBSRC}/strtoul.c ${SH_LIBSRC}/vprint.c \
+               ${SH_LIBSRC}/itos.c ${SH_LIBSRC}/rename.c \
+               ${SH_LIBSRC}/zread.c ${SH_LIBSRC}/zwrite.c \
+               ${SH_LIBSRC}/shtty.c ${SH_LIBSRC}/inet_aton.c \
+               ${SH_LIBSRC}/netopen.c ${SH_LIBSRC}/strpbrk.c \
+               ${SH_LIBSRC}/timeval.c ${SH_LIBSRC}/clock.c \
+               ${SH_LIBSRC}/makepath.c ${SH_LIBSRC}/pathcanon.c \
+               ${SH_LIBSRC}/pathphys.c ${SH_LIBSRC}/stringlist.c \
+               ${SH_LIBSRC}/stringvec.c ${SH_LIBSRC}/tmpfile.c \
+               ${SH_LIBSRC}/spell.c ${SH_LIBSRC}/strtrans.c \
+               ${SH_LIBSRC}/strindex.c ${SH_LIBSRC}/shquote.c \
+               ${SH_LIBSRC}/snprintf.c ${SH_LIBSRC}/mailstat.c \
+               ${SH_LIBSRC}/fmtulong.c ${SH_LIBSRC}/fmtullong.c \
+               ${SH_LIBSRC}/strtoll.c ${SH_LIBSRC}/strtoull.c \
+               ${SH_LIBSRC}/strtoimax.c ${SH_LIBSRC}/strtoumax.c \
+               ${SH_LIBSRC}/fmtumax.c ${SH_LIBSRC}/netconn.c \
+               ${SH_LIBSRC}/mktime.c ${SH_LIBSRC}/strftime.c \
+               ${SH_LIBSRC}/memset.c ${SH_LIBSRC}/xstrchr.c \
+               ${SH_LIBSRC}/zcatfd.c ${SH_LIBSRC}/shmatch.c \
+               ${SH_LIBSRC}/strnlen.c ${SH_LIBSRC}/winsize.c \
+               ${SH_LIBSRC}/eaccess.c ${SH_LIBSRC}/wcsdup.c \
+               ${SH_LIBSRC}/zmapfd.c
+
+SHLIB_LIB = -lsh
+SHLIB_LIBNAME = libsh.a
+SHLIB_LIBRARY = ${SH_LIBDIR}/${SHLIB_LIBNAME}
+SHLIB_LDFLAGS = -L${SH_LIBDIR}
+SHLIB_DEP = ${SHLIB_LIBRARY}
+
+# we assume for now that readline source is being shipped with bash
+RL_LIBSRC = $(LIBSRC)/readline
+RL_LIBDOC = $(RL_LIBSRC)/doc
+RL_LIBDIR = @RL_LIBDIR@
+RL_ABSSRC = ${topdir}/$(RL_LIBDIR)
+
+RL_INCLUDEDIR = @RL_INCLUDEDIR@
+
+READLINE_LIB = @READLINE_LIB@
+READLINE_LIBRARY = $(RL_LIBDIR)/libreadline.a
+READLINE_LDFLAGS = -L${RL_LIBDIR}
+READLINE_DEP = @READLINE_DEP@
+
+# The source, object and documentation of the GNU Readline library.
+READLINE_SOURCE        = $(RL_LIBSRC)/rldefs.h $(RL_LIBSRC)/rlconf.h \
+                 $(RL_LIBSRC)/readline.h $(RL_LIBSRC)/tcap.h \
+                 $(RL_LIBSRC)/chardefs.h $(RL_LIBSRC)/keymaps.h \
+                 $(RL_LIBSRC)/history.h $(RL_LIBSRC)/histlib.h \
+                 $(RL_LIBSRC)/posixstat.h $(RL_LIBSRC)/tilde.h \
+                 $(RL_LIBSRC)/rlstdc.h ${RL_LIBSRC}/xmalloc.h \
+                 $(RL_LIBSRC)/rlshell.h ${RL_LIBSRC}/rlprivate.h \
+                 $(RL_LIBSRC)/funmap.c $(RL_LIBSRC)/emacs_keymap.c \
+                 $(RL_LIBSRC)/search.c $(RL_LIBSRC)/vi_keymap.c \
+                 $(RL_LIBSRC)/keymaps.c $(RL_LIBSRC)/parens.c \
+                 $(RL_LIBSRC)/vi_mode.c $(RL_LIBSRC)/callback.c \
+                 $(RL_LIBSRC)/readline.c $(RL_LIBSRC)/tilde.c \
+                 $(RL_LIBSRC)/rltty.c $(RL_LIBSRC)/complete.c \
+                 $(RL_LIBSRC)/bind.c $(RL_LIBSRC)/isearch.c \
+                 $(RL_LIBSRC)/display.c $(RL_LIBSRC)/signals.c \
+                 $(RL_LIBSRC)/util.c $(RL_LIBSRC)/kill.c $(RL_LIBSRC)/text.c \
+                 $(RL_LIBSRC)/undo.c $(RL_LIBSRC)/macro.c \
+                 $(RL_LIBSRC)/terminal.c $(RL_LIBSRC)/nls.c \
+                 $(RL_LIBSRC)/input.c $(RL_LIBSRC)/xmalloc.c \
+                 $(RL_LIBSRC)/shell.c $(RL_LIBSRC)/savestring.c \
+                 $(RL_LIBSRC)/misc.c $(RL_LIBSRC)/mbutil.c $(RL_LIBSRC)/compat.c \
+                 $(RL_LIBSRC)/histexpand.c $(RL_LIBSRC)/history.c \
+                 $(RL_LIBSRC)/histsearch.c $(RL_LIBSRC)/histfile.c
+
+READLINE_OBJ   = $(RL_LIBDIR)/readline.o $(RL_LIBDIR)/funmap.o \
+                 $(RL_LIBDIR)/parens.o $(RL_LIBDIR)/search.o \
+                 $(RL_LIBDIR)/keymaps.o $(RL_LIBDIR)/xmalloc.o \
+                 $(RL_LIBDIR)/rltty.o $(RL_LIBDIR)/complete.o \
+                 $(RL_LIBDIR)/bind.o $(RL_LIBDIR)/isearch.o \
+                 $(RL_LIBDIR)/display.o $(RL_LIBDIR)/signals.o \
+                 $(RL_LIBDIR)/tilde.o $(RL_LIBDIR)/util.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)/savestring.o \
+                 $(RL_LIBDIR)/mbutil.o $(RL_LIBDIR)/compat.o \
+                 $(RL_LIBDIR)/history.o $(RL_LIBDIR)/histexpand.o \
+                 $(RL_LIBDIR)/histsearch.o $(RL_LIBDIR)/histfile.o
+
+HIST_LIBSRC = $(LIBSRC)/readline
+HIST_LIBDIR = @HIST_LIBDIR@
+HIST_ABSSRC = ${topdir}/$(HIST_LIBDIR)
+
+HISTORY_LIB = @HISTORY_LIB@
+HISTORY_LIBRARY = $(HIST_LIBDIR)/libhistory.a
+HISTORY_LDFLAGS = -L$(HIST_LIBDIR)
+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)/shell.o
+
+# You only need termcap (or curses) if you are linking with GNU Readline.
+TERM_LIBSRC = $(LIBSRC)/termcap
+TERM_LIBDIR = $(dot)/$(LIBSUBDIR)/termcap
+TERM_ABSSRC = ${topdir}/$(TERM_LIBDIR)
+
+TERMCAP_LIB = @TERMCAP_LIB@
+TERMCAP_LIBRARY = $(TERM_LIBDIR)/libtermcap.a
+TERMCAP_LDFLAGS = -L$(TERM_LIBDIR)
+TERMCAP_DEP = @TERMCAP_DEP@
+
+TERMCAP_SOURCE = $(TERM_LIBSRC)/termcap.c $(TERM_LIBSRC)/tparam.c
+TERMCAP_OBJ    = $(TERM_LIBDIR)/termcap.o $(TERM_LIBDIR)/tparam.o
+
+GLOB_LIBSRC = $(LIBSRC)/glob
+GLOB_LIBDIR = $(dot)/$(LIBSUBDIR)/glob
+GLOB_ABSSRC = ${topdir}/$(GLOB_LIBDIR)
+
+GLOB_LIB     = -lglob
+GLOB_LIBRARY = $(GLOB_LIBDIR)/libglob.a
+GLOB_LDFLAGS = -L$(GLOB_LIBDIR)
+GLOB_DEP = $(GLOB_LIBRARY)
+
+GLOB_SOURCE = $(GLOB_LIBSRC)/glob.c $(GLOB_LIBSRC)/strmatch.c \
+             $(GLOB_LIBSRC)/smatch.c $(GLOB_LIBSRC)/xmbsrtowcs.c \
+             $(GLOB_LIBSRC)/glob_loop.c $(GLOB_LIBSRC)/sm_loop.c \
+             $(GLOB_LIBSRC)/glob.h $(GLOB_LIBSRC)/strmatch.h
+GLOB_OBJ    = $(GLOB_LIBDIR)/glob.o $(GLOB_LIBDIR)/strmatch.o \
+             $(GLOB_LIBDIR)/smatch.o $(GLOB_LIBDIR)/xmbsrtowcs.o
+
+# The source, object and documentation for the GNU Tilde library.
+TILDE_LIBSRC = $(LIBSRC)/tilde
+TILDE_LIBDIR = $(dot)/$(LIBSUBDIR)/tilde
+TILDE_ABSSRC = ${topdir}/$(TILDE_LIBDIR)
+
+TILDE_LIB = @TILDE_LIB@
+TILDE_LIBRARY = $(TILDE_LIBDIR)/libtilde.a
+TILDE_LDFLAGS = -L$(TILDE_LIBDIR)
+TILDE_DEP = $(TILDE_LIBRARY)
+
+TILDE_SOURCE   = $(TILDE_LIBSRC)/tilde.c $(TILDE_LIBSRC)/tilde.h
+TILDE_OBJ      = $(TILDE_LIBDIR)/tilde.o
+
+# libintl
+INTL_LIBSRC = $(LIBSRC)/intl
+INTL_LIBDIR = $(dot)/$(LIBSUBDIR)/intl
+INTL_ABSSRC = ${topdir}/$(INTL_LIB)
+INTL_BUILDDIR = ${LIBBUILD}/intl
+
+INTL_LIB     = @LIBINTL@
+INTL_LIBRARY = $(INTL_LIBDIR)/libintl.a
+INTL_DEP = @INTL_DEP@
+INTL_INC = @INTL_INC@
+
+LIBINTL_H = @LIBINTL_H@
+
+# tests
+LIBINTL = @LIBINTL@
+LTLIBINTL = @LTLIBINTL@
+INTLLIBS = @INTLLIBS@
+INTLOBJS = @INTLOBJS@
+
+# 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)
+
+MALLOC_SRC = @MALLOC_SRC@
+MALLOC_OTHERSRC = ${ALLOC_LIBSRC}/trace.c ${ALLOC_LIBSRC}/stats.c \
+                 ${ALLOC_LIBSRC}/table.c ${ALLOC_LIBSRC}/watch.c
+MALLOC_SOURCE = ${ALLOC_LIBSRC}/${MALLOC_SRC} ${MALLOC_OTHERSRC}
+MALLOC_CFLAGS = -DRCHECK -Dbotch=programming_error ${MALLOC_DEBUG}
+
+MALLOC_LIB     = @MALLOC_LIB@
+MALLOC_LIBRARY = @MALLOC_LIBRARY@
+MALLOC_LDFLAGS = @MALLOC_LDFLAGS@
+MALLOC_DEP = @MALLOC_DEP@
+
+ALLOC_HEADERS = $(ALLOC_LIBSRC)/getpagesize.h $(ALLOC_LIBSRC)/shmalloc.h \
+               $(ALLOC_LIBSRC)/imalloc.h $(ALLOC_LIBSRC)/mstats.h \
+               $(ALLOC_LIBSRC)/table.h $(ALLOC_LIBSRC)/watch.h
+
+$(MALLOC_LIBRARY):     ${MALLOC_SOURCE} ${ALLOC_HEADERS} config.h
+               @(cd $(ALLOC_LIBDIR) && \
+                $(MAKE) $(MFLAGS) \
+                MALLOC_CFLAGS="$(MALLOC_CFLAGS)" ${MALLOC_TARGET} ) || exit 1
+
+BASHINCDIR = ${srcdir}/include
+BASHINCFILES =  $(BASHINCDIR)/posixstat.h $(BASHINCDIR)/ansi_stdlib.h \
+                $(BASHINCDIR)/filecntl.h $(BASHINCDIR)/posixdir.h \
+                $(BASHINCDIR)/memalloc.h $(BASHINCDIR)/stdc.h \
+                $(BASHINCDIR)/posixjmp.h $(BASHINCDIR)/posixwait.h \
+                $(BASHINCDIR)/posixtime.h $(BASHINCDIR)/systimes.h \
+                $(BASHINCDIR)/unionwait.h $(BASHINCDIR)/maxpath.h \
+                $(BASHINCDIR)/shtty.h $(BASHINCDIR)/typemax.h \
+                $(BASHINCDIR)/ocache.h
+
+LIBRARIES = $(SHLIB_LIB) $(READLINE_LIB) $(HISTORY_LIB) $(TERMCAP_LIB) $(GLOB_LIB) \
+           $(TILDE_LIB) $(MALLOC_LIB) $(INTL_LIB) $(LOCAL_LIBS)
+
+LIBDEP = $(SHLIB_DEP) $(INTL_DEP) $(READLINE_DEP) $(HISTORY_DEP) $(TERMCAP_DEP) $(GLOB_DEP) \
+        $(TILDE_DEP) $(MALLOC_DEP)
+
+LIBRARY_LDFLAGS = $(READLINE_LDFLAGS) $(HISTORY_LDFLAGS) $(GLOB_LDFLAGS) \
+                 $(TILDE_LDFLAGS) $(MALLOC_LDFLAGS) $(SHLIB_LDFLAGS)
+
+#
+# The shell itself
+#
+
+# 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 hashcmd.c hashlib.c mailcheck.c \
+          test.c trap.c alias.c jobs.c nojobs.c $(ALLOC_FILES) braces.c \
+          input.c bashhist.c array.c arrayfunc.c sig.c pathexp.c \
+          unwind_prot.c siglist.c bashline.c bracecomp.c error.c \
+          list.c stringlib.c locale.c findcmd.c redir.c \
+          pcomplete.c pcomplib.c syntax.c xmalloc.c
+
+HSOURCES = shell.h flags.h trap.h hashcmd.h hashlib.h jobs.h builtins.h \
+          general.h variables.h config.h $(ALLOC_HEADERS) alias.h \
+          quit.h unwind_prot.h syntax.h ${GRAM_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 arrayfunc.h sig.h mailcheck.h bashintl.h bashjmp.h \
+          execute_cmd.h parser.h pathexp.h pathnames.h pcomplete.h \
+          $(BASHINCFILES)
+
+SOURCES         = $(CSOURCES) $(HSOURCES) $(BUILTIN_DEFS)
+
+# header files chosen based on running of configure
+SIGNAMES_H = @SIGNAMES_H@
+
+# object files chosen based on running of configure
+JOBS_O = @JOBS_O@
+SIGLIST_O = @SIGLIST_O@
+SIGNAMES_O = @SIGNAMES_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 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 arrayfunc.o braces.o bracecomp.o bashhist.o \
+          bashline.o $(SIGLIST_O) list.o stringlib.o locale.o findcmd.o redir.o \
+          pcomplete.o pcomplib.o syntax.o xmalloc.o $(SIGNAMES_O)
+
+# Where the source code of the shell builtins resides.
+BUILTIN_SRCDIR=$(srcdir)/builtins
+DEFSRC=$(BUILTIN_SRCDIR)
+BUILTIN_ABSSRC=${topdir}/builtins
+DEFDIR = $(dot)/builtins
+DEBUGGER_DIR = $(dot)/debugger
+
+BUILTIN_DEFS = $(DEFSRC)/alias.def $(DEFSRC)/bind.def $(DEFSRC)/break.def \
+              $(DEFSRC)/builtin.def $(DEFSRC)/cd.def $(DEFSRC)/colon.def \
+              $(DEFSRC)/command.def ${DEFSRC}/complete.def \
+              $(DEFSRC)/caller.def $(DEFSRC)/declare.def \
+              $(DEFSRC)/echo.def $(DEFSRC)/enable.def $(DEFSRC)/eval.def \
+              $(DEFSRC)/exec.def $(DEFSRC)/exit.def $(DEFSRC)/fc.def \
+              $(DEFSRC)/fg_bg.def $(DEFSRC)/hash.def $(DEFSRC)/help.def \
+              $(DEFSRC)/history.def $(DEFSRC)/jobs.def $(DEFSRC)/kill.def \
+              $(DEFSRC)/let.def $(DEFSRC)/read.def $(DEFSRC)/return.def \
+              $(DEFSRC)/set.def $(DEFSRC)/setattr.def $(DEFSRC)/shift.def \
+              $(DEFSRC)/source.def $(DEFSRC)/suspend.def $(DEFSRC)/test.def \
+              $(DEFSRC)/times.def $(DEFSRC)/trap.def $(DEFSRC)/type.def \
+              $(DEFSRC)/ulimit.def $(DEFSRC)/umask.def $(DEFSRC)/wait.def \
+              $(DEFSRC)/getopts.def $(DEFSRC)/reserved.def \
+              $(DEFSRC)/pushd.def $(DEFSRC)/shopt.def $(DEFSRC)/printf.def
+BUILTIN_C_SRC  = $(DEFSRC)/mkbuiltins.c $(DEFSRC)/common.c \
+                $(DEFSRC)/evalstring.c $(DEFSRC)/evalfile.c \
+                $(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 \
+              $(DEFDIR)/builtin.o $(DEFDIR)/cd.o $(DEFDIR)/colon.o \
+              $(DEFDIR)/command.o $(DEFDIR)/caller.o $(DEFDIR)/declare.o \
+              $(DEFDIR)/echo.o $(DEFDIR)/enable.o $(DEFDIR)/eval.o \
+              $(DEFDIR)/exec.o $(DEFDIR)/exit.o $(DEFDIR)/fc.o \
+              $(DEFDIR)/fg_bg.o $(DEFDIR)/hash.o $(DEFDIR)/help.o \
+              $(DEFDIR)/history.o $(DEFDIR)/jobs.o $(DEFDIR)/kill.o \
+              $(DEFDIR)/let.o $(DEFDIR)/pushd.o $(DEFDIR)/read.o \
+              $(DEFDIR)/return.o $(DEFDIR)/shopt.o $(DEFDIR)/printf.o \
+              $(DEFDIR)/set.o $(DEFDIR)/setattr.o $(DEFDIR)/shift.o \
+              $(DEFDIR)/source.o $(DEFDIR)/suspend.o $(DEFDIR)/test.o \
+              $(DEFDIR)/times.o $(DEFDIR)/trap.o $(DEFDIR)/type.o \
+              $(DEFDIR)/ulimit.o $(DEFDIR)/umask.o $(DEFDIR)/wait.o \
+              $(DEFDIR)/getopts.o $(BUILTIN_C_OBJ)
+GETOPT_SOURCE   = $(DEFSRC)/getopt.c $(DEFSRC)/getopt.h
+PSIZE_SOURCE   = $(DEFSRC)/psize.sh $(DEFSRC)/psize.c
+
+BUILTINS_LIBRARY = $(DEFDIR)/libbuiltins.a
+BUILTINS_LIB = -lbuiltins
+BUILTINS_LDFLAGS = -L$(DEFDIR)
+BUILTINS_DEP = $(BUILTINS_LIBRARY)
+
+# Documentation for the shell.
+DOCSRC = $(srcdir)/doc
+DOCDIR = $(dot)/doc
+
+# Translations and other i18n support files
+PO_SRC = $(srcdir)/po/
+PO_DIR = $(dot)/po/
+
+SIGNAMES_SUPPORT = $(SUPPORT_SRC)mksignames.c
+
+SUPPORT_SRC = $(srcdir)/support/
+SDIR = $(dot)/support/
+
+TESTS_SUPPORT = recho$(EXEEXT) zecho$(EXEEXT) printenv$(EXEEXT)
+CREATED_SUPPORT = signames.h recho$(EXEEXT) zecho$(EXEEXT) printenv$(EXEEXT) \
+                 tests/recho$(EXEEXT) tests/zecho$(EXEEXT) \
+                 tests/printenv$(EXEEXT) mksignames$(EXEEXT) lsignames.h \
+                 mksyntax${EXEEXT} syntax.c $(VERSPROG) $(VERSOBJ) \
+                 buildversion.o mksignames.o signames.o buildsignames.o
+CREATED_CONFIGURE = config.h config.cache config.status config.log \
+                   stamp-h po/POTFILES
+CREATED_MAKEFILES = Makefile builtins/Makefile doc/Makefile \
+                   lib/readline/Makefile lib/glob/Makefile \
+                   lib/sh/Makefile lib/tilde/Makefile lib/malloc/Makefile \
+                   lib/termcap/Makefile examples/loadables/Makefile \
+                   examples/loadables/perl/Makefile support/Makefile \
+                   lib/intl/Makefile po/Makefile po/Makefile.in
+
+# Keep GNU Make from exporting the entire environment for small machines.
+.NOEXPORT:
+
+.made: $(Program) bashbug
+       @echo "$(Program) last made for a $(Machine) running $(OS)" >.made
+
+$(Program):  .build $(OBJECTS) $(BUILTINS_DEP) $(LIBDEP)
+       $(RM) $@
+       $(PURIFY) $(CC) $(BUILTINS_LDFLAGS) $(LIBRARY_LDFLAGS) $(LDFLAGS) -o $(Program) $(OBJECTS) $(LIBS)
+       ls -l $(Program)
+       -$(SIZE) $(Program)
+
+.build:        $(SOURCES) config.h Makefile version.h $(VERSPROG)
+       @echo
+       @echo "   ***********************************************************"
+       @echo "   *                                                         *"
+       @echo "   * `$(BUILD_DIR)/$(VERSPROG) -l`"
+       @echo "   *                                                         *"
+       @echo "   ***********************************************************"
+       @echo
+
+bashbug: $(SUPPORT_SRC)bashbug.sh config.h Makefile $(VERSPROG)
+       @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
+
+strip: $(Program) .made
+       strip $(Program)
+       ls -l $(Program)
+       -$(SIZE) $(Program)
+
+lint:
+       ${MAKE} ${MFLAGS} CFLAGS='${GCC_LINT_FLAGS}' .made
+
+version.h:  $(SOURCES) config.h Makefile 
+       $(SHELL) $(SUPPORT_SRC)mkversion.sh -b -S ${topdir} -s $(RELSTATUS) -d $(Version) -o newversion.h \
+               && mv newversion.h version.h
+
+bashversion$(EXEEXT):  patchlevel.h conftypes.h version.h buildversion.o $(SUPPORT_SRC)bashversion.c
+       $(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) -o $@ $(SUPPORT_SRC)bashversion.c buildversion.o ${LIBS_FOR_BUILD}
+
+buildversion.o: version.h conftypes.h patchlevel.h $(srcdir)/version.c
+       $(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) -DBUILDTOOL -c -o $@ $(srcdir)/version.c
+
+# old rules
+GRAM_H = parser-built
+y.tab.o: y.tab.c ${GRAM_H} command.h ${BASHINCDIR}/stdc.h input.h
+${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
+       touch parser-built
+#      -if cmp -s old-y.tab.h y.tab.h; then mv old-y.tab.h y.tab.h; else cp -p y.tab.h ${GRAM_H}; fi
+
+# experimental new rules - work with GNU make but not BSD (or OSF) make
+#y.tab.o: y.tab.c y.tab.h
+#y.tab.c y.tab.h: parse.y command.h ${BASHINCDIR}/stdc.h input.h
+#      -if test -f y.tab.h; then mv -f y.tab.h old-y.tab.h; fi
+#      $(YACC) -d $(srcdir)/parse.y
+#      -if cmp -s old-y.tab.h y.tab.h; then mv old-y.tab.h y.tab.h; fi
+
+$(READLINE_LIBRARY): config.h $(READLINE_SOURCE)
+       @echo making $@ in ${RL_LIBDIR}
+       @( { test "${RL_LIBDIR}" = "${libdir}" && exit 0; } || \
+               cd ${RL_LIBDIR} && $(MAKE) $(MFLAGS) libreadline.a) || exit 1
+
+$(HISTORY_LIBRARY): config.h $(HISTORY_SOURCE)
+       @echo making $@ in ${HIST_LIBDIR}
+       @( { test "${HIST_LIBDIR}" = "${libdir}" && exit 0; } || \
+               cd ${HIST_LIBDIR} && $(MAKE) $(MFLAGS) libhistory.a) || exit 1
+
+$(GLOB_LIBRARY): config.h $(GLOB_SOURCE)
+       @echo making $@ in ${GLOB_LIBDIR}
+       @(cd ${GLOB_LIBDIR} && \
+               $(MAKE) $(MFLAGS) DEBUG=${DEBUG} libglob.a) || exit 1
+
+$(TILDE_LIBRARY): config.h $(TILDE_SOURCE)
+       @echo making $@ in ${TILDE_LIBDIR}
+       @(cd ${TILDE_LIBDIR} && \
+               $(MAKE) $(MFLAGS) libtilde.a) || exit 1
+
+$(TERMCAP_LIBRARY): config.h ${TERMCAP_SOURCE}
+       @echo making $@ in ${TERM_LIBDIR}       
+       @(cd ${TERM_LIBDIR} && \
+               $(MAKE) $(MFLAGS) libtermcap.a) || exit 1
+
+$(SHLIB_LIBRARY): config.h ${SHLIB_SOURCE}
+       @echo making $@ in ${SH_LIBDIR}
+       @(cd ${SH_LIBDIR} && \
+               $(MAKE) $(MFLAGS) DEBUG=${DEBUG} ${SHLIB_LIBNAME}) || exit 1
+
+${INTL_LIBRARY}: config.h ${INTL_LIBDIR}/Makefile
+       @echo making $@ in ${INTL_LIBDIR}
+       @(cd ${INTL_LIBDIR} && \
+               $(MAKE) $(MFLAGS) all) || exit 1
+
+${LIBINTL_H}:  ${INTL_LIBRARY}
+
+signames.o: $(SUPPORT_SRC)signames.c
+       $(RM) $@
+       $(CC) $(CCFLAGS) -c $(SUPPORT_SRC)signames.c
+
+buildsignames.o:       $(SUPPORT_SRC)signames.c
+       $(RM) $@
+       $(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) -DBUILDTOOL -o $@ -c $(SUPPORT_SRC)signames.c
+
+mksignames.o:  $(SUPPORT_SRC)mksignames.c
+       $(RM) $@
+       $(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) -DBUILDTOOL -c $(SUPPORT_SRC)mksignames.c
+
+mksignames$(EXEEXT):   mksignames.o buildsignames.o
+       $(RM) $@
+       $(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) -o $@ mksignames.o buildsignames.o ${LIBS_FOR_BUILD}
+
+mksyntax$(EXEEXT):     ${srcdir}/mksyntax.c config.h syntax.h ${BASHINCDIR}/chartypes.h
+       $(RM) $@
+       ${CC_FOR_BUILD} ${CCFLAGS_FOR_BUILD} -o $@ ${srcdir}/mksyntax.c ${LIBS_FOR_BUILD}
+
+# make a list of signals for the local system -- this is done when we're
+# *not* cross-compiling
+lsignames.h:   mksignames$(EXEEXT)
+       $(RM) $@
+       ./mksignames$(EXEEXT) $@
+
+# copy the correct signames header file to signames.h
+signames.h: $(SIGNAMES_H)
+       -if cmp -s $(SIGNAMES_H) $@ ; then :; else $(RM) $@ ; $(CP) $(SIGNAMES_H) $@ ; fi
+
+syntax.c:      mksyntax${EXEEXT} $(srcdir)/syntax.h 
+       $(RM) $@
+       ./mksyntax$(EXEEXT) -o $@
+
+$(BUILTINS_LIBRARY): $(BUILTIN_DEFS) $(BUILTIN_C_SRC) config.h ${BASHINCDIR}/memalloc.h version.h
+       @(cd $(DEFDIR) && $(MAKE) $(MFLAGS) DEBUG=${DEBUG} libbuiltins.a ) || exit 1
+
+# these require special rules to circumvent make builtin rules
+${DEFDIR}/common.o:    $(BUILTIN_SRCDIR)/common.c
+       @(cd $(DEFDIR) && $(MAKE) $(MFLAGS) DEBUG=${DEBUG} common.o) || exit 1
+
+${DEFDIR}/bashgetopt.o:        $(BUILTIN_SRCDIR)/bashgetopt.c
+       @(cd $(DEFDIR) && $(MAKE) $(MFLAGS) DEBUG=${DEBUG} bashgetopt.o) || exit 1
+
+${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 makefile:     config.status $(srcdir)/Makefile.in
+       CONFIG_FILES=Makefile CONFIG_HEADERS= $(SHELL) ./config.status
+
+pathnames.h:           config.status $(srcdir)/Makefile.in
+       CONFIG_HEADERS= $(SHELL) ./config.status
+
+Makefiles makefiles:   config.status $(srcdir)/Makefile.in
+       @for mf in $(CREATED_MAKEFILES); do \
+               CONFIG_FILES=$$mf CONFIG_HEADERS= $(SHELL) ./config.status ; \
+       done
+
+config.h:      stamp-h 
+
+stamp-h:       config.status $(srcdir)/config.h.in $(srcdir)/config-top.h $(srcdir)/config-bot.h
+       CONFIG_FILES= CONFIG_HEADERS=config.h $(SHELL) ./config.status
+
+config.status: $(srcdir)/configure
+       $(SHELL) ./config.status --recheck
+
+# comment out for distribution
+$(srcdir)/configure:   $(srcdir)/configure.in $(srcdir)/aclocal.m4 $(srcdir)/config.h.in
+       cd $(srcdir) && autoconf
+
+# for chet
+reconfig: force
+       sh $(srcdir)/configure -C
+
+#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) )
+
+info dvi ps: force
+       @(cd $(DOCDIR) ; $(MAKE) $(MFLAGS) CFLAGS='$(CCFLAGS)' $@ )
+
+force:
+
+TAGS:  $(SOURCES) $(BUILTIN_C_SRC) $(LIBRARY_SOURCE)
+       etags $(SOURCES) $(BUILTIN_C_SRC) $(LIBRARY_SOURCE)
+
+tags:  $(SOURCES) $(BUILTIN_C_SRC) $(LIBRARY_SOURCE)
+       ctags -x $(SOURCES) $(BUILTIN_C_SRC) $(LIBRARY_SOURCE) > $@
+
+# Targets that actually do things not part of the build
+
+installdirs:
+       @${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(bindir)
+       @${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(man1dir)
+       @${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(infodir)
+       -( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
+
+install:       .made installdirs
+       $(INSTALL_PROGRAM) $(INSTALLMODE) $(Program) $(DESTDIR)$(bindir)/$(Program)
+       $(INSTALL_SCRIPT) $(INSTALLMODE2) bashbug $(DESTDIR)$(bindir)/bashbug
+       -( cd $(DOCDIR) ; $(MAKE) $(MFLAGS) \
+               man1dir=$(man1dir) man1ext=$(man1ext) \
+               man3dir=$(man3dir) man3ext=$(man3ext) \
+               infodir=$(infodir) htmldir=$(htmldir) DESTDIR=$(DESTDIR) $@ )
+       -( cd $(DEFDIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
+       -( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
+
+install-strip:
+       $(MAKE) $(MFLAGS) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' \
+               prefix=${prefix} exec_prefix=${exec_prefix} \
+               DESTDIR=$(DESTDIR) install
+
+uninstall:     .made
+       $(RM) $(DESTDIR)$(bindir)/$(Program) $(DESTDIR)$(bindir)/bashbug
+       -( cd $(DOCDIR) ; $(MAKE) $(MFLAGS) \
+               man1dir=$(man1dir) man1ext=$(man1ext) \
+               man3dir=$(man3dir) man3ext=$(man3ext) \
+               infodir=$(infodir) htmldir=$(htmldir) DESTDIR=$(DESTDIR) $@ )
+       -( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
+
+.PHONY: basic-clean clean realclean maintainer-clean distclean mostlyclean maybe-clean
+
+LIB_SUBDIRS = ${RL_LIBDIR}  ${HIST_LIBDIR} ${TERM_LIBDIR} ${GLOB_LIBDIR} \
+               ${INTL_LIBDIR} ${TILDE_LIBDIR} ${ALLOC_LIBDIR} ${SH_LIBDIR}
+
+basic-clean:
+       $(RM) $(OBJECTS) $(Program) bashbug
+       $(RM) .build .made version.h 
+
+clean: basic-clean
+       ( cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ )
+       ( cd builtins && $(MAKE) $(MFLAGS) $@ )
+       -( cd $(SDIR) && $(MAKE) $(MFLAGS) $@ )
+       -for libdir in ${LIB_SUBDIRS}; do \
+               (cd $$libdir && test -f Makefile && $(MAKE) $(MFLAGS) $@) ;\
+       done
+       -( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
+       $(RM) $(CREATED_SUPPORT)
+
+mostlyclean: basic-clean
+       ( cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ )
+       ( cd builtins && $(MAKE) $(MFLAGS) $@ )
+       -( cd $(SDIR) && $(MAKE) $(MFLAGS) $@ )
+       -for libdir in ${LIB_SUBDIRS}; do \
+               (cd $$libdir && test -f Makefile && $(MAKE) $(MFLAGS) $@) ;\
+       done
+       -( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
+
+distclean:     basic-clean maybe-clean
+       ( cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ )
+       ( cd builtins && $(MAKE) $(MFLAGS) $@ )
+       -( cd $(SDIR) && $(MAKE) $(MFLAGS) $@ )
+       -for libdir in ${LIB_SUBDIRS}; do \
+               (cd $$libdir && test -f Makefile && $(MAKE) $(MFLAGS) $@) ;\
+       done
+       -( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
+       $(RM) $(CREATED_CONFIGURE) tags TAGS 
+       $(RM) $(CREATED_SUPPORT) Makefile $(CREATED_MAKEFILES) pathnames.h
+
+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
+       ( cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ )
+       ( cd builtins && $(MAKE) $(MFLAGS) $@ )
+       ( cd $(SDIR) && $(MAKE) $(MFLAGS) $@ )
+       -for libdir in ${LIB_SUBDIRS}; do \
+               (cd $$libdir && test -f Makefile && $(MAKE) $(MFLAGS) $@) ;\
+       done
+       -( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
+       $(RM) $(CREATED_CONFIGURE) $(CREATED_MAKEFILES)
+       $(RM) $(CREATED_SUPPORT) Makefile pathnames.h
+
+maybe-clean:
+       -if test "X$(topdir)" != "X$(BUILD_DIR)" ; then \
+               $(RM) parser-built y.tab.c y.tab.h ; \
+       fi
+
+recho$(EXEEXT):                $(SUPPORT_SRC)recho.c
+       @$(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) -o $@ $(SUPPORT_SRC)recho.c ${LIBS_FOR_BUILD}
+
+zecho$(EXEEXT):                $(SUPPORT_SRC)zecho.c
+       @$(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) -o $@ $(SUPPORT_SRC)zecho.c ${LIBS_FOR_BUILD}
+
+printenv$(EXEEXT):     $(SUPPORT_SRC)printenv.c
+       @$(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) -o $@ $(SUPPORT_SRC)printenv.c ${LIBS_FOR_BUILD}
+
+test tests check:      force $(Program) $(TESTS_SUPPORT)
+       @-test -d tests || mkdir tests
+       @cp $(TESTS_SUPPORT) tests
+       @( cd $(srcdir)/tests && \
+               PATH=$(BUILD_DIR)/tests:$$PATH THIS_SH=$(THIS_SH) $(SHELL) ${TESTSCRIPT} )
+
+symlinks:
+       $(SHELL) $(SUPPORT_SRC)fixlinks -s $(srcdir)
+
+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 ${PACKAGE} $(PACKAGE_VERSION)
+       @echo tar cf $(PACKAGE)-${PACKAGE_VERSION}.tar ${PACKAGE}-$(PACKAGE_VERSION)
+       @echo gzip $(PACKAGE)-$(PACKAGE_VERSION).tar
+
+depend:        depends
+
+depends: force
+       $(Program) $(SUPPORT_SRC)mkdep -c ${CC} -- ${CCFLAGS} ${CSOURCES}
+
+#### PRIVATE TARGETS ####
+hashtest:      hashlib.c
+       $(CC) -DTEST_HASHING $(CCFLAGS) -o $@ $(srcdir)/hashlib.c
+
+############################ DEPENDENCIES ###############################
+
+# Files that depend on the definitions in config-top.h, which are not meant
+# to be changed
+shell.o: config-top.h
+input.o: config-top.h
+y.tab.o: config-top.h
+jobs.o: config-top.h
+nojobs.o: config-top.h
+execute_cmd.o: config-top.h
+variables.o: config-top.h
+builtins/command.o: config-top.h
+builtins/common.o: config-top.h
+builtins/break.o: config-top.h
+builtins/echo.o: config-top.h
+builtins/evalstring.o: config-top.h
+builtins/exit.o: config-top.h
+builtins/kill.o: config-top.h
+
+# shell basics
+copy_cmd.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+copy_cmd.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+copy_cmd.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+copy_cmd.o: make_cmd.h subst.h sig.h pathnames.h externs.h
+dispose_cmd.o: bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+dispose_cmd.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h
+dispose_cmd.o: error.h general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+dispose_cmd.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+dispose_cmd.o: make_cmd.h subst.h sig.h pathnames.h externs.h
+dispose_cmd.o: ${BASHINCDIR}/ocache.h
+error.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h flags.h ${BASHINCDIR}/stdc.h error.h
+error.o: command.h general.h xmalloc.h externs.h input.h bashhist.h
+error.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+error.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+error.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+error.o: make_cmd.h subst.h sig.h pathnames.h externs.h
+error.o: input.h execute_cmd.h 
+eval.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h trap.h flags.h ${DEFSRC}/common.h
+eval.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+eval.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+eval.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+eval.o: make_cmd.h subst.h sig.h pathnames.h externs.h
+eval.o: input.h execute_cmd.h 
+execute_cmd.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+execute_cmd.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+execute_cmd.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+execute_cmd.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+execute_cmd.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+execute_cmd.o: ${BASHINCDIR}/memalloc.h ${GRAM_H} flags.h builtins.h jobs.h quit.h siglist.h
+execute_cmd.o: execute_cmd.h findcmd.h redir.h trap.h test.h pathexp.h
+execute_cmd.o: $(DEFSRC)/common.h ${DEFDIR}/builtext.h ${GLOB_LIBSRC}/strmatch.h
+execute_cmd.o: ${BASHINCDIR}/posixtime.h ${BASHINCDIR}/chartypes.h
+expr.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h 
+expr.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+expr.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+expr.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+expr.o: make_cmd.h subst.h sig.h pathnames.h externs.h
+expr.o: ${BASHINCDIR}/chartypes.h
+findcmd.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h ${BASHINCDIR}/posixstat.h bashansi.h
+findcmd.o: ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/memalloc.h shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h
+findcmd.o: ${BASHINCDIR}/stdc.h error.h general.h xmalloc.h variables.h arrayfunc.h conftypes.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h
+findcmd.o: dispose_cmd.h make_cmd.h subst.h sig.h pathnames.h externs.h
+findcmd.o: flags.h hashlib.h pathexp.h hashcmd.h 
+findcmd.o: ${BASHINCDIR}/chartypes.h
+flags.o: config.h flags.h 
+flags.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+flags.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+flags.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+flags.o: make_cmd.h subst.h sig.h pathnames.h externs.h bashhist.h
+general.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h ${BASHINCDIR}/filecntl.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+general.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+general.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+general.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+general.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+general.o: ${BASHINCDIR}/maxpath.h ${BASHINCDIR}/posixtime.h
+general.o: ${BASHINCDIR}/chartypes.h
+hashcmd.o: config.h ${BASHINCDIR}/posixstat.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+hashcmd.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+hashcmd.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashcmd.h
+hashcmd.o: execute_cmd.h findcmd.h ${BASHINCDIR}/stdc.h hashlib.h
+hashlib.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+hashlib.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+hashlib.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+hashlib.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+hashlib.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+input.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+input.o: command.h ${BASHINCDIR}/stdc.h general.h xmalloc.h input.h error.h externs.h
+list.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+list.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+list.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+list.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+locale.o: config.h bashtypes.h bashintl.h ${LIBINTL_H} bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+locale.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+locale.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+locale.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+locale.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+locale.o: ${BASHINCDIR}/chartypes.h
+mailcheck.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+mailcheck.o: ${BASHINCDIR}/posixtime.h
+mailcheck.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+mailcheck.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+mailcheck.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+mailcheck.o: make_cmd.h subst.h sig.h pathnames.h externs.h
+mailcheck.o: execute_cmd.h mailcheck.h 
+make_cmd.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h bashansi.h
+make_cmd.o: command.h ${BASHINCDIR}/stdc.h general.h xmalloc.h error.h flags.h make_cmd.h
+make_cmd.o: variables.h arrayfunc.h conftypes.h array.h hashlib.h subst.h input.h externs.h
+make_cmd.o: jobs.h quit.h siglist.h syntax.h dispose_cmd.h
+make_cmd.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/ocache.h
+y.tab.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/memalloc.h
+y.tab.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+y.tab.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+y.tab.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+y.tab.o: make_cmd.h subst.h sig.h pathnames.h externs.h test.h
+y.tab.o: trap.h flags.h parser.h input.h mailcheck.h $(DEFSRC)/common.h
+y.tab.o: $(DEFDIR)/builtext.h bashline.h bashhist.h jobs.h siglist.h alias.h
+pathexp.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+pathexp.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+pathexp.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+pathexp.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+pathexp.o: make_cmd.h subst.h sig.h pathnames.h externs.h
+pathexp.o: pathexp.h flags.h 
+pathexp.o: $(GLOB_LIBSRC)/glob.h $(GLOB_LIBSRC)/strmatch.h
+pathexp.o: ${BASHINCDIR}/shmbutil.h
+print_cmd.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+print_cmd.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+print_cmd.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+print_cmd.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+print_cmd.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+print_cmd.o: ${GRAM_H} $(DEFSRC)/common.h
+redir.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/filecntl.h
+redir.o: ${BASHINCDIR}/memalloc.h shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+redir.o: general.h xmalloc.h variables.h arrayfunc.h conftypes.h array.h hashlib.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h
+redir.o: dispose_cmd.h make_cmd.h subst.h sig.h pathnames.h externs.h 
+redir.o: flags.h execute_cmd.h redir.h input.h
+shell.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/filecntl.h
+shell.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+shell.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+shell.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+shell.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+shell.o: flags.h trap.h mailcheck.h builtins.h $(DEFSRC)/common.h
+shell.o: jobs.h siglist.h input.h execute_cmd.h findcmd.h bashhist.h
+shell.o: ${GLOB_LIBSRC}/strmatch.h ${BASHINCDIR}/posixtime.h
+sig.o: config.h bashtypes.h
+sig.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+sig.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+sig.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+sig.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+sig.o: jobs.h siglist.h trap.h $(DEFSRC)/common.h bashline.h bashhist.h
+siglist.o: config.h bashtypes.h siglist.h trap.h
+stringlib.o: bashtypes.h ${BASHINCDIR}/chartypes.h
+stringlib.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+stringlib.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+stringlib.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+stringlib.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+stringlib.o: ${GLOB_LIBSRC}/glob.h ${GLOB_LIBSRC}/strmatch.h
+subst.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/posixstat.h
+subst.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+subst.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+subst.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+subst.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+subst.o: flags.h jobs.h siglist.h execute_cmd.h ${BASHINCDIR}/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}/strmatch.h
+subst.o: ${BASHINCDIR}/chartypes.h
+subst.o: ${BASHINCDIR}/shmbutil.h
+test.o: bashtypes.h ${BASHINCDIR}/posixstat.h ${BASHINCDIR}/filecntl.h
+test.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+test.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+test.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+test.o: make_cmd.h subst.h sig.h pathnames.h externs.h test.h
+test.o: ${DEFSRC}/common.h 
+trap.o: config.h bashtypes.h trap.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+trap.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+trap.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+trap.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+trap.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+trap.o: signames.h $(DEFSRC)/common.h
+trap.o: ${DEFDIR}/builtext.h
+unwind_prot.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h command.h ${BASHINCDIR}/stdc.h
+unwind_prot.o: general.h xmalloc.h unwind_prot.h quit.h sig.h
+variables.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+variables.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+variables.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+variables.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+variables.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+variables.o: flags.h execute_cmd.h mailcheck.h input.h $(DEFSRC)/common.h
+variables.o: findcmd.h bashhist.h hashcmd.h pathexp.h
+variables.o: pcomplete.h  ${BASHINCDIR}/chartypes.h
+variables.o: ${BASHINCDIR}/posixtime.h
+version.o:  conftypes.h patchlevel.h version.h
+xmalloc.o: config.h bashtypes.h ${BASHINCDIR}/ansi_stdlib.h error.h
+
+# job control
+
+jobs.o: config.h bashtypes.h trap.h ${BASHINCDIR}/filecntl.h input.h ${BASHINCDIR}/shtty.h
+jobs.o: bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+jobs.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+jobs.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+jobs.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+jobs.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+jobs.o: jobs.h flags.h $(DEFSRC)/common.h $(DEFDIR)/builtext.h
+jobs.o: ${BASHINCDIR}/posixwait.h ${BASHINCDIR}/unionwait.h
+jobs.o: ${BASHINCDIR}/posixtime.h
+nojobs.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h bashjmp.h ${BASHINCDIR}/posixjmp.h
+nojobs.o: command.h ${BASHINCDIR}/stdc.h general.h xmalloc.h jobs.h quit.h siglist.h externs.h
+nojobs.o: sig.h error.h ${BASHINCDIR}/shtty.h input.h
+
+# shell features that may be compiled in
+
+array.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+array.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+array.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+array.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+array.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+array.o: $(DEFSRC)/common.h
+arrayfunc.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+arrayfunc.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+arrayfunc.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+arrayfunc.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+arrayfunc.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+arrayfunc.o: $(DEFSRC)/common.h
+arrayfunc.o: ${BASHINCDIR}/shmbutil.h
+braces.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+braces.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+braces.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+braces.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+braces.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+braces.o: ${BASHINCDIR}/shmbutil.h
+alias.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h command.h ${BASHINCDIR}/stdc.h
+alias.o: general.h xmalloc.h bashtypes.h externs.h alias.h
+alias.o: pcomplete.h 
+alias.o: ${BASHINCDIR}/chartypes.h
+
+pcomplib.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h bashtypes.h
+pcomplib.o: ${BASHINCDIR}/stdc.h hashlib.h pcomplete.h shell.h syntax.h
+pcomplib.o: bashjmp.h command.h general.h xmalloc.h error.h variables.h arrayfunc.h conftypes.h quit.h
+pcomplib.o: unwind_prot.h dispose_cmd.h make_cmd.h subst.h sig.h pathnames.h
+pcomplib.o: externs.h ${BASHINCDIR}/maxpath.h
+
+pcomplete.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h bashtypes.h
+pcomplete.o: ${BASHINCDIR}/stdc.h hashlib.h pcomplete.h shell.h syntax.h
+pcomplete.o: bashjmp.h command.h general.h xmalloc.h error.h variables.h arrayfunc.h conftypes.h quit.h
+pcomplete.o: unwind_prot.h dispose_cmd.h make_cmd.h subst.h sig.h pathnames.h
+pcomplete.o: externs.h ${BASHINCDIR}/maxpath.h execute_cmd.h 
+
+# library support files
+
+bashhist.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/posixstat.h
+bashhist.o: ${BASHINCDIR}/filecntl.h
+bashhist.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+bashhist.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+bashhist.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+bashhist.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+bashhist.o: flags.h input.h parser.h pathexp.h $(DEFSRC)/common.h bashline.h
+bashhist.o: $(GLOB_LIBSRC)/strmatch.h
+bashline.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+bashline.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+bashline.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+bashline.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+bashline.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+bashline.o: builtins.h bashhist.h bashline.h execute_cmd.h findcmd.h pathexp.h
+bashline.o: $(DEFSRC)/common.h $(GLOB_LIBSRC)/glob.h alias.h
+bashline.o: pcomplete.h ${BASHINCDIR}/chartypes.h input.h
+bracecomp.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+bracecomp.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+bracecomp.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+bracecomp.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+bracecomp.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+bracecomp.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h command.h hashlib.h builtins.h general.h xmalloc.h
+bracecomp.o: quit.h alias.h config.h  variables.h arrayfunc.h conftypes.h
+bracecomp.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+
+# library dependencies
+
+bashline.o: $(RL_LIBSRC)/rlconf.h
+bashline.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/rlstdc.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 $(RL_LIBSRC)/rlstdc.h
+y.tab.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/chardefs.h
+y.tab.o: $(RL_LIBSRC)/readline.h $(RL_LIBSRC)/rlstdc.h
+subst.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/chardefs.h
+subst.o: $(RL_LIBSRC)/readline.h $(RL_LIBSRC)/rlstdc.h
+
+shell.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h
+subst.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h
+bashline.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h
+bashhist.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h
+y.tab.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h
+
+execute_cmd.o: $(TILDE_LIBSRC)/tilde.h
+general.o: $(TILDE_LIBSRC)/tilde.h
+mailcheck.o: $(TILDE_LIBSRC)/tilde.h
+shell.o: $(TILDE_LIBSRC)/tilde.h
+subst.o: $(TILDE_LIBSRC)/tilde.h
+variables.o: $(TILDE_LIBSRC)/tilde.h
+
+# libintl dependencies
+arrayfunc.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+bashhist.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+bashline.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+braces.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+error.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+eval.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+execute_cmd.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+expr.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+general.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+input.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+jobs.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+mailcheck.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+make_cmd.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+nojobs.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+parse.y: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+pcomplete.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+pcomplib.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+print_cmd.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+redir.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+shell.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+sig.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+siglist.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+subst.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+test.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+trap.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+variables.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+version.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+xmalloc.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+
+signames.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+
+# XXX - dependencies checked through here
+
+# builtin c sources
+builtins/bashgetopt.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+builtins/bashgetopt.o: shell.h syntax.h config.h bashjmp.h command.h general.h xmalloc.h error.h
+builtins/bashgetopt.o: variables.h arrayfunc.h conftypes.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+builtins/bashgetopt.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+builtins/bashgetopt.o: $(DEFSRC)/common.h
+builtins/bashgetopt.o: ${BASHINCDIR}/chartypes.h
+builtins/common.o: bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+builtins/common.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h command.h
+builtins/common.o: ${BASHINCDIR}/memalloc.h variables.h arrayfunc.h conftypes.h input.h siglist.h
+builtins/common.o: quit.h unwind_prot.h ${BASHINCDIR}/maxpath.h jobs.h builtins.h
+builtins/common.o: dispose_cmd.h make_cmd.h subst.h externs.h bashhist.h 
+builtins/common.o: execute_cmd.h ${BASHINCDIR}/stdc.h general.h xmalloc.h error.h pathnames.h
+builtins/common.o: ${DEFDIR}/builtext.h
+builtins/common.o: ${BASHINCDIR}/chartypes.h
+builtins/evalfile.o: bashtypes.h ${BASHINCDIR}/posixstat.h ${BASHINCDIR}/filecntl.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+builtins/evalfile.o: shell.h syntax.h config.h bashjmp.h command.h general.h xmalloc.h error.h
+builtins/evalfile.o: variables.h arrayfunc.h conftypes.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+builtins/evalfile.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+builtins/evalfile.o: jobs.h builtins.h flags.h input.h execute_cmd.h
+builtins/evalfile.o: bashhist.h $(DEFSRC)/common.h
+builtins/evalstring.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+builtins/evalstring.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h command.h siglist.h
+builtins/evalstring.o: ${BASHINCDIR}/memalloc.h variables.h arrayfunc.h conftypes.h input.h
+builtins/evalstring.o: quit.h unwind_prot.h ${BASHINCDIR}/maxpath.h jobs.h builtins.h
+builtins/evalstring.o: dispose_cmd.h make_cmd.h subst.h externs.h 
+builtins/evalstring.o: jobs.h builtins.h flags.h input.h execute_cmd.h
+builtins/evalstring.o: bashhist.h $(DEFSRC)/common.h
+builtins/getopt.o: config.h ${BASHINCDIR}/memalloc.h
+builtins/getopt.o: shell.h syntax.h bashjmp.h command.h general.h xmalloc.h error.h
+builtins/getopt.o: variables.h arrayfunc.h conftypes.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+builtins/getopt.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+builtins/getopt.o: $(DEFSRC)/getopt.h
+builtins/mkbuiltins.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h ${BASHINCDIR}/filecntl.h
+builtins/mkbuiltins.o: bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+
+# builtin def files
+builtins/alias.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/alias.o: quit.h $(DEFSRC)/common.h
+builtins/alias.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h command.h ${BASHINCDIR}/stdc.h unwind_prot.h
+builtins/alias.o: dispose_cmd.h make_cmd.h subst.h externs.h variables.h arrayfunc.h conftypes.h 
+builtins/bind.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/bind.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/bind.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
+builtins/bind.o: $(DEFSRC)/bashgetopt.h
+builtins/break.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/break.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
+builtins/break.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/builtin.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/builtin.o: quit.h $(DEFSRC)/common.h $(DEFSRC)/bashgetopt.h
+builtins/builtin.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h 
+builtins/builtin.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/caller.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/caller.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
+builtins/caller.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/caller.o: $(DEFSRC)/common.h quit.h 
+builtins/caller.o: ${BASHINCDIR}/chartypes.h bashtypes.h
+builtins/caller.o: ${DEFDIR}/builtext.h
+builtins/cd.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/cd.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
+builtins/cd.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/cd.o: $(DEFSRC)/common.h quit.h 
+builtins/command.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/command.o: quit.h $(DEFSRC)/bashgetopt.h
+builtins/command.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h 
+builtins/command.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/declare.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/declare.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
+builtins/declare.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/declare.o: $(DEFSRC)/bashgetopt.h
+builtins/echo.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/echo.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
+builtins/echo.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/enable.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/enable.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
+builtins/enable.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/enable.o: pcomplete.h 
+builtins/eval.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/eval.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h 
+builtins/eval.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/exec.o: bashtypes.h 
+builtins/exec.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/exec.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
+builtins/exec.o: dispose_cmd.h make_cmd.h subst.h externs.h execute_cmd.h 
+builtins/exec.o: findcmd.h flags.h quit.h $(DEFSRC)/common.h ${BASHINCDIR}/stdc.h
+builtins/exit.o: bashtypes.h 
+builtins/exit.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/exit.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
+builtins/exit.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/fc.o: bashtypes.h ${BASHINCDIR}/posixstat.h
+builtins/fc.o: bashansi.h ${BASHINCDIR}/ansi_stdlib.h builtins.h command.h ${BASHINCDIR}/stdc.h 
+builtins/fc.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/fc.o: flags.h unwind_prot.h variables.h arrayfunc.h conftypes.h shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h 
+builtins/fc.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h quit.h 
+builtins/fc.o: $(DEFSRC)/bashgetopt.h bashhist.h
+builtins/fc.o: ${BASHINCDIR}/chartypes.h
+builtins/fg_bg.o: bashtypes.h $(DEFSRC)/bashgetopt.h 
+builtins/fg_bg.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/fg_bg.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
+builtins/fg_bg.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/getopts.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/getopts.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h 
+builtins/getopts.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/hash.o: bashtypes.h 
+builtins/hash.o: builtins.h command.h findcmd.h ${BASHINCDIR}/stdc.h $(DEFSRC)/common.h
+builtins/hash.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/hash.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h 
+builtins/help.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/help.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/help.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
+builtins/help.o: $(GLOB_LIBSRC)/glob.h 
+builtins/history.o: bashtypes.h 
+builtins/history.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/history.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/history.o: ${BASHINCDIR}/filecntl.h shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h
+builtins/history.o: bashhist.h variables.h arrayfunc.h conftypes.h 
+builtins/inlib.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/inlib.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h 
+builtins/inlib.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/jobs.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/jobs.o: quit.h $(DEFSRC)/bashgetopt.h
+builtins/jobs.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h 
+builtins/jobs.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/kill.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/kill.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/kill.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h trap.h unwind_prot.h variables.h arrayfunc.h conftypes.h 
+builtins/let.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/let.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/let.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h 
+builtins/printf.o: config.h ${BASHINCDIR}/memalloc.h bashjmp.h command.h error.h
+builtins/printf.o: general.h xmalloc.h quit.h dispose_cmd.h make_cmd.h subst.h
+builtins/printf.o: externs.h sig.h pathnames.h shell.h syntax.h unwind_prot.h
+builtins/printf.o: variables.h arrayfunc.h conftypes.h ${BASHINCDIR}/stdc.h $(DEFSRC)/bashgetopt.h
+builtins/printf.o: ${BASHINCDIR}/chartypes.h
+builtins/pushd.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/pushd.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/pushd.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
+builtins/pushd.o: $(DEFSRC)/common.h
+builtins/read.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/read.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/read.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h 
+builtins/return.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/return.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/return.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h 
+builtins/set.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/set.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/set.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h flags.h
+builtins/setattr.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/setattr.o: quit.h $(DEFSRC)/common.h $(DEFSRC)/bashgetopt.h
+builtins/setattr.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h 
+builtins/setattr.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/shift.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/shift.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/shift.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h 
+builtins/shift.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/shopt.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h
+builtins/shopt.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h
+builtins/shopt.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h unwind_prot.h variables.h arrayfunc.h conftypes.h ${BASHINCDIR}/maxpath.h
+builtins/shopt.o: $(DEFSRC)/common.h $(DEFSRC)/bashgetopt.h
+builtins/source.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/source.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/source.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
+builtins/source.o: findcmd.h $(DEFSRC)/bashgetopt.h flags.h trap.h
+builtins/suspend.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/suspend.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/suspend.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h 
+builtins/test.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/test.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/test.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h 
+builtins/test.o: test.h 
+builtins/times.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/times.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/times.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h 
+builtins/trap.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/trap.o: quit.h $(DEFSRC)/common.h
+builtins/trap.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h 
+builtins/trap.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/type.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/type.o: quit.h $(DEFSRC)/common.h findcmd.h
+builtins/type.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
+builtins/type.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/ulimit.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/ulimit.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/ulimit.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h 
+builtins/umask.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/umask.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/umask.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h 
+builtins/umask.o: ${BASHINCDIR}/chartypes.h
+builtins/wait.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/wait.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/wait.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
+builtins/wait.o: ${BASHINCDIR}/chartypes.h
+
+builtins/complete.o: config.h shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h
+builtins/complete.o: unwind_prot.h variables.h arrayfunc.h conftypes.h
+builtins/complete.o: bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+builtins/complete.o: builtins.h 
+builtins/complete.o: pcomplete.h
+builtins/complete.o: ${DEFSRC}/common.h ${DEFSRC}/bashgetopt.h
+
+# libintl dependencies
+builtins/bind.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/break.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/caller.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/cd.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/common.c: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/complete.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/declare.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/enable.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/evalfile.c: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/exec.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/exit.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/fc.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/fg_bg.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/getopt.c: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/hash.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/help.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/history.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/inlib.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/jobs.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/kill.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/let.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/mkbuiltins.c: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/printf.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/pushd.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/read.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/return.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/set.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/setattr.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/shift.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/shopt.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/source.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/suspend.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/type.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/ulimit.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/umask.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+
+# builtin library dependencies
+builtins/bind.o: $(RL_LIBSRC)/chardefs.h $(RL_LIBSRC)/readline.h
+builtins/bind.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/rlstdc.h
+
+builtins/bind.o: $(HIST_LIBSRC)/history.h $(RL_LIBSRC)/rlstdc.h
+builtins/fc.o: $(HIST_LIBSRC)/history.h $(RL_LIBSRC)/rlstdc.h
+builtins/history.o: $(HIST_LIBSRC)/history.h $(RL_LIBSRC)/rlstdc.h
+
+builtins/common.o: $(TILDE_LIBSRC)/tilde.h
+builtins/cd.o: $(TILDE_LIBSRC)/tilde.h 
+
+builtins/alias.o: $(DEFSRC)/alias.def
+builtins/bind.o: $(DEFSRC)/bind.def
+builtins/break.o: $(DEFSRC)/break.def
+builtins/builtin.o: $(DEFSRC)/builtin.def
+builtins/caller.o: $(DEFSRC)/caller.def
+builtins/cd.o: $(DEFSRC)/cd.def
+builtins/colon.o: $(DEFSRC)/colon.def
+builtins/command.o: $(DEFSRC)/command.def
+builtins/complete.o: $(DEFSRC)/complete.def
+builtins/declare.o: $(DEFSRC)/declare.def
+builtins/echo.o: $(DEFSRC)/echo.def
+builtins/enable.o: $(DEFSRC)/enable.def
+builtins/eval.o: $(DEFSRC)/eval.def
+builtins/exec.o: $(DEFSRC)/exec.def
+builtins/exit.o: $(DEFSRC)/exit.def
+builtins/fc.o: $(DEFSRC)/fc.def
+builtins/fg_bg.o: $(DEFSRC)/fg_bg.def
+builtins/getopts.o: $(DEFSRC)/getopts.def
+builtins/hash.o: $(DEFSRC)/hash.def
+builtins/help.o: $(DEFSRC)/help.def
+builtins/history.o: $(DEFSRC)/history.def
+builtins/inlib.o: $(DEFSRC)/inlib.def
+builtins/jobs.o: $(DEFSRC)/jobs.def
+builtins/kill.o: $(DEFSRC)/kill.def
+builtins/let.o: $(DEFSRC)/let.def
+builtins/pushd.o: $(DEFSRC)/pushd.def
+builtins/read.o: $(DEFSRC)/read.def
+builtins/reserved.o: $(DEFSRC)/reserved.def
+builtins/return.o: $(DEFSRC)/return.def
+builtins/set.o: $(DEFSRC)/set.def
+builtins/setattr.o: $(DEFSRC)/setattr.def
+builtins/shift.o: $(DEFSRC)/shift.def
+builtins/shopt.o: $(DEFSRC)/shopt.def
+builtins/source.o: $(DEFSRC)/source.def
+builtins/suspend.o: $(DEFSRC)/suspend.def
+builtins/test.o: $(DEFSRC)/test.def
+builtins/times.o: $(DEFSRC)/times.def
+builtins/trap.o: $(DEFSRC)/trap.def
+builtins/type.o: $(DEFSRC)/type.def
+builtins/ulimit.o: $(DEFSRC)/ulimit.def
+builtins/umask.o: $(DEFSRC)/umask.def
+builtins/wait.o: $(DEFSRC)/wait.def
diff --git a/Makefile.in~ b/Makefile.in~
new file mode 100644 (file)
index 0000000..1059b2e
--- /dev/null
@@ -0,0 +1,1469 @@
+# Makefile for bash-3.1, version 2.159
+#
+# Copyright (C) 1996-2005 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
+
+# Make sure the first target in the makefile is the right one
+all: .made
+
+PACKAGE = @PACKAGE_NAME@
+VERSION = @PACKAGE_VERSION@
+
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+
+# Include some boilerplate Gnu makefile definitions.
+prefix = @prefix@
+
+exec_prefix = @exec_prefix@
+bindir = @bindir@
+libdir = @libdir@
+infodir = @infodir@
+includedir = @includedir@
+datadir = @datadir@
+localedir = $(datadir)/locale
+
+mandir = @mandir@
+manpfx = man
+
+man1ext = .1
+man1dir = $(mandir)/$(manpfx)1
+man3ext = .3
+man3dir = $(mandir)/$(manpfx)3
+
+htmldir = @htmldir@
+
+# Support an alternate destination root directory for package building
+DESTDIR =
+
+topdir = @top_srcdir@
+BUILD_DIR = @BUILD_DIR@
+top_builddir = @BUILD_DIR@
+srcdir = @srcdir@
+VPATH = .:@srcdir@
+
+@SET_MAKE@
+CC = @CC@
+CC_FOR_BUILD = @CC_FOR_BUILD@
+YACC = @YACC@
+SHELL = @MAKE_SHELL@
+CP = cp
+RM = rm -f
+AR = @AR@
+ARFLAGS = @ARFLAGS@
+RANLIB = @RANLIB@
+SIZE = @SIZE@
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALLMODE= -m 0755
+INSTALLMODE2 = -m 0555
+
+TESTSCRIPT = @TESTSCRIPT@
+
+DEBUGGER_START_FILE = @DEBUGGER_START_FILE@
+
+#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.
+PURIFY = @PURIFY@
+
+# Here is a rule for making .o files from .c files that does not
+# force the type of the machine (like -M_MACHINE) into the flags.
+.c.o:
+       $(RM) $@
+       $(CC) $(CCFLAGS) -c $<
+
+EXEEXT = @EXEEXT@
+OBJEXT = @OBJEXT@
+
+# The name of this program and some version information.
+VERSPROG = bashversion$(EXEEXT)
+VERSOBJ = bashversion.$(OBJEXT)
+
+Program = bash$(EXEEXT)
+Version = @BASHVERS@
+PatchLevel = `$(BUILD_DIR)/$(VERSPROG) -p`
+RELSTATUS = @RELSTATUS@
+
+Machine = @host_cpu@
+OS = @host_os@
+VENDOR = @host_vendor@
+MACHTYPE = @host@
+
+# comment out for release
+DEBUG = @DEBUG@
+MALLOC_DEBUG = @MALLOC_DEBUG@
+
+THIS_SH = $(BUILD_DIR)/$(Program)
+
+# PROFILE_FLAGS is either -pg, to generate profiling info for use
+# with gprof, or nothing (the default).
+PROFILE_FLAGS= @PROFILE_FLAGS@
+
+CFLAGS = @CFLAGS@
+CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@ @CROSS_COMPILE@
+CPPFLAGS = @CPPFLAGS@
+CPPFLAGS_FOR_BUILD = @CPPFLAGS_FOR_BUILD@
+LOCAL_CFLAGS = @LOCAL_CFLAGS@ ${DEBUG} ${MALLOC_DEBUG}
+DEFS = @DEFS@
+LOCAL_DEFS = @LOCAL_DEFS@
+
+LOCALE_DEFS = -DLOCALEDIR='"$(localedir)"' -DPACKAGE='"$(PACKAGE)"'
+
+LOCAL_LIBS = @LOCAL_LIBS@
+LIBS = $(BUILTINS_LIB) $(LIBRARIES) @LIBS@
+LIBS_FOR_BUILD = 
+
+STATIC_LD = @STATIC_LD@
+LOCAL_LDFLAGS = @LOCAL_LDFLAGS@
+
+SYSTEM_FLAGS = -DPROGRAM='"$(Program)"' -DCONF_HOSTTYPE='"$(Machine)"' -DCONF_OSTYPE='"$(OS)"' -DCONF_MACHTYPE='"$(MACHTYPE)"' -DCONF_VENDOR='"$(VENDOR)"' $(LOCALE_DEFS)
+
+BASE_CCFLAGS = $(PROFILE_FLAGS) $(SYSTEM_FLAGS) $(LOCAL_DEFS) \
+         $(DEFS) $(LOCAL_CFLAGS) $(INCLUDES)
+
+CCFLAGS = $(BASE_CCFLAGS) $(CPPFLAGS) $(CFLAGS)
+
+CCFLAGS_FOR_BUILD = $(BASE_CCFLAGS) $(CPPFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD)
+
+LDFLAGS = @LDFLAGS@ $(STATIC_LD) $(LOCAL_LDFLAGS) $(PROFILE_FLAGS) $(CFLAGS)
+LDFLAGS_FOR_BUILD = $(LDFLAGS)
+
+INCLUDES = -I. @RL_INCLUDE@ -I$(srcdir) -I$(BASHINCDIR) -I$(LIBSRC) $(INTL_INC)
+
+# Maybe add: -Wextra
+GCC_LINT_FLAGS = -O -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wno-parentheses \
+                -Wcast-align -Wstrict-prototypes -Wconversion -Wformat \
+                -Wformat-nonliteral -Wmissing-braces -Wuninitialized \
+                -Wmissing-declarations  -Winline \
+                -Wmissing-prototypes -Wtraditional -Wredundant-decls -pedantic
+
+GCC_LINT_CFLAGS = $(BASE_CCFLAGS) $(CPPFLAGS) $(GCC_LINT_FLAGS)
+
+#
+# Support libraries
+# 
+
+dot = .
+
+LIBSUBDIR = lib
+LIBSRC = $(srcdir)/$(LIBSUBDIR)
+
+LIBBUILD = ${BUILD_DIR}/${LIBSUBDIR}
+
+SUBDIR_INCLUDES = -I. @RL_INCLUDE@ -I$(topdir) -I$(topdir)/$(LIBSUBDIR)
+
+BUILD_INCLUDED_LIBINTL = @BUILD_INCLUDED_LIBINTL@
+USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@
+
+# the bash library
+# the library is a mix of functions that the C library does not provide on
+# some platforms and general shell utility functions
+SH_LIBSRC = $(LIBSRC)/sh
+SH_LIBDIR = $(dot)/${LIBSUBDIR}/sh
+SH_ABSSRC = ${topdir}/${SH_LIBSRC}
+
+SHLIB_SOURCE = ${SH_LIBSRC}/clktck.c ${SH_LIBSRC}/getcwd.c \
+               ${SH_LIBSRC}/getenv.c ${SH_LIBSRC}/oslib.c \
+               ${SH_LIBSRC}/setlinebuf.c \
+               ${SH_LIBSRC}/strcasecmp.c ${SH_LIBSRC}/strerror.c \
+               ${SH_LIBSRC}/strtod.c ${SH_LIBSRC}/strtol.c \
+               ${SH_LIBSRC}/strtoul.c ${SH_LIBSRC}/vprint.c \
+               ${SH_LIBSRC}/itos.c ${SH_LIBSRC}/rename.c \
+               ${SH_LIBSRC}/zread.c ${SH_LIBSRC}/zwrite.c \
+               ${SH_LIBSRC}/shtty.c ${SH_LIBSRC}/inet_aton.c \
+               ${SH_LIBSRC}/netopen.c ${SH_LIBSRC}/strpbrk.c \
+               ${SH_LIBSRC}/timeval.c ${SH_LIBSRC}/clock.c \
+               ${SH_LIBSRC}/makepath.c ${SH_LIBSRC}/pathcanon.c \
+               ${SH_LIBSRC}/pathphys.c ${SH_LIBSRC}/stringlist.c \
+               ${SH_LIBSRC}/stringvec.c ${SH_LIBSRC}/tmpfile.c \
+               ${SH_LIBSRC}/spell.c ${SH_LIBSRC}/strtrans.c \
+               ${SH_LIBSRC}/strindex.c ${SH_LIBSRC}/shquote.c \
+               ${SH_LIBSRC}/snprintf.c ${SH_LIBSRC}/mailstat.c \
+               ${SH_LIBSRC}/fmtulong.c ${SH_LIBSRC}/fmtullong.c \
+               ${SH_LIBSRC}/strtoll.c ${SH_LIBSRC}/strtoull.c \
+               ${SH_LIBSRC}/strtoimax.c ${SH_LIBSRC}/strtoumax.c \
+               ${SH_LIBSRC}/fmtumax.c ${SH_LIBSRC}/netconn.c \
+               ${SH_LIBSRC}/mktime.c ${SH_LIBSRC}/strftime.c \
+               ${SH_LIBSRC}/memset.c ${SH_LIBSRC}/xstrchr.c \
+               ${SH_LIBSRC}/zcatfd.c ${SH_LIBSRC}/shmatch.c \
+               ${SH_LIBSRC}/strnlen.c ${SH_LIBSRC}/winsize.c \
+               ${SH_LIBSRC}/eaccess.c ${SH_LIBSRC}/wcsdup.c \
+               ${SH_LIBSRC}/zmapfd.c
+
+SHLIB_LIB = -lsh
+SHLIB_LIBNAME = libsh.a
+SHLIB_LIBRARY = ${SH_LIBDIR}/${SHLIB_LIBNAME}
+SHLIB_LDFLAGS = -L${SH_LIBDIR}
+SHLIB_DEP = ${SHLIB_LIBRARY}
+
+# we assume for now that readline source is being shipped with bash
+RL_LIBSRC = $(LIBSRC)/readline
+RL_LIBDOC = $(RL_LIBSRC)/doc
+RL_LIBDIR = @RL_LIBDIR@
+RL_ABSSRC = ${topdir}/$(RL_LIBDIR)
+
+RL_INCLUDEDIR = @RL_INCLUDEDIR@
+
+READLINE_LIB = @READLINE_LIB@
+READLINE_LIBRARY = $(RL_LIBDIR)/libreadline.a
+READLINE_LDFLAGS = -L${RL_LIBDIR}
+READLINE_DEP = @READLINE_DEP@
+
+# The source, object and documentation of the GNU Readline library.
+READLINE_SOURCE        = $(RL_LIBSRC)/rldefs.h $(RL_LIBSRC)/rlconf.h \
+                 $(RL_LIBSRC)/readline.h $(RL_LIBSRC)/tcap.h \
+                 $(RL_LIBSRC)/chardefs.h $(RL_LIBSRC)/keymaps.h \
+                 $(RL_LIBSRC)/history.h $(RL_LIBSRC)/histlib.h \
+                 $(RL_LIBSRC)/posixstat.h $(RL_LIBSRC)/tilde.h \
+                 $(RL_LIBSRC)/rlstdc.h ${RL_LIBSRC}/xmalloc.h \
+                 $(RL_LIBSRC)/rlshell.h ${RL_LIBSRC}/rlprivate.h \
+                 $(RL_LIBSRC)/funmap.c $(RL_LIBSRC)/emacs_keymap.c \
+                 $(RL_LIBSRC)/search.c $(RL_LIBSRC)/vi_keymap.c \
+                 $(RL_LIBSRC)/keymaps.c $(RL_LIBSRC)/parens.c \
+                 $(RL_LIBSRC)/vi_mode.c $(RL_LIBSRC)/callback.c \
+                 $(RL_LIBSRC)/readline.c $(RL_LIBSRC)/tilde.c \
+                 $(RL_LIBSRC)/rltty.c $(RL_LIBSRC)/complete.c \
+                 $(RL_LIBSRC)/bind.c $(RL_LIBSRC)/isearch.c \
+                 $(RL_LIBSRC)/display.c $(RL_LIBSRC)/signals.c \
+                 $(RL_LIBSRC)/util.c $(RL_LIBSRC)/kill.c $(RL_LIBSRC)/text.c \
+                 $(RL_LIBSRC)/undo.c $(RL_LIBSRC)/macro.c \
+                 $(RL_LIBSRC)/terminal.c $(RL_LIBSRC)/nls.c \
+                 $(RL_LIBSRC)/input.c $(RL_LIBSRC)/xmalloc.c \
+                 $(RL_LIBSRC)/shell.c $(RL_LIBSRC)/savestring.c \
+                 $(RL_LIBSRC)/misc.c $(RL_LIBSRC)/mbutil.c $(RL_LIBSRC)/compat.c \
+                 $(RL_LIBSRC)/histexpand.c $(RL_LIBSRC)/history.c \
+                 $(RL_LIBSRC)/histsearch.c $(RL_LIBSRC)/histfile.c
+
+READLINE_OBJ   = $(RL_LIBDIR)/readline.o $(RL_LIBDIR)/funmap.o \
+                 $(RL_LIBDIR)/parens.o $(RL_LIBDIR)/search.o \
+                 $(RL_LIBDIR)/keymaps.o $(RL_LIBDIR)/xmalloc.o \
+                 $(RL_LIBDIR)/rltty.o $(RL_LIBDIR)/complete.o \
+                 $(RL_LIBDIR)/bind.o $(RL_LIBDIR)/isearch.o \
+                 $(RL_LIBDIR)/display.o $(RL_LIBDIR)/signals.o \
+                 $(RL_LIBDIR)/tilde.o $(RL_LIBDIR)/util.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)/savestring.o \
+                 $(RL_LIBDIR)/mbutil.o $(RL_LIBDIR)/compat.o \
+                 $(RL_LIBDIR)/history.o $(RL_LIBDIR)/histexpand.o \
+                 $(RL_LIBDIR)/histsearch.o $(RL_LIBDIR)/histfile.o
+
+HIST_LIBSRC = $(LIBSRC)/readline
+HIST_LIBDIR = @HIST_LIBDIR@
+HIST_ABSSRC = ${topdir}/$(HIST_LIBDIR)
+
+HISTORY_LIB = @HISTORY_LIB@
+HISTORY_LIBRARY = $(HIST_LIBDIR)/libhistory.a
+HISTORY_LDFLAGS = -L$(HIST_LIBDIR)
+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)/shell.o
+
+# You only need termcap (or curses) if you are linking with GNU Readline.
+TERM_LIBSRC = $(LIBSRC)/termcap
+TERM_LIBDIR = $(dot)/$(LIBSUBDIR)/termcap
+TERM_ABSSRC = ${topdir}/$(TERM_LIBDIR)
+
+TERMCAP_LIB = @TERMCAP_LIB@
+TERMCAP_LIBRARY = $(TERM_LIBDIR)/libtermcap.a
+TERMCAP_LDFLAGS = -L$(TERM_LIBDIR)
+TERMCAP_DEP = @TERMCAP_DEP@
+
+TERMCAP_SOURCE = $(TERM_LIBSRC)/termcap.c $(TERM_LIBSRC)/tparam.c
+TERMCAP_OBJ    = $(TERM_LIBDIR)/termcap.o $(TERM_LIBDIR)/tparam.o
+
+GLOB_LIBSRC = $(LIBSRC)/glob
+GLOB_LIBDIR = $(dot)/$(LIBSUBDIR)/glob
+GLOB_ABSSRC = ${topdir}/$(GLOB_LIBDIR)
+
+GLOB_LIB     = -lglob
+GLOB_LIBRARY = $(GLOB_LIBDIR)/libglob.a
+GLOB_LDFLAGS = -L$(GLOB_LIBDIR)
+GLOB_DEP = $(GLOB_LIBRARY)
+
+GLOB_SOURCE = $(GLOB_LIBSRC)/glob.c $(GLOB_LIBSRC)/strmatch.c \
+             $(GLOB_LIBSRC)/smatch.c $(GLOB_LIBSRC)/xmbsrtowcs.c \
+             $(GLOB_LIBSRC)/glob_loop.c $(GLOB_LIBSRC)/sm_loop.c \
+             $(GLOB_LIBSRC)/glob.h $(GLOB_LIBSRC)/strmatch.h
+GLOB_OBJ    = $(GLOB_LIBDIR)/glob.o $(GLOB_LIBDIR)/strmatch.o \
+             $(GLOB_LIBDIR)/smatch.o $(GLOB_LIBDIR)/xmbsrtowcs.o
+
+# The source, object and documentation for the GNU Tilde library.
+TILDE_LIBSRC = $(LIBSRC)/tilde
+TILDE_LIBDIR = $(dot)/$(LIBSUBDIR)/tilde
+TILDE_ABSSRC = ${topdir}/$(TILDE_LIBDIR)
+
+TILDE_LIB = @TILDE_LIB@
+TILDE_LIBRARY = $(TILDE_LIBDIR)/libtilde.a
+TILDE_LDFLAGS = -L$(TILDE_LIBDIR)
+TILDE_DEP = $(TILDE_LIBRARY)
+
+TILDE_SOURCE   = $(TILDE_LIBSRC)/tilde.c $(TILDE_LIBSRC)/tilde.h
+TILDE_OBJ      = $(TILDE_LIBDIR)/tilde.o
+
+# libintl
+INTL_LIBSRC = $(LIBSRC)/intl
+INTL_LIBDIR = $(dot)/$(LIBSUBDIR)/intl
+INTL_ABSSRC = ${topdir}/$(INTL_LIB)
+INTL_BUILDDIR = ${LIBBUILD}/intl
+
+INTL_LIB     = @LIBINTL@
+INTL_LIBRARY = $(INTL_LIBDIR)/libintl.a
+INTL_DEP = @INTL_DEP@
+INTL_INC = @INTL_INC@
+
+LIBINTL_H = @LIBINTL_H@
+
+# tests
+LIBINTL = @LIBINTL@
+LTLIBINTL = @LTLIBINTL@
+INTLLIBS = @INTLLIBS@
+INTLOBJS = @INTLOBJS@
+
+# 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)
+
+MALLOC_SRC = @MALLOC_SRC@
+MALLOC_OTHERSRC = ${ALLOC_LIBSRC}/trace.c ${ALLOC_LIBSRC}/stats.c \
+                 ${ALLOC_LIBSRC}/table.c ${ALLOC_LIBSRC}/watch.c
+MALLOC_SOURCE = ${ALLOC_LIBSRC}/${MALLOC_SRC} ${MALLOC_OTHERSRC}
+MALLOC_CFLAGS = -DRCHECK -Dbotch=programming_error ${MALLOC_DEBUG}
+
+MALLOC_LIB     = @MALLOC_LIB@
+MALLOC_LIBRARY = @MALLOC_LIBRARY@
+MALLOC_LDFLAGS = @MALLOC_LDFLAGS@
+MALLOC_DEP = @MALLOC_DEP@
+
+ALLOC_HEADERS = $(ALLOC_LIBSRC)/getpagesize.h $(ALLOC_LIBSRC)/shmalloc.h \
+               $(ALLOC_LIBSRC)/imalloc.h $(ALLOC_LIBSRC)/mstats.h \
+               $(ALLOC_LIBSRC)/table.h $(ALLOC_LIBSRC)/watch.h
+
+$(MALLOC_LIBRARY):     ${MALLOC_SOURCE} ${ALLOC_HEADERS} config.h
+               @(cd $(ALLOC_LIBDIR) && \
+                $(MAKE) $(MFLAGS) \
+                MALLOC_CFLAGS="$(MALLOC_CFLAGS)" ${MALLOC_TARGET} ) || exit 1
+
+BASHINCDIR = ${srcdir}/include
+BASHINCFILES =  $(BASHINCDIR)/posixstat.h $(BASHINCDIR)/ansi_stdlib.h \
+                $(BASHINCDIR)/filecntl.h $(BASHINCDIR)/posixdir.h \
+                $(BASHINCDIR)/memalloc.h $(BASHINCDIR)/stdc.h \
+                $(BASHINCDIR)/posixjmp.h $(BASHINCDIR)/posixwait.h \
+                $(BASHINCDIR)/posixtime.h $(BASHINCDIR)/systimes.h \
+                $(BASHINCDIR)/unionwait.h $(BASHINCDIR)/maxpath.h \
+                $(BASHINCDIR)/shtty.h $(BASHINCDIR)/typemax.h \
+                $(BASHINCDIR)/ocache.h
+
+LIBRARIES = $(SHLIB_LIB) $(READLINE_LIB) $(HISTORY_LIB) $(TERMCAP_LIB) $(GLOB_LIB) \
+           $(TILDE_LIB) $(MALLOC_LIB) $(INTL_LIB) $(LOCAL_LIBS)
+
+LIBDEP = $(SHLIB_DEP) $(INTL_DEP) $(READLINE_DEP) $(HISTORY_DEP) $(TERMCAP_DEP) $(GLOB_DEP) \
+        $(TILDE_DEP) $(MALLOC_DEP)
+
+LIBRARY_LDFLAGS = $(READLINE_LDFLAGS) $(HISTORY_LDFLAGS) $(GLOB_LDFLAGS) \
+                 $(TILDE_LDFLAGS) $(MALLOC_LDFLAGS) $(SHLIB_LDFLAGS)
+
+#
+# The shell itself
+#
+
+# 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 hashcmd.c hashlib.c mailcheck.c \
+          test.c trap.c alias.c jobs.c nojobs.c $(ALLOC_FILES) braces.c \
+          input.c bashhist.c array.c arrayfunc.c sig.c pathexp.c \
+          unwind_prot.c siglist.c bashline.c bracecomp.c error.c \
+          list.c stringlib.c locale.c findcmd.c redir.c \
+          pcomplete.c pcomplib.c syntax.c xmalloc.c
+
+HSOURCES = shell.h flags.h trap.h hashcmd.h hashlib.h jobs.h builtins.h \
+          general.h variables.h config.h $(ALLOC_HEADERS) alias.h \
+          quit.h unwind_prot.h syntax.h ${GRAM_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 arrayfunc.h sig.h mailcheck.h bashintl.h bashjmp.h \
+          execute_cmd.h parser.h pathexp.h pathnames.h pcomplete.h \
+          $(BASHINCFILES)
+
+SOURCES         = $(CSOURCES) $(HSOURCES) $(BUILTIN_DEFS)
+
+# header files chosen based on running of configure
+SIGNAMES_H = @SIGNAMES_H@
+
+# object files chosen based on running of configure
+JOBS_O = @JOBS_O@
+SIGLIST_O = @SIGLIST_O@
+SIGNAMES_O = @SIGNAMES_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 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 arrayfunc.o braces.o bracecomp.o bashhist.o \
+          bashline.o $(SIGLIST_O) list.o stringlib.o locale.o findcmd.o redir.o \
+          pcomplete.o pcomplib.o syntax.o xmalloc.o $(SIGNAMES_O)
+
+# Where the source code of the shell builtins resides.
+BUILTIN_SRCDIR=$(srcdir)/builtins
+DEFSRC=$(BUILTIN_SRCDIR)
+BUILTIN_ABSSRC=${topdir}/builtins
+DEFDIR = $(dot)/builtins
+DEBUGGER_DIR = $(dot)/debugger
+
+BUILTIN_DEFS = $(DEFSRC)/alias.def $(DEFSRC)/bind.def $(DEFSRC)/break.def \
+              $(DEFSRC)/builtin.def $(DEFSRC)/cd.def $(DEFSRC)/colon.def \
+              $(DEFSRC)/command.def ${DEFSRC}/complete.def \
+              $(DEFSRC)/caller.def $(DEFSRC)/declare.def \
+              $(DEFSRC)/echo.def $(DEFSRC)/enable.def $(DEFSRC)/eval.def \
+              $(DEFSRC)/exec.def $(DEFSRC)/exit.def $(DEFSRC)/fc.def \
+              $(DEFSRC)/fg_bg.def $(DEFSRC)/hash.def $(DEFSRC)/help.def \
+              $(DEFSRC)/history.def $(DEFSRC)/jobs.def $(DEFSRC)/kill.def \
+              $(DEFSRC)/let.def $(DEFSRC)/read.def $(DEFSRC)/return.def \
+              $(DEFSRC)/set.def $(DEFSRC)/setattr.def $(DEFSRC)/shift.def \
+              $(DEFSRC)/source.def $(DEFSRC)/suspend.def $(DEFSRC)/test.def \
+              $(DEFSRC)/times.def $(DEFSRC)/trap.def $(DEFSRC)/type.def \
+              $(DEFSRC)/ulimit.def $(DEFSRC)/umask.def $(DEFSRC)/wait.def \
+              $(DEFSRC)/getopts.def $(DEFSRC)/reserved.def \
+              $(DEFSRC)/pushd.def $(DEFSRC)/shopt.def $(DEFSRC)/printf.def
+BUILTIN_C_SRC  = $(DEFSRC)/mkbuiltins.c $(DEFSRC)/common.c \
+                $(DEFSRC)/evalstring.c $(DEFSRC)/evalfile.c \
+                $(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 \
+              $(DEFDIR)/builtin.o $(DEFDIR)/cd.o $(DEFDIR)/colon.o \
+              $(DEFDIR)/command.o $(DEFDIR)/caller.o $(DEFDIR)/declare.o \
+              $(DEFDIR)/echo.o $(DEFDIR)/enable.o $(DEFDIR)/eval.o \
+              $(DEFDIR)/exec.o $(DEFDIR)/exit.o $(DEFDIR)/fc.o \
+              $(DEFDIR)/fg_bg.o $(DEFDIR)/hash.o $(DEFDIR)/help.o \
+              $(DEFDIR)/history.o $(DEFDIR)/jobs.o $(DEFDIR)/kill.o \
+              $(DEFDIR)/let.o $(DEFDIR)/pushd.o $(DEFDIR)/read.o \
+              $(DEFDIR)/return.o $(DEFDIR)/shopt.o $(DEFDIR)/printf.o \
+              $(DEFDIR)/set.o $(DEFDIR)/setattr.o $(DEFDIR)/shift.o \
+              $(DEFDIR)/source.o $(DEFDIR)/suspend.o $(DEFDIR)/test.o \
+              $(DEFDIR)/times.o $(DEFDIR)/trap.o $(DEFDIR)/type.o \
+              $(DEFDIR)/ulimit.o $(DEFDIR)/umask.o $(DEFDIR)/wait.o \
+              $(DEFDIR)/getopts.o $(BUILTIN_C_OBJ)
+GETOPT_SOURCE   = $(DEFSRC)/getopt.c $(DEFSRC)/getopt.h
+PSIZE_SOURCE   = $(DEFSRC)/psize.sh $(DEFSRC)/psize.c
+
+BUILTINS_LIBRARY = $(DEFDIR)/libbuiltins.a
+BUILTINS_LIB = -lbuiltins
+BUILTINS_LDFLAGS = -L$(DEFDIR)
+BUILTINS_DEP = $(BUILTINS_LIBRARY)
+
+# Documentation for the shell.
+DOCSRC = $(srcdir)/doc
+DOCDIR = $(dot)/doc
+
+# Translations and other i18n support files
+PO_SRC = $(srcdir)/po/
+PO_DIR = $(dot)/po/
+
+SIGNAMES_SUPPORT = $(SUPPORT_SRC)mksignames.c
+
+SUPPORT_SRC = $(srcdir)/support/
+SDIR = $(dot)/support/
+
+TESTS_SUPPORT = recho$(EXEEXT) zecho$(EXEEXT) printenv$(EXEEXT)
+CREATED_SUPPORT = signames.h recho$(EXEEXT) zecho$(EXEEXT) printenv$(EXEEXT) \
+                 tests/recho$(EXEEXT) tests/zecho$(EXEEXT) \
+                 tests/printenv$(EXEEXT) mksignames$(EXEEXT) lsignames.h \
+                 mksyntax${EXEEXT} syntax.c $(VERSPROG) $(VERSOBJ) \
+                 buildversion.o mksignames.o signames.o buildsignames.o
+CREATED_CONFIGURE = config.h config.cache config.status config.log \
+                   stamp-h po/POTFILES
+CREATED_MAKEFILES = Makefile builtins/Makefile doc/Makefile \
+                   lib/readline/Makefile lib/glob/Makefile \
+                   lib/sh/Makefile lib/tilde/Makefile lib/malloc/Makefile \
+                   lib/termcap/Makefile examples/loadables/Makefile \
+                   examples/loadables/perl/Makefile support/Makefile \
+                   lib/intl/Makefile po/Makefile po/Makefile.in
+
+# Keep GNU Make from exporting the entire environment for small machines.
+.NOEXPORT:
+
+.made: $(Program) bashbug
+       @echo "$(Program) last made for a $(Machine) running $(OS)" >.made
+
+$(Program):  .build $(OBJECTS) $(BUILTINS_DEP) $(LIBDEP)
+       $(RM) $@
+       $(PURIFY) $(CC) $(BUILTINS_LDFLAGS) $(LIBRARY_LDFLAGS) $(LDFLAGS) -o $(Program) $(OBJECTS) $(LIBS)
+       ls -l $(Program)
+       -$(SIZE) $(Program)
+
+.build:        $(SOURCES) config.h Makefile version.h $(VERSPROG)
+       @echo
+       @echo "   ***********************************************************"
+       @echo "   *                                                         *"
+       @echo "   * `$(BUILD_DIR)/$(VERSPROG) -l`"
+       @echo "   *                                                         *"
+       @echo "   ***********************************************************"
+       @echo
+
+bashbug: $(SUPPORT_SRC)bashbug.sh config.h Makefile $(VERSPROG)
+       @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
+
+strip: $(Program) .made
+       strip $(Program)
+       ls -l $(Program)
+       -$(SIZE) $(Program)
+
+lint:
+       ${MAKE} ${MFLAGS} CFLAGS='${GCC_LINT_FLAGS}' .made
+
+version.h:  $(SOURCES) config.h Makefile 
+       $(SHELL) $(SUPPORT_SRC)mkversion.sh -b -S ${topdir} -s $(RELSTATUS) -d $(Version) -o newversion.h \
+               && mv newversion.h version.h
+
+bashversion$(EXEEXT):  patchlevel.h conftypes.h version.h buildversion.o $(SUPPORT_SRC)bashversion.c
+       $(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) -o $@ $(SUPPORT_SRC)bashversion.c buildversion.o ${LIBS_FOR_BUILD}
+
+buildversion.o: version.h conftypes.h patchlevel.h $(srcdir)/version.c
+       $(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) -DBUILDTOOL -c -o $@ $(srcdir)/version.c
+
+# old rules
+GRAM_H = parser-built
+y.tab.o: y.tab.c ${GRAM_H} command.h ${BASHINCDIR}/stdc.h input.h
+${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
+       touch parser-built
+#      -if cmp -s old-y.tab.h y.tab.h; then mv old-y.tab.h y.tab.h; else cp -p y.tab.h ${GRAM_H}; fi
+
+# experimental new rules - work with GNU make but not BSD (or OSF) make
+#y.tab.o: y.tab.c y.tab.h
+#y.tab.c y.tab.h: parse.y command.h ${BASHINCDIR}/stdc.h input.h
+#      -if test -f y.tab.h; then mv -f y.tab.h old-y.tab.h; fi
+#      $(YACC) -d $(srcdir)/parse.y
+#      -if cmp -s old-y.tab.h y.tab.h; then mv old-y.tab.h y.tab.h; fi
+
+$(READLINE_LIBRARY): config.h $(READLINE_SOURCE)
+       @echo making $@ in ${RL_LIBDIR}
+       @( { test "${RL_LIBDIR}" = "${libdir}" && exit 0; } || \
+               cd ${RL_LIBDIR} && $(MAKE) $(MFLAGS) libreadline.a) || exit 1
+
+$(HISTORY_LIBRARY): config.h $(HISTORY_SOURCE)
+       @echo making $@ in ${HIST_LIBDIR}
+       @( { test "${HIST_LIBDIR}" = "${libdir}" && exit 0; } || \
+               cd ${HIST_LIBDIR} && $(MAKE) $(MFLAGS) libhistory.a) || exit 1
+
+$(GLOB_LIBRARY): config.h $(GLOB_SOURCE)
+       @echo making $@ in ${GLOB_LIBDIR}
+       @(cd ${GLOB_LIBDIR} && \
+               $(MAKE) $(MFLAGS) DEBUG=${DEBUG} libglob.a) || exit 1
+
+$(TILDE_LIBRARY): config.h $(TILDE_SOURCE)
+       @echo making $@ in ${TILDE_LIBDIR}
+       @(cd ${TILDE_LIBDIR} && \
+               $(MAKE) $(MFLAGS) libtilde.a) || exit 1
+
+$(TERMCAP_LIBRARY): config.h ${TERMCAP_SOURCE}
+       @echo making $@ in ${TERM_LIBDIR}       
+       @(cd ${TERM_LIBDIR} && \
+               $(MAKE) $(MFLAGS) libtermcap.a) || exit 1
+
+$(SHLIB_LIBRARY): config.h ${SHLIB_SOURCE}
+       @echo making $@ in ${SH_LIBDIR}
+       @(cd ${SH_LIBDIR} && \
+               $(MAKE) $(MFLAGS) DEBUG=${DEBUG} ${SHLIB_LIBNAME}) || exit 1
+
+${INTL_LIBRARY}: config.h ${INTL_LIBDIR}/Makefile
+       @echo making $@ in ${INTL_LIBDIR}
+       @(cd ${INTL_LIBDIR} && \
+               $(MAKE) $(MFLAGS) all) || exit 1
+
+${LIBINTL_H}:  ${INTL_LIBRARY}
+
+signames.o: $(SUPPORT_SRC)signames.c
+       $(RM) $@
+       $(CC) $(CCFLAGS) -c $(SUPPORT_SRC)signames.c
+
+buildsignames.o:       $(SUPPORT_SRC)signames.c
+       $(RM) $@
+       $(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) -DBUILDTOOL -o $@ -c $(SUPPORT_SRC)signames.c
+
+mksignames.o:  $(SUPPORT_SRC)mksignames.c
+       $(RM) $@
+       $(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) -DBUILDTOOL -c $(SUPPORT_SRC)mksignames.c
+
+mksignames$(EXEEXT):   mksignames.o buildsignames.o
+       $(RM) $@
+       $(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) -o $@ mksignames.o buildsignames.o ${LIBS_FOR_BUILD}
+
+mksyntax$(EXEEXT):     ${srcdir}/mksyntax.c config.h syntax.h ${BASHINCDIR}/chartypes.h
+       $(RM) $@
+       ${CC_FOR_BUILD} ${CCFLAGS_FOR_BUILD} -o $@ ${srcdir}/mksyntax.c ${LIBS_FOR_BUILD}
+
+# make a list of signals for the local system -- this is done when we're
+# *not* cross-compiling
+lsignames.h:   mksignames$(EXEEXT)
+       $(RM) $@
+       ./mksignames$(EXEEXT) $@
+
+# copy the correct signames header file to signames.h
+signames.h: $(SIGNAMES_H)
+       -if cmp -s $(SIGNAMES_H) $@ ; then :; else $(RM) $@ ; $(CP) $(SIGNAMES_H) $@ ; fi
+
+syntax.c:      mksyntax${EXEEXT} $(srcdir)/syntax.h 
+       $(RM) $@
+       ./mksyntax$(EXEEXT) -o $@
+
+$(BUILTINS_LIBRARY): $(BUILTIN_DEFS) $(BUILTIN_C_SRC) config.h ${BASHINCDIR}/memalloc.h version.h
+       @(cd $(DEFDIR) && $(MAKE) $(MFLAGS) DEBUG=${DEBUG} libbuiltins.a ) || exit 1
+
+# these require special rules to circumvent make builtin rules
+${DEFDIR}/common.o:    $(BUILTIN_SRCDIR)/common.c
+       @(cd $(DEFDIR) && $(MAKE) $(MFLAGS) DEBUG=${DEBUG} common.o) || exit 1
+
+${DEFDIR}/bashgetopt.o:        $(BUILTIN_SRCDIR)/bashgetopt.c
+       @(cd $(DEFDIR) && $(MAKE) $(MFLAGS) DEBUG=${DEBUG} bashgetopt.o) || exit 1
+
+${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 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 \
+               CONFIG_FILES=$$mf CONFIG_HEADERS= $(SHELL) ./config.status ; \
+       done
+
+config.h:      stamp-h 
+
+stamp-h:       config.status $(srcdir)/config.h.in $(srcdir)/config-top.h $(srcdir)/config-bot.h
+       CONFIG_FILES= CONFIG_HEADERS=config.h $(SHELL) ./config.status
+
+config.status: $(srcdir)/configure
+       $(SHELL) ./config.status --recheck
+
+pathnames.h:           Makefile $(srcdir)/pathnames.h.in
+       sed -e 's|@DEBUGGER_START_FILE\@|${DEBUGGER_START_FILE}|g' $(srcdir)/pathnames.h.in > pathnames.tmp
+       @if test -f $@; then \
+               cmp -s pathnames.tmp $@ || mv pathnames.tmp $@; \
+       else \
+               mv pathnames.tmp $@; \
+       fi
+       ${RM} pathnames.tmp
+
+# comment out for distribution
+$(srcdir)/configure:   $(srcdir)/configure.in $(srcdir)/aclocal.m4 $(srcdir)/config.h.in
+       cd $(srcdir) && autoconf
+
+# for chet
+reconfig: force
+       sh $(srcdir)/configure -C
+
+#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) )
+
+info dvi ps: force
+       @(cd $(DOCDIR) ; $(MAKE) $(MFLAGS) CFLAGS='$(CCFLAGS)' $@ )
+
+force:
+
+TAGS:  $(SOURCES) $(BUILTIN_C_SRC) $(LIBRARY_SOURCE)
+       etags $(SOURCES) $(BUILTIN_C_SRC) $(LIBRARY_SOURCE)
+
+tags:  $(SOURCES) $(BUILTIN_C_SRC) $(LIBRARY_SOURCE)
+       ctags -x $(SOURCES) $(BUILTIN_C_SRC) $(LIBRARY_SOURCE) > $@
+
+# Targets that actually do things not part of the build
+
+installdirs:
+       @${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(bindir)
+       @${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(man1dir)
+       @${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(infodir)
+       -( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
+
+install:       .made installdirs
+       $(INSTALL_PROGRAM) $(INSTALLMODE) $(Program) $(DESTDIR)$(bindir)/$(Program)
+       $(INSTALL_SCRIPT) $(INSTALLMODE2) bashbug $(DESTDIR)$(bindir)/bashbug
+       -( cd $(DOCDIR) ; $(MAKE) $(MFLAGS) \
+               man1dir=$(man1dir) man1ext=$(man1ext) \
+               man3dir=$(man3dir) man3ext=$(man3ext) \
+               infodir=$(infodir) htmldir=$(htmldir) DESTDIR=$(DESTDIR) $@ )
+       -( cd $(DEFDIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
+       -( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
+
+install-strip:
+       $(MAKE) $(MFLAGS) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' \
+               prefix=${prefix} exec_prefix=${exec_prefix} \
+               DESTDIR=$(DESTDIR) install
+
+uninstall:     .made
+       $(RM) $(DESTDIR)$(bindir)/$(Program) $(DESTDIR)$(bindir)/bashbug
+       -( cd $(DOCDIR) ; $(MAKE) $(MFLAGS) \
+               man1dir=$(man1dir) man1ext=$(man1ext) \
+               man3dir=$(man3dir) man3ext=$(man3ext) \
+               infodir=$(infodir) htmldir=$(htmldir) DESTDIR=$(DESTDIR) $@ )
+       -( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
+
+.PHONY: basic-clean clean realclean maintainer-clean distclean mostlyclean maybe-clean
+
+LIB_SUBDIRS = ${RL_LIBDIR}  ${HIST_LIBDIR} ${TERM_LIBDIR} ${GLOB_LIBDIR} \
+               ${INTL_LIBDIR} ${TILDE_LIBDIR} ${ALLOC_LIBDIR} ${SH_LIBDIR}
+
+basic-clean:
+       $(RM) $(OBJECTS) $(Program) bashbug
+       $(RM) .build .made version.h 
+
+clean: basic-clean
+       ( cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ )
+       ( cd builtins && $(MAKE) $(MFLAGS) $@ )
+       -( cd $(SDIR) && $(MAKE) $(MFLAGS) $@ )
+       -for libdir in ${LIB_SUBDIRS}; do \
+               (cd $$libdir && test -f Makefile && $(MAKE) $(MFLAGS) $@) ;\
+       done
+       -( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
+       $(RM) $(CREATED_SUPPORT)
+
+mostlyclean: basic-clean
+       ( cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ )
+       ( cd builtins && $(MAKE) $(MFLAGS) $@ )
+       -( cd $(SDIR) && $(MAKE) $(MFLAGS) $@ )
+       -for libdir in ${LIB_SUBDIRS}; do \
+               (cd $$libdir && test -f Makefile && $(MAKE) $(MFLAGS) $@) ;\
+       done
+       -( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
+
+distclean:     basic-clean maybe-clean
+       ( cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ )
+       ( cd builtins && $(MAKE) $(MFLAGS) $@ )
+       -( cd $(SDIR) && $(MAKE) $(MFLAGS) $@ )
+       -for libdir in ${LIB_SUBDIRS}; do \
+               (cd $$libdir && test -f Makefile && $(MAKE) $(MFLAGS) $@) ;\
+       done
+       -( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
+       $(RM) $(CREATED_CONFIGURE) tags TAGS 
+       $(RM) $(CREATED_SUPPORT) Makefile $(CREATED_MAKEFILES) pathnames.h
+
+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
+       ( cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ )
+       ( cd builtins && $(MAKE) $(MFLAGS) $@ )
+       ( cd $(SDIR) && $(MAKE) $(MFLAGS) $@ )
+       -for libdir in ${LIB_SUBDIRS}; do \
+               (cd $$libdir && test -f Makefile && $(MAKE) $(MFLAGS) $@) ;\
+       done
+       -( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
+       $(RM) $(CREATED_CONFIGURE) $(CREATED_MAKEFILES)
+       $(RM) $(CREATED_SUPPORT) Makefile pathnames.h
+
+maybe-clean:
+       -if test "X$(topdir)" != "X$(BUILD_DIR)" ; then \
+               $(RM) parser-built y.tab.c y.tab.h ; \
+       fi
+
+recho$(EXEEXT):                $(SUPPORT_SRC)recho.c
+       @$(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) -o $@ $(SUPPORT_SRC)recho.c ${LIBS_FOR_BUILD}
+
+zecho$(EXEEXT):                $(SUPPORT_SRC)zecho.c
+       @$(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) -o $@ $(SUPPORT_SRC)zecho.c ${LIBS_FOR_BUILD}
+
+printenv$(EXEEXT):     $(SUPPORT_SRC)printenv.c
+       @$(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) -o $@ $(SUPPORT_SRC)printenv.c ${LIBS_FOR_BUILD}
+
+test tests check:      force $(Program) $(TESTS_SUPPORT)
+       @-test -d tests || mkdir tests
+       @cp $(TESTS_SUPPORT) tests
+       @( cd $(srcdir)/tests && \
+               PATH=$(BUILD_DIR)/tests:$$PATH THIS_SH=$(THIS_SH) $(SHELL) ${TESTSCRIPT} )
+
+symlinks:
+       $(SHELL) $(SUPPORT_SRC)fixlinks -s $(srcdir)
+
+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 ${PACKAGE} $(PACKAGE_VERSION)
+       @echo tar cf $(PACKAGE)-${PACKAGE_VERSION}.tar ${PACKAGE}-$(PACKAGE_VERSION)
+       @echo gzip $(PACKAGE)-$(PACKAGE_VERSION).tar
+
+depend:        depends
+
+depends: force
+       $(Program) $(SUPPORT_SRC)mkdep -c ${CC} -- ${CCFLAGS} ${CSOURCES}
+
+#### PRIVATE TARGETS ####
+hashtest:      hashlib.c
+       $(CC) -DTEST_HASHING $(CCFLAGS) -o $@ $(srcdir)/hashlib.c
+
+############################ DEPENDENCIES ###############################
+
+# Files that depend on the definitions in config-top.h, which are not meant
+# to be changed
+shell.o: config-top.h
+input.o: config-top.h
+y.tab.o: config-top.h
+jobs.o: config-top.h
+nojobs.o: config-top.h
+execute_cmd.o: config-top.h
+variables.o: config-top.h
+builtins/command.o: config-top.h
+builtins/common.o: config-top.h
+builtins/break.o: config-top.h
+builtins/echo.o: config-top.h
+builtins/evalstring.o: config-top.h
+builtins/exit.o: config-top.h
+builtins/kill.o: config-top.h
+
+# shell basics
+copy_cmd.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+copy_cmd.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+copy_cmd.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+copy_cmd.o: make_cmd.h subst.h sig.h pathnames.h externs.h
+dispose_cmd.o: bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+dispose_cmd.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h
+dispose_cmd.o: error.h general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+dispose_cmd.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+dispose_cmd.o: make_cmd.h subst.h sig.h pathnames.h externs.h
+dispose_cmd.o: ${BASHINCDIR}/ocache.h
+error.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h flags.h ${BASHINCDIR}/stdc.h error.h
+error.o: command.h general.h xmalloc.h externs.h input.h bashhist.h
+error.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+error.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+error.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+error.o: make_cmd.h subst.h sig.h pathnames.h externs.h
+error.o: input.h execute_cmd.h 
+eval.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h trap.h flags.h ${DEFSRC}/common.h
+eval.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+eval.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+eval.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+eval.o: make_cmd.h subst.h sig.h pathnames.h externs.h
+eval.o: input.h execute_cmd.h 
+execute_cmd.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+execute_cmd.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+execute_cmd.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+execute_cmd.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+execute_cmd.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+execute_cmd.o: ${BASHINCDIR}/memalloc.h ${GRAM_H} flags.h builtins.h jobs.h quit.h siglist.h
+execute_cmd.o: execute_cmd.h findcmd.h redir.h trap.h test.h pathexp.h
+execute_cmd.o: $(DEFSRC)/common.h ${DEFDIR}/builtext.h ${GLOB_LIBSRC}/strmatch.h
+execute_cmd.o: ${BASHINCDIR}/posixtime.h ${BASHINCDIR}/chartypes.h
+expr.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h 
+expr.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+expr.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+expr.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+expr.o: make_cmd.h subst.h sig.h pathnames.h externs.h
+expr.o: ${BASHINCDIR}/chartypes.h
+findcmd.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h ${BASHINCDIR}/posixstat.h bashansi.h
+findcmd.o: ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/memalloc.h shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h
+findcmd.o: ${BASHINCDIR}/stdc.h error.h general.h xmalloc.h variables.h arrayfunc.h conftypes.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h
+findcmd.o: dispose_cmd.h make_cmd.h subst.h sig.h pathnames.h externs.h
+findcmd.o: flags.h hashlib.h pathexp.h hashcmd.h 
+findcmd.o: ${BASHINCDIR}/chartypes.h
+flags.o: config.h flags.h 
+flags.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+flags.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+flags.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+flags.o: make_cmd.h subst.h sig.h pathnames.h externs.h bashhist.h
+general.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h ${BASHINCDIR}/filecntl.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+general.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+general.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+general.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+general.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+general.o: ${BASHINCDIR}/maxpath.h ${BASHINCDIR}/posixtime.h
+general.o: ${BASHINCDIR}/chartypes.h
+hashcmd.o: config.h ${BASHINCDIR}/posixstat.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+hashcmd.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+hashcmd.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashcmd.h
+hashcmd.o: execute_cmd.h findcmd.h ${BASHINCDIR}/stdc.h hashlib.h
+hashlib.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+hashlib.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+hashlib.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+hashlib.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+hashlib.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+input.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+input.o: command.h ${BASHINCDIR}/stdc.h general.h xmalloc.h input.h error.h externs.h
+list.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+list.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+list.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+list.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+locale.o: config.h bashtypes.h bashintl.h ${LIBINTL_H} bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+locale.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+locale.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+locale.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+locale.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+locale.o: ${BASHINCDIR}/chartypes.h
+mailcheck.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+mailcheck.o: ${BASHINCDIR}/posixtime.h
+mailcheck.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+mailcheck.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+mailcheck.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+mailcheck.o: make_cmd.h subst.h sig.h pathnames.h externs.h
+mailcheck.o: execute_cmd.h mailcheck.h 
+make_cmd.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h bashansi.h
+make_cmd.o: command.h ${BASHINCDIR}/stdc.h general.h xmalloc.h error.h flags.h make_cmd.h
+make_cmd.o: variables.h arrayfunc.h conftypes.h array.h hashlib.h subst.h input.h externs.h
+make_cmd.o: jobs.h quit.h siglist.h syntax.h dispose_cmd.h
+make_cmd.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/ocache.h
+y.tab.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/memalloc.h
+y.tab.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+y.tab.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+y.tab.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+y.tab.o: make_cmd.h subst.h sig.h pathnames.h externs.h test.h
+y.tab.o: trap.h flags.h parser.h input.h mailcheck.h $(DEFSRC)/common.h
+y.tab.o: $(DEFDIR)/builtext.h bashline.h bashhist.h jobs.h siglist.h alias.h
+pathexp.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+pathexp.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+pathexp.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+pathexp.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+pathexp.o: make_cmd.h subst.h sig.h pathnames.h externs.h
+pathexp.o: pathexp.h flags.h 
+pathexp.o: $(GLOB_LIBSRC)/glob.h $(GLOB_LIBSRC)/strmatch.h
+pathexp.o: ${BASHINCDIR}/shmbutil.h
+print_cmd.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+print_cmd.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+print_cmd.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+print_cmd.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+print_cmd.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+print_cmd.o: ${GRAM_H} $(DEFSRC)/common.h
+redir.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/filecntl.h
+redir.o: ${BASHINCDIR}/memalloc.h shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+redir.o: general.h xmalloc.h variables.h arrayfunc.h conftypes.h array.h hashlib.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h
+redir.o: dispose_cmd.h make_cmd.h subst.h sig.h pathnames.h externs.h 
+redir.o: flags.h execute_cmd.h redir.h input.h
+shell.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/filecntl.h
+shell.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+shell.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+shell.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+shell.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+shell.o: flags.h trap.h mailcheck.h builtins.h $(DEFSRC)/common.h
+shell.o: jobs.h siglist.h input.h execute_cmd.h findcmd.h bashhist.h
+shell.o: ${GLOB_LIBSRC}/strmatch.h ${BASHINCDIR}/posixtime.h
+sig.o: config.h bashtypes.h
+sig.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+sig.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+sig.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+sig.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+sig.o: jobs.h siglist.h trap.h $(DEFSRC)/common.h bashline.h bashhist.h
+siglist.o: config.h bashtypes.h siglist.h trap.h
+stringlib.o: bashtypes.h ${BASHINCDIR}/chartypes.h
+stringlib.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+stringlib.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+stringlib.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+stringlib.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+stringlib.o: ${GLOB_LIBSRC}/glob.h ${GLOB_LIBSRC}/strmatch.h
+subst.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/posixstat.h
+subst.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+subst.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+subst.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+subst.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+subst.o: flags.h jobs.h siglist.h execute_cmd.h ${BASHINCDIR}/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}/strmatch.h
+subst.o: ${BASHINCDIR}/chartypes.h
+subst.o: ${BASHINCDIR}/shmbutil.h
+test.o: bashtypes.h ${BASHINCDIR}/posixstat.h ${BASHINCDIR}/filecntl.h
+test.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+test.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+test.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+test.o: make_cmd.h subst.h sig.h pathnames.h externs.h test.h
+test.o: ${DEFSRC}/common.h 
+trap.o: config.h bashtypes.h trap.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+trap.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+trap.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+trap.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+trap.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+trap.o: signames.h $(DEFSRC)/common.h
+trap.o: ${DEFDIR}/builtext.h
+unwind_prot.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h command.h ${BASHINCDIR}/stdc.h
+unwind_prot.o: general.h xmalloc.h unwind_prot.h quit.h sig.h
+variables.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+variables.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+variables.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+variables.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+variables.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+variables.o: flags.h execute_cmd.h mailcheck.h input.h $(DEFSRC)/common.h
+variables.o: findcmd.h bashhist.h hashcmd.h pathexp.h
+variables.o: pcomplete.h  ${BASHINCDIR}/chartypes.h
+variables.o: ${BASHINCDIR}/posixtime.h
+version.o:  conftypes.h patchlevel.h version.h
+xmalloc.o: config.h bashtypes.h ${BASHINCDIR}/ansi_stdlib.h error.h
+
+# job control
+
+jobs.o: config.h bashtypes.h trap.h ${BASHINCDIR}/filecntl.h input.h ${BASHINCDIR}/shtty.h
+jobs.o: bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+jobs.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+jobs.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+jobs.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+jobs.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+jobs.o: jobs.h flags.h $(DEFSRC)/common.h $(DEFDIR)/builtext.h
+jobs.o: ${BASHINCDIR}/posixwait.h ${BASHINCDIR}/unionwait.h
+jobs.o: ${BASHINCDIR}/posixtime.h
+nojobs.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h bashjmp.h ${BASHINCDIR}/posixjmp.h
+nojobs.o: command.h ${BASHINCDIR}/stdc.h general.h xmalloc.h jobs.h quit.h siglist.h externs.h
+nojobs.o: sig.h error.h ${BASHINCDIR}/shtty.h input.h
+
+# shell features that may be compiled in
+
+array.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+array.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+array.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+array.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+array.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+array.o: $(DEFSRC)/common.h
+arrayfunc.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+arrayfunc.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+arrayfunc.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+arrayfunc.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+arrayfunc.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+arrayfunc.o: $(DEFSRC)/common.h
+arrayfunc.o: ${BASHINCDIR}/shmbutil.h
+braces.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+braces.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+braces.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+braces.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+braces.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+braces.o: ${BASHINCDIR}/shmbutil.h
+alias.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h command.h ${BASHINCDIR}/stdc.h
+alias.o: general.h xmalloc.h bashtypes.h externs.h alias.h
+alias.o: pcomplete.h 
+alias.o: ${BASHINCDIR}/chartypes.h
+
+pcomplib.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h bashtypes.h
+pcomplib.o: ${BASHINCDIR}/stdc.h hashlib.h pcomplete.h shell.h syntax.h
+pcomplib.o: bashjmp.h command.h general.h xmalloc.h error.h variables.h arrayfunc.h conftypes.h quit.h
+pcomplib.o: unwind_prot.h dispose_cmd.h make_cmd.h subst.h sig.h pathnames.h
+pcomplib.o: externs.h ${BASHINCDIR}/maxpath.h
+
+pcomplete.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h bashtypes.h
+pcomplete.o: ${BASHINCDIR}/stdc.h hashlib.h pcomplete.h shell.h syntax.h
+pcomplete.o: bashjmp.h command.h general.h xmalloc.h error.h variables.h arrayfunc.h conftypes.h quit.h
+pcomplete.o: unwind_prot.h dispose_cmd.h make_cmd.h subst.h sig.h pathnames.h
+pcomplete.o: externs.h ${BASHINCDIR}/maxpath.h execute_cmd.h 
+
+# library support files
+
+bashhist.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/posixstat.h
+bashhist.o: ${BASHINCDIR}/filecntl.h
+bashhist.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+bashhist.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+bashhist.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+bashhist.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+bashhist.o: flags.h input.h parser.h pathexp.h $(DEFSRC)/common.h bashline.h
+bashhist.o: $(GLOB_LIBSRC)/strmatch.h
+bashline.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+bashline.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+bashline.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+bashline.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+bashline.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+bashline.o: builtins.h bashhist.h bashline.h execute_cmd.h findcmd.h pathexp.h
+bashline.o: $(DEFSRC)/common.h $(GLOB_LIBSRC)/glob.h alias.h
+bashline.o: pcomplete.h ${BASHINCDIR}/chartypes.h input.h
+bracecomp.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+bracecomp.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+bracecomp.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
+bracecomp.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+bracecomp.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+bracecomp.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h command.h hashlib.h builtins.h general.h xmalloc.h
+bracecomp.o: quit.h alias.h config.h  variables.h arrayfunc.h conftypes.h
+bracecomp.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+
+# library dependencies
+
+bashline.o: $(RL_LIBSRC)/rlconf.h
+bashline.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/rlstdc.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 $(RL_LIBSRC)/rlstdc.h
+y.tab.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/chardefs.h
+y.tab.o: $(RL_LIBSRC)/readline.h $(RL_LIBSRC)/rlstdc.h
+subst.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/chardefs.h
+subst.o: $(RL_LIBSRC)/readline.h $(RL_LIBSRC)/rlstdc.h
+
+shell.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h
+subst.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h
+bashline.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h
+bashhist.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h
+y.tab.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h
+
+execute_cmd.o: $(TILDE_LIBSRC)/tilde.h
+general.o: $(TILDE_LIBSRC)/tilde.h
+mailcheck.o: $(TILDE_LIBSRC)/tilde.h
+shell.o: $(TILDE_LIBSRC)/tilde.h
+subst.o: $(TILDE_LIBSRC)/tilde.h
+variables.o: $(TILDE_LIBSRC)/tilde.h
+
+# libintl dependencies
+arrayfunc.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+bashhist.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+bashline.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+braces.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+error.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+eval.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+execute_cmd.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+expr.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+general.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+input.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+jobs.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+mailcheck.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+make_cmd.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+nojobs.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+parse.y: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+pcomplete.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+pcomplib.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+print_cmd.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+redir.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+shell.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+sig.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+siglist.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+subst.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+test.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+trap.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+variables.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+version.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+xmalloc.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+
+signames.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+
+# XXX - dependencies checked through here
+
+# builtin c sources
+builtins/bashgetopt.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+builtins/bashgetopt.o: shell.h syntax.h config.h bashjmp.h command.h general.h xmalloc.h error.h
+builtins/bashgetopt.o: variables.h arrayfunc.h conftypes.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+builtins/bashgetopt.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+builtins/bashgetopt.o: $(DEFSRC)/common.h
+builtins/bashgetopt.o: ${BASHINCDIR}/chartypes.h
+builtins/common.o: bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+builtins/common.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h command.h
+builtins/common.o: ${BASHINCDIR}/memalloc.h variables.h arrayfunc.h conftypes.h input.h siglist.h
+builtins/common.o: quit.h unwind_prot.h ${BASHINCDIR}/maxpath.h jobs.h builtins.h
+builtins/common.o: dispose_cmd.h make_cmd.h subst.h externs.h bashhist.h 
+builtins/common.o: execute_cmd.h ${BASHINCDIR}/stdc.h general.h xmalloc.h error.h pathnames.h
+builtins/common.o: ${DEFDIR}/builtext.h
+builtins/common.o: ${BASHINCDIR}/chartypes.h
+builtins/evalfile.o: bashtypes.h ${BASHINCDIR}/posixstat.h ${BASHINCDIR}/filecntl.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+builtins/evalfile.o: shell.h syntax.h config.h bashjmp.h command.h general.h xmalloc.h error.h
+builtins/evalfile.o: variables.h arrayfunc.h conftypes.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+builtins/evalfile.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+builtins/evalfile.o: jobs.h builtins.h flags.h input.h execute_cmd.h
+builtins/evalfile.o: bashhist.h $(DEFSRC)/common.h
+builtins/evalstring.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+builtins/evalstring.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h command.h siglist.h
+builtins/evalstring.o: ${BASHINCDIR}/memalloc.h variables.h arrayfunc.h conftypes.h input.h
+builtins/evalstring.o: quit.h unwind_prot.h ${BASHINCDIR}/maxpath.h jobs.h builtins.h
+builtins/evalstring.o: dispose_cmd.h make_cmd.h subst.h externs.h 
+builtins/evalstring.o: jobs.h builtins.h flags.h input.h execute_cmd.h
+builtins/evalstring.o: bashhist.h $(DEFSRC)/common.h
+builtins/getopt.o: config.h ${BASHINCDIR}/memalloc.h
+builtins/getopt.o: shell.h syntax.h bashjmp.h command.h general.h xmalloc.h error.h
+builtins/getopt.o: variables.h arrayfunc.h conftypes.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
+builtins/getopt.o: make_cmd.h subst.h sig.h pathnames.h externs.h 
+builtins/getopt.o: $(DEFSRC)/getopt.h
+builtins/mkbuiltins.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h ${BASHINCDIR}/filecntl.h
+builtins/mkbuiltins.o: bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+
+# builtin def files
+builtins/alias.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/alias.o: quit.h $(DEFSRC)/common.h
+builtins/alias.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h command.h ${BASHINCDIR}/stdc.h unwind_prot.h
+builtins/alias.o: dispose_cmd.h make_cmd.h subst.h externs.h variables.h arrayfunc.h conftypes.h 
+builtins/bind.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/bind.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/bind.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
+builtins/bind.o: $(DEFSRC)/bashgetopt.h
+builtins/break.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/break.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
+builtins/break.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/builtin.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/builtin.o: quit.h $(DEFSRC)/common.h $(DEFSRC)/bashgetopt.h
+builtins/builtin.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h 
+builtins/builtin.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/caller.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/caller.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
+builtins/caller.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/caller.o: $(DEFSRC)/common.h quit.h 
+builtins/caller.o: ${BASHINCDIR}/chartypes.h bashtypes.h
+builtins/caller.o: ${DEFDIR}/builtext.h
+builtins/cd.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/cd.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
+builtins/cd.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/cd.o: $(DEFSRC)/common.h quit.h 
+builtins/command.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/command.o: quit.h $(DEFSRC)/bashgetopt.h
+builtins/command.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h 
+builtins/command.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/declare.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/declare.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
+builtins/declare.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/declare.o: $(DEFSRC)/bashgetopt.h
+builtins/echo.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/echo.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
+builtins/echo.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/enable.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/enable.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
+builtins/enable.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/enable.o: pcomplete.h 
+builtins/eval.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/eval.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h 
+builtins/eval.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/exec.o: bashtypes.h 
+builtins/exec.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/exec.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
+builtins/exec.o: dispose_cmd.h make_cmd.h subst.h externs.h execute_cmd.h 
+builtins/exec.o: findcmd.h flags.h quit.h $(DEFSRC)/common.h ${BASHINCDIR}/stdc.h
+builtins/exit.o: bashtypes.h 
+builtins/exit.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/exit.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
+builtins/exit.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/fc.o: bashtypes.h ${BASHINCDIR}/posixstat.h
+builtins/fc.o: bashansi.h ${BASHINCDIR}/ansi_stdlib.h builtins.h command.h ${BASHINCDIR}/stdc.h 
+builtins/fc.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/fc.o: flags.h unwind_prot.h variables.h arrayfunc.h conftypes.h shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h 
+builtins/fc.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h quit.h 
+builtins/fc.o: $(DEFSRC)/bashgetopt.h bashhist.h
+builtins/fc.o: ${BASHINCDIR}/chartypes.h
+builtins/fg_bg.o: bashtypes.h $(DEFSRC)/bashgetopt.h 
+builtins/fg_bg.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/fg_bg.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
+builtins/fg_bg.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/getopts.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/getopts.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h 
+builtins/getopts.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/hash.o: bashtypes.h 
+builtins/hash.o: builtins.h command.h findcmd.h ${BASHINCDIR}/stdc.h $(DEFSRC)/common.h
+builtins/hash.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/hash.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h 
+builtins/help.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/help.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/help.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
+builtins/help.o: $(GLOB_LIBSRC)/glob.h 
+builtins/history.o: bashtypes.h 
+builtins/history.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/history.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/history.o: ${BASHINCDIR}/filecntl.h shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h
+builtins/history.o: bashhist.h variables.h arrayfunc.h conftypes.h 
+builtins/inlib.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/inlib.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h 
+builtins/inlib.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/jobs.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/jobs.o: quit.h $(DEFSRC)/bashgetopt.h
+builtins/jobs.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h 
+builtins/jobs.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/kill.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/kill.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/kill.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h trap.h unwind_prot.h variables.h arrayfunc.h conftypes.h 
+builtins/let.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/let.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/let.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h 
+builtins/printf.o: config.h ${BASHINCDIR}/memalloc.h bashjmp.h command.h error.h
+builtins/printf.o: general.h xmalloc.h quit.h dispose_cmd.h make_cmd.h subst.h
+builtins/printf.o: externs.h sig.h pathnames.h shell.h syntax.h unwind_prot.h
+builtins/printf.o: variables.h arrayfunc.h conftypes.h ${BASHINCDIR}/stdc.h $(DEFSRC)/bashgetopt.h
+builtins/printf.o: ${BASHINCDIR}/chartypes.h
+builtins/pushd.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/pushd.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/pushd.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
+builtins/pushd.o: $(DEFSRC)/common.h
+builtins/read.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/read.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/read.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h 
+builtins/return.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/return.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/return.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h 
+builtins/set.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/set.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/set.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h flags.h
+builtins/setattr.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/setattr.o: quit.h $(DEFSRC)/common.h $(DEFSRC)/bashgetopt.h
+builtins/setattr.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h 
+builtins/setattr.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/shift.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/shift.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/shift.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h 
+builtins/shift.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/shopt.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h
+builtins/shopt.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h
+builtins/shopt.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h unwind_prot.h variables.h arrayfunc.h conftypes.h ${BASHINCDIR}/maxpath.h
+builtins/shopt.o: $(DEFSRC)/common.h $(DEFSRC)/bashgetopt.h
+builtins/source.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/source.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/source.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
+builtins/source.o: findcmd.h $(DEFSRC)/bashgetopt.h flags.h trap.h
+builtins/suspend.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/suspend.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/suspend.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h 
+builtins/test.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/test.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/test.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h 
+builtins/test.o: test.h 
+builtins/times.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/times.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/times.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h 
+builtins/trap.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/trap.o: quit.h $(DEFSRC)/common.h
+builtins/trap.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h 
+builtins/trap.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/type.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/type.o: quit.h $(DEFSRC)/common.h findcmd.h
+builtins/type.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
+builtins/type.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/ulimit.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/ulimit.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/ulimit.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h 
+builtins/umask.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/umask.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/umask.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h 
+builtins/umask.o: ${BASHINCDIR}/chartypes.h
+builtins/wait.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
+builtins/wait.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/wait.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
+builtins/wait.o: ${BASHINCDIR}/chartypes.h
+
+builtins/complete.o: config.h shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h
+builtins/complete.o: unwind_prot.h variables.h arrayfunc.h conftypes.h
+builtins/complete.o: bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+builtins/complete.o: builtins.h 
+builtins/complete.o: pcomplete.h
+builtins/complete.o: ${DEFSRC}/common.h ${DEFSRC}/bashgetopt.h
+
+# libintl dependencies
+builtins/bind.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/break.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/caller.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/cd.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/common.c: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/complete.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/declare.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/enable.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/evalfile.c: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/exec.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/exit.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/fc.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/fg_bg.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/getopt.c: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/hash.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/help.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/history.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/inlib.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/jobs.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/kill.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/let.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/mkbuiltins.c: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/printf.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/pushd.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/read.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/return.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/set.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/setattr.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/shift.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/shopt.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/source.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/suspend.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/type.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/ulimit.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+builtins/umask.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+
+# builtin library dependencies
+builtins/bind.o: $(RL_LIBSRC)/chardefs.h $(RL_LIBSRC)/readline.h
+builtins/bind.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/rlstdc.h
+
+builtins/bind.o: $(HIST_LIBSRC)/history.h $(RL_LIBSRC)/rlstdc.h
+builtins/fc.o: $(HIST_LIBSRC)/history.h $(RL_LIBSRC)/rlstdc.h
+builtins/history.o: $(HIST_LIBSRC)/history.h $(RL_LIBSRC)/rlstdc.h
+
+builtins/common.o: $(TILDE_LIBSRC)/tilde.h
+builtins/cd.o: $(TILDE_LIBSRC)/tilde.h 
+
+builtins/alias.o: $(DEFSRC)/alias.def
+builtins/bind.o: $(DEFSRC)/bind.def
+builtins/break.o: $(DEFSRC)/break.def
+builtins/builtin.o: $(DEFSRC)/builtin.def
+builtins/caller.o: $(DEFSRC)/caller.def
+builtins/cd.o: $(DEFSRC)/cd.def
+builtins/colon.o: $(DEFSRC)/colon.def
+builtins/command.o: $(DEFSRC)/command.def
+builtins/complete.o: $(DEFSRC)/complete.def
+builtins/declare.o: $(DEFSRC)/declare.def
+builtins/echo.o: $(DEFSRC)/echo.def
+builtins/enable.o: $(DEFSRC)/enable.def
+builtins/eval.o: $(DEFSRC)/eval.def
+builtins/exec.o: $(DEFSRC)/exec.def
+builtins/exit.o: $(DEFSRC)/exit.def
+builtins/fc.o: $(DEFSRC)/fc.def
+builtins/fg_bg.o: $(DEFSRC)/fg_bg.def
+builtins/getopts.o: $(DEFSRC)/getopts.def
+builtins/hash.o: $(DEFSRC)/hash.def
+builtins/help.o: $(DEFSRC)/help.def
+builtins/history.o: $(DEFSRC)/history.def
+builtins/inlib.o: $(DEFSRC)/inlib.def
+builtins/jobs.o: $(DEFSRC)/jobs.def
+builtins/kill.o: $(DEFSRC)/kill.def
+builtins/let.o: $(DEFSRC)/let.def
+builtins/pushd.o: $(DEFSRC)/pushd.def
+builtins/read.o: $(DEFSRC)/read.def
+builtins/reserved.o: $(DEFSRC)/reserved.def
+builtins/return.o: $(DEFSRC)/return.def
+builtins/set.o: $(DEFSRC)/set.def
+builtins/setattr.o: $(DEFSRC)/setattr.def
+builtins/shift.o: $(DEFSRC)/shift.def
+builtins/shopt.o: $(DEFSRC)/shopt.def
+builtins/source.o: $(DEFSRC)/source.def
+builtins/suspend.o: $(DEFSRC)/suspend.def
+builtins/test.o: $(DEFSRC)/test.def
+builtins/times.o: $(DEFSRC)/times.def
+builtins/trap.o: $(DEFSRC)/trap.def
+builtins/type.o: $(DEFSRC)/type.def
+builtins/ulimit.o: $(DEFSRC)/ulimit.def
+builtins/umask.o: $(DEFSRC)/umask.def
+builtins/wait.o: $(DEFSRC)/wait.def
index e0360cfc28d2ea970977af207ed6409d910b302b..a5036e989f454d348f51a5c7f5094f91e83b1568 100644 (file)
@@ -215,7 +215,7 @@ AC_CACHE_VAL(bash_cv_sys_siglist,
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
-#ifndef SYS_SIGLIST_DECLARED
+#if !HAVE_DECL_SYS_SIGLIST
 extern char *sys_siglist[];
 #endif
 main()
index 04a6fceb6570c8d9f0a5d9b69aa35b2411c8ff40..e0360cfc28d2ea970977af207ed6409d910b302b 100644 (file)
@@ -1541,24 +1541,21 @@ AC_DEFUN(BASH_CHECK_DEV_FD,
 [AC_MSG_CHECKING(whether /dev/fd is available)
 AC_CACHE_VAL(bash_cv_dev_fd,
 [bash_cv_dev_fd=""
-if test -d /dev/fd  && test -r /dev/fd/0 < /dev/null; then
+if test -d /dev/fd  && (exec test -r /dev/fd/0 < /dev/null) ; then
 # check for systems like FreeBSD 5 that only provide /dev/fd/[012]
-   exec 3</dev/null
-   if test -r /dev/fd/3; then
+   if (exec test -r /dev/fd/3 3</dev/null) ; then
      bash_cv_dev_fd=standard
    else
      bash_cv_dev_fd=absent
    fi
-   exec 3<&-
 fi
 if test -z "$bash_cv_dev_fd" ; then 
-  if test -d /proc/self/fd && test -r /proc/self/fd/0 < /dev/null; then
+  if test -d /proc/self/fd && (exec test -r /proc/self/fd/0 < /dev/null) ; then
     bash_cv_dev_fd=whacky
   else
     bash_cv_dev_fd=absent
   fi
 fi
-set +x
 ])
 AC_MSG_RESULT($bash_cv_dev_fd)
 if test $bash_cv_dev_fd = "standard"; then
@@ -1573,9 +1570,9 @@ fi
 AC_DEFUN(BASH_CHECK_DEV_STDIN,
 [AC_MSG_CHECKING(whether /dev/stdin stdout stderr are available)
 AC_CACHE_VAL(bash_cv_dev_stdin,
-[if test -d /dev/fd && test -r /dev/stdin < /dev/null; then
+[if test -d /dev/fd && (exec test -r /dev/stdin < /dev/null) ; then
    bash_cv_dev_stdin=present
- elif test -d /proc/self/fd && test -r /dev/stdin < /dev/null; then
+ elif test -d /proc/self/fd && (exec test -r /dev/stdin < /dev/null) ; then
    bash_cv_dev_stdin=present
  else
    bash_cv_dev_stdin=absent
@@ -2367,7 +2364,7 @@ AC_DEFUN([AM_INTL_SUBDIR],
   AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h stddef.h \
 stdlib.h string.h unistd.h sys/param.h])
   AC_CHECK_FUNCS([feof_unlocked fgets_unlocked getc_unlocked getcwd getegid \
-geteuid getgid getuid mempcpy munmap putenv setenv setlocale stpcpy \
+geteuid getgid getuid mempcpy munmap putenv setenv setlocale localeconv stpcpy \
 strcasecmp strdup strtoul tsearch __argz_count __argz_stringify __argz_next \
 __fsetlocking])
 
index 48a099dde0ee1676f7495281aa2d3c1287eb24dd..7a6904d99168f10c3fa322251d3ada684c476a60 100644 (file)
@@ -45,7 +45,7 @@ static void quote_array_assignment_chars __P((WORD_LIST *));
 static char *array_value_internal __P((char *, int, int, int *));
 
 /* Standard error message to use when encountering an invalid array subscript */
-char *bash_badsub_errmsg = N_("bad array subscript");
+const char * const bash_badsub_errmsg = N_("bad array subscript");
 
 /* **************************************************************** */
 /*                                                                 */
diff --git a/arrayfunc.c~ b/arrayfunc.c~
new file mode 100644 (file)
index 0000000..48a099d
--- /dev/null
@@ -0,0 +1,837 @@
+/* arrayfunc.c -- High-level array functions used by other parts of the shell. */
+
+/* Copyright (C) 2001-2006 Free Software Foundation, Inc.
+
+   This file is part of GNU Bash, the Bourne Again SHell.
+
+   Bash is free software; you can redistribute it and/or modify it under
+   the terms of the GNU General Public License as published by the Free
+   Software Foundation; either version 2, or (at your option) any later
+   version.
+
+   Bash is distributed in the hope that it will be useful, but WITHOUT ANY
+   WARRANTY; without even the implied warranty of MERCHANTABILITY or
+   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+   for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with Bash; see the file COPYING.  If not, write to the Free Software
+   Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+#include "config.h"
+
+#if defined (ARRAY_VARS)
+
+#if defined (HAVE_UNISTD_H)
+#  include <unistd.h>
+#endif
+#include <stdio.h>
+
+#include "bashintl.h"
+
+#include "shell.h"
+
+#include "shmbutil.h"
+
+#include "builtins/common.h"
+
+extern char *this_command_name;
+extern int last_command_exit_value;
+extern int array_needs_making;
+
+static SHELL_VAR *bind_array_var_internal __P((SHELL_VAR *, arrayind_t, char *, int));
+
+static void quote_array_assignment_chars __P((WORD_LIST *));
+static char *array_value_internal __P((char *, int, int, int *));
+
+/* Standard error message to use when encountering an invalid array subscript */
+char *bash_badsub_errmsg = N_("bad array subscript");
+
+/* **************************************************************** */
+/*                                                                 */
+/*  Functions to manipulate array variables and perform assignments */
+/*                                                                 */
+/* **************************************************************** */
+
+/* Convert a shell variable to an array variable.  The original value is
+   saved as array[0]. */
+SHELL_VAR *
+convert_var_to_array (var)
+     SHELL_VAR *var;
+{
+  char *oldval;
+  ARRAY *array;
+
+  oldval = value_cell (var);
+  array = array_create ();
+  if (oldval)
+    array_insert (array, 0, oldval);
+
+  FREE (value_cell (var));
+  var_setarray (var, array);
+
+  /* these aren't valid anymore */
+  var->dynamic_value = (sh_var_value_func_t *)NULL;
+  var->assign_func = (sh_var_assign_func_t *)NULL;
+
+  INVALIDATE_EXPORTSTR (var);
+  if (exported_p (var))
+    array_needs_making++;
+
+  VSETATTR (var, att_array);
+  VUNSETATTR (var, att_invisible);
+
+  return var;
+}
+
+static SHELL_VAR *
+bind_array_var_internal (entry, ind, value, flags)
+     SHELL_VAR *entry;
+     arrayind_t ind;
+     char *value;
+     int flags;
+{
+  SHELL_VAR *dentry;
+  char *newval;
+
+  /* If we're appending, we need the old value of the array reference, so
+     fake out make_variable_value with a dummy SHELL_VAR */
+  if (flags & ASS_APPEND)
+    {
+      dentry = (SHELL_VAR *)xmalloc (sizeof (SHELL_VAR));
+      dentry->name = savestring (entry->name);
+      newval = array_reference (array_cell (entry), ind);
+      if (newval)
+       dentry->value = savestring (newval);
+      else
+       {
+         dentry->value = (char *)xmalloc (1);
+         dentry->value[0] = '\0';
+       }
+      dentry->exportstr = 0;
+      dentry->attributes = entry->attributes & ~(att_array|att_exported);
+      /* Leave the rest of the members uninitialized; the code doesn't look
+        at them. */
+      newval = make_variable_value (dentry, value, flags);      
+      dispose_variable (dentry);
+    }
+  else
+    newval = make_variable_value (entry, value, flags);
+
+  if (entry->assign_func)
+    (*entry->assign_func) (entry, newval, ind);
+  else
+    array_insert (array_cell (entry), ind, newval);
+  FREE (newval);
+
+  return (entry);
+}
+
+/* Perform an array assignment name[ind]=value.  If NAME already exists and
+   is not an array, and IND is 0, perform name=value instead.  If NAME exists
+   and is not an array, and IND is not 0, convert it into an array with the
+   existing value as name[0].
+
+   If NAME does not exist, just create an array variable, no matter what
+   IND's value may be. */
+SHELL_VAR *
+bind_array_variable (name, ind, value, flags)
+     char *name;
+     arrayind_t ind;
+     char *value;
+     int flags;
+{
+  SHELL_VAR *entry;
+
+  entry = var_lookup (name, shell_variables);
+
+  if (entry == (SHELL_VAR *) 0)
+    entry = make_new_array_variable (name);
+  else if (readonly_p (entry) || noassign_p (entry))
+    {
+      if (readonly_p (entry))
+       err_readonly (name);
+      return (entry);
+    }
+  else if (array_p (entry) == 0)
+    entry = convert_var_to_array (entry);
+
+  /* ENTRY is an array variable, and ARRAY points to the value. */
+  return (bind_array_var_internal (entry, ind, value, flags));
+}
+
+/* Parse NAME, a lhs of an assignment statement of the form v[s], and
+   assign VALUE to that array element by calling bind_array_variable(). */
+SHELL_VAR *
+assign_array_element (name, value, flags)
+     char *name, *value;
+     int flags;
+{
+  char *sub, *vname;
+  arrayind_t ind;
+  int sublen;
+  SHELL_VAR *entry;
+
+  vname = array_variable_name (name, &sub, &sublen);
+
+  if (vname == 0)
+    return ((SHELL_VAR *)NULL);
+
+  if ((ALL_ELEMENT_SUB (sub[0]) && sub[1] == ']') || (sublen <= 1))
+    {
+      free (vname);
+      err_badarraysub (name);
+      return ((SHELL_VAR *)NULL);
+    }
+
+  ind = array_expand_index (sub, sublen);
+  if (ind < 0)
+    {
+      free (vname);
+      err_badarraysub (name);
+      return ((SHELL_VAR *)NULL);
+    }
+
+  entry = bind_array_variable (vname, ind, value, flags);
+
+  free (vname);
+  return (entry);
+}
+
+/* Find the array variable corresponding to NAME.  If there is no variable,
+   create a new array variable.  If the variable exists but is not an array,
+   convert it to an indexed array.  If CHECK_FLAGS is non-zero, an existing
+   variable is checked for the readonly or noassign attribute in preparation
+   for assignment (e.g., by the `read' builtin). */
+SHELL_VAR *
+find_or_make_array_variable (name, check_flags)
+     char *name;
+     int check_flags;
+{
+  SHELL_VAR *var;
+
+  var = find_variable (name);
+
+  if (var == 0)
+    var = make_new_array_variable (name);
+  else if (check_flags && (readonly_p (var) || noassign_p (var)))
+    {
+      if (readonly_p (var))
+       err_readonly (name);
+      return ((SHELL_VAR *)NULL);
+    }
+  else if (array_p (var) == 0)
+    var = convert_var_to_array (var);
+
+  return (var);
+}
+  
+/* Perform a compound assignment statement for array NAME, where VALUE is
+   the text between the parens:  NAME=( VALUE ) */
+SHELL_VAR *
+assign_array_from_string (name, value, flags)
+     char *name, *value;
+     int flags;
+{
+  SHELL_VAR *var;
+
+  var = find_or_make_array_variable (name, 1);
+  if (var == 0)
+    return ((SHELL_VAR *)NULL);
+
+  return (assign_array_var_from_string (var, value, flags));
+}
+
+/* Sequentially assign the indices of indexed array variable VAR from the
+   words in LIST. */
+SHELL_VAR *
+assign_array_var_from_word_list (var, list, flags)
+     SHELL_VAR *var;
+     WORD_LIST *list;
+     int flags;
+{
+  register arrayind_t i;
+  register WORD_LIST *l;
+  ARRAY *a;
+
+  a = array_cell (var);
+  i = (flags & ASS_APPEND) ? array_max_index (a) + 1 : 0;
+
+  for (l = list; l; l = l->next, i++)
+    if (var->assign_func)
+      (*var->assign_func) (var, l->word->word, i);
+    else
+      array_insert (a, i, l->word->word);
+  return var;
+}
+
+WORD_LIST *
+expand_compound_array_assignment (value, flags)
+     char *value;
+     int flags;
+{
+  WORD_LIST *list, *nlist;
+  char *val;
+  int ni;
+
+  /* I don't believe this condition is ever true any more. */
+  if (*value == '(')   /*)*/
+    {
+      ni = 1;
+      val = extract_array_assignment_list (value, &ni);
+      if (val == 0)
+       return (WORD_LIST *)NULL;
+    }
+  else
+    val = value;
+
+  /* Expand the value string into a list of words, performing all the
+     shell expansions including pathname generation and word splitting. */
+  /* First we split the string on whitespace, using the shell parser
+     (ksh93 seems to do this). */
+  list = parse_string_to_word_list (val, 1, "array assign");
+
+  /* If we're using [subscript]=value, we need to quote each [ and ] to
+     prevent unwanted filename expansion. */
+  if (list)
+    quote_array_assignment_chars (list);
+
+  /* Now that we've split it, perform the shell expansions on each
+     word in the list. */
+  nlist = list ? expand_words_no_vars (list) : (WORD_LIST *)NULL;
+
+  dispose_words (list);
+
+  if (val != value)
+    free (val);
+
+  return nlist;
+}
+
+void
+assign_compound_array_list (var, nlist, flags)
+     SHELL_VAR *var;
+     WORD_LIST *nlist;
+     int flags;
+{
+  ARRAY *a;
+  WORD_LIST *list;
+  char *w, *val, *nval;
+  int len, iflags;
+  arrayind_t ind, last_ind;
+
+  a = array_cell (var);
+
+  /* Now that we are ready to assign values to the array, kill the existing
+     value. */
+  if (a && (flags & ASS_APPEND) == 0)
+    array_flush (a);
+  last_ind = (flags & ASS_APPEND) ? array_max_index (a) + 1 : 0;
+
+  for (list = nlist; list; list = list->next)
+    {
+      iflags = flags;
+      w = list->word->word;
+
+      /* We have a word of the form [ind]=value */
+      if ((list->word->flags & W_ASSIGNMENT) && w[0] == '[')
+       {
+         len = skipsubscript (w, 0);
+
+         /* XXX - changes for `+=' */
+         if (w[len] != ']' || (w[len+1] != '=' && (w[len+1] != '+' || w[len+2] != '=')))
+           {
+             nval = make_variable_value (var, w, flags);
+             if (var->assign_func)
+               (*var->assign_func) (var, nval, last_ind);
+             else
+               array_insert (a, last_ind, nval);
+             FREE (nval);
+             last_ind++;
+             continue;
+           }
+
+         if (len == 1)
+           {
+             err_badarraysub (w);
+             continue;
+           }
+
+         if (ALL_ELEMENT_SUB (w[1]) && len == 2)
+           {
+             report_error (_("%s: cannot assign to non-numeric index"), w);
+             continue;
+           }
+
+         ind = array_expand_index (w + 1, len);
+         if (ind < 0)
+           {
+             err_badarraysub (w);
+             continue;
+           }
+         last_ind = ind;
+         /* XXX - changes for `+=' -- just accept the syntax.  ksh93 doesn't do this */
+         if (w[len + 1] == '+' && w[len + 2] == '=')
+           {
+             iflags |= ASS_APPEND;
+             val = w + len + 3;
+           }
+         else
+           val = w + len + 2;
+       }
+      else             /* No [ind]=value, just a stray `=' */
+       {
+         ind = last_ind;
+         val = w;
+       }
+
+      if (integer_p (var))
+       this_command_name = (char *)NULL;       /* no command name for errors */
+      bind_array_var_internal (var, ind, val, iflags);
+      last_ind++;
+    }
+}
+
+/* Perform a compound array assignment:  VAR->name=( VALUE ).  The
+   VALUE has already had the parentheses stripped. */
+SHELL_VAR *
+assign_array_var_from_string (var, value, flags)
+     SHELL_VAR *var;
+     char *value;
+     int flags;
+{
+  WORD_LIST *nlist;
+
+  if (value == 0)
+    return var;
+
+  nlist = expand_compound_array_assignment (value, flags);
+  assign_compound_array_list (var, nlist, flags);
+
+  if (nlist)
+    dispose_words (nlist);
+  return (var);
+}
+
+/* For each word in a compound array assignment, if the word looks like
+   [ind]=value, quote the `[' and `]' before the `=' to protect them from
+   unwanted filename expansion. */
+static void
+quote_array_assignment_chars (list)
+     WORD_LIST *list;
+{
+  char *s, *t, *nword;
+  int saw_eq;
+  WORD_LIST *l;
+
+  for (l = list; l; l = l->next)
+    {
+      if (l->word == 0 || l->word->word == 0 || l->word->word[0] == '\0')
+       continue;       /* should not happen, but just in case... */
+      /* Don't bother if it doesn't look like [ind]=value */
+      if (l->word->word[0] != '[' || xstrchr (l->word->word, '=') == 0) /* ] */
+       continue;
+      s = nword = (char *)xmalloc (strlen (l->word->word) * 2 + 1);
+      saw_eq = 0;
+      for (t = l->word->word; *t; )
+       {
+         if (*t == '=')
+           saw_eq = 1;
+         if (saw_eq == 0 && (*t == '[' || *t == ']'))
+           *s++ = '\\';
+         *s++ = *t++;
+       }
+      *s = '\0';
+      free (l->word->word);
+      l->word->word = nword;
+    }
+}
+
+/* This function assumes s[i] == '['; returns with s[ret] == ']' if
+   an array subscript is correctly parsed. */
+int
+skipsubscript (s, i)
+     const char *s;
+     int i;
+{
+  int count, c;
+#if defined (HANDLE_MULTIBYTE)
+  mbstate_t state, state_bak;
+  size_t slength, mblength;
+#endif
+
+#if defined (HANDLE_MULTIBYTE)
+  memset (&state, '\0', sizeof (mbstate_t));
+  slength = strlen (s + i);
+#endif
+  
+  count = 1;
+  while (count)
+    {
+      /* Advance one (possibly multibyte) character in S starting at I. */
+#if defined (HANDLE_MULTIBYTE)
+      if (MB_CUR_MAX > 1)
+       {
+         state_bak = state;
+         mblength = mbrlen (s + i, slength, &state);
+
+         if (MB_INVALIDCH (mblength))
+           {
+             state = state_bak;
+             i++;
+             slength--;
+           }
+         else if (MB_NULLWCH (mblength))
+           return i;
+         else
+           {
+             i += mblength;
+             slength -= mblength;
+           }
+       }
+      else
+#endif
+      ++i;
+
+      c = s[i];
+
+      if (c == 0)
+        break;
+      else if (c == '[')
+       count++;
+      else if (c == ']')
+       count--;
+    }
+
+  return i;
+}
+
+/* This function is called with SUB pointing to just after the beginning
+   `[' of an array subscript and removes the array element to which SUB
+   expands from array VAR.  A subscript of `*' or `@' unsets the array. */
+int
+unbind_array_element (var, sub)
+     SHELL_VAR *var;
+     char *sub;
+{
+  int len;
+  arrayind_t ind;
+  ARRAY_ELEMENT *ae;
+
+  len = skipsubscript (sub, 0);
+  if (sub[len] != ']' || len == 0)
+    {
+      builtin_error ("%s[%s: %s", var->name, sub, _(bash_badsub_errmsg));
+      return -1;
+    }
+  sub[len] = '\0';
+
+  if (ALL_ELEMENT_SUB (sub[0]) && sub[1] == 0)
+    {
+      unbind_variable (var->name);
+      return (0);
+    }
+  ind = array_expand_index (sub, len+1);
+  if (ind < 0)
+    {
+      builtin_error ("[%s]: %s", sub, _(bash_badsub_errmsg));
+      return -1;
+    }
+  ae = array_remove (array_cell (var), ind);
+  if (ae)
+    array_dispose_element (ae);
+  return 0;
+}
+
+/* Format and output an array assignment in compound form VAR=(VALUES),
+   suitable for re-use as input. */
+void
+print_array_assignment (var, quoted)
+     SHELL_VAR *var;
+     int quoted;
+{
+  char *vstr;
+
+  vstr = array_to_assign (array_cell (var), quoted);
+
+  if (vstr == 0)
+    printf ("%s=%s\n", var->name, quoted ? "'()'" : "()");
+  else
+    {
+      printf ("%s=%s\n", var->name, vstr);
+      free (vstr);
+    }
+}
+
+/***********************************************************************/
+/*                                                                    */
+/* Utility functions to manage arrays and their contents for expansion */
+/*                                                                    */
+/***********************************************************************/
+
+/* Return 1 if NAME is a properly-formed array reference v[sub]. */
+int
+valid_array_reference (name)
+     char *name;
+{
+  char *t;
+  int r, len;
+
+  t = xstrchr (name, '[');     /* ] */
+  if (t)
+    {
+      *t = '\0';
+      r = legal_identifier (name);
+      *t = '[';
+      if (r == 0)
+       return 0;
+      /* Check for a properly-terminated non-blank subscript. */
+      len = skipsubscript (t, 0);
+      if (t[len] != ']' || len == 1)
+       return 0;
+      for (r = 1; r < len; r++)
+       if (whitespace (t[r]) == 0)
+         return 1;
+      return 0;
+    }
+  return 0;
+}
+
+/* Expand the array index beginning at S and extending LEN characters. */
+arrayind_t
+array_expand_index (s, len)
+     char *s;
+     int len;
+{
+  char *exp, *t;
+  int expok;
+  arrayind_t val;
+
+  exp = (char *)xmalloc (len);
+  strncpy (exp, s, len - 1);
+  exp[len - 1] = '\0';
+  t = expand_arith_string (exp, 0);
+  this_command_name = (char *)NULL;
+  val = evalexp (t, &expok);
+  free (t);
+  free (exp);
+  if (expok == 0)
+    {
+      last_command_exit_value = EXECUTION_FAILURE;
+      jump_to_top_level (DISCARD);
+    }
+  return val;
+}
+
+/* Return the name of the variable specified by S without any subscript.
+   If SUBP is non-null, return a pointer to the start of the subscript
+   in *SUBP. If LENP is non-null, the length of the subscript is returned
+   in *LENP.  This returns newly-allocated memory. */
+char *
+array_variable_name (s, subp, lenp)
+     char *s, **subp;
+     int *lenp;
+{
+  char *t, *ret;
+  int ind, ni;
+
+  t = xstrchr (s, '[');
+  if (t == 0)
+    {
+      if (subp)
+       *subp = t;
+      if (lenp)
+       *lenp = 0;
+      return ((char *)NULL);
+    }
+  ind = t - s;
+  ni = skipsubscript (s, ind);
+  if (ni <= ind + 1 || s[ni] != ']')
+    {
+      err_badarraysub (s);
+      if (subp)
+       *subp = t;
+      if (lenp)
+       *lenp = 0;
+      return ((char *)NULL);
+    }
+
+  *t = '\0';
+  ret = savestring (s);
+  *t++ = '[';          /* ] */
+
+  if (subp)
+    *subp = t;
+  if (lenp)
+    *lenp = ni - ind;
+
+  return ret;
+}
+
+/* Return the variable specified by S without any subscript.  If SUBP is
+   non-null, return a pointer to the start of the subscript in *SUBP.
+   If LENP is non-null, the length of the subscript is returned in *LENP. */
+SHELL_VAR *
+array_variable_part (s, subp, lenp)
+     char *s, **subp;
+     int *lenp;
+{
+  char *t;
+  SHELL_VAR *var;
+
+  t = array_variable_name (s, subp, lenp);
+  if (t == 0)
+    return ((SHELL_VAR *)NULL);
+  var = find_variable (t);
+
+  free (t);
+  return (var == 0 || invisible_p (var)) ? (SHELL_VAR *)0 : var;
+}
+
+/* Return a string containing the elements in the array and subscript
+   described by S.  If the subscript is * or @, obeys quoting rules akin
+   to the expansion of $* and $@ including double quoting.  If RTYPE
+   is non-null it gets 1 if the array reference is name[@] or name[*]
+   and 0 otherwise. */
+static char *
+array_value_internal (s, quoted, allow_all, rtype)
+     char *s;
+     int quoted, allow_all, *rtype;
+{
+  int len;
+  arrayind_t ind;
+  char *retval, *t, *temp;
+  WORD_LIST *l;
+  SHELL_VAR *var;
+
+  var = array_variable_part (s, &t, &len);
+
+  /* Expand the index, even if the variable doesn't exist, in case side
+     effects are needed, like ${w[i++]} where w is unset. */
+#if 0
+  if (var == 0)
+    return (char *)NULL;
+#endif
+
+  if (len == 0)
+    return ((char *)NULL);     /* error message already printed */
+
+  /* [ */
+  if (ALL_ELEMENT_SUB (t[0]) && t[1] == ']')
+    {
+      if (rtype)
+       *rtype = 1;
+      if (allow_all == 0)
+       {
+         err_badarraysub (s);
+         return ((char *)NULL);
+       }
+      else if (var == 0 || value_cell (var) == 0)
+       return ((char *)NULL);
+      else if (array_p (var) == 0)
+       l = add_string_to_list (value_cell (var), (WORD_LIST *)NULL);
+      else
+       {
+         l = array_to_word_list (array_cell (var));
+         if (l == (WORD_LIST *)NULL)
+           return ((char *) NULL);
+       }
+
+      if (t[0] == '*' && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)))
+       {
+         temp = string_list_dollar_star (l);
+         retval = quote_string (temp);
+         free (temp);
+       }
+      else     /* ${name[@]} or unquoted ${name[*]} */
+       retval = string_list_dollar_at (l, quoted);
+
+      dispose_words (l);
+    }
+  else
+    {
+      if (rtype)
+       *rtype = 0;
+      ind = array_expand_index (t, len);
+      if (ind < 0)
+       {
+         if (var)
+           err_badarraysub (var->name);
+         else
+           {
+             t[-1] = '\0';
+             err_badarraysub (s);
+             t[-1] = '[';      /* ] */
+           }
+         return ((char *)NULL);
+       }
+      if (var == 0)
+       return ((char *)NULL);
+      if (array_p (var) == 0)
+       return (ind == 0 ? value_cell (var) : (char *)NULL);
+      retval = array_reference (array_cell (var), ind);
+    }
+
+  return retval;
+}
+
+/* Return a string containing the elements described by the array and
+   subscript contained in S, obeying quoting for subscripts * and @. */
+char *
+array_value (s, quoted, rtype)
+     char *s;
+     int quoted, *rtype;
+{
+  return (array_value_internal (s, quoted, 1, rtype));
+}
+
+/* Return the value of the array indexing expression S as a single string.
+   If ALLOW_ALL is 0, do not allow `@' and `*' subscripts.  This is used
+   by other parts of the shell such as the arithmetic expression evaluator
+   in expr.c. */
+char *
+get_array_value (s, allow_all, rtype)
+     char *s;
+     int allow_all, *rtype;
+{
+  return (array_value_internal (s, 0, allow_all, rtype));
+}
+
+char *
+array_keys (s, quoted)
+     char *s;
+     int quoted;
+{
+  int len;
+  char *retval, *t, *temp;
+  WORD_LIST *l;
+  SHELL_VAR *var;
+
+  var = array_variable_part (s, &t, &len);
+
+  /* [ */
+  if (var == 0 || ALL_ELEMENT_SUB (t[0]) == 0 || t[1] != ']')
+    return (char *)NULL;
+
+  if (array_p (var) == 0)
+    l = add_string_to_list ("0", (WORD_LIST *)NULL);
+  else
+    {
+      l = array_keys_to_word_list (array_cell (var));
+      if (l == (WORD_LIST *)NULL)
+        return ((char *) NULL);
+    }
+
+  if (t[0] == '*' && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)))
+    {
+      temp = string_list_dollar_star (l);
+      retval = quote_string (temp);
+      free (temp);
+    }
+  else /* ${!name[@]} or unquoted ${!name[*]} */
+    retval = string_list_dollar_at (l, quoted);
+
+  dispose_words (l);
+  return retval;
+}
+#endif /* ARRAY_VARS */
index b02899339297791fc1285753f09c1423c6076274..7c55b7425e4da33961b72e0d539bd45a8e8852c4 100644 (file)
@@ -1,5 +1,5 @@
 @%:@! /bin/sh
-@%:@ From configure.in for Bash 3.2, version 3.190.
+@%:@ From configure.in for Bash 3.2, version 3.193.
 @%:@ Guess values for system-dependent variables and create Makefiles.
 @%:@ Generated by GNU Autoconf 2.59 for bash 3.2-maint.
 @%:@
@@ -1693,7 +1693,7 @@ if test "$opt_curses" = yes; then
 fi
 
 if test -z "${DEBUGGER_START_FILE}"; then
-       DEBUGGER_START_FILE=${ac_default_prefix}/share/bashdb/bashdb-main.inc
+       DEBUGGER_START_FILE='${datadir}/bashdb/bashdb-main.inc'
 fi
 
 opt_minimal_config=no
@@ -23402,7 +23402,7 @@ cat >>conftest.$ac_ext <<_ACEOF
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
-#ifndef SYS_SIGLIST_DECLARED
+#if !HAVE_DECL_SYS_SIGLIST
 extern char *sys_siglist[];
 #endif
 main()
@@ -27177,24 +27177,21 @@ if test "${bash_cv_dev_fd+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   bash_cv_dev_fd=""
-if test -d /dev/fd  && test -r /dev/fd/0 < /dev/null; then
+if test -d /dev/fd  && (exec test -r /dev/fd/0 < /dev/null) ; then
 # check for systems like FreeBSD 5 that only provide /dev/fd/[012]
-   exec 3</dev/null
-   if test -r /dev/fd/3; then
+   if (exec test -r /dev/fd/3 3</dev/null) ; then
      bash_cv_dev_fd=standard
    else
      bash_cv_dev_fd=absent
    fi
-   exec 3<&-
 fi
 if test -z "$bash_cv_dev_fd" ; then 
-  if test -d /proc/self/fd && test -r /proc/self/fd/0 < /dev/null; then
+  if test -d /proc/self/fd && (exec test -r /proc/self/fd/0 < /dev/null) ; then
     bash_cv_dev_fd=whacky
   else
     bash_cv_dev_fd=absent
   fi
 fi
-set +x
 
 fi
 
@@ -27225,9 +27222,9 @@ echo $ECHO_N "checking whether /dev/stdin stdout stderr are available... $ECHO_C
 if test "${bash_cv_dev_stdin+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  if test -d /dev/fd && test -r /dev/stdin < /dev/null; then
+  if test -d /dev/fd && (exec test -r /dev/stdin < /dev/null) ; then
    bash_cv_dev_stdin=present
- elif test -d /proc/self/fd && test -r /dev/stdin < /dev/null; then
+ elif test -d /proc/self/fd && (exec test -r /dev/stdin < /dev/null) ; then
    bash_cv_dev_stdin=present
  else
    bash_cv_dev_stdin=absent
@@ -27429,7 +27426,7 @@ esac
 #AC_SUBST(ALLOCA_SOURCE)
 #AC_SUBST(ALLOCA_OBJECT)
 
-                                                                                                                                                      ac_config_files="$ac_config_files Makefile builtins/Makefile lib/readline/Makefile lib/glob/Makefile lib/intl/Makefile lib/malloc/Makefile lib/sh/Makefile lib/termcap/Makefile lib/tilde/Makefile doc/Makefile support/Makefile po/Makefile.in examples/loadables/Makefile examples/loadables/perl/Makefile pathnames.h"
+                                                                                                                                            ac_config_files="$ac_config_files Makefile builtins/Makefile lib/readline/Makefile lib/glob/Makefile lib/intl/Makefile lib/malloc/Makefile lib/sh/Makefile lib/termcap/Makefile lib/tilde/Makefile doc/Makefile support/Makefile po/Makefile.in examples/loadables/Makefile examples/loadables/perl/Makefile"
           ac_config_commands="$ac_config_commands default"
 cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
@@ -27986,7 +27983,6 @@ do
   "po/Makefile.in" ) CONFIG_FILES="$CONFIG_FILES po/Makefile.in" ;;
   "examples/loadables/Makefile" ) CONFIG_FILES="$CONFIG_FILES examples/loadables/Makefile" ;;
   "examples/loadables/perl/Makefile" ) CONFIG_FILES="$CONFIG_FILES examples/loadables/perl/Makefile" ;;
-  "pathnames.h" ) CONFIG_FILES="$CONFIG_FILES pathnames.h" ;;
   "default-1" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default-1" ;;
   "default" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;;
   "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
index 84e4075e3c65875aa1f7dcc2ad2003258d75c6bc..1175d795fb23762565fa8dfdcb651ceab89c10db 100644 (file)
                       {
                         'm4_pattern_forbid' => 1,
                         'AC_CONFIG_LIBOBJ_DIR' => 1,
+                        'AC_TYPE_OFF_T' => 1,
                         'AC_C_VOLATILE' => 1,
+                        'AC_FUNC_CLOSEDIR_VOID' => 1,
+                        'AC_REPLACE_FNMATCH' => 1,
+                        'AC_PROG_LIBTOOL' => 1,
+                        'AC_FUNC_STAT' => 1,
+                        'AC_FUNC_WAIT3' => 1,
+                        'AC_HEADER_TIME' => 1,
+                        'AM_AUTOMAKE_VERSION' => 1,
+                        'AC_STRUCT_TM' => 1,
+                        'AC_FUNC_LSTAT' => 1,
+                        'AC_FUNC_GETMNTENT' => 1,
+                        'AC_TYPE_MODE_T' => 1,
+                        'AC_FUNC_STRTOD' => 1,
+                        'AC_CHECK_HEADERS' => 1,
+                        'AC_FUNC_STRNLEN' => 1,
+                        'm4_sinclude' => 1,
+                        'AC_PROG_CXX' => 1,
+                        'AC_PATH_X' => 1,
+                        'AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK' => 1,
+                        'AC_PROG_AWK' => 1,
+                        '_m4_warn' => 1,
+                        'AC_HEADER_STDC' => 1,
+                        'AC_HEADER_MAJOR' => 1,
+                        'AC_FUNC_ERROR_AT_LINE' => 1,
+                        'AC_PROG_GCC_TRADITIONAL' => 1,
+                        'AC_LIBSOURCE' => 1,
+                        'AC_FUNC_MBRTOWC' => 1,
+                        'AC_STRUCT_ST_BLOCKS' => 1,
+                        'AC_TYPE_SIGNAL' => 1,
+                        'AC_TYPE_UID_T' => 1,
+                        'AC_PROG_MAKE_SET' => 1,
+                        'AC_CONFIG_AUX_DIR' => 1,
+                        'm4_pattern_allow' => 1,
+                        'sinclude' => 1,
+                        'AC_DEFINE_TRACE_LITERAL' => 1,
+                        'AC_FUNC_STRERROR_R' => 1,
+                        'AC_PROG_CC' => 1,
+                        'AC_DECL_SYS_SIGLIST' => 1,
+                        'AC_FUNC_FORK' => 1,
+                        'AC_FUNC_STRCOLL' => 1,
+                        'AC_FUNC_VPRINTF' => 1,
+                        'AC_PROG_YACC' => 1,
+                        'AC_INIT' => 1,
+                        'AC_STRUCT_TIMEZONE' => 1,
+                        'AC_FUNC_CHOWN' => 1,
+                        'AC_SUBST' => 1,
+                        'AC_FUNC_ALLOCA' => 1,
+                        'AC_FUNC_GETPGRP' => 1,
+                        'AC_CANONICAL_HOST' => 1,
+                        'AC_PROG_RANLIB' => 1,
+                        'AM_INIT_AUTOMAKE' => 1,
+                        'AC_FUNC_SETPGRP' => 1,
+                        'AC_CONFIG_SUBDIRS' => 1,
+                        'AC_FUNC_MMAP' => 1,
+                        'AC_FUNC_REALLOC' => 1,
+                        'AC_TYPE_SIZE_T' => 1,
+                        'AC_CHECK_TYPES' => 1,
+                        'AC_CONFIG_LINKS' => 1,
+                        'AC_CHECK_MEMBERS' => 1,
+                        'AM_MAINTAINER_MODE' => 1,
+                        'AC_FUNC_UTIME_NULL' => 1,
+                        'AC_FUNC_SELECT_ARGTYPES' => 1,
+                        'AC_HEADER_STAT' => 1,
+                        'AC_FUNC_STRFTIME' => 1,
+                        'AC_C_INLINE' => 1,
+                        'AC_PROG_CPP' => 1,
+                        'AC_C_CONST' => 1,
+                        'AC_PROG_LEX' => 1,
+                        'AC_TYPE_PID_T' => 1,
+                        'AC_CONFIG_FILES' => 1,
+                        'include' => 1,
+                        'AC_FUNC_SETVBUF_REVERSED' => 1,
+                        'AC_PROG_INSTALL' => 1,
+                        'AM_GNU_GETTEXT' => 1,
+                        'AC_FUNC_OBSTACK' => 1,
+                        'AC_CHECK_LIB' => 1,
+                        'AC_FUNC_MALLOC' => 1,
+                        'AC_FUNC_GETGROUPS' => 1,
+                        'AC_FUNC_GETLOADAVG' => 1,
+                        'AH_OUTPUT' => 1,
+                        'AC_FUNC_FSEEKO' => 1,
+                        'AM_PROG_CC_C_O' => 1,
+                        'AM_CONDITIONAL' => 1,
+                        'AC_CANONICAL_SYSTEM' => 1,
+                        'AC_FUNC_MKTIME' => 1,
+                        'AC_CONFIG_HEADERS' => 1,
+                        'AC_HEADER_SYS_WAIT' => 1,
+                        'AC_PROG_LN_S' => 1,
+                        'AC_FUNC_MEMCMP' => 1,
+                        'm4_include' => 1,
+                        'AC_HEADER_DIRENT' => 1,
+                        'AC_CHECK_FUNCS' => 1
+                      }
+                    ], 'Autom4te::Request' ),
+             bless( [
+                      '1',
+                      1,
+                      [
+                        '/usr/share/autoconf'
+                      ],
+                      [
+                        '/usr/share/autoconf/autoconf/autoconf.m4f',
+                        'aclocal.m4',
+                        'configure.in'
+                      ],
+                      {
+                        'm4_pattern_forbid' => 1,
+                        'AC_CONFIG_LIBOBJ_DIR' => 1,
                         'AC_TYPE_OFF_T' => 1,
+                        'AC_C_VOLATILE' => 1,
                         'AC_FUNC_CLOSEDIR_VOID' => 1,
                         'AC_REPLACE_FNMATCH' => 1,
                         'AC_PROG_LIBTOOL' => 1,
                         'AC_FUNC_STAT' => 1,
                         'AC_HEADER_TIME' => 1,
                         'AC_FUNC_WAIT3' => 1,
-                        'AC_FUNC_LSTAT' => 1,
-                        'AC_STRUCT_TM' => 1,
                         'AM_AUTOMAKE_VERSION' => 1,
+                        'AC_STRUCT_TM' => 1,
+                        'AC_FUNC_LSTAT' => 1,
                         'AC_TYPE_MODE_T' => 1,
                         'AC_FUNC_GETMNTENT' => 1,
                         'AC_FUNC_STRTOD' => 1,
                         'AC_FUNC_CHOWN' => 1,
                         'AC_SUBST' => 1,
                         'AC_FUNC_ALLOCA' => 1,
-                        'AC_FUNC_GETPGRP' => 1,
                         'AC_CANONICAL_HOST' => 1,
+                        'AC_FUNC_GETPGRP' => 1,
                         'AC_PROG_RANLIB' => 1,
                         'AM_INIT_AUTOMAKE' => 1,
                         'AC_FUNC_SETPGRP' => 1,
                         'AC_FUNC_MMAP' => 1,
                         'AC_FUNC_REALLOC' => 1,
                         'AC_TYPE_SIZE_T' => 1,
-                        'AC_CHECK_TYPES' => 1,
                         'AC_CONFIG_LINKS' => 1,
+                        'AC_CHECK_TYPES' => 1,
                         'AC_CHECK_MEMBERS' => 1,
                         'AM_MAINTAINER_MODE' => 1,
                         'AC_FUNC_UTIME_NULL' => 1,
                         'AC_FUNC_SELECT_ARGTYPES' => 1,
                         'AC_FUNC_STRFTIME' => 1,
                         'AC_HEADER_STAT' => 1,
-                        'AC_PROG_CPP' => 1,
                         'AC_C_INLINE' => 1,
+                        'AC_PROG_CPP' => 1,
                         'AC_TYPE_PID_T' => 1,
-                        'AC_PROG_LEX' => 1,
                         'AC_C_CONST' => 1,
+                        'AC_PROG_LEX' => 1,
                         'AC_CONFIG_FILES' => 1,
                         'include' => 1,
                         'AC_FUNC_SETVBUF_REVERSED' => 1,
                         'AC_PROG_INSTALL' => 1,
                         'AM_GNU_GETTEXT' => 1,
-                        'AC_CHECK_LIB' => 1,
                         'AC_FUNC_OBSTACK' => 1,
+                        'AC_CHECK_LIB' => 1,
                         'AC_FUNC_MALLOC' => 1,
                         'AC_FUNC_GETGROUPS' => 1,
                         'AC_FUNC_GETLOADAVG' => 1,
                         'AH_OUTPUT' => 1,
                         'AC_FUNC_FSEEKO' => 1,
                         'AM_PROG_CC_C_O' => 1,
-                        'AC_FUNC_MKTIME' => 1,
-                        'AC_CANONICAL_SYSTEM' => 1,
                         'AM_CONDITIONAL' => 1,
+                        'AC_CANONICAL_SYSTEM' => 1,
+                        'AC_FUNC_MKTIME' => 1,
                         'AC_CONFIG_HEADERS' => 1,
                         'AC_HEADER_SYS_WAIT' => 1,
                         'AC_FUNC_MEMCMP' => 1,
index 52bbce238730bff3f1486fe7fd6bf43621662a27..643efc8dfdfa58b101a6c3777df43a8f549a1338 100644 (file)
@@ -64,7 +64,7 @@ m4trace:configure.in:52: -1- AC_SUBST([host_vendor], [`echo $ac_cv_host | sed 's
 m4trace:configure.in:52: -1- AC_SUBST([host_os], [`echo $ac_cv_host | sed 's/^\([[^-]]*\)-\([[^-]]*\)-\(.*\)$/\3/'`])
 m4trace:configure.in:102: -2- _m4_warn([obsolete], [The macro `AC_HELP_STRING' is obsolete.
 You should run autoupdate.], [autoconf/general.m4:219: AC_HELP_STRING is expanded from...
-aclocal.m4:1972: AM_PATH_LISPDIR is expanded from...
+aclocal.m4:1969: AM_PATH_LISPDIR is expanded from...
 configure.in:102: the top level])
 m4trace:configure.in:102: -1- AC_SUBST([EMACS])
 m4trace:configure.in:102: -1- AC_SUBST([lispdir])
@@ -316,7 +316,7 @@ m4trace:configure.in:483: -1- AC_CHECK_LIB([ncurses], [tgetent], [bash_cv_termca
 m4trace:configure.in:483: -1- _m4_warn([obsolete], [The macro `AC_TRY_RUN' is obsolete.
 You should run autoupdate.], [autoconf/general.m4:2289: AC_TRY_RUN is expanded from...
 autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
-aclocal.m4:1865: RL_LIB_READLINE_VERSION is expanded from...
+aclocal.m4:1862: RL_LIB_READLINE_VERSION is expanded from...
 configure.in:483: the top level])
 m4trace:configure.in:483: -1- AC_DEFINE_TRACE_LITERAL([RL_READLINE_VERSION])
 m4trace:configure.in:483: -1- AH_OUTPUT([RL_READLINE_VERSION], [/* encoded version of the installed readline library */
@@ -398,16 +398,16 @@ m4trace:configure.in:627: -1- AC_SUBST([XGETTEXT])
 m4trace:configure.in:627: -1- AC_SUBST([MSGMERGE])
 m4trace:configure.in:627: -1- _m4_warn([obsolete], [The macro `AC_OUTPUT_COMMANDS' is obsolete.
 You should run autoupdate.], [autoconf/status.m4:318: AC_OUTPUT_COMMANDS is expanded from...
-aclocal.m4:3828: AM_PO_SUBDIRS is expanded from...
+aclocal.m4:3825: AM_PO_SUBDIRS is expanded from...
 configure.in:627: AM_PO_SUBDIRS is required by...
-aclocal.m4:2340: AM_GNU_GETTEXT is expanded from...
+aclocal.m4:2337: AM_GNU_GETTEXT is expanded from...
 configure.in:627: the top level])
 m4trace:configure.in:627: -3- _m4_warn([obsolete], [The macro `_AC_OUTPUT_COMMANDS_CNT' is obsolete.
 You should run autoupdate.], [autoconf/status.m4:321: _AC_OUTPUT_COMMANDS_CNT is expanded from...
 autoconf/status.m4:318: AC_OUTPUT_COMMANDS is expanded from...
-aclocal.m4:3828: AM_PO_SUBDIRS is expanded from...
+aclocal.m4:3825: AM_PO_SUBDIRS is expanded from...
 configure.in:627: AM_PO_SUBDIRS is required by...
-aclocal.m4:2340: AM_GNU_GETTEXT is expanded from...
+aclocal.m4:2337: AM_GNU_GETTEXT is expanded from...
 configure.in:627: the top level])
 m4trace:configure.in:627: -1- AC_TYPE_OFF_T
 m4trace:configure.in:627: -1- AC_DEFINE_TRACE_LITERAL([off_t])
@@ -460,11 +460,11 @@ m4trace:configure.in:627: -1- _m4_warn([obsolete], [The macro `AC_TRY_RUN' is ob
 You should run autoupdate.], [autoconf/general.m4:2289: AC_TRY_RUN is expanded from...
 autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
 autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from...
-aclocal.m4:2621: gt_INTDIV0 is expanded from...
+aclocal.m4:2618: gt_INTDIV0 is expanded from...
 configure.in:627: gt_INTDIV0 is required by...
-aclocal.m4:2410: AM_INTL_SUBDIR is expanded from...
+aclocal.m4:2407: AM_INTL_SUBDIR is expanded from...
 configure.in:627: AM_INTL_SUBDIR is required by...
-aclocal.m4:2340: AM_GNU_GETTEXT is expanded from...
+aclocal.m4:2337: AM_GNU_GETTEXT is expanded from...
 configure.in:627: the top level])
 m4trace:configure.in:627: -1- AC_DEFINE_TRACE_LITERAL([INTDIV0_RAISES_SIGFPE])
 m4trace:configure.in:627: -1- AH_OUTPUT([INTDIV0_RAISES_SIGFPE], [/* Define if integer division by zero raises signal SIGFPE. */
@@ -473,13 +473,13 @@ m4trace:configure.in:627: -1- _m4_warn([obsolete], [The macro `AC_TRY_COMPILE' i
 You should run autoupdate.], [autoconf/general.m4:2180: AC_TRY_COMPILE is expanded from...
 autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
 autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from...
-aclocal.m4:2676: jm_AC_HEADER_INTTYPES_H is expanded from...
+aclocal.m4:2673: jm_AC_HEADER_INTTYPES_H is expanded from...
 configure.in:627: jm_AC_HEADER_INTTYPES_H is required by...
-aclocal.m4:3979: jm_AC_TYPE_UINTMAX_T is expanded from...
+aclocal.m4:3976: jm_AC_TYPE_UINTMAX_T is expanded from...
 configure.in:627: jm_AC_TYPE_UINTMAX_T is required by...
-aclocal.m4:2410: AM_INTL_SUBDIR is expanded from...
+aclocal.m4:2407: AM_INTL_SUBDIR is expanded from...
 configure.in:627: AM_INTL_SUBDIR is required by...
-aclocal.m4:2340: AM_GNU_GETTEXT is expanded from...
+aclocal.m4:2337: AM_GNU_GETTEXT is expanded from...
 configure.in:627: the top level])
 m4trace:configure.in:627: -1- AC_DEFINE_TRACE_LITERAL([HAVE_INTTYPES_H_WITH_UINTMAX])
 m4trace:configure.in:627: -1- AH_OUTPUT([HAVE_INTTYPES_H_WITH_UINTMAX], [/* Define if <inttypes.h> exists, doesn\'t clash with <sys/types.h>, and
@@ -489,13 +489,13 @@ m4trace:configure.in:627: -1- _m4_warn([obsolete], [The macro `AC_TRY_COMPILE' i
 You should run autoupdate.], [autoconf/general.m4:2180: AC_TRY_COMPILE is expanded from...
 autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
 autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from...
-aclocal.m4:3947: jm_AC_HEADER_STDINT_H is expanded from...
+aclocal.m4:3944: jm_AC_HEADER_STDINT_H is expanded from...
 configure.in:627: jm_AC_HEADER_STDINT_H is required by...
-aclocal.m4:3979: jm_AC_TYPE_UINTMAX_T is expanded from...
+aclocal.m4:3976: jm_AC_TYPE_UINTMAX_T is expanded from...
 configure.in:627: jm_AC_TYPE_UINTMAX_T is required by...
-aclocal.m4:2410: AM_INTL_SUBDIR is expanded from...
+aclocal.m4:2407: AM_INTL_SUBDIR is expanded from...
 configure.in:627: AM_INTL_SUBDIR is required by...
-aclocal.m4:2340: AM_GNU_GETTEXT is expanded from...
+aclocal.m4:2337: AM_GNU_GETTEXT is expanded from...
 configure.in:627: the top level])
 m4trace:configure.in:627: -1- AC_DEFINE_TRACE_LITERAL([HAVE_STDINT_H_WITH_UINTMAX])
 m4trace:configure.in:627: -1- AH_OUTPUT([HAVE_STDINT_H_WITH_UINTMAX], [/* Define if <stdint.h> exists, doesn\'t clash with <sys/types.h>, and declares
@@ -505,13 +505,13 @@ m4trace:configure.in:627: -1- _m4_warn([obsolete], [The macro `AC_TRY_LINK' is o
 You should run autoupdate.], [autoconf/general.m4:2223: AC_TRY_LINK is expanded from...
 autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
 autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from...
-aclocal.m4:4002: jm_AC_TYPE_UNSIGNED_LONG_LONG is expanded from...
+aclocal.m4:3999: jm_AC_TYPE_UNSIGNED_LONG_LONG is expanded from...
 configure.in:627: jm_AC_TYPE_UNSIGNED_LONG_LONG is required by...
-aclocal.m4:3979: jm_AC_TYPE_UINTMAX_T is expanded from...
+aclocal.m4:3976: jm_AC_TYPE_UINTMAX_T is expanded from...
 configure.in:627: jm_AC_TYPE_UINTMAX_T is required by...
-aclocal.m4:2410: AM_INTL_SUBDIR is expanded from...
+aclocal.m4:2407: AM_INTL_SUBDIR is expanded from...
 configure.in:627: AM_INTL_SUBDIR is required by...
-aclocal.m4:2340: AM_GNU_GETTEXT is expanded from...
+aclocal.m4:2337: AM_GNU_GETTEXT is expanded from...
 configure.in:627: the top level])
 m4trace:configure.in:627: -1- AC_DEFINE_TRACE_LITERAL([HAVE_UNSIGNED_LONG_LONG])
 m4trace:configure.in:627: -1- AH_OUTPUT([HAVE_UNSIGNED_LONG_LONG], [/* Define if you have the unsigned long long type. */
@@ -527,11 +527,11 @@ m4trace:configure.in:627: -1- _m4_warn([obsolete], [The macro `AC_TRY_COMPILE' i
 You should run autoupdate.], [autoconf/general.m4:2180: AC_TRY_COMPILE is expanded from...
 autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
 autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from...
-aclocal.m4:2648: gt_HEADER_INTTYPES_H is expanded from...
+aclocal.m4:2645: gt_HEADER_INTTYPES_H is expanded from...
 configure.in:627: gt_HEADER_INTTYPES_H is required by...
-aclocal.m4:2410: AM_INTL_SUBDIR is expanded from...
+aclocal.m4:2407: AM_INTL_SUBDIR is expanded from...
 configure.in:627: AM_INTL_SUBDIR is required by...
-aclocal.m4:2340: AM_GNU_GETTEXT is expanded from...
+aclocal.m4:2337: AM_GNU_GETTEXT is expanded from...
 configure.in:627: the top level])
 m4trace:configure.in:627: -1- AC_DEFINE_TRACE_LITERAL([HAVE_INTTYPES_H])
 m4trace:configure.in:627: -1- AH_OUTPUT([HAVE_INTTYPES_H], [/* Define if <inttypes.h> exists and doesn\'t clash with <sys/types.h>. */
@@ -540,11 +540,11 @@ m4trace:configure.in:627: -1- _m4_warn([obsolete], [The macro `AC_TRY_COMPILE' i
 You should run autoupdate.], [autoconf/general.m4:2180: AC_TRY_COMPILE is expanded from...
 autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
 autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from...
-aclocal.m4:2708: gt_INTTYPES_PRI is expanded from...
+aclocal.m4:2705: gt_INTTYPES_PRI is expanded from...
 configure.in:627: gt_INTTYPES_PRI is required by...
-aclocal.m4:2410: AM_INTL_SUBDIR is expanded from...
+aclocal.m4:2407: AM_INTL_SUBDIR is expanded from...
 configure.in:627: AM_INTL_SUBDIR is required by...
-aclocal.m4:2340: AM_GNU_GETTEXT is expanded from...
+aclocal.m4:2337: AM_GNU_GETTEXT is expanded from...
 configure.in:627: the top level])
 m4trace:configure.in:627: -1- AC_DEFINE_TRACE_LITERAL([PRI_MACROS_BROKEN])
 m4trace:configure.in:627: -1- AH_OUTPUT([PRI_MACROS_BROKEN], [/* Define if <inttypes.h> exists and defines unusable PRI* macros. */
@@ -625,21 +625,21 @@ m4trace:configure.in:627: -1- _m4_warn([obsolete], [The macro `AC_TRY_LINK' is o
 You should run autoupdate.], [autoconf/general.m4:2223: AC_TRY_LINK is expanded from...
 autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
 autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from...
-aclocal.m4:2521: AM_ICONV_LINK is expanded from...
-aclocal.m4:2549: AM_ICONV is expanded from...
-aclocal.m4:2410: AM_INTL_SUBDIR is expanded from...
+aclocal.m4:2518: AM_ICONV_LINK is expanded from...
+aclocal.m4:2546: AM_ICONV is expanded from...
+aclocal.m4:2407: AM_INTL_SUBDIR is expanded from...
 configure.in:627: AM_INTL_SUBDIR is required by...
-aclocal.m4:2340: AM_GNU_GETTEXT is expanded from...
+aclocal.m4:2337: AM_GNU_GETTEXT is expanded from...
 configure.in:627: the top level])
 m4trace:configure.in:627: -1- _m4_warn([obsolete], [The macro `AC_TRY_LINK' is obsolete.
 You should run autoupdate.], [autoconf/general.m4:2223: AC_TRY_LINK is expanded from...
 autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
 autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from...
-aclocal.m4:2521: AM_ICONV_LINK is expanded from...
-aclocal.m4:2549: AM_ICONV is expanded from...
-aclocal.m4:2410: AM_INTL_SUBDIR is expanded from...
+aclocal.m4:2518: AM_ICONV_LINK is expanded from...
+aclocal.m4:2546: AM_ICONV is expanded from...
+aclocal.m4:2407: AM_INTL_SUBDIR is expanded from...
 configure.in:627: AM_INTL_SUBDIR is required by...
-aclocal.m4:2340: AM_GNU_GETTEXT is expanded from...
+aclocal.m4:2337: AM_GNU_GETTEXT is expanded from...
 configure.in:627: the top level])
 m4trace:configure.in:627: -1- AC_DEFINE_TRACE_LITERAL([HAVE_ICONV])
 m4trace:configure.in:627: -1- AH_OUTPUT([HAVE_ICONV], [/* Define if you have the iconv() function. */
@@ -649,10 +649,10 @@ m4trace:configure.in:627: -1- AC_SUBST([LTLIBICONV])
 m4trace:configure.in:627: -1- _m4_warn([obsolete], [The macro `AC_TRY_COMPILE' is obsolete.
 You should run autoupdate.], [autoconf/general.m4:2180: AC_TRY_COMPILE is expanded from...
 autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
-aclocal.m4:2549: AM_ICONV is expanded from...
-aclocal.m4:2410: AM_INTL_SUBDIR is expanded from...
+aclocal.m4:2546: AM_ICONV is expanded from...
+aclocal.m4:2407: AM_INTL_SUBDIR is expanded from...
 configure.in:627: AM_INTL_SUBDIR is required by...
-aclocal.m4:2340: AM_GNU_GETTEXT is expanded from...
+aclocal.m4:2337: AM_GNU_GETTEXT is expanded from...
 configure.in:627: the top level])
 m4trace:configure.in:627: -1- AC_DEFINE_TRACE_LITERAL([ICONV_CONST])
 m4trace:configure.in:627: -1- AH_OUTPUT([ICONV_CONST], [/* Define as const if the declaration of iconv() needs const. */
@@ -661,10 +661,10 @@ m4trace:configure.in:627: -1- _m4_warn([obsolete], [The macro `AC_TRY_LINK' is o
 You should run autoupdate.], [autoconf/general.m4:2223: AC_TRY_LINK is expanded from...
 autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
 autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from...
-aclocal.m4:1999: AM_LANGINFO_CODESET is expanded from...
-aclocal.m4:2410: AM_INTL_SUBDIR is expanded from...
+aclocal.m4:1996: AM_LANGINFO_CODESET is expanded from...
+aclocal.m4:2407: AM_INTL_SUBDIR is expanded from...
 configure.in:627: AM_INTL_SUBDIR is required by...
-aclocal.m4:2340: AM_GNU_GETTEXT is expanded from...
+aclocal.m4:2337: AM_GNU_GETTEXT is expanded from...
 configure.in:627: the top level])
 m4trace:configure.in:627: -1- AC_DEFINE_TRACE_LITERAL([HAVE_LANGINFO_CODESET])
 m4trace:configure.in:627: -1- AH_OUTPUT([HAVE_LANGINFO_CODESET], [/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
@@ -673,10 +673,10 @@ m4trace:configure.in:627: -1- _m4_warn([obsolete], [The macro `AC_TRY_LINK' is o
 You should run autoupdate.], [autoconf/general.m4:2223: AC_TRY_LINK is expanded from...
 autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
 autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from...
-aclocal.m4:2766: AM_LC_MESSAGES is expanded from...
-aclocal.m4:2410: AM_INTL_SUBDIR is expanded from...
+aclocal.m4:2763: AM_LC_MESSAGES is expanded from...
+aclocal.m4:2407: AM_INTL_SUBDIR is expanded from...
 configure.in:627: AM_INTL_SUBDIR is required by...
-aclocal.m4:2340: AM_GNU_GETTEXT is expanded from...
+aclocal.m4:2337: AM_GNU_GETTEXT is expanded from...
 configure.in:627: the top level])
 m4trace:configure.in:627: -1- AC_DEFINE_TRACE_LITERAL([HAVE_LC_MESSAGES])
 m4trace:configure.in:627: -1- AH_OUTPUT([HAVE_LC_MESSAGES], [/* Define if your <locale.h> file defines LC_MESSAGES. */
@@ -687,19 +687,19 @@ m4trace:configure.in:627: -1- _m4_warn([obsolete], [The macro `AC_TRY_LINK' is o
 You should run autoupdate.], [autoconf/general.m4:2223: AC_TRY_LINK is expanded from...
 autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
 autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from...
-aclocal.m4:2340: AM_GNU_GETTEXT is expanded from...
+aclocal.m4:2337: AM_GNU_GETTEXT is expanded from...
 configure.in:627: the top level])
 m4trace:configure.in:627: -1- _m4_warn([obsolete], [The macro `AC_TRY_LINK' is obsolete.
 You should run autoupdate.], [autoconf/general.m4:2223: AC_TRY_LINK is expanded from...
 autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
 autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from...
-aclocal.m4:2340: AM_GNU_GETTEXT is expanded from...
+aclocal.m4:2337: AM_GNU_GETTEXT is expanded from...
 configure.in:627: the top level])
 m4trace:configure.in:627: -1- _m4_warn([obsolete], [The macro `AC_TRY_LINK' is obsolete.
 You should run autoupdate.], [autoconf/general.m4:2223: AC_TRY_LINK is expanded from...
 autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
 autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from...
-aclocal.m4:2340: AM_GNU_GETTEXT is expanded from...
+aclocal.m4:2337: AM_GNU_GETTEXT is expanded from...
 configure.in:627: the top level])
 m4trace:configure.in:627: -1- AC_DEFINE_TRACE_LITERAL([ENABLE_NLS])
 m4trace:configure.in:627: -1- AH_OUTPUT([ENABLE_NLS], [/* Define to 1 if translation of program messages to the user\'s native
@@ -1244,14 +1244,14 @@ m4trace:configure.in:777: -1- _m4_warn([obsolete], [The macro `AC_TRY_LINK' is o
 You should run autoupdate.], [autoconf/general.m4:2223: AC_TRY_LINK is expanded from...
 autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
 autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from...
-aclocal.m4:1746: BASH_CHECK_MULTIBYTE is expanded from...
+aclocal.m4:1743: BASH_CHECK_MULTIBYTE is expanded from...
 configure.in:777: the top level])
 m4trace:configure.in:777: -1- AC_DEFINE_TRACE_LITERAL([HAVE_LANGINFO_CODESET])
 m4trace:configure.in:777: -1- _m4_warn([obsolete], [The macro `AC_TRY_COMPILE' is obsolete.
 You should run autoupdate.], [autoconf/general.m4:2180: AC_TRY_COMPILE is expanded from...
 autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
 autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from...
-aclocal.m4:1746: BASH_CHECK_MULTIBYTE is expanded from...
+aclocal.m4:1743: BASH_CHECK_MULTIBYTE is expanded from...
 configure.in:777: the top level])
 m4trace:configure.in:777: -1- AC_DEFINE_TRACE_LITERAL([HAVE_WCHAR_T])
 m4trace:configure.in:777: -1- AH_OUTPUT([HAVE_WCHAR_T], [/* systems should define this type here */
@@ -1260,7 +1260,7 @@ m4trace:configure.in:777: -1- _m4_warn([obsolete], [The macro `AC_TRY_COMPILE' i
 You should run autoupdate.], [autoconf/general.m4:2180: AC_TRY_COMPILE is expanded from...
 autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
 autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from...
-aclocal.m4:1746: BASH_CHECK_MULTIBYTE is expanded from...
+aclocal.m4:1743: BASH_CHECK_MULTIBYTE is expanded from...
 configure.in:777: the top level])
 m4trace:configure.in:777: -1- AC_DEFINE_TRACE_LITERAL([HAVE_WCTYPE_T])
 m4trace:configure.in:777: -1- AH_OUTPUT([HAVE_WCTYPE_T], [/* systems should define this type here */
@@ -1269,7 +1269,7 @@ m4trace:configure.in:777: -1- _m4_warn([obsolete], [The macro `AC_TRY_COMPILE' i
 You should run autoupdate.], [autoconf/general.m4:2180: AC_TRY_COMPILE is expanded from...
 autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
 autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from...
-aclocal.m4:1746: BASH_CHECK_MULTIBYTE is expanded from...
+aclocal.m4:1743: BASH_CHECK_MULTIBYTE is expanded from...
 configure.in:777: the top level])
 m4trace:configure.in:777: -1- AC_DEFINE_TRACE_LITERAL([HAVE_WINT_T])
 m4trace:configure.in:777: -1- AH_OUTPUT([HAVE_WINT_T], [/* systems should define this type here */
@@ -1515,7 +1515,7 @@ m4trace:configure.in:853: -1- AC_DEFINE_TRACE_LITERAL([HAVE_LSTAT])
 m4trace:configure.in:857: -1- _m4_warn([obsolete], [The macro `AC_TRY_RUN' is obsolete.
 You should run autoupdate.], [autoconf/general.m4:2289: AC_TRY_RUN is expanded from...
 autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
-aclocal.m4:1909: BASH_FUNC_CTYPE_NONASCII is expanded from...
+aclocal.m4:1906: BASH_FUNC_CTYPE_NONASCII is expanded from...
 configure.in:857: the top level])
 m4trace:configure.in:857: -1- AC_DEFINE_TRACE_LITERAL([CTYPE_NON_ASCII])
 m4trace:configure.in:858: -1- _m4_warn([obsolete], [The macro `AC_TRY_RUN' is obsolete.
@@ -1769,7 +1769,7 @@ m4trace:configure.in:927: -1- AC_DEFINE_TRACE_LITERAL([FIONREAD_IN_SYS_IOCTL])
 m4trace:configure.in:929: -1- _m4_warn([obsolete], [The macro `AC_TRY_RUN' is obsolete.
 You should run autoupdate.], [autoconf/general.m4:2289: AC_TRY_RUN is expanded from...
 autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
-aclocal.m4:1942: BASH_CHECK_WCONTINUED is expanded from...
+aclocal.m4:1939: BASH_CHECK_WCONTINUED is expanded from...
 configure.in:929: the top level])
 m4trace:configure.in:929: -1- AC_DEFINE_TRACE_LITERAL([WCONTINUED_BROKEN])
 m4trace:configure.in:932: -1- _m4_warn([obsolete], [The macro `AC_TRY_COMPILE' is obsolete.
@@ -1782,21 +1782,21 @@ m4trace:configure.in:933: -1- AC_DEFINE_TRACE_LITERAL([HAVE_GETPW_DECLS])
 m4trace:configure.in:934: -1- _m4_warn([obsolete], [The macro `AC_TRY_RUN' is obsolete.
 You should run autoupdate.], [autoconf/general.m4:2289: AC_TRY_RUN is expanded from...
 autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
-aclocal.m4:1670: BASH_CHECK_RTSIGS is expanded from...
+aclocal.m4:1667: BASH_CHECK_RTSIGS is expanded from...
 configure.in:934: the top level])
 m4trace:configure.in:934: -1- AC_DEFINE_TRACE_LITERAL([UNUSABLE_RT_SIGNALS])
 m4trace:configure.in:935: -1- AC_SUBST([SIGLIST_O])
 m4trace:configure.in:939: -1- _m4_warn([obsolete], [The macro `AC_TRY_COMPILE' is obsolete.
 You should run autoupdate.], [autoconf/general.m4:2180: AC_TRY_COMPILE is expanded from...
 autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
-aclocal.m4:1619: BASH_CHECK_KERNEL_RLIMIT is expanded from...
+aclocal.m4:1616: BASH_CHECK_KERNEL_RLIMIT is expanded from...
 configure.in:939: the top level])
 m4trace:configure.in:939: -1- _m4_warn([obsolete], [The macro `AC_TRY_COMPILE' is obsolete.
 You should run autoupdate.], [autoconf/general.m4:2180: AC_TRY_COMPILE is expanded from...
 autoconf/general.m4:2173: AC_COMPILE_IFELSE is expanded from...
 autoconf/general.m4:2180: AC_TRY_COMPILE is expanded from...
 autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
-aclocal.m4:1619: BASH_CHECK_KERNEL_RLIMIT is expanded from...
+aclocal.m4:1616: BASH_CHECK_KERNEL_RLIMIT is expanded from...
 configure.in:939: the top level])
 m4trace:configure.in:939: -1- AC_DEFINE_TRACE_LITERAL([RLIMIT_NEEDS_KERNEL])
 m4trace:configure.in:947: -1- AC_CHECK_LIB([termcap], [tgetent], [bash_cv_termcap_lib=libtermcap], [AC_CHECK_LIB(tinfo, tgetent, bash_cv_termcap_lib=libtinfo,
@@ -1848,13 +1848,12 @@ m4trace:configure.in:1094: -1- AC_SUBST([LOCAL_LIBS])
 m4trace:configure.in:1095: -1- AC_SUBST([LOCAL_CFLAGS])
 m4trace:configure.in:1096: -1- AC_SUBST([LOCAL_LDFLAGS])
 m4trace:configure.in:1097: -1- AC_SUBST([LOCAL_DEFS])
-m4trace:configure.in:1111: -1- AC_CONFIG_FILES([Makefile builtins/Makefile lib/readline/Makefile lib/glob/Makefile \
+m4trace:configure.in:1110: -1- AC_CONFIG_FILES([Makefile builtins/Makefile lib/readline/Makefile lib/glob/Makefile \
          lib/intl/Makefile \
          lib/malloc/Makefile lib/sh/Makefile lib/termcap/Makefile \
          lib/tilde/Makefile doc/Makefile support/Makefile po/Makefile.in \
-         examples/loadables/Makefile examples/loadables/perl/Makefile \
-         pathnames.h])
-m4trace:configure.in:1111: -1- _m4_warn([obsolete], [AC_OUTPUT should be used without arguments.
+         examples/loadables/Makefile examples/loadables/perl/Makefile])
+m4trace:configure.in:1110: -1- _m4_warn([obsolete], [AC_OUTPUT should be used without arguments.
 You should run autoupdate.], [])
-m4trace:configure.in:1111: -1- AC_SUBST([LIB@&t@OBJS], [$ac_libobjs])
-m4trace:configure.in:1111: -1- AC_SUBST([LTLIBOBJS], [$ac_ltlibobjs])
+m4trace:configure.in:1110: -1- AC_SUBST([LIB@&t@OBJS], [$ac_libobjs])
+m4trace:configure.in:1110: -1- AC_SUBST([LTLIBOBJS], [$ac_ltlibobjs])
diff --git a/bashline.c~ b/bashline.c~
new file mode 100644 (file)
index 0000000..97ab9fb
--- /dev/null
@@ -0,0 +1,3200 @@
+/* bashline.c -- Bash's interface to the readline library. */
+
+/* Copyright (C) 1987-2006 Free Software Foundation, Inc.
+
+   This file is part of GNU Bash, the Bourne Again SHell.
+
+   Bash is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   Bash is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+   License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with Bash; see the file COPYING.  If not, write to the Free
+   Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+#include "config.h"
+
+#if defined (READLINE)
+
+#include "bashtypes.h"
+#include "posixstat.h"
+
+#if defined (HAVE_UNISTD_H)
+#  include <unistd.h>
+#endif
+
+#if defined (HAVE_GRP_H)
+#  include <grp.h>
+#endif
+
+#if defined (HAVE_NETDB_H)
+#  include <netdb.h>
+#endif
+
+#include <stdio.h>
+#include "chartypes.h"
+#include "bashansi.h"
+#include "bashintl.h"
+
+#include "shell.h"
+#include "input.h"
+#include "builtins.h"
+#include "bashhist.h"
+#include "bashline.h"
+#include "execute_cmd.h"
+#include "findcmd.h"
+#include "pathexp.h"
+#include "builtins/common.h"
+#include <readline/rlconf.h>
+#include <readline/readline.h>
+#include <readline/history.h>
+
+#include <glob/glob.h>
+
+#if defined (ALIAS)
+#  include "alias.h"
+#endif
+
+#if defined (PROGRAMMABLE_COMPLETION)
+#  include "pcomplete.h"
+#endif
+
+/* These should agree with the defines for emacs_mode and vi_mode in
+   rldefs.h, even though that's not a public readline header file. */
+#ifndef EMACS_EDITING_MODE
+#  define NO_EDITING_MODE      -1
+#  define EMACS_EDITING_MODE    1
+#  define VI_EDITING_MODE       0
+#endif
+
+#if defined (BRACE_COMPLETION)
+extern int bash_brace_completion __P((int, int));
+#endif /* BRACE_COMPLETION */
+
+/* Forward declarations */
+
+/* Functions bound to keys in Readline for Bash users. */
+static int shell_expand_line __P((int, int));
+static int display_shell_version __P((int, int));
+static int operate_and_get_next __P((int, int));
+
+static int bash_ignore_filenames __P((char **));
+static int bash_ignore_everything __P((char **));
+
+#if defined (BANG_HISTORY)
+static char *history_expand_line_internal __P((char *));
+static int history_expand_line __P((int, int));
+static int tcsh_magic_space __P((int, int));
+#endif /* BANG_HISTORY */
+#ifdef ALIAS
+static int alias_expand_line __P((int, int));
+#endif
+#if defined (BANG_HISTORY) && defined (ALIAS)
+static int history_and_alias_expand_line __P((int, int));
+#endif
+
+/* Helper functions for Readline. */
+static void bash_directory_expansion __P((char **));
+static int bash_directory_completion_hook __P((char **));
+static int filename_completion_ignore __P((char **));
+static int bash_push_line __P((void));
+
+static void cleanup_expansion_error __P((void));
+static void maybe_make_readline_line __P((char *));
+static void set_up_new_line __P((char *));
+
+static int check_redir __P((int));
+static char **attempt_shell_completion __P((const char *, int, int));
+static char *variable_completion_function __P((const char *, int));
+static char *hostname_completion_function __P((const char *, int));
+static char *command_subst_completion_function __P((const char *, int));
+
+static void build_history_completion_array __P((void));
+static char *history_completion_generator __P((const char *, int));
+static int dynamic_complete_history __P((int, int));
+
+static void initialize_hostname_list __P((void));
+static void add_host_name __P((char *));
+static void snarf_hosts_from_file __P((char *));
+static char **hostnames_matching __P((char *));
+
+static void _ignore_completion_names __P((char **, sh_ignore_func_t *));
+static int name_is_acceptable __P((const char *));
+static int test_for_directory __P((const char *));
+static int return_zero __P((const char *));
+
+static char *bash_dequote_filename __P((char *, int));
+static char *quote_word_break_chars __P((char *));
+static char *bash_quote_filename __P((char *, int, char *));
+
+static int bash_execute_unix_command __P((int, int));
+static void init_unix_command_map __P((void));
+static int isolate_sequence __P((char *, int, int, int *));
+
+static int set_saved_history __P((void));
+
+#if defined (ALIAS)
+static int posix_edit_macros __P((int, int));
+#endif
+
+#if defined (PROGRAMMABLE_COMPLETION)
+static int find_cmd_start __P((int));
+static int find_cmd_end __P((int));
+static char *find_cmd_name __P((int));
+static char *prog_complete_return __P((const char *, int));
+
+static char **prog_complete_matches;
+#endif
+
+/* Variables used here but defined in other files. */
+#if defined (BANG_HISTORY)
+extern int hist_verify;
+#endif
+
+extern int current_command_line_count, last_command_exit_value;
+extern int posixly_correct, no_symbolic_links;
+extern char *current_prompt_string, *ps1_prompt;
+extern STRING_INT_ALIST word_token_alist[];
+extern sh_builtin_func_t *last_shell_builtin, *this_shell_builtin;
+
+/* SPECIFIC_COMPLETION_FUNCTIONS specifies that we have individual
+   completion functions which indicate what type of completion should be
+   done (at or before point) that can be bound to key sequences with
+   the readline library. */
+#define SPECIFIC_COMPLETION_FUNCTIONS
+
+#if defined (SPECIFIC_COMPLETION_FUNCTIONS)
+static int bash_specific_completion __P((int, rl_compentry_func_t *));
+
+static int bash_complete_filename_internal __P((int));
+static int bash_complete_username_internal __P((int));
+static int bash_complete_hostname_internal __P((int));
+static int bash_complete_variable_internal __P((int));
+static int bash_complete_command_internal __P((int));
+
+static int bash_complete_filename __P((int, int));
+static int bash_possible_filename_completions __P((int, int));
+static int bash_complete_username __P((int, int));
+static int bash_possible_username_completions __P((int, int));
+static int bash_complete_hostname __P((int, int));
+static int bash_possible_hostname_completions __P((int, int));
+static int bash_complete_variable __P((int, int));
+static int bash_possible_variable_completions __P((int, int));
+static int bash_complete_command __P((int, int));
+static int bash_possible_command_completions __P((int, int));
+
+static char *glob_complete_word __P((const char *, int));
+static int bash_glob_completion_internal __P((int));
+static int bash_glob_complete_word __P((int, int));
+static int bash_glob_expand_word __P((int, int));
+static int bash_glob_list_expansions __P((int, int));
+
+#endif /* SPECIFIC_COMPLETION_FUNCTIONS */
+
+static int edit_and_execute_command __P((int, int, int, char *));
+#if defined (VI_MODE)
+static int vi_edit_and_execute_command __P((int, int));
+static int bash_vi_complete __P((int, int));
+#endif
+static int emacs_edit_and_execute_command __P((int, int));
+
+/* Non-zero once initalize_readline () has been called. */
+int bash_readline_initialized = 0;
+
+/* If non-zero, we do hostname completion, breaking words at `@' and
+   trying to complete the stuff after the `@' from our own internal
+   host list. */
+int perform_hostname_completion = 1;
+
+/* If non-zero, we don't do command completion on an empty line. */
+int no_empty_command_completion;
+
+/* Set FORCE_FIGNORE if you want to honor FIGNORE even if it ignores the
+   only possible matches.  Set to 0 if you want to match filenames if they
+   are the only possible matches, even if FIGNORE says to. */
+int force_fignore = 1;
+
+static char *bash_completer_word_break_characters = " \t\n\"'@><=;|&(:";
+static char *bash_nohostname_word_break_characters = " \t\n\"'><=;|&(:";
+/* )) */
+
+static rl_hook_func_t *old_rl_startup_hook = (rl_hook_func_t *)NULL;
+
+static int dot_in_path = 0;
+
+/* What kind of quoting is performed by bash_quote_filename:
+       COMPLETE_DQUOTE = double-quoting the filename
+       COMPLETE_SQUOTE = single_quoting the filename
+       COMPLETE_BSQUOTE = backslash-quoting special chars in the filename
+*/
+#define COMPLETE_DQUOTE  1
+#define COMPLETE_SQUOTE  2
+#define COMPLETE_BSQUOTE 3
+static int completion_quoting_style = COMPLETE_BSQUOTE;
+
+/* Flag values for the final argument to bash_default_completion */
+#define DEFCOMP_CMDPOS         1
+
+/* Change the readline VI-mode keymaps into or out of Posix.2 compliance.
+   Called when the shell is put into or out of `posix' mode. */
+void
+posix_readline_initialize (on_or_off)
+     int on_or_off;
+{
+  if (on_or_off)
+    rl_variable_bind ("comment-begin", "#");
+#if defined (VI_MODE)
+  rl_bind_key_in_map (CTRL ('I'), on_or_off ? rl_insert : rl_complete, vi_insertion_keymap);
+#endif
+}
+
+/* When this function returns, rl_completer_word_break_characters points to
+   dynamically allocated memory. */
+int
+enable_hostname_completion (on_or_off)
+     int on_or_off;
+{
+  int old_value;
+  char *at, *nv, *nval;
+
+  old_value = perform_hostname_completion;
+
+  if (on_or_off)
+    {
+      perform_hostname_completion = 1;
+      rl_special_prefixes = "$@";
+    }
+  else
+    {
+      perform_hostname_completion = 0;
+      rl_special_prefixes = "$";
+    }
+
+  /* Now we need to figure out how to appropriately modify and assign
+     rl_completer_word_break_characters depending on whether we want
+     hostname completion on or off. */
+
+  /* If this is the first time this has been called
+     (bash_readline_initialized == 0), use the sames values as before, but
+     allocate new memory for rl_completer_word_break_characters. */
+
+  if (bash_readline_initialized == 0 &&
+      (rl_completer_word_break_characters == 0 || 
+       rl_completer_word_break_characters == rl_basic_word_break_characters))
+    {
+      if (on_or_off)
+       rl_completer_word_break_characters = savestring (bash_completer_word_break_characters);
+      else
+       rl_completer_word_break_characters = savestring (bash_nohostname_word_break_characters);
+    }
+  else
+    {
+      /* See if we have anything to do. */
+      at = strchr (rl_completer_word_break_characters, '@');
+      if ((at == 0 && on_or_off == 0) || (at != 0 && on_or_off != 0))
+        return old_value;
+
+      /* We have something to do.  Do it. */
+      nval = (char *)xmalloc (strlen (rl_completer_word_break_characters) + 1 + on_or_off);
+
+      if (on_or_off == 0)
+       {
+         /* Turn it off -- just remove `@' from word break chars.  We want
+            to remove all occurrences of `@' from the char list, so we loop
+            rather than just copy the rest of the list over AT. */
+         for (nv = nval, at = rl_completer_word_break_characters; *at; )
+           if (*at != '@')
+             *nv++ = *at++;
+           else
+             at++;
+         *nv = '\0';
+       }
+      else
+       {
+         nval[0] = '@';
+         strcpy (nval + 1, rl_completer_word_break_characters);
+        }
+
+      free (rl_completer_word_break_characters);
+      rl_completer_word_break_characters = nval;
+    }
+
+  return (old_value);
+}
+
+/* Called once from parse.y if we are going to use readline. */
+void
+initialize_readline ()
+{
+  rl_command_func_t *func;
+  char kseq[2];
+
+  if (bash_readline_initialized)
+    return;
+
+  rl_terminal_name = get_string_value ("TERM");
+  rl_instream = stdin;
+  rl_outstream = stderr;
+
+  /* Allow conditional parsing of the ~/.inputrc file. */
+  rl_readline_name = "Bash";
+
+  /* Add bindable names before calling rl_initialize so they may be
+     referenced in the various inputrc files. */
+  rl_add_defun ("shell-expand-line", shell_expand_line, -1);
+#ifdef BANG_HISTORY
+  rl_add_defun ("history-expand-line", history_expand_line, -1);
+  rl_add_defun ("magic-space", tcsh_magic_space, -1);
+#endif
+
+#ifdef ALIAS
+  rl_add_defun ("alias-expand-line", alias_expand_line, -1);
+#  ifdef BANG_HISTORY
+  rl_add_defun ("history-and-alias-expand-line", history_and_alias_expand_line, -1);
+#  endif
+#endif
+
+  /* Backwards compatibility. */
+  rl_add_defun ("insert-last-argument", rl_yank_last_arg, -1);
+
+  rl_add_defun ("operate-and-get-next", operate_and_get_next, -1);
+  rl_add_defun ("display-shell-version", display_shell_version, -1);
+  rl_add_defun ("edit-and-execute-command", emacs_edit_and_execute_command, -1);
+
+#if defined (BRACE_COMPLETION)
+  rl_add_defun ("complete-into-braces", bash_brace_completion, -1);
+#endif
+
+#if defined (SPECIFIC_COMPLETION_FUNCTIONS)
+  rl_add_defun ("complete-filename", bash_complete_filename, -1);
+  rl_add_defun ("possible-filename-completions", bash_possible_filename_completions, -1);
+  rl_add_defun ("complete-username", bash_complete_username, -1);
+  rl_add_defun ("possible-username-completions", bash_possible_username_completions, -1);
+  rl_add_defun ("complete-hostname", bash_complete_hostname, -1);
+  rl_add_defun ("possible-hostname-completions", bash_possible_hostname_completions, -1);
+  rl_add_defun ("complete-variable", bash_complete_variable, -1);
+  rl_add_defun ("possible-variable-completions", bash_possible_variable_completions, -1);
+  rl_add_defun ("complete-command", bash_complete_command, -1);
+  rl_add_defun ("possible-command-completions", bash_possible_command_completions, -1);
+  rl_add_defun ("glob-complete-word", bash_glob_complete_word, -1);
+  rl_add_defun ("glob-expand-word", bash_glob_expand_word, -1);
+  rl_add_defun ("glob-list-expansions", bash_glob_list_expansions, -1);
+#endif
+
+  rl_add_defun ("dynamic-complete-history", dynamic_complete_history, -1);
+
+  /* Bind defaults before binding our custom shell keybindings. */
+  if (RL_ISSTATE(RL_STATE_INITIALIZED) == 0)
+    rl_initialize ();
+
+  /* Bind up our special shell functions. */
+  rl_bind_key_if_unbound_in_map (CTRL('E'), shell_expand_line, emacs_meta_keymap);
+
+#ifdef BANG_HISTORY
+  rl_bind_key_if_unbound_in_map ('^', history_expand_line, emacs_meta_keymap);
+#endif
+
+  rl_bind_key_if_unbound_in_map (CTRL ('O'), operate_and_get_next, emacs_standard_keymap);
+  rl_bind_key_if_unbound_in_map (CTRL ('V'), display_shell_version, emacs_ctlx_keymap);
+
+  /* In Bash, the user can switch editing modes with "set -o [vi emacs]",
+     so it is not necessary to allow C-M-j for context switching.  Turn
+     off this occasionally confusing behaviour. */
+  kseq[0] = CTRL('J');
+  kseq[1] = '\0';
+  func = rl_function_of_keyseq (kseq, emacs_meta_keymap, (int *)NULL);
+  if (func == rl_vi_editing_mode)
+    rl_unbind_key_in_map (CTRL('J'), emacs_meta_keymap);
+  kseq[0] = CTRL('M');
+  func = rl_function_of_keyseq (kseq, emacs_meta_keymap, (int *)NULL);
+  if (func == rl_vi_editing_mode)
+    rl_unbind_key_in_map (CTRL('M'), emacs_meta_keymap);
+#if defined (VI_MODE)
+  rl_unbind_key_in_map (CTRL('E'), vi_movement_keymap);
+#endif
+
+#if defined (BRACE_COMPLETION)
+  rl_bind_key_if_unbound_in_map ('{', bash_brace_completion, emacs_meta_keymap); /*}*/
+#endif /* BRACE_COMPLETION */
+
+#if defined (SPECIFIC_COMPLETION_FUNCTIONS)
+  rl_bind_key_if_unbound_in_map ('/', bash_complete_filename, emacs_meta_keymap);
+  rl_bind_key_if_unbound_in_map ('/', bash_possible_filename_completions, emacs_ctlx_keymap);
+
+  /* Have to jump through hoops here because there is a default binding for
+     M-~ (rl_tilde_expand) */
+  kseq[0] = '~';
+  kseq[1] = '\0';
+  func = rl_function_of_keyseq (kseq, emacs_meta_keymap, (int *)NULL);
+  if (func == 0 || func == rl_tilde_expand)
+    rl_bind_keyseq_in_map (kseq, bash_complete_username, emacs_meta_keymap);
+
+  rl_bind_key_if_unbound_in_map ('~', bash_possible_username_completions, emacs_ctlx_keymap);
+
+  rl_bind_key_if_unbound_in_map ('@', bash_complete_hostname, emacs_meta_keymap);
+  rl_bind_key_if_unbound_in_map ('@', bash_possible_hostname_completions, emacs_ctlx_keymap);
+
+  rl_bind_key_if_unbound_in_map ('$', bash_complete_variable, emacs_meta_keymap);
+  rl_bind_key_if_unbound_in_map ('$', bash_possible_variable_completions, emacs_ctlx_keymap);
+
+  rl_bind_key_if_unbound_in_map ('!', bash_complete_command, emacs_meta_keymap);
+  rl_bind_key_if_unbound_in_map ('!', bash_possible_command_completions, emacs_ctlx_keymap);
+
+  rl_bind_key_if_unbound_in_map ('g', bash_glob_complete_word, emacs_meta_keymap);
+  rl_bind_key_if_unbound_in_map ('*', bash_glob_expand_word, emacs_ctlx_keymap);
+  rl_bind_key_if_unbound_in_map ('g', bash_glob_list_expansions, emacs_ctlx_keymap);
+
+#endif /* SPECIFIC_COMPLETION_FUNCTIONS */
+
+  kseq[0] = TAB;
+  kseq[1] = '\0';
+  func = rl_function_of_keyseq (kseq, emacs_meta_keymap, (int *)NULL);
+  if (func == 0 || func == rl_tab_insert)
+    rl_bind_key_in_map (TAB, dynamic_complete_history, emacs_meta_keymap);
+
+  /* Tell the completer that we want a crack first. */
+  rl_attempted_completion_function = attempt_shell_completion;
+
+  /* Tell the completer that we might want to follow symbolic links or
+     do other expansion on directory names. */
+  rl_directory_completion_hook = bash_directory_completion_hook;
+
+  /* Tell the filename completer we want a chance to ignore some names. */
+  rl_ignore_some_completions_function = filename_completion_ignore;
+
+  /* Bind C-xC-e to invoke emacs and run result as commands. */
+  rl_bind_key_if_unbound_in_map (CTRL ('E'), emacs_edit_and_execute_command, emacs_ctlx_keymap);
+#if defined (VI_MODE)
+  rl_bind_key_if_unbound_in_map ('v', vi_edit_and_execute_command, vi_movement_keymap);
+#  if defined (ALIAS)
+  rl_bind_key_if_unbound_in_map ('@', posix_edit_macros, vi_movement_keymap);
+#  endif
+
+  rl_bind_key_in_map ('\\', bash_vi_complete, vi_movement_keymap);
+  rl_bind_key_in_map ('*', bash_vi_complete, vi_movement_keymap);
+  rl_bind_key_in_map ('=', bash_vi_complete, vi_movement_keymap);
+#endif
+
+  rl_completer_quote_characters = "'\"";
+
+  /* This sets rl_completer_word_break_characters and rl_special_prefixes
+     to the appropriate values, depending on whether or not hostname
+     completion is enabled. */
+  enable_hostname_completion (perform_hostname_completion);
+
+  /* characters that need to be quoted when appearing in filenames. */
+  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;
+
+#if 0
+  /* This is superfluous and makes it impossible to use tab completion in
+     vi mode even when explicitly binding it in ~/.inputrc.  sv_strict_posix()
+     should already have called posix_readline_initialize() when
+     posixly_correct was set. */
+  if (posixly_correct)
+    posix_readline_initialize (1);
+#endif
+
+  rl_erase_empty_line = 1;
+  bash_readline_initialized = 1;
+}
+
+/* On Sun systems at least, rl_attempted_completion_function can end up
+   getting set to NULL, and rl_completion_entry_function set to do command
+   word completion if Bash is interrupted while trying to complete a command
+   word.  This just resets all the completion functions to the right thing.
+   It's called from throw_to_top_level(). */
+void
+bashline_reinitialize ()
+{
+  tilde_initialize ();
+  rl_attempted_completion_function = attempt_shell_completion;
+  rl_completion_entry_function = NULL;
+  rl_directory_completion_hook = bash_directory_completion_hook;
+  rl_ignore_some_completions_function = filename_completion_ignore;
+}
+
+/* Contains the line to push into readline. */
+static char *push_to_readline = (char *)NULL;
+
+/* Push the contents of push_to_readline into the
+   readline buffer. */
+static int
+bash_push_line ()
+{
+  if (push_to_readline)
+    {
+      rl_insert_text (push_to_readline);
+      free (push_to_readline);
+      push_to_readline = (char *)NULL;
+      rl_startup_hook = old_rl_startup_hook;
+    }
+  return 0;
+}
+
+/* Call this to set the initial text for the next line to read
+   from readline. */
+int
+bash_re_edit (line)
+     char *line;
+{
+  FREE (push_to_readline);
+
+  push_to_readline = savestring (line);
+  old_rl_startup_hook = rl_startup_hook;
+  rl_startup_hook = bash_push_line;
+
+  return (0);
+}
+
+static int
+display_shell_version (count, c)
+     int count, c;
+{
+  rl_crlf ();
+  show_shell_version (0);
+  putc ('\r', rl_outstream);
+  fflush (rl_outstream);
+  rl_on_new_line ();
+  rl_redisplay ();
+  return 0;
+}
+
+/* **************************************************************** */
+/*                                                                 */
+/*                          Readline Stuff                         */
+/*                                                                 */
+/* **************************************************************** */
+
+/* If the user requests hostname completion, then simply build a list
+   of hosts, and complete from that forever more, or at least until
+   HOSTFILE is unset. */
+
+/* THIS SHOULD BE A STRINGLIST. */
+/* The kept list of hostnames. */
+static char **hostname_list = (char **)NULL;
+
+/* The physical size of the above list. */
+static int hostname_list_size;
+
+/* The number of hostnames in the above list. */
+static int hostname_list_length;
+
+/* Whether or not HOSTNAME_LIST has been initialized. */
+int hostname_list_initialized = 0;
+
+/* Initialize the hostname completion table. */
+static void
+initialize_hostname_list ()
+{
+  char *temp;
+
+  temp = get_string_value ("HOSTFILE");
+  if (temp == 0)
+    temp = get_string_value ("hostname_completion_file");
+  if (temp == 0)
+    temp = DEFAULT_HOSTS_FILE;
+
+  snarf_hosts_from_file (temp);
+
+  if (hostname_list)
+    hostname_list_initialized++;
+}
+
+/* Add NAME to the list of hosts. */
+static void
+add_host_name (name)
+     char *name;
+{
+  if (hostname_list_length + 2 > hostname_list_size)
+    {
+      hostname_list_size = (hostname_list_size + 32) - (hostname_list_size % 32);
+      hostname_list = strvec_resize (hostname_list, hostname_list_size);
+    }
+
+  hostname_list[hostname_list_length++] = savestring (name);
+  hostname_list[hostname_list_length] = (char *)NULL;
+}
+
+#define cr_whitespace(c) ((c) == '\r' || (c) == '\n' || whitespace(c))
+
+static void
+snarf_hosts_from_file (filename)
+     char *filename;
+{
+  FILE *file;
+  char *temp, buffer[256], name[256];
+  register int i, start;
+
+  file = fopen (filename, "r");
+  if (file == 0)
+    return;
+
+  while (temp = fgets (buffer, 255, file))
+    {
+      /* Skip to first character. */
+      for (i = 0; buffer[i] && cr_whitespace (buffer[i]); i++)
+       ;
+
+      /* If comment or blank line, ignore. */
+      if (buffer[i] == '\0' || buffer[i] == '#')
+       continue;
+
+      /* If `preprocessor' directive, do the include. */
+      if (strncmp (buffer + i, "$include ", 9) == 0)
+       {
+         char *incfile, *t;
+
+         /* Find start of filename. */
+         for (incfile = buffer + i + 9; *incfile && whitespace (*incfile); incfile++)
+           ;
+
+         /* Find end of filename. */
+         for (t = incfile; *t && cr_whitespace (*t) == 0; t++)
+           ;
+
+         *t = '\0';
+
+         snarf_hosts_from_file (incfile);
+         continue;
+       }
+
+      /* Skip internet address if present. */
+      if (DIGIT (buffer[i]))
+       for (; buffer[i] && cr_whitespace (buffer[i]) == 0; i++);
+
+      /* Gobble up names.  Each name is separated with whitespace. */
+      while (buffer[i])
+       {
+         for (; cr_whitespace (buffer[i]); i++)
+           ;
+         if (buffer[i] == '\0' || buffer[i] ==  '#')
+           break;
+
+         /* Isolate the current word. */
+         for (start = i; buffer[i] && cr_whitespace (buffer[i]) == 0; i++)
+           ;
+         if (i == start)
+           continue;
+         strncpy (name, buffer + start, i - start);
+         name[i - start] = '\0';
+         add_host_name (name);
+       }
+    }
+  fclose (file);
+}
+
+/* Return the hostname list. */
+char **
+get_hostname_list ()
+{
+  if (hostname_list_initialized == 0)
+    initialize_hostname_list ();
+  return (hostname_list);
+}
+
+void
+clear_hostname_list ()
+{
+  register int i;
+
+  if (hostname_list_initialized == 0)
+    return;
+  for (i = 0; i < hostname_list_length; i++)
+    free (hostname_list[i]);
+  hostname_list_length = 0;
+}
+
+/* Return a NULL terminated list of hostnames which begin with TEXT.
+   Initialize the hostname list the first time if neccessary.
+   The array is malloc ()'ed, but not the individual strings. */
+static char **
+hostnames_matching (text)
+     char *text;
+{
+  register int i, len, nmatch, rsize;
+  char **result;
+
+  if (hostname_list_initialized == 0)
+    initialize_hostname_list ();
+
+  if (hostname_list_initialized == 0)
+    return ((char **)NULL);
+
+  /* Special case.  If TEXT consists of nothing, then the whole list is
+     what is desired. */
+  if (*text == '\0')
+    {
+      result = strvec_create (1 + hostname_list_length);
+      for (i = 0; i < hostname_list_length; i++)
+       result[i] = hostname_list[i];
+      result[i] = (char *)NULL;
+      return (result);
+    }
+
+  /* Scan until found, or failure. */
+  len = strlen (text);
+  result = (char **)NULL;
+  for (i = nmatch = rsize = 0; i < hostname_list_length; i++)
+    {
+      if (STREQN (text, hostname_list[i], len) == 0)
+       continue;
+
+      /* OK, it matches.  Add it to the list. */
+      if (nmatch >= (rsize - 1))
+       {
+         rsize = (rsize + 16) - (rsize % 16);
+         result = strvec_resize (result, rsize);
+       }
+
+      result[nmatch++] = hostname_list[i];
+    }
+  if (nmatch)
+    result[nmatch] = (char *)NULL;
+  return (result);
+}
+
+/* The equivalent of the Korn shell C-o operate-and-get-next-history-line
+   editing command. */
+static int saved_history_line_to_use = -1;
+
+static int
+set_saved_history ()
+{
+  if (saved_history_line_to_use >= 0)
+    rl_get_previous_history (history_length - saved_history_line_to_use, 0);
+  saved_history_line_to_use = -1;
+  rl_startup_hook = old_rl_startup_hook;
+  return (0);
+}
+
+static int
+operate_and_get_next (count, c)
+     int count, c;
+{
+  int where;
+
+  /* Accept the current line. */
+  rl_newline (1, c);
+
+  /* Find the current line, and find the next line to use. */
+  where = where_history ();
+
+  if ((history_is_stifled () && (history_length >= history_max_entries)) ||
+      (where >= history_length - 1))
+    saved_history_line_to_use = where;
+  else
+    saved_history_line_to_use = where + 1;
+
+  old_rl_startup_hook = rl_startup_hook;
+  rl_startup_hook = set_saved_history;
+
+  return 0;
+}
+
+/* This vi mode command causes VI_EDIT_COMMAND to be run on the current
+   command being entered (if no explicit argument is given), otherwise on
+   a command from the history file. */
+
+#define VI_EDIT_COMMAND                "fc -e \"${VISUAL:-${EDITOR:-vi}}\""
+#define EMACS_EDIT_COMMAND     "fc -e \"${VISUAL:-${EDITOR:-emacs}}\""
+#define POSIX_VI_EDIT_COMMAND  "fc -e vi"
+
+static int
+edit_and_execute_command (count, c, editing_mode, edit_command)
+     int count, c, editing_mode;
+     char *edit_command;
+{
+  char *command;
+  int r, cclc, rrs;
+
+  rrs = rl_readline_state;
+  cclc = current_command_line_count;
+
+  /* Accept the current line. */
+  rl_newline (1, c);
+
+  if (rl_explicit_arg)
+    {
+      command = (char *)xmalloc (strlen (edit_command) + 8);
+      sprintf (command, "%s %d", edit_command, count);
+    }
+  else
+    {
+      /* Take the command we were just editing, add it to the history file,
+        then call fc to operate on it.  We have to add a dummy command to
+        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 ();
+      bash_add_history (rl_line_buffer);
+      bash_add_history ("");
+      history_lines_this_session++;
+      using_history ();
+      command = savestring (edit_command);
+    }
+
+  /* Now, POSIX.1-2001 and SUSv3 say that the commands executed from the
+     temporary file should be placed into the history.  We don't do that
+     yet. */
+  r = parse_and_execute (command, (editing_mode == VI_EDITING_MODE) ? "v" : "C-xC-e", SEVAL_NOHIST);
+
+  current_command_line_count = cclc;
+
+  /* Now erase the contents of the current line and undo the effects of the
+     rl_accept_line() above.  We don't even want to make the text we just
+     executed available for undoing. */
+  rl_line_buffer[0] = '\0';    /* XXX */
+  rl_point = rl_end = 0;
+  rl_done = 0;
+  rl_readline_state = rrs;
+
+  rl_forced_update_display ();
+
+  return r;
+}
+
+#if defined (VI_MODE)
+static int
+vi_edit_and_execute_command (count, c)
+     int count, c;
+{
+  if (posixly_correct)
+    return (edit_and_execute_command (count, c, VI_EDITING_MODE, POSIX_VI_EDIT_COMMAND));
+  else
+    return (edit_and_execute_command (count, c, VI_EDITING_MODE, VI_EDIT_COMMAND));
+}
+#endif /* VI_MODE */
+
+static int
+emacs_edit_and_execute_command (count, c)
+     int count, c;
+{
+  return (edit_and_execute_command (count, c, EMACS_EDITING_MODE, EMACS_EDIT_COMMAND));
+}
+
+#if defined (ALIAS)
+static int
+posix_edit_macros (count, key)
+     int count, key;
+{
+  int c;
+  char alias_name[3], *alias_value, *macro;
+
+  c = rl_read_key ();
+  alias_name[0] = '_';
+  alias_name[1] = c;
+  alias_name[2] = '\0';
+
+  alias_value = get_alias_value (alias_name);
+  if (alias_value && *alias_value)
+    {
+      macro = savestring (alias_value);
+      rl_push_macro_input (macro);
+    }
+  return 0;
+}
+#endif
+
+/* **************************************************************** */
+/*                                                                 */
+/*                     How To Do Shell Completion                  */
+/*                                                                 */
+/* **************************************************************** */
+
+#define COMMAND_SEPARATORS ";|&{(`"
+/* )} */ 
+
+static int
+check_redir (ti)
+     int ti;
+{
+  register int this_char, prev_char;
+
+  /* Handle the two character tokens `>&', `<&', and `>|'.
+     We are not in a command position after one of these. */
+  this_char = rl_line_buffer[ti];
+  prev_char = rl_line_buffer[ti - 1];
+
+  if ((this_char == '&' && (prev_char == '<' || prev_char == '>')) ||
+      (this_char == '|' && prev_char == '>'))
+    return (1);
+  else if ((this_char == '{' && prev_char == '$') || /* } */
+          (char_is_quoted (rl_line_buffer, ti)))
+    return (1);
+  return (0);
+}
+
+#if defined (PROGRAMMABLE_COMPLETION)
+/*
+ * XXX - because of the <= start test, and setting os = s+1, this can
+ * potentially return os > start.  This is probably not what we want to
+ * happen, but fix later after 2.05a-release.
+ */
+static int
+find_cmd_start (start)
+     int start;
+{
+  register int s, os;
+
+  os = 0;
+  while (((s = skip_to_delim (rl_line_buffer, os, COMMAND_SEPARATORS)) <= start) &&
+        rl_line_buffer[s])
+    os = s+1;
+  return os;
+}
+
+static int
+find_cmd_end (end)
+     int end;
+{
+  register int e;
+
+  e = skip_to_delim (rl_line_buffer, end, COMMAND_SEPARATORS);
+  return e;
+}
+
+static char *
+find_cmd_name (start)
+     int start;
+{
+  char *name;
+  register int s, e;
+
+  for (s = start; whitespace (rl_line_buffer[s]); s++)
+    ;
+
+  /* skip until a shell break character */
+  e = skip_to_delim (rl_line_buffer, s, "()<>;&| \t\n");
+
+  name = substring (rl_line_buffer, s, e);
+
+  return (name);
+}
+
+static char *
+prog_complete_return (text, matchnum)
+     const char *text;
+     int matchnum;
+{
+  static int ind;
+
+  if (matchnum == 0)
+    ind = 0;
+
+  if (prog_complete_matches == 0 || prog_complete_matches[ind] == 0)
+    return (char *)NULL;
+  return (prog_complete_matches[ind++]);
+}
+
+#endif /* PROGRAMMABLE_COMPLETION */
+
+/* Do some completion on TEXT.  The indices of TEXT in RL_LINE_BUFFER are
+   at START and END.  Return an array of matches, or NULL if none. */
+static char **
+attempt_shell_completion (text, start, end)
+     const char *text;
+     int start, end;
+{
+  int in_command_position, ti, saveti, qc, dflags;
+  char **matches, *command_separator_chars;
+
+  command_separator_chars = COMMAND_SEPARATORS;
+  matches = (char **)NULL;
+  rl_ignore_some_completions_function = filename_completion_ignore;
+
+  /* Determine if this could be a command word.  It is if it appears at
+     the start of the line (ignoring preceding whitespace), or if it
+     appears after a character that separates commands.  It cannot be a
+     command word if we aren't at the top-level prompt. */
+  ti = start - 1;
+  saveti = qc = -1;
+
+  while ((ti > -1) && (whitespace (rl_line_buffer[ti])))
+    ti--;
+
+#if 1
+  /* If this is an open quote, maybe we're trying to complete a quoted
+     command name. */
+  if (ti >= 0 && (rl_line_buffer[ti] == '"' || rl_line_buffer[ti] == '\''))
+    {
+      qc = rl_line_buffer[ti];
+      saveti = ti--;
+      while (ti > -1 && (whitespace (rl_line_buffer[ti])))
+       ti--;
+    }
+#endif
+      
+  in_command_position = 0;
+  if (ti < 0)
+    {
+      /* Only do command completion at the start of a line when we
+        are prompting at the top level. */
+      if (current_prompt_string == ps1_prompt)
+       in_command_position++;
+    }
+  else if (member (rl_line_buffer[ti], command_separator_chars))
+    {
+      in_command_position++;
+
+      if (check_redir (ti) == 1)
+       in_command_position = 0;
+    }
+  else
+    {
+      /* This still could be in command position.  It is possible
+        that all of the previous words on the line are variable
+        assignments. */
+    }
+
+  /* Check that we haven't incorrectly flagged a closed command substitution
+     as indicating we're in a command position. */
+  if (in_command_position && ti >= 0 && rl_line_buffer[ti] == '`' &&
+       *text != '`' && unclosed_pair (rl_line_buffer, end, "`") == 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 == '`' && 
+       (in_command_position || (unclosed_pair (rl_line_buffer, start, "`") &&
+                                unclosed_pair (rl_line_buffer, end, "`"))))
+    matches = rl_completion_matches (text, command_subst_completion_function);
+
+#if defined (PROGRAMMABLE_COMPLETION)
+  /* Attempt programmable completion. */
+  if (!matches && in_command_position == 0 && prog_completion_enabled &&
+      (progcomp_size () > 0) && current_prompt_string == ps1_prompt)
+    {
+      int s, e, foundcs;
+      char *n;
+
+      /* XXX - don't free the members */
+      if (prog_complete_matches)
+       free (prog_complete_matches);
+      prog_complete_matches = (char **)NULL;
+
+      s = find_cmd_start (start);
+      e = find_cmd_end (end);
+      n = find_cmd_name (s);
+      if (e > s && assignment (n, 0) == 0)
+       prog_complete_matches = programmable_completions (n, text, s, e, &foundcs);
+      else
+       foundcs = 0;
+      FREE (n);
+      /* XXX - if we found a COMPSPEC for the command, just return whatever
+        the programmable completion code returns, and disable the default
+        filename completion that readline will do unless the COPT_DEFAULT
+        option has been set with the `-o default' option to complete. */
+      if (foundcs)
+       {
+         /* If the user specified that the compspec returns filenames, make
+            sure that readline knows it. */
+         if (foundcs & COPT_FILENAMES)
+           rl_filename_completion_desired = 1;
+         /* If the user doesn't want a space appended, tell readline. */
+         if (foundcs & COPT_NOSPACE)
+           rl_completion_suppress_append = 1;
+         /* Turn what the programmable completion code returns into what
+            readline wants.  I should have made compute_lcd_of_matches
+            external... */
+         matches = rl_completion_matches (text, prog_complete_return);
+         if ((foundcs & COPT_DEFAULT) == 0)
+           rl_attempted_completion_over = 1;   /* no default */
+         if (matches || ((foundcs & COPT_BASHDEFAULT) == 0))
+           return (matches);
+       }
+    }
+#endif
+
+  if (matches == 0)
+    {
+      dflags = 0;
+      if (in_command_position)
+       dflags |= DEFCOMP_CMDPOS;
+      matches = bash_default_completion (text, start, end, qc, dflags);
+    }
+
+  return matches;
+}
+
+char **
+bash_default_completion (text, start, end, qc, compflags)
+     const char *text;
+     int start, end, qc, compflags;
+{
+  char **matches;
+
+  matches = (char **)NULL;
+
+  /* New posix-style command substitution or variable name? */
+  if (!matches && *text == '$')
+    {
+      if (qc != '\'' && text[1] == '(') /* ) */
+       matches = rl_completion_matches (text, command_subst_completion_function);
+      else
+       matches = rl_completion_matches (text, variable_completion_function);
+    }
+
+  /* If the word starts in `~', and there is no slash in the word, then
+     try completing this word as a username. */
+  if (!matches && *text == '~' && !xstrchr (text, '/'))
+    matches = rl_completion_matches (text, rl_username_completion_function);
+
+  /* Another one.  Why not?  If the word starts in '@', then look through
+     the world of known hostnames for completion first. */
+  if (!matches && perform_hostname_completion && *text == '@')
+    matches = rl_completion_matches (text, hostname_completion_function);
+
+  /* And last, (but not least) if this word is in a command position, then
+     complete over possible command names, including aliases, functions,
+     and command names. */
+  if (matches == 0 && (compflags & DEFCOMP_CMDPOS))
+    {
+      /* If END == START and text[0] == 0, we are trying to complete an empty
+        command word. */
+      if (no_empty_command_completion && end == start && text[0] == '\0')
+       {
+         matches = (char **)NULL;
+         rl_ignore_some_completions_function = bash_ignore_everything;
+       }
+      else
+       {
+#define CMD_IS_DIR(x)  (absolute_pathname(x) == 0 && absolute_program(x) == 0 && *(x) != '~' && test_for_directory (x))
+
+         dot_in_path = 0;
+         matches = rl_completion_matches (text, command_word_completion_function);
+
+         /* If we are attempting command completion and nothing matches, we
+            do not want readline to perform filename completion for us.  We
+            still want to be able to complete partial pathnames, so set the
+            completion ignore function to something which will remove
+            filenames and leave directories in the match list. */
+         if (matches == (char **)NULL)
+           rl_ignore_some_completions_function = bash_ignore_filenames;
+         else if (matches[1] == 0 && CMD_IS_DIR(matches[0]) && dot_in_path == 0)
+           /* If we found a single match, without looking in the current
+              directory (because it's not in $PATH), but the found name is
+              also a command in the current directory, suppress appending any
+              terminating character, since it's ambiguous. */
+           {
+             rl_completion_suppress_append = 1;
+             rl_filename_completion_desired = 0;
+           }
+         else if (matches[0] && matches[1] && STREQ (matches[0], matches[1]) && CMD_IS_DIR (matches[0]))
+           /* There are multiple instances of the same match (duplicate
+              completions haven't yet been removed).  In this case, all of
+              the matches will be the same, and the duplicate removal code
+              will distill them all down to one.  We turn on
+              rl_completion_suppress_append for the same reason as above.
+              Remember: we only care if there's eventually a single unique
+              completion.  If there are multiple completions this won't
+              make a difference and the problem won't occur. */
+           {
+             rl_completion_suppress_append = 1;
+             rl_filename_completion_desired = 0;
+           }
+       }
+    }
+
+  /* This could be a globbing pattern, so try to expand it using pathname
+     expansion. */
+  if (!matches && glob_pattern_p (text))
+    {
+      matches = rl_completion_matches (text, glob_complete_word);
+      /* A glob expression that matches more than one filename is problematic.
+        If we match more than one filename, punt. */
+      if (matches && matches[1] && rl_completion_type == TAB)
+       {
+         strvec_dispose (matches);
+         matches = (char **)0;
+       }
+    }
+
+  return (matches);
+}
+
+/* This is the function to call when the word to complete is in a position
+   where a command word can be found.  It grovels $PATH, looking for commands
+   that match.  It also scans aliases, function names, and the shell_builtin
+   table. */
+char *
+command_word_completion_function (hint_text, state)
+     const char *hint_text;
+     int state;
+{
+  static char *hint = (char *)NULL;
+  static char *path = (char *)NULL;
+  static char *val = (char *)NULL;
+  static char *filename_hint = (char *)NULL;
+  static char *dequoted_hint = (char *)NULL;
+  static int path_index, hint_len, dequoted_len, istate, igncase;
+  static int mapping_over, local_index, searching_path, hint_is_dir;
+  static SHELL_VAR **varlist = (SHELL_VAR **)NULL;
+#if defined (ALIAS)
+  static alias_t **alias_list = (alias_t **)NULL;
+#endif /* ALIAS */
+  char *temp;
+
+  /* We have to map over the possibilities for command words.  If we have
+     no state, then make one just for that purpose. */
+  if (!state)
+    {
+      if (dequoted_hint && dequoted_hint != hint)
+       free (dequoted_hint);
+      if (hint)
+       free (hint);
+
+      mapping_over = searching_path = 0;
+      hint_is_dir = CMD_IS_DIR (hint_text);
+      val = (char *)NULL;
+
+      temp = rl_variable_value ("completion-ignore-case");
+      igncase = strcmp (temp, "on") == 0;
+
+      /* If this is an absolute program name, do not check it against
+        aliases, reserved words, functions or builtins.  We must check
+        whether or not it is unique, and, if so, whether that filename
+        is executable. */
+      if (absolute_program (hint_text))
+       {
+         /* Perform tilde expansion on what's passed, so we don't end up
+            passing filenames with tildes directly to stat(). */
+         if (*hint_text == '~')
+           hint = bash_tilde_expand (hint_text, 0);
+         else
+           hint = savestring (hint_text);
+
+         dequoted_hint = hint;
+         /* If readline's completer found a quote character somewhere, but
+            didn't set the quote character, there must have been a quote
+            character embedded in the filename.  It can't be at the start of
+            the filename, so we need to dequote the filename before we look
+            in the file system for it. */
+         if (rl_completion_found_quote && rl_completion_quote_character == 0)
+           {
+             dequoted_hint = bash_dequote_filename (hint, 0);
+             free (hint);
+             hint = dequoted_hint;
+           }
+         dequoted_len = hint_len = strlen (hint);
+
+         if (filename_hint)
+           free (filename_hint);
+
+         filename_hint = savestring (hint);
+
+         mapping_over = 4;
+         istate = 0;
+         goto inner;
+       }
+
+      dequoted_hint = hint = savestring (hint_text);
+      dequoted_len = hint_len = strlen (hint);
+
+      if (rl_completion_found_quote && rl_completion_quote_character == 0)
+       {
+         dequoted_hint = bash_dequote_filename (hint, 0);
+         dequoted_len = strlen (dequoted_hint);
+       }
+      
+      path = get_string_value ("PATH");
+      path_index = dot_in_path = 0;
+
+      /* Initialize the variables for each type of command word. */
+      local_index = 0;
+
+      if (varlist)
+       free (varlist);
+
+      varlist = all_visible_functions ();
+
+#if defined (ALIAS)
+      if (alias_list)
+       free (alias_list);
+
+      alias_list = all_aliases ();
+#endif /* ALIAS */
+    }
+
+  /* mapping_over says what we are currently hacking.  Note that every case
+     in this list must fall through when there are no more possibilities. */
+
+  switch (mapping_over)
+    {
+    case 0:                    /* Aliases come first. */
+#if defined (ALIAS)
+      while (alias_list && alias_list[local_index])
+       {
+         register char *alias;
+
+         alias = alias_list[local_index++]->name;
+
+         if (STREQN (alias, hint, hint_len))
+           return (savestring (alias));
+       }
+#endif /* ALIAS */
+      local_index = 0;
+      mapping_over++;
+
+    case 1:                    /* Then shell reserved words. */
+      {
+       while (word_token_alist[local_index].word)
+         {
+           register char *reserved_word;
+
+           reserved_word = word_token_alist[local_index++].word;
+
+           if (STREQN (reserved_word, hint, hint_len))
+             return (savestring (reserved_word));
+         }
+       local_index = 0;
+       mapping_over++;
+      }
+
+    case 2:                    /* Then function names. */
+      while (varlist && varlist[local_index])
+       {
+         register char *varname;
+
+         varname = varlist[local_index++]->name;
+
+         if (STREQN (varname, hint, hint_len))
+           return (savestring (varname));
+       }
+      local_index = 0;
+      mapping_over++;
+
+    case 3:                    /* Then shell builtins. */
+      for (; local_index < num_shell_builtins; local_index++)
+       {
+         /* Ignore it if it doesn't have a function pointer or if it
+            is not currently enabled. */
+         if (!shell_builtins[local_index].function ||
+             (shell_builtins[local_index].flags & BUILTIN_ENABLED) == 0)
+           continue;
+
+         if (STREQN (shell_builtins[local_index].name, hint, hint_len))
+           {
+             int i = local_index++;
+
+             return (savestring (shell_builtins[i].name));
+           }
+       }
+      local_index = 0;
+      mapping_over++;
+    }
+
+  /* If the text passed is a directory in the current directory, return it
+     as a possible match.  Executables in directories in the current
+     directory can be specified using relative pathnames and successfully
+     executed even when `.' is not in $PATH. */
+  if (hint_is_dir)
+    {
+      hint_is_dir = 0; /* only return the hint text once */
+      return (savestring (hint_text));
+    }
+    
+  /* Repeatedly call filename_completion_function while we have
+     members of PATH left.  Question:  should we stat each file?
+     Answer: we call executable_file () on each file. */
+ outer:
+
+  istate = (val != (char *)NULL);
+
+  if (!istate)
+    {
+      char *current_path;
+
+      /* Get the next directory from the path.  If there is none, then we
+        are all done. */
+      if (!path || !path[path_index] ||
+         (current_path = extract_colon_unit (path, &path_index)) == 0)
+       return ((char *)NULL);
+
+      searching_path = 1;
+      if (*current_path == 0)
+       {
+         free (current_path);
+         current_path = savestring (".");
+       }
+
+      if (*current_path == '~')
+       {
+         char *t;
+
+         t = bash_tilde_expand (current_path, 0);
+         free (current_path);
+         current_path = t;
+       }
+
+      if (current_path[0] == '.' && current_path[1] == '\0')
+       dot_in_path = 1;
+
+      if (filename_hint)
+       free (filename_hint);
+
+      filename_hint = sh_makepath (current_path, hint, 0);
+      free (current_path);
+    }
+
+ inner:
+  val = rl_filename_completion_function (filename_hint, istate);
+  istate = 1;
+
+  if (val == 0)
+    {
+      /* If the hint text is an absolute program, then don't bother
+        searching through PATH. */
+      if (absolute_program (hint))
+       return ((char *)NULL);
+
+      goto outer;
+    }
+  else
+    {
+      int match, freetemp;
+#if 0
+      char *temp;              /* shadows previous declaration */
+#endif
+
+      if (absolute_program (hint))
+       {
+         if (igncase == 0)
+           match = strncmp (val, hint, hint_len) == 0;
+         else
+           match = strncasecmp (val, hint, hint_len) == 0;
+
+         /* If we performed tilde expansion, restore the original
+            filename. */
+         if (*hint_text == '~')
+           {
+             int l, tl, vl, dl;
+             char *rd;
+             vl = strlen (val);
+             tl = strlen (hint_text);
+#if 0
+             l = vl - hint_len;        /* # of chars added */
+#else
+             rd = savestring (filename_hint);
+             bash_directory_expansion (&rd);
+             dl = strlen (rd);
+             l = vl - dl;              /* # of chars added */
+             free (rd);
+#endif
+             temp = (char *)xmalloc (l + 2 + tl);
+             strcpy (temp, hint_text);
+             strcpy (temp + tl, val + vl - l);
+           }
+         else
+           temp = savestring (val);
+         freetemp = 1;
+       }
+      else
+       {
+         temp = strrchr (val, '/');
+
+         if (temp)
+           {
+             temp++;
+             if (igncase == 0)
+               freetemp = match = strncmp (temp, hint, hint_len) == 0;
+             else
+               freetemp = match = strncasecmp (temp, hint, hint_len) == 0;
+             if (match)
+               temp = savestring (temp);
+           }
+         else
+           freetemp = match = 0;
+       }
+
+#if 0
+      /* If we have found a match, and it is an executable file or a
+        directory name, return it. */
+      if (match && executable_or_directory (val))
+#else
+      /* If we have found a match, and it is an executable file, return it.
+        We don't return directory names when searching $PATH, since the
+        bash execution code won't find executables in directories which
+        appear in directories in $PATH when they're specified using
+        relative pathnames. */
+      if (match && (searching_path ? executable_file (val) : executable_or_directory (val)))
+#endif
+       {
+         free (val);
+         val = "";             /* So it won't be NULL. */
+         return (temp);
+       }
+      else
+       {
+         if (freetemp)
+           free (temp);
+         free (val);
+         goto inner;
+       }
+    }
+}
+
+/* Completion inside an unterminated command substitution. */
+static char *
+command_subst_completion_function (text, state)
+     const char *text;
+     int state;
+{
+  static char **matches = (char **)NULL;
+  static const char *orig_start;
+  static char *filename_text = (char *)NULL;
+  static int cmd_index, start_len;
+  char *value;
+
+  if (state == 0)
+    {
+      if (filename_text)
+       free (filename_text);
+      orig_start = text;
+      if (*text == '`')
+       text++;
+      else if (*text == '$' && text[1] == '(') /* ) */
+       text += 2;
+      /* If the text was quoted, suppress any quote character that the
+        readline completion code would insert. */
+      rl_completion_suppress_quote = 1;
+      start_len = text - orig_start;
+      filename_text = savestring (text);
+      if (matches)
+       free (matches);
+
+      /*
+       * At this point we can entertain the idea of re-parsing
+       * `filename_text' into a (possibly incomplete) command name and
+       * arguments, and doing completion based on that.  This is
+       * currently very rudimentary, but it is a small improvement.
+       */
+      for (value = filename_text + strlen (filename_text) - 1; value > filename_text; value--)
+        if (whitespace (*value) || member (*value, COMMAND_SEPARATORS))
+          break;
+      if (value <= filename_text)
+       matches = rl_completion_matches (filename_text, command_word_completion_function);
+      else
+       {
+         value++;
+         start_len += value - filename_text;
+         if (whitespace (value[-1]))
+           matches = rl_completion_matches (value, rl_filename_completion_function);
+         else
+           matches = rl_completion_matches (value, command_word_completion_function);
+       }
+
+      /* If there is more than one match, rl_completion_matches has already
+        put the lcd in matches[0].  Skip over it. */
+      cmd_index = matches && matches[0] && matches[1];
+
+      /* If there's a single match and it's a directory, set the append char
+        to the expected `/'.  Otherwise, don't append anything. */
+      if (matches && matches[0] && matches[1] == 0 && test_for_directory (matches[0]))
+       rl_completion_append_character = '/';
+      else
+       rl_completion_suppress_append = 1;
+    }
+
+  if (!matches || !matches[cmd_index])
+    {
+      rl_filename_quoting_desired = 0; /* disable quoting */
+      return ((char *)NULL);
+    }
+  else
+    {
+      value = (char *)xmalloc (1 + start_len + strlen (matches[cmd_index]));
+
+      if (start_len == 1)
+       value[0] = *orig_start;
+      else
+       strncpy (value, orig_start, start_len);
+
+      strcpy (value + start_len, matches[cmd_index]);
+
+      cmd_index++;
+      return (value);
+    }
+}
+
+/* Okay, now we write the entry_function for variable completion. */
+static char *
+variable_completion_function (text, state)
+     const char *text;
+     int state;
+{
+  static char **varlist = (char **)NULL;
+  static int varlist_index;
+  static char *varname = (char *)NULL;
+  static int namelen;
+  static int first_char, first_char_loc;
+
+  if (!state)
+    {
+      if (varname)
+       free (varname);
+
+      first_char_loc = 0;
+      first_char = text[0];
+
+      if (first_char == '$')
+       first_char_loc++;
+
+      if (text[first_char_loc] == '{')
+       first_char_loc++;
+
+      varname = savestring (text + first_char_loc);
+
+      namelen = strlen (varname);
+      if (varlist)
+       strvec_dispose (varlist);
+
+      varlist = all_variables_matching_prefix (varname);
+      varlist_index = 0;
+    }
+
+  if (!varlist || !varlist[varlist_index])
+    {
+      return ((char *)NULL);
+    }
+  else
+    {
+      char *value;
+
+      value = (char *)xmalloc (4 + strlen (varlist[varlist_index]));
+
+      if (first_char_loc)
+       {
+         value[0] = first_char;
+         if (first_char_loc == 2)
+           value[1] = '{';
+       }
+
+      strcpy (value + first_char_loc, varlist[varlist_index]);
+      if (first_char_loc == 2)
+       strcat (value, "}");
+
+      varlist_index++;
+      return (value);
+    }
+}
+
+/* How about a completion function for hostnames? */
+static char *
+hostname_completion_function (text, state)
+     const char *text;
+     int state;
+{
+  static char **list = (char **)NULL;
+  static int list_index = 0;
+  static int first_char, first_char_loc;
+
+  /* If we don't have any state, make some. */
+  if (state == 0)
+    {
+      FREE (list);
+
+      list = (char **)NULL;
+
+      first_char_loc = 0;
+      first_char = *text;
+
+      if (first_char == '@')
+       first_char_loc++;
+
+      list = hostnames_matching ((char *)text+first_char_loc);
+      list_index = 0;
+    }
+
+  if (list && list[list_index])
+    {
+      char *t;
+
+      t = (char *)xmalloc (2 + strlen (list[list_index]));
+      *t = first_char;
+      strcpy (t + first_char_loc, list[list_index]);
+      list_index++;
+      return (t);
+    }
+
+  return ((char *)NULL);
+}
+
+/*
+ * A completion function for service names from /etc/services (or wherever).
+ */
+char *
+bash_servicename_completion_function (text, state)
+     const char *text;
+     int state;
+{
+#if defined (__WIN32__) || defined (__OPENNT) || !defined (HAVE_GETSERVENT)
+  return ((char *)NULL);
+#else
+  static char *sname = (char *)NULL;
+  static struct servent *srvent;
+  static int snamelen, firstc;
+  char *value;
+  char **alist, *aentry;
+  int afound;
+
+  if (state == 0)
+    {
+      FREE (sname);
+      firstc = *text;
+
+      sname = savestring (text);
+      snamelen = strlen (sname);
+      setservent (0);
+    }
+
+  while (srvent = getservent ())
+    {
+      afound = 0;
+      if (snamelen == 0 || (STREQN (sname, srvent->s_name, snamelen)))
+       break;
+      /* Not primary, check aliases */
+      for (alist = srvent->s_aliases; *alist; alist++)
+       {
+         aentry = *alist;
+         if (STREQN (sname, aentry, snamelen))
+           {
+             afound = 1;
+             break;
+           }
+       }
+
+      if (afound)
+       break;
+    }
+
+  if (srvent == 0)
+    {
+      endservent ();
+      return ((char *)NULL);
+    }
+
+  value = afound ? savestring (aentry) : savestring (srvent->s_name);
+  return value;
+#endif
+}
+
+/*
+ * A completion function for group names from /etc/group (or wherever).
+ */
+char *
+bash_groupname_completion_function (text, state)
+     const char *text;
+     int state;
+{
+#if defined (__WIN32__) || defined (__OPENNT) || !defined (HAVE_GRP_H)
+  return ((char *)NULL);
+#else
+  static char *gname = (char *)NULL;
+  static struct group *grent;
+  static int gnamelen;
+  char *value;
+
+  if (state == 0)
+    {
+      FREE (gname);
+      gname = savestring (text);
+      gnamelen = strlen (gname);
+
+      setgrent ();
+    }
+
+  while (grent = getgrent ())
+    {
+      if (gnamelen == 0 || (STREQN (gname, grent->gr_name, gnamelen)))
+        break;
+    }
+
+  if (grent == 0)
+    {
+      endgrent ();
+      return ((char *)NULL);
+    }
+
+  value = savestring (grent->gr_name);
+  return (value);
+#endif
+}
+
+/* Functions to perform history and alias expansions on the current line. */
+
+#if defined (BANG_HISTORY)
+/* Perform history expansion on the current line.  If no history expansion
+   is done, pre_process_line() returns what it was passed, so we need to
+   allocate a new line here. */
+static char *
+history_expand_line_internal (line)
+     char *line;
+{
+  char *new_line;
+  int old_verify;
+
+  old_verify = hist_verify;
+  hist_verify = 0;
+  new_line = pre_process_line (line, 0, 0);
+  hist_verify = old_verify;
+
+  return (new_line == line) ? savestring (line) : new_line;
+}
+#endif
+
+/* There was an error in expansion.  Let the preprocessor print
+   the error here. */
+static void
+cleanup_expansion_error ()
+{
+  char *to_free;
+#if defined (BANG_HISTORY)
+  int old_verify;
+
+  old_verify = hist_verify;
+  hist_verify = 0;
+#endif
+
+  fprintf (rl_outstream, "\r\n");
+  to_free = pre_process_line (rl_line_buffer, 1, 0);
+#if defined (BANG_HISTORY)
+  hist_verify = old_verify;
+#endif
+  if (to_free != rl_line_buffer)
+    FREE (to_free);
+  putc ('\r', rl_outstream);
+  rl_forced_update_display ();
+}
+
+/* If NEW_LINE differs from what is in the readline line buffer, add an
+   undo record to get from the readline line buffer contents to the new
+   line and make NEW_LINE the current readline line. */
+static void
+maybe_make_readline_line (new_line)
+     char *new_line;
+{
+  if (strcmp (new_line, rl_line_buffer) != 0)
+    {
+      rl_point = rl_end;
+
+      rl_add_undo (UNDO_BEGIN, 0, 0, 0);
+      rl_delete_text (0, rl_point);
+      rl_point = rl_end = rl_mark = 0;
+      rl_insert_text (new_line);
+      rl_add_undo (UNDO_END, 0, 0, 0);
+    }
+}
+
+/* Make NEW_LINE be the current readline line.  This frees NEW_LINE. */
+static void
+set_up_new_line (new_line)
+     char *new_line;
+{
+  int old_point, at_end;
+
+  old_point = rl_point;
+  at_end = rl_point == rl_end;
+
+  /* If the line was history and alias expanded, then make that
+     be one thing to undo. */
+  maybe_make_readline_line (new_line);
+  free (new_line);
+
+  /* Place rl_point where we think it should go. */
+  if (at_end)
+    rl_point = rl_end;
+  else if (old_point < rl_end)
+    {
+      rl_point = old_point;
+      if (!whitespace (rl_line_buffer[rl_point]))
+       rl_forward_word (1, 0);
+    }
+}
+
+#if defined (ALIAS)
+/* Expand aliases in the current readline line. */
+static int
+alias_expand_line (count, ignore)
+     int count, ignore;
+{
+  char *new_line;
+
+  new_line = alias_expand (rl_line_buffer);
+
+  if (new_line)
+    {
+      set_up_new_line (new_line);
+      return (0);
+    }
+  else
+    {
+      cleanup_expansion_error ();
+      return (1);
+    }
+}
+#endif
+
+#if defined (BANG_HISTORY)
+/* History expand the line. */
+static int
+history_expand_line (count, ignore)
+     int count, ignore;
+{
+  char *new_line;
+
+  new_line = history_expand_line_internal (rl_line_buffer);
+
+  if (new_line)
+    {
+      set_up_new_line (new_line);
+      return (0);
+    }
+  else
+    {
+      cleanup_expansion_error ();
+      return (1);
+    }
+}
+
+/* Expand history substitutions in the current line and then insert a
+   space (hopefully close to where we were before). */
+static int
+tcsh_magic_space (count, ignore)
+     int count, ignore;
+{
+  int dist_from_end, old_point;
+
+  old_point = rl_point;
+  dist_from_end = rl_end - rl_point;
+  if (history_expand_line (count, ignore) == 0)
+    {
+      /* Try a simple heuristic from Stephen Gildea <gildea@intouchsys.com>.
+        This works if all expansions were before rl_point or if no expansions
+        were performed. */
+      rl_point = (old_point == 0) ? old_point : rl_end - dist_from_end;
+      rl_insert (1, ' ');
+      return (0);
+    }
+  else
+    return (1);
+}
+#endif /* BANG_HISTORY */
+
+/* History and alias expand the line. */
+static int
+history_and_alias_expand_line (count, ignore)
+     int count, ignore;
+{
+  char *new_line;
+
+  new_line = 0;
+#if defined (BANG_HISTORY)
+  new_line = history_expand_line_internal (rl_line_buffer);
+#endif
+
+#if defined (ALIAS)
+  if (new_line)
+    {
+      char *alias_line;
+
+      alias_line = alias_expand (new_line);
+      free (new_line);
+      new_line = alias_line;
+    }
+#endif /* ALIAS */
+
+  if (new_line)
+    {
+      set_up_new_line (new_line);
+      return (0);
+    }
+  else
+    {
+      cleanup_expansion_error ();
+      return (1);
+    }
+}
+
+/* History and alias expand the line, then perform the shell word
+   expansions by calling expand_string.  This can't use set_up_new_line()
+   because we want the variable expansions as a separate undo'able
+   set of operations. */
+static int
+shell_expand_line (count, ignore)
+     int count, ignore;
+{
+  char *new_line;
+  WORD_LIST *expanded_string;
+
+  new_line = 0;
+#if defined (BANG_HISTORY)
+  new_line = history_expand_line_internal (rl_line_buffer);
+#endif
+
+#if defined (ALIAS)
+  if (new_line)
+    {
+      char *alias_line;
+
+      alias_line = alias_expand (new_line);
+      free (new_line);
+      new_line = alias_line;
+    }
+#endif /* ALIAS */
+
+  if (new_line)
+    {
+      int old_point = rl_point;
+      int at_end = rl_point == rl_end;
+
+      /* If the line was history and alias expanded, then make that
+        be one thing to undo. */
+      maybe_make_readline_line (new_line);
+      free (new_line);
+
+      /* If there is variable expansion to perform, do that as a separate
+        operation to be undone. */
+      new_line = savestring (rl_line_buffer);
+      expanded_string = expand_string (new_line, 0);
+      FREE (new_line);
+      if (expanded_string == 0)
+       {
+         new_line = (char *)xmalloc (1);
+         new_line[0] = '\0';
+       }
+      else
+       {
+         new_line = string_list (expanded_string);
+         dispose_words (expanded_string);
+       }
+
+      maybe_make_readline_line (new_line);
+      free (new_line);
+
+      /* Place rl_point where we think it should go. */
+      if (at_end)
+       rl_point = rl_end;
+      else if (old_point < rl_end)
+       {
+         rl_point = old_point;
+         if (!whitespace (rl_line_buffer[rl_point]))
+           rl_forward_word (1, 0);
+       }
+      return 0;
+    }
+  else
+    {
+      cleanup_expansion_error ();
+      return 1;
+    }
+}
+
+/* If FIGNORE is set, then don't match files with the given suffixes when
+   completing filenames.  If only one of the possibilities has an acceptable
+   suffix, delete the others, else just return and let the completer
+   signal an error.  It is called by the completer when real
+   completions are done on filenames by the completer's internal
+   function, not for completion lists (M-?) and not on "other"
+   completion types, such as hostnames or commands. */
+
+static struct ignorevar fignore =
+{
+  "FIGNORE",
+  (struct ign *)0,
+  0,
+  (char *)0,
+  (sh_iv_item_func_t *) 0,
+};
+
+static void
+_ignore_completion_names (names, name_func)
+     char **names;
+     sh_ignore_func_t *name_func;
+{
+  char **newnames;
+  int idx, nidx;
+  char **oldnames;
+  int oidx;
+
+  /* If there is only one completion, see if it is acceptable.  If it is
+     not, free it up.  In any case, short-circuit and return.  This is a
+     special case because names[0] is not the prefix of the list of names
+     if there is only one completion; it is the completion itself. */
+  if (names[1] == (char *)0)
+    {
+      if (force_fignore)
+       if ((*name_func) (names[0]) == 0)
+         {
+           free (names[0]);
+           names[0] = (char *)NULL;
+         }
+
+      return;
+    }
+
+  /* Allocate space for array to hold list of pointers to matching
+     filenames.  The pointers are copied back to NAMES when done. */
+  for (nidx = 1; names[nidx]; nidx++)
+    ;
+  newnames = strvec_create (nidx + 1);
+
+  if (force_fignore == 0)
+    {
+      oldnames = strvec_create (nidx - 1);
+      oidx = 0;
+    }
+
+  newnames[0] = names[0];
+  for (idx = nidx = 1; names[idx]; idx++)
+    {
+      if ((*name_func) (names[idx]))
+       newnames[nidx++] = names[idx];
+      else if (force_fignore == 0)
+       oldnames[oidx++] = names[idx];
+      else
+       free (names[idx]);
+    }
+
+  newnames[nidx] = (char *)NULL;
+
+  /* If none are acceptable then let the completer handle it. */
+  if (nidx == 1)
+    {
+      if (force_fignore)
+       {
+         free (names[0]);
+         names[0] = (char *)NULL;
+       }
+      else
+       free (oldnames);
+
+      free (newnames);
+      return;
+    }
+
+  if (force_fignore == 0)
+    {
+      while (oidx)
+       free (oldnames[--oidx]);
+      free (oldnames);
+    }
+
+  /* If only one is acceptable, copy it to names[0] and return. */
+  if (nidx == 2)
+    {
+      free (names[0]);
+      names[0] = newnames[1];
+      names[1] = (char *)NULL;
+      free (newnames);
+      return;
+    }
+
+  /* Copy the acceptable names back to NAMES, set the new array end,
+     and return. */
+  for (nidx = 1; newnames[nidx]; nidx++)
+    names[nidx] = newnames[nidx];
+  names[nidx] = (char *)NULL;
+  free (newnames);
+}
+
+static int
+name_is_acceptable (name)
+     const char *name;
+{
+  struct ign *p;
+  int nlen;
+
+  for (nlen = strlen (name), p = fignore.ignores; p->val; p++)
+    {
+      if (nlen > p->len && p->len > 0 && STREQ (p->val, &name[nlen - p->len]))
+       return (0);
+    }
+
+  return (1);
+}
+
+#if 0
+static int
+ignore_dot_names (name)
+     char *name;
+{
+  return (name[0] != '.');
+}
+#endif
+
+static int
+filename_completion_ignore (names)
+     char **names;
+{
+#if 0
+  if (glob_dot_filenames == 0)
+    _ignore_completion_names (names, ignore_dot_names);
+#endif
+
+  setup_ignore_patterns (&fignore);
+
+  if (fignore.num_ignores == 0)
+    return 0;
+
+  _ignore_completion_names (names, name_is_acceptable);
+
+  return 0;
+}
+
+/* Return 1 if NAME is a directory. */
+static int
+test_for_directory (name)
+     const char *name;
+{
+  struct stat finfo;
+  char *fn;
+
+  fn = bash_tilde_expand (name, 0);
+  if (stat (fn, &finfo) != 0)
+    {
+      free (fn);
+      return 0;
+    }
+  free (fn);
+  return (S_ISDIR (finfo.st_mode));
+}
+
+/* Remove files from NAMES, leaving directories. */
+static int
+bash_ignore_filenames (names)
+     char **names;
+{
+  _ignore_completion_names (names, test_for_directory);
+  return 0;
+}
+
+static int
+return_zero (name)
+     const char *name;
+{
+  return 0;
+}
+
+static int
+bash_ignore_everything (names)
+     char **names;
+{
+  _ignore_completion_names (names, return_zero);
+  return 0;
+}
+
+/* Simulate the expansions that will be performed by
+   rl_filename_completion_function.  This must be called with the address of
+   a pointer to malloc'd memory. */
+static void
+bash_directory_expansion (dirname)
+     char **dirname;
+{
+  char *d, *nd;
+
+  d = savestring (*dirname);
+
+  if (rl_directory_rewrite_hook)
+    (*rl_directory_rewrite_hook) (&d);
+
+  if (rl_directory_completion_hook && (*rl_directory_completion_hook) (&d))
+    {
+      free (*dirname);
+      *dirname = d;
+    }
+  else if (rl_completion_found_quote)
+    {
+      nd = bash_dequote_filename (d, rl_completion_quote_character);
+      free (*dirname);
+      free (d);
+      *dirname = nd;
+    }
+}
+  
+/* Handle symbolic link references and other directory name
+   expansions while hacking completion. */
+static int
+bash_directory_completion_hook (dirname)
+     char **dirname;
+{
+  char *local_dirname, *new_dirname, *t;
+  int return_value, should_expand_dirname;
+  WORD_LIST *wl;
+  struct stat sb;
+
+  return_value = should_expand_dirname = 0;
+  local_dirname = *dirname;
+
+#if 0
+  should_expand_dirname = xstrchr (local_dirname, '$') || xstrchr (local_dirname, '`');
+#else
+  if (xstrchr (local_dirname, '$'))
+    should_expand_dirname = 1;
+  else
+    {
+      t = xstrchr (local_dirname, '`');
+      if (t && unclosed_pair (local_dirname, strlen (local_dirname), "`") == 0)
+       should_expand_dirname = 1;
+    }
+#endif
+
+#if defined (HAVE_LSTAT)
+  if (should_expand_dirname && lstat (local_dirname, &sb) == 0)
+#else
+  if (should_expand_dirname && stat (local_dirname, &sb) == 0)
+#endif
+    should_expand_dirname = 0;
+
+  if (should_expand_dirname)  
+    {
+      new_dirname = savestring (local_dirname);
+      wl = expand_prompt_string (new_dirname, 0);      /* does the right thing */
+      if (wl)
+       {
+         *dirname = string_list (wl);
+         /* Tell the completer to replace the directory name only if we
+            actually expanded something. */
+         return_value = STREQ (local_dirname, *dirname) == 0;
+         free (local_dirname);
+         free (new_dirname);
+         dispose_words (wl);
+         local_dirname = *dirname;
+       }
+      else
+       {
+         free (new_dirname);
+         free (local_dirname);
+         *dirname = (char *)xmalloc (1);
+         **dirname = '\0';
+         return 1;
+       }
+    }
+  else 
+    {
+      /* Dequote the filename even if we don't expand it. */
+      new_dirname = bash_dequote_filename (local_dirname, rl_completion_quote_character);
+      free (local_dirname);
+      local_dirname = *dirname = new_dirname;
+    }
+
+  if (!no_symbolic_links && (local_dirname[0] != '.' || local_dirname[1]))
+    {
+      char *temp1, *temp2;
+      int len1, len2;
+
+      t = get_working_directory ("symlink-hook");
+      temp1 = make_absolute (local_dirname, t);
+      free (t);
+      temp2 = sh_canonpath (temp1, PATH_CHECKDOTDOT|PATH_CHECKEXISTS);
+      /* If we can't canonicalize, bail. */
+      if (temp2 == 0)
+       {
+         free (temp1);
+         return 1;
+       }
+      len1 = strlen (temp1);
+      if (temp1[len1 - 1] == '/')
+       {
+         len2 = strlen (temp2);
+         if (len2 > 2)         /* don't append `/' to `/' or `//' */
+           {
+             temp2 = (char *)xrealloc (temp2, len2 + 2);
+             temp2[len2] = '/';
+             temp2[len2 + 1] = '\0';
+           }
+       }
+      free (local_dirname);
+      *dirname = temp2;
+      free (temp1);
+    }
+  return (return_value);
+}
+
+static char **history_completion_array = (char **)NULL;
+static int harry_size;
+static int harry_len;
+
+static void
+build_history_completion_array ()
+{
+  register int i, j;
+  HIST_ENTRY **hlist;
+  char **tokens;
+
+  /* First, clear out the current dynamic history completion list. */
+  if (harry_size)
+    {
+      strvec_dispose (history_completion_array);
+      history_completion_array = (char **)NULL;
+      harry_size = 0;
+      harry_len = 0;
+    }
+
+  /* Next, grovel each line of history, making each shell-sized token
+     a separate entry in the history_completion_array. */
+  hlist = history_list ();
+
+  if (hlist)
+    {
+      for (i = 0; hlist[i]; i++)
+       {
+         /* Separate each token, and place into an array. */
+         tokens = history_tokenize (hlist[i]->line);
+
+         for (j = 0; tokens && tokens[j]; j++)
+           {
+             if (harry_len + 2 > harry_size)
+               history_completion_array = strvec_resize (history_completion_array, harry_size += 10);
+
+             history_completion_array[harry_len++] = tokens[j];
+             history_completion_array[harry_len] = (char *)NULL;
+           }
+         free (tokens);
+       }
+
+      /* Sort the complete list of tokens. */
+      qsort (history_completion_array, harry_len, sizeof (char *), (QSFUNC *)strvec_strcmp);
+    }
+}
+
+static char *
+history_completion_generator (hint_text, state)
+     const char *hint_text;
+     int state;
+{
+  static int local_index, len;
+  static const char *text;
+
+  /* If this is the first call to the generator, then initialize the
+     list of strings to complete over. */
+  if (state == 0)
+    {
+      local_index = 0;
+      build_history_completion_array ();
+      text = hint_text;
+      len = strlen (text);
+    }
+
+  while (history_completion_array && history_completion_array[local_index])
+    {
+      if (strncmp (text, history_completion_array[local_index++], len) == 0)
+       return (savestring (history_completion_array[local_index - 1]));
+    }
+  return ((char *)NULL);
+}
+
+static int
+dynamic_complete_history (count, key)
+     int count, key;
+{
+  int r;
+
+  rl_compentry_func_t *orig_func;
+  rl_completion_func_t *orig_attempt_func;
+
+  orig_func = rl_completion_entry_function;
+  orig_attempt_func = rl_attempted_completion_function;
+  rl_completion_entry_function = history_completion_generator;
+  rl_attempted_completion_function = (rl_completion_func_t *)NULL;
+
+  /* XXX - use rl_completion_mode here? */
+  if (rl_last_func == dynamic_complete_history)
+    r = rl_complete_internal ('?');
+  else
+    r = rl_complete_internal (TAB);
+
+  rl_completion_entry_function = orig_func;
+  rl_attempted_completion_function = orig_attempt_func;
+  return r;
+}
+
+#if defined (SPECIFIC_COMPLETION_FUNCTIONS)
+static int
+bash_complete_username (ignore, ignore2)
+     int ignore, ignore2;
+{
+  return bash_complete_username_internal (rl_completion_mode (bash_complete_username));
+}
+
+static int
+bash_possible_username_completions (ignore, ignore2)
+     int ignore, ignore2;
+{
+  return bash_complete_username_internal ('?');
+}
+
+static int
+bash_complete_username_internal (what_to_do)
+     int what_to_do;
+{
+  return bash_specific_completion (what_to_do, rl_username_completion_function);
+}
+
+static int
+bash_complete_filename (ignore, ignore2)
+     int ignore, ignore2;
+{
+  return bash_complete_filename_internal (rl_completion_mode (bash_complete_filename));
+}
+
+static int
+bash_possible_filename_completions (ignore, ignore2)
+     int ignore, ignore2;
+{
+  return bash_complete_filename_internal ('?');
+}
+
+static int
+bash_complete_filename_internal (what_to_do)
+     int what_to_do;
+{
+  rl_compentry_func_t *orig_func;
+  rl_completion_func_t *orig_attempt_func;
+  rl_icppfunc_t *orig_dir_func;
+  /*const*/ char *orig_rl_completer_word_break_characters;
+  int r;
+
+  orig_func = rl_completion_entry_function;
+  orig_attempt_func = rl_attempted_completion_function;
+  orig_dir_func = rl_directory_completion_hook;
+  orig_rl_completer_word_break_characters = rl_completer_word_break_characters;
+  rl_completion_entry_function = rl_filename_completion_function;
+  rl_attempted_completion_function = (rl_completion_func_t *)NULL;
+  rl_directory_completion_hook = (rl_icppfunc_t *)NULL;
+  rl_completer_word_break_characters = " \t\n\"\'";
+
+  r = rl_complete_internal (what_to_do);
+
+  rl_completion_entry_function = orig_func;
+  rl_attempted_completion_function = orig_attempt_func;
+  rl_directory_completion_hook = orig_dir_func;
+  rl_completer_word_break_characters = orig_rl_completer_word_break_characters;
+
+  return r;
+}
+
+static int
+bash_complete_hostname (ignore, ignore2)
+     int ignore, ignore2;
+{
+  return bash_complete_hostname_internal (rl_completion_mode (bash_complete_hostname));
+}
+
+static int
+bash_possible_hostname_completions (ignore, ignore2)
+     int ignore, ignore2;
+{
+  return bash_complete_hostname_internal ('?');
+}
+
+static int
+bash_complete_variable (ignore, ignore2)
+     int ignore, ignore2;
+{
+  return bash_complete_variable_internal (rl_completion_mode (bash_complete_variable));
+}
+
+static int
+bash_possible_variable_completions (ignore, ignore2)
+     int ignore, ignore2;
+{
+  return bash_complete_variable_internal ('?');
+}
+
+static int
+bash_complete_command (ignore, ignore2)
+     int ignore, ignore2;
+{
+  return bash_complete_command_internal (rl_completion_mode (bash_complete_command));
+}
+
+static int
+bash_possible_command_completions (ignore, ignore2)
+     int ignore, ignore2;
+{
+  return bash_complete_command_internal ('?');
+}
+
+static int
+bash_complete_hostname_internal (what_to_do)
+     int what_to_do;
+{
+  return bash_specific_completion (what_to_do, hostname_completion_function);
+}
+
+static int
+bash_complete_variable_internal (what_to_do)
+     int what_to_do;
+{
+  return bash_specific_completion (what_to_do, variable_completion_function);
+}
+
+static int
+bash_complete_command_internal (what_to_do)
+     int what_to_do;
+{
+  return bash_specific_completion (what_to_do, command_word_completion_function);
+}
+
+static char *globtext;
+static char *globorig;
+
+static char *
+glob_complete_word (text, state)
+     const char *text;
+     int state;
+{
+  static char **matches = (char **)NULL;
+  static int ind;
+  int glen;
+  char *ret, *ttext;
+
+  if (state == 0)
+    {
+      rl_filename_completion_desired = 1;
+      FREE (matches);
+      if (globorig != globtext)
+       FREE (globorig);
+      FREE (globtext);
+
+      ttext = bash_tilde_expand (text, 0);
+
+      if (rl_explicit_arg)
+       {
+         globorig = savestring (ttext);
+         glen = strlen (ttext);
+         globtext = (char *)xmalloc (glen + 2);
+         strcpy (globtext, ttext);
+         globtext[glen] = '*';
+         globtext[glen+1] = '\0';
+       }
+      else
+        globtext = globorig = savestring (ttext);
+
+      if (ttext != text)
+       free (ttext);
+
+      matches = shell_glob_filename (globtext);
+      if (GLOB_FAILED (matches))
+       matches = (char **)NULL;
+      ind = 0;
+    }
+
+  ret = matches ? matches[ind] : (char *)NULL;
+  ind++;
+  return ret;
+}
+
+static int
+bash_glob_completion_internal (what_to_do)
+     int what_to_do;
+{
+  return bash_specific_completion (what_to_do, glob_complete_word);
+}
+
+/* A special quoting function so we don't end up quoting globbing characters
+   in the word if there are no matches or multiple matches. */
+static char *
+bash_glob_quote_filename (s, rtype, qcp)
+     char *s;
+     int rtype;
+     char *qcp;
+{
+  if (globorig && qcp && *qcp == '\0' && STREQ (s, globorig))
+    return (savestring (s));
+  else
+    return (bash_quote_filename (s, rtype, qcp));
+}
+
+static int
+bash_glob_complete_word (count, key)
+     int count, key;
+{
+  int r;
+  rl_quote_func_t *orig_quoting_function;
+
+  if (rl_editing_mode == EMACS_EDITING_MODE)
+    rl_explicit_arg = 1;       /* force `*' append */
+  orig_quoting_function = rl_filename_quoting_function;
+  rl_filename_quoting_function = bash_glob_quote_filename;
+  
+  r = bash_glob_completion_internal (rl_completion_mode (bash_glob_complete_word));
+
+  rl_filename_quoting_function = orig_quoting_function;
+  return r;
+}
+
+static int
+bash_glob_expand_word (count, key)
+     int count, key;
+{
+  return bash_glob_completion_internal ('*');
+}
+
+static int
+bash_glob_list_expansions (count, key)
+     int count, key;
+{
+  return bash_glob_completion_internal ('?');
+}
+
+static int
+bash_specific_completion (what_to_do, generator)
+     int what_to_do;
+     rl_compentry_func_t *generator;
+{
+  rl_compentry_func_t *orig_func;
+  rl_completion_func_t *orig_attempt_func;
+  int r;
+
+  orig_func = rl_completion_entry_function;
+  orig_attempt_func = rl_attempted_completion_function;
+  rl_completion_entry_function = generator;
+  rl_attempted_completion_function = NULL;
+
+  r = rl_complete_internal (what_to_do);
+
+  rl_completion_entry_function = orig_func;
+  rl_attempted_completion_function = orig_attempt_func;
+
+  return r;
+}
+
+#endif /* SPECIFIC_COMPLETION_FUNCTIONS */
+
+#if defined (VI_MODE)
+/* Completion, from vi mode's point of view.  This is a modified version of
+   rl_vi_complete which uses the bash globbing code to implement what POSIX
+   specifies, which is to append a `*' and attempt filename generation (which
+   has the side effect of expanding any globbing characters in the word). */
+static int
+bash_vi_complete (count, key)
+     int count, key;
+{
+#if defined (SPECIFIC_COMPLETION_FUNCTIONS)
+  int p, r;
+  char *t;
+
+  if ((rl_point < rl_end) && (!whitespace (rl_line_buffer[rl_point])))
+    {
+      if (!whitespace (rl_line_buffer[rl_point + 1]))
+       rl_vi_end_word (1, 'E');
+      rl_point++;
+    }
+
+  /* Find boundaries of current word, according to vi definition of a
+     `bigword'. */
+  t = 0;
+  if (rl_point > 0)
+    {
+      p = rl_point;
+      rl_vi_bWord (1, 'B');
+      r = rl_point;
+      rl_point = p;
+      p = r;
+
+      t = substring (rl_line_buffer, p, rl_point);
+    }      
+
+  if (t && glob_pattern_p (t) == 0)
+    rl_explicit_arg = 1;       /* XXX - force glob_complete_word to append `*' */
+  FREE (t);
+
+  if (key == '*')      /* Expansion and replacement. */
+    r = bash_glob_expand_word (count, key);
+  else if (key == '=') /* List possible completions. */
+    r = bash_glob_list_expansions (count, key);
+  else if (key == '\\')        /* Standard completion */
+    r = bash_glob_complete_word (count, key);
+  else
+    r = rl_complete (0, key);
+
+  if (key == '*' || key == '\\')
+    rl_vi_start_inserting (key, 1, 1);
+
+  return (r);
+#else
+  return rl_vi_complete (count, key);
+#endif /* !SPECIFIC_COMPLETION_FUNCTIONS */
+}
+#endif /* VI_MODE */
+
+/* Filename quoting for completion. */
+/* A function to strip unquoted quote characters (single quotes, double
+   quotes, and backslashes).  It allows single quotes to appear
+   within double quotes, and vice versa.  It should be smarter. */
+static char *
+bash_dequote_filename (text, quote_char)
+     char *text;
+     int quote_char;
+{
+  char *ret, *p, *r;
+  int l, quoted;
+
+  l = strlen (text);
+  ret = (char *)xmalloc (l + 1);
+  for (quoted = quote_char, p = text, r = ret; p && *p; p++)
+    {
+      /* Allow backslash-quoted characters to pass through unscathed. */
+      if (*p == '\\')
+       {
+         *r++ = *++p;
+         if (*p == '\0')
+           break;
+         continue;
+       }
+      /* Close quote. */
+      if (quoted && *p == quoted)
+       {
+         quoted = 0;
+         continue;
+       }
+      /* Open quote. */
+      if (quoted == 0 && (*p == '\'' || *p == '"'))
+       {
+         quoted = *p;
+         continue;
+       }
+      *r++ = *p;
+    }
+  *r = '\0';
+  return ret;
+}
+
+/* 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 = (char *)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 (xstrchr (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.  This returns newly-allocated
+   memory. */
+static char *
+bash_quote_filename (s, rtype, qcp)
+     char *s;
+     int rtype;
+     char *qcp;
+{
+  char *rtext, *mtext, *ret;
+  int rlen, cs;
+
+  rtext = (char *)NULL;
+
+  /* If RTYPE == MULT_MATCH, it means that there is
+     more than one match.  In this case, we do not add
+     the closing quote or attempt to perform tilde
+     expansion.  If RTYPE == SINGLE_MATCH, we try
+     to perform tilde expansion, because single and double
+     quotes inhibit tilde expansion by the shell. */
+
+  cs = completion_quoting_style;
+  /* Might need to modify the default completion style based on *qcp,
+     since it's set to any user-provided opening quote.  We also change
+     to single-quoting if there is no user-provided opening quote and
+     the word being completed contains newlines, since those are not
+     quoted correctly using backslashes (a backslash-newline pair is
+     special to the shell parser). */
+  if (*qcp == '\0' && cs == COMPLETE_BSQUOTE && xstrchr (s, '\n'))
+    cs = COMPLETE_SQUOTE;
+  else if (*qcp == '"')
+    cs = COMPLETE_DQUOTE;
+  else if (*qcp == '\'')
+    cs = COMPLETE_SQUOTE;
+#if defined (BANG_HISTORY)
+  else if (*qcp == '\0' && history_expansion && cs == COMPLETE_DQUOTE &&
+          history_expansion_inhibited == 0 && xstrchr (s, '!'))
+    cs = COMPLETE_BSQUOTE;
+
+  if (*qcp == '"' && history_expansion && cs == COMPLETE_DQUOTE &&
+       history_expansion_inhibited == 0 && xstrchr (s, '!'))
+    {
+      cs = COMPLETE_BSQUOTE;
+      *qcp = '\0';
+    }
+#endif
+
+  /* Don't tilde-expand backslash-quoted filenames, since only single and
+     double quotes inhibit tilde expansion. */
+  mtext = s;
+  if (mtext[0] == '~' && rtype == SINGLE_MATCH && cs != COMPLETE_BSQUOTE)
+    mtext = bash_tilde_expand (s, 0);
+
+  switch (cs)
+    {
+    case COMPLETE_DQUOTE:
+      rtext = sh_double_quote (mtext);
+      break;
+    case COMPLETE_SQUOTE:
+      rtext = sh_single_quote (mtext);
+      break;
+    case COMPLETE_BSQUOTE:
+      rtext = sh_backslash_quote (mtext);
+      break;
+    }
+
+  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);
+  ret = (char *)xmalloc (rlen + 1);
+  strcpy (ret, rtext);
+
+  /* If there are multiple matches, cut off the closing quote. */
+  if (rtype == MULT_MATCH && cs != COMPLETE_BSQUOTE)
+    ret[rlen - 1] = '\0';
+  free (rtext);
+  return ret;
+}
+
+/* Support for binding readline key sequences to Unix commands. */
+static Keymap cmd_xmap;
+
+static int
+bash_execute_unix_command (count, key)
+     int count;        /* ignored */
+     int key;
+{
+  Keymap ckmap;                /* current keymap */
+  Keymap xkmap;                /* unix command executing keymap */
+  register int i;
+  char *cmd;
+  sh_parser_state_t ps;
+
+  /* First, we need to find the right command to execute.  This is tricky,
+     because we might have already indirected into another keymap. */
+  ckmap = rl_get_keymap ();
+  if (ckmap != rl_executing_keymap)
+    {
+      /* bogus.  we have to search.  only handle one level of indirection. */
+      for (i = 0; i < KEYMAP_SIZE; i++)
+       {
+         if (ckmap[i].type == ISKMAP && (Keymap)ckmap[i].function == rl_executing_keymap)
+           break;
+       }
+      if (i < KEYMAP_SIZE)
+       xkmap = (Keymap)cmd_xmap[i].function;
+      else
+       {
+         rl_crlf ();
+         internal_error (_("bash_execute_unix_command: cannot find keymap for command"));
+         rl_forced_update_display ();
+         return 1;
+       }
+    }
+  else
+    xkmap = cmd_xmap;
+
+  cmd = (char *)xkmap[key].function;
+
+  if (cmd == 0)
+    {
+      rl_ding ();
+      return 1;
+    }
+
+  rl_crlf ();  /* move to a new line */
+
+  save_parser_state (&ps);
+
+  cmd = savestring (cmd);
+  parse_and_execute (cmd, "bash_execute_unix_command", SEVAL_NOHIST);
+
+  restore_parser_state (&ps);
+
+  /* and restore the readline buffer and display after command execution. */
+  rl_forced_update_display ();
+  return 0;
+}
+
+static void
+init_unix_command_map ()
+{
+  cmd_xmap = rl_make_bare_keymap ();
+}
+
+static int
+isolate_sequence (string, ind, need_dquote, startp)
+     char *string;
+     int ind, need_dquote, *startp;
+{
+  register int i;
+  int c, passc, delim;
+
+  for (i = ind; string[i] && whitespace (string[i]); i++)
+    ;
+  /* NEED_DQUOTE means that the first non-white character *must* be `"'. */
+  if (need_dquote && string[i] != '"')
+    {
+      builtin_error (_("%s: first non-whitespace character is not `\"'"), string);
+      return -1;
+    }
+
+  /* We can have delimited strings even if NEED_DQUOTE == 0, like the command
+     string to bind the key sequence to. */
+  delim = (string[i] == '"' || string[i] == '\'') ? string[i] : 0;
+    
+  if (startp)
+    *startp = delim ? ++i : i;
+
+  for (passc = 0; c = string[i]; i++)
+    {
+      if (passc)
+       {
+         passc = 0;
+         continue;
+       }
+      if (c == '\\')
+       {
+         passc++;
+         continue;
+       }
+      if (c == delim)
+       break;
+    }
+
+  if (delim && string[i] != delim)
+    {
+      builtin_error (_("no closing `%c' in %s"), delim, string);
+      return -1;
+    }
+
+  return i;
+}
+
+int
+bind_keyseq_to_unix_command (line)
+     char *line;
+{
+  Keymap kmap;
+  char *kseq, *value;
+  int i, kstart;
+
+  if (cmd_xmap == 0)
+    init_unix_command_map ();
+
+  kmap = rl_get_keymap ();
+
+  /* We duplicate some of the work done by rl_parse_and_bind here, but
+     this code only has to handle `"keyseq": ["]command["]' and can
+     generate an error for anything else. */
+  i = isolate_sequence (line, 0, 1, &kstart);
+  if (i < 0)
+    return -1;
+
+  /* Create the key sequence string to pass to rl_generic_bind */
+  kseq = substring (line, kstart, i);
+
+  for ( ; line[i] && line[i] != ':'; i++)
+    ;
+  if (line[i] != ':')
+    {
+      builtin_error (_("%s: missing colon separator"), line);
+      return -1;
+    }
+
+  i = isolate_sequence (line, i + 1, 0, &kstart);
+  if (i < 0)
+    return -1;
+
+  /* Create the value string containing the command to execute. */
+  value = substring (line, kstart, i);
+
+  /* Save the command to execute and the key sequence in the CMD_XMAP */
+  rl_generic_bind (ISMACR, kseq, value, cmd_xmap);
+
+  /* and bind the key sequence in the current keymap to a function that
+     understands how to execute from CMD_XMAP */
+  rl_bind_keyseq_in_map (kseq, bash_execute_unix_command, kmap);
+  
+  return 0;
+}
+
+/* Used by the programmable completion code.  Complete TEXT as a filename,
+   but return only directories as matches.  Dequotes the filename before
+   attempting to find matches. */
+char **
+bash_directory_completion_matches (text)
+     const char *text;
+{
+  char **m1;
+  char *dfn;
+  int qc;
+
+  qc = rl_dispatching ? rl_completion_quote_character : 0;  
+  dfn = bash_dequote_filename ((char *)text, qc);
+  m1 = rl_completion_matches (dfn, rl_filename_completion_function);
+  free (dfn);
+
+  if (m1 == 0 || m1[0] == 0)
+    return m1;
+  /* We don't bother recomputing the lcd of the matches, because it will just
+     get thrown away by the programmable completion code and recomputed
+     later. */
+  (void)bash_ignore_filenames (m1);
+  return m1;
+}
+
+char *
+bash_dequote_text (text)
+     const char *text;
+{
+  char *dtxt;
+  int qc;
+
+  qc = (text[0] == '"' || text[0] == '\'') ? text[0] : 0;
+  dtxt = bash_dequote_filename ((char *)text, qc);
+  return (dtxt);
+}
+#endif /* READLINE */
index 25373974167d43d3b4144afc194cb54382f8f1ec..34a72be43bf26af03d28f7cbe2dfff9e3aca41c3 100644 (file)
--- a/braces.c
+++ b/braces.c
@@ -55,7 +55,7 @@
  */
 
 /* The character which is used to separate arguments. */
-int brace_arg_separator = ',';
+static const int brace_arg_separator = ',';
 
 #if defined (__P)
 static int brace_gobbler __P((char *, size_t, int *, int));
diff --git a/braces.c~ b/braces.c~
new file mode 100644 (file)
index 0000000..2537397
--- /dev/null
+++ b/braces.c~
@@ -0,0 +1,630 @@
+/* braces.c -- code for doing word expansion in curly braces. */
+
+/* Copyright (C) 1987-2003 Free Software Foundation, Inc.
+
+   This file is part of GNU Bash, the Bourne Again SHell.
+
+   Bash is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   Bash is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+   License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with Bash; see the file COPYING.  If not, write to the Free
+   Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+/* Stuff in curly braces gets expanded before all other shell expansions. */
+
+#include "config.h"
+
+#if defined (BRACE_EXPANSION)
+
+#if defined (HAVE_UNISTD_H)
+#  ifdef _MINIX
+#    include <sys/types.h>
+#  endif
+#  include <unistd.h>
+#endif
+
+#include "bashansi.h"
+
+#if defined (SHELL)
+#  include "shell.h"
+#endif /* SHELL */
+
+#include "general.h"
+#include "shmbutil.h"
+#include "chartypes.h"
+
+#define brace_whitespace(c) (!(c) || (c) == ' ' || (c) == '\t' || (c) == '\n')
+
+#define BRACE_SEQ_SPECIFIER    ".."
+
+/* Basic idea:
+
+   Segregate the text into 3 sections: preamble (stuff before an open brace),
+   postamble (stuff after the matching close brace) and amble (stuff after
+   preamble, and before postamble).  Expand amble, and then tack on the
+   expansions to preamble.  Expand postamble, and tack on the expansions to
+   the result so far.
+ */
+
+/* The character which is used to separate arguments. */
+int brace_arg_separator = ',';
+
+#if defined (__P)
+static int brace_gobbler __P((char *, size_t, int *, int));
+static char **expand_amble __P((char *, size_t, int));
+static char **expand_seqterm __P((char *, size_t));
+static char **mkseq __P((int, int, int, int));
+static char **array_concat __P((char **, char **));
+#else
+static int brace_gobbler ();
+static char **expand_amble ();
+static char **expand_seqterm ();
+static char **mkseq();
+static char **array_concat ();
+#endif
+
+#if 0
+static void
+dump_result (a)
+     char **a;
+{
+  int i;
+
+  for (i = 0; a[i]; i++)
+    printf ("dump_result: a[%d] = -%s-\n", i, a[i]);
+}
+#endif
+
+/* Return an array of strings; the brace expansion of TEXT. */
+char **
+brace_expand (text)
+     char *text;
+{
+  register int start;
+  size_t tlen;
+  char *preamble, *postamble, *amble;
+  size_t alen;
+  char **tack, **result;
+  int i, j, c, c1;
+
+  DECLARE_MBSTATE;
+
+  /* Find the text of the preamble. */
+  tlen = strlen (text);
+  i = 0;
+#if defined (CSH_BRACE_COMPAT)
+  c = brace_gobbler (text, tlen, &i, '{');     /* } */
+#else
+  /* Make sure that when we exit this loop, c == 0 or text[i] begins a
+     valid brace expansion sequence. */
+  do
+    {
+      c = brace_gobbler (text, tlen, &i, '{'); /* } */
+      c1 = c;
+      /* Verify that c begins a valid brace expansion word.  If it doesn't, we
+        go on.  Loop stops when there are no more open braces in the word. */
+      if (c)
+       {
+         start = j = i + 1;    /* { */
+         c = brace_gobbler (text, tlen, &j, '}');
+         if (c == 0)           /* it's not */
+           {
+             i++;
+             c = c1;
+             continue;
+           }
+         else                  /* it is */
+           {
+             c = c1;
+             break;
+           }
+       }
+      else
+       break;
+    }
+  while (c);
+#endif /* !CSH_BRACE_COMPAT */
+
+  preamble = (char *)xmalloc (i + 1);
+  strncpy (preamble, text, i);
+  preamble[i] = '\0';
+
+  result = (char **)xmalloc (2 * sizeof (char *));
+  result[0] = preamble;
+  result[1] = (char *)NULL;
+
+  /* Special case.  If we never found an exciting character, then
+     the preamble is all of the text, so just return that. */
+  if (c != '{')
+    return (result);
+
+  /* Find the amble.  This is the stuff inside this set of braces. */
+  start = ++i;
+  c = brace_gobbler (text, tlen, &i, '}');
+
+  /* What if there isn't a matching close brace? */
+  if (c == 0)
+    {
+#if defined (NOTDEF)
+      /* Well, if we found an unquoted BRACE_ARG_SEPARATOR between START
+        and I, then this should be an error.  Otherwise, it isn't. */
+      j = start;
+      while (j < i)
+       {
+         if (text[j] == '\\')
+           {
+             j++;
+             ADVANCE_CHAR (text, tlen, j);
+             continue;
+           }
+
+         if (text[j] == brace_arg_separator)
+           {   /* { */
+             strvec_dispose (result);
+             report_error ("no closing `%c' in %s", '}', text);
+             throw_to_top_level ();
+           }
+         ADVANCE_CHAR (text, tlen, j);
+       }
+#endif
+      free (preamble);         /* Same as result[0]; see initialization. */
+      result[0] = savestring (text);
+      return (result);
+    }
+
+#if defined (SHELL)
+  amble = substring (text, start, i);
+  alen = i - start;
+#else
+  amble = (char *)xmalloc (1 + (i - start));
+  strncpy (amble, &text[start], (i - start));
+  alen = i - start;
+  amble[alen] = '\0';
+#endif
+
+#if defined (SHELL)
+  INITIALIZE_MBSTATE;
+
+  /* If the amble does not contain an unquoted BRACE_ARG_SEPARATOR, then
+     just return without doing any expansion.  */
+  j = 0;
+  while (amble[j])
+    {
+      if (amble[j] == '\\')
+       {
+         j++;
+         ADVANCE_CHAR (amble, alen, j);
+         continue;
+       }
+
+      if (amble[j] == brace_arg_separator)
+       break;
+
+      ADVANCE_CHAR (amble, alen, j);
+    }
+
+  if (amble[j] == 0)
+    {
+      tack = expand_seqterm (amble, alen);
+      if (tack)
+       goto add_tack;
+      else
+       {
+         free (amble);
+         free (preamble);
+         result[0] = savestring (text);
+         return (result);
+       }
+    }
+#endif /* SHELL */
+
+  tack = expand_amble (amble, alen, 0);
+add_tack:
+  result = array_concat (result, tack);
+  free (amble);
+  strvec_dispose (tack);
+
+  postamble = text + i + 1;
+
+  tack = brace_expand (postamble);
+  result = array_concat (result, tack);
+  strvec_dispose (tack);
+
+  return (result);
+}
+
+/* Expand the text found inside of braces.  We simply try to split the
+   text at BRACE_ARG_SEPARATORs into separate strings.  We then brace
+   expand each slot which needs it, until there are no more slots which
+   need it. */
+static char **
+expand_amble (text, tlen, flags)
+     char *text;
+     size_t tlen;
+     int flags;
+{
+  char **result, **partial;
+  char *tem;
+  int start, i, c;
+
+  DECLARE_MBSTATE;
+
+  result = (char **)NULL;
+
+  start = i = 0;
+  c = 1;
+  while (c)
+    {
+      c = brace_gobbler (text, tlen, &i, brace_arg_separator);
+#if defined (SHELL)
+      tem = substring (text, start, i);
+#else
+      tem = (char *)xmalloc (1 + (i - start));
+      strncpy (tem, &text[start], (i - start));
+      tem[i- start] = '\0';
+#endif
+
+      partial = brace_expand (tem);
+
+      if (!result)
+       result = partial;
+      else
+       {
+         register int lr, lp, j;
+
+         lr = strvec_len (result);
+         lp = strvec_len (partial);
+
+         result = strvec_resize (result, lp + lr + 1);
+
+         for (j = 0; j < lp; j++)
+           result[lr + j] = partial[j];
+
+         result[lr + j] = (char *)NULL;
+         free (partial);
+       }
+      free (tem);
+      ADVANCE_CHAR (text, tlen, i);
+      start = i;
+    }
+  return (result);
+}
+
+#define ST_BAD 0
+#define ST_INT 1
+#define ST_CHAR        2
+
+static char **
+mkseq (start, end, incr, type)
+     int start, end, incr, type;
+{
+  int n, i;
+  char **result, *t;
+
+  n = abs (end - start) + 1;
+  result = strvec_create (n + 1);
+
+  if (incr == 0)
+    incr = 1;
+  
+  if (start > end && incr > 0)
+    incr = -incr;
+  else if (start < end && incr < 0)
+    incr = -incr;
+
+  /* Make sure we go through the loop at least once, so {3..3} prints `3' */
+  i = 0;
+  n = start;
+  do
+    {
+#if defined (SHELL)
+      QUIT;            /* XXX - memory leak here */
+#endif
+      if (type == ST_INT)
+       result[i++] = itos (n);
+      else
+       {
+         t = (char *)xmalloc (2);
+         t[0] = n;
+         t[1] = '\0';
+         result[i++] = t;
+       }
+      if (n == end)
+        break;
+      n += incr;
+    }
+  while (1);
+
+  result[i] = (char *)0;
+  return (result);
+}
+
+static char **
+expand_seqterm (text, tlen)
+     char *text;
+     size_t tlen;
+{
+  char *t, *lhs, *rhs;
+  int i, lhs_t, rhs_t, lhs_v, rhs_v;
+  intmax_t tl, tr;
+  char **result;
+
+  t = strstr (text, BRACE_SEQ_SPECIFIER);
+  if (t == 0)
+    return ((char **)NULL);
+
+  i = t - text;                /* index of start of BRACE_SEQ_SPECIFIER */
+  lhs = substring (text, 0, i);
+  rhs = substring (text, i + sizeof(BRACE_SEQ_SPECIFIER) - 1, tlen);
+
+  if (lhs[0] == 0 || rhs[0] == 0)
+    {
+      free (lhs);
+      free (rhs);
+      return ((char **)NULL);
+    }
+
+  /* Now figure out whether LHS and RHS are integers or letters.  Both
+     sides have to match. */
+  lhs_t = (legal_number (lhs, &tl)) ? ST_INT :
+               ((ISALPHA (lhs[0]) && lhs[1] == 0) ?  ST_CHAR : ST_BAD);
+  rhs_t = (legal_number (rhs, &tr)) ? ST_INT :
+               ((ISALPHA (rhs[0]) && rhs[1] == 0) ?  ST_CHAR : ST_BAD);
+
+  if (lhs_t != rhs_t || lhs_t == ST_BAD || rhs_t == ST_BAD)
+    {
+      free (lhs);
+      free (rhs);
+      return ((char **)NULL);
+    }
+
+  /* OK, we have something.  It's either a sequence of integers, ascending
+     or descending, or a sequence or letters, ditto.  Generate the sequence,
+     put it into a string vector, and return it. */
+  
+  if (lhs_t == ST_CHAR)
+    {
+      lhs_v = (unsigned char)lhs[0];
+      rhs_v = (unsigned char)rhs[0];
+    }
+  else
+    {
+      lhs_v = tl;              /* integer truncation */
+      rhs_v = tr;
+    }
+
+  result = mkseq (lhs_v, rhs_v, 1, lhs_t);
+
+  free (lhs);
+  free (rhs);
+
+  return (result);
+}
+
+/* Start at INDEX, and skip characters in TEXT. Set INDEX to the
+   index of the character matching SATISFY.  This understands about
+   quoting.  Return the character that caused us to stop searching;
+   this is either the same as SATISFY, or 0. */
+/* If SATISFY is `}', we are looking for a brace expression, so we
+   should enforce the rules that govern valid brace expansions:
+       1) to count as an arg separator, a comma or `..' has to be outside
+          an inner set of braces.       
+*/
+static int
+brace_gobbler (text, tlen, indx, satisfy)
+     char *text;
+     size_t tlen;
+     int *indx;
+     int satisfy;
+{
+  register int i, c, quoted, level, commas, pass_next;
+#if defined (SHELL)
+  int si;
+  char *t;
+#endif
+  DECLARE_MBSTATE;
+
+  level = quoted = pass_next = 0;
+#if defined (CSH_BRACE_COMPAT)
+  commas = 1;
+#else
+  commas = (satisfy == '}') ? 0 : 1;
+#endif
+
+  i = *indx;
+  while (c = text[i])
+    {
+      if (pass_next)
+       {
+         pass_next = 0;
+         ADVANCE_CHAR (text, tlen, i);
+         continue;
+       }
+
+      /* A backslash escapes the next character.  This allows backslash to
+        escape the quote character in a double-quoted string. */
+      if (c == '\\' && (quoted == 0 || quoted == '"' || quoted == '`'))
+       {
+         pass_next = 1;
+         i++;
+         continue;
+       }
+
+#if defined (SHELL)
+      /* If compiling for the shell, treat ${...} like \{...} */
+      if (c == '$' && text[i+1] == '{' && quoted != '\'')              /* } */
+       {
+         pass_next = 1;
+         i++;
+         if (quoted == 0)
+           level++;
+         continue;
+       }
+#endif
+
+      if (quoted)
+       {
+         if (c == quoted)
+           quoted = 0;
+         ADVANCE_CHAR (text, tlen, i);
+         continue;
+       }
+
+      if (c == '"' || c == '\'' || c == '`')
+       {
+         quoted = c;
+         i++;
+         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);
+         i++;
+         continue;
+       }
+#endif
+
+      if (c == satisfy && level == 0 && quoted == 0 && commas > 0)
+       {
+         /* We ignore an open brace surrounded by whitespace, and also
+            an open brace followed immediately by a close brace preceded
+            by whitespace.  */
+         if (c == '{' &&
+             ((!i || brace_whitespace (text[i - 1])) &&
+              (brace_whitespace (text[i + 1]) || text[i + 1] == '}')))
+           {
+             i++;
+             continue;
+           }
+
+           break;
+       }
+
+      if (c == '{')
+       level++;
+      else if (c == '}' && level)
+       level--;
+#if !defined (CSH_BRACE_COMPAT)
+      else if (satisfy == '}' && c == brace_arg_separator && level == 0)
+       commas++;
+      else if (satisfy == '}' && STREQN (text+i, BRACE_SEQ_SPECIFIER, 2) &&
+               text[i+2] != satisfy && level == 0)
+       commas++;
+#endif
+
+      ADVANCE_CHAR (text, tlen, i);
+    }
+
+  *indx = i;
+  return (c);
+}
+
+/* Return a new array of strings which is the result of appending each
+   string in ARR2 to each string in ARR1.  The resultant array is
+   len (arr1) * len (arr2) long.  For convenience, ARR1 (and its contents)
+   are free ()'ed.  ARR1 can be NULL, in that case, a new version of ARR2
+   is returned. */
+static char **
+array_concat (arr1, arr2)
+     char **arr1, **arr2;
+{
+  register int i, j, len, len1, len2;
+  register char **result;
+
+  if (arr1 == 0)
+    return (strvec_copy (arr2));
+
+  if (arr2 == 0)
+    return (strvec_copy (arr1));
+
+  len1 = strvec_len (arr1);
+  len2 = strvec_len (arr2);
+
+  result = (char **)xmalloc ((1 + (len1 * len2)) * sizeof (char *));
+
+  len = 0;
+  for (i = 0; i < len1; i++)
+    {
+      int strlen_1 = strlen (arr1[i]);
+
+      for (j = 0; j < len2; j++)
+       {
+         result[len] = (char *)xmalloc (1 + strlen_1 + strlen (arr2[j]));
+         strcpy (result[len], arr1[i]);
+         strcpy (result[len] + strlen_1, arr2[j]);
+         len++;
+       }
+      free (arr1[i]);
+    }
+  free (arr1);
+
+  result[len] = (char *)NULL;
+  return (result);
+}
+
+#if defined (TEST)
+#include <stdio.h>
+
+fatal_error (format, arg1, arg2)
+     char *format, *arg1, *arg2;
+{
+  report_error (format, arg1, arg2);
+  exit (1);
+}
+
+report_error (format, arg1, arg2)
+     char *format, *arg1, *arg2;
+{
+  fprintf (stderr, format, arg1, arg2);
+  fprintf (stderr, "\n");
+}
+
+main ()
+{
+  char example[256];
+
+  for (;;)
+    {
+      char **result;
+      int i;
+
+      fprintf (stderr, "brace_expand> ");
+
+      if ((!fgets (example, 256, stdin)) ||
+         (strncmp (example, "quit", 4) == 0))
+       break;
+
+      if (strlen (example))
+       example[strlen (example) - 1] = '\0';
+
+      result = brace_expand (example);
+
+      for (i = 0; result[i]; i++)
+       printf ("%s\n", result[i]);
+
+      free_array (result);
+    }
+}
+\f
+/*
+ * Local variables:
+ * compile-command: "gcc -g -Bstatic -DTEST -o brace_expand braces.c general.o"
+ * end:
+ */
+
+#endif /* TEST */
+#endif /* BRACE_EXPANSION */
index fa5c6678e7beaff06aa9e5faed0b747d87da675f..7d3ff4617b26ce38de1e0eb1bca4b07472e0928c 100644 (file)
@@ -56,7 +56,7 @@ extern int errno;
 
 extern int posixly_correct;
 extern int array_needs_making;
-extern char *bash_getcwd_errstr;
+extern const char * const bash_getcwd_errstr;
 
 static int bindpwd __P((int));
 static void setpwd __P((char *));
index 54e328e4f5fda9b32d57c4ec1ee47f04a76afdec..fa5c6678e7beaff06aa9e5faed0b747d87da675f 100644 (file)
@@ -73,11 +73,11 @@ int cdable_vars;
 $BUILTIN cd
 $FUNCTION cd_builtin
 $SHORT_DOC cd [-L|-P] [dir]
-Change the current directory to DIR.  The variable $HOME is the
-default DIR.  The variable CDPATH defines the search path for
-the directory containing DIR.  Alternative directory names in CDPATH
-are separated by a colon (:).  A null directory name is the same as
-the current directory, i.e. `.'.  If DIR begins with a slash (/),
+Change the current directory to DIR.  The default for DIR is the value
+of the HOME shell variable.  The variable CDPATH defines the search
+path for the directory containing DIR.  Alternative directory names in
+CDPATH are separated by a colon (:).  A null directory name is the same
+as the current directory, i.e., `.'.  If DIR begins with a slash (/),
 then CDPATH is not used.  If the directory is not found, and the
 shell option `cdable_vars' is set, then try the word as a variable
 name.  If that variable has a value, then cd to the value of that
index 7b29b326c1cfcf52cea5ca9cc463106df153ae17..66e55c4bb372df4213d79356b4f6be83f93cddc7 100644 (file)
@@ -69,7 +69,7 @@ extern int last_command_exit_value;
 extern int running_trap;
 extern int posixly_correct;
 extern char *this_command_name, *shell_name;
-extern char *bash_getcwd_errstr;
+extern const char * const bash_getcwd_errstr;
 
 /* Used by some builtins and the mainline code. */
 sh_builtin_func_t *last_shell_builtin = (sh_builtin_func_t *)NULL;
@@ -639,7 +639,7 @@ display_signal_list (list, forcecols)
            {
              printf ("%2d) %s", i, name);
 
-             if (++column < 4)
+             if (++column < 5)
                printf ("\t");
              else
                {
index e19ccb252001202201a948795dcfdd646399ff9e..c4caca303ed06d315dd27e2397c651a6879eb1fc 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2006 Free Software Foundation, Inc.
 
    This file is part of GNU Bash, the Bourne Again SHell.
 
@@ -639,7 +639,7 @@ display_signal_list (list, forcecols)
            {
              printf ("%2d) %s", i, name);
 
-             if (++column < 4)
+             if (++column < 5)
                printf ("\t");
              else
                {
index 2aca007dc841180d9a78fff0f3fd12761b531d9b..56f875494fd35f08bbf7b9ab7f65c3952a47870a 100644 (file)
@@ -73,8 +73,8 @@ static int print_cmd_completions __P((WORD_LIST *));
 
 static char *Garg, *Warg, *Parg, *Sarg, *Xarg, *Farg, *Carg;
 
-static struct _compacts {
-  char *actname;
+static const struct _compacts {
+  const char * const actname;
   int actflag;
   int actopt;
 } compacts[] = {
@@ -106,8 +106,8 @@ static struct _compacts {
 };
 
 /* This should be a STRING_INT_ALIST */
-static struct _compopt {
-  char *optname;
+const static struct _compopt {
+  const char * const optname;
   int optflag;
 } compopts[] = {
   { "bashdefault", COPT_BASHDEFAULT },
index 66c27d28af24e4c2d095ba17a905d584e866ed1c..2aca007dc841180d9a78fff0f3fd12761b531d9b 100644 (file)
@@ -533,7 +533,7 @@ print_cmd_completions (list)
 $BUILTIN compgen
 $DEPENDS_ON PROGRAMMABLE_COMPLETION
 $FUNCTION compgen_builtin
-$SHORT_DOC compgen [-abcdefgjksuv] [-o option] [-A action] [-G globpat] [-W wordlist] [-P prefix] [-S suffix] [-X filterpat] [-F function] [-C command] [word]
+$SHORT_DOC compgen [-abcdefgjksuv] [-o option]  [-A action] [-G globpat] [-W wordlist]  [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [word]
 Display the possible completions depending on the options.  Intended
 to be used from within a shell function generating possible completions.
 If the optional WORD argument is supplied, matches against WORD are
index 2ab8852192d12ab1c7774063924d1f09b13e3e21..3c0bfdf7f51c96d27bbdefa49f973d3c4b339e94 100644 (file)
@@ -45,6 +45,7 @@ $END
 #include "common.h"
 #include "builtext.h"  /* for jobs_builtin */
 
+extern int check_jobs_at_exit;
 extern int last_command_exit_value;
 extern int running_trap, trap_saved_exit_value;
 extern int subshell_environment;
@@ -94,7 +95,7 @@ exit_or_logout (list)
   int exit_value;
 
 #if defined (JOB_CONTROL)
-  int exit_immediate_okay;
+  int exit_immediate_okay, stopmsg;
 
   exit_immediate_okay = (interactive  == 0 ||
                         last_shell_builtin == exit_builtin ||
@@ -102,21 +103,32 @@ exit_or_logout (list)
                         last_shell_builtin == jobs_builtin);
 
   /* Check for stopped jobs if the user wants to. */
-  if (!exit_immediate_okay)
+  if (exit_immediate_okay == 0)
     {
       register int i;
-      for (i = 0; i < js.j_jobslots; i++)
+      for (i = stopmsg = 0; i < js.j_jobslots; i++)
        if (jobs[i] && STOPPED (i))
-         {
-           fprintf (stderr, _("There are stopped jobs.\n"));
-
-           /* This is NOT superfluous because EOF can get here without
-              going through the command parser.  Set both last and this
-              so that either `exit', `logout', or ^D will work to exit
-              immediately if nothing intervenes. */
-           this_shell_builtin = last_shell_builtin = exit_builtin;
-           return (EXECUTION_FAILURE);
-         }
+         stopmsg = JSTOPPED;
+       else if (check_jobs_at_exit && stopmsg == 0 && RUNNING (i))
+         stopmsg = JRUNNING;
+
+      if (stopmsg == JSTOPPED)
+       fprintf (stderr, _("There are stopped jobs.\n"));
+      else if (stopmsg == JRUNNING)
+       fprintf (stderr, _("There are running jobs.\n"));
+
+      if (stopmsg && check_jobs_at_exit)
+        list_all_jobs (JLIST_STANDARD);
+
+      if (stopmsg)
+       {
+         /* This is NOT superfluous because EOF can get here without
+            going through the command parser.  Set both last and this
+            so that either `exit', `logout', or ^D will work to exit
+            immediately if nothing intervenes. */
+         this_shell_builtin = last_shell_builtin = exit_builtin;
+         return (EXECUTION_FAILURE);
+       }
     }
 #endif /* JOB_CONTROL */
 
index ddaa5d315cd44f215a0b7e928f7f369ec9106a1a..2993610e1fb8f4ddb096afa57e94d39a1ea0278a 100644 (file)
@@ -1,7 +1,7 @@
 This file is exit.def, from which is created exit.c.
 It implements the builtins "exit", and "logout" in Bash.
 
-Copyright (C) 1987-2005 Free Software Foundation, Inc.
+Copyright (C) 1987-2006 Free Software Foundation, Inc.
 
 This file is part of GNU Bash, the Bourne Again SHell.
 
@@ -60,7 +60,7 @@ exit_builtin (list)
 {
   if (interactive)
     {
-      fprintf (stderr, login_shell ? "logout\n" : "exit\n");
+      fprintf (stderr, login_shell ? _("logout\n") : "exit\n");
       fflush (stderr);
     }
 
@@ -102,7 +102,7 @@ exit_or_logout (list)
                         last_shell_builtin == jobs_builtin);
 
   /* Check for stopped jobs if the user wants to. */
-  if (!exit_immediate_okay)
+  if (exit_immediate_okay == 0)
     {
       register int i;
       for (i = 0; i < js.j_jobslots; i++)
index 35a6de9cced58295b5bf515ab2857ff74235788b..059f98660fc038b137ed64a05d0b410d3f3b7794 100644 (file)
@@ -1,7 +1,7 @@
 This file is help.def, from which is created help.c.
 It implements the builtin "help" in Bash.
 
-Copyright (C) 1987-2003 Free Software Foundation, Inc.
+Copyright (C) 1987-2006 Free Software Foundation, Inc.
 
 This file is part of GNU Bash, the Bourne Again SHell.
 
@@ -176,7 +176,8 @@ static void
 show_builtin_command_help ()
 {
   int i, j;
-  char blurb[36];
+  int height, width;
+  char *t, blurb[128];
 
   printf (
 _("These shell commands are defined internally.  Type `help' to see this list.\n\
@@ -187,21 +188,42 @@ Use `man -k' or `info' to find out more about commands not in this list.\n\
 A star (*) next to a name means that the command is disabled.\n\
 \n"));
 
-  for (i = 0; i < num_shell_builtins; i++)
+  t = get_string_value ("COLUMNS");
+  width = (t && *t) ? atoi (t) : 80;
+  if (width <= 0)
+    width = 80;
+
+  width /= 2;
+  if (width > sizeof (blurb))
+    width = sizeof (blurb);
+  height = (num_shell_builtins + 1) / 2;       /* number of rows */
+
+  for (i = 0; i < height; i++)
     {
       QUIT;
+
+      /* first column */
       blurb[0] = (shell_builtins[i].flags & BUILTIN_ENABLED) ? ' ' : '*';
-      strncpy (blurb + 1, shell_builtins[i].short_doc, 34);
-      blurb[35] = '\0';
+      strncpy (blurb + 1, shell_builtins[i].short_doc, width - 2);
+      blurb[width - 2] = '>';          /* indicate truncation */
+      blurb[width - 1] = '\0';
       printf ("%s", blurb);
+      if ((i << 1) == num_shell_builtins)
+       {
+         printf ("\n");
+         break;
+       }
 
-      if (i % 2)
-       printf ("\n");
-      else
-       for (j = strlen (blurb); j < 35; j++)
-         putc (' ', stdout);
+      /* two spaces */
+      for (j = strlen (blurb); j < width; j++)
+        putc (' ', stdout);
+
+      /* second column */
+      blurb[0] = (shell_builtins[i+height].flags & BUILTIN_ENABLED) ? ' ' : '*';
+      strncpy (blurb + 1, shell_builtins[i+height].short_doc, width - 3);
+      blurb[width - 3] = '>';          /* indicate truncation */
+      blurb[width - 2] = '\0';
+      printf ("%s\n", blurb);
     }
-  if (i % 2)
-    printf ("\n");
 }
 #endif /* HELP_BUILTIN */
diff --git a/builtins/help.def.save1 b/builtins/help.def.save1
new file mode 100644 (file)
index 0000000..7984b78
--- /dev/null
@@ -0,0 +1,207 @@
+This file is help.def, from which is created help.c.
+It implements the builtin "help" in Bash.
+
+Copyright (C) 1987-2003 Free Software Foundation, Inc.
+
+This file is part of GNU Bash, the Bourne Again SHell.
+
+Bash is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Bash is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License along
+with Bash; see the file COPYING.  If not, write to the Free Software
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
+
+$PRODUCES help.c
+
+$BUILTIN help
+$FUNCTION help_builtin
+$DEPENDS_ON HELP_BUILTIN
+$SHORT_DOC help [-s] [pattern ...]
+Display helpful information about builtin commands.  If PATTERN is
+specified, gives detailed help on all commands matching PATTERN,
+otherwise a list of the builtins is printed.  The -s option
+restricts the output for each builtin command matching PATTERN to
+a short usage synopsis.
+$END
+
+#include <config.h>
+
+#if defined (HELP_BUILTIN)
+#include <stdio.h>
+
+#if defined (HAVE_UNISTD_H)
+#  ifdef _MINIX
+#    include <sys/types.h>
+#  endif
+#  include <unistd.h>
+#endif
+
+#include <errno.h>
+
+#include <filecntl.h>
+
+#include "../bashintl.h"
+
+#include "../shell.h"
+#include "../builtins.h"
+#include "../pathexp.h"
+#include "common.h"
+#include "bashgetopt.h"
+
+#include <glob/strmatch.h>
+#include <glob/glob.h>
+
+#ifndef errno
+extern int errno;
+#endif
+
+static void show_builtin_command_help __P((void));
+static void show_longdoc __P((int));
+
+/* Print out a list of the known functions in the shell, and what they do.
+   If LIST is supplied, print out the list which matches for each pattern
+   specified. */
+int
+help_builtin (list)
+     WORD_LIST *list;
+{
+  register int i;
+  char *pattern, *name;
+  int plen, match_found, sflag;
+
+  sflag = 0;
+  reset_internal_getopt ();
+  while ((i = internal_getopt (list, "s")) != -1)
+    {
+      switch (i)
+       {
+       case 's':
+         sflag = 1;
+         break;
+       default:
+         builtin_usage ();
+         return (EX_USAGE);
+       }
+    }
+  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))
+    {
+      if (list->next)
+       printf (_("Shell commands matching keywords `"));
+      else
+       printf (_("Shell commands matching keyword `"));
+      print_word_list (list, ", ");
+      printf ("'\n\n");
+    }
+
+  for (match_found = 0, pattern = ""; list; list = list->next)
+    {
+      pattern = list->word->word;
+      plen = strlen (pattern);
+
+      for (i = 0; name = shell_builtins[i].name; i++)
+       {
+         QUIT;
+         if ((strncmp (pattern, name, plen) == 0) ||
+             (strmatch (pattern, name, FNMATCH_EXTFLAG) != FNM_NOMATCH))
+           {
+             printf ("%s: %s\n", name, shell_builtins[i].short_doc);
+
+             if (sflag == 0)
+               show_longdoc (i);
+
+             match_found++;
+           }
+       }
+    }
+
+  if (match_found == 0)
+    {
+      builtin_error (_("no help topics match `%s'.  Try `help help' or `man -k %s' or `info %s'."), pattern, pattern, pattern);
+      return (EXECUTION_FAILURE);
+    }
+
+  fflush (stdout);
+  return (EXECUTION_SUCCESS);
+}
+
+/* By convention, enforced by mkbuiltins.c, if separate help files are being
+   used, the long_doc array contains one string -- the full pathname of the
+   help file for this builtin.  */
+static void
+show_longdoc (i)
+     int i;
+{
+  register int j;
+  char * const *doc;
+  int fd;
+
+  doc = shell_builtins[i].long_doc;
+
+  if (doc && doc[0] && *doc[0] == '/' && doc[1] == (char *)NULL)
+    {
+      fd = open (doc[0], O_RDONLY);
+      if (fd == -1)
+       {
+         builtin_error (_("%s: cannot open: %s"), doc[0], strerror (errno));
+         return;
+       }
+      zcatfd (fd, 1, doc[0]);
+      close (fd);
+    }
+  else
+    for (j = 0; doc[j]; j++)
+      printf ("%*s%s\n", BASE_INDENT, " ", _(doc[j]));
+}
+
+static void
+show_builtin_command_help ()
+{
+  int i, j;
+  char blurb[36];
+
+  printf (
+_("These shell commands are defined internally.  Type `help' to see this list.\n\
+Type `help name' to find out more about the function `name'.\n\
+Use `info bash' to find out more about the shell in general.\n\
+Use `man -k' or `info' to find out more about commands not in this list.\n\
+\n\
+A star (*) next to a name means that the command is disabled.\n\
+\n"));
+
+  for (i = 0; i < num_shell_builtins; i++)
+    {
+      QUIT;
+      blurb[0] = (shell_builtins[i].flags & BUILTIN_ENABLED) ? ' ' : '*';
+      strncpy (blurb + 1, shell_builtins[i].short_doc, 37);
+      blurb[38] = '\0';
+      printf ("%s", blurb);
+
+      if (i % 2)
+       printf ("\n");
+      else
+       for (j = strlen (blurb); j < 40; j++)
+         putc (' ', stdout);
+    }
+  if (i % 2)
+    printf ("\n");
+}
+#endif /* HELP_BUILTIN */
diff --git a/builtins/help.def.save2 b/builtins/help.def.save2
new file mode 100644 (file)
index 0000000..f376fc3
--- /dev/null
@@ -0,0 +1,217 @@
+This file is help.def, from which is created help.c.
+It implements the builtin "help" in Bash.
+
+Copyright (C) 1987-2003 Free Software Foundation, Inc.
+
+This file is part of GNU Bash, the Bourne Again SHell.
+
+Bash is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Bash is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License along
+with Bash; see the file COPYING.  If not, write to the Free Software
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
+
+$PRODUCES help.c
+
+$BUILTIN help
+$FUNCTION help_builtin
+$DEPENDS_ON HELP_BUILTIN
+$SHORT_DOC help [-s] [pattern ...]
+Display helpful information about builtin commands.  If PATTERN is
+specified, gives detailed help on all commands matching PATTERN,
+otherwise a list of the builtins is printed.  The -s option
+restricts the output for each builtin command matching PATTERN to
+a short usage synopsis.
+$END
+
+#include <config.h>
+
+#if defined (HELP_BUILTIN)
+#include <stdio.h>
+
+#if defined (HAVE_UNISTD_H)
+#  ifdef _MINIX
+#    include <sys/types.h>
+#  endif
+#  include <unistd.h>
+#endif
+
+#include <errno.h>
+
+#include <filecntl.h>
+
+#include "../bashintl.h"
+
+#include "../shell.h"
+#include "../builtins.h"
+#include "../pathexp.h"
+#include "common.h"
+#include "bashgetopt.h"
+
+#include <glob/strmatch.h>
+#include <glob/glob.h>
+
+#ifndef errno
+extern int errno;
+#endif
+
+static void show_builtin_command_help __P((void));
+static void show_longdoc __P((int));
+
+/* Print out a list of the known functions in the shell, and what they do.
+   If LIST is supplied, print out the list which matches for each pattern
+   specified. */
+int
+help_builtin (list)
+     WORD_LIST *list;
+{
+  register int i;
+  char *pattern, *name;
+  int plen, match_found, sflag;
+
+  sflag = 0;
+  reset_internal_getopt ();
+  while ((i = internal_getopt (list, "s")) != -1)
+    {
+      switch (i)
+       {
+       case 's':
+         sflag = 1;
+         break;
+       default:
+         builtin_usage ();
+         return (EX_USAGE);
+       }
+    }
+  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))
+    {
+      if (list->next)
+       printf (_("Shell commands matching keywords `"));
+      else
+       printf (_("Shell commands matching keyword `"));
+      print_word_list (list, ", ");
+      printf ("'\n\n");
+    }
+
+  for (match_found = 0, pattern = ""; list; list = list->next)
+    {
+      pattern = list->word->word;
+      plen = strlen (pattern);
+
+      for (i = 0; name = shell_builtins[i].name; i++)
+       {
+         QUIT;
+         if ((strncmp (pattern, name, plen) == 0) ||
+             (strmatch (pattern, name, FNMATCH_EXTFLAG) != FNM_NOMATCH))
+           {
+             printf ("%s: %s\n", name, shell_builtins[i].short_doc);
+
+             if (sflag == 0)
+               show_longdoc (i);
+
+             match_found++;
+           }
+       }
+    }
+
+  if (match_found == 0)
+    {
+      builtin_error (_("no help topics match `%s'.  Try `help help' or `man -k %s' or `info %s'."), pattern, pattern, pattern);
+      return (EXECUTION_FAILURE);
+    }
+
+  fflush (stdout);
+  return (EXECUTION_SUCCESS);
+}
+
+/* By convention, enforced by mkbuiltins.c, if separate help files are being
+   used, the long_doc array contains one string -- the full pathname of the
+   help file for this builtin.  */
+static void
+show_longdoc (i)
+     int i;
+{
+  register int j;
+  char * const *doc;
+  int fd;
+
+  doc = shell_builtins[i].long_doc;
+
+  if (doc && doc[0] && *doc[0] == '/' && doc[1] == (char *)NULL)
+    {
+      fd = open (doc[0], O_RDONLY);
+      if (fd == -1)
+       {
+         builtin_error (_("%s: cannot open: %s"), doc[0], strerror (errno));
+         return;
+       }
+      zcatfd (fd, 1, doc[0]);
+      close (fd);
+    }
+  else
+    for (j = 0; doc[j]; j++)
+      printf ("%*s%s\n", BASE_INDENT, " ", _(doc[j]));
+}
+
+static void
+show_builtin_command_help ()
+{
+  int i, j;
+  int width;
+  char *t, blurb[128];
+
+  printf (
+_("These shell commands are defined internally.  Type `help' to see this list.\n\
+Type `help name' to find out more about the function `name'.\n\
+Use `info bash' to find out more about the shell in general.\n\
+Use `man -k' or `info' to find out more about commands not in this list.\n\
+\n\
+A star (*) next to a name means that the command is disabled.\n\
+\n"));
+
+  t = get_string_value ("COLUMNS");
+  width = (t && *t) ? atoi (t) : 80;
+  if (width <= 0)
+    width = 80;
+
+  width /= 2;
+  if (width > sizeof (blurb))
+    width = sizeof (blurb);
+
+  for (i = 0; i < num_shell_builtins; i++)
+    {
+      QUIT;
+      blurb[0] = (shell_builtins[i].flags & BUILTIN_ENABLED) ? ' ' : '*';
+      strncpy (blurb + 1, shell_builtins[i].short_doc, width - 2);
+      blurb[width - 1] = '\0';
+      printf ("%s", blurb);
+
+      if (i % 2)
+       printf ("\n");
+      else
+       for (j = strlen (blurb); j < width; j++)
+         putc (' ', stdout);
+    }
+  if (i % 2)
+    printf ("\n");
+}
+#endif /* HELP_BUILTIN */
index 584b944b0bb0f7d14cb575a1f721763394bda7fb..8b598b046274ee7191c1a773fc5a7bf3de384179 100644 (file)
@@ -145,7 +145,7 @@ $END
 
 $BUILTIN variables
 $DOCNAME variable_help
-$SHORT_DOC variables - Some variable names and meanings
+$SHORT_DOC variables - Names and meanings of some shell variables
 BASH_VERSION   Version information for this Bash.
 CDPATH A colon-separated list of directories to search
                for directries given as arguments to `cd'.
index 5e4f6ca0ff8259ed43b27a1499c6e44f97b96faa..9de094c2595bbbef602822ba0770e9aedf21bb17 100644 (file)
@@ -164,13 +164,13 @@ static int get_edit_mode __P((char *));
 static int bash_set_history __P((int, char *));
 #endif
 
-static char *on = "on";
-static char *off = "off";
+static const char * const on = "on";
+static const char * const off = "off";
 
 /* A struct used to match long options for set -o to the corresponding
    option letter or internal variable.  The functions can be called to
    dynamically generate values. */
-struct {
+const struct {
   char *name;
   int letter;
   int *variable;
index e77e723a010386f9a40d260a5e00d43aae09dc53..45c0f7074f42b25c9f822435e461c10a8bf9c1a6 100644 (file)
@@ -61,6 +61,9 @@ extern int no_line_editing;
 $BUILTIN set
 $FUNCTION set_builtin
 $SHORT_DOC set [--abefhkmnptuvxBCHP] [-o option-name] [arg ...]
+Change the value of shell attributes and positional parameters, or display
+the names and values of shell variables.  Available
+shell options are:
     -a  Mark variables which are modified or created for export.
     -b  Notify of job termination immediately.
     -e  Exit immediately if a command exits with a non-zero status.
@@ -161,8 +164,8 @@ static int get_edit_mode __P((char *));
 static int bash_set_history __P((int, char *));
 #endif
 
-static char *on = "on";
-static char *off = "off";
+static const char * const on = "on";
+static const char * const off = "off";
 
 /* A struct used to match long options for set -o to the corresponding
    option letter or internal variable.  The functions can be called to
index 7e7508ac5d10617a283f13c2766747448d4b1836..8055473e506d4945bc4eca870c0a632b5db83a4e 100644 (file)
@@ -68,6 +68,8 @@ extern int glob_ignore_case, match_ignore_case;
 extern int hup_on_exit;
 extern int xpg_echo;
 extern int gnu_error_format;
+extern int check_jobs_at_exit;
+extern int autocd;
 
 #if defined (EXTENDED_GLOB)
 extern int extended_glob;
@@ -114,9 +116,11 @@ static struct {
   int  *value;
   shopt_set_func_t *set_func;
 } shopt_vars[] = {
+  { "autocd", &autocd, (shopt_set_func_t *)NULL },
   { "cdable_vars", &cdable_vars, (shopt_set_func_t *)NULL },
   { "cdspell", &cdspelling, (shopt_set_func_t *)NULL },
   { "checkhash", &check_hashed_filenames, (shopt_set_func_t *)NULL },
+  { "checkjobs", &check_jobs_at_exit, (shopt_set_func_t *)NULL },
   { "checkwinsize", &check_window_size, (shopt_set_func_t *)NULL },
 #if defined (HISTORY)
   { "cmdhist", &command_oriented_history, (shopt_set_func_t *)NULL },
@@ -170,8 +174,8 @@ static struct {
   { (char *)0, (int *)0, (shopt_set_func_t *)NULL }
 };
 
-static char *on = "on";
-static char *off = "off";
+static const char * const on = "on";
+static const char * const off = "off";
 
 static int find_shopt __P((char *));
 static int toggle_shopts __P((int, WORD_LIST *, int));
index dce7745655adc199465a0865e0100e9aecc041a3..0ee794d408d3c952cc2ab352c32db4cbe5b82364 100644 (file)
@@ -1,7 +1,7 @@
 This file is shopt.def, from which is created shopt.c.
 It implements the Bash `shopt' builtin.
 
-Copyright (C) 1994-2005 Free Software Foundation, Inc.
+Copyright (C) 1994-2006 Free Software Foundation, Inc.
 
 This file is part of GNU Bash, the Bourne Again SHell.
 
@@ -68,6 +68,8 @@ extern int glob_ignore_case, match_ignore_case;
 extern int hup_on_exit;
 extern int xpg_echo;
 extern int gnu_error_format;
+extern int check_jobs_at_exit;
+extern int autocd;
 
 #if defined (EXTENDED_GLOB)
 extern int extended_glob;
@@ -114,9 +116,11 @@ static struct {
   int  *value;
   shopt_set_func_t *set_func;
 } shopt_vars[] = {
+  { "autocd", &autocd, (shopt_set_func_t *)NULL },
   { "cdable_vars", &cdable_vars, (shopt_set_func_t *)NULL },
   { "cdspell", &cdspelling, (shopt_set_func_t *)NULL },
   { "checkhash", &check_hashed_filenames, (shopt_set_func_t *)NULL },
+  { "checkjobs", &check_jobs_at_exit, (shopt_set_func_t *)NULL },
   { "checkwinsize", &check_window_size, (shopt_set_func_t *)NULL },
 #if defined (HISTORY)
   { "cmdhist", &command_oriented_history, (shopt_set_func_t *)NULL },
index 339dc36bd0824189d6fd89dcf2cf430131dc8c47..2307c4650f717adca63f86e5aad6393b437f5a6c 100644 (file)
@@ -193,8 +193,8 @@ typedef struct {
   int  option;                 /* The ulimit option for this limit. */
   int  parameter;              /* Parameter to pass to get_limit (). */
   int  block_factor;           /* Blocking factor for specific limit. */
-  char *description;           /* Descriptive string to output. */
-  char *units;                 /* scale */
+  const char * const description;      /* Descriptive string to output. */
+  const char * const units;    /* scale */
 } RESOURCE_LIMITS;
 
 static RESOURCE_LIMITS limits[] = {
index f9a0bba1c1ecb449b087dce2344c87efd515c67e..339dc36bd0824189d6fd89dcf2cf430131dc8c47 100644 (file)
@@ -1,7 +1,7 @@
 This file is ulimit.def, from which is created ulimit.c.
 It implements the builtin "ulimit" in Bash.
 
-Copyright (C) 1987-2005 Free Software Foundation, Inc.
+Copyright (C) 1987-2006 Free Software Foundation, Inc.
 
 This file is part of GNU Bash, the Bourne Again SHell.
 
@@ -430,7 +430,7 @@ ulimit_internal (cmd, cmdarg, mode, multiple)
 
       if ((real_limit / block_factor) != limit)
        {
-         sh_erange (cmdarg, "limit");
+         sh_erange (cmdarg, _("limit"));
          return (EXECUTION_FAILURE);
        }
     }
index 2cc7ca759c30c776382ba9cc7f60e365ee816afb..6b8ae1cdb3119778a1963023acd1255f72ebd7b2 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.in for Bash 3.2, version 3.190.
+# From configure.in for Bash 3.2, version 3.193.
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.59 for bash 3.2-maint.
 #
@@ -1693,7 +1693,7 @@ if test "$opt_curses" = yes; then
 fi
 
 if test -z "${DEBUGGER_START_FILE}"; then
-       DEBUGGER_START_FILE=${ac_default_prefix}/share/bashdb/bashdb-main.inc
+       DEBUGGER_START_FILE='${datadir}/bashdb/bashdb-main.inc'
 fi
 
 opt_minimal_config=no
@@ -23402,7 +23402,7 @@ cat >>conftest.$ac_ext <<_ACEOF
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
-#ifndef SYS_SIGLIST_DECLARED
+#if !HAVE_DECL_SYS_SIGLIST
 extern char *sys_siglist[];
 #endif
 main()
@@ -27426,7 +27426,7 @@ esac
 #AC_SUBST(ALLOCA_SOURCE)
 #AC_SUBST(ALLOCA_OBJECT)
 
-                                                                                                                                                      ac_config_files="$ac_config_files Makefile builtins/Makefile lib/readline/Makefile lib/glob/Makefile lib/intl/Makefile lib/malloc/Makefile lib/sh/Makefile lib/termcap/Makefile lib/tilde/Makefile doc/Makefile support/Makefile po/Makefile.in examples/loadables/Makefile examples/loadables/perl/Makefile pathnames.h"
+                                                                                                                                            ac_config_files="$ac_config_files Makefile builtins/Makefile lib/readline/Makefile lib/glob/Makefile lib/intl/Makefile lib/malloc/Makefile lib/sh/Makefile lib/termcap/Makefile lib/tilde/Makefile doc/Makefile support/Makefile po/Makefile.in examples/loadables/Makefile examples/loadables/perl/Makefile"
           ac_config_commands="$ac_config_commands default"
 cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
@@ -27983,7 +27983,6 @@ do
   "po/Makefile.in" ) CONFIG_FILES="$CONFIG_FILES po/Makefile.in" ;;
   "examples/loadables/Makefile" ) CONFIG_FILES="$CONFIG_FILES examples/loadables/Makefile" ;;
   "examples/loadables/perl/Makefile" ) CONFIG_FILES="$CONFIG_FILES examples/loadables/perl/Makefile" ;;
-  "pathnames.h" ) CONFIG_FILES="$CONFIG_FILES pathnames.h" ;;
   "default-1" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default-1" ;;
   "default" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;;
   "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
index 9ef2200df4cdd7471c18628176b78260eb0d423f..b14ccc676c0b17c4525e8912a51a015bf74c2878 100644 (file)
@@ -22,7 +22,7 @@ dnl Process this file with autoconf to produce a configure script.
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 # 02111-1307, USA.
 
-AC_REVISION([for Bash 3.2, version 3.192])dnl
+AC_REVISION([for Bash 3.2, version 3.193])dnl
 
 define(bashvers, 3.2)
 define(relstatus, maint)
@@ -149,7 +149,7 @@ if test "$opt_curses" = yes; then
 fi
 
 if test -z "${DEBUGGER_START_FILE}"; then
-       DEBUGGER_START_FILE=${ac_default_prefix}/share/bashdb/bashdb-main.inc
+       DEBUGGER_START_FILE='${datadir}/bashdb/bashdb-main.inc'
 fi
 
 dnl optional shell features in config.h.in
@@ -782,7 +782,7 @@ AC_CHECK_LIB(dl, dlopen)
 AC_CHECK_FUNCS(dlopen dlclose dlsym)
 fi
 
-dnl this defines SYS_SIGLIST_DECLARED
+dnl this defines HAVE_DECL_SYS_SIGLIST
 AC_DECL_SYS_SIGLIST
 
 dnl network functions -- check for inet_aton again
@@ -1103,8 +1103,7 @@ AC_OUTPUT([Makefile builtins/Makefile lib/readline/Makefile lib/glob/Makefile \
          lib/intl/Makefile \
          lib/malloc/Makefile lib/sh/Makefile lib/termcap/Makefile \
          lib/tilde/Makefile doc/Makefile support/Makefile po/Makefile.in \
-         examples/loadables/Makefile examples/loadables/perl/Makefile \
-         pathnames.h],
+         examples/loadables/Makefile examples/loadables/perl/Makefile],
 [
 # Makefile uses this timestamp file to record whether config.h is up to date.
 echo timestamp > stamp-h
diff --git a/configure.in.save1 b/configure.in.save1
new file mode 100644 (file)
index 0000000..9ef2200
--- /dev/null
@@ -0,0 +1,1111 @@
+dnl
+dnl Configure script for bash-3.2
+dnl
+dnl report bugs to chet@po.cwru.edu
+dnl
+dnl Process this file with autoconf to produce a configure script.
+
+# Copyright (C) 1987-2006 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+AC_REVISION([for Bash 3.2, version 3.192])dnl
+
+define(bashvers, 3.2)
+define(relstatus, maint)
+
+AC_INIT([bash], bashvers-relstatus, [bug-bash@gnu.org])
+
+dnl make sure we are using a recent autoconf version
+AC_PREREQ(2.50)
+
+AC_CONFIG_SRCDIR(shell.h)
+dnl where to find install.sh, config.sub, and config.guess
+AC_CONFIG_AUX_DIR(./support)
+AC_CONFIG_HEADERS(config.h)
+
+dnl checks for version info
+BASHVERS=bashvers
+RELSTATUS=relstatus
+
+dnl defaults for debug settings
+case "$RELSTATUS" in
+alp*|bet*|dev*|rc*|maint*)     DEBUG='-DDEBUG' MALLOC_DEBUG='-DMALLOC_DEBUG' ;;
+*)     DEBUG= MALLOC_DEBUG= ;;
+esac
+
+dnl canonicalize the host and os so we can do some tricky things before
+dnl parsing options
+AC_CANONICAL_HOST
+
+dnl configure defaults
+opt_bash_malloc=yes
+opt_purify=no
+opt_purecov=no
+opt_afs=no
+opt_curses=no
+opt_with_installed_readline=no
+
+#htmldir=
+
+dnl some systems should be configured without the bash malloc by default
+dnl and some need a special compiler or loader
+dnl look in the NOTES file for more
+case "${host_cpu}-${host_os}" in
+alpha*-*)      opt_bash_malloc=no ;;   # alpha running osf/1 or linux
+*[[Cc]]ray*-*) opt_bash_malloc=no ;;   # Crays
+*-osf1*)       opt_bash_malloc=no ;;   # other osf/1 machines
+sparc-svr4*)   opt_bash_malloc=no ;;   # sparc SVR4, SVR4.2
+sparc-netbsd*) opt_bash_malloc=no ;;   # needs 8-byte alignment
+mips-irix6*)   opt_bash_malloc=no ;;   # needs 8-byte alignment
+m68k-sysv)     opt_bash_malloc=no ;;   # fixes file descriptor leak in closedir
+sparc-linux*)  opt_bash_malloc=no ;;   # sparc running linux; requires ELF
+#*-freebsd*-gnu)       opt_bash_malloc=no ;;   # there's some undetermined problem here
+#*-freebsd*)   opt_bash_malloc=no ;;   # they claim it's better; I disagree
+*-openbsd*)    opt_bash_malloc=no ;;   # they claim it needs eight-bit alignment
+*-aix*)                opt_bash_malloc=no ;;   # AIX machines
+*-nextstep*)   opt_bash_malloc=no ;;   # NeXT machines running NeXTstep
+*-macos*)      opt_bash_malloc=no ;;   # Apple MacOS X
+*-rhapsody*)   opt_bash_malloc=no ;;   # Apple Rhapsody (MacOS X)
+*-darwin*)     opt_bash_malloc=no ;;   # Apple Darwin (MacOS X)
+*-dgux*)       opt_bash_malloc=no ;;   # DG/UX machines
+*-qnx*)                opt_bash_malloc=no ;;   # QNX 4.2, QNX 6.x
+*-machten4)    opt_bash_malloc=no ;;   # MachTen 4.x
+*-bsdi2.1|*-bsdi3.?)   opt_bash_malloc=no ; : ${CC:=shlicc2} ;; # for loadable builtins
+*-beos*)       opt_bash_malloc=no ;;   # they say it's suitable
+*-cygwin*)     opt_bash_malloc=no ;;   # Cygnus's CYGWIN environment
+*-opennt*|*-interix*)  opt_bash_malloc=no ;;   # Interix, now owned by Microsoft
+esac
+
+# memory scrambling on free()
+case "${host_os}" in
+sco3.2v5*|sco3.2v4*)   opt_memscramble=no ;;
+*)                     opt_memscramble=yes ;;
+esac
+
+dnl
+dnl macros for the bash debugger
+dnl
+AM_PATH_LISPDIR
+AC_ARG_VAR(DEBUGGER_START_FILE, [location of bash debugger initialization file])
+
+dnl arguments to configure
+dnl packages
+AC_ARG_WITH(afs, AC_HELP_STRING([--with-afs], [if you are running AFS]), opt_afs=$withval)
+AC_ARG_WITH(bash-malloc, AC_HELP_STRING([--with-bash-malloc], [use the Bash version of malloc]), opt_bash_malloc=$withval)
+AC_ARG_WITH(curses, AC_HELP_STRING([--with-curses], [use the curses library instead of the termcap library]), opt_curses=$withval)
+AC_ARG_WITH(gnu-malloc, AC_HELP_STRING([--with-gnu-malloc], [synonym for --with-bash-malloc]), opt_bash_malloc=$withval)
+AC_ARG_WITH(installed-readline, AC_HELP_STRING([--with-installed-readline], [use a version of the readline library that is already installed]), opt_with_installed_readline=$withval)
+AC_ARG_WITH(purecov, AC_HELP_STRING([--with-purecov], [configure to postprocess with pure coverage]), opt_purecov=$withval)
+AC_ARG_WITH(purify, AC_HELP_STRING([--with-purify], [configure to postprocess with purify]), opt_purify=$withval)
+
+if test "$opt_bash_malloc" = yes; then
+       MALLOC_TARGET=malloc
+       MALLOC_SRC=malloc.c
+
+       MALLOC_LIB='-lmalloc'
+       MALLOC_LIBRARY='$(ALLOC_LIBDIR)/libmalloc.a'
+       MALLOC_LDFLAGS='-L$(ALLOC_LIBDIR)'
+       MALLOC_DEP='$(MALLOC_LIBRARY)'
+
+       AC_DEFINE(USING_BASH_MALLOC)
+else
+       MALLOC_LIB=
+       MALLOC_LIBRARY=
+       MALLOC_LDFLAGS=
+       MALLOC_DEP=     
+fi
+
+if test "$opt_purify" = yes; then
+       PURIFY="purify "
+       AC_DEFINE(DISABLE_MALLOC_WRAPPERS)
+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
+
+if test -z "${DEBUGGER_START_FILE}"; then
+       DEBUGGER_START_FILE=${ac_default_prefix}/share/bashdb/bashdb-main.inc
+fi
+
+dnl optional shell features in config.h.in
+opt_minimal_config=no
+
+opt_job_control=yes
+opt_alias=yes
+opt_readline=yes
+opt_history=yes
+opt_bang_history=yes
+opt_dirstack=yes
+opt_restricted=yes
+opt_process_subst=yes
+opt_prompt_decoding=yes
+opt_select=yes
+opt_help=yes
+opt_array_variables=yes
+opt_dparen_arith=yes
+opt_extended_glob=yes
+opt_brace_expansion=yes
+opt_disabled_builtins=no
+opt_command_timing=yes
+opt_xpg_echo=no
+opt_strict_posix=no
+opt_cond_command=yes
+opt_cond_regexp=yes
+opt_arith_for_command=yes
+opt_net_redirs=yes
+opt_progcomp=yes
+opt_separate_help=no
+opt_multibyte=yes
+opt_debugger=yes
+opt_single_longdoc_strings=yes
+
+dnl options that affect how bash is compiled and linked
+opt_static_link=no
+opt_profiling=no
+
+dnl argument parsing for optional features
+AC_ARG_ENABLE(minimal-config, AC_HELP_STRING([--enable-minimal-config], [a minimal sh-like configuration]), opt_minimal_config=$enableval)
+
+dnl a minimal configuration turns everything off, but features can be
+dnl added individually
+if test $opt_minimal_config = yes; then
+       opt_job_control=no opt_alias=no opt_readline=no
+       opt_history=no opt_bang_history=no opt_dirstack=no
+       opt_restricted=no opt_process_subst=no opt_prompt_decoding=no
+       opt_select=no opt_help=no opt_array_variables=no opt_dparen_arith=no
+       opt_brace_expansion=no opt_disabled_builtins=no opt_command_timing=no
+       opt_extended_glob=no opt_cond_command=no opt_arith_for_command=no
+       opt_net_redirs=no opt_progcomp=no opt_separate_help=no
+       opt_multibyte=yes opt_cond_regexp=no
+fi
+
+AC_ARG_ENABLE(alias, AC_HELP_STRING([--enable-alias], [enable shell aliases]), opt_alias=$enableval)
+AC_ARG_ENABLE(arith-for-command, AC_HELP_STRING([--enable-arith-for-command], [enable arithmetic for command]), opt_arith_for_command=$enableval)
+AC_ARG_ENABLE(array-variables, AC_HELP_STRING([--enable-array-variables], [include shell array variables]), opt_array_variables=$enableval)
+AC_ARG_ENABLE(bang-history, AC_HELP_STRING([--enable-bang-history], [turn on csh-style history substitution]), opt_bang_history=$enableval)
+AC_ARG_ENABLE(brace-expansion, AC_HELP_STRING([--enable-brace-expansion], [include brace expansion]), opt_brace_expansion=$enableval)
+AC_ARG_ENABLE(command-timing, AC_HELP_STRING([--enable-command-timing], [enable the time reserved word and command timing]), opt_command_timing=$enableval)
+AC_ARG_ENABLE(cond-command, AC_HELP_STRING([--enable-cond-command], [enable the conditional command]), opt_cond_command=$enableval)
+AC_ARG_ENABLE(cond-regexp, AC_HELP_STRING([--enable-cond-regexp], [enable extgended regular expression matching in conditional commands]), opt_cond_regexp=$enableval)
+AC_ARG_ENABLE(debugger, AC_HELP_STRING([--enable-debugger], [enable support for bash debugger]), opt_debugger=$enableval)
+AC_ARG_ENABLE(directory-stack, AC_HELP_STRING([--enable-directory-stack], [enable builtins pushd/popd/dirs]), opt_dirstack=$enableval)
+AC_ARG_ENABLE(disabled-builtins, AC_HELP_STRING([--enable-disabled-builtins], [allow disabled builtins to still be invoked]), opt_disabled_builtins=$enableval)
+AC_ARG_ENABLE(dparen-arithmetic, AC_HELP_STRING([--enable-dparen-arithmetic], [include ((...)) command]), opt_dparen_arith=$enableval)
+AC_ARG_ENABLE(extended-glob, AC_HELP_STRING([--enable-extended-glob], [include ksh-style extended pattern matching]), opt_extended_glob=$enableval)
+AC_ARG_ENABLE(help-builtin, AC_HELP_STRING([--enable-help-builtin], [include the help builtin]), opt_help=$enableval)
+AC_ARG_ENABLE(history, AC_HELP_STRING([--enable-history], [turn on command history]), opt_history=$enableval)
+AC_ARG_ENABLE(job-control, AC_HELP_STRING([--enable-job-control], [enable job control features]), opt_job_control=$enableval)
+AC_ARG_ENABLE(multibyte, AC_HELP_STRING([--enable-multibyte], [enable multibyte characters if OS supports them]), opt_multibyte=$enableval)
+AC_ARG_ENABLE(net-redirections, AC_HELP_STRING([--enable-net-redirections], [enable /dev/tcp/host/port redirection]), opt_net_redirs=$enableval)
+AC_ARG_ENABLE(process-substitution, AC_HELP_STRING([--enable-process-substitution], [enable process substitution]), opt_process_subst=$enableval)
+AC_ARG_ENABLE(progcomp, AC_HELP_STRING([--enable-progcomp], [enable programmable completion and the complete builtin]), opt_progcomp=$enableval)
+AC_ARG_ENABLE(prompt-string-decoding, AC_HELP_STRING([--enable-prompt-string-decoding], [turn on escape character decoding in prompts]), opt_prompt_decoding=$enableval)
+AC_ARG_ENABLE(readline, AC_HELP_STRING([--enable-readline], [turn on command line editing]), opt_readline=$enableval)
+AC_ARG_ENABLE(restricted, AC_HELP_STRING([--enable-restricted], [enable a restricted shell]), opt_restricted=$enableval)
+AC_ARG_ENABLE(select, AC_HELP_STRING([--enable-select], [include select command]), opt_select=$enableval)
+AC_ARG_ENABLE(separate-helpfiles, AC_HELP_STRING([--enable-separate-helpfiles], [use external files for help builtin documentation]), opt_separate_help=$enableval)
+AC_ARG_ENABLE(single-help-strings, AC_HELP_STRING([--enable-single-help-strings], [store help documentation as a single string to ease translation]), opt_single_longdoc_strings=$enableval)
+AC_ARG_ENABLE(strict-posix-default, AC_HELP_STRING([--enable-strict-posix-default], [configure bash to be posix-conformant by default]), opt_strict_posix=$enableval)
+AC_ARG_ENABLE(usg-echo-default, AC_HELP_STRING([--enable-usg-echo-default], [a synonym for --enable-xpg-echo-default]), opt_xpg_echo=$enableval)
+AC_ARG_ENABLE(xpg-echo-default, AC_HELP_STRING([--enable-xpg-echo-default], [make the echo builtin expand escape sequences by default]), opt_xpg_echo=$enableval)
+
+dnl options that alter how bash is compiled and linked
+AC_ARG_ENABLE(mem-scramble, AC_HELP_STRING([--enable-mem-scramble], [scramble memory on calls to malloc and free]), opt_memscramble=$enableval)
+AC_ARG_ENABLE(profiling, AC_HELP_STRING([--enable-profiling], [allow profiling with gprof]), opt_profiling=$enableval)
+AC_ARG_ENABLE(static-link, AC_HELP_STRING([--enable-static-link], [link bash statically, for use as a root shell]), opt_static_link=$enableval)
+
+dnl opt_job_control is handled later, after BASH_JOB_CONTROL_MISSING runs
+
+dnl opt_readline and opt_history are handled later, because AC_PROG_CC needs
+dnl to be run before we can check the version of an already-installed readline
+dnl library
+
+if test $opt_alias = yes; then
+AC_DEFINE(ALIAS)
+fi
+if test $opt_dirstack = yes; then
+AC_DEFINE(PUSHD_AND_POPD)
+fi
+if test $opt_restricted = yes; then
+AC_DEFINE(RESTRICTED_SHELL)
+fi
+if test $opt_process_subst = yes; then
+AC_DEFINE(PROCESS_SUBSTITUTION)
+fi
+if test $opt_prompt_decoding = yes; then
+AC_DEFINE(PROMPT_STRING_DECODE)
+fi
+if test $opt_select = yes; then
+AC_DEFINE(SELECT_COMMAND)
+fi
+if test $opt_help = yes; then
+AC_DEFINE(HELP_BUILTIN)
+fi
+if test $opt_array_variables = yes; then
+AC_DEFINE(ARRAY_VARS)
+fi
+if test $opt_dparen_arith = yes; then
+AC_DEFINE(DPAREN_ARITHMETIC)
+fi
+if test $opt_brace_expansion = yes; then
+AC_DEFINE(BRACE_EXPANSION)
+fi
+if test $opt_disabled_builtins = yes; then
+AC_DEFINE(DISABLED_BUILTINS)
+fi
+if test $opt_command_timing = yes; then
+AC_DEFINE(COMMAND_TIMING)
+fi
+if test $opt_xpg_echo = yes ; then
+AC_DEFINE(DEFAULT_ECHO_TO_XPG)
+fi
+if test $opt_strict_posix = yes; then
+AC_DEFINE(STRICT_POSIX)
+fi
+if test $opt_extended_glob = yes ; then
+AC_DEFINE(EXTENDED_GLOB)
+fi
+if test $opt_cond_command = yes ; then
+AC_DEFINE(COND_COMMAND)
+fi
+if test $opt_cond_regexp = yes ; then
+AC_DEFINE(COND_REGEXP)
+fi
+if test $opt_arith_for_command = yes; then
+AC_DEFINE(ARITH_FOR_COMMAND)
+fi
+if test $opt_net_redirs = yes; then
+AC_DEFINE(NETWORK_REDIRECTIONS)
+fi
+if test $opt_progcomp = yes; then
+AC_DEFINE(PROGRAMMABLE_COMPLETION)
+fi
+if test $opt_multibyte = no; then
+AC_DEFINE(NO_MULTIBYTE_SUPPORT)
+fi
+if test $opt_debugger = yes; then
+AC_DEFINE(DEBUGGER)
+fi
+
+if test $opt_memscramble = yes; then
+AC_DEFINE(MEMSCRAMBLE)
+fi
+
+if test "$opt_minimal_config" = yes; then
+       TESTSCRIPT=run-minimal
+else
+       TESTSCRIPT=run-all
+fi
+
+HELPDIR= HELPDIRDEFINE= HELPINSTALL=
+if test "$opt_separate_help" != no; then
+       if test "$opt_separate_help" = "yes" ; then
+               HELPDIR='${datadir}/bash'
+       else
+               HELPDIR=$opt_separate_help
+       fi
+       HELPDIRDEFINE='-H ${HELPDIR}'
+       HELPINSTALL='install-help'
+fi
+HELPSTRINGS=
+if test "$opt_single_longdoc_strings" != "yes"; then
+       HELPSTRINGS='-S'
+fi
+
+dnl now substitute in the values generated by arguments
+AC_SUBST(TESTSCRIPT)
+AC_SUBST(PURIFY)
+AC_SUBST(MALLOC_TARGET)
+AC_SUBST(MALLOC_SRC)
+
+AC_SUBST(MALLOC_LIB)
+AC_SUBST(MALLOC_LIBRARY)
+AC_SUBST(MALLOC_LDFLAGS)
+AC_SUBST(MALLOC_DEP)
+
+AC_SUBST(htmldir)
+
+AC_SUBST(HELPDIR)
+AC_SUBST(HELPDIRDEFINE)
+AC_SUBST(HELPINSTALL)
+AC_SUBST(HELPSTRINGS)
+
+echo ""
+echo "Beginning configuration for bash-$BASHVERS-$RELSTATUS for ${host_cpu}-${host_vendor}-${host_os}"
+echo ""
+
+dnl compilation checks
+dnl AC_PROG_CC sets $cross_compiling to `yes' if cross-compiling for a
+dnl different environment
+AC_PROG_CC
+
+dnl test for Unix variants
+AC_ISC_POSIX
+AC_MINIX
+
+AC_SYS_LARGEFILE
+
+dnl BEGIN changes for cross-building (currently cygwin, minGW, and
+dnl (obsolete) BeOS)
+
+SIGNAMES_O=
+SIGNAMES_H=lsignames.h
+
+dnl load up the cross-building cache file -- add more cases and cache
+dnl files as necessary
+
+dnl Note that host and target machine are the same, and different than the
+dnl build machine.
+dnl Set SIGNAMES_H based on whether or not we're cross-compiling.
+
+CROSS_COMPILE=
+if test "x$cross_compiling" = "xyes"; then
+    case "${host}" in
+    *-cygwin*)
+       cross_cache=${srcdir}/cross-build/cygwin32.cache
+       ;;
+    *-mingw*)
+       cross_cache=${srcdir}/cross-build/cygwin32.cache
+       ;;
+    i[[3456]]86-*-beos*)
+       cross_cache=${srcdir}/cross-build/x86-beos.cache
+       ;;
+    *) echo "configure: cross-compiling for $host is not supported" >&2
+       ;;
+    esac
+    if test -n "${cross_cache}" && test -r "${cross_cache}"; then
+       echo "loading cross-build cache file ${cross_cache}"
+       . ${cross_cache}
+    fi
+    unset cross_cache
+    SIGNAMES_O='signames.o'
+    CROSS_COMPILE='-DCROSS_COMPILING'
+    AC_SUBST(CROSS_COMPILE)
+fi
+AC_SUBST(SIGNAMES_H)
+AC_SUBST(SIGNAMES_O)
+
+if test -z "$CC_FOR_BUILD"; then
+    if test "x$cross_compiling" = "xno"; then
+       CC_FOR_BUILD='$(CC)'
+    else
+       CC_FOR_BUILD=gcc
+    fi
+fi
+AC_SUBST(CC_FOR_BUILD)
+
+dnl END changes for cross-building
+
+dnl We want these before the checks, so the checks can modify their values.
+test -z "$CFLAGS" && CFLAGS=-g auto_cflags=1
+
+dnl If we're using gcc and the user hasn't specified CFLAGS, add -O2 to CFLAGS.
+test -n "$GCC" && test -n "$auto_cflags" && CFLAGS="$CFLAGS -O2"
+
+dnl handle options that alter how bash is compiled and linked
+dnl these must come after the test for cc/gcc
+if test "$opt_profiling" = "yes"; then
+       PROFILE_FLAGS=-pg
+       case "$host_os" in
+       solaris2*)      ;;
+       *)              opt_static_link=yes ;;
+       esac
+       DEBUG= MALLOC_DEBUG=
+fi
+
+if test "$opt_static_link" = yes; then
+       # if we're using gcc, add `-static' to LDFLAGS, except on Solaris >= 2
+       if test -n "$GCC" || test "$ac_cv_prog_gcc" = "yes"; then
+               STATIC_LD="-static" 
+               case "$host_os" in
+               solaris2*)      ;;
+               *)              LDFLAGS="$LDFLAGS -static" ;;   # XXX experimental
+               esac
+       fi
+fi
+
+if test "X$cross_compiling" = "Xno"; then
+       CPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-"$CPPFLAGS"}
+       LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-'$(LDFLAGS)'}
+else
+       CPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-""}
+       LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-""}
+fi
+
+test -z "$CFLAGS_FOR_BUILD" && CFLAGS_FOR_BUILD="-g"
+
+AC_SUBST(CFLAGS)
+AC_SUBST(CPPFLAGS)
+AC_SUBST(LDFLAGS)
+AC_SUBST(STATIC_LD)
+
+AC_SUBST(CFLAGS_FOR_BUILD)
+AC_SUBST(CPPFLAGS_FOR_BUILD)
+AC_SUBST(LDFLAGS_FOR_BUILD)
+
+AC_PROG_GCC_TRADITIONAL
+
+dnl BEGIN READLINE and HISTORY LIBRARY SECTION
+dnl prepare to allow bash to be linked against an already-installed readline
+
+dnl first test that the readline version is new enough to link bash against
+if test "$opt_readline" = yes && test "$opt_with_installed_readline" != "no"
+then
+       # If the user specified --with-installed-readline=PREFIX and PREFIX
+       # is not `yes', set ac_cv_rl_prefix to PREFIX
+       test $opt_with_installed_readline != "yes" && ac_cv_rl_prefix=$opt_with_installed_readline
+
+       RL_LIB_READLINE_VERSION
+
+       case "$ac_cv_rl_version" in
+       5*|6*|7*|8*|9*) ;;
+       *)      opt_with_installed_readline=no 
+               AC_MSG_WARN(installed readline library is too old to be linked with bash)
+               AC_MSG_WARN(using private bash version)
+               ;;
+       esac
+fi
+
+TILDE_LIB=-ltilde
+if test $opt_readline = yes; then
+       AC_DEFINE(READLINE)
+       if test "$opt_with_installed_readline" != "no" ; then
+               case "$opt_with_installed_readline" in
+               yes)    RL_INCLUDE= ;;
+               *)      case "$RL_INCLUDEDIR" in
+                       /usr/include)   ;;
+                       *)              RL_INCLUDE='-I${RL_INCLUDEDIR}' ;;
+                       esac
+                       ;;
+               esac
+               READLINE_DEP=
+               READLINE_LIB=-lreadline
+               # section for OS versions that don't allow unresolved symbols
+               # to be compiled into dynamic libraries.
+               case "$host_os" in
+               cygwin*)        TILDE_LIB= ;;
+               esac
+       else
+               RL_LIBDIR='$(dot)/$(LIBSUBDIR)/readline'
+               READLINE_DEP='$(READLINE_LIBRARY)'
+               # section for OS versions that ship an older/broken version of
+               # readline as a standard dynamic library and don't allow a
+               # static version specified as -llibname to override the
+               # dynamic version
+               case "${host_os}" in
+               darwin8*)       READLINE_LIB='${READLINE_LIBRARY}' ;;
+               *)              READLINE_LIB=-lreadline ;;
+               esac
+       fi
+else
+       RL_LIBDIR='$(dot)/$(LIBSUBDIR)/readline'
+       READLINE_LIB= READLINE_DEP=
+fi
+if test $opt_history = yes || test $opt_bang_history = yes; then
+       if test $opt_history = yes; then
+               AC_DEFINE(HISTORY)
+       fi
+       if test $opt_bang_history = yes; then
+               AC_DEFINE(BANG_HISTORY)
+       fi
+       if test "$opt_with_installed_readline" != "no"; then
+               HIST_LIBDIR=$RL_LIBDIR
+               HISTORY_DEP=
+               HISTORY_LIB=-lhistory
+               case "$opt_with_installed_readline" in
+               yes)    RL_INCLUDE= ;;
+               *)      case "$RL_INCLUDEDIR" in
+                       /usr/include)   ;;
+                       *)              RL_INCLUDE='-I${RL_INCLUDEDIR}' ;;
+                       esac
+                       ;;
+               esac
+       else
+               HIST_LIBDIR='$(dot)/$(LIBSUBDIR)/readline'
+               HISTORY_DEP='$(HISTORY_LIBRARY)'
+               # section for OS versions that ship an older version of
+               # readline as a standard dynamic library and don't allow a
+               # static version specified as -llibname to override the
+               # dynamic version
+               case "${host_os}" in
+               darwin8*)       HISTORY_LIB='${HISTORY_LIBRARY}' ;;
+               *)              HISTORY_LIB=-lhistory ;;
+               esac
+       fi
+else
+       HIST_LIBDIR='$(dot)/$(LIBSUBDIR)/readline'
+       HISTORY_LIB= HISTORY_DEP=
+fi
+AC_SUBST(READLINE_LIB)
+AC_SUBST(READLINE_DEP)
+AC_SUBST(RL_LIBDIR)
+AC_SUBST(RL_INCLUDEDIR)
+AC_SUBST(RL_INCLUDE)
+AC_SUBST(HISTORY_LIB)
+AC_SUBST(HISTORY_DEP)
+AC_SUBST(HIST_LIBDIR)
+AC_SUBST(TILDE_LIB)
+
+dnl END READLINE and HISTORY LIBRARY SECTION
+
+dnl programs needed by the build and install process
+AC_PROG_INSTALL
+AC_CHECK_PROG(AR, ar, , ar)
+dnl Set default for ARFLAGS, since autoconf does not have a macro for it.
+dnl This allows people to set it when running configure or make
+test -n "$ARFLAGS" || ARFLAGS="cr"
+AC_PROG_RANLIB
+AC_PROG_YACC
+AC_PROG_MAKE_SET
+
+case "$host_os" in
+opennt*|interix*)      MAKE_SHELL="$INTERIX_ROOT/bin/sh" ;;
+*)                     MAKE_SHELL=/bin/sh ;;
+esac
+AC_SUBST(MAKE_SHELL)
+
+dnl this is similar to the expanded AC_PROG_RANLIB
+if test x$SIZE = x; then
+       if test x$ac_tool_prefix = x; then
+               SIZE=size
+       else
+               SIZE=${ac_tool_prefix}size
+               save_IFS=$IFS ; IFS=:
+               size_found=0
+               for dir in $PATH; do
+                       if test -x $dir/$SIZE ; then
+                               size_found=1
+                               break
+                       fi
+               done
+               if test $size_found -eq 0; then
+                       SIZE=:
+               fi
+               IFS=$save_IFS
+       fi
+fi
+AC_SUBST(SIZE)
+
+dnl Turn on any extensions available in the GNU C library.
+AC_DEFINE(_GNU_SOURCE, 1)
+
+dnl C compiler characteristics
+AC_C_CONST
+AC_C_INLINE
+AC_C_BIGENDIAN
+AC_C_STRINGIZE
+AC_C_LONG_DOUBLE
+AC_C_PROTOTYPES
+AC_C_CHAR_UNSIGNED
+
+dnl initialize GNU gettext
+AM_GNU_GETTEXT([no-libtool], [need-ngettext], [lib/intl])
+
+dnl header files
+AC_HEADER_DIRENT
+AC_HEADER_TIME
+
+BASH_HEADER_INTTYPES
+
+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 dlfcn.h \
+                stddef.h stdint.h netdb.h pwd.h grp.h strings.h regex.h)
+AC_CHECK_HEADERS(sys/pte.h sys/stream.h sys/select.h sys/file.h \
+                sys/resource.h sys/param.h sys/socket.h sys/stat.h \
+                sys/time.h sys/times.h sys/types.h sys/wait.h)
+AC_CHECK_HEADERS(netinet/in.h arpa/inet.h)
+
+dnl sys/ptem.h requires definitions from sys/stream.h on systems where it
+dnl exists
+AC_CHECK_HEADER(sys/ptem.h, , ,[[
+#if HAVE_SYS_STREAM_H
+#  include <sys/stream.h>
+#endif
+]])
+
+dnl special checks for libc functions
+AC_FUNC_ALLOCA
+AC_FUNC_GETPGRP
+AC_FUNC_SETVBUF_REVERSED
+AC_FUNC_VPRINTF
+AC_FUNC_STRCOLL
+
+dnl if we're not using the bash malloc but require the C alloca, set things
+dnl up to build a libmalloc.a containing only alloca.o
+
+if test "$ac_cv_func_alloca_works" = "no" && test "$opt_bash_malloc" = "no"; then
+       MALLOC_TARGET=alloca
+       MALLOC_SRC=alloca.c
+
+       MALLOC_LIB='-lmalloc'
+       MALLOC_LIBRARY='$(ALLOC_LIBDIR)/libmalloc.a'
+       MALLOC_LDFLAGS='-L$(ALLOC_LIBDIR)'
+       MALLOC_DEP='$(MALLOC_LIBRARY)'
+fi
+
+dnl if vprintf is not in libc, see if it's defined in stdio.h
+if test "$ac_cv_func_vprintf" = no; then
+    AC_MSG_CHECKING(for declaration of vprintf in stdio.h)
+    AC_EGREP_HEADER([[int[     ]*vprintf[^a-zA-Z0-9]]],stdio.h,ac_cv_func_vprintf=yes)
+    AC_MSG_RESULT($ac_cv_func_vprintf)
+    if test $ac_cv_func_vprintf = yes; then
+       AC_DEFINE(HAVE_VPRINTF)
+    fi
+fi
+
+if test "$ac_cv_func_vprintf" = no && test "$ac_cv_func__doprnt" = "yes"; then
+  AC_LIBOBJ(vprint)
+fi
+
+dnl signal stuff
+AC_TYPE_SIGNAL
+
+dnl checks for certain version-specific system calls and libc functions
+AC_CHECK_FUNC(__setostype, AC_DEFINE(HAVE_SETOSTYPE))
+AC_CHECK_FUNC(wait3, AC_DEFINE(HAVE_WAIT3))
+AC_CHECK_FUNC(isinf, AC_DEFINE(HAVE_ISINF_IN_LIBC))
+AC_CHECK_FUNC(isnan, AC_DEFINE(HAVE_ISNAN_IN_LIBC))
+
+dnl checks for missing libc functions
+AC_CHECK_FUNC(mkfifo,AC_DEFINE(HAVE_MKFIFO),AC_DEFINE(MKFIFO_MISSING))
+
+dnl checks for system calls
+AC_CHECK_FUNCS(dup2 eaccess fcntl getdtablesize getgroups gethostname \
+               getpagesize getpeername getrlimit getrusage gettimeofday \
+               kill killpg lstat readlink sbrk select setdtablesize \
+               tcgetpgrp uname ulimit waitpid)
+AC_REPLACE_FUNCS(rename)
+
+dnl checks for c library functions
+AC_CHECK_FUNCS(bcopy bzero confstr fnmatch \
+               getaddrinfo gethostbyname getservbyname getservent inet_aton \
+               memmove pathconf putenv raise regcomp regexec \
+               setenv setlinebuf setlocale setvbuf siginterrupt strchr \
+               sysconf tcgetattr times ttyname tzset unsetenv)
+
+AC_CHECK_FUNCS(vsnprintf snprintf vasprintf asprintf)
+AC_CHECK_FUNCS(isascii isblank isgraph isprint isspace isxdigit)
+AC_CHECK_FUNCS(getpwent getpwnam getpwuid)
+AC_REPLACE_FUNCS(getcwd memset strcasecmp strerror strftime strnlen strpbrk strstr)
+AC_REPLACE_FUNCS(strtod strtol strtoul strtoll strtoull strtoimax strtoumax)
+
+AC_CHECK_DECLS([confstr])
+AC_CHECK_DECLS([printf])
+AC_CHECK_DECLS([sbrk])
+AC_CHECK_DECLS([setregid])
+AC_CHECK_DECLS([strcpy])
+AC_CHECK_DECLS([strsignal])
+
+dnl Extra test to detect the horribly broken HP/UX 11.00 strtold(3)
+AC_CHECK_DECLS([strtold], [
+    AC_MSG_CHECKING([for broken strtold])
+    AC_CACHE_VAL(bash_cv_strtold_broken,
+       [AC_TRY_COMPILE(
+           [#include <stdlib.h>],
+           [int main() { long double r; char *foo, bar; r = strtold(foo, &bar);}],
+           bash_cv_strtold_broken=no, bash_cv_strtold_broken=yes,
+           [AC_MSG_WARN(cannot check for broken strtold if cross-compiling, defaulting to no)])
+       ]
+    )
+    AC_MSG_RESULT($bash_cv_strtold_broken)
+    if test "$bash_cv_strtold_broken" = "yes" ; then
+       AC_DEFINE(STRTOLD_BROKEN)
+    fi
+])
+    
+
+BASH_CHECK_DECL(strtoimax)
+BASH_CHECK_DECL(strtol)
+BASH_CHECK_DECL(strtoll)
+BASH_CHECK_DECL(strtoul)
+BASH_CHECK_DECL(strtoull)
+BASH_CHECK_DECL(strtoumax)
+
+AC_FUNC_MKTIME
+
+dnl
+dnl Checks for lib/intl and related code (uses some of the output from
+dnl AM_GNU_GETTEXT)
+dnl
+
+AC_CHECK_HEADERS([argz.h errno.h fcntl.h malloc.h stdio_ext.h])
+
+dnl AC_FUNC_MALLOC
+AC_FUNC_MMAP
+AC_CHECK_FUNCS([__argz_count __argz_next __argz_stringify dcgettext mempcpy \
+               munmap stpcpy strcspn strdup])
+
+INTL_DEP= INTL_INC= LIBINTL_H=
+if test "x$USE_INCLUDED_LIBINTL" = "xyes"; then
+       INTL_DEP='${INTL_LIBDIR}/libintl.a'
+       INTL_INC='-I${INTL_LIBSRC} -I${INTL_BUILDDIR}'
+       LIBINTL_H='${INTL_BUILDDIR}/libintl.h'
+fi
+AC_SUBST(INTL_DEP)
+AC_SUBST(INTL_INC)
+AC_SUBST(LIBINTL_H)
+
+dnl
+dnl End of checks needed by files in lib/intl
+dnl
+
+BASH_CHECK_MULTIBYTE
+
+dnl checks for the dynamic loading library functions in libc and libdl
+if test "$opt_static_link" != yes; then
+AC_CHECK_LIB(dl, dlopen)
+AC_CHECK_FUNCS(dlopen dlclose dlsym)
+fi
+
+dnl this defines SYS_SIGLIST_DECLARED
+AC_DECL_SYS_SIGLIST
+
+dnl network functions -- check for inet_aton again
+if test "$ac_cv_func_inet_aton" != 'yes'; then
+BASH_FUNC_INET_ATON
+fi
+
+dnl libraries
+dnl this is reportedly no longer necessary for irix[56].?
+case "$host_os" in
+irix4*)        AC_CHECK_LIB(sun, getpwent) ;;
+esac
+
+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_LIB_SOCKET
+fi
+dnl check for gethostbyname in socket libraries if it's not in libc
+if test "$ac_cv_func_gethostbyname" = no; then
+       BASH_FUNC_GETHOSTBYNAME
+fi
+
+dnl system types
+AC_TYPE_GETGROUPS
+AC_TYPE_OFF_T
+AC_TYPE_MODE_T
+AC_TYPE_UID_T
+AC_TYPE_PID_T
+AC_TYPE_SIZE_T
+AC_CHECK_TYPE(ssize_t, int)
+AC_CHECK_TYPE(time_t, long)
+
+BASH_TYPE_LONG_LONG
+BASH_TYPE_UNSIGNED_LONG_LONG
+
+AC_TYPE_SIGNAL
+
+AC_CHECK_SIZEOF(char, 1)
+AC_CHECK_SIZEOF(short, 2)
+AC_CHECK_SIZEOF(int, 4)
+AC_CHECK_SIZEOF(long, 4)
+AC_CHECK_SIZEOF(char *, 4)
+AC_CHECK_SIZEOF(double, 8)
+AC_CHECK_SIZEOF([long long], 8)
+
+AC_CHECK_TYPE(u_int, [unsigned int])
+AC_CHECK_TYPE(u_long, [unsigned long])
+
+BASH_TYPE_BITS16_T
+BASH_TYPE_U_BITS16_T
+BASH_TYPE_BITS32_T
+BASH_TYPE_U_BITS32_T
+BASH_TYPE_BITS64_T
+
+BASH_TYPE_PTRDIFF_T
+
+dnl structures
+AC_HEADER_STAT
+
+dnl system services
+AC_SYS_INTERPRETER
+if test $ac_cv_sys_interpreter = yes; then
+AC_DEFINE(HAVE_HASH_BANG_EXEC)
+fi
+
+dnl Miscellaneous Bash tests
+if test "$ac_cv_func_lstat" = "no"; then
+BASH_FUNC_LSTAT
+fi
+
+dnl behavior of system calls and library functions
+BASH_FUNC_CTYPE_NONASCII
+BASH_FUNC_DUP2_CLOEXEC_CHECK
+BASH_SYS_PGRP_SYNC
+BASH_SYS_SIGNAL_VINTAGE
+
+dnl checking for the presence of certain library symbols
+BASH_SYS_ERRLIST
+BASH_SYS_SIGLIST
+BASH_UNDER_SYS_SIGLIST
+
+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_CHECK_TYPE(intmax_t, , $bash_cv_type_long_long)
+BASH_CHECK_TYPE(uintmax_t, , $bash_cv_type_unsigned_long_long)
+if test "$ac_cv_header_sys_socket_h" = "yes"; then
+BASH_CHECK_TYPE(socklen_t, [#include <sys/socket.h>], int, HAVE_SOCKLEN_T)
+fi
+BASH_TYPE_RLIMIT
+
+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_DIRENT_D_NAMLEN
+BASH_STRUCT_WINSIZE
+BASH_STRUCT_TIMEVAL
+AC_CHECK_MEMBERS([struct stat.st_blocks])
+AC_STRUCT_TM
+AC_STRUCT_TIMEZONE
+BASH_STRUCT_TIMEZONE
+
+dnl presence and behavior of C library functions
+BASH_FUNC_STRSIGNAL
+BASH_FUNC_OPENDIR_CHECK
+BASH_FUNC_ULIMIT_MAXFDS
+BASH_FUNC_GETENV
+if test "$ac_cv_func_getcwd" = "yes"; then
+BASH_FUNC_GETCWD
+fi
+BASH_FUNC_POSIX_SETJMP
+BASH_FUNC_STRCOLL
+
+dnl If putenv or unsetenv is not present, set the right define so the
+dnl prototype and declaration in lib/sh/getenv.c will be standard-conformant
+
+if test "$ac_cv_func_putenv" = "yes"; then
+BASH_FUNC_STD_PUTENV
+else
+AC_DEFINE(HAVE_STD_PUTENV)
+fi
+if test "$ac_cv_func_unsetenv" = "yes"; then
+BASH_FUNC_STD_UNSETENV
+else
+AC_DEFINE(HAVE_STD_UNSETENV)
+fi
+
+BASH_FUNC_PRINTF_A_FORMAT
+
+dnl presence and behavior of OS functions
+BASH_SYS_REINSTALL_SIGHANDLERS
+BASH_SYS_JOB_CONTROL_MISSING
+BASH_SYS_NAMED_PIPES
+
+dnl presence of certain CPP defines
+AC_HEADER_TIOCGWINSZ
+BASH_HAVE_TIOCSTAT
+BASH_HAVE_FIONREAD
+
+BASH_CHECK_WCONTINUED
+
+dnl miscellaneous
+BASH_CHECK_SPEED_T
+BASH_CHECK_GETPW_FUNCS
+BASH_CHECK_RTSIGS
+BASH_CHECK_SYS_SIGLIST
+
+dnl special checks
+case "$host_os" in
+hpux*) BASH_CHECK_KERNEL_RLIMIT ;;
+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)
+
+BASH_CHECK_DEV_FD
+BASH_CHECK_DEV_STDIN
+BASH_SYS_DEFAULT_MAIL_DIR
+
+if test "$bash_cv_job_control_missing" = missing; then
+       opt_job_control=no
+fi
+
+if test "$opt_job_control" = yes; then
+AC_DEFINE(JOB_CONTROL)
+JOBS_O=jobs.o
+else
+JOBS_O=nojobs.o
+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
+dnl this should really go away someday
+
+case "${host_os}" in
+sysv4.2*)      AC_DEFINE(SVR4_2)
+               AC_DEFINE(SVR4) ;;
+sysv4*)                AC_DEFINE(SVR4) ;;
+sysv5*)                AC_DEFINE(SVR5) ;;
+hpux9*)                LOCAL_CFLAGS="-DHPUX9 -DHPUX" ;;
+hpux*)         LOCAL_CFLAGS=-DHPUX ;;
+dgux*)         LOCAL_CFLAGS=-D_DGUX_SOURCE; LOCAL_LIBS=-ldgc ;;
+isc*)          LOCAL_CFLAGS=-Disc386 ;;
+rhapsody*)     LOCAL_CFLAGS=-DRHAPSODY ;;
+darwin*)       LOCAL_CFLAGS=-DMACOSX ;;
+sco3.2v5*)     LOCAL_CFLAGS="-b elf -DWAITPID_BROKEN -DPATH_MAX=1024" ;;
+sco3.2v4*)     LOCAL_CFLAGS="-DMUST_UNBLOCK_CHLD -DPATH_MAX=1024" ;;
+sco3.2*)       LOCAL_CFLAGS=-DMUST_UNBLOCK_CHLD ;;
+sunos4*)       LOCAL_CFLAGS=-DSunOS4 ;;
+solaris2.5*)   LOCAL_CFLAGS=-DSunOS5 ;;
+lynxos*)       LOCAL_CFLAGS=-DRECYCLES_PIDS ;;
+linux*)                LOCAL_LDFLAGS=-rdynamic          # allow dynamic loading
+               case "`uname -r`" in
+               2.[[456789]]*|3*)       AC_DEFINE(PGRP_PIPE) ;;
+               esac ;;
+*qnx6*)                LOCAL_CFLAGS="-Dqnx -Dqnx6" LOCAL_LIBS="-lncurses" ;;
+*qnx*)         LOCAL_CFLAGS="-Dqnx -F -3s" LOCAL_LDFLAGS="-3s" LOCAL_LIBS="-lunix -lncurses" ;;
+powerux*)      LOCAL_LIBS="-lgen" ;;
+cygwin*)       LOCAL_CFLAGS=-DRECYCLES_PIDS ;;
+opennt*|interix*) LOCAL_CFLAGS="-DNO_MAIN_ENV_ARG -DBROKEN_DIRENT_D_INO -D_POSIX_SOURCE" ;;
+esac
+
+dnl Stanza for OS/compiler pair-specific flags
+case "${host_os}-${CC}" in
+aix4.2*-*gcc*) LOCAL_LDFLAGS="-Xlinker -bexpall -Xlinker -brtl" ;;
+aix4.2*)       LOCAL_LDFLAGS="-bexpall -brtl" ;;
+bsdi4*-*gcc*)  LOCAL_LDFLAGS="-rdynamic" ;;    # allow dynamic loading, like Linux
+esac
+
+dnl FreeBSD-3.x can have either a.out or ELF
+case "${host_os}" in
+freebsd[[3-9]]*)
+               if test -x /usr/bin/objformat && test "`/usr/bin/objformat`" = "elf" ; then
+                       LOCAL_LDFLAGS=-rdynamic # allow dynamic loading
+               fi ;;
+freebsdelf*)   LOCAL_LDFLAGS=-rdynamic ;;      # allow dynamic loading
+dragonfly*)    LOCAL_LDFLAGS=-rdynamic ;;      # allow dynamic loading
+esac
+
+case "$host_cpu" in
+*cray*)                LOCAL_CFLAGS="-DCRAY" ;; # shell var so config.h can use it
+esac
+
+case "$host_cpu-$host_os" in
+ibmrt-*bsd4*)  LOCAL_CFLAGS="-ma -U__STDC__" ;;
+esac
+
+case "$host_cpu-$host_vendor-$host_os" in
+m88k-motorola-sysv3)   LOCAL_CFLAGS=-DWAITPID_BROKEN ;;
+mips-pyramid-sysv4)    LOCAL_CFLAGS=-Xa ;;
+esac
+
+#
+# Shared object configuration section.  These values are generated by
+# ${srcdir}/support/shobj-conf
+#
+if test "$ac_cv_func_dlopen" = "yes" && test -f ${srcdir}/support/shobj-conf
+then
+       AC_MSG_CHECKING(shared object configuration for loadable builtins)
+       eval `${CONFIG_SHELL-/bin/sh} ${srcdir}/support/shobj-conf -C "${CC}" -c "${host_cpu}" -o "${host_os}" -v "${host_vendor}"`
+       AC_SUBST(SHOBJ_CC)
+       AC_SUBST(SHOBJ_CFLAGS)
+       AC_SUBST(SHOBJ_LD)
+       AC_SUBST(SHOBJ_LDFLAGS)
+       AC_SUBST(SHOBJ_XLDFLAGS)
+       AC_SUBST(SHOBJ_LIBS)
+       AC_SUBST(SHOBJ_STATUS)
+       AC_MSG_RESULT($SHOBJ_STATUS)
+fi
+
+# try to create a directory tree if the source is elsewhere
+# this should be packaged into a script accessible via ${srcdir}/support
+case "$srcdir" in
+.)     ;;
+*)     for d in doc tests support lib examples; do     # dirs
+               test -d $d || mkdir $d
+       done
+       for ld in readline glob tilde malloc sh termcap; do     # libdirs
+               test -d lib/$ld || mkdir lib/$ld
+       done
+       test -d examples/loadables || mkdir examples/loadables  # loadable builtins
+       test -d examples/loadables/perl || mkdir examples/loadables/perl
+       ;;
+esac
+
+BUILD_DIR=`pwd`
+case "$BUILD_DIR" in
+*\ *)  BUILD_DIR=`echo "$BUILD_DIR" | sed 's: :\\\\ :g'` ;;
+*)     ;;
+esac
+
+AC_SUBST(PROFILE_FLAGS)
+
+AC_SUBST(incdir)
+AC_SUBST(BUILD_DIR)
+
+AC_SUBST(YACC)
+AC_SUBST(AR)
+AC_SUBST(ARFLAGS)
+
+AC_SUBST(BASHVERS)
+AC_SUBST(RELSTATUS)
+AC_SUBST(DEBUG)
+AC_SUBST(MALLOC_DEBUG)
+
+AC_SUBST(host_cpu)
+AC_SUBST(host_vendor)
+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_OUTPUT([Makefile builtins/Makefile lib/readline/Makefile lib/glob/Makefile \
+         lib/intl/Makefile \
+         lib/malloc/Makefile lib/sh/Makefile lib/termcap/Makefile \
+         lib/tilde/Makefile doc/Makefile support/Makefile po/Makefile.in \
+         examples/loadables/Makefile examples/loadables/perl/Makefile \
+         pathnames.h],
+[
+# Makefile uses this timestamp file to record whether config.h is up to date.
+echo timestamp > stamp-h
+])
diff --git a/configure.in~ b/configure.in~
new file mode 100644 (file)
index 0000000..91df7da
--- /dev/null
@@ -0,0 +1,1110 @@
+dnl
+dnl Configure script for bash-3.2
+dnl
+dnl report bugs to chet@po.cwru.edu
+dnl
+dnl Process this file with autoconf to produce a configure script.
+
+# Copyright (C) 1987-2006 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+AC_REVISION([for Bash 3.2, version 3.192])dnl
+
+define(bashvers, 3.2)
+define(relstatus, maint)
+
+AC_INIT([bash], bashvers-relstatus, [bug-bash@gnu.org])
+
+dnl make sure we are using a recent autoconf version
+AC_PREREQ(2.50)
+
+AC_CONFIG_SRCDIR(shell.h)
+dnl where to find install.sh, config.sub, and config.guess
+AC_CONFIG_AUX_DIR(./support)
+AC_CONFIG_HEADERS(config.h)
+
+dnl checks for version info
+BASHVERS=bashvers
+RELSTATUS=relstatus
+
+dnl defaults for debug settings
+case "$RELSTATUS" in
+alp*|bet*|dev*|rc*|maint*)     DEBUG='-DDEBUG' MALLOC_DEBUG='-DMALLOC_DEBUG' ;;
+*)     DEBUG= MALLOC_DEBUG= ;;
+esac
+
+dnl canonicalize the host and os so we can do some tricky things before
+dnl parsing options
+AC_CANONICAL_HOST
+
+dnl configure defaults
+opt_bash_malloc=yes
+opt_purify=no
+opt_purecov=no
+opt_afs=no
+opt_curses=no
+opt_with_installed_readline=no
+
+#htmldir=
+
+dnl some systems should be configured without the bash malloc by default
+dnl and some need a special compiler or loader
+dnl look in the NOTES file for more
+case "${host_cpu}-${host_os}" in
+alpha*-*)      opt_bash_malloc=no ;;   # alpha running osf/1 or linux
+*[[Cc]]ray*-*) opt_bash_malloc=no ;;   # Crays
+*-osf1*)       opt_bash_malloc=no ;;   # other osf/1 machines
+sparc-svr4*)   opt_bash_malloc=no ;;   # sparc SVR4, SVR4.2
+sparc-netbsd*) opt_bash_malloc=no ;;   # needs 8-byte alignment
+mips-irix6*)   opt_bash_malloc=no ;;   # needs 8-byte alignment
+m68k-sysv)     opt_bash_malloc=no ;;   # fixes file descriptor leak in closedir
+sparc-linux*)  opt_bash_malloc=no ;;   # sparc running linux; requires ELF
+#*-freebsd*-gnu)       opt_bash_malloc=no ;;   # there's some undetermined problem here
+#*-freebsd*)   opt_bash_malloc=no ;;   # they claim it's better; I disagree
+*-openbsd*)    opt_bash_malloc=no ;;   # they claim it needs eight-bit alignment
+*-aix*)                opt_bash_malloc=no ;;   # AIX machines
+*-nextstep*)   opt_bash_malloc=no ;;   # NeXT machines running NeXTstep
+*-macos*)      opt_bash_malloc=no ;;   # Apple MacOS X
+*-rhapsody*)   opt_bash_malloc=no ;;   # Apple Rhapsody (MacOS X)
+*-darwin*)     opt_bash_malloc=no ;;   # Apple Darwin (MacOS X)
+*-dgux*)       opt_bash_malloc=no ;;   # DG/UX machines
+*-qnx*)                opt_bash_malloc=no ;;   # QNX 4.2, QNX 6.x
+*-machten4)    opt_bash_malloc=no ;;   # MachTen 4.x
+*-bsdi2.1|*-bsdi3.?)   opt_bash_malloc=no ; : ${CC:=shlicc2} ;; # for loadable builtins
+*-beos*)       opt_bash_malloc=no ;;   # they say it's suitable
+*-cygwin*)     opt_bash_malloc=no ;;   # Cygnus's CYGWIN environment
+*-opennt*|*-interix*)  opt_bash_malloc=no ;;   # Interix, now owned by Microsoft
+esac
+
+# memory scrambling on free()
+case "${host_os}" in
+sco3.2v5*|sco3.2v4*)   opt_memscramble=no ;;
+*)                     opt_memscramble=yes ;;
+esac
+
+dnl
+dnl macros for the bash debugger
+dnl
+AM_PATH_LISPDIR
+AC_ARG_VAR(DEBUGGER_START_FILE, [location of bash debugger initialization file])
+
+dnl arguments to configure
+dnl packages
+AC_ARG_WITH(afs, AC_HELP_STRING([--with-afs], [if you are running AFS]), opt_afs=$withval)
+AC_ARG_WITH(bash-malloc, AC_HELP_STRING([--with-bash-malloc], [use the Bash version of malloc]), opt_bash_malloc=$withval)
+AC_ARG_WITH(curses, AC_HELP_STRING([--with-curses], [use the curses library instead of the termcap library]), opt_curses=$withval)
+AC_ARG_WITH(gnu-malloc, AC_HELP_STRING([--with-gnu-malloc], [synonym for --with-bash-malloc]), opt_bash_malloc=$withval)
+AC_ARG_WITH(installed-readline, AC_HELP_STRING([--with-installed-readline], [use a version of the readline library that is already installed]), opt_with_installed_readline=$withval)
+AC_ARG_WITH(purecov, AC_HELP_STRING([--with-purecov], [configure to postprocess with pure coverage]), opt_purecov=$withval)
+AC_ARG_WITH(purify, AC_HELP_STRING([--with-purify], [configure to postprocess with purify]), opt_purify=$withval)
+
+if test "$opt_bash_malloc" = yes; then
+       MALLOC_TARGET=malloc
+       MALLOC_SRC=malloc.c
+
+       MALLOC_LIB='-lmalloc'
+       MALLOC_LIBRARY='$(ALLOC_LIBDIR)/libmalloc.a'
+       MALLOC_LDFLAGS='-L$(ALLOC_LIBDIR)'
+       MALLOC_DEP='$(MALLOC_LIBRARY)'
+
+       AC_DEFINE(USING_BASH_MALLOC)
+else
+       MALLOC_LIB=
+       MALLOC_LIBRARY=
+       MALLOC_LDFLAGS=
+       MALLOC_DEP=     
+fi
+
+if test "$opt_purify" = yes; then
+       PURIFY="purify "
+       AC_DEFINE(DISABLE_MALLOC_WRAPPERS)
+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
+
+if test -z "${DEBUGGER_START_FILE}"; then
+       DEBUGGER_START_FILE='${datadir}/bashdb/bashdb-main.inc'
+fi
+
+dnl optional shell features in config.h.in
+opt_minimal_config=no
+
+opt_job_control=yes
+opt_alias=yes
+opt_readline=yes
+opt_history=yes
+opt_bang_history=yes
+opt_dirstack=yes
+opt_restricted=yes
+opt_process_subst=yes
+opt_prompt_decoding=yes
+opt_select=yes
+opt_help=yes
+opt_array_variables=yes
+opt_dparen_arith=yes
+opt_extended_glob=yes
+opt_brace_expansion=yes
+opt_disabled_builtins=no
+opt_command_timing=yes
+opt_xpg_echo=no
+opt_strict_posix=no
+opt_cond_command=yes
+opt_cond_regexp=yes
+opt_arith_for_command=yes
+opt_net_redirs=yes
+opt_progcomp=yes
+opt_separate_help=no
+opt_multibyte=yes
+opt_debugger=yes
+opt_single_longdoc_strings=yes
+
+dnl options that affect how bash is compiled and linked
+opt_static_link=no
+opt_profiling=no
+
+dnl argument parsing for optional features
+AC_ARG_ENABLE(minimal-config, AC_HELP_STRING([--enable-minimal-config], [a minimal sh-like configuration]), opt_minimal_config=$enableval)
+
+dnl a minimal configuration turns everything off, but features can be
+dnl added individually
+if test $opt_minimal_config = yes; then
+       opt_job_control=no opt_alias=no opt_readline=no
+       opt_history=no opt_bang_history=no opt_dirstack=no
+       opt_restricted=no opt_process_subst=no opt_prompt_decoding=no
+       opt_select=no opt_help=no opt_array_variables=no opt_dparen_arith=no
+       opt_brace_expansion=no opt_disabled_builtins=no opt_command_timing=no
+       opt_extended_glob=no opt_cond_command=no opt_arith_for_command=no
+       opt_net_redirs=no opt_progcomp=no opt_separate_help=no
+       opt_multibyte=yes opt_cond_regexp=no
+fi
+
+AC_ARG_ENABLE(alias, AC_HELP_STRING([--enable-alias], [enable shell aliases]), opt_alias=$enableval)
+AC_ARG_ENABLE(arith-for-command, AC_HELP_STRING([--enable-arith-for-command], [enable arithmetic for command]), opt_arith_for_command=$enableval)
+AC_ARG_ENABLE(array-variables, AC_HELP_STRING([--enable-array-variables], [include shell array variables]), opt_array_variables=$enableval)
+AC_ARG_ENABLE(bang-history, AC_HELP_STRING([--enable-bang-history], [turn on csh-style history substitution]), opt_bang_history=$enableval)
+AC_ARG_ENABLE(brace-expansion, AC_HELP_STRING([--enable-brace-expansion], [include brace expansion]), opt_brace_expansion=$enableval)
+AC_ARG_ENABLE(command-timing, AC_HELP_STRING([--enable-command-timing], [enable the time reserved word and command timing]), opt_command_timing=$enableval)
+AC_ARG_ENABLE(cond-command, AC_HELP_STRING([--enable-cond-command], [enable the conditional command]), opt_cond_command=$enableval)
+AC_ARG_ENABLE(cond-regexp, AC_HELP_STRING([--enable-cond-regexp], [enable extgended regular expression matching in conditional commands]), opt_cond_regexp=$enableval)
+AC_ARG_ENABLE(debugger, AC_HELP_STRING([--enable-debugger], [enable support for bash debugger]), opt_debugger=$enableval)
+AC_ARG_ENABLE(directory-stack, AC_HELP_STRING([--enable-directory-stack], [enable builtins pushd/popd/dirs]), opt_dirstack=$enableval)
+AC_ARG_ENABLE(disabled-builtins, AC_HELP_STRING([--enable-disabled-builtins], [allow disabled builtins to still be invoked]), opt_disabled_builtins=$enableval)
+AC_ARG_ENABLE(dparen-arithmetic, AC_HELP_STRING([--enable-dparen-arithmetic], [include ((...)) command]), opt_dparen_arith=$enableval)
+AC_ARG_ENABLE(extended-glob, AC_HELP_STRING([--enable-extended-glob], [include ksh-style extended pattern matching]), opt_extended_glob=$enableval)
+AC_ARG_ENABLE(help-builtin, AC_HELP_STRING([--enable-help-builtin], [include the help builtin]), opt_help=$enableval)
+AC_ARG_ENABLE(history, AC_HELP_STRING([--enable-history], [turn on command history]), opt_history=$enableval)
+AC_ARG_ENABLE(job-control, AC_HELP_STRING([--enable-job-control], [enable job control features]), opt_job_control=$enableval)
+AC_ARG_ENABLE(multibyte, AC_HELP_STRING([--enable-multibyte], [enable multibyte characters if OS supports them]), opt_multibyte=$enableval)
+AC_ARG_ENABLE(net-redirections, AC_HELP_STRING([--enable-net-redirections], [enable /dev/tcp/host/port redirection]), opt_net_redirs=$enableval)
+AC_ARG_ENABLE(process-substitution, AC_HELP_STRING([--enable-process-substitution], [enable process substitution]), opt_process_subst=$enableval)
+AC_ARG_ENABLE(progcomp, AC_HELP_STRING([--enable-progcomp], [enable programmable completion and the complete builtin]), opt_progcomp=$enableval)
+AC_ARG_ENABLE(prompt-string-decoding, AC_HELP_STRING([--enable-prompt-string-decoding], [turn on escape character decoding in prompts]), opt_prompt_decoding=$enableval)
+AC_ARG_ENABLE(readline, AC_HELP_STRING([--enable-readline], [turn on command line editing]), opt_readline=$enableval)
+AC_ARG_ENABLE(restricted, AC_HELP_STRING([--enable-restricted], [enable a restricted shell]), opt_restricted=$enableval)
+AC_ARG_ENABLE(select, AC_HELP_STRING([--enable-select], [include select command]), opt_select=$enableval)
+AC_ARG_ENABLE(separate-helpfiles, AC_HELP_STRING([--enable-separate-helpfiles], [use external files for help builtin documentation]), opt_separate_help=$enableval)
+AC_ARG_ENABLE(single-help-strings, AC_HELP_STRING([--enable-single-help-strings], [store help documentation as a single string to ease translation]), opt_single_longdoc_strings=$enableval)
+AC_ARG_ENABLE(strict-posix-default, AC_HELP_STRING([--enable-strict-posix-default], [configure bash to be posix-conformant by default]), opt_strict_posix=$enableval)
+AC_ARG_ENABLE(usg-echo-default, AC_HELP_STRING([--enable-usg-echo-default], [a synonym for --enable-xpg-echo-default]), opt_xpg_echo=$enableval)
+AC_ARG_ENABLE(xpg-echo-default, AC_HELP_STRING([--enable-xpg-echo-default], [make the echo builtin expand escape sequences by default]), opt_xpg_echo=$enableval)
+
+dnl options that alter how bash is compiled and linked
+AC_ARG_ENABLE(mem-scramble, AC_HELP_STRING([--enable-mem-scramble], [scramble memory on calls to malloc and free]), opt_memscramble=$enableval)
+AC_ARG_ENABLE(profiling, AC_HELP_STRING([--enable-profiling], [allow profiling with gprof]), opt_profiling=$enableval)
+AC_ARG_ENABLE(static-link, AC_HELP_STRING([--enable-static-link], [link bash statically, for use as a root shell]), opt_static_link=$enableval)
+
+dnl opt_job_control is handled later, after BASH_JOB_CONTROL_MISSING runs
+
+dnl opt_readline and opt_history are handled later, because AC_PROG_CC needs
+dnl to be run before we can check the version of an already-installed readline
+dnl library
+
+if test $opt_alias = yes; then
+AC_DEFINE(ALIAS)
+fi
+if test $opt_dirstack = yes; then
+AC_DEFINE(PUSHD_AND_POPD)
+fi
+if test $opt_restricted = yes; then
+AC_DEFINE(RESTRICTED_SHELL)
+fi
+if test $opt_process_subst = yes; then
+AC_DEFINE(PROCESS_SUBSTITUTION)
+fi
+if test $opt_prompt_decoding = yes; then
+AC_DEFINE(PROMPT_STRING_DECODE)
+fi
+if test $opt_select = yes; then
+AC_DEFINE(SELECT_COMMAND)
+fi
+if test $opt_help = yes; then
+AC_DEFINE(HELP_BUILTIN)
+fi
+if test $opt_array_variables = yes; then
+AC_DEFINE(ARRAY_VARS)
+fi
+if test $opt_dparen_arith = yes; then
+AC_DEFINE(DPAREN_ARITHMETIC)
+fi
+if test $opt_brace_expansion = yes; then
+AC_DEFINE(BRACE_EXPANSION)
+fi
+if test $opt_disabled_builtins = yes; then
+AC_DEFINE(DISABLED_BUILTINS)
+fi
+if test $opt_command_timing = yes; then
+AC_DEFINE(COMMAND_TIMING)
+fi
+if test $opt_xpg_echo = yes ; then
+AC_DEFINE(DEFAULT_ECHO_TO_XPG)
+fi
+if test $opt_strict_posix = yes; then
+AC_DEFINE(STRICT_POSIX)
+fi
+if test $opt_extended_glob = yes ; then
+AC_DEFINE(EXTENDED_GLOB)
+fi
+if test $opt_cond_command = yes ; then
+AC_DEFINE(COND_COMMAND)
+fi
+if test $opt_cond_regexp = yes ; then
+AC_DEFINE(COND_REGEXP)
+fi
+if test $opt_arith_for_command = yes; then
+AC_DEFINE(ARITH_FOR_COMMAND)
+fi
+if test $opt_net_redirs = yes; then
+AC_DEFINE(NETWORK_REDIRECTIONS)
+fi
+if test $opt_progcomp = yes; then
+AC_DEFINE(PROGRAMMABLE_COMPLETION)
+fi
+if test $opt_multibyte = no; then
+AC_DEFINE(NO_MULTIBYTE_SUPPORT)
+fi
+if test $opt_debugger = yes; then
+AC_DEFINE(DEBUGGER)
+fi
+
+if test $opt_memscramble = yes; then
+AC_DEFINE(MEMSCRAMBLE)
+fi
+
+if test "$opt_minimal_config" = yes; then
+       TESTSCRIPT=run-minimal
+else
+       TESTSCRIPT=run-all
+fi
+
+HELPDIR= HELPDIRDEFINE= HELPINSTALL=
+if test "$opt_separate_help" != no; then
+       if test "$opt_separate_help" = "yes" ; then
+               HELPDIR='${datadir}/bash'
+       else
+               HELPDIR=$opt_separate_help
+       fi
+       HELPDIRDEFINE='-H ${HELPDIR}'
+       HELPINSTALL='install-help'
+fi
+HELPSTRINGS=
+if test "$opt_single_longdoc_strings" != "yes"; then
+       HELPSTRINGS='-S'
+fi
+
+dnl now substitute in the values generated by arguments
+AC_SUBST(TESTSCRIPT)
+AC_SUBST(PURIFY)
+AC_SUBST(MALLOC_TARGET)
+AC_SUBST(MALLOC_SRC)
+
+AC_SUBST(MALLOC_LIB)
+AC_SUBST(MALLOC_LIBRARY)
+AC_SUBST(MALLOC_LDFLAGS)
+AC_SUBST(MALLOC_DEP)
+
+AC_SUBST(htmldir)
+
+AC_SUBST(HELPDIR)
+AC_SUBST(HELPDIRDEFINE)
+AC_SUBST(HELPINSTALL)
+AC_SUBST(HELPSTRINGS)
+
+echo ""
+echo "Beginning configuration for bash-$BASHVERS-$RELSTATUS for ${host_cpu}-${host_vendor}-${host_os}"
+echo ""
+
+dnl compilation checks
+dnl AC_PROG_CC sets $cross_compiling to `yes' if cross-compiling for a
+dnl different environment
+AC_PROG_CC
+
+dnl test for Unix variants
+AC_ISC_POSIX
+AC_MINIX
+
+AC_SYS_LARGEFILE
+
+dnl BEGIN changes for cross-building (currently cygwin, minGW, and
+dnl (obsolete) BeOS)
+
+SIGNAMES_O=
+SIGNAMES_H=lsignames.h
+
+dnl load up the cross-building cache file -- add more cases and cache
+dnl files as necessary
+
+dnl Note that host and target machine are the same, and different than the
+dnl build machine.
+dnl Set SIGNAMES_H based on whether or not we're cross-compiling.
+
+CROSS_COMPILE=
+if test "x$cross_compiling" = "xyes"; then
+    case "${host}" in
+    *-cygwin*)
+       cross_cache=${srcdir}/cross-build/cygwin32.cache
+       ;;
+    *-mingw*)
+       cross_cache=${srcdir}/cross-build/cygwin32.cache
+       ;;
+    i[[3456]]86-*-beos*)
+       cross_cache=${srcdir}/cross-build/x86-beos.cache
+       ;;
+    *) echo "configure: cross-compiling for $host is not supported" >&2
+       ;;
+    esac
+    if test -n "${cross_cache}" && test -r "${cross_cache}"; then
+       echo "loading cross-build cache file ${cross_cache}"
+       . ${cross_cache}
+    fi
+    unset cross_cache
+    SIGNAMES_O='signames.o'
+    CROSS_COMPILE='-DCROSS_COMPILING'
+    AC_SUBST(CROSS_COMPILE)
+fi
+AC_SUBST(SIGNAMES_H)
+AC_SUBST(SIGNAMES_O)
+
+if test -z "$CC_FOR_BUILD"; then
+    if test "x$cross_compiling" = "xno"; then
+       CC_FOR_BUILD='$(CC)'
+    else
+       CC_FOR_BUILD=gcc
+    fi
+fi
+AC_SUBST(CC_FOR_BUILD)
+
+dnl END changes for cross-building
+
+dnl We want these before the checks, so the checks can modify their values.
+test -z "$CFLAGS" && CFLAGS=-g auto_cflags=1
+
+dnl If we're using gcc and the user hasn't specified CFLAGS, add -O2 to CFLAGS.
+test -n "$GCC" && test -n "$auto_cflags" && CFLAGS="$CFLAGS -O2"
+
+dnl handle options that alter how bash is compiled and linked
+dnl these must come after the test for cc/gcc
+if test "$opt_profiling" = "yes"; then
+       PROFILE_FLAGS=-pg
+       case "$host_os" in
+       solaris2*)      ;;
+       *)              opt_static_link=yes ;;
+       esac
+       DEBUG= MALLOC_DEBUG=
+fi
+
+if test "$opt_static_link" = yes; then
+       # if we're using gcc, add `-static' to LDFLAGS, except on Solaris >= 2
+       if test -n "$GCC" || test "$ac_cv_prog_gcc" = "yes"; then
+               STATIC_LD="-static" 
+               case "$host_os" in
+               solaris2*)      ;;
+               *)              LDFLAGS="$LDFLAGS -static" ;;   # XXX experimental
+               esac
+       fi
+fi
+
+if test "X$cross_compiling" = "Xno"; then
+       CPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-"$CPPFLAGS"}
+       LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-'$(LDFLAGS)'}
+else
+       CPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-""}
+       LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-""}
+fi
+
+test -z "$CFLAGS_FOR_BUILD" && CFLAGS_FOR_BUILD="-g"
+
+AC_SUBST(CFLAGS)
+AC_SUBST(CPPFLAGS)
+AC_SUBST(LDFLAGS)
+AC_SUBST(STATIC_LD)
+
+AC_SUBST(CFLAGS_FOR_BUILD)
+AC_SUBST(CPPFLAGS_FOR_BUILD)
+AC_SUBST(LDFLAGS_FOR_BUILD)
+
+AC_PROG_GCC_TRADITIONAL
+
+dnl BEGIN READLINE and HISTORY LIBRARY SECTION
+dnl prepare to allow bash to be linked against an already-installed readline
+
+dnl first test that the readline version is new enough to link bash against
+if test "$opt_readline" = yes && test "$opt_with_installed_readline" != "no"
+then
+       # If the user specified --with-installed-readline=PREFIX and PREFIX
+       # is not `yes', set ac_cv_rl_prefix to PREFIX
+       test $opt_with_installed_readline != "yes" && ac_cv_rl_prefix=$opt_with_installed_readline
+
+       RL_LIB_READLINE_VERSION
+
+       case "$ac_cv_rl_version" in
+       5*|6*|7*|8*|9*) ;;
+       *)      opt_with_installed_readline=no 
+               AC_MSG_WARN(installed readline library is too old to be linked with bash)
+               AC_MSG_WARN(using private bash version)
+               ;;
+       esac
+fi
+
+TILDE_LIB=-ltilde
+if test $opt_readline = yes; then
+       AC_DEFINE(READLINE)
+       if test "$opt_with_installed_readline" != "no" ; then
+               case "$opt_with_installed_readline" in
+               yes)    RL_INCLUDE= ;;
+               *)      case "$RL_INCLUDEDIR" in
+                       /usr/include)   ;;
+                       *)              RL_INCLUDE='-I${RL_INCLUDEDIR}' ;;
+                       esac
+                       ;;
+               esac
+               READLINE_DEP=
+               READLINE_LIB=-lreadline
+               # section for OS versions that don't allow unresolved symbols
+               # to be compiled into dynamic libraries.
+               case "$host_os" in
+               cygwin*)        TILDE_LIB= ;;
+               esac
+       else
+               RL_LIBDIR='$(dot)/$(LIBSUBDIR)/readline'
+               READLINE_DEP='$(READLINE_LIBRARY)'
+               # section for OS versions that ship an older/broken version of
+               # readline as a standard dynamic library and don't allow a
+               # static version specified as -llibname to override the
+               # dynamic version
+               case "${host_os}" in
+               darwin8*)       READLINE_LIB='${READLINE_LIBRARY}' ;;
+               *)              READLINE_LIB=-lreadline ;;
+               esac
+       fi
+else
+       RL_LIBDIR='$(dot)/$(LIBSUBDIR)/readline'
+       READLINE_LIB= READLINE_DEP=
+fi
+if test $opt_history = yes || test $opt_bang_history = yes; then
+       if test $opt_history = yes; then
+               AC_DEFINE(HISTORY)
+       fi
+       if test $opt_bang_history = yes; then
+               AC_DEFINE(BANG_HISTORY)
+       fi
+       if test "$opt_with_installed_readline" != "no"; then
+               HIST_LIBDIR=$RL_LIBDIR
+               HISTORY_DEP=
+               HISTORY_LIB=-lhistory
+               case "$opt_with_installed_readline" in
+               yes)    RL_INCLUDE= ;;
+               *)      case "$RL_INCLUDEDIR" in
+                       /usr/include)   ;;
+                       *)              RL_INCLUDE='-I${RL_INCLUDEDIR}' ;;
+                       esac
+                       ;;
+               esac
+       else
+               HIST_LIBDIR='$(dot)/$(LIBSUBDIR)/readline'
+               HISTORY_DEP='$(HISTORY_LIBRARY)'
+               # section for OS versions that ship an older version of
+               # readline as a standard dynamic library and don't allow a
+               # static version specified as -llibname to override the
+               # dynamic version
+               case "${host_os}" in
+               darwin8*)       HISTORY_LIB='${HISTORY_LIBRARY}' ;;
+               *)              HISTORY_LIB=-lhistory ;;
+               esac
+       fi
+else
+       HIST_LIBDIR='$(dot)/$(LIBSUBDIR)/readline'
+       HISTORY_LIB= HISTORY_DEP=
+fi
+AC_SUBST(READLINE_LIB)
+AC_SUBST(READLINE_DEP)
+AC_SUBST(RL_LIBDIR)
+AC_SUBST(RL_INCLUDEDIR)
+AC_SUBST(RL_INCLUDE)
+AC_SUBST(HISTORY_LIB)
+AC_SUBST(HISTORY_DEP)
+AC_SUBST(HIST_LIBDIR)
+AC_SUBST(TILDE_LIB)
+
+dnl END READLINE and HISTORY LIBRARY SECTION
+
+dnl programs needed by the build and install process
+AC_PROG_INSTALL
+AC_CHECK_PROG(AR, ar, , ar)
+dnl Set default for ARFLAGS, since autoconf does not have a macro for it.
+dnl This allows people to set it when running configure or make
+test -n "$ARFLAGS" || ARFLAGS="cr"
+AC_PROG_RANLIB
+AC_PROG_YACC
+AC_PROG_MAKE_SET
+
+case "$host_os" in
+opennt*|interix*)      MAKE_SHELL="$INTERIX_ROOT/bin/sh" ;;
+*)                     MAKE_SHELL=/bin/sh ;;
+esac
+AC_SUBST(MAKE_SHELL)
+
+dnl this is similar to the expanded AC_PROG_RANLIB
+if test x$SIZE = x; then
+       if test x$ac_tool_prefix = x; then
+               SIZE=size
+       else
+               SIZE=${ac_tool_prefix}size
+               save_IFS=$IFS ; IFS=:
+               size_found=0
+               for dir in $PATH; do
+                       if test -x $dir/$SIZE ; then
+                               size_found=1
+                               break
+                       fi
+               done
+               if test $size_found -eq 0; then
+                       SIZE=:
+               fi
+               IFS=$save_IFS
+       fi
+fi
+AC_SUBST(SIZE)
+
+dnl Turn on any extensions available in the GNU C library.
+AC_DEFINE(_GNU_SOURCE, 1)
+
+dnl C compiler characteristics
+AC_C_CONST
+AC_C_INLINE
+AC_C_BIGENDIAN
+AC_C_STRINGIZE
+AC_C_LONG_DOUBLE
+AC_C_PROTOTYPES
+AC_C_CHAR_UNSIGNED
+
+dnl initialize GNU gettext
+AM_GNU_GETTEXT([no-libtool], [need-ngettext], [lib/intl])
+
+dnl header files
+AC_HEADER_DIRENT
+AC_HEADER_TIME
+
+BASH_HEADER_INTTYPES
+
+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 dlfcn.h \
+                stddef.h stdint.h netdb.h pwd.h grp.h strings.h regex.h)
+AC_CHECK_HEADERS(sys/pte.h sys/stream.h sys/select.h sys/file.h \
+                sys/resource.h sys/param.h sys/socket.h sys/stat.h \
+                sys/time.h sys/times.h sys/types.h sys/wait.h)
+AC_CHECK_HEADERS(netinet/in.h arpa/inet.h)
+
+dnl sys/ptem.h requires definitions from sys/stream.h on systems where it
+dnl exists
+AC_CHECK_HEADER(sys/ptem.h, , ,[[
+#if HAVE_SYS_STREAM_H
+#  include <sys/stream.h>
+#endif
+]])
+
+dnl special checks for libc functions
+AC_FUNC_ALLOCA
+AC_FUNC_GETPGRP
+AC_FUNC_SETVBUF_REVERSED
+AC_FUNC_VPRINTF
+AC_FUNC_STRCOLL
+
+dnl if we're not using the bash malloc but require the C alloca, set things
+dnl up to build a libmalloc.a containing only alloca.o
+
+if test "$ac_cv_func_alloca_works" = "no" && test "$opt_bash_malloc" = "no"; then
+       MALLOC_TARGET=alloca
+       MALLOC_SRC=alloca.c
+
+       MALLOC_LIB='-lmalloc'
+       MALLOC_LIBRARY='$(ALLOC_LIBDIR)/libmalloc.a'
+       MALLOC_LDFLAGS='-L$(ALLOC_LIBDIR)'
+       MALLOC_DEP='$(MALLOC_LIBRARY)'
+fi
+
+dnl if vprintf is not in libc, see if it's defined in stdio.h
+if test "$ac_cv_func_vprintf" = no; then
+    AC_MSG_CHECKING(for declaration of vprintf in stdio.h)
+    AC_EGREP_HEADER([[int[     ]*vprintf[^a-zA-Z0-9]]],stdio.h,ac_cv_func_vprintf=yes)
+    AC_MSG_RESULT($ac_cv_func_vprintf)
+    if test $ac_cv_func_vprintf = yes; then
+       AC_DEFINE(HAVE_VPRINTF)
+    fi
+fi
+
+if test "$ac_cv_func_vprintf" = no && test "$ac_cv_func__doprnt" = "yes"; then
+  AC_LIBOBJ(vprint)
+fi
+
+dnl signal stuff
+AC_TYPE_SIGNAL
+
+dnl checks for certain version-specific system calls and libc functions
+AC_CHECK_FUNC(__setostype, AC_DEFINE(HAVE_SETOSTYPE))
+AC_CHECK_FUNC(wait3, AC_DEFINE(HAVE_WAIT3))
+AC_CHECK_FUNC(isinf, AC_DEFINE(HAVE_ISINF_IN_LIBC))
+AC_CHECK_FUNC(isnan, AC_DEFINE(HAVE_ISNAN_IN_LIBC))
+
+dnl checks for missing libc functions
+AC_CHECK_FUNC(mkfifo,AC_DEFINE(HAVE_MKFIFO),AC_DEFINE(MKFIFO_MISSING))
+
+dnl checks for system calls
+AC_CHECK_FUNCS(dup2 eaccess fcntl getdtablesize getgroups gethostname \
+               getpagesize getpeername getrlimit getrusage gettimeofday \
+               kill killpg lstat readlink sbrk select setdtablesize \
+               tcgetpgrp uname ulimit waitpid)
+AC_REPLACE_FUNCS(rename)
+
+dnl checks for c library functions
+AC_CHECK_FUNCS(bcopy bzero confstr fnmatch \
+               getaddrinfo gethostbyname getservbyname getservent inet_aton \
+               memmove pathconf putenv raise regcomp regexec \
+               setenv setlinebuf setlocale setvbuf siginterrupt strchr \
+               sysconf tcgetattr times ttyname tzset unsetenv)
+
+AC_CHECK_FUNCS(vsnprintf snprintf vasprintf asprintf)
+AC_CHECK_FUNCS(isascii isblank isgraph isprint isspace isxdigit)
+AC_CHECK_FUNCS(getpwent getpwnam getpwuid)
+AC_REPLACE_FUNCS(getcwd memset strcasecmp strerror strftime strnlen strpbrk strstr)
+AC_REPLACE_FUNCS(strtod strtol strtoul strtoll strtoull strtoimax strtoumax)
+
+AC_CHECK_DECLS([confstr])
+AC_CHECK_DECLS([printf])
+AC_CHECK_DECLS([sbrk])
+AC_CHECK_DECLS([setregid])
+AC_CHECK_DECLS([strcpy])
+AC_CHECK_DECLS([strsignal])
+
+dnl Extra test to detect the horribly broken HP/UX 11.00 strtold(3)
+AC_CHECK_DECLS([strtold], [
+    AC_MSG_CHECKING([for broken strtold])
+    AC_CACHE_VAL(bash_cv_strtold_broken,
+       [AC_TRY_COMPILE(
+           [#include <stdlib.h>],
+           [int main() { long double r; char *foo, bar; r = strtold(foo, &bar);}],
+           bash_cv_strtold_broken=no, bash_cv_strtold_broken=yes,
+           [AC_MSG_WARN(cannot check for broken strtold if cross-compiling, defaulting to no)])
+       ]
+    )
+    AC_MSG_RESULT($bash_cv_strtold_broken)
+    if test "$bash_cv_strtold_broken" = "yes" ; then
+       AC_DEFINE(STRTOLD_BROKEN)
+    fi
+])
+    
+
+BASH_CHECK_DECL(strtoimax)
+BASH_CHECK_DECL(strtol)
+BASH_CHECK_DECL(strtoll)
+BASH_CHECK_DECL(strtoul)
+BASH_CHECK_DECL(strtoull)
+BASH_CHECK_DECL(strtoumax)
+
+AC_FUNC_MKTIME
+
+dnl
+dnl Checks for lib/intl and related code (uses some of the output from
+dnl AM_GNU_GETTEXT)
+dnl
+
+AC_CHECK_HEADERS([argz.h errno.h fcntl.h malloc.h stdio_ext.h])
+
+dnl AC_FUNC_MALLOC
+AC_FUNC_MMAP
+AC_CHECK_FUNCS([__argz_count __argz_next __argz_stringify dcgettext mempcpy \
+               munmap stpcpy strcspn strdup])
+
+INTL_DEP= INTL_INC= LIBINTL_H=
+if test "x$USE_INCLUDED_LIBINTL" = "xyes"; then
+       INTL_DEP='${INTL_LIBDIR}/libintl.a'
+       INTL_INC='-I${INTL_LIBSRC} -I${INTL_BUILDDIR}'
+       LIBINTL_H='${INTL_BUILDDIR}/libintl.h'
+fi
+AC_SUBST(INTL_DEP)
+AC_SUBST(INTL_INC)
+AC_SUBST(LIBINTL_H)
+
+dnl
+dnl End of checks needed by files in lib/intl
+dnl
+
+BASH_CHECK_MULTIBYTE
+
+dnl checks for the dynamic loading library functions in libc and libdl
+if test "$opt_static_link" != yes; then
+AC_CHECK_LIB(dl, dlopen)
+AC_CHECK_FUNCS(dlopen dlclose dlsym)
+fi
+
+dnl this defines SYS_SIGLIST_DECLARED
+AC_DECL_SYS_SIGLIST
+
+dnl network functions -- check for inet_aton again
+if test "$ac_cv_func_inet_aton" != 'yes'; then
+BASH_FUNC_INET_ATON
+fi
+
+dnl libraries
+dnl this is reportedly no longer necessary for irix[56].?
+case "$host_os" in
+irix4*)        AC_CHECK_LIB(sun, getpwent) ;;
+esac
+
+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_LIB_SOCKET
+fi
+dnl check for gethostbyname in socket libraries if it's not in libc
+if test "$ac_cv_func_gethostbyname" = no; then
+       BASH_FUNC_GETHOSTBYNAME
+fi
+
+dnl system types
+AC_TYPE_GETGROUPS
+AC_TYPE_OFF_T
+AC_TYPE_MODE_T
+AC_TYPE_UID_T
+AC_TYPE_PID_T
+AC_TYPE_SIZE_T
+AC_CHECK_TYPE(ssize_t, int)
+AC_CHECK_TYPE(time_t, long)
+
+BASH_TYPE_LONG_LONG
+BASH_TYPE_UNSIGNED_LONG_LONG
+
+AC_TYPE_SIGNAL
+
+AC_CHECK_SIZEOF(char, 1)
+AC_CHECK_SIZEOF(short, 2)
+AC_CHECK_SIZEOF(int, 4)
+AC_CHECK_SIZEOF(long, 4)
+AC_CHECK_SIZEOF(char *, 4)
+AC_CHECK_SIZEOF(double, 8)
+AC_CHECK_SIZEOF([long long], 8)
+
+AC_CHECK_TYPE(u_int, [unsigned int])
+AC_CHECK_TYPE(u_long, [unsigned long])
+
+BASH_TYPE_BITS16_T
+BASH_TYPE_U_BITS16_T
+BASH_TYPE_BITS32_T
+BASH_TYPE_U_BITS32_T
+BASH_TYPE_BITS64_T
+
+BASH_TYPE_PTRDIFF_T
+
+dnl structures
+AC_HEADER_STAT
+
+dnl system services
+AC_SYS_INTERPRETER
+if test $ac_cv_sys_interpreter = yes; then
+AC_DEFINE(HAVE_HASH_BANG_EXEC)
+fi
+
+dnl Miscellaneous Bash tests
+if test "$ac_cv_func_lstat" = "no"; then
+BASH_FUNC_LSTAT
+fi
+
+dnl behavior of system calls and library functions
+BASH_FUNC_CTYPE_NONASCII
+BASH_FUNC_DUP2_CLOEXEC_CHECK
+BASH_SYS_PGRP_SYNC
+BASH_SYS_SIGNAL_VINTAGE
+
+dnl checking for the presence of certain library symbols
+BASH_SYS_ERRLIST
+BASH_SYS_SIGLIST
+BASH_UNDER_SYS_SIGLIST
+
+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_CHECK_TYPE(intmax_t, , $bash_cv_type_long_long)
+BASH_CHECK_TYPE(uintmax_t, , $bash_cv_type_unsigned_long_long)
+if test "$ac_cv_header_sys_socket_h" = "yes"; then
+BASH_CHECK_TYPE(socklen_t, [#include <sys/socket.h>], int, HAVE_SOCKLEN_T)
+fi
+BASH_TYPE_RLIMIT
+
+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_DIRENT_D_NAMLEN
+BASH_STRUCT_WINSIZE
+BASH_STRUCT_TIMEVAL
+AC_CHECK_MEMBERS([struct stat.st_blocks])
+AC_STRUCT_TM
+AC_STRUCT_TIMEZONE
+BASH_STRUCT_TIMEZONE
+
+dnl presence and behavior of C library functions
+BASH_FUNC_STRSIGNAL
+BASH_FUNC_OPENDIR_CHECK
+BASH_FUNC_ULIMIT_MAXFDS
+BASH_FUNC_GETENV
+if test "$ac_cv_func_getcwd" = "yes"; then
+BASH_FUNC_GETCWD
+fi
+BASH_FUNC_POSIX_SETJMP
+BASH_FUNC_STRCOLL
+
+dnl If putenv or unsetenv is not present, set the right define so the
+dnl prototype and declaration in lib/sh/getenv.c will be standard-conformant
+
+if test "$ac_cv_func_putenv" = "yes"; then
+BASH_FUNC_STD_PUTENV
+else
+AC_DEFINE(HAVE_STD_PUTENV)
+fi
+if test "$ac_cv_func_unsetenv" = "yes"; then
+BASH_FUNC_STD_UNSETENV
+else
+AC_DEFINE(HAVE_STD_UNSETENV)
+fi
+
+BASH_FUNC_PRINTF_A_FORMAT
+
+dnl presence and behavior of OS functions
+BASH_SYS_REINSTALL_SIGHANDLERS
+BASH_SYS_JOB_CONTROL_MISSING
+BASH_SYS_NAMED_PIPES
+
+dnl presence of certain CPP defines
+AC_HEADER_TIOCGWINSZ
+BASH_HAVE_TIOCSTAT
+BASH_HAVE_FIONREAD
+
+BASH_CHECK_WCONTINUED
+
+dnl miscellaneous
+BASH_CHECK_SPEED_T
+BASH_CHECK_GETPW_FUNCS
+BASH_CHECK_RTSIGS
+BASH_CHECK_SYS_SIGLIST
+
+dnl special checks
+case "$host_os" in
+hpux*) BASH_CHECK_KERNEL_RLIMIT ;;
+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)
+
+BASH_CHECK_DEV_FD
+BASH_CHECK_DEV_STDIN
+BASH_SYS_DEFAULT_MAIL_DIR
+
+if test "$bash_cv_job_control_missing" = missing; then
+       opt_job_control=no
+fi
+
+if test "$opt_job_control" = yes; then
+AC_DEFINE(JOB_CONTROL)
+JOBS_O=jobs.o
+else
+JOBS_O=nojobs.o
+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
+dnl this should really go away someday
+
+case "${host_os}" in
+sysv4.2*)      AC_DEFINE(SVR4_2)
+               AC_DEFINE(SVR4) ;;
+sysv4*)                AC_DEFINE(SVR4) ;;
+sysv5*)                AC_DEFINE(SVR5) ;;
+hpux9*)                LOCAL_CFLAGS="-DHPUX9 -DHPUX" ;;
+hpux*)         LOCAL_CFLAGS=-DHPUX ;;
+dgux*)         LOCAL_CFLAGS=-D_DGUX_SOURCE; LOCAL_LIBS=-ldgc ;;
+isc*)          LOCAL_CFLAGS=-Disc386 ;;
+rhapsody*)     LOCAL_CFLAGS=-DRHAPSODY ;;
+darwin*)       LOCAL_CFLAGS=-DMACOSX ;;
+sco3.2v5*)     LOCAL_CFLAGS="-b elf -DWAITPID_BROKEN -DPATH_MAX=1024" ;;
+sco3.2v4*)     LOCAL_CFLAGS="-DMUST_UNBLOCK_CHLD -DPATH_MAX=1024" ;;
+sco3.2*)       LOCAL_CFLAGS=-DMUST_UNBLOCK_CHLD ;;
+sunos4*)       LOCAL_CFLAGS=-DSunOS4 ;;
+solaris2.5*)   LOCAL_CFLAGS=-DSunOS5 ;;
+lynxos*)       LOCAL_CFLAGS=-DRECYCLES_PIDS ;;
+linux*)                LOCAL_LDFLAGS=-rdynamic          # allow dynamic loading
+               case "`uname -r`" in
+               2.[[456789]]*|3*)       AC_DEFINE(PGRP_PIPE) ;;
+               esac ;;
+*qnx6*)                LOCAL_CFLAGS="-Dqnx -Dqnx6" LOCAL_LIBS="-lncurses" ;;
+*qnx*)         LOCAL_CFLAGS="-Dqnx -F -3s" LOCAL_LDFLAGS="-3s" LOCAL_LIBS="-lunix -lncurses" ;;
+powerux*)      LOCAL_LIBS="-lgen" ;;
+cygwin*)       LOCAL_CFLAGS=-DRECYCLES_PIDS ;;
+opennt*|interix*) LOCAL_CFLAGS="-DNO_MAIN_ENV_ARG -DBROKEN_DIRENT_D_INO -D_POSIX_SOURCE" ;;
+esac
+
+dnl Stanza for OS/compiler pair-specific flags
+case "${host_os}-${CC}" in
+aix4.2*-*gcc*) LOCAL_LDFLAGS="-Xlinker -bexpall -Xlinker -brtl" ;;
+aix4.2*)       LOCAL_LDFLAGS="-bexpall -brtl" ;;
+bsdi4*-*gcc*)  LOCAL_LDFLAGS="-rdynamic" ;;    # allow dynamic loading, like Linux
+esac
+
+dnl FreeBSD-3.x can have either a.out or ELF
+case "${host_os}" in
+freebsd[[3-9]]*)
+               if test -x /usr/bin/objformat && test "`/usr/bin/objformat`" = "elf" ; then
+                       LOCAL_LDFLAGS=-rdynamic # allow dynamic loading
+               fi ;;
+freebsdelf*)   LOCAL_LDFLAGS=-rdynamic ;;      # allow dynamic loading
+dragonfly*)    LOCAL_LDFLAGS=-rdynamic ;;      # allow dynamic loading
+esac
+
+case "$host_cpu" in
+*cray*)                LOCAL_CFLAGS="-DCRAY" ;; # shell var so config.h can use it
+esac
+
+case "$host_cpu-$host_os" in
+ibmrt-*bsd4*)  LOCAL_CFLAGS="-ma -U__STDC__" ;;
+esac
+
+case "$host_cpu-$host_vendor-$host_os" in
+m88k-motorola-sysv3)   LOCAL_CFLAGS=-DWAITPID_BROKEN ;;
+mips-pyramid-sysv4)    LOCAL_CFLAGS=-Xa ;;
+esac
+
+#
+# Shared object configuration section.  These values are generated by
+# ${srcdir}/support/shobj-conf
+#
+if test "$ac_cv_func_dlopen" = "yes" && test -f ${srcdir}/support/shobj-conf
+then
+       AC_MSG_CHECKING(shared object configuration for loadable builtins)
+       eval `${CONFIG_SHELL-/bin/sh} ${srcdir}/support/shobj-conf -C "${CC}" -c "${host_cpu}" -o "${host_os}" -v "${host_vendor}"`
+       AC_SUBST(SHOBJ_CC)
+       AC_SUBST(SHOBJ_CFLAGS)
+       AC_SUBST(SHOBJ_LD)
+       AC_SUBST(SHOBJ_LDFLAGS)
+       AC_SUBST(SHOBJ_XLDFLAGS)
+       AC_SUBST(SHOBJ_LIBS)
+       AC_SUBST(SHOBJ_STATUS)
+       AC_MSG_RESULT($SHOBJ_STATUS)
+fi
+
+# try to create a directory tree if the source is elsewhere
+# this should be packaged into a script accessible via ${srcdir}/support
+case "$srcdir" in
+.)     ;;
+*)     for d in doc tests support lib examples; do     # dirs
+               test -d $d || mkdir $d
+       done
+       for ld in readline glob tilde malloc sh termcap; do     # libdirs
+               test -d lib/$ld || mkdir lib/$ld
+       done
+       test -d examples/loadables || mkdir examples/loadables  # loadable builtins
+       test -d examples/loadables/perl || mkdir examples/loadables/perl
+       ;;
+esac
+
+BUILD_DIR=`pwd`
+case "$BUILD_DIR" in
+*\ *)  BUILD_DIR=`echo "$BUILD_DIR" | sed 's: :\\\\ :g'` ;;
+*)     ;;
+esac
+
+AC_SUBST(PROFILE_FLAGS)
+
+AC_SUBST(incdir)
+AC_SUBST(BUILD_DIR)
+
+AC_SUBST(YACC)
+AC_SUBST(AR)
+AC_SUBST(ARFLAGS)
+
+AC_SUBST(BASHVERS)
+AC_SUBST(RELSTATUS)
+AC_SUBST(DEBUG)
+AC_SUBST(MALLOC_DEBUG)
+
+AC_SUBST(host_cpu)
+AC_SUBST(host_vendor)
+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_OUTPUT([Makefile builtins/Makefile lib/readline/Makefile lib/glob/Makefile \
+         lib/intl/Makefile \
+         lib/malloc/Makefile lib/sh/Makefile lib/termcap/Makefile \
+         lib/tilde/Makefile doc/Makefile support/Makefile po/Makefile.in \
+         examples/loadables/Makefile examples/loadables/perl/Makefile],
+[
+# Makefile uses this timestamp file to record whether config.h is up to date.
+echo timestamp > stamp-h
+])
index fec088614ebf0540052e30a6fb59581348d9e2fd..9f22755e01965c94593885a820ca5f64a17641ae 100644 (file)
@@ -6,12 +6,12 @@
 .\"    Case Western Reserve University
 .\"    chet@po.cwru.edu
 .\"
-.\"    Last Change: Mon Nov 27 12:02:01 EST 2006
+.\"    Last Change: Tue Dec 26 19:01:54 EST 2006
 .\"
 .\" bash_builtins, strip all but Built-Ins section
 .if \n(zZ=1 .ig zZ
 .if \n(zY=1 .ig zY
-.TH BASH 1 "2006 November 27" "GNU Bash-3.2"
+.TH BASH 1 "2006 December 26" "GNU Bash-3.2"
 .\"
 .\" There's some problem with having a `@'
 .\" in a tagged paragraph with the BSD man macros.
@@ -1245,6 +1245,11 @@ The following variables are set by the shell:
 Expands to the full file name used to invoke this instance of
 .BR bash .
 .TP
+.B BASHPID
+Expands to the process id of the current bash process.
+This differs from \fB$$\fP under certain circumstances, such as subshells
+that do not require bash to be re-initialized.
+.TP
 .B BASH_ARGC
 An array variable whose values are the number of parameters in each
 frame of the current bash execution call stack.
@@ -1346,6 +1351,10 @@ This variable is available only in shell functions invoked by the
 programmable completion facilities (see \fBProgrammable Completion\fP
 below).
 .TP
+.B COMP_KEY
+The key (or final key of a key sequence) used to invoke the current
+completion function.
+.TP
 .B COMP_LINE
 The current command line.
 This variable is available only in shell functions and external
@@ -1363,6 +1372,20 @@ commands invoked by the
 programmable completion facilities (see \fBProgrammable Completion\fP
 below).
 .TP
+.B COMP_TYPE
+Set to an integer value corresponding to the type of completion attempted
+that caused a completion function to be called:
+\fITAB\fP, for normal completion,
+\fI?\fP, for listing completions after successive tabs,
+\fI!\fP, for listing alternatives on partial word completion,
+\fI@\fP, to list completions if the word is not unmodified,
+or
+\fI%\fP, for menu completion.
+This variable is available only in shell functions and external
+commands invoked by the
+programmable completion facilities (see \fBProgrammable Completion\fP
+below).
+.TP
 .B COMP_WORDBREAKS
 The set of characters that the Readline library treats as word
 separators when performing word completion.
@@ -2674,10 +2697,18 @@ is unset, or its
 value is exactly
 .BR <space><tab><newline> ,
 the default, then
+sequences of
+.BR <space> ,
+.BR <tab> ,
+and
+.B <newline>
+at the beginning and end of the results of the previous
+expansions are ignored, and
 any sequence of
 .SM
 .B IFS
-characters serves to delimit words.  If
+characters not at the beginning or end serves to delimit words.
+If
 .SM
 .B IFS
 has a value other than the default, then sequences of
@@ -4178,11 +4209,15 @@ is executed for each child that exits.
 .PP
 If an attempt to exit
 .B bash
-is made while jobs are stopped, the shell prints a warning message.  The
+is made while jobs are stopped (or, if the \fBcheckjobs\fP shell option has
+been enabled using the \fBshopt\fP builtin, running), the shell prints a
+warning message, and, if the \fBcheckjobs\fP option is enabled, lists the
+jobs and their statuses.
+The
 .B jobs
-command may then be used to inspect their status.
+command may then be used to inspect their status. 
 If a second attempt to exit is made without an intervening command,
-the shell does not print another warning, and the stopped
+the shell does not print another warning, and any stopped
 jobs are terminated.
 .SH PROMPTING
 When executing interactively, 
@@ -5459,10 +5494,14 @@ After these matches have been generated, any shell function or command
 specified with the \fB\-F\fP and \fB\-C\fP options is invoked.
 When the command or function is invoked, the
 .SM
-.B COMP_LINE
+.BR COMP_LINE ,
+.SM
+.BR COMP_POINT ,
+.SM
+.BR COMP_KEY ,
 and
 .SM
-.B COMP_POINT
+.B COMP_TYPE
 variables are assigned values as described above under
 \fBShell Variables\fP.
 If a shell function is being invoked, the 
@@ -7554,6 +7593,10 @@ Any command associated with the \fBRETURN\fP trap is executed
 before execution resumes after the function or script.
 .TP
 \fBset\fP [\fB\-\-abefhkmnptuvxBCEHPT\fP] [\fB\-o\fP \fIoption\fP] [\fIarg\fP ...]
+.PD 0
+.TP
+\fBset\fP [\fB+abefhkmnptuvxBCEHPT\fP] [\fB+o\fP \fIoption\fP] [\fIarg\fP ...]
+.PD
 Without options, the name and value of each shell variable are displayed
 in a format that can be reused as input
 for setting or resetting the currently-set variables.
@@ -7955,6 +7998,11 @@ The list of \fBshopt\fP options is:
 .if n .sp 1v
 .PD 0
 .TP 8
+.B autocd
+If set, a command name that is the name of a directory is executed as if
+it were the argument to the \fBcd\fP command.
+This option is only used by interactive shells.
+.TP 8
 .B cdable_vars
 If set, an argument to the
 .B cd
@@ -7977,6 +8025,13 @@ If set, \fBbash\fP checks that a command found in the hash
 table exists before trying to execute it.  If a hashed command no
 longer exists, a normal path search is performed.
 .TP 8
+.B checkjobs
+If set, bash lists the status of any stopped and running jobs before
+exiting an interactive shell.  If any jobs are running, this causes
+the exit to be deferred until a second exit is attempted without an
+intervening command (see \fBJOB CONTROL\fP above).  The shell always
+postpones exiting if any jobs are stopped.
+.TP 8
 .B checkwinsize
 If set, \fBbash\fP checks the window size after each command
 and, if necessary, updates the values of
index fe45d2e347e5f894e3b7224a87cdac9b286a45ea..37998900a95037ce7a779c3c7ecdfa44cf68d428 100644 (file)
@@ -6,12 +6,12 @@
 .\"    Case Western Reserve University
 .\"    chet@po.cwru.edu
 .\"
-.\"    Last Change: Mon Nov 27 12:02:01 EST 2006
+.\"    Last Change: Tue Dec 26 19:01:54 EST 2006
 .\"
 .\" bash_builtins, strip all but Built-Ins section
 .if \n(zZ=1 .ig zZ
 .if \n(zY=1 .ig zY
-.TH BASH 1 "2006 November 27" "GNU Bash-3.2"
+.TH BASH 1 "2006 December 26" "GNU Bash-3.2"
 .\"
 .\" There's some problem with having a `@'
 .\" in a tagged paragraph with the BSD man macros.
@@ -1245,6 +1245,11 @@ The following variables are set by the shell:
 Expands to the full file name used to invoke this instance of
 .BR bash .
 .TP
+.B BASHPID
+Expands to the process id of the current bash process.
+This differs from \fB$$\fP under certain circumstances, such as subshells
+that do not require bash to be re-initialized.
+.TP
 .B BASH_ARGC
 An array variable whose values are the number of parameters in each
 frame of the current bash execution call stack.
@@ -1363,6 +1368,20 @@ commands invoked by the
 programmable completion facilities (see \fBProgrammable Completion\fP
 below).
 .TP
+.B COMP_TYPE
+Set to an integer value corresponding to the type of completion attempted
+that caused a completion function to be called:
+\fITAB\fP, for normal completion,
+\fI?\fP, for listing completions after successive tabs,
+\fI!\fP, for listing alternatives on partial word completion,
+\fI@\fP, to list completions if the word is not unmodified,
+or
+\fI%\fP, for menu completion.
+This variable is available only in shell functions and external
+commands invoked by the
+programmable completion facilities (see \fBProgrammable Completion\fP
+below).
+.TP
 .B COMP_WORDBREAKS
 The set of characters that the Readline library treats as word
 separators when performing word completion.
@@ -2674,10 +2693,18 @@ is unset, or its
 value is exactly
 .BR <space><tab><newline> ,
 the default, then
+sequences of
+.BR <space> ,
+.BR <tab> ,
+and
+.B <newline>
+at the beginning and end of the results of the previous
+expansions are ignored, and
 any sequence of
 .SM
 .B IFS
-characters serves to delimit words.  If
+characters not at the beginning or end serves to delimit words.
+If
 .SM
 .B IFS
 has a value other than the default, then sequences of
@@ -4178,11 +4205,15 @@ is executed for each child that exits.
 .PP
 If an attempt to exit
 .B bash
-is made while jobs are stopped, the shell prints a warning message.  The
+is made while jobs are stopped (or, if the \fBcheckjobs\fP shell option has
+been enabled using the \fBshopt\fP builtin, running), the shell prints a
+warning message, and, if the \fBcheckjobs\fP option is enabled, lists the
+jobs and their statuses.
+The
 .B jobs
-command may then be used to inspect their status.
+command may then be used to inspect their status. 
 If a second attempt to exit is made without an intervening command,
-the shell does not print another warning, and the stopped
+the shell does not print another warning, and any stopped
 jobs are terminated.
 .SH PROMPTING
 When executing interactively, 
@@ -5459,10 +5490,11 @@ After these matches have been generated, any shell function or command
 specified with the \fB\-F\fP and \fB\-C\fP options is invoked.
 When the command or function is invoked, the
 .SM
-.B COMP_LINE
-and
+.BR COMP_LINE ,
 .SM
-.B COMP_POINT
+.BR COMP_POINT ,
+and
+.B COMP_TYPE
 variables are assigned values as described above under
 \fBShell Variables\fP.
 If a shell function is being invoked, the 
@@ -7417,7 +7449,7 @@ The return status is 0 unless an error occurs while
 reading the name of the current directory or an
 invalid option is supplied.
 .TP
-\fBread\fP [\fB\-ers\fP] [\fB\-u\fP \fIfd\fP] [\fB\-t\fP \fItimeout\fP] [\fB\-a\fP \fIaname\fP] [\fB\-p\fP \fIprompt\fP] [\fB\-n\fP \fInchars\fP] [\fB\-d\fP \fIdelim\fP] [\fIname\fP ...]
+\fBread\fP [\fB\-ers\fP] [\fB\-a\fP \fIaname\fP] [\fB\-d\fP \fIdelim\fP] [\fB\-n\fP \fInchars\fP] [\fB\-p\fP \fIprompt\fP] [\fB\-t\fP \fItimeout\fP] [\fB\-u\fP \fIfd\fP] [\fIname\fP ...]
 One line is read from the standard input, or from the file descriptor
 \fIfd\fP supplied as an argument to the \fB\-u\fP option, and the first word
 is assigned to the first
@@ -7554,6 +7586,10 @@ Any command associated with the \fBRETURN\fP trap is executed
 before execution resumes after the function or script.
 .TP
 \fBset\fP [\fB\-\-abefhkmnptuvxBCEHPT\fP] [\fB\-o\fP \fIoption\fP] [\fIarg\fP ...]
+.PD 0
+.TP
+\fBset\fP [\fB+abefhkmnptuvxBCEHPT\fP] [\fB+o\fP \fIoption\fP] [\fIarg\fP ...]
+.PD
 Without options, the name and value of each shell variable are displayed
 in a format that can be reused as input
 for setting or resetting the currently-set variables.
@@ -7955,6 +7991,11 @@ The list of \fBshopt\fP options is:
 .if n .sp 1v
 .PD 0
 .TP 8
+.B autocd
+If set, a command name that is the name of a directory is executed as if
+it were the argument to the \fBcd\fP command.
+This option is only used by interactive shells.
+.TP 8
 .B cdable_vars
 If set, an argument to the
 .B cd
@@ -7977,6 +8018,13 @@ If set, \fBbash\fP checks that a command found in the hash
 table exists before trying to execute it.  If a hashed command no
 longer exists, a normal path search is performed.
 .TP 8
+.B checkjobs
+If set, bash lists the status of any stopped and running jobs before
+exiting an interactive shell.  If any jobs are running, this causes
+the exit to be deferred until a second exit is attempted without an
+intervening command (see \fBJOB CONTROL\fP above).  The shell always
+postpones exiting if any jobs are stopped.
+.TP 8
 .B checkwinsize
 If set, \fBbash\fP checks the window size after each command
 and, if necessary, updates the values of
index 3c4f397d74439ae4ab08e20f6d42e46b1ae811b4..093c94d96e22bd09bb0db8aede362c74e6dd3f89 100644 (file)
@@ -562,7 +562,7 @@ fashion:
 
 In a non-interactive shell, or an interactive shell in which the
 @code{interactive_comments} option to the @code{shopt}
-builtin is enabled (@pxref{Bash Builtins}),
+builtin is enabled (@pxref{The Shopt Builtin}),
 a word beginning with @samp{#}
 causes that word and all remaining characters on that line to
 be ignored.  An interactive shell without the @code{interactive_comments}
@@ -848,7 +848,7 @@ The syntax of the @code{case} command is:
 @code{case} will selectively execute the @var{command-list} corresponding to
 the first @var{pattern} that matches @var{word}.
 If the shell option @code{nocasematch}
-(see the description of @code{shopt} in @ref{Bash Builtins})
+(see the description of @code{shopt} in @ref{The Shopt Builtin})
 is enabled, the match is performed without regard to the case
 of alphabetic characters.
 The @samp{|} is used to separate multiple patterns, and the @samp{)}
@@ -960,7 +960,7 @@ When the @samp{==} and @samp{!=} operators are used, the string to the
 right of the operator is considered a pattern and matched according
 to the rules described below in @ref{Pattern Matching}.
 If the shell option @code{nocasematch}
-(see the description of @code{shopt} in @ref{Bash Builtins})
+(see the description of @code{shopt} in @ref{The Shopt Builtin})
 is enabled, the match is performed without regard to the case
 of alphabetic characters.
 The return value is 0 if the string matches (@samp{==}) or does not
@@ -977,7 +977,7 @@ the pattern, and 1 otherwise.
 If the regular expression is syntactically incorrect, the conditional
 expression's return value is 2.
 If the shell option @code{nocasematch}
-(see the description of @code{shopt} in @ref{Bash Builtins})
+(see the description of @code{shopt} in @ref{The Shopt Builtin})
 is enabled, the match is performed without regard to the case
 of alphabetic characters.
 Substrings matched by parenthesized subexpressions within the regular
@@ -1785,13 +1785,15 @@ The shell scans the results of parameter expansion, command substitution,
 and arithmetic expansion that did not occur within double quotes for
 word splitting.
 
-The shell treats each character of @env{$IFS}
-as a delimiter, and splits the results of the other
-expansions into words on these characters.  If
-@env{IFS} is unset, or its value is exactly @code{<space><tab><newline>},
-the default, then any sequence of @env{IFS}
-characters serves to delimit words.  If @env{IFS}
-has a value other than the default, then sequences of
+The shell treats each character of @env{$IFS} as a delimiter, and splits
+the results of the other expansions into words on these characters.
+If @env{IFS} is unset, or its value is exactly @code{<space><tab><newline>},
+the default, then sequences of
+@code{ <space>}, @code{<tab>}, and @code{<newline>}
+at the beginning and end of the results of the previous
+expansions are ignored, and any sequence of @env{IFS}
+characters not at the beginning or end serves to delimit words.
+If @env{IFS} has a value other than the default, then sequences of
 the whitespace characters @code{space} and @code{tab}
 are ignored at the beginning and end of the
 word, as long as the whitespace character is in the
@@ -1844,7 +1846,7 @@ When matching a file name, the slash character must always be
 matched explicitly.
 In other cases, the @samp{.} character is not treated specially.
 
-See the description of @code{shopt} in @ref{Bash Builtins},
+See the description of @code{shopt} in @ref{The Shopt Builtin},
 for a description of the @code{nocaseglob}, @code{nullglob},
 @code{failglob}, and @code{dotglob} options.
 
@@ -2355,7 +2357,7 @@ options enabled at invocation (either by default or with command-line
 arguments) or by @code{set}
 
 @item
-options enabled by @code{shopt}
+options enabled by @code{shopt} (@pxref{The Shopt Builtin})
 
 @item
 shell aliases defined with @code{alias} (@pxref{Aliases})
@@ -2512,7 +2514,7 @@ builtin (@pxref{Job Control Builtins}) or marked
 to not receive @code{SIGHUP} using @code{disown -h}.
 
 If the  @code{huponexit} shell option has been set with @code{shopt}
-(@pxref{Bash Builtins}), Bash sends a @code{SIGHUP} to all jobs when
+(@pxref{The Shopt Builtin}), Bash sends a @code{SIGHUP} to all jobs when
 an interactive login shell exits.
 
 If Bash is waiting for a command to complete and receives a signal
@@ -2592,8 +2594,8 @@ under another shell.
 * Bourne Shell Builtins::      Builtin commands inherited from the Bourne
                                Shell.
 * Bash Builtins::              Table of builtins specific to Bash.
-* The Set Builtin::            Change the values of shell attributes and
-                               positional parameters.
+* Modifying Shell Behavior::   Builtins to modify shell attributes and
+                               optional behavior.
 * Special Builtins::           Builtin commands classified specially by
                                POSIX.
 @end menu
@@ -2896,8 +2898,9 @@ shift [@var{n}]
 @end example
 Shift the positional parameters to the left by @var{n}.
 The positional parameters from @var{n}+1 @dots{} @code{$#} are
-renamed to @code{$1} @dots{} @code{$#}-@var{n}+1.
-Parameters represented by the numbers @code{$#} to @var{n}+1 are unset.
+renamed to @code{$1} @dots{} @code{$#}-@var{n}.
+Parameters represented by the numbers @code{$#} to @code{$#}-@var{n}+1
+are unset.
 @var{n} must be a non-negative number less than or equal to @code{$#}.
 If @var{n} is zero or greater than @code{$#}, the positional parameters
 are not changed.
@@ -3018,7 +3021,7 @@ before every simple command, @code{for} command, @code{case} command,
 @code{select} command, every arithmetic @code{for} command, and before
 the first command executes in a shell function.
 Refer to the description of the @code{extglob} option to the
-@code{shopt} builtin (@pxref{Bash Builtins}) for details of its
+@code{shopt} builtin (@pxref{The Shopt Builtin}) for details of its
 effect on the @code{DEBUG} trap.
 If a @var{sigspec} is @code{ERR}, the command @var{arg} 
 is executed whenever a simple command has a non-zero exit status,
@@ -3254,7 +3257,7 @@ When @option{-p} is used, additional options are ignored.
 The @option{-F} option inhibits the display of function definitions;
 only the function name and attributes are printed.
 If the @code{extdebug} shell option is enabled using @code{shopt}
-(@pxref{Bash Builtins}), the source file name and line number where
+(@pxref{The Shopt Builtin}), the source file name and line number where
 the function is defined are displayed as well.
 @option{-F} implies @option{-f}.
 The following options can be used to restrict output to variables with
@@ -3528,421 +3531,177 @@ Read input from file descriptor @var{fd}.
 
 @end table
 
-@item shopt
-@btindex shopt
+@item source
+@btindex source
 @example
-shopt [-pqsu] [-o] [@var{optname} @dots{}]
+source @var{filename}
 @end example
-Toggle the values of variables controlling optional shell behavior.
-With no options, or with the @option{-p} option, a list of all settable
-options is displayed, with an indication of whether or not each is set.
-The @option{-p} option causes output to be displayed in a form that
-may be reused as input.
-Other options have the following meanings:
+A synonym for @code{.} (@pxref{Bourne Shell Builtins}).
 
-@table @code
-@item -s
-Enable (set) each @var{optname}.
+@item type
+@btindex type
+@example
+type [-afptP] [@var{name} @dots{}]
+@end example
+For each @var{name}, indicate how it would be interpreted if used as a
+command name.
 
-@item -u
-Disable (unset) each @var{optname}.
+If the @option{-t} option is used, @code{type} prints a single word
+which is one of @samp{alias}, @samp{function}, @samp{builtin},
+@samp{file} or @samp{keyword},
+if @var{name} is an alias, shell function, shell builtin,
+disk file, or shell reserved word, respectively.
+If the @var{name} is not found, then nothing is printed, and
+@code{type} returns a failure status.
 
-@item -q
-Suppresses normal output; the return status
-indicates whether the @var{optname} is set or unset.
-If multiple @var{optname} arguments are given with @option{-q},
-the return status is zero if all @var{optnames} are enabled;
-non-zero otherwise.
+If the @option{-p} option is used, @code{type} either returns the name
+of the disk file that would be executed, or nothing if @option{-t}
+would not return @samp{file}.
 
-@item -o
-Restricts the values of
-@var{optname} to be those defined for the @option{-o} option to the
-@code{set} builtin (@pxref{The Set Builtin}).
-@end table
+The @option{-P} option forces a path search for each @var{name}, even if
+@option{-t} would not return @samp{file}.
 
-If either @option{-s} or @option{-u}
-is used with no @var{optname} arguments, the display is limited to
-those options which are set or unset, respectively.
+If a command is hashed, @option{-p} and @option{-P} print the hashed value,
+not necessarily the file that appears first in @code{$PATH}.
 
-Unless otherwise noted, the @code{shopt} options are disabled (off)
-by default.
+If the @option{-a} option is used, @code{type} returns all of the places
+that contain an executable named @var{file}.
+This includes aliases and functions, if and only if the @option{-p} option
+is not also used.
 
-The return status when listing options is zero if all @var{optnames}
-are enabled, non-zero otherwise.  When setting or unsetting options,
-the return status is zero unless an @var{optname} is not a valid shell
-option.
+If the @option{-f} option is used, @code{type} does not attempt to find
+shell functions, as with the @code{command} builtin.
 
-The list of @code{shopt} options is:
+The return status is zero if any of the @var{names} are found, non-zero
+if none are found.
+
+@item typeset
+@btindex typeset
+@example
+typeset [-afFrxi] [-p] [@var{name}[=@var{value}] @dots{}]
+@end example
+The @code{typeset} command is supplied for compatibility with the Korn
+shell; however, it has been deprecated in favor of the @code{declare}
+builtin command.
+
+@item ulimit
+@btindex ulimit
+@example
+ulimit [-acdefilmnpqrstuvxSH] [@var{limit}]
+@end example
+@code{ulimit} provides control over the resources available to processes
+started by the shell, on systems that allow such control.  If an
+option is given, it is interpreted as follows:
 @table @code
-@item cdable_vars
-If this is set, an argument to the @code{cd}
-builtin command that
-is not a directory is assumed to be the name of a variable whose
-value is the directory to change to.
+@item -S
+Change and report the soft limit associated with a resource.
 
-@item cdspell
-If set, minor errors in the spelling of a directory component in a
-@code{cd} command will be corrected.
-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 only used by interactive shells.
+@item -H
+Change and report the hard limit associated with a resource.
 
-@item checkhash
-If this is set, Bash checks that a command found in the hash
-table exists before trying to execute it.  If a hashed command no
-longer exists, a normal path search is performed.
+@item -a
+All current limits are reported.
 
-@item checkwinsize
-If set, Bash checks the window size after each command
-and, if necessary, updates the values of    
-@env{LINES} and @env{COLUMNS}.
+@item -c
+The maximum size of core files created.
 
-@item cmdhist
-If set, Bash
-attempts to save all lines of a multiple-line
-command in the same history entry.  This allows
-easy re-editing of multi-line commands.
+@item -d
+The maximum size of a process's data segment.
 
-@item dotglob
-If set, Bash includes filenames beginning with a `.' in
-the results of filename expansion.
+@item -e
+The maximum scheduling priority ("nice").
 
-@item execfail
-If this is set, a non-interactive shell will not exit if
-it cannot execute the file specified as an argument to the @code{exec}
-builtin command.  An interactive shell does not exit if @code{exec}
-fails.
+@item -f
+The maximum size of files written by the shell and its children.
 
-@item expand_aliases
-If set, aliases are expanded as described below under Aliases,
-@ref{Aliases}.
-This option is enabled by default for interactive shells.
+@item -i
+The maximum number of pending signals.
 
-@item extdebug
-If set, behavior intended for use by debuggers is enabled:
+@item -l
+The maximum size that may be locked into memory.
 
-@enumerate
-@item
-The @option{-F} option to the @code{declare} builtin (@pxref{Bash Builtins})
-displays the source file name and line number corresponding to each function
-name supplied as an argument.
+@item -m
+The maximum resident set size.
 
-@item
-If the command run by the @code{DEBUG} trap returns a non-zero value, the
-next command is skipped and not executed.
+@item -n
+The maximum number of open file descriptors.
 
-@item
-If the command run by the @code{DEBUG} trap returns a value of 2, and the
-shell is executing in a subroutine (a shell function or a shell script
-executed by the @code{.} or @code{source} builtins), a call to
-@code{return} is simulated.
+@item -p
+The pipe buffer size.
 
-@item
-@code{BASH_ARGC} and @code{BASH_ARGV} are updated as described in their
-descriptions (@pxref{Bash Variables}).
+@item -q
+The maximum number of bytes in POSIX message queues.
 
-@item
-Function tracing is enabled:  command substitution, shell functions, and
-subshells invoked with @code{( @var{command} )} inherit the
-@code{DEBUG} and @code{RETURN} traps.
+@item -r
+The maximum real-time scheduling priority.
 
-@item
-Error tracing is enabled:  command substitution, shell functions, and
-subshells invoked with @code{( @var{command} )} inherit the
-@code{ERROR} trap.
-@end enumerate
+@item -s
+The maximum stack size.
 
-@item extglob
-If set, the extended pattern matching features described above
-(@pxref{Pattern Matching}) are enabled.
+@item -t
+The maximum amount of cpu time in seconds.
 
-@item extquote
-If set, @code{$'@var{string}'} and @code{$"@var{string}"} quoting is  
-performed within @code{$@{@var{parameter}@}} expansions                     
-enclosed in double quotes.  This option is enabled by default. 
+@item -u
+The maximum number of processes available to a single user.
 
-@item failglob
-If set, patterns which fail to match filenames during pathname expansion
-result in an expansion error.
+@item -v
+The maximum amount of virtual memory available to the process.
 
-@item force_fignore
-If set, the suffixes specified by the @env{FIGNORE} shell variable
-cause words to be ignored when performing word completion even if
-the ignored words are the only possible completions.
-@xref{Bash Variables}, for a description of @env{FIGNORE}.
-This option is enabled by default.
+@item -x
+The maximum number of file locks.
 
-@item gnu_errfmt
-If set, shell error messages are written in the standard @sc{gnu} error
-message format.
+@end table
 
-@item histappend
-If set, the history list is appended to the file named by the value
-of the @env{HISTFILE}
-variable when the shell exits, rather than overwriting the file.
+If @var{limit} is given, it is the new value of the specified resource;
+the special @var{limit} values @code{hard}, @code{soft}, and
+@code{unlimited} stand for the current hard limit, the current soft limit,
+and no limit, respectively.
+Otherwise, the current value of the soft limit for the specified resource
+is printed, unless the @option{-H} option is supplied.
+When setting new limits, if neither @option{-H} nor @option{-S} is supplied,
+both the hard and soft limits are set.
+If no option is given, then @option{-f} is assumed.  Values are in 1024-byte
+increments, except for @option{-t}, which is in seconds, @option{-p},
+which is in units of 512-byte blocks, and @option{-n} and @option{-u}, which
+are unscaled values.
 
-@item histreedit
-If set, and Readline
-is being used, a user is given the opportunity to re-edit a
-failed history substitution.
+The return status is zero unless an invalid option or argument is supplied,
+or an error occurs while setting a new limit.
 
-@item histverify
-If set, and Readline
-is being used, the results of history substitution are not immediately
-passed to the shell parser.  Instead, the resulting line is loaded into
-the Readline editing buffer, allowing further modification.
+@item unalias
+@btindex unalias
+@example
+unalias [-a] [@var{name} @dots{} ]
+@end example
 
-@item hostcomplete
-If set, and Readline is being used, Bash will attempt to perform
-hostname completion when a word containing a @samp{@@} is being
-completed (@pxref{Commands For Completion}).  This option is enabled
-by default.
+Remove each @var{name} from the list of aliases.  If @option{-a} is
+supplied, all aliases are removed.
+Aliases are described in @ref{Aliases}.
 
-@item huponexit
-If set, Bash will send @code{SIGHUP} to all jobs when an interactive
-login shell exits (@pxref{Signals}).
+@end table
 
-@item interactive_comments
-Allow a word beginning with @samp{#}
-to cause that word and all remaining characters on that
-line to be ignored in an interactive shell.
-This option is enabled by default.
-
-@item lithist
-If enabled, and the @code{cmdhist}
-option is enabled, multi-line commands are saved to the history with
-embedded newlines rather than using semicolon separators where possible.
-
-@item login_shell
-The shell sets this option if it is started as a login shell
-(@pxref{Invoking Bash}).
-The value may not be changed.
-
-@item mailwarn
-If set, and a file that Bash is checking for mail has been  
-accessed since the last time it was checked, the message
-@code{"The mail in @var{mailfile} has been read"} is displayed.
-
-@item no_empty_cmd_completion
-If set, and Readline is being used, Bash will not attempt to search
-the @env{PATH} for possible completions when completion is attempted
-on an empty line.
-
-@item nocaseglob
-If set, Bash matches filenames in a case-insensitive fashion when
-performing filename expansion.
-
-@item nocasematch
-If set, Bash matches patterns in a case-insensitive fashion when
-performing matching while executing @code{case} or @code{[[}
-conditional commands.
-
-@item nullglob
-If set, Bash allows filename patterns which match no
-files to expand to a null string, rather than themselves.
-
-@item progcomp
-If set, the programmable completion facilities
-(@pxref{Programmable Completion}) are enabled.
-This option is enabled by default.
-
-@item promptvars
-If set, prompt strings undergo
-parameter expansion, command substitution, arithmetic
-expansion, and quote removal after being expanded
-as described below (@pxref{Printing a Prompt}).
-This option is enabled by default.
-
-@item restricted_shell
-The shell sets this option if it is started in restricted mode
-(@pxref{The Restricted Shell}).
-The value may not be changed.
-This is not reset when the startup files are executed, allowing
-the startup files to discover whether or not a shell is restricted.
-
-@item shift_verbose
-If this is set, the @code{shift}
-builtin prints an error message when the shift count exceeds the
-number of positional parameters.
-
-@item sourcepath
-If set, the @code{source} builtin uses the value of @env{PATH}
-to find the directory containing the file supplied as an argument.
-This option is enabled by default.
-
-@item xpg_echo
-If set, the @code{echo} builtin expands backslash-escape sequences
-by default.
-
-@end table
-
-@noindent
-The return status when listing options is zero if all @var{optnames}
-are enabled, non-zero otherwise.
-When setting or unsetting options, the return status is zero unless an
-@var{optname} is not a valid shell option.
-
-@item source
-@btindex source
-@example
-source @var{filename}
-@end example
-A synonym for @code{.} (@pxref{Bourne Shell Builtins}).
-
-@item type
-@btindex type
-@example
-type [-afptP] [@var{name} @dots{}]
-@end example
-For each @var{name}, indicate how it would be interpreted if used as a
-command name.
-
-If the @option{-t} option is used, @code{type} prints a single word
-which is one of @samp{alias}, @samp{function}, @samp{builtin},
-@samp{file} or @samp{keyword},
-if @var{name} is an alias, shell function, shell builtin,
-disk file, or shell reserved word, respectively.
-If the @var{name} is not found, then nothing is printed, and
-@code{type} returns a failure status.
-
-If the @option{-p} option is used, @code{type} either returns the name
-of the disk file that would be executed, or nothing if @option{-t}
-would not return @samp{file}.
-
-The @option{-P} option forces a path search for each @var{name}, even if
-@option{-t} would not return @samp{file}.
-
-If a command is hashed, @option{-p} and @option{-P} print the hashed value,
-not necessarily the file that appears first in @code{$PATH}.
-
-If the @option{-a} option is used, @code{type} returns all of the places
-that contain an executable named @var{file}.
-This includes aliases and functions, if and only if the @option{-p} option
-is not also used.
-
-If the @option{-f} option is used, @code{type} does not attempt to find
-shell functions, as with the @code{command} builtin.
-
-The return status is zero if any of the @var{names} are found, non-zero
-if none are found.
-
-@item typeset
-@btindex typeset
-@example
-typeset [-afFrxi] [-p] [@var{name}[=@var{value}] @dots{}]
-@end example
-The @code{typeset} command is supplied for compatibility with the Korn
-shell; however, it has been deprecated in favor of the @code{declare}
-builtin command.
-
-@item ulimit
-@btindex ulimit
-@example
-ulimit [-acdefilmnpqrstuvxSH] [@var{limit}]
-@end example
-@code{ulimit} provides control over the resources available to processes
-started by the shell, on systems that allow such control.  If an
-option is given, it is interpreted as follows:
-@table @code
-@item -S
-Change and report the soft limit associated with a resource.
-
-@item -H
-Change and report the hard limit associated with a resource.
-
-@item -a
-All current limits are reported.
-
-@item -c
-The maximum size of core files created.
-
-@item -d
-The maximum size of a process's data segment.
-
-@item -e
-The maximum scheduling priority ("nice").
-
-@item -f
-The maximum size of files written by the shell and its children.
-
-@item -i
-The maximum number of pending signals.
-
-@item -l
-The maximum size that may be locked into memory.
-
-@item -m
-The maximum resident set size.
-
-@item -n
-The maximum number of open file descriptors.
-
-@item -p
-The pipe buffer size.
-
-@item -q
-The maximum number of bytes in POSIX message queues.
-
-@item -r
-The maximum real-time scheduling priority.
-
-@item -s
-The maximum stack size.
-
-@item -t
-The maximum amount of cpu time in seconds.
-
-@item -u
-The maximum number of processes available to a single user.
-
-@item -v
-The maximum amount of virtual memory available to the process.
-
-@item -x
-The maximum number of file locks.
-
-@end table
-
-If @var{limit} is given, it is the new value of the specified resource;
-the special @var{limit} values @code{hard}, @code{soft}, and
-@code{unlimited} stand for the current hard limit, the current soft limit,
-and no limit, respectively.
-Otherwise, the current value of the soft limit for the specified resource
-is printed, unless the @option{-H} option is supplied.
-When setting new limits, if neither @option{-H} nor @option{-S} is supplied,
-both the hard and soft limits are set.
-If no option is given, then @option{-f} is assumed.  Values are in 1024-byte
-increments, except for @option{-t}, which is in seconds, @option{-p},
-which is in units of 512-byte blocks, and @option{-n} and @option{-u}, which
-are unscaled values.
-
-The return status is zero unless an invalid option or argument is supplied,
-or an error occurs while setting a new limit.
-
-@item unalias
-@btindex unalias
-@example
-unalias [-a] [@var{name} @dots{} ]
-@end example
-
-Remove each @var{name} from the list of aliases.  If @option{-a} is
-supplied, all aliases are removed.
-Aliases are described in @ref{Aliases}.
-
-@end table
+@node Modifying Shell Behavior
+@section Modifying Shell Behavior
+@menu
+* The Set Builtin::            Change the values of shell attributes and
+                               positional parameters.
+* The Shopt Builtin::          Modify shell optional behavior.
+@end menu
 
 @node The Set Builtin
-@section The Set Builtin
+@subsection The Set Builtin
 
-This builtin is so complicated that it deserves its own section.
+This builtin is so complicated that it deserves its own section.  @code{set}
+allows you to change the values of shell options and set the positional
+parameters, or to display the names and values of shell variables.
 
 @table @code
 @item set
 @btindex set
 @example
 set [--abefhkmnptuvxBCEHPT] [-o @var{option}] [@var{argument} @dots{}]
+set [+abefhkmnptuvxBCEHPT] [+o @var{option}] [@var{argument} @dots{}]
 @end example
 
 If no options or arguments are supplied, @code{set} displays the names
@@ -4191,6 +3950,283 @@ The special parameter @code{#} is set to N.
 The return status is always zero unless an invalid option is supplied.
 @end table
 
+@node The Shopt Builtin
+@subsection The Shopt Builtin
+
+This builtin allows you to change additional shell optional behavior.
+
+@table @code
+
+@item shopt
+@btindex shopt
+@example
+shopt [-pqsu] [-o] [@var{optname} @dots{}]
+@end example
+Toggle the values of variables controlling optional shell behavior.
+With no options, or with the @option{-p} option, a list of all settable
+options is displayed, with an indication of whether or not each is set.
+The @option{-p} option causes output to be displayed in a form that
+may be reused as input.
+Other options have the following meanings:
+
+@table @code
+@item -s
+Enable (set) each @var{optname}.
+
+@item -u
+Disable (unset) each @var{optname}.
+
+@item -q
+Suppresses normal output; the return status
+indicates whether the @var{optname} is set or unset.
+If multiple @var{optname} arguments are given with @option{-q},
+the return status is zero if all @var{optnames} are enabled;
+non-zero otherwise.
+
+@item -o
+Restricts the values of
+@var{optname} to be those defined for the @option{-o} option to the
+@code{set} builtin (@pxref{The Set Builtin}).
+@end table
+
+If either @option{-s} or @option{-u}
+is used with no @var{optname} arguments, the display is limited to
+those options which are set or unset, respectively.
+
+Unless otherwise noted, the @code{shopt} options are disabled (off)
+by default.
+
+The return status when listing options is zero if all @var{optnames}
+are enabled, non-zero otherwise.  When setting or unsetting options,
+the return status is zero unless an @var{optname} is not a valid shell
+option.
+
+The list of @code{shopt} options is:
+@table @code
+
+@item autocd
+If set, a command name that is the name of a directory is executed as if
+it were the argument to the @code{cd} command.
+This option is only used by interactive shells.
+
+@item cdable_vars
+If this is set, an argument to the @code{cd} builtin command that
+is not a directory is assumed to be the name of a variable whose
+value is the directory to change to.
+
+@item cdspell
+If set, minor errors in the spelling of a directory component in a
+@code{cd} command will be corrected.
+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 only used by interactive shells.
+
+@item checkhash
+If this is set, Bash checks that a command found in the hash
+table exists before trying to execute it.  If a hashed command no
+longer exists, a normal path search is performed.
+
+@item checkjobs
+If set, Bash lists the status of any stopped and running jobs before
+exiting an interactive shell.  If any jobs are running, this causes
+the exit to be deferred until a second exit is attempted without an
+intervening command (@pxref{Job Control}).
+The shell always postpones exiting if any jobs are stopped.
+
+@item checkwinsize
+If set, Bash checks the window size after each command
+and, if necessary, updates the values of    
+@env{LINES} and @env{COLUMNS}.
+
+@item cmdhist
+If set, Bash
+attempts to save all lines of a multiple-line
+command in the same history entry.  This allows
+easy re-editing of multi-line commands.
+
+@item dotglob
+If set, Bash includes filenames beginning with a `.' in
+the results of filename expansion.
+
+@item execfail
+If this is set, a non-interactive shell will not exit if
+it cannot execute the file specified as an argument to the @code{exec}
+builtin command.  An interactive shell does not exit if @code{exec}
+fails.
+
+@item expand_aliases
+If set, aliases are expanded as described below under Aliases,
+@ref{Aliases}.
+This option is enabled by default for interactive shells.
+
+@item extdebug
+If set, behavior intended for use by debuggers is enabled:
+
+@enumerate
+@item
+The @option{-F} option to the @code{declare} builtin (@pxref{Bash Builtins})
+displays the source file name and line number corresponding to each function
+name supplied as an argument.
+
+@item
+If the command run by the @code{DEBUG} trap returns a non-zero value, the
+next command is skipped and not executed.
+
+@item
+If the command run by the @code{DEBUG} trap returns a value of 2, and the
+shell is executing in a subroutine (a shell function or a shell script
+executed by the @code{.} or @code{source} builtins), a call to
+@code{return} is simulated.
+
+@item
+@code{BASH_ARGC} and @code{BASH_ARGV} are updated as described in their
+descriptions (@pxref{Bash Variables}).
+
+@item
+Function tracing is enabled:  command substitution, shell functions, and
+subshells invoked with @code{( @var{command} )} inherit the
+@code{DEBUG} and @code{RETURN} traps.
+
+@item
+Error tracing is enabled:  command substitution, shell functions, and
+subshells invoked with @code{( @var{command} )} inherit the
+@code{ERROR} trap.
+@end enumerate
+
+@item extglob
+If set, the extended pattern matching features described above
+(@pxref{Pattern Matching}) are enabled.
+
+@item extquote
+If set, @code{$'@var{string}'} and @code{$"@var{string}"} quoting is  
+performed within @code{$@{@var{parameter}@}} expansions                     
+enclosed in double quotes.  This option is enabled by default. 
+
+@item failglob
+If set, patterns which fail to match filenames during pathname expansion
+result in an expansion error.
+
+@item force_fignore
+If set, the suffixes specified by the @env{FIGNORE} shell variable
+cause words to be ignored when performing word completion even if
+the ignored words are the only possible completions.
+@xref{Bash Variables}, for a description of @env{FIGNORE}.
+This option is enabled by default.
+
+@item gnu_errfmt
+If set, shell error messages are written in the standard @sc{gnu} error
+message format.
+
+@item histappend
+If set, the history list is appended to the file named by the value
+of the @env{HISTFILE}
+variable when the shell exits, rather than overwriting the file.
+
+@item histreedit
+If set, and Readline
+is being used, a user is given the opportunity to re-edit a
+failed history substitution.
+
+@item histverify
+If set, and Readline
+is being used, the results of history substitution are not immediately
+passed to the shell parser.  Instead, the resulting line is loaded into
+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 containing a @samp{@@} is being
+completed (@pxref{Commands For Completion}).  This option is enabled
+by default.
+
+@item huponexit
+If set, Bash will send @code{SIGHUP} to all jobs when an interactive
+login shell exits (@pxref{Signals}).
+
+@item interactive_comments
+Allow a word beginning with @samp{#}
+to cause that word and all remaining characters on that
+line to be ignored in an interactive shell.
+This option is enabled by default.
+
+@item lithist
+If enabled, and the @code{cmdhist}
+option is enabled, multi-line commands are saved to the history with
+embedded newlines rather than using semicolon separators where possible.
+
+@item login_shell
+The shell sets this option if it is started as a login shell
+(@pxref{Invoking Bash}).
+The value may not be changed.
+
+@item mailwarn
+If set, and a file that Bash is checking for mail has been  
+accessed since the last time it was checked, the message
+@code{"The mail in @var{mailfile} has been read"} is displayed.
+
+@item no_empty_cmd_completion
+If set, and Readline is being used, Bash will not attempt to search
+the @env{PATH} for possible completions when completion is attempted
+on an empty line.
+
+@item nocaseglob
+If set, Bash matches filenames in a case-insensitive fashion when
+performing filename expansion.
+
+@item nocasematch
+If set, Bash matches patterns in a case-insensitive fashion when
+performing matching while executing @code{case} or @code{[[}
+conditional commands.
+
+@item nullglob
+If set, Bash allows filename patterns which match no
+files to expand to a null string, rather than themselves.
+
+@item progcomp
+If set, the programmable completion facilities
+(@pxref{Programmable Completion}) are enabled.
+This option is enabled by default.
+
+@item promptvars
+If set, prompt strings undergo
+parameter expansion, command substitution, arithmetic
+expansion, and quote removal after being expanded
+as described below (@pxref{Printing a Prompt}).
+This option is enabled by default.
+
+@item restricted_shell
+The shell sets this option if it is started in restricted mode
+(@pxref{The Restricted Shell}).
+The value may not be changed.
+This is not reset when the startup files are executed, allowing
+the startup files to discover whether or not a shell is restricted.
+
+@item shift_verbose
+If this is set, the @code{shift}
+builtin prints an error message when the shift count exceeds the
+number of positional parameters.
+
+@item sourcepath
+If set, the @code{source} builtin uses the value of @env{PATH}
+to find the directory containing the file supplied as an argument.
+This option is enabled by default.
+
+@item xpg_echo
+If set, the @code{echo} builtin expands backslash-escape sequences
+by default.
+
+@end table
+
+@noindent
+The return status when listing options is zero if all @var{optnames}
+are enabled, non-zero otherwise.
+When setting or unsetting options, the return status is zero unless an
+@var{optname} is not a valid shell option.
+
+@end table
+
 @node Special Builtins
 @section Special Builtins
 @cindex special builtin
@@ -4310,6 +4346,11 @@ variables for controlling the job control facilities
 @item BASH
 The full pathname used to execute the current instance of Bash.
 
+@item BASHPID
+Expands to the process id of the current Bash process.
+This differs from @code{$$} under certain circumstances, such as subshells
+that do not require Bash to be re-initialized.
+
 @item BASH_ARGC
 An array variable whose values are the number of parameters in each
 frame of the current bash execution call stack.  The number of
@@ -4318,7 +4359,7 @@ with @code{.} or @code{source}) is at the top of the stack.  When a
 subroutine is executed, the number of parameters passed is pushed onto
 @code{BASH_ARGC}.
 The shell sets @code{BASH_ARGC} only when in extended debugging mode
-(see @ref{Bash Builtins}  
+(see @ref{The Shopt Builtin}
 for a description of the @code{extdebug} option to the @code{shopt}
 builtin).
 
@@ -4329,7 +4370,7 @@ is at the top of the stack; the first parameter of the initial call is
 at the bottom.  When a subroutine is executed, the parameters supplied
 are pushed onto @code{BASH_ARGV}.
 The shell sets @code{BASH_ARGV} only when in extended debugging mode
-(see @ref{Bash Builtins}  
+(see @ref{The Shopt Builtin}
 for a description of the @code{extdebug} option to the @code{shopt}
 builtin).
 
@@ -4428,6 +4469,23 @@ This variable is available only in shell functions and external
 commands invoked by the
 programmable completion facilities (@pxref{Programmable Completion}).
 
+@item COMP_TYPE
+Set to an integer value corresponding to the type of completion attempted
+that caused a completion function to be called:
+@var{TAB}, for normal completion,
+@samp{?}, for listing completions after successive tabs,
+@samp{!}, for listing alternatives on partial word completion,
+@samp{@@}, to list completions if the word is not unmodified,
+or
+@samp{%}, for menu completion.
+This variable is available only in shell functions and external
+commands invoked by the
+programmable completion facilities (@pxref{Programmable Completion}).
+
+@item COMP_KEY
+The key (or final key of a key sequence) used to invoke the current
+completion function.
+
 @item COMP_WORDBREAKS
 The set of characters that the Readline library treats as word
 separators when performing word completion.
@@ -4858,7 +4916,7 @@ line before the single-character options to be recognized.
 @table @code
 @item --debugger
 Arrange for the debugger profile to be executed before the shell
-starts.  Turns on extended debugging mode (see @ref{Bash Builtins}
+starts.  Turns on extended debugging mode (see @ref{The Shopt Builtin}
 for a description of the @code{extdebug} option to the @code{shopt}
 builtin) and shell function tracing
 (see @ref{The Set Builtin} for a description of the @code{-o functrace}
@@ -4961,7 +5019,7 @@ This implies the @option{-n} option; no commands will be executed.
 
 @item [-+]O [@var{shopt_option}]
 @var{shopt_option} is one of the shell options accepted by the
-@code{shopt} builtin (@pxref{Shell Builtin Commands}).
+@code{shopt} builtin (@pxref{The Shopt Builtin}).
 If @var{shopt_option} is present, @option{-O} sets the value of that option;
 @option{+O} unsets it.  
 If @var{shopt_option} is not supplied, the names and values of the shell
@@ -5260,7 +5318,7 @@ Parser syntax errors will not cause the shell to exit.
 @item
 Simple spelling correction for directory arguments to the @code{cd}
 builtin is enabled by default (see the description of the @code{cdspell}
-option to the @code{shopt} builtin in @ref{Bash Builtins}).
+option to the @code{shopt} builtin in @ref{The Shopt Builtin}).
 
 @item
 The shell will check the value of the @env{TMOUT} variable and exit
@@ -5544,7 +5602,7 @@ If arguments are needed, a shell function should be used
 
 Aliases are not expanded when the shell is not interactive,
 unless the @code{expand_aliases} shell option is set using
-@code{shopt} (@pxref{Bash Builtins}).
+@code{shopt} (@pxref{The Shopt Builtin}).
 
 The rules concerning the definition and use of aliases are
 somewhat confusing.  Bash
@@ -6246,11 +6304,13 @@ Bash reports such changes immediately (@pxref{The Set Builtin}).
 Any trap on @code{SIGCHLD} is executed for each child process
 that exits.
 
-If an attempt to exit Bash is made while jobs are stopped, the
-shell prints a message warning that there are stopped jobs.
+If an attempt to exit Bash is made while jobs are stopped, (or running, if
+the @code{checkjobs} option is enabled -- see @ref{The Shopt Builtin}), the
+shell prints a warning message, and if the @code{checkjobs} option is
+enabled, lists the jobs and their statuses.
 The @code{jobs} command may then be used to inspect their status.
 If a second attempt to exit is made without an intervening command,
-Bash does not print another warning, and the stopped jobs are terminated.
+Bash does not print another warning, and any stopped jobs are terminated.
 
 @node Job Control Builtins
 @section Job Control Builtins
@@ -7233,7 +7293,7 @@ executed with the @code{.} or @code{source} builtins
 
 @item
 Bash includes the @code{shopt} builtin, for finer control of shell
-optional capabilities (@pxref{Bash Builtins}), and allows these options
+optional capabilities (@pxref{The Shopt Builtin}), and allows these options
 to be set and unset at shell invocation (@pxref{Invoking Bash}).
 
 @item
index fdce9e3c7b2ee8015e3b3d7ad37070ac8649c2ac..df1e2ab789ee4c98f2544bb990aef4df90c9258d 100644 (file)
@@ -16,7 +16,7 @@ This is Edition @value{EDITION}, last updated @value{UPDATED},
 of @cite{The GNU Bash Reference Manual},
 for @code{Bash}, Version @value{VERSION}.
 
-Copyright @copyright{} 1988-2003 Free Software Foundation, Inc.
+Copyright @copyright{} 1988-2005 Free Software Foundation, Inc.
 
 Permission is granted to make and distribute verbatim copies of
 this manual provided the copyright notice and this permission notice
@@ -24,7 +24,7 @@ are preserved on all copies.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.1 or
+under the terms of the GNU Free Documentation License, Version 1.2 or
 any later version published by the Free Software Foundation; with no
 Invariant Sections, with the Front-Cover texts being ``A GNU Manual,''
 and with the Back-Cover Texts as in (a) below.  A copy of the license is
@@ -74,7 +74,7 @@ USA @*
 @top Bash Features
 
 This text is a brief description of the features that are present in
-the Bash shell (version @value{VERSION}, @value{UPDATED})..
+the Bash shell (version @value{VERSION}, @value{UPDATED}).
 
 This is Edition @value{EDITION}, last updated @value{UPDATED},
 of @cite{The GNU Bash Reference Manual},
@@ -94,46 +94,28 @@ reference on shell behavior.
 
 @menu
 * Introduction::               An introduction to the shell.
-
 * Definitions::                        Some definitions used in the rest of this
                                manual.
-
 * Basic Shell Features::       The shell "building blocks".
-
 * Shell Builtin Commands::     Commands that are a part of the shell.
-
 * Shell Variables::            Variables used or set by Bash.
-
 * Bash Features::              Features found only in Bash.
-
-* Job Control::                        A chapter describing what job control is
-                               and how Bash allows you to use it.
-
-* Using History Interactively::        Chapter dealing with history expansion
-                               rules.
-
+* Job Control::                        What job control is and how Bash allows you
+                               to use it.
+* Using History Interactively::        Command History Expansion
 * Command Line Editing::       Chapter describing the command line
                                editing features.
-
 * Installing Bash::            How to build and install Bash on your system.
-
 * Reporting Bugs::             How to report bugs in Bash.
-
 * Major Differences From The Bourne Shell::    A terse list of the differences
                                                between Bash and historical
                                                versions of /bin/sh.
-
 * Copying This Manual::                Copying this manual.
-
 * Builtin Index::              Index of Bash builtin commands.
-
 * Reserved Word Index::                Index of Bash reserved words.
-
 * Variable Index::             Quick reference helps you find the
                                variable you want.
-
 * Function Index::             Index of bindable Readline functions.
-
 * Concept Index::              General index for concepts described in
                                this manual.
 @end menu
@@ -143,7 +125,6 @@ reference on shell behavior.
 @chapter Introduction
 @menu
 * What is Bash?::              A short description of Bash.
-
 * What is a shell?::           A brief introduction to shells.
 @end menu
 
@@ -154,14 +135,15 @@ Bash is the shell, or command language interpreter,
 for the @sc{gnu} operating system.
 The name is an acronym for the @samp{Bourne-Again SHell},
 a pun on Stephen Bourne, the author of the direct ancestor of
-the current Unix shell @code{/bin/sh}, 
+the current Unix shell @code{sh}, 
 which appeared in the Seventh Edition Bell Labs Research version
 of Unix.
 
 Bash is largely compatible with @code{sh} and incorporates useful
 features from the Korn shell @code{ksh} and the C shell @code{csh}.
 It is intended to be a conformant implementation of the @sc{ieee}
-@sc{posix} Shell and Tools specification (@sc{ieee} Working Group 1003.2).
+@sc{posix} Shell and Tools portion of the @sc{ieee} @sc{posix}
+specification (@sc{ieee} Standard 1003.1).
 It offers functional improvements over @code{sh} for both interactive and
 programming use.
 
@@ -170,19 +152,29 @@ a version of @code{csh}, Bash is the default shell.
 Like other @sc{gnu} software, Bash is quite portable.  It currently runs
 on nearly every version of Unix and a few other operating systems @minus{}
 independently-supported ports exist for @sc{ms-dos}, @sc{os/2},
-Windows @sc{95/98}, and Windows @sc{nt}.
+and Windows platforms.
 
 @node What is a shell?
 @section What is a shell?
 
 At its base, a shell is simply a macro processor that executes
-commands.  A Unix shell is both a command interpreter, which
-provides the user interface to the rich set of @sc{gnu} utilities,
-and a programming language, allowing these utilitites to be
-combined.  Files containing commands can be created, and become
+commands.  The term macro processor means functionality where text
+and symbols are expanded to create larger expressions.
+
+A Unix shell is both a command interpreter and a programming
+language.  As a command interpreter, the shell provides the user
+interface to the rich set of @sc{gnu} utilities.  The programming
+language features allow these utilities to be combined.
+Files containing commands can be created, and become
 commands themselves.  These new commands have the same status as
 system commands in directories such as @file{/bin}, allowing users
-or groups to establish custom environments. 
+or groups to establish custom environments to automate their common
+tasks.
+
+Shells may be used interactively or non-interactively.  In
+interactive mode, they accept input typed from the keyboard.
+When executing non-interactively, shells execute commands read
+from a file.
 
 A shell allows execution of @sc{gnu} commands, both synchronously and
 asynchronously.
@@ -193,8 +185,6 @@ The @dfn{redirection} constructs permit
 fine-grained control of the input and output of those commands.
 Moreover, the shell allows control over the contents of commands'
 environments.
-Shells may be used interactively or non-interactively: they accept
-input typed from the keyboard or from a file.
 
 Shells also provide a small set of built-in
 commands (@dfn{builtins}) implementing functionality impossible
@@ -216,7 +206,7 @@ variables, flow control constructs, quoting, and functions.
 Shells offer features geared specifically for
 interactive use rather than to augment the programming language. 
 These interactive features include job control, command line
-editing, history and aliases.  Each of these features is
+editing, command history and aliases.  Each of these features is
 described in this manual.
 
 @node Definitions
@@ -228,7 +218,8 @@ These definitions are used throughout the remainder of this manual.
 @item POSIX
 @cindex POSIX
 A family of open system standards based on Unix.  Bash
-is concerned with @sc{posix} 1003.2, the Shell and Tools Standard.
+is primarily concerned with the Shell and Utilities portion of the
+@sc{posix} 1003.1 standard. 
 
 @item blank
 A space or tab character.
@@ -297,7 +288,7 @@ group @sc{id}.
 
 @item process group ID
 @cindex process group ID
-A unique identifer that represents a @code{process group}
+A unique identifier that represents a @code{process group}
 during its lifetime.
 
 @item reserved word
@@ -318,7 +309,7 @@ of an event occurring in the system.
 @item special builtin
 @cindex special builtin
 A shell builtin command that has been classified as special by the
-@sc{posix} 1003.2 standard.
+@sc{posix} standard.
 
 @item token
 @cindex token
@@ -338,8 +329,8 @@ Bash is an acronym for @samp{Bourne-Again SHell}.
 The Bourne shell is
 the traditional Unix shell originally written by Stephen Bourne.
 All of the Bourne shell builtin commands are available in Bash,
-and the rules for evaluation and quoting are taken from the @sc{posix}
-1003.2 specification for the `standard' Unix shell.
+The rules for evaluation and quoting are taken from the @sc{posix}
+specification for the `standard' Unix shell.
 
 This chapter briefly summarizes the shell's `building blocks':
 commands, control structures, shell functions, shell @i{parameters},
@@ -363,9 +354,7 @@ and to named files, and how the shell executes commands.
 @section Shell Syntax
 @menu
 * Shell Operation::    The basic operation of the shell.
-
 * Quoting::            How to remove the special meaning from characters.
-
 * Comments::           How to specify comments.
 @end menu
 
@@ -436,7 +425,6 @@ status (@pxref{Exit Status}).
 * Double Quotes::      How to suppress most of the interpretation of a
                        sequence of characters.
 * ANSI-C Quoting::     How to expand ANSI-C sequences in quoted strings.
-
 * Locale Translation:: How to translate strings into different languages.
 @end menu
 
@@ -449,7 +437,8 @@ parameter expansion.
 Each of the shell metacharacters (@pxref{Definitions})
 has special meaning to the shell and must be quoted if it is to
 represent itself.
-When the command history expansion facilities are being used, the
+When the command history expansion facilities are being used
+(@pxref{History Interaction}), the
 @var{history expansion} character, usually @samp{!}, must be quoted
 to prevent history expansion.  @xref{Bash History Facilities}, for
 more details concerning history expansion.
@@ -478,7 +467,8 @@ between single quotes, even when preceded by a backslash.
 
 Enclosing characters in double quotes (@samp{"}) preserves the literal value
 of all characters within the quotes, with the exception of
-@samp{$}, @samp{`}, and @samp{\}.
+@samp{$}, @samp{`}, @samp{\},
+and, when history expansion is enabled, @samp{!}.
 The characters @samp{$} and @samp{`}
 retain their special meaning within double quotes (@pxref{Shell Expansions}).
 The backslash retains its special meaning only when followed by one of
@@ -489,8 +479,9 @@ characters are removed.  Backslashes preceding characters without a
 special meaning are left unmodified.
 A double quote may be quoted within double quotes by preceding it with
 a backslash.
-When command history is being used, the double quote may not be used to
-quote the history expansion character.
+If enabled, history expansion will be performed unless an @samp{!}
+appearing in double quotes is escaped using a backslash.
+The backslash preceding the @samp{!} is not removed.
 
 The special parameters @samp{*} and @samp{@@} have special meaning
 when in double quotes (@pxref{Shell Parameter Expansion}).
@@ -597,9 +588,7 @@ some other grouping.
 * Pipelines::                  Connecting the input and output of several
                                commands.
 * Lists::                      How to execute commands sequentially.
-* Looping Constructs::         Shell commands for iterative action.
-* Conditional Constructs::     Shell commands for conditional execution.
-* Command Grouping::           Ways to group commands.
+* Compound Commands::          Shell commands for control flow.
 @end menu
 
 @node Simple Commands
@@ -657,8 +646,16 @@ shell waits for all commands in the pipeline to complete.
 Each command in a pipeline is executed in its own subshell
 (@pxref{Command Execution Environment}).  The exit
 status of a pipeline is the exit status of the last command in the
-pipeline.  If the reserved word @samp{!} precedes the pipeline, the
-exit status is the logical negation of the exit status of the last command.
+pipeline, unless the @code{pipefail} option is enabled
+(@pxref{The Set Builtin}).
+If @code{pipefail} is enabled, the pipeline's return status is the
+value of the last (rightmost) command to exit with a non-zero status,
+or zero if all commands exit successfully.
+If the reserved word @samp{!} precedes the pipeline, the
+exit status is the logical negation of the exit status as described
+above.
+The shell waits for all commands in the pipeline to terminate before
+returning a value.
 
 @node Lists
 @subsection Lists of Commands
@@ -713,8 +710,27 @@ The return status of
 @sc{and} and @sc{or} lists is the exit status of the last command
 executed in the list.
 
+@node Compound Commands
+@subsection Compound Commands
+@cindex commands, compound
+
+@menu
+* Looping Constructs::         Shell commands for iterative action.
+* Conditional Constructs::     Shell commands for conditional execution.
+* Command Grouping::           Ways to group commands.
+@end menu
+
+Compound commands are the shell programming constructs.
+Each construct begins with a reserved word or control operator and is
+terminated by a corresponding reserved word or operator.
+Any redirections (@pxref{Redirections}) associated with a compound command
+apply to all commands within that compound command unless explicitly overridden.
+
+Bash provides looping constructs, conditional commands, and mechanisms
+to group commands and execute them as a unit.
+
 @node Looping Constructs
-@subsection Looping Constructs
+@subsubsection Looping Constructs
 @cindex commands, looping
 
 Bash supports the following looping constructs.
@@ -786,7 +802,7 @@ The @code{break} and @code{continue} builtins (@pxref{Bourne Shell Builtins})
 may be used to control loop execution.
 
 @node Conditional Constructs
-@subsection Conditional Constructs
+@subsubsection Conditional Constructs
 @cindex commands, conditional
 
 @table @code
@@ -831,6 +847,10 @@ The syntax of the @code{case} command is:
 
 @code{case} will selectively execute the @var{command-list} corresponding to
 the first @var{pattern} that matches @var{word}.
+If the shell option @code{nocasematch}
+(see the description of @code{shopt} in @ref{Bash Builtins})
+is enabled, the match is performed without regard to the case
+of alphabetic characters.
 The @samp{|} is used to separate multiple patterns, and the @samp{)}
 operator terminates a pattern list.
 A list of patterns and an associated command-list is known
@@ -877,7 +897,7 @@ The list of words following @code{in} is expanded, generating a list
 of items.  The set of expanded words is printed on the standard
 error output stream, each preceded by a number.  If the
 @samp{in @var{words}} is omitted, the positional parameters are printed,
-as if @samp{in "$@@"} had been specifed.
+as if @samp{in "$@@"} had been specified.
 The @env{PS3} prompt is then displayed and a line is read from the
 standard input.
 If the line consists of a number corresponding to one of the displayed
@@ -939,11 +959,34 @@ as primaries.
 When the @samp{==} and @samp{!=} operators are used, the string to the
 right of the operator is considered a pattern and matched according
 to the rules described below in @ref{Pattern Matching}.
-The return value is 0 if the string matches or does not match
-the pattern, respectively, and 1 otherwise.
+If the shell option @code{nocasematch}
+(see the description of @code{shopt} in @ref{Bash Builtins})
+is enabled, the match is performed without regard to the case
+of alphabetic characters.
+The return value is 0 if the string matches (@samp{==}) or does not
+match (@samp{!=})the pattern, and 1 otherwise.
 Any part of the pattern may be quoted to force it to be matched as a
 string.
 
+An additional binary operator, @samp{=~}, is available, with the same
+precedence as @samp{==} and @samp{!=}.
+When it is used, the string to the right of the operator is considered
+an extended regular expression and matched accordingly (as in @i{regex}3)).  
+The return value is 0 if the string matches
+the pattern, and 1 otherwise.
+If the regular expression is syntactically incorrect, the conditional
+expression's return value is 2.
+If the shell option @code{nocasematch}
+(see the description of @code{shopt} in @ref{Bash Builtins})
+is enabled, the match is performed without regard to the case
+of alphabetic characters.
+Substrings matched by parenthesized subexpressions within the regular
+expression are saved in the array variable @code{BASH_REMATCH}.
+The element of @code{BASH_REMATCH} with index 0 is the portion of the string
+matching the entire regular expression.
+The element of @code{BASH_REMATCH} with index @var{n} is the portion of the
+string matching the @var{n}th parenthesized subexpression.
+
 Expressions may be combined using the following operators, listed
 in decreasing order of precedence:
 
@@ -969,7 +1012,7 @@ value of the entire conditional expression.
 @end table
 
 @node Command Grouping
-@subsection Grouping Commands
+@subsubsection Grouping Commands
 @cindex commands, grouping
 
 Bash provides two ways to group a list of commands to be executed
@@ -984,9 +1027,10 @@ commands in the list may be redirected to a single stream.
 @end example
 
 Placing a list of commands between parentheses causes a subshell
-to be created, and each of the commands in @var{list} to be executed
-in that subshell.  Since the @var{list} is executed in a subshell,
-variable assignments do not remain in effect after the subshell completes.
+environment to be created (@pxref{Command Execution Environment}), and each
+of the commands in @var{list} to be executed in that subshell.  Since the
+@var{list} is executed in a subshell, variable assignments do not remain in
+effect after the subshell completes. 
 
 @item @{@}
 @rwindex @{
@@ -1026,24 +1070,36 @@ shell context; no new process is created to interpret them.
 Functions are declared using this syntax:
 @rwindex function
 @example
-[ @code{function} ] @var{name} () @{ @var{command-list}; @}
+[ @code{function} ] @var{name} () @var{compound-command} [ @var{redirections} ]
 @end example
 
 This defines a shell function named @var{name}.  The reserved
 word @code{function} is optional.
 If the @code{function} reserved
 word is supplied, the parentheses are optional.
-The @var{body} of the function is the @var{command-list} between @{ and @}.
-This list is executed whenever @var{name} is specified as the
-name of a command.  The exit status of a function is
-the exit status of the last command executed in the body.
-
-Note that for historical reasons, the curly braces that surround
-the body of the function must be separated from the body by
+The @var{body} of the function is the compound command
+@var{compound-command} (@pxref{Compound Commands}).
+That command is usually a @var{list} enclosed between @{ and @}, but
+may be any compound command listed above.
+@var{compound-command} is executed whenever @var{name} is specified as the
+name of a command.
+Any redirections (@pxref{Redirections}) associated with the shell function
+are performed when the function is executed.
+
+A function definition may be deleted using the @option{-f} option to the
+@code{unset} builtin (@pxref{Bourne Shell Builtins}).
+
+The exit status of a function definition is zero unless a syntax error
+occurs or a readonly function with the same name already exists.
+When executed, the exit status of a function is the exit status of the
+last command executed in the body.
+
+Note that for historical reasons, in the most common usage the curly braces
+that surround the body of the function must be separated from the body by
 @code{blank}s or newlines.
 This is because the braces are reserved words and are only recognized
 as such when they are separated by whitespace.
-Also, the @var{command-list} must be terminated by a semicolon,
+Also, when using the braces, the @var{list} must be terminated by a semicolon,
 a @samp{&}, or a newline.
 
 When a function is executed, the arguments to the
@@ -1051,17 +1107,17 @@ function become the positional parameters
 during its execution (@pxref{Positional Parameters}).
 The special parameter @samp{#} that expands to the number of
 positional parameters is updated to reflect the change.
-Positional parameter @code{0} is unchanged.
+Special parameter @code{0} is unchanged.
 The first element of the @env{FUNCNAME} variable is set to the
 name of the function while the function is executing.
 All other aspects of the shell execution
 environment are identical between a function and its caller
-with the exception that the @env{DEBUG} trap
-below) is not inherited unless the function has been given the
+with the exception that the @env{DEBUG} and @env{RETURN} traps
+are not inherited unless the function has been given the
 @code{trace} attribute using the @code{declare} builtin or
 the @code{-o functrace} option has been enabled with
 the @code{set} builtin,
-(in which case all functions inherit the @code{DEBUG} trap).
+(in which case all functions inherit the @env{DEBUG} and @env{RETURN} traps).
 @xref{Bourne Shell Builtins}, for the description of the
 @code{trap} builtin.
 
@@ -1142,9 +1198,25 @@ Word splitting is not performed, with the exception
 of @code{"$@@"} as explained below.
 Filename expansion is not performed.
 Assignment statements may also appear as arguments to the
+@code{alias}, 
 @code{declare}, @code{typeset}, @code{export}, @code{readonly},
 and @code{local} builtin commands.
 
+In the context where an assignment statement is assigning a value  
+to a shell variable or array index (@pxref{Arrays}), the @samp{+=}
+operator can be used to   
+append to or add to the variable's previous value.
+When @samp{+=} is applied to a variable for which the integer attribute
+has been set, @var{value} is evaluated as an arithmetic expression and
+added to the variable's current value, which is also evaluated.
+When @samp{+=} is applied to an array variable using compound assignment
+(@pxref{Arrays}), the
+variable's value is not unset (as it is when using @samp{=}), and new
+values are appended to the array beginning at one greater than the array's
+maximum index.
+When applied to a string-valued variable, @var{value} is expanded and
+appended to the variable's value.
+
 @node Positional Parameters
 @subsection Positional Parameters
 @cindex parameters, positional
@@ -1193,6 +1265,10 @@ Expands to the positional parameters, starting from one.  When the
 expansion occurs within double quotes, each parameter expands to a
 separate word.  That is, @code{"$@@"} is equivalent to
 @code{"$1" "$2" @dots{}}.
+If the double-quoted expansion occurs within a word, the expansion of
+the first parameter is joined with the beginning part of the original
+word, and the expansion of the last parameter is joined with the last
+part of the original word.
 When there are no positional parameters, @code{"$@@"} and
 @code{$@@}
 expand to nothing (i.e., they are removed).
@@ -1229,12 +1305,13 @@ to the filename used to invoke Bash, as given by argument zero.
 
 @item _
 (An underscore.)
-At shell startup, set to the absolute filename of the shell or shell
-script being executed as passed in the argument list.
+At shell startup, set to the absolute pathname used to invoke the
+shell or shell script being executed as passed in the environment
+or argument list.
 Subsequently, expands to the last argument to the previous command,
 after expansion.   
-Also set to the full pathname of each command executed and placed in
-the environment exported to that command.
+Also set to the full pathname used to invoke each command executed
+and placed in the environment exported to that command.
 When checking mail, this parameter holds the name of the mail file.
 @end vtable
 
@@ -1300,7 +1377,7 @@ This mechanism is similar to
 @var{filename expansion} (@pxref{Filename Expansion}),
 but the file names generated need not exist.
 Patterns to be brace expanded take the form of an optional @var{preamble},
-followed by either a series of comma-separated strings or a sequnce expression
+followed by either a series of comma-separated strings or a seqeunce expression
 between a pair of braces,
 followed by an optional @var{postscript}.
 The preamble is prefixed to each string contained within the braces, and
@@ -1389,7 +1466,7 @@ If the login name is invalid, or the tilde expansion fails, the word is
 left unchanged.
 
 Each variable assignment is checked for unquoted tilde-prefixes immediately
-following a @samp{:} or @samp{=}.
+following a @samp{:} or the first @samp{=}.
 In these cases, tilde expansion is also performed.
 Consequently, one may use file names with tildes in assignments to
 @env{PATH}, @env{MAILPATH}, and @env{CDPATH},
@@ -1482,9 +1559,9 @@ If @var{parameter} is unset or null, the expansion of
 If @var{parameter}
 is unset or null, the expansion of @var{word}
 is assigned to @var{parameter}.
-The value of @var{parameter}
-is then substituted.  Positional parameters and special parameters may
-not be assigned to in this way.
+The value of @var{parameter} is then substituted. 
+Positional parameters and special parameters may not be assigned to
+in this way.
 
 @item $@{@var{parameter}:?@var{word}@}
 If @var{parameter}
@@ -1517,13 +1594,21 @@ parameters beginning at @var{offset}.
 If @var{parameter} is an array name indexed by @samp{@@} or @samp{*},
 the result is the @var{length}
 members of the array beginning with @code{$@{@var{parameter}[@var{offset}]@}}.
+A negative @var{offset} is taken relative to one greater than the maximum
+index of the specified array.
+Note that a negative offset must be separated from the colon by at least
+one space to avoid being confused with the @samp{:-} expansion.
 Substring indexing is zero-based unless the positional parameters
-are used, in which case the indexing starts at 1.
+are used, in which case the indexing starts at 1 by default.
+If @var{offset} is 0, and the positional parameters are used, @code{$@@} is
+prefixed to the list.
 
 @item $@{!@var{prefix}*@}
 @itemx $@{!@var{prefix}@@@}
 Expands to the names of variables whose names begin with @var{prefix},
 separated by the first character of the @env{IFS} special variable.
+When @samp{@@} is used and the expansion appears within double quotes, each
+variable name expands to a separate word.
 
 @item $@{!@var{name}[@@]@}
 @itemx $@{!@var{name}[*]@}
@@ -1576,15 +1661,13 @@ the pattern removal operation is applied to each member of the
 array in turn, and the expansion is the resultant list.
 
 @item $@{@var{parameter}/@var{pattern}/@var{string}@} 
-@itemx $@{@var{parameter}//@var{pattern}/@var{string}@}
 
 The @var{pattern} is expanded to produce a pattern just as in
 filename expansion.
 @var{Parameter} is expanded and the longest match of @var{pattern}
 against its value is replaced with @var{string}.
-In the first form, only the first match is replaced.
-The second form causes all matches of @var{pattern} to be
-replaced with @var{string}.
+If @var{pattern} begins with @samp{/}, all matches of @var{pattern} are
+replaced with @var{string}.  Normally only the first match is replaced.
 If @var{pattern} begins with @samp{#}, it must match at the beginning
 of the expanded value of @var{parameter}.
 If @var{pattern} begins with @samp{%}, it must match at the end
@@ -1702,13 +1785,15 @@ The shell scans the results of parameter expansion, command substitution,
 and arithmetic expansion that did not occur within double quotes for
 word splitting.
 
-The shell treats each character of @env{$IFS}
-as a delimiter, and splits the results of the other
-expansions into words on these characters.  If
-@env{IFS} is unset, or its value is exactly @code{<space><tab><newline>},
-the default, then any sequence of @env{IFS}
-characters serves to delimit words.  If @env{IFS}
-has a value other than the default, then sequences of
+The shell treats each character of @env{$IFS} as a delimiter, and splits
+the results of the other expansions into words on these characters.
+If @env{IFS} is unset, or its value is exactly @code{<space><tab><newline>},
+the default, then sequences of
+@code{ <space>}, @code{<tab>}, and @code{<newline>}
+at the beginning and end of the results of the previous
+expansions are ignored, and any sequence of @env{IFS}
+characters not at the beginning or end serves to delimit words.
+If @env{IFS} has a value other than the default, then sequences of
 the whitespace characters @code{space} and @code{tab}
 are ignored at the beginning and end of the
 word, as long as the whitespace character is in the
@@ -1749,6 +1834,8 @@ and the shell option @code{nullglob} is disabled, the word is left
 unchanged.
 If the @code{nullglob} option is set, and no matches are found, the word
 is removed.
+If the @code{failglob} shell option is set, and no matches are found,
+an error message is printed and the command is not executed.
 If the shell option @code{nocaseglob} is enabled, the match is performed
 without regard to the case of alphabetic characters.
 
@@ -1761,7 +1848,7 @@ In other cases, the @samp{.} character is not treated specially.
 
 See the description of @code{shopt} in @ref{Bash Builtins},
 for a description of the @code{nocaseglob}, @code{nullglob},
-and @code{dotglob} options.
+@code{failglob}, and @code{dotglob} options.
 
 The @env{GLOBIGNORE}
 shell variable may be used to restrict the set of filenames matching a
@@ -1825,7 +1912,7 @@ force the use of the C locale by setting the @env{LC_COLLATE} or
 Within @samp{[} and @samp{]}, @var{character classes} can be specified
 using the syntax
 @code{[:}@var{class}@code{:]}, where @var{class} is one of the
-following classes defined in the @sc{posix} 1003.2 standard:
+following classes defined in the @sc{posix} standard:
 @example
 alnum   alpha   ascii   blank   cntrl   digit   graph   lower
 print   punct   space   upper   word    xdigit
@@ -1862,7 +1949,7 @@ Matches zero or more occurrences of the given patterns.
 Matches one or more occurrences of the given patterns.
 
 @item @@(@var{pattern-list})
-Matches exactly one of the given patterns.
+Matches one of the given patterns.
 
 @item !(@var{pattern-list})
 Matches anything except one of the given patterns.
@@ -1948,6 +2035,10 @@ connection to the corresponding socket.
 
 A failure to open or create a file causes the redirection to fail.
 
+Redirections using file descriptors greater than 9 should be used with
+care, as they may conflict with file descriptors the shell uses
+internally.
+
 @subsection Redirecting Input
 Redirection of input causes the file whose name results from
 the expansion of @var{word}
@@ -2123,21 +2214,15 @@ is not specified.  If the file does not exist, it is created.
 @menu
 * Simple Command Expansion::   How Bash expands simple commands before
                                executing them.
-
 * Command Search and Execution::       How Bash finds commands and runs them.
-
 * Command Execution Environment::      The environment in which Bash
                                        executes commands that are not
                                        shell builtins.
-
 * Environment::                The environment given to a command.
-
 * Exit Status::                The status returned by commands and how Bash
                        interprets it.
-
 * Signals::            What happens when Bash or a command it runs
                        receives a signal.
-
 @end menu
 
 @node Simple Command Expansion
@@ -2314,7 +2399,8 @@ shell's parent, and traps ignored by the shell are ignored
 A command invoked in this separate environment cannot affect the
 shell's execution environment. 
 
-Command substitution and asynchronous commands are invoked in a
+Command substitution, commands grouped with parentheses,
+and asynchronous commands are invoked in a
 subshell environment that is a duplicate of the shell environment,
 except that traps caught by the shell are reset to the values
 that the shell inherited from its parent at invocation.  Builtin
@@ -2407,10 +2493,11 @@ In all cases, Bash ignores @code{SIGQUIT}.
 If job control is in effect (@pxref{Job Control}), Bash
 ignores @code{SIGTTIN}, @code{SIGTTOU}, and @code{SIGTSTP}.
 
-Commands started by Bash have signal handlers set to the
+Non-builtin commands started by Bash have signal handlers set to the
 values inherited by the shell from its parent.
 When job control is not in effect, asynchronous commands
-ignore @code{SIGINT} and @code{SIGQUIT} as well.
+ignore @code{SIGINT} and @code{SIGQUIT} in addition to these inherited
+handlers.
 Commands run as a result of
 command substitution ignore the keyboard-generated job control signals
 @code{SIGTTIN}, @code{SIGTTOU}, and @code{SIGTSTP}.
@@ -2430,9 +2517,9 @@ If the  @code{huponexit} shell option has been set with @code{shopt}
 (@pxref{Bash Builtins}), Bash sends a @code{SIGHUP} to all jobs when
 an interactive login shell exits.
 
-When Bash receives a signal for which a trap has been set while waiting
-for a command to complete, the trap will not be executed until the
-command completes. 
+If Bash is waiting for a command to complete and receives a signal
+for which a trap has been set, the trap will not be executed until
+the command completes. 
 When Bash is waiting for an asynchronous
 command via the @code{wait} builtin, the reception of a signal for
 which a trap has been set will cause the @code{wait} builtin to return
@@ -2507,10 +2594,10 @@ under another shell.
 * Bourne Shell Builtins::      Builtin commands inherited from the Bourne
                                Shell.
 * Bash Builtins::              Table of builtins specific to Bash.
-* The Set Builtin::            This builtin is so overloaded it
-                               deserves its own section.
+* The Set Builtin::            Change the values of shell attributes and
+                               positional parameters.
 * Special Builtins::           Builtin commands classified specially by
-                               POSIX.2.
+                               POSIX.
 @end menu
 
 Builtin commands are contained within the shell itself.
@@ -2520,7 +2607,7 @@ the command directly, without invoking another program.
 Builtin commands are necessary to implement functionality impossible
 or inconvenient to obtain with separate utilities.
 
-This section briefly the builtins which Bash inherits from
+This section briefly describes the builtins which Bash inherits from
 the Bourne Shell, as well as the builtin commands which are unique
 to or have been extended in Bash.
 
@@ -2533,11 +2620,17 @@ facilities (@pxref{Programmable Completion Builtins}).
 
 Many of the builtins have been extended by @sc{posix} or Bash.
 
+Unless otherwise noted, each builtin command documented as accepting
+options preceded by @samp{-} accepts @samp{--}
+to signify the end of the options.
+For example, the @code{:}, @code{true}, @code{false}, and @code{test}
+builtins do not accept options.
+
 @node Bourne Shell Builtins
 @section Bourne Shell Builtins
 
 The following shell builtin commands are inherited from the Bourne Shell.
-These commands are implemented as specified by the @sc{posix} 1003.2 standard.
+These commands are implemented as specified by the @sc{posix} standard.
 
 @table @code
 @item :    @r{(a colon)}
@@ -2581,14 +2674,21 @@ The return status is zero unless @var{n} is not greater than or equal to 1.
 @example
 cd [-L|-P] [@var{directory}]
 @end example
-Change the current working directory to @var{directory}.  If @var{directory}
-is not given, the value of the @env{HOME} shell variable is used.  If the
-shell variable @env{CDPATH} exists, it is used as a search path.  If
-@var{directory} begins with a slash, @env{CDPATH} is not used.
-The @option{-P} option means
-to not follow symbolic links; symbolic links are followed by default
-or with the @option{-L} option.
+Change the current working directory to @var{directory}.
+If @var{directory} is not given, the value of the @env{HOME} shell
+variable is used.
+If the shell variable @env{CDPATH} exists, it is used as a search path.
+If @var{directory} begins with a slash, @env{CDPATH} is not used.
+
+The @option{-P} option means to not follow symbolic links; symbolic
+links are followed by default or with the @option{-L} option.
 If @var{directory} is @samp{-}, it is equivalent to @env{$OLDPWD}.
+
+If a non-empty directory name from @env{CDPATH} is used, or if
+@samp{-} is the first argument, and the directory change is
+successful, the absolute pathname of the new working directory is
+written to the standard output.
+
 The return status is zero if the directory is successfully changed,
 non-zero otherwise.
 
@@ -2623,7 +2723,7 @@ exec [-cl] [-a @var{name}] [@var{command} [@var{arguments}]]
 If @var{command}
 is supplied, it replaces the shell without creating a new process.
 If the @option{-l} option is supplied, the shell places a dash at the
-beginning of the zeroth arg passed to @var{command}.
+beginning of the zeroth argument passed to @var{command}.
 This is what the @code{login} program does.
 The @option{-c} option causes @var{command} to be executed with an empty
 environment.
@@ -2718,7 +2818,7 @@ If @code{getopts} is silent, then a colon (@samp{:}) is placed in
 @item hash
 @btindex hash
 @example
-hash [-'r] [-p @var{filename}] [-dt] [@var{name}]
+hash [-r] [-p @var{filename}] [-dt] [@var{name}]
 @end example
 Remember the full pathnames of commands specified as @var{name} arguments,
 so they need not be searched for on subsequent invocations.
@@ -2815,6 +2915,8 @@ Evaluate a conditional expression @var{expr}.
 Each operator and operand must be a separate argument.
 Expressions are composed of the primaries described below in
 @ref{Bash Conditional Expressions}.
+@code{test} does not accept any options, nor does it accept and ignore
+an argument of @option{--} as signifying the end of options.
 
 When the @code{[} form is used, the last argument to the command must
 be a @code{]}.
@@ -2895,9 +2997,10 @@ The return status is zero.
 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.
+shell receives signal @var{sigspec}.  If @var{arg} is absent (and
+there is a single @var{sigspec}) or
+equal to @samp{-}, each specified signal's disposition is reset
+to the value it had when the shell was started.
 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 not present and @option{-p} has been supplied,
@@ -2908,9 +3011,8 @@ associated with each signal number in a form that may be reused as
 shell input.
 The @option{-l} option causes the shell to print a list of signal names
 and their corresponding numbers.
-
-Each @var{sigspec} is either a signal name such as @code{SIGINT} (with
-or without the @code{SIG} prefix) or a signal number.
+Each @var{sigspec} is either a signal name or a signal number.
+Signal names are case insensitive and the @code{SIG} prefix is optional.
 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
@@ -2921,19 +3023,21 @@ Refer to the description of the @code{extglob} option to the
 @code{shopt} builtin (@pxref{Bash Builtins}) for details of its
 effect on the @code{DEBUG} trap.
 If a @var{sigspec} is @code{ERR}, the command @var{arg} 
-is executed whenever a simple command has a non-zero exit status.
+is executed whenever a simple command has a non-zero exit status,
+subject to the following conditions.
 The @code{ERR} trap is not executed if the failed command is part of the
 command list immediately following an @code{until} or @code{while} keyword,
 part of the test in an @code{if} statement,
 part of a @code{&&} or @code{||} list, or if the command's return
 status is being inverted using @code{!}.
+These are the same conditions obeyed by the @code{errexit} option.
 If a @var{sigspec} is @code{RETURN}, the command @var{arg} is executed
 each time a shell function or a script executed with the @code{.} or
 @code{source} builtins finishes executing.
 
 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.
+Trapped signals that are not being ignored are reset to their original
+values in a child process when it is created.
 
 The return status is zero unless a @var{sigspec} does not specify a
 valid signal.
@@ -2978,7 +3082,7 @@ The return status is zero unless a @var{name} is readonly.
 
 This section describes builtin commands which are unique to
 or have been extended in Bash.
-Some of these commands are specified in the @sc{posix} 1003.2 standard.
+Some of these commands are specified in the @sc{posix} standard.
 
 @table @code
 
@@ -3012,7 +3116,7 @@ key and function bindings,
 bind a key sequence to a Readline function or macro,
 or set a Readline variable.
 Each non-option argument is a command as it would appear in a
-Readline initialization file (@pxref{Readline Init File}),
+Readline initialization file (@pxref{Readline Init File}),
 but each binding or command must be passed as a separate argument;  e.g.,
 @samp{"\C-x\C-r":re-read-init-file}.
 Options, if supplied, have the following meanings:
@@ -3098,7 +3202,7 @@ builtin command.
 caller [@var{expr}]
 @end example
 Returns the context of any active subroutine call (a shell function or
-a script executed with the @code{.} or @code{source} builtins.
+a script executed with the @code{.} or @code{source} builtins).
 
 Without @var{expr}, @code{caller} displays the line number and source
 filename of the current subroutine call.
@@ -3176,7 +3280,8 @@ by subsequent assignment statements or unset.
 
 @item -t
 Give each @var{name} the @code{trace} attribute.
-Traced functions inherit the @code{DEBUG} trap from the calling shell.
+Traced functions inherit the @code{DEBUG} and @code{RETURN} traps from
+the calling shell.
 The trace attribute has no special meaning for variables.
 
 @item -x
@@ -3184,7 +3289,10 @@ Mark each @var{name} for export to subsequent commands via
 the environment.
 @end table
 
-Using @samp{+} instead of @samp{-} turns off the attribute instead.
+Using @samp{+} instead of @samp{-} turns off the attribute instead,
+with the exceptions that @samp{+a}
+may not be used to destroy an array variable and @samp{+r} will not
+remove the readonly attribute.
 When used in a function, @code{declare} makes each @var{name} local,
 as with the @code{local} command.  If a variable name is followed by
 =@var{value}, the value of the variable is set to @var{value}.
@@ -3215,6 +3323,8 @@ even on systems where they are interpreted by default.
 The @code{xpg_echo} shell option may be used to
 dynamically determine whether or not @code{echo} expands these
 escape characters by default.
+@code{echo} does not interpret @option{--} to mean the end of options.
+
 @code{echo} interprets the following escape sequences:
 @table @code
 @item \a
@@ -3240,9 +3350,6 @@ backslash
 @item \0@var{nnn}
 the eight-bit character whose value is the octal value @var{nnn}
 (zero to three octal digits)
-@item \@var{nnn}
-the eight-bit character whose value is the octal value @var{nnn}
-(one to three octal digits)
 @item \x@var{HH}
 the eight-bit character whose value is the hexadecimal value @var{HH}
 (one or two hex digits)
@@ -3251,7 +3358,7 @@ the eight-bit character whose value is the hexadecimal value @var{HH}
 @item enable
 @btindex enable
 @example
-enable [-n] [-p] [-f @var{filename}] [-ads] [@var{name} @dots{}]
+enable [-a] [-dnps] [-f @var{filename}] [@var{name} @dots{}]
 @end example
 Enable and disable builtin shell commands.
 Disabling a builtin allows a disk command which has the same name
@@ -3329,7 +3436,7 @@ parent.
 @item printf
 @btindex printf
 @example
-@code{printf} @var{format} [@var{arguments}]
+@code{printf} [-v @var{var}] @var{format} [@var{arguments}]
 @end example
 Write the formatted @var{arguments} to the standard output under the
 control of the @var{format}.
@@ -3340,9 +3447,16 @@ format specifications, each of which causes printing of the next successive
 @var{argument}.
 In addition to the standard @code{printf(1)} formats, @samp{%b} causes
 @code{printf} to expand backslash escape sequences in the corresponding
-@var{argument}, and @samp{%q} causes @code{printf} to output the
+@var{argument},
+(except that @samp{\c} terminates output, backslashes in
+@samp{\'}, @samp{\"}, and @samp{\?} are not removed, and octal escapes
+beginning with @samp{\0} may contain up to four digits),
+and @samp{%q} causes @code{printf} to output the
 corresponding @var{argument} in a format that can be reused as shell input.
 
+The @option{-v} option causes the output to be assigned to the variable
+@var{var} rather than being printed to the standard output.
+
 The @var{format} is reused as necessary to consume all of the @var{arguments}.
 If the @var{format} requires more @var{arguments} than are supplied, the
 extra format specifications behave as if a zero value or null string, as
@@ -3526,6 +3640,20 @@ If the command run by the @code{DEBUG} trap returns a value of 2, and the
 shell is executing in a subroutine (a shell function or a shell script
 executed by the @code{.} or @code{source} builtins), a call to
 @code{return} is simulated.
+
+@item
+@code{BASH_ARGC} and @code{BASH_ARGV} are updated as described in their
+descriptions (@pxref{Bash Variables}).
+
+@item
+Function tracing is enabled:  command substitution, shell functions, and
+subshells invoked with @code{( @var{command} )} inherit the
+@code{DEBUG} and @code{RETURN} traps.
+
+@item
+Error tracing is enabled:  command substitution, shell functions, and
+subshells invoked with @code{( @var{command} )} inherit the
+@code{ERROR} trap.
 @end enumerate
 
 @item extglob
@@ -3537,6 +3665,21 @@ If set, @code{$'@var{string}'} and @code{$"@var{string}"} quoting is
 performed within @code{$@{@var{parameter}@}} expansions                     
 enclosed in double quotes.  This option is enabled by default. 
 
+@item failglob
+If set, patterns which fail to match filenames during pathname expansion
+result in an expansion error.
+
+@item force_fignore
+If set, the suffixes specified by the @env{FIGNORE} shell variable
+cause words to be ignored when performing word completion even if
+the ignored words are the only possible completions.
+@xref{Bash Variables}, for a description of @env{FIGNORE}.
+This option is enabled by default.
+
+@item gnu_errfmt
+If set, shell error messages are written in the standard @sc{gnu} error
+message format.
+
 @item histappend
 If set, the history list is appended to the file named by the value
 of the @env{HISTFILE}
@@ -3593,6 +3736,11 @@ on an empty line.
 If set, Bash matches filenames in a case-insensitive fashion when
 performing filename expansion.
 
+@item nocasematch
+If set, Bash matches patterns in a case-insensitive fashion when
+performing matching while executing @code{case} or @code{[[}
+conditional commands.
+
 @item nullglob
 If set, Bash allows filename patterns which match no
 files to expand to a null string, rather than themselves.
@@ -3603,8 +3751,10 @@ If set, the programmable completion facilities
 This option is enabled by default.
 
 @item promptvars
-If set, prompt strings undergo variable and parameter expansion after
-being expanded (@pxref{Printing a Prompt}).
+If set, prompt strings undergo
+parameter expansion, command substitution, arithmetic
+expansion, and quote removal after being expanded
+as described below (@pxref{Printing a Prompt}).
 This option is enabled by default.
 
 @item restricted_shell
@@ -3692,7 +3842,7 @@ builtin command.
 @item ulimit
 @btindex ulimit
 @example
-ulimit [-acdflmnpstuvSH] [@var{limit}]
+ulimit [-acdefilmnpqrstuvxSH] [@var{limit}]
 @end example
 @code{ulimit} provides control over the resources available to processes
 started by the shell, on systems that allow such control.  If an
@@ -3713,8 +3863,14 @@ The maximum size of core files created.
 @item -d
 The maximum size of a process's data segment.
 
+@item -e
+The maximum scheduling priority ("nice").
+
 @item -f
-The maximum size of files created by the shell.
+The maximum size of files written by the shell and its children.
+
+@item -i
+The maximum number of pending signals.
 
 @item -l
 The maximum size that may be locked into memory.
@@ -3728,6 +3884,12 @@ The maximum number of open file descriptors.
 @item -p
 The pipe buffer size.
 
+@item -q
+The maximum number of bytes in POSIX message queues.
+
+@item -r
+The maximum real-time scheduling priority.
+
 @item -s
 The maximum stack size.
 
@@ -3740,6 +3902,9 @@ The maximum number of processes available to a single user.
 @item -v
 The maximum amount of virtual memory available to the process.
 
+@item -x
+The maximum number of file locks.
+
 @end table
 
 If @var{limit} is given, it is the new value of the specified resource;
@@ -3779,12 +3944,16 @@ This builtin is so complicated that it deserves its own section.
 @item set
 @btindex set
 @example
-set [--abefhkmnptuvxBCHP] [-o @var{option}] [@var{argument} @dots{}]
+set [--abefhkmnptuvxBCEHPT] [-o @var{option}] [@var{argument} @dots{}]
+set [+abefhkmnptuvxBCEHPT] [+o @var{option}] [@var{argument} @dots{}]
 @end example
 
 If no options or arguments are supplied, @code{set} displays the names
 and values of all shell variables and functions, sorted according to the
-current locale, in a format that may be reused as input.
+current locale, in a format that may be reused as input
+for setting or resetting the currently-set variables.
+Read-only variables cannot be reset.
+In @sc{posix} mode, only shell variables are listed.
 
 When options are supplied, they set or unset shell attributes.
 Options, if specified, have the following meanings:
@@ -3801,10 +3970,11 @@ immediately, rather than before printing the next primary prompt.
 @item -e
 Exit immediately if a simple command (@pxref{Simple Commands}) exits
 with a non-zero status, unless the command that fails is part of the
-command list immediately following a @code{while} or @code{until}
-keyword, part of the test in an @code{if} statement,
-part of a @code{&&} or @code{||} list, or if the command's return
-status is being inverted using @code{!}.
+command list immediately following a @code{while} or @code{until} keyword,
+part of the test in an @code{if} statement,
+part of a @code{&&} or @code{||} list,
+any command in a pipeline but the last,
+or if the command's return status is being inverted using @code{!}.
 A trap on @code{ERR}, if set, is executed before the shell exits.
 
 @item -f
@@ -3893,9 +4063,15 @@ Same as @code{-t}.
 @item physical
 Same as @code{-P}.
 
+@item pipefail
+If set, the return value of a pipeline is the value of the last
+(rightmost) command to exit with a non-zero status, or zero if all
+commands in the pipeline exit successfully.
+This option is disabled by default.
+
 @item posix
 Change the behavior of Bash where the default operation differs
-from the @sc{posix} 1003.2 standard to match the standard
+from the @sc{posix} standard to match the standard
 (@pxref{Bash POSIX Mode}).
 This is intended to make Bash behave as a strict superset of that
 standard.
@@ -3939,8 +4115,8 @@ shell will exit.
 Print shell input lines as they are read.
 
 @item -x
-Print a trace of simple commands, \fBfor\fP commands, \fBcase\fP
-commands, \fBselect\fP commands, and arithmetic \fBfor\fP commands
+Print a trace of simple commands, @code{for} commands, @code{case}
+commands, @code{select} commands, and arithmetic @code{for} commands
 and their arguments or associated word lists after they are
 expanded and before they are executed.  The value of the @env{PS4}
 variable is expanded and the resultant value is printed before
@@ -3989,9 +4165,11 @@ $ cd ..; pwd
 @end example
 
 @item -T
-If set, any trap on @code{DEBUG} is inherited by shell functions, command
-substitutions, and commands executed in a subshell environment.
-The @code{DEBUG} trap is normally not inherited in such cases.
+If set, any trap on @code{DEBUG} and @code{RETURN} are inherited by
+shell functions, command substitutions, and commands executed
+in a subshell environment.
+The @code{DEBUG} and @code{RETURN} traps are normally not inherited
+in such cases.
 
 @item --
 If no arguments follow this option, then the positional parameters are
@@ -4020,7 +4198,7 @@ The return status is always zero unless an invalid option is supplied.
 @section Special Builtins
 @cindex special builtin
 
-For historical reasons, the @sc{posix} 1003.2 standard has classified
+For historical reasons, the @sc{posix} standard has classified
 several builtin commands as @emph{special}.
 When Bash is executing in @sc{posix} mode, the special builtins
 differ from other builtin commands in three respects:
@@ -4142,6 +4320,10 @@ parameters to the current subroutine (shell function or script executed
 with @code{.} or @code{source}) is at the top of the stack.  When a
 subroutine is executed, the number of parameters passed is pushed onto
 @code{BASH_ARGC}.
+The shell sets @code{BASH_ARGC} only when in extended debugging mode
+(see @ref{Bash Builtins}  
+for a description of the @code{extdebug} option to the @code{shopt}
+builtin).
 
 @item BASH_ARGV
 An array variable containing all of the parameters in the current bash
@@ -4149,6 +4331,10 @@ execution call stack.  The final parameter of the last subroutine call
 is at the top of the stack; the first parameter of the initial call is
 at the bottom.  When a subroutine is executed, the parameters supplied
 are pushed onto @code{BASH_ARGV}.
+The shell sets @code{BASH_ARGV} only when in extended debugging mode
+(see @ref{Bash Builtins}  
+for a description of the @code{extdebug} option to the @code{shopt}
+builtin).
 
 @item BASH_COMMAND
 The command currently being executed or about to be executed, unless the
@@ -4167,10 +4353,20 @@ The command argument to the @option{-c} invocation option.
 An array variable whose members are the line numbers in source files
 corresponding to each member of @var{FUNCNAME}.
 @code{$@{BASH_LINENO[$i]@}} is the line number in the source file where
-@code{$@{FUNCNAME[$i + 1]@}} was called.
-The corresponding source file name is @code{$@{BASH_SOURCE[$i + 1]@}}.
+@code{$@{FUNCNAME[$i]@}} was called.
+The corresponding source file name is @code{$@{BASH_SOURCE[$i]@}}.
 Use @code{LINENO} to obtain the current line number.
 
+@item BASH_REMATCH
+An array variable whose members are assigned by the @samp{=~} binary
+operator to the @code{[[} conditional command
+(@pxref{Conditional Constructs}).
+The element with index 0 is the portion of the string
+matching the entire regular expression.
+The element with index @var{n} is the portion of the
+string matching the @var{n}th parenthesized subexpression.
+This variable is read-only.
+
 @item BASH_SOURCE
 An array variable whose members are the source filenames corresponding
 to the elements in the @code{FUNCNAME} array variable.
@@ -4244,6 +4440,8 @@ even if it is subsequently reset.
 @item COMP_WORDS
 An array variable consisting of the individual
 words in the current command line.
+The words are split on shell metacharacters as the shell parser would
+separate them.
 This variable is available only in shell functions invoked by the
 programmable completion facilities (@pxref{Programmable Completion}).
 
@@ -4289,7 +4487,7 @@ An array variable containing the names of all shell functions
 currently in the execution call stack.
 The element with index 0 is the name of any currently-executing
 shell function.
-The bottom-most element is "main".
+The bottom-most element is @code{"main"}.
 This variable exists only when a shell function is executing.
 Assignments to @env{FUNCNAME} have no effect and return an error status.
 If @env{FUNCNAME} is unset, it loses its special properties, even if
@@ -4355,7 +4553,8 @@ default value is @file{~/.bash_history}.
 @item HISTFILESIZE
 The maximum number of lines contained in the history file.  When this
 variable is assigned a value, the history file is truncated, if
-necessary, to contain no more than that number of lines.
+necessary, by removing the oldest entries,
+to contain no more than that number of lines.
 The history file is also truncated to this size after
 writing it when an interactive shell exits.
 The default value is 500.
@@ -4384,6 +4583,13 @@ provides the functionality of @code{ignoreboth}.
 The maximum number of commands to remember on the history list.
 The default value is 500.
 
+@item HISTTIMEFORMAT
+If this variable is set and not null, its value is used as a format string
+for @var{strftime} to print the time stamp associated with each history
+entry displayed by the @code{history} builtin.
+If this variable is set, time stamps are written to the history file so
+they may be preserved across shell sessions.
+
 @item HOSTFILE
 Contains the name of a file in the same format as @file{/etc/hosts} that
 should be read when the shell needs to complete a hostname.
@@ -4529,6 +4735,11 @@ the count to the value assigned, and the expanded value
 becomes the value assigned plus the number of seconds
 since the assignment.
 
+@item SHELL
+The full pathname to the shell is kept in this environment variable.
+If it is not set when the shell starts,
+Bash assigns to it the full pathname of the current user's login shell.
+
 @item SHELLOPTS
 A colon-separated list of enabled shell options.  Each word in
 the list is a valid argument for the @option{-o} option to the
@@ -4596,12 +4807,16 @@ The @code{select} command (@pxref{Conditional Constructs}) terminates
 if input does not arrive after @code{TMOUT} seconds when input is coming
 from a terminal.
 
-In an interative shell, the value is interpreted as
+In an interactive shell, the value is interpreted as
 the number of seconds to wait for input after issuing the primary
 prompt when the shell is interactive.
 Bash terminates after that number of seconds if input does
 not arrive.
 
+@item TMPDIR
+If set, Bash uses its value as the name of a directory in which
+Bash creates temporary files for the shell's use.
+
 @item UID
 The numeric real user id of the current user.  This variable is readonly.
 
@@ -4654,7 +4869,7 @@ option).
 
 @item --dump-po-strings
 A list of all double-quoted strings preceded by @samp{$}
-is printed on the standard ouput
+is printed on the standard output
 in the @sc{gnu} @code{gettext} PO (portable object) file format.
 Equivalent to @option{-D} except for the output format.
 
@@ -4662,7 +4877,7 @@ Equivalent to @option{-D} except for the output format.
 Equivalent to @option{-D}.
 
 @item --help
-Display a usage message on standard output and exit sucessfully.
+Display a usage message on standard output and exit successfully.
 
 @item --init-file @var{filename}
 @itemx --rcfile @var{filename}
@@ -4689,7 +4904,7 @@ invoked as @code{sh}.
 
 @item --posix
 Change the behavior of Bash where the default operation differs
-from the @sc{posix} 1003.2 standard to match the standard.  This
+from the @sc{posix} standard to match the standard.  This
 is intended to make Bash behave as a strict superset of that
 standard.  @xref{Bash POSIX Mode}, for a description of the Bash
 @sc{posix} mode.
@@ -4741,7 +4956,7 @@ when invoking an interactive shell.
 
 @item -D
 A list of all double-quoted strings preceded by @samp{$}
-is printed on the standard ouput.
+is printed on the standard output.
 These are the strings that
 are subject to language translation when the current locale
 is not @code{C} or @code{POSIX} (@pxref{Locale Translation}).
@@ -4791,7 +5006,7 @@ 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.
+This section describes 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}).
@@ -4916,8 +5131,8 @@ the same, but the effective user id is not reset.
 
 An interactive shell
 is one started without non-option arguments, unless @option{-s} is
-specified, without specifiying the @option{-c} option, and
-whose input and output are both
+specified, without specifying the @option{-c} option, and
+whose input and error output are both
 connected to terminals (as determined by @code{isatty(3)}),
 or one started with the @option{-i} option.
 
@@ -5009,7 +5224,7 @@ In the absence of any traps, @code{SIGINT} is caught and handled
 
 @item
 An interactive login shell sends a @code{SIGHUP} to all jobs on exit
-if the @code{hupoxexit} shell option has been enabled (@pxref{Signals}).
+if the @code{huponexit} shell option has been enabled (@pxref{Signals}).
 
 @item
 The @option{-n} invocation option is ignored, and @samp{set -n} has
@@ -5037,6 +5252,7 @@ shell to exit.
 @item
 When running in @sc{posix} mode, a special builtin returning an error
 status will not cause the shell to exit (@pxref{Bash POSIX Mode}).
+
 @item
 A failed @code{exec} will not cause the shell to exit
 (@pxref{Bourne Shell Builtins}).
@@ -5072,6 +5288,9 @@ If the @var{file} argument to one of the primaries is one of
 @file{/dev/stdin}, @file{/dev/stdout}, or @file{/dev/stderr}, file
 descriptor 0, 1, or 2, respectively, is checked.
 
+Unless otherwise specified, primaries that operate on files follow symbolic
+links and operate on the target of the link, rather than the link itself.
+
 @table @code
 @item -a @var{file}
 True if @var{file} exists.
@@ -5285,7 +5504,7 @@ omitted, then base 10 is used.
 The digits greater than 9 are represented by the lowercase letters,
 the uppercase letters, @samp{@@}, and @samp{_}, in that order.
 If @var{base} is less than or equal to 36, lowercase and uppercase
-letters may be used interchangably to represent numbers between 10
+letters may be used interchangeably to represent numbers between 10
 and 35.
 
 Operators are evaluated in order of precedence.  Sub-expressions in
@@ -5304,13 +5523,15 @@ the @code{alias} and @code{unalias} builtin commands.
 The first word of each simple command, if unquoted, is checked to see
 if it has an alias.
 If so, that word is replaced by the text of the alias.
-The alias name and the replacement text may contain any valid
-shell input, including shell metacharacters, with the exception
-that the alias name may not contain @samp{=}.
+The characters @samp{/}, @samp{$}, @samp{`}, @samp{=} and any of the
+shell metacharacters or quoting characters listed above may not appear
+in an alias name.
+The replacement text may contain any valid
+shell input, including shell metacharacters.
 The first word of the replacement text is tested for
 aliases, but a word that is identical to an alias being expanded
-is not expanded a second time.  This means that one may alias
-@code{ls} to @code{"ls -F"},
+is not expanded a second time.
+This means that one may alias @code{ls} to @code{"ls -F"},
 for instance, and Bash does not try to recursively expand the
 replacement text. If the last character of the alias value is a
 space or tab character, then the next command word following the
@@ -5403,12 +5624,18 @@ The braces are required to avoid
 conflicts with the shell's filename expansion operators.  If the
 @var{subscript} is @samp{@@} or @samp{*}, the word expands to all members
 of the array @var{name}.  These subscripts differ only when the word
-appears within double quotes.  If the word is double-quoted,
+appears within double quotes.
+If the word is double-quoted,
 @code{$@{name[*]@}} expands to a single word with
 the value of each array member separated by the first character of the
 @env{IFS} variable, and @code{$@{name[@@]@}} expands each element of
 @var{name} to a separate word.  When there are no array members,
-@code{$@{name[@@]@}} expands to nothing.  This is analogous to the
+@code{$@{name[@@]@}} expands to nothing.
+If the double-quoted expansion occurs within a word, the expansion of
+the first parameter is joined with the beginning part of the original
+word, and the expansion of the last parameter is joined with the last
+part of the original word.
+This is analogous to the
 expansion of the special parameters @samp{@@} and @samp{*}. 
 @code{$@{#name[}@var{subscript}@code{]@}} expands to the length of
 @code{$@{name[}@var{subscript}@code{]@}}.
@@ -5420,6 +5647,8 @@ referencing element zero.
 The @code{unset} builtin is used to destroy arrays.
 @code{unset} @var{name}[@var{subscript}]
 destroys the array element at index @var{subscript}.
+Care must be taken to avoid unwanted side effects caused by filename
+generation.
 @code{unset} @var{name}, where @var{name} is an array, removes the
 entire array. A subscript of @samp{*} or @samp{@@} also removes the
 entire array.
@@ -5516,7 +5745,7 @@ from the stack, so that only the stack is manipulated.
 @btindex pushd
 @item pushd
 @example
-pushd [@var{dir} | @var{+N} | @var{-N}] [-n]
+pushd [-n] [@var{+N} | @var{-N} | @var{dir} ]
 @end example
 
 Save the current directory on the top of the directory stack
@@ -5524,6 +5753,9 @@ and then @code{cd} to @var{dir}.
 With no arguments, @code{pushd} exchanges the top two directories.
 
 @table @code
+@item -n
+Suppresses the normal change of directory when adding directories
+to the stack, so that only the stack is manipulated.
 @item +@var{N}
 Brings the @var{N}th directory (counting from the left of the
 list printed by @code{dirs}, starting with zero) to the top of
@@ -5532,9 +5764,6 @@ the list by rotating the stack.
 Brings the @var{N}th directory (counting from the right of the
 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.
 @item @var{dir}
 Makes the current working directory be the top of the stack, and then
 executes the equivalent of `@code{cd} @var{dir}'.
@@ -5596,9 +5825,9 @@ The version of Bash (e.g., 2.00)
 @item \V
 The release of Bash, version + patchlevel (e.g., 2.00.0)
 @item \w
-The current working directory.
+The current working directory, with @env{$HOME} abbreviated with a tilde.
 @item \W
-The basename of @env{$PWD}.
+The basename of @env{$PWD}, with @env{$HOME} abbreviated with a tilde.
 @item \!
 The history number of this command.
 @item \#
@@ -5688,7 +5917,7 @@ the shell spawned to execute the script.
 
 Starting Bash with the @option{--posix} command-line option or executing
 @samp{set -o posix} while Bash is running will cause Bash to conform more
-closely to the @sc{posix} 1003.2 standard by changing the behavior to
+closely to the @sc{posix} standard by changing the behavior to
 match that specified by @sc{posix} in areas where the Bash default differs.
 
 When invoked as @code{sh}, Bash enters @sc{posix} mode after reading the
@@ -5712,20 +5941,22 @@ is stopped is `Stopped(@var{signame})', where @var{signame} is, for
 example, @code{SIGTSTP}.
 
 @item
-Reserved words may not be aliased.
+The @code{bg} builtin uses the required format to describe each job placed
+in the background, which does not include an indication of whether the job
+is the current or previous job.
 
 @item
-The @sc{posix} 1003.2 @env{PS1} and @env{PS2} expansions of @samp{!} to
+Reserved words appearing in a context where reserved words are recognized
+do not undergo alias expansion.
+
+@item
+The @sc{posix} @env{PS1} and @env{PS2} expansions of @samp{!} to
 the history number and @samp{!!} to @samp{!} are enabled,
 and parameter expansion is performed on the values of @env{PS1} and
 @env{PS2} regardless of the setting of the @code{promptvars} option.
 
 @item
-Interactive comments are enabled by default.  (Bash has them on by
-default anyway.)
-
-@item
-The @sc{posix} 1003.2 startup files are executed (@env{$ENV}) rather than
+The @sc{posix} startup files are executed (@env{$ENV}) rather than
 the normal Bash files.
 
 @item
@@ -5738,7 +5969,11 @@ default value of @env{$HISTFILE}).
 
 @item
 The output of @samp{kill -l} prints all the signal names on a single line,
-separated by spaces.
+separated by spaces, without the @samp{SIG} prefix.
+
+@item
+The @code{kill} builtin does not accept signal names with a @samp{SIG}
+prefix.
 
 @item
 Non-interactive shells exit if @var{filename} in @code{.} @var{filename}
@@ -5763,22 +5998,16 @@ may not start with a digit.  Declaring a function with an invalid name
 causes a fatal syntax error in non-interactive shells.
 
 @item
-@sc{posix} 1003.2 `special' builtins are found before shell functions
+@sc{posix} special builtins are found before shell functions
 during command lookup.
 
 @item
-If a @sc{posix} 1003.2 special builtin returns an error status, a
+If a @sc{posix} special builtin returns an error status, a
 non-interactive shell exits.  The fatal errors are those listed in
-the POSIX.2 standard, and include things like passing incorrect options,
+the POSIX standard, and include things like passing incorrect options,
 redirection errors, variable assignment errors for assignments preceding
 the command name, and so on.
 
-@item
-If the @code{cd} builtin finds a directory to change to
-using @env{$CDPATH}, the
-value it assigns to the @env{PWD} variable does not contain any
-symbolic links, as if @samp{cd -P} had been executed.
-
 @item
 If @env{CDPATH} is set, the @code{cd} builtin will not implicitly
 append the current directory to it.  This means that @code{cd} will
@@ -5803,7 +6032,7 @@ variable in a @code{for} statement or the selection variable in a
 Process substitution is not available.
 
 @item
-Assignment statements preceding @sc{posix} 1003.2 special builtins
+Assignment statements preceding @sc{posix} special builtins
 persist in the shell environment after the builtin completes.
 
 @item
@@ -5813,12 +6042,20 @@ special builtin command had been executed.
 
 @item
 The @code{export} and @code{readonly} builtin commands display their
-output in the format required by @sc{posix} 1003.2.
+output in the format required by @sc{posix}.
 
 @item
 The @code{trap} builtin displays signal names without the leading
 @code{SIG}.
 
+@item
+The @code{trap} builtin doesn't check the first argument for a possible
+signal specification and revert the signal handling to the original
+disposition if it is, unless that argument consists solely of digits and
+is a valid signal number.  If users want to reset the handler for a given
+signal to the original disposition, they should use @samp{-} as the
+first argument.
+
 @item
 The @code{.} and @code{source} builtins do not search the current directory
 for the filename argument if it is not found by searching @env{PATH}.
@@ -5831,6 +6068,11 @@ Bash clears the @option{-e} option in such subshells.
 @item
 Alias expansion is always enabled, even in non-interactive shells.
 
+@item
+When the @code{alias} builtin displays alias definitions, it does not
+display them with a leading @samp{alias } unless the @option{-p} option
+is supplied.
+
 @item
 When the @code{set} builtin is invoked without options, it does not display
 shell function names and definitions.
@@ -5845,29 +6087,61 @@ When the @code{cd} builtin is invoked in @var{logical} mode, and the pathname
 constructed from @code{$PWD} and the directory name supplied as an argument
 does not refer to an existing directory, @code{cd} will fail instead of
 falling back to @var{physical} mode.
+
+@item
+When the @code{pwd} builtin is supplied the @option{-P} option, it resets
+@code{$PWD} to a pathname containing no symlinks.
+
+@item
+The @code{pwd} builtin verifies that the value it prints is the same as the
+current directory, even if it is not asked to check the file system with the
+@option{-P} option.
+
+@item
+When listing the history, the @code{fc} builtin does not include an
+indication of whether or not a history entry has been modified.
+
+@item
+The default editor used by @code{fc} is @code{ed}.
+
+@item
+The @code{type} and @code{command} builtins will not report a non-executable
+file as having been found, though the shell will attempt to execute such a
+file if it is the only so-named file found in @code{$PATH}.
+
+@item
+The @code{vi} editing mode will invoke the @code{vi} editor directly when
+the @samp{v} command is run, instead of checking @code{$FCEDIT} and
+@code{$EDITOR}.
+
+@item
+When the @code{xpg_echo} option is enabled, Bash does not attempt to interpret
+any arguments to @code{echo} as options.  Each argument is displayed, after
+escape characters are converted.
+
 @end enumerate
 
-There is other @sc{posix} 1003.2 behavior that Bash does not implement.
+There is other @sc{posix} behavior that Bash does not implement by
+default even when in @sc{posix} mode.
 Specifically:
 
 @enumerate
-@item
-Assignment statements affect the execution environment of all
-builtins, not just special ones.
 
 @item
-When a subshell is created to execute a shell script with execute permission,
-but without a leading @samp{#!}, Bash sets @code{$0} to the full pathname of
-the script as found by searching @code{$PATH}, rather than the command as
-typed by the user.
+The @code{fc} builtin checks @code{$EDITOR} as a program to edit history
+entries if @code{FCEDIT} is unset, rather than defaulting directly to
+@code{ed}.  @code{fc} uses @code{ed} if @code{EDITOR} is unset.
 
 @item
-When using @samp{.} to source a shell script found in @code{$PATH}, bash
-checks execute permission bits rather than read permission bits, just as
-if it were searching for a command.
+As noted above, Bash requires the @code{xpg_echo} option to be enabled for
+the @code{echo} builtin to be fully conformant.
 
 @end enumerate
 
+Bash can be configured to be @sc{posix}-conformant by default, by specifying
+the @option{--enable-strict-posix-default} to @code{configure} when building
+(@pxref{Optional Features}).
+
 @node Job Control
 @chapter Job Control
 
@@ -5943,11 +6217,12 @@ There are a number of ways to refer to a job in the shell.  The
 character @samp{%} introduces a job name.
 
 Job number @code{n} may be referred to as @samp{%n}.
-The symbols @samp{%%} and
-@samp{%+} refer to the shell's notion of the current job, which
-is the last job stopped while it was in the foreground or started
-in the background.  The
-previous job may be referenced using @samp{%-}.  In output
+The symbols @samp{%%} and  @samp{%+} refer to the shell's notion of the
+current job, which is the last job stopped while it was in the foreground
+or started in the background.
+A single @samp{%} (with no accompanying job specification) also refers
+to the current job.
+The previous job may be referenced using @samp{%-}.  In output
 pertaining to jobs (e.g., the output of the @code{jobs} command),
 the current job is always flagged with a @samp{+}, and the
 previous job with a @samp{-}. 
@@ -5974,7 +6249,7 @@ Bash reports such changes immediately (@pxref{The Set Builtin}).
 Any trap on @code{SIGCHLD} is executed for each child process
 that exits.
 
-If an attempt to exit Bash is while jobs are stopped, the
+If an attempt to exit Bash is made while jobs are stopped, the
 shell prints a message warning that there are stopped jobs.
 The @code{jobs} command may then be used to inspect their status.
 If a second attempt to exit is made without an intervening command,
@@ -5988,15 +6263,15 @@ Bash does not print another warning, and the stopped jobs are terminated.
 @item bg
 @btindex bg
 @example
-bg [@var{jobspec}]
+bg [@var{jobspec} @dots{}]
 @end example
-Resume the suspended job @var{jobspec} in the background, as if it
+Resume each suspended job @var{jobspec} in the background, as if it
 had been started with @samp{&}.
 If @var{jobspec} is not supplied, the current job is used.
 The return status is zero unless it is run when job control is not
-enabled, or, when run with job control enabled, if @var{jobspec} was
-not found or @var{jobspec} specifies a job that was started without
-job control.
+enabled, or, when run with job control enabled, any
+@var{jobspec} was not found or specifies a job
+that was started without job control.
 
 @item fg
 @btindex fg
@@ -6056,8 +6331,9 @@ kill -l [@var{exit_status}]
 @end example
 Send a signal specified by @var{sigspec} or @var{signum} to the process
 named by job specification @var{jobspec} or process @sc{id} @var{pid}.
-@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.
+@var{sigspec} is either a case-insensitive 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 @option{-l} option lists the signal names.
 If any arguments are supplied when @option{-l} is given, the names of the
@@ -6071,11 +6347,11 @@ or non-zero if an error occurs or an invalid option is encountered.
 @item wait
 @btindex wait
 @example
-wait [@var{jobspec} or @var{pid}]
+wait [@var{jobspec} or @var{pid} ...]
 @end example
-Wait until the child process specified by process @sc{id} @var{pid} or job
-specification @var{jobspec} exits and return the exit status of the last
-command waited for.
+Wait until the child process specified by each process @sc{id} @var{pid}
+or job specification @var{jobspec} exits and return the exit status of the
+last command waited for.
 If a job spec is given, all processes in the job are waited for.
 If no arguments are given, all currently active child processes are
 waited for, and the return status is zero.
@@ -6155,27 +6431,20 @@ the various supported platforms.  The distribution supports the
 @sc{gnu} operating systems, nearly every version of Unix, and several
 non-Unix systems such as BeOS and Interix.
 Other independent ports exist for
-@sc{ms-dos}, @sc{os/2}, Windows @sc{95/98}, and Windows @sc{nt}.
+@sc{ms-dos}, @sc{os/2}, and Windows platforms.
 
 @menu
 * Basic Installation:: Installation instructions.
-
 * Compilers and Options::      How to set special options for various
                                systems.
-
 * Compiling For Multiple Architectures::       How to compile Bash for more
                                                than one kind of system from
                                                the same source tree.
-
 * Installation Names:: How to set the various paths used by the installation.
-
 * Specifying the System Type:: How to configure Bash for a particular system.
-
 * Sharing Defaults::   How to share default configuration values among GNU
                        programs.
-
 * Operation Controls:: Options recognized by the configuration program.
-
 * Optional Features::  How to enable and disable optional features when
                        building Bash.
 @end menu
@@ -6416,10 +6685,10 @@ Define if you are using the Andrew File System from Transarc.
 
 @item --with-bash-malloc
 Use the Bash version of
-@code{malloc} in @file{lib/malloc/malloc.c}.  This is not the same
+@code{malloc} in the directory @file{lib/malloc}.  This is not the same
 @code{malloc} that appears in @sc{gnu} libc, but an older version
-derived from the 4.2 @sc{bsd} @code{malloc}.  This @code{malloc} is
-very fast, but wastes some space on each allocation.
+originally derived from the 4.2 @sc{bsd} @code{malloc}.  This @code{malloc}
+is very fast, but wastes some space on each allocation.
 This option is enabled by default.
 The @file{NOTES} file contains a list of systems for
 which this should be turned off, and @code{configure} disables this
@@ -6436,7 +6705,7 @@ A synonym for @code{--with-bash-malloc}.
 @item --with-installed-readline[=@var{PREFIX}]
 Define this to make Bash link with a locally-installed version of Readline
 rather than the version in @file{lib/readline}.  This works only with
-Readline 4.3 and later versions.  If @var{PREFIX} is @code{yes} or not
+Readline 5.0 and later versions.  If @var{PREFIX} is @code{yes} or not
 supplied, @code{configure} uses the values of the make variables
 @code{includedir} and @code{libdir}, which are subdirectories of @code{prefix}
 by default, to find the installed version of Readline if it is not in
@@ -6516,9 +6785,17 @@ displaying timing statistics for the pipeline following @code{time}
 This allows pipelines as well as shell builtins and functions to be timed.
 
 @item --enable-cond-command
-Include support for the @code{[[} conditional command
+Include support for the @code{[[} conditional command.
 (@pxref{Conditional Constructs}).
 
+@item --enable-cond-regexp
+Include support for matching POSIX regular expressions using the
+@samp{=~} binary operator in the @code{[[} conditional command.
+(@pxref{Conditional Constructs}).
+
+@item --enable-debugger
+Include support for the bash debugger (distributed separately).
+
 @item --enable-directory-stack
 Include support for a @code{csh}-like directory stack and the
 @code{pushd}, @code{popd}, and @code{dirs} builtins
@@ -6564,17 +6841,17 @@ when used in redirections (@pxref{Redirections}).
 This enables process substitution (@pxref{Process Substitution}) if
 the operating system provides the necessary support.
 
+@item --enable-progcomp
+Enable the programmable completion facilities
+(@pxref{Programmable Completion}).
+If Readline is not enabled, this option has no effect.
+
 @item --enable-prompt-string-decoding
 Turn on the interpretation of a number of backslash-escaped characters
 in the @env{$PS1}, @env{$PS2}, @env{$PS3}, and @env{$PS4} prompt
 strings.  See @ref{Printing a Prompt}, for a complete list of prompt
 string escape sequences.
 
-@item --enable-progcomp
-Enable the programmable completion facilities
-(@pxref{Programmable Completion}).
-If Readline is not enabled, this option has no effect.
-
 @item --enable-readline
 Include support for command-line editing and history with the Bash
 version of the Readline library (@pxref{Command Line Editing}).
@@ -6588,6 +6865,19 @@ when called as @code{rbash}, enters a restricted mode.  See
 Include the @code{select} builtin, which allows the generation of simple
 menus (@pxref{Conditional Constructs}).
 
+@item --enable-separate-helpfiles
+Use external files for the documentation displayed by the @code{help} builtin
+instead of storing the text internally.
+
+@item --enable-single-help-strings
+Store the text displayed by the @code{help} builtin as a single string for
+each help topic.  This aids in translating the text to different languages.
+You may need to disable this if your compiler cannot handle very long string
+literals.
+
+@item --enable-strict-posix-default
+Make Bash @sc{posix}-conformant by default (@pxref{Bash POSIX Mode}).
+
 @item --enable-usg-echo-default
 A synonym for @code{--enable-xpg-echo-default}.
 
@@ -6596,7 +6886,7 @@ Make the @code{echo} builtin expand backslash-escaped characters by default,
 without requiring the @option{-e} option.
 This sets the default value of the @code{xpg_echo} shell option to @code{on},
 which makes the Bash @code{echo} behave more like the version specified in
-the Single Unix Specification, version 2.
+the Single Unix Specification, version 3.
 @xref{Bash Builtins}, for a description of the escape sequences that
 @code{echo} recognizes.
 
@@ -6654,14 +6944,14 @@ Please send all reports concerning this manual to
 
 Bash implements essentially the same grammar, parameter and
 variable expansion, redirection, and quoting as the Bourne Shell. 
-Bash uses the @sc{posix} 1003.2 standard as the specification of
+Bash uses the @sc{posix} standard as the specification of
 how these features are to be implemented.  There are some
 differences between the traditional Bourne shell and Bash; this
 section quickly details the differences of significance.  A
 number of these differences are explained in greater depth in
 previous sections.
-This section uses the version of @code{sh} included in SVR4.2 as
-the baseline reference.
+This section uses the version of @code{sh} included in SVR4.2 (the
+last version of the historical Bourne shell) as the baseline reference.
 
 @itemize @bullet
 
@@ -6684,6 +6974,8 @@ Bash provides a programmable word completion mechanism
 @item
 Bash has command history (@pxref{Bash History Facilities}) and the
 @code{history} and @code{fc} builtins to manipulate it.
+The Bash history list maintains timestamp information and uses the
+value of the @code{HISTTIMEFORMAT} variable to display it.
 
 @item
 Bash implements @code{csh}-like history expansion
@@ -6711,6 +7003,8 @@ invocation options list the translatable strings found in a script
 Bash implements the @code{!} keyword to negate the return value of
 a pipeline (@pxref{Pipelines}).
 Very useful when an @code{if} statement needs to act only if a test fails.
+The Bash @samp{-o pipefail} option to @code{set} will cause a pipeline to
+return a failure status if any command fails.
 
 @item
 Bash has the @code{time} reserved word and command timing (@pxref{Pipelines}).
@@ -6727,7 +7021,12 @@ generation of simple menus (@pxref{Conditional Constructs}).
 
 @item
 Bash includes the @code{[[} compound command, which makes conditional
-testing part of the shell grammar (@pxref{Conditional Constructs}).
+testing part of the shell grammar (@pxref{Conditional Constructs}), including
+optional regular expression matching.
+
+@item
+Bash provides optional case-insensitive matching for the @code{case} and
+@code{[[} constructs.
 
 @item
 Bash includes brace expansion (@pxref{Brace Expansion}) and tilde
@@ -6748,6 +7047,10 @@ exported to child processes.  The Bourne shell does not normally do
 this unless the variables are explicitly marked using the @code{export}
 command.
 
+@item
+Bash supports the @samp{+=} assignment operator, which appends to the value
+of the variable named on the left hand side.
+
 @item
 Bash includes the @sc{posix} pattern removal @samp{%}, @samp{#}, @samp{%%}
 and @samp{##} expansions to remove leading or trailing substrings from
@@ -6805,7 +7108,7 @@ not all words (@pxref{Word Splitting}).
 This closes a longstanding shell security hole.
 
 @item
-Bash implements the full set of @sc{posix} 1003.2 filename expansion operators,
+Bash implements the full set of @sc{posix} filename expansion operators,
 including @var{character classes}, @var{equivalence classes}, and
 @var{collating symbols} (@pxref{Filename Expansion}).
 
@@ -6839,6 +7142,14 @@ opened for both reading and writing, and the @samp{&>} redirection
 operator, for directing standard output and standard error to the same
 file (@pxref{Redirections}).
 
+@item
+Bash includes the @samp{<<<} redirection operator, allowing a string to
+be used as the standard input to a command.
+
+@item
+Bash implements the @samp{[n]<&@var{word}} and @samp{[n]>&@var{word}}
+redirection operators, which move one file descriptor to another.
+
 @item
 Bash treats a number of filenames specially when they are
 used in redirection operators (@pxref{Redirections}).
@@ -6932,11 +7243,22 @@ to be set and unset at shell invocation (@pxref{Invoking Bash}).
 Bash has much more optional behavior controllable with the @code{set}
 builtin (@pxref{The Set Builtin}).
 
+@item
+The @samp{-x} (@code{xtrace}) option displays commands other than
+simple commands when performing an execution trace
+(@pxref{The Set Builtin}).
+
 @item
 The @code{test} builtin (@pxref{Bourne Shell Builtins})
 is slightly different, as it implements the @sc{posix} algorithm,
 which specifies the behavior based on the number of arguments.
 
+@item
+Bash includes the @code{caller} builtin, which displays the context of
+any active subroutine call (a shell function or a script executed with
+the @code{.} or @code{source} builtins).  This supports the bash
+debugger.
+
 @item
 The @code{trap} builtin (@pxref{Bourne Shell Builtins}) allows a
 @code{DEBUG} pseudo-signal specification, similar to @code{EXIT}.
@@ -6963,7 +7285,9 @@ The @code{trap} builtin (@pxref{Bourne Shell Builtins}) allows a
 Commands specified with an @code{RETURN} trap are executed before
 execution resumes after a shell function or a shell script executed with
 @code{.} or @code{source} returns.
-The @code{RETURN} trap is not inherited by shell functions.
+The @code{RETURN} trap is not inherited by shell functions unless the
+function has been given the @code{trace} attribute or the
+@code{functrace} option has been enabled using the @code{shopt} builtin.
 
 @item
 The Bash @code{type} builtin is more extensive and gives more information
@@ -6995,6 +7319,10 @@ job table (@pxref{Job Control Builtins}) or suppress the sending
 of @code{SIGHUP} to a job when the shell exits as the result of a
 @code{SIGHUP}.
 
+@item
+Bash includes a number of features to support a separate debugger for
+shell scripts.
+
 @item
 The SVR4.2 shell has two privilege-related builtins
 (@code{mldmode} and @code{priv}) not present in Bash.
@@ -7065,8 +7393,8 @@ with a @samp{-}.
 
 @item
 The SVR4.2 shell exits a script if any builtin fails; Bash exits
-a script only if one of the @sc{posix} 1003.2 special builtins fails, and
-only for certain failures, as enumerated in the @sc{posix} 1003.2 standard.
+a script only if one of the @sc{posix} special builtins fails, and
+only for certain failures, as enumerated in the @sc{posix} standard.
 
 @item 
 The SVR4.2 shell behaves differently when invoked as @code{jsh}
diff --git a/doc/bashref.texi.save1 b/doc/bashref.texi.save1
new file mode 100644 (file)
index 0000000..3424599
--- /dev/null
@@ -0,0 +1,7445 @@
+\input texinfo.tex @c -*- texinfo -*-
+@c %**start of header
+@setfilename bashref.info
+@settitle Bash Reference Manual
+@c %**end of header
+
+@setchapternewpage odd
+
+@include version.texi
+
+@copying
+This text is a brief description of the features that are present in
+the Bash shell (version @value{VERSION}, @value{UPDATED}).
+
+This is Edition @value{EDITION}, last updated @value{UPDATED},
+of @cite{The GNU Bash Reference Manual},
+for @code{Bash}, Version @value{VERSION}.
+
+Copyright @copyright{} 1988-2005 Free Software Foundation, Inc.
+
+Permission is granted to make and distribute verbatim copies of
+this manual provided the copyright notice and this permission notice
+are preserved on all copies.
+
+@quotation
+Permission is granted to copy, distribute and/or modify this document
+under the terms of the GNU Free Documentation License, Version 1.2 or
+any later version published by the Free Software Foundation; with no
+Invariant Sections, with the Front-Cover texts being ``A GNU Manual,''
+and with the Back-Cover Texts as in (a) below.  A copy of the license is
+included in the section entitled ``GNU Free Documentation License.''
+
+(a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
+this GNU Manual, like GNU software.  Copies published by the Free
+Software Foundation raise funds for GNU development.''
+@end quotation
+@end copying
+
+@defcodeindex bt
+@defcodeindex rw
+@set BashFeatures
+
+@dircategory Basics
+@direntry
+* Bash: (bash).                     The GNU Bourne-Again SHell.
+@end direntry
+
+@finalout
+
+@titlepage
+@title Bash Reference Manual
+@subtitle Reference Documentation for Bash
+@subtitle Edition @value{EDITION}, for @code{Bash} Version @value{VERSION}.
+@subtitle @value{UPDATED-MONTH}
+@author Chet Ramey, Case Western Reserve University
+@author Brian Fox, Free Software Foundation
+
+@page
+@vskip 0pt plus 1filll
+@insertcopying
+
+@sp 1
+Published by the Free Software Foundation @*
+59 Temple Place, Suite 330, @*
+Boston, MA 02111-1307 @*
+USA @*
+
+@end titlepage
+
+@contents
+
+@ifnottex
+@node Top, Introduction, (dir), (dir)
+@top Bash Features
+
+This text is a brief description of the features that are present in
+the Bash shell (version @value{VERSION}, @value{UPDATED}).
+
+This is Edition @value{EDITION}, last updated @value{UPDATED},
+of @cite{The GNU Bash Reference Manual},
+for @code{Bash}, Version @value{VERSION}.
+
+Bash contains features that appear in other popular shells, and some
+features that only appear in Bash.  Some of the shells that Bash has
+borrowed concepts from are the Bourne Shell (@file{sh}), the Korn Shell
+(@file{ksh}), and the C-shell (@file{csh} and its successor,
+@file{tcsh}). The following menu breaks the features up into
+categories based upon which one of these other shells inspired the
+feature.
+
+This manual is meant as a brief introduction to features found in
+Bash.  The Bash manual page should be used as the definitive
+reference on shell behavior.
+
+@menu
+* Introduction::               An introduction to the shell.
+* Definitions::                        Some definitions used in the rest of this
+                               manual.
+* Basic Shell Features::       The shell "building blocks".
+* Shell Builtin Commands::     Commands that are a part of the shell.
+* Shell Variables::            Variables used or set by Bash.
+* Bash Features::              Features found only in Bash.
+* Job Control::                        What job control is and how Bash allows you
+                               to use it.
+* Using History Interactively::        Command History Expansion
+* Command Line Editing::       Chapter describing the command line
+                               editing features.
+* Installing Bash::            How to build and install Bash on your system.
+* Reporting Bugs::             How to report bugs in Bash.
+* Major Differences From The Bourne Shell::    A terse list of the differences
+                                               between Bash and historical
+                                               versions of /bin/sh.
+* Copying This Manual::                Copying this manual.
+* Builtin Index::              Index of Bash builtin commands.
+* Reserved Word Index::                Index of Bash reserved words.
+* Variable Index::             Quick reference helps you find the
+                               variable you want.
+* Function Index::             Index of bindable Readline functions.
+* Concept Index::              General index for concepts described in
+                               this manual.
+@end menu
+@end ifnottex
+
+@node Introduction
+@chapter Introduction
+@menu
+* What is Bash?::              A short description of Bash.
+* What is a shell?::           A brief introduction to shells.
+@end menu
+
+@node What is Bash?
+@section What is Bash?
+
+Bash is the shell, or command language interpreter,
+for the @sc{gnu} operating system.
+The name is an acronym for the @samp{Bourne-Again SHell},
+a pun on Stephen Bourne, the author of the direct ancestor of
+the current Unix shell @code{sh}, 
+which appeared in the Seventh Edition Bell Labs Research version
+of Unix.
+
+Bash is largely compatible with @code{sh} and incorporates useful
+features from the Korn shell @code{ksh} and the C shell @code{csh}.
+It is intended to be a conformant implementation of the @sc{ieee}
+@sc{posix} Shell and Tools portion of the @sc{ieee} @sc{posix}
+specification (@sc{ieee} Standard 1003.1).
+It offers functional improvements over @code{sh} for both interactive and
+programming use.
+
+While the @sc{gnu} operating system provides other shells, including
+a version of @code{csh}, Bash is the default shell.
+Like other @sc{gnu} software, Bash is quite portable.  It currently runs
+on nearly every version of Unix and a few other operating systems @minus{}
+independently-supported ports exist for @sc{ms-dos}, @sc{os/2},
+and Windows platforms.
+
+@node What is a shell?
+@section What is a shell?
+
+At its base, a shell is simply a macro processor that executes
+commands.  The term macro processor means functionality where text
+and symbols are expanded to create larger expressions.
+
+A Unix shell is both a command interpreter and a programming
+language.  As a command interpreter, the shell provides the user
+interface to the rich set of @sc{gnu} utilities.  The programming
+language features allow these utilities to be combined.
+Files containing commands can be created, and become
+commands themselves.  These new commands have the same status as
+system commands in directories such as @file{/bin}, allowing users
+or groups to establish custom environments to automate their common
+tasks.
+
+Shells may be used interactively or non-interactively.  In
+interactive mode, they accept input typed from the keyboard.
+When executing non-interactively, shells execute commands read
+from a file.
+
+A shell allows execution of @sc{gnu} commands, both synchronously and
+asynchronously.
+The shell waits for synchronous commands to complete before accepting
+more input; asynchronous commands continue to execute in parallel
+with the shell while it reads and executes additional commands.
+The @dfn{redirection} constructs permit
+fine-grained control of the input and output of those commands.
+Moreover, the shell allows control over the contents of commands'
+environments.
+
+Shells also provide a small set of built-in
+commands (@dfn{builtins}) implementing functionality impossible
+or inconvenient to obtain via separate utilities.
+For example, @code{cd}, @code{break}, @code{continue}, and
+@code{exec}) cannot be implemented outside of the shell because
+they directly manipulate the shell itself.
+The @code{history}, @code{getopts}, @code{kill}, or @code{pwd}
+builtins, among others, could be implemented in separate utilities,
+but they are more convenient to use as builtin commands.
+All of the shell builtins are described in
+subsequent sections.
+
+While executing commands is essential, most of the power (and
+complexity) of shells is due to their embedded programming
+languages.  Like any high-level language, the shell provides
+variables, flow control constructs, quoting, and functions. 
+
+Shells offer features geared specifically for
+interactive use rather than to augment the programming language. 
+These interactive features include job control, command line
+editing, command history and aliases.  Each of these features is
+described in this manual.
+
+@node Definitions
+@chapter Definitions
+These definitions are used throughout the remainder of this manual.
+
+@table @code
+
+@item POSIX
+@cindex POSIX
+A family of open system standards based on Unix.  Bash
+is primarily concerned with the Shell and Utilities portion of the
+@sc{posix} 1003.1 standard. 
+
+@item blank
+A space or tab character.
+
+@item builtin
+@cindex builtin
+A command that is implemented internally by the shell itself, rather
+than by an executable program somewhere in the file system.
+
+@item control operator
+@cindex control operator
+A @code{word} that performs a control function.  It is a @code{newline}
+or one of the following:
+@samp{||}, @samp{&&}, @samp{&}, @samp{;}, @samp{;;},
+@samp{|}, @samp{(}, or @samp{)}.
+
+@item exit status
+@cindex exit status
+The value returned by a command to its caller.  The value is restricted
+to eight bits, so the maximum value is 255.
+
+@item field
+@cindex field
+A unit of text that is the result of one of the shell expansions.  After
+expansion, when executing a command, the resulting fields are used as
+the command name and arguments.
+
+@item filename
+@cindex filename
+A string of characters used to identify a file.
+
+@item job
+@cindex job
+A set of processes comprising a pipeline, and any processes descended
+from it, that are all in the same process group.
+
+@item job control
+@cindex job control
+A mechanism by which users can selectively stop (suspend) and restart
+(resume) execution of processes.
+
+@item metacharacter
+@cindex metacharacter
+A character that, when unquoted, separates words.  A metacharacter is
+a @code{blank} or one of the following characters:
+@samp{|}, @samp{&}, @samp{;}, @samp{(}, @samp{)}, @samp{<}, or
+@samp{>}.
+
+@item name
+@cindex name
+@cindex identifier
+A @code{word} consisting solely of letters, numbers, and underscores,
+and beginning with a letter or underscore.  @code{Name}s are used as
+shell variable and function names.
+Also referred to as an @code{identifier}.
+
+@item operator
+@cindex operator, shell
+A @code{control operator} or a @code{redirection operator}.
+@xref{Redirections}, for a list of redirection operators.
+
+@item process group
+@cindex process group
+A collection of related processes each having the same process
+group @sc{id}.
+
+@item process group ID
+@cindex process group ID
+A unique identifier that represents a @code{process group}
+during its lifetime.
+
+@item reserved word
+@cindex reserved word
+A @code{word} that has a special meaning to the shell.  Most reserved
+words introduce shell flow control constructs, such as @code{for} and
+@code{while}.
+
+@item return status
+@cindex return status
+A synonym for @code{exit status}.
+
+@item signal
+@cindex signal
+A mechanism by which a process may be notified by the kernel
+of an event occurring in the system.
+
+@item special builtin
+@cindex special builtin
+A shell builtin command that has been classified as special by the
+@sc{posix} standard.
+
+@item token
+@cindex token
+A sequence of characters considered a single unit by the shell.  It is
+either a @code{word} or an @code{operator}.
+
+@item word
+@cindex word
+A @code{token} that is not an @code{operator}.
+@end table
+
+@node Basic Shell Features
+@chapter Basic Shell Features
+@cindex Bourne shell
+
+Bash is an acronym for @samp{Bourne-Again SHell}.
+The Bourne shell is
+the traditional Unix shell originally written by Stephen Bourne.
+All of the Bourne shell builtin commands are available in Bash,
+The rules for evaluation and quoting are taken from the @sc{posix}
+specification for the `standard' Unix shell.
+
+This chapter briefly summarizes the shell's `building blocks':
+commands, control structures, shell functions, shell @i{parameters},
+shell expansions,
+@i{redirections}, which are a way to direct input and output from
+and to named files, and how the shell executes commands.
+
+@menu
+* Shell Syntax::               What your input means to the shell.
+* Shell Commands::             The types of commands you can use.
+* Shell Functions::            Grouping commands by name.
+* Shell Parameters::           How the shell stores values.
+* Shell Expansions::           How Bash expands parameters and the various
+                               expansions available.
+* Redirections::               A way to control where input and output go.
+* Executing Commands::         What happens when you run a command.
+* Shell Scripts::              Executing files of shell commands.
+@end menu
+
+@node Shell Syntax
+@section Shell Syntax
+@menu
+* Shell Operation::    The basic operation of the shell.
+* Quoting::            How to remove the special meaning from characters.
+* Comments::           How to specify comments.
+@end menu
+
+When the shell reads input, it proceeds through a
+sequence of operations.  If the input indicates the beginning of a
+comment, the shell ignores the comment symbol (@samp{#}), and the rest
+of that line.
+                                
+Otherwise, roughly speaking,  the shell reads its input and
+divides the input into words and operators, employing the quoting rules
+to select which meanings to assign various words and characters.
+
+The shell then parses these tokens into commands and other constructs,
+removes the special meaning of certain words or characters, expands
+others, redirects input and output as needed, executes the specified
+command, waits for the command's exit status, and makes that exit status
+available for further inspection or processing.
+
+@node Shell Operation
+@subsection Shell Operation
+
+The following is a brief description of the shell's operation when it
+reads and executes a command.  Basically, the shell does the
+following:
+
+@enumerate
+@item
+Reads its input from a file (@pxref{Shell Scripts}), from a string
+supplied as an argument to the @option{-c} invocation option
+(@pxref{Invoking Bash}), or from the user's terminal.
+
+@item
+Breaks the input into words and operators, obeying the quoting rules
+described in @ref{Quoting}.  These tokens are separated by
+@code{metacharacters}.  Alias expansion is performed by this step
+(@pxref{Aliases}).
+
+@item
+Parses the tokens into simple and compound commands
+(@pxref{Shell Commands}).
+
+@item
+Performs the various shell expansions (@pxref{Shell Expansions}), breaking
+the expanded tokens into lists of filenames (@pxref{Filename Expansion})
+and commands and arguments.
+
+@item
+Performs any necessary redirections (@pxref{Redirections}) and removes
+the redirection operators and their operands from the argument list.
+
+@item
+Executes the command (@pxref{Executing Commands}).
+
+@item
+Optionally waits for the command to complete and collects its exit
+status (@pxref{Exit Status}).
+
+@end enumerate
+
+@node Quoting
+@subsection Quoting
+@cindex quoting
+@menu
+* Escape Character::   How to remove the special meaning from a single
+                       character.
+* Single Quotes::      How to inhibit all interpretation of a sequence
+                       of characters.
+* Double Quotes::      How to suppress most of the interpretation of a
+                       sequence of characters.
+* ANSI-C Quoting::     How to expand ANSI-C sequences in quoted strings.
+* Locale Translation:: How to translate strings into different languages.
+@end menu
+
+Quoting is used to remove the special meaning of certain
+characters or words to the shell.  Quoting can be used to
+disable special treatment for special characters, to prevent
+reserved words from being recognized as such, and to prevent
+parameter expansion.
+
+Each of the shell metacharacters (@pxref{Definitions})
+has special meaning to the shell and must be quoted if it is to
+represent itself.
+When the command history expansion facilities are being used
+(@pxref{History Interaction}), the
+@var{history expansion} character, usually @samp{!}, must be quoted
+to prevent history expansion.  @xref{Bash History Facilities}, for
+more details concerning history expansion.
+
+There are three quoting mechanisms: the
+@var{escape character}, single quotes, and double quotes.
+
+@node Escape Character
+@subsubsection Escape Character
+A non-quoted backslash @samp{\} is the Bash escape character.
+It preserves the literal value of the next character that follows,
+with the exception of @code{newline}.  If a @code{\newline} pair
+appears, and the backslash itself is not quoted, the @code{\newline}
+is treated as a line continuation (that is, it is removed from
+the input stream and effectively ignored).
+
+@node Single Quotes
+@subsubsection Single Quotes
+
+Enclosing characters in single quotes (@samp{'}) preserves the literal value
+of each character within the quotes.  A single quote may not occur
+between single quotes, even when preceded by a backslash.
+
+@node Double Quotes
+@subsubsection Double Quotes
+
+Enclosing characters in double quotes (@samp{"}) preserves the literal value
+of all characters within the quotes, with the exception of
+@samp{$}, @samp{`}, @samp{\},
+and, when history expansion is enabled, @samp{!}.
+The characters @samp{$} and @samp{`}
+retain their special meaning within double quotes (@pxref{Shell Expansions}).
+The backslash retains its special meaning only when followed by one of
+the following characters:
+@samp{$}, @samp{`}, @samp{"}, @samp{\}, or @code{newline}.
+Within double quotes, backslashes that are followed by one of these
+characters are removed.  Backslashes preceding characters without a
+special meaning are left unmodified.
+A double quote may be quoted within double quotes by preceding it with
+a backslash.
+If enabled, history expansion will be performed unless an @samp{!}
+appearing in double quotes is escaped using a backslash.
+The backslash preceding the @samp{!} is not removed.
+
+The special parameters @samp{*} and @samp{@@} have special meaning
+when in double quotes (@pxref{Shell Parameter Expansion}).
+
+@node ANSI-C Quoting
+@subsubsection ANSI-C Quoting
+@cindex quoting, ANSI
+
+Words of the form @code{$'@var{string}'} are treated specially.  The
+word expands to @var{string}, with backslash-escaped characters replaced
+as specified by the ANSI C standard.  Backslash escape sequences, if
+present, are decoded as follows:
+
+@table @code
+@item \a
+alert (bell)
+@item \b
+backspace
+@item \e
+an escape character (not ANSI C)
+@item \f
+form feed
+@item \n
+newline
+@item \r
+carriage return
+@item \t
+horizontal tab
+@item \v
+vertical tab
+@item \\
+backslash
+@item \'
+single quote
+@item \@var{nnn}
+the eight-bit character whose value is the octal value @var{nnn}
+(one to three digits)
+@item \x@var{HH}
+the eight-bit character whose value is the hexadecimal value @var{HH}
+(one or two hex digits)
+@item \c@var{x}
+a control-@var{x} character
+@end table
+
+@noindent
+The expanded result is single-quoted, as if the dollar sign had not
+been present.
+
+@node Locale Translation
+@subsubsection Locale-Specific Translation
+@cindex localization
+@cindex internationalization
+@cindex native languages
+@cindex translation, native languages
+
+A double-quoted string preceded by a dollar sign (@samp{$}) will cause
+the string to be translated according to the current locale.
+If the current locale is @code{C} or @code{POSIX}, the dollar sign
+is ignored.
+If the string is translated and replaced, the replacement is
+double-quoted.
+
+@vindex LC_MESSAGES
+@vindex TEXTDOMAIN
+@vindex TEXTDOMAINDIR
+Some systems use the message catalog selected by the @env{LC_MESSAGES}
+shell variable.  Others create the name of the message catalog from the
+value of the @env{TEXTDOMAIN} shell variable, possibly adding a
+suffix of @samp{.mo}.  If you use the @env{TEXTDOMAIN} variable, you
+may need to set the @env{TEXTDOMAINDIR} variable to the location of
+the message catalog files.  Still others use both variables in this
+fashion:
+@env{TEXTDOMAINDIR}/@env{LC_MESSAGES}/LC_MESSAGES/@env{TEXTDOMAIN}.mo.
+
+@node Comments
+@subsection Comments
+@cindex comments, shell
+
+In a non-interactive shell, or an interactive shell in which the
+@code{interactive_comments} option to the @code{shopt}
+builtin is enabled (@pxref{The Shopt Builtin}),
+a word beginning with @samp{#}
+causes that word and all remaining characters on that line to
+be ignored.  An interactive shell without the @code{interactive_comments}
+option enabled does not allow comments.  The @code{interactive_comments}
+option is on by default in interactive shells.
+@xref{Interactive Shells}, for a description of what makes
+a shell interactive.
+
+@node Shell Commands
+@section Shell Commands
+@cindex commands, shell
+
+A simple shell command such as @code{echo a b c} consists of the command
+itself followed by arguments, separated by spaces.
+
+More complex shell commands are composed of simple commands arranged together
+in a variety of ways: in a pipeline in which the output of one command
+becomes the input of a second, in a loop or conditional construct, or in
+some other grouping.
+
+@menu
+* Simple Commands::            The most common type of command.
+* Pipelines::                  Connecting the input and output of several
+                               commands.
+* Lists::                      How to execute commands sequentially.
+* Compound Commands::          Shell commands for control flow.
+@end menu
+
+@node Simple Commands
+@subsection Simple Commands
+@cindex commands, simple
+
+A simple command is the kind of command encountered most often.
+It's just a sequence of words separated by @code{blank}s, terminated
+by one of the shell's control operators (@pxref{Definitions}).  The
+first word generally specifies a command to be executed, with the
+rest of the words being that command's arguments.
+
+The return status (@pxref{Exit Status}) of a simple command is
+its exit status as provided
+by the @sc{posix} 1003.1 @code{waitpid} function, or 128+@var{n} if
+the command was terminated by signal @var{n}.
+
+@node Pipelines
+@subsection Pipelines
+@cindex pipeline
+@cindex commands, pipelines
+
+A @code{pipeline} is a sequence of simple commands separated by
+@samp{|}.
+
+@rwindex time
+@rwindex !
+@cindex command timing
+The format for a pipeline is
+@example
+[@code{time} [@code{-p}]] [@code{!}] @var{command1} [@code{|} @var{command2} @dots{}]
+@end example
+
+@noindent
+The output of each command in the pipeline is connected via a pipe
+to the input of the next command.
+That is, each command reads the previous command's output.
+
+The reserved word @code{time} causes timing statistics
+to be printed for the pipeline once it finishes.
+The statistics currently consist of elapsed (wall-clock) time and
+user and system time consumed by the command's execution.
+The @option{-p} option changes the output format to that specified
+by @sc{posix}.
+The @env{TIMEFORMAT} variable may be set to a format string that
+specifies how the timing information should be displayed.
+@xref{Bash Variables}, for a description of the available formats.
+The use of @code{time} as a reserved word permits the timing of
+shell builtins, shell functions, and pipelines.  An external
+@code{time} command cannot time these easily.
+
+If the pipeline is not executed asynchronously (@pxref{Lists}), the
+shell waits for all commands in the pipeline to complete.
+
+Each command in a pipeline is executed in its own subshell
+(@pxref{Command Execution Environment}).  The exit
+status of a pipeline is the exit status of the last command in the
+pipeline, unless the @code{pipefail} option is enabled
+(@pxref{The Set Builtin}).
+If @code{pipefail} is enabled, the pipeline's return status is the
+value of the last (rightmost) command to exit with a non-zero status,
+or zero if all commands exit successfully.
+If the reserved word @samp{!} precedes the pipeline, the
+exit status is the logical negation of the exit status as described
+above.
+The shell waits for all commands in the pipeline to terminate before
+returning a value.
+
+@node Lists
+@subsection Lists of Commands
+@cindex commands, lists
+
+A @code{list} is a sequence of one or more pipelines separated by one
+of the operators @samp{;}, @samp{&}, @samp{&&}, or @samp{||},
+and optionally terminated by one of @samp{;}, @samp{&}, or a
+@code{newline}.
+
+Of these list operators, @samp{&&} and @samp{||}
+have equal precedence, followed by @samp{;} and @samp{&},
+which have equal precedence.
+
+A sequence of one or more newlines may appear in a @code{list}
+to delimit commands, equivalent to a semicolon.
+
+If a command is terminated by the control operator @samp{&},
+the shell executes the command asynchronously in a subshell.
+This is known as executing the command in the @var{background}.
+The shell does not wait for the command to finish, and the return
+status is 0 (true).
+When job control is not active (@pxref{Job Control}),
+the standard input for asynchronous commands, in the absence of any
+explicit redirections, is redirected from @code{/dev/null}.
+
+Commands separated by a @samp{;} are executed sequentially; the shell
+waits for each command to terminate in turn.  The return status is the
+exit status of the last command executed.
+
+The control operators @samp{&&} and @samp{||}
+denote @sc{and} lists and @sc{or} lists, respectively.
+An @sc{and} list has the form
+@example
+@var{command1} && @var{command2}
+@end example
+
+@noindent
+@var{command2} is executed if, and only if, @var{command1}
+returns an exit status of zero.
+
+An @sc{or} list has the form
+@example
+@var{command1} || @var{command2}
+@end example
+
+@noindent
+@var{command2} is executed if, and only if, @var{command1}
+returns a non-zero exit status.
+
+The return status of
+@sc{and} and @sc{or} lists is the exit status of the last command
+executed in the list.
+
+@node Compound Commands
+@subsection Compound Commands
+@cindex commands, compound
+
+@menu
+* Looping Constructs::         Shell commands for iterative action.
+* Conditional Constructs::     Shell commands for conditional execution.
+* Command Grouping::           Ways to group commands.
+@end menu
+
+Compound commands are the shell programming constructs.
+Each construct begins with a reserved word or control operator and is
+terminated by a corresponding reserved word or operator.
+Any redirections (@pxref{Redirections}) associated with a compound command
+apply to all commands within that compound command unless explicitly overridden.
+
+Bash provides looping constructs, conditional commands, and mechanisms
+to group commands and execute them as a unit.
+
+@node Looping Constructs
+@subsubsection Looping Constructs
+@cindex commands, looping
+
+Bash supports the following looping constructs.
+
+Note that wherever a @samp{;} appears in the description of a
+command's syntax, it may be replaced with one or more newlines.
+
+@table @code
+@item until
+@rwindex until
+@rwindex do
+@rwindex done
+The syntax of the @code{until} command is:
+@example
+until @var{test-commands}; do @var{consequent-commands}; done
+@end example
+Execute @var{consequent-commands} as long as
+@var{test-commands} has an exit status which is not zero.
+The return status is the exit status of the last command executed
+in @var{consequent-commands}, or zero if none was executed.
+
+@item while
+@rwindex while
+The syntax of the @code{while} command is:
+@example
+while @var{test-commands}; do @var{consequent-commands}; done
+@end example
+
+Execute @var{consequent-commands} as long as
+@var{test-commands} has an exit status of zero.
+The return status is the exit status of the last command executed
+in @var{consequent-commands}, or zero if none was executed.
+
+@item for
+@rwindex for
+The syntax of the @code{for} command is:
+
+@example
+for @var{name} [in @var{words} @dots{}]; do @var{commands}; done
+@end example
+Expand @var{words}, and execute @var{commands} once for each member
+in the resultant list, with @var{name} bound to the current member.
+If @samp{in @var{words}} is not present, the @code{for} command
+executes the @var{commands} once for each positional parameter that is
+set, as if @samp{in "$@@"} had been specified
+(@pxref{Special Parameters}).
+The return status is the exit status of the last command that executes.
+If there are no items in the expansion of @var{words}, no commands are
+executed, and the return status is zero.
+
+An alternate form of the @code{for} command is also supported:
+
+@example
+for (( @var{expr1} ; @var{expr2} ; @var{expr3} )) ; do @var{commands} ; done
+@end example
+First, the arithmetic expression @var{expr1} is evaluated according
+to the rules described below (@pxref{Shell Arithmetic}).
+The arithmetic expression @var{expr2} is then evaluated repeatedly
+until it evaluates to zero.   
+Each time @var{expr2} evaluates to a non-zero value, @var{commands} are
+executed and the arithmetic expression @var{expr3} is evaluated.       
+If any expression is omitted, it behaves as if it evaluates to 1.
+The return value is the exit status of the last command in @var{list}
+that is executed, or false if any of the expressions is invalid.
+
+@end table
+
+The @code{break} and @code{continue} builtins (@pxref{Bourne Shell Builtins})
+may be used to control loop execution.
+
+@node Conditional Constructs
+@subsubsection Conditional Constructs
+@cindex commands, conditional
+
+@table @code
+@item if
+@rwindex if
+@rwindex then
+@rwindex else
+@rwindex elif
+@rwindex fi
+The syntax of the @code{if} command is:
+
+@example
+if @var{test-commands}; then
+  @var{consequent-commands};
+[elif @var{more-test-commands}; then
+  @var{more-consequents};]
+[else @var{alternate-consequents};]
+fi
+@end example
+
+The @var{test-commands} list is executed, and if its return status is zero,
+the @var{consequent-commands} list is executed.
+If @var{test-commands} returns a non-zero status, each @code{elif} list
+is executed in turn, and if its exit status is zero,
+the corresponding @var{more-consequents} is executed and the   
+command completes.
+If @samp{else @var{alternate-consequents}} is present, and
+the final command in the final @code{if} or @code{elif} clause
+has a non-zero exit status, then @var{alternate-consequents} is executed.
+The return status is the exit status of the last command executed, or
+zero if no condition tested true.
+
+@item case
+@rwindex case
+@rwindex in
+@rwindex esac
+The syntax of the @code{case} command is:
+
+@example
+@code{case @var{word} in [ [(] @var{pattern} [| @var{pattern}]@dots{}) @var{command-list} ;;]@dots{} esac}
+@end example
+
+@code{case} will selectively execute the @var{command-list} corresponding to
+the first @var{pattern} that matches @var{word}.
+If the shell option @code{nocasematch}
+(see the description of @code{shopt} in @ref{The Shopt Builtin})
+is enabled, the match is performed without regard to the case
+of alphabetic characters.
+The @samp{|} is used to separate multiple patterns, and the @samp{)}
+operator terminates a pattern list.
+A list of patterns and an associated command-list is known
+as a @var{clause}.  Each clause must be terminated with @samp{;;}.
+The @var{word} undergoes tilde expansion, parameter expansion, command
+substitution, arithmetic expansion, and quote removal before matching is
+attempted.  Each @var{pattern} undergoes tilde expansion, parameter
+expansion, command substitution, and arithmetic expansion.
+
+There may be an arbitrary number of @code{case} clauses, each terminated
+by a @samp{;;}.  The first pattern that matches determines the
+command-list that is executed.
+
+Here is an example using @code{case} in a script that could be used to
+describe one interesting feature of an animal:
+
+@example
+echo -n "Enter the name of an animal: "
+read ANIMAL
+echo -n "The $ANIMAL has "
+case $ANIMAL in
+  horse | dog | cat) echo -n "four";;
+  man | kangaroo ) echo -n "two";;
+  *) echo -n "an unknown number of";;
+esac
+echo " legs."
+@end example
+
+@noindent
+The return status is zero if no @var{pattern} is matched.  Otherwise, the
+return status is the exit status of the @var{command-list} executed.
+
+@item select
+@rwindex select
+
+The @code{select} construct allows the easy generation of menus.
+It has almost the same syntax as the @code{for} command:
+
+@example
+select @var{name} [in @var{words} @dots{}]; do @var{commands}; done
+@end example
+
+The list of words following @code{in} is expanded, generating a list
+of items.  The set of expanded words is printed on the standard
+error output stream, each preceded by a number.  If the
+@samp{in @var{words}} is omitted, the positional parameters are printed,
+as if @samp{in "$@@"} had been specified.
+The @env{PS3} prompt is then displayed and a line is read from the
+standard input.
+If the line consists of a number corresponding to one of the displayed
+words, then the value of @var{name} is set to that word.
+If the line is empty, the words and prompt are displayed again.
+If @code{EOF} is read, the @code{select} command completes.
+Any other value read causes @var{name} to be set to null.
+The line read is saved in the variable @env{REPLY}.
+
+The @var{commands} are executed after each selection until a
+@code{break} command is executed, at which
+point the @code{select} command completes.
+
+Here is an example that allows the user to pick a filename from the
+current directory, and displays the name and index of the file
+selected.
+
+@example
+select fname in *;
+do
+       echo you picked $fname \($REPLY\)
+       break;
+done
+@end example
+
+@item ((@dots{}))
+@example
+(( @var{expression} ))
+@end example
+
+The arithmetic @var{expression} is evaluated according to the rules
+described below (@pxref{Shell Arithmetic}).
+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
+let "@var{expression}"
+@end example
+@noindent
+@xref{Bash Builtins}, for a full description of the @code{let} builtin.
+
+@item [[@dots{}]]
+@rwindex [[
+@rwindex ]]
+@example
+[[ @var{expression} ]]
+@end example
+
+Return a status of 0 or 1 depending on the evaluation of
+the conditional expression @var{expression}.
+Expressions are composed of the primaries described below in
+@ref{Bash Conditional Expressions}.
+Word splitting and filename expansion are not performed on the words
+between the @samp{[[} and @samp{]]}; tilde expansion, parameter and
+variable expansion, arithmetic expansion, command substitution, process
+substitution, and quote removal are performed.
+Conditional operators such as @samp{-f} must be unquoted to be recognized
+as primaries.
+
+When the @samp{==} and @samp{!=} operators are used, the string to the
+right of the operator is considered a pattern and matched according
+to the rules described below in @ref{Pattern Matching}.
+If the shell option @code{nocasematch}
+(see the description of @code{shopt} in @ref{The Shopt Builtin})
+is enabled, the match is performed without regard to the case
+of alphabetic characters.
+The return value is 0 if the string matches (@samp{==}) or does not
+match (@samp{!=})the pattern, and 1 otherwise.
+Any part of the pattern may be quoted to force it to be matched as a
+string.
+
+An additional binary operator, @samp{=~}, is available, with the same
+precedence as @samp{==} and @samp{!=}.
+When it is used, the string to the right of the operator is considered
+an extended regular expression and matched accordingly (as in @i{regex}3)).  
+The return value is 0 if the string matches
+the pattern, and 1 otherwise.
+If the regular expression is syntactically incorrect, the conditional
+expression's return value is 2.
+If the shell option @code{nocasematch}
+(see the description of @code{shopt} in @ref{The Shopt Builtin})
+is enabled, the match is performed without regard to the case
+of alphabetic characters.
+Substrings matched by parenthesized subexpressions within the regular
+expression are saved in the array variable @code{BASH_REMATCH}.
+The element of @code{BASH_REMATCH} with index 0 is the portion of the string
+matching the entire regular expression.
+The element of @code{BASH_REMATCH} with index @var{n} is the portion of the
+string matching the @var{n}th parenthesized subexpression.
+
+Expressions may be combined using the following operators, listed
+in decreasing order of precedence:
+
+@table @code
+@item ( @var{expression} )
+Returns the value of @var{expression}.
+This may be used to override the normal precedence of operators.
+
+@item ! @var{expression}
+True if @var{expression} is false.
+
+@item @var{expression1} && @var{expression2}
+True if both @var{expression1} and @var{expression2} are true.
+
+@item @var{expression1} || @var{expression2}
+True if either @var{expression1} or @var{expression2} is true.
+@end table
+@noindent
+The @code{&&} and @code{||} operators do not evaluate @var{expression2} if the
+value of @var{expression1} is sufficient to determine the return
+value of the entire conditional expression.
+
+@end table
+
+@node Command Grouping
+@subsubsection Grouping Commands
+@cindex commands, grouping
+
+Bash provides two ways to group a list of commands to be executed
+as a unit.  When commands are grouped, redirections may be applied
+to the entire command list.  For example, the output of all the
+commands in the list may be redirected to a single stream.
+
+@table @code
+@item ()
+@example
+( @var{list} )
+@end example
+
+Placing a list of commands between parentheses causes a subshell
+environment to be created (@pxref{Command Execution Environment}), and each
+of the commands in @var{list} to be executed in that subshell.  Since the
+@var{list} is executed in a subshell, variable assignments do not remain in
+effect after the subshell completes. 
+
+@item @{@}
+@rwindex @{
+@rwindex @}
+@example
+@{ @var{list}; @}
+@end example
+
+Placing a list of commands between curly braces causes the list to
+be executed in the current shell context.  No subshell is created.
+The semicolon (or newline) following @var{list} is required.
+@end table
+
+In addition to the creation of a subshell, there is a subtle difference
+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 the @var{list} by whitespace.
+
+The exit status of both of these constructs is the exit status of
+@var{list}.
+
+@node Shell Functions
+@section Shell Functions
+@cindex shell function
+@cindex functions, shell
+
+Shell functions are a way to group commands for later execution
+using a single name for the group.  They are executed just like
+a "regular" command.
+When the name of a shell function is used as a simple command name,
+the list of commands associated with that function name is executed.
+Shell functions are executed in the current
+shell context; no new process is created to interpret them.
+
+Functions are declared using this syntax:
+@rwindex function
+@example
+[ @code{function} ] @var{name} () @var{compound-command} [ @var{redirections} ]
+@end example
+
+This defines a shell function named @var{name}.  The reserved
+word @code{function} is optional.
+If the @code{function} reserved
+word is supplied, the parentheses are optional.
+The @var{body} of the function is the compound command
+@var{compound-command} (@pxref{Compound Commands}).
+That command is usually a @var{list} enclosed between @{ and @}, but
+may be any compound command listed above.
+@var{compound-command} is executed whenever @var{name} is specified as the
+name of a command.
+Any redirections (@pxref{Redirections}) associated with the shell function
+are performed when the function is executed.
+
+A function definition may be deleted using the @option{-f} option to the
+@code{unset} builtin (@pxref{Bourne Shell Builtins}).
+
+The exit status of a function definition is zero unless a syntax error
+occurs or a readonly function with the same name already exists.
+When executed, the exit status of a function is the exit status of the
+last command executed in the body.
+
+Note that for historical reasons, in the most common usage the curly braces
+that surround the body of the function must be separated from the body by
+@code{blank}s or newlines.
+This is because the braces are reserved words and are only recognized
+as such when they are separated by whitespace.
+Also, when using the braces, the @var{list} must be terminated by a semicolon,
+a @samp{&}, or a newline.
+
+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 expands to the number of
+positional parameters is updated to reflect the change.
+Special parameter @code{0} is unchanged.
+The first element of the @env{FUNCNAME} variable is set to the
+name of the function while the function is executing.
+All other aspects of the shell execution
+environment are identical between a function and its caller
+with the exception that the @env{DEBUG} and @env{RETURN} traps
+are not inherited unless the function has been given the
+@code{trace} attribute using the @code{declare} builtin or
+the @code{-o functrace} option has been enabled with
+the @code{set} builtin,
+(in which case all functions inherit the @env{DEBUG} and @env{RETURN} traps).
+@xref{Bourne Shell Builtins}, for the description of the
+@code{trap} builtin.
+
+If the builtin command @code{return}
+is executed in a function, the function completes and
+execution resumes with the next command after the function
+call.
+Any command associated with the @code{RETURN} trap is executed
+before execution resumes.
+When a function completes, the values of the
+positional parameters and the special parameter @samp{#}
+are restored to the values they had prior to the function's
+execution.  If a numeric argument is given to @code{return},
+that is the function's return status; otherwise the function's
+return status is the exit status of the last command executed
+before the @code{return}.
+
+Variables local to the function may be declared with the
+@code{local} builtin.  These variables are visible only to
+the function and the commands it invokes.
+
+Function names and definitions may be listed with the
+@option{-f} option to the @code{declare} or @code{typeset}
+builtin commands (@pxref{Bash Builtins}).
+The @option{-F} option to @code{declare} or @code{typeset}
+will list the function names only
+(and optionally the source file and line number, if the @code{extdebug}
+shell option is enabled).
+Functions may be exported so that subshells
+automatically have them defined with the
+@option{-f} option to the @code{export} builtin
+(@pxref{Bourne Shell Builtins}).
+Note that shell functions and variables with the same name may result
+in multiple identically-named entries in the environment passed to the
+shell's children.
+Care should be taken in cases where this may cause a problem.
+
+Functions may be recursive.  No limit is placed on the number of
+recursive  calls.
+
+@node Shell Parameters
+@section Shell Parameters
+@cindex parameters
+@cindex variable, shell
+@cindex shell variable
+
+@menu
+* Positional Parameters::      The shell's command-line arguments.
+* Special Parameters::         Parameters denoted by special characters.
+@end menu
+
+A @var{parameter} is an entity that stores values.
+It can be a @code{name}, a number, or one of the special characters
+listed below.
+A @var{variable} is a parameter denoted by a @code{name}.
+A variable has a @var{value} and zero or more @var{attributes}.
+Attributes are assigned using the @code{declare} builtin command
+(see the description of the @code{declare} builtin in @ref{Bash Builtins}).
+
+A parameter is set if it has been assigned a value.  The null string is
+a valid value.  Once a variable is set, it may be unset only by using
+the @code{unset} builtin command.
+
+A variable may be assigned to by a statement of the form
+@example
+@var{name}=[@var{value}]
+@end example
+@noindent
+If @var{value}
+is not given, the variable is assigned the null string.  All
+@var{value}s undergo tilde expansion, parameter and variable expansion,
+command substitution, arithmetic expansion, and quote
+removal (detailed below).  If the variable has its @code{integer}
+attribute set, then @var{value} 
+is evaluated as an arithmetic expression even if the @code{$((@dots{}))}
+expansion is not used (@pxref{Arithmetic Expansion}).
+Word splitting is not performed, with the exception
+of @code{"$@@"} as explained below.
+Filename expansion is not performed.
+Assignment statements may also appear as arguments to the
+@code{alias}, 
+@code{declare}, @code{typeset}, @code{export}, @code{readonly},
+and @code{local} builtin commands.
+
+In the context where an assignment statement is assigning a value  
+to a shell variable or array index (@pxref{Arrays}), the @samp{+=}
+operator can be used to   
+append to or add to the variable's previous value.
+When @samp{+=} is applied to a variable for which the integer attribute
+has been set, @var{value} is evaluated as an arithmetic expression and
+added to the variable's current value, which is also evaluated.
+When @samp{+=} is applied to an array variable using compound assignment
+(@pxref{Arrays}), the
+variable's value is not unset (as it is when using @samp{=}), and new
+values are appended to the array beginning at one greater than the array's
+maximum index.
+When applied to a string-valued variable, @var{value} is expanded and
+appended to the variable's value.
+
+@node Positional Parameters
+@subsection Positional Parameters
+@cindex parameters, positional
+
+A @var{positional parameter} is a parameter denoted by one or more
+digits, other than the single digit @code{0}.  Positional parameters are
+assigned from the shell's arguments when it is invoked,
+and may be reassigned using the @code{set} builtin command.
+Positional parameter @code{N} may be referenced as @code{$@{N@}}, or
+as @code{$N} when @code{N} consists of a single digit.
+Positional parameters may not be assigned to with assignment statements.
+The @code{set} and @code{shift} builtins are used to set and
+unset them (@pxref{Shell Builtin Commands}).
+The positional parameters are
+temporarily replaced when a shell function is executed
+(@pxref{Shell Functions}).
+
+When a positional parameter consisting of more than a single
+digit is expanded, it must be enclosed in braces.
+
+@node Special Parameters
+@subsection Special Parameters
+@cindex parameters, special
+
+The shell treats several parameters specially.  These parameters may
+only be referenced; assignment to them is not allowed.
+
+@vtable @code
+
+@item *
+Expands to the positional parameters, starting from one.  When the
+expansion occurs within double quotes, it expands to a single word
+with the value of each parameter separated by the first character
+of the @env{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 @env{IFS} is unset, the parameters are separated by spaces.
+If @env{IFS} is null, the parameters are joined without intervening
+separators.
+
+
+@item @@
+Expands to the positional parameters, starting from one.  When the
+expansion occurs within double quotes, each parameter expands to a
+separate word.  That is, @code{"$@@"} is equivalent to
+@code{"$1" "$2" @dots{}}.
+If the double-quoted expansion occurs within a word, the expansion of
+the first parameter is joined with the beginning part of the original
+word, and the expansion of the last parameter is joined with the last
+part of the original word.
+When there are no positional parameters, @code{"$@@"} and
+@code{$@@}
+expand to nothing (i.e., they are removed).
+
+@item #
+Expands to the number of positional parameters in decimal.
+
+@item ?
+Expands to the exit status of the most recently executed foreground
+pipeline.
+
+@item -
+(A hyphen.)  Expands to the current option flags as specified upon
+invocation, by the @code{set}
+builtin command, or those set by the shell itself
+(such as the @option{-i} option).
+
+@item $
+Expands to the process @sc{id} of the shell.  In a @code{()} subshell, it
+expands to the process @sc{id} of the invoking shell, not the subshell.
+
+@item !
+Expands to the process @sc{id} of the most recently executed background
+(asynchronous) command.
+
+@item 0
+Expands to the name of the shell or shell script.  This is set at
+shell initialization.  If Bash is invoked with a file of commands
+(@pxref{Shell Scripts}), @code{$0} is set to the name of that file.
+If Bash is started with the @option{-c} option (@pxref{Invoking Bash}),
+then @code{$0} is set to the first argument after the string to be
+executed, if one is present.  Otherwise, it is set
+to the filename used to invoke Bash, as given by argument zero.
+
+@item _
+(An underscore.)
+At shell startup, set to the absolute pathname used to invoke the
+shell or shell script being executed as passed in the environment
+or argument list.
+Subsequently, expands to the last argument to the previous command,
+after expansion.   
+Also set to the full pathname used to invoke each command executed
+and placed in the environment exported to that command.
+When checking mail, this parameter holds the name of the mail file.
+@end vtable
+
+@node Shell Expansions
+@section Shell Expansions
+@cindex expansion
+
+Expansion is performed on the command line after it has been split into
+@code{token}s.  There are seven kinds of expansion performed:
+@itemize @bullet
+@item brace expansion
+@item tilde expansion
+@item parameter and variable expansion
+@item command substitution
+@item arithmetic expansion
+@item word splitting
+@item filename expansion
+@end itemize
+
+@menu
+* Brace Expansion::            Expansion of expressions within braces.
+* Tilde Expansion::            Expansion of the ~ character.
+* Shell Parameter Expansion::  How Bash expands variables to their values.
+* Command Substitution::       Using the output of a command as an argument.
+* Arithmetic Expansion::       How to use arithmetic in shell expansions.
+* Process Substitution::       A way to write and read to and from a
+                               command.
+* Word Splitting::     How the results of expansion are split into separate
+                       arguments.
+* Filename Expansion:: A shorthand for specifying filenames matching patterns.
+* Quote Removal::      How and when quote characters are removed from
+                       words.
+@end menu
+
+The order of expansions is: brace expansion, tilde expansion,
+parameter, variable, and arithmetic expansion and
+command substitution
+(done in a left-to-right fashion), word splitting, and filename
+expansion.
+
+On systems that can support it, there is an additional expansion
+available: @var{process substitution}.  This is performed at the
+same time as parameter, variable, and arithmetic 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
+@code{"$@@"} (@pxref{Special Parameters}) and @code{"$@{@var{name}[@@]@}"}
+(@pxref{Arrays}).
+
+After all expansions, @code{quote removal} (@pxref{Quote Removal})
+is performed.
+
+@node Brace Expansion
+@subsection Brace Expansion
+@cindex brace expansion
+@cindex expansion, brace
+
+Brace expansion is a mechanism by which arbitrary strings may be generated.
+This mechanism is similar to
+@var{filename expansion} (@pxref{Filename Expansion}),
+but the file names generated need not exist.
+Patterns to be brace expanded take the form of an optional @var{preamble},
+followed by either a series of comma-separated strings or a seqeunce expression
+between a pair of braces,
+followed by an optional @var{postscript}.
+The preamble is prefixed to each string contained within the braces, and
+the postscript is then appended to each resulting string, expanding left
+to right.
+
+Brace expansions may be nested.
+The results of each expanded string are not sorted; left to right order
+is preserved.
+For example,
+@example
+bash$ echo a@{d,c,b@}e
+ade ace abe
+@end example
+
+A sequence expression takes the form @code{@{@var{x}..@var{y}@}},
+where @var{x} and @var{y} are either integers or single characters.
+When integers are supplied, the expression expands to each number between
+@var{x} and @var{y}, inclusive.
+When characters are supplied, the expression expands to each character
+lexicographically between @var{x} and @var{y}, inclusive.  Note that
+both @var{x} and @var{y} must be of the same type.
+
+Brace expansion is performed before any other expansions,
+and any characters special to other expansions are preserved
+in the result.  It is strictly textual.  Bash
+does not apply any syntactic interpretation to the context of the
+expansion or the text between the braces.
+To avoid conflicts with parameter expansion, the string @samp{$@{}
+is not considered eligible for brace expansion.
+
+A correctly-formed brace expansion must contain unquoted opening
+and closing braces, and at least one unquoted comma or a valid
+sequence expression.
+Any incorrectly formed brace expansion is left unchanged.
+
+A @{ or @samp{,} may be quoted with a backslash to prevent its
+being considered part of a brace expression.
+To avoid conflicts with parameter expansion, the string @samp{$@{}
+is not considered eligible for brace expansion.
+
+This construct is typically used as shorthand when the common
+prefix of the strings to be generated is longer than in the
+above example:
+@example
+mkdir /usr/local/src/bash/@{old,new,dist,bugs@}
+@end example
+or
+@example
+chown root /usr/@{ucb/@{ex,edit@},lib/@{ex?.?*,how_ex@}@}
+@end example
+
+@node Tilde Expansion
+@subsection Tilde Expansion
+@cindex tilde expansion
+@cindex expansion, tilde
+
+If a word begins with an unquoted tilde character (@samp{~}), all of the
+characters up to the first unquoted slash (or all characters,
+if there is no unquoted slash) are considered a @var{tilde-prefix}.
+If none of the characters in the tilde-prefix are quoted, the
+characters in the tilde-prefix following the tilde are treated as a
+possible @var{login name}.
+If this login name is the null string, the tilde is replaced with the
+value of the @env{HOME} shell variable.
+If @env{HOME} is unset, the home directory of the user executing the
+shell is substituted instead.
+Otherwise, the tilde-prefix is replaced with the home directory
+associated with the specified login name.
+
+If the tilde-prefix is @samp{~+}, the value of
+the shell variable @env{PWD} replaces the tilde-prefix.
+If the tilde-prefix is @samp{~-}, the value of the shell variable
+@env{OLDPWD}, if it is set, is substituted.
+
+If the characters following the tilde in the tilde-prefix consist of a
+number @var{N}, optionally prefixed by a @samp{+} or a @samp{-},
+the tilde-prefix is replaced with the
+corresponding element from the directory stack, as it would be displayed
+by the @code{dirs} builtin invoked with the characters following tilde
+in the tilde-prefix as an argument (@pxref{The Directory Stack}).
+If the tilde-prefix, sans the tilde, consists of a number without a
+leading @samp{+} or @samp{-}, @samp{+} is assumed.
+
+If the login name is invalid, or the tilde expansion fails, the word is
+left unchanged.
+
+Each variable assignment is checked for unquoted tilde-prefixes immediately
+following a @samp{:} or the first @samp{=}.
+In these cases, tilde expansion is also performed.
+Consequently, one may use file names with tildes in assignments to
+@env{PATH}, @env{MAILPATH}, and @env{CDPATH},
+and the shell assigns the expanded value.
+
+The following table shows how Bash treats unquoted tilde-prefixes:
+
+@table @code
+@item ~
+The value of @code{$HOME}
+@item ~/foo
+@file{$HOME/foo}
+
+@item ~fred/foo
+The subdirectory @code{foo} of the home directory of the user
+@code{fred}
+
+@item ~+/foo
+@file{$PWD/foo}
+
+@item ~-/foo
+@file{$@{OLDPWD-'~-'@}/foo}
+
+@item ~@var{N}
+The string that would be displayed by @samp{dirs +@var{N}}
+
+@item ~+@var{N}
+The string that would be displayed by @samp{dirs +@var{N}}
+
+@item ~-@var{N}
+The string that would be displayed by @samp{dirs -@var{N}}
+
+@end table
+
+@node Shell Parameter Expansion
+@subsection Shell Parameter Expansion
+@cindex parameter expansion
+@cindex expansion, parameter
+
+The @samp{$} character introduces parameter expansion,
+command substitution, or arithmetic expansion.  The parameter name
+or symbol to be expanded may be enclosed in braces, which
+are optional but serve to protect the variable to be expanded from
+characters immediately following it which could be
+interpreted as part of the name.
+
+When braces are used, the matching ending brace is the first @samp{@}}
+not escaped by a backslash or within a quoted string, and not within an
+embedded arithmetic expansion, command substitution, or parameter
+expansion.
+
+The basic form of parameter expansion is $@{@var{parameter}@}.
+The value of @var{parameter} is substituted.  The braces are required
+when @var{parameter}
+is a positional parameter with more than one digit,
+or when @var{parameter}
+is followed by a character that is not to be
+interpreted as part of its name.
+
+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 is used in the rest of the substitution, rather
+than the value of @var{parameter} itself.
+This is known as @code{indirect expansion}.
+The exceptions to this are the expansions of $@{!@var{prefix*}@}
+and $@{!@var{name}[@@]@}
+described below.
+The exclamation point must immediately follow the left brace in order to
+introduce indirection.
+
+In each of the cases below, @var{word} is subject to tilde expansion,
+parameter expansion, command substitution, and arithmetic expansion.
+
+When not performing substring expansion, Bash tests for a parameter
+that is unset or null; omitting the colon results in a test only for a
+parameter that is unset.  Put another way, if the colon is included,
+the operator tests for both existence and that the value is not null;
+if the colon is omitted, the operator tests only for existence.
+
+@table @code
+
+@item $@{@var{parameter}:@minus{}@var{word}@}
+If @var{parameter} is unset or null, the expansion of
+@var{word} is substituted.  Otherwise, the value of
+@var{parameter} is substituted.
+
+@item $@{@var{parameter}:=@var{word}@}
+If @var{parameter}
+is unset or null, the expansion of @var{word}
+is assigned to @var{parameter}.
+The value of @var{parameter} is then substituted. 
+Positional parameters and special parameters may not be assigned to
+in this way.
+
+@item $@{@var{parameter}:?@var{word}@}
+If @var{parameter}
+is null or unset, the expansion of @var{word} (or a message
+to that effect if @var{word}
+is not present) is written to the standard error and the shell, if it
+is not interactive, exits.  Otherwise, the value of @var{parameter} is
+substituted.
+
+@item $@{@var{parameter}:+@var{word}@}
+If @var{parameter}
+is null or unset, nothing is substituted, otherwise the expansion of
+@var{word} is substituted.
+
+@item $@{@var{parameter}:@var{offset}@}
+@itemx $@{@var{parameter}:@var{offset}:@var{length}@}
+Expands to up to @var{length} characters of @var{parameter}
+starting at the character specified by @var{offset}.
+If @var{length} is omitted, expands to the substring of
+@var{parameter} starting at the character specified by @var{offset}.
+@var{length} and @var{offset} are arithmetic expressions
+(@pxref{Shell Arithmetic}).
+This is referred to as Substring Expansion.
+
+@var{length} must evaluate to a number greater than or equal to zero.
+If @var{offset} evaluates to a number less than zero, the value
+is used as an offset from the end of the value of @var{parameter}.
+If @var{parameter} is @samp{@@}, the result is @var{length} positional
+parameters beginning at @var{offset}.
+If @var{parameter} is an array name indexed by @samp{@@} or @samp{*},
+the result is the @var{length}
+members of the array beginning with @code{$@{@var{parameter}[@var{offset}]@}}.
+A negative @var{offset} is taken relative to one greater than the maximum
+index of the specified array.
+Note that a negative offset must be separated from the colon by at least
+one space to avoid being confused with the @samp{:-} expansion.
+Substring indexing is zero-based unless the positional parameters
+are used, in which case the indexing starts at 1 by default.
+If @var{offset} is 0, and the positional parameters are used, @code{$@@} is
+prefixed to the list.
+
+@item $@{!@var{prefix}*@}
+@itemx $@{!@var{prefix}@@@}
+Expands to the names of variables whose names begin with @var{prefix},
+separated by the first character of the @env{IFS} special variable.
+When @samp{@@} is used and the expansion appears within double quotes, each
+variable name expands to a separate word.
+
+@item $@{!@var{name}[@@]@}
+@itemx $@{!@var{name}[*]@}
+If @var{name} is an array variable, expands to the list of array indices
+(keys) assigned in @var{name}.
+If @var{name} is not an array, expands to 0 if @var{name} is set and null
+otherwise.
+When @samp{@@} is used and the expansion appears within double quotes, each
+key expands to a separate word.
+
+@item $@{#@var{parameter}@}
+The length in characters of the expanded value of @var{parameter} is
+substituted.
+If @var{parameter} is @samp{*} or @samp{@@}, the value substituted
+is the number of positional parameters.
+If @var{parameter} is an array name subscripted by @samp{*} or @samp{@@}, 
+the value substituted is the number of elements in the array.
+
+@item $@{@var{parameter}#@var{word}@}
+@itemx $@{@var{parameter}##@var{word}@}
+The @var{word}
+is expanded to produce a pattern just as in filename
+expansion (@pxref{Filename Expansion}).  If the pattern matches
+the beginning of the expanded value of @var{parameter},
+then the result of the expansion is the expanded value of @var{parameter}
+with the shortest matching pattern (the @samp{#} case) or the
+longest matching pattern (the @samp{##} case) deleted.
+If @var{parameter} is @samp{@@} or @samp{*},
+the pattern removal operation is applied to each positional
+parameter in turn, and the expansion is the resultant list.
+If @var{parameter} is an array variable subscripted with
+@samp{@@} or @samp{*},
+the pattern removal operation is applied to each member of the
+array in turn, and the expansion is the resultant list.
+
+@item $@{@var{parameter}%@var{word}@}
+@itemx $@{@var{parameter}%%@var{word}@}
+The @var{word} is expanded to produce a pattern just as in
+filename expansion.
+If the pattern matches a trailing portion of the expanded value of
+@var{parameter}, then the result of the expansion is the value of
+@var{parameter} with the shortest matching pattern (the @samp{%} case)
+or the longest matching pattern (the @samp{%%} case) deleted.
+If @var{parameter} is @samp{@@} or @samp{*},
+the pattern removal operation is applied to each positional
+parameter in turn, and the expansion is the resultant list.
+If @var{parameter}
+is an array variable subscripted with @samp{@@} or @samp{*},
+the pattern removal operation is applied to each member of the
+array in turn, and the expansion is the resultant list.
+
+@item $@{@var{parameter}/@var{pattern}/@var{string}@} 
+
+The @var{pattern} is expanded to produce a pattern just as in
+filename expansion.
+@var{Parameter} is expanded and the longest match of @var{pattern}
+against its value is replaced with @var{string}.
+If @var{pattern} begins with @samp{/}, all matches of @var{pattern} are
+replaced with @var{string}.  Normally only the first match is replaced.
+If @var{pattern} begins with @samp{#}, it must match at the beginning
+of the expanded value of @var{parameter}.
+If @var{pattern} begins with @samp{%}, it must match at the end
+of the expanded value of @var{parameter}.
+If @var{string} is null, matches of @var{pattern} are deleted
+and the @code{/} following @var{pattern} may be omitted.
+If @var{parameter} is @samp{@@} or @samp{*},
+the substitution operation is applied to each positional
+parameter in turn, and the expansion is the resultant list.
+If @var{parameter}
+is an array variable subscripted with @samp{@@} or @samp{*},
+the substitution operation is applied to each member of the
+array in turn, and the expansion is the resultant list.
+
+@end table
+
+@node Command Substitution
+@subsection Command Substitution
+@cindex command substitution
+
+Command substitution allows the output of a command to replace
+the command itself.
+Command substitution occurs when a command is enclosed as follows:
+@example
+$(@var{command})
+@end example
+@noindent
+or
+@example
+`@var{command}`
+@end example
+
+@noindent
+Bash performs the expansion by executing @var{command} and
+replacing the command substitution with the standard output of the
+command, with any trailing newlines deleted.
+Embedded newlines are not deleted, but they may be removed during
+word splitting.
+The command substitution @code{$(cat @var{file})} can be
+replaced by the equivalent but faster @code{$(< @var{file})}.
+
+When the old-style backquote form of substitution is used,
+backslash retains its literal meaning except when followed by
+@samp{$}, @samp{`}, or @samp{\}. 
+The first backquote not preceded by a backslash terminates the
+command substitution.
+When using the @code{$(@var{command})} form, all characters between
+the parentheses make up the command; none are treated specially.
+
+Command substitutions may be nested.  To nest when using the backquoted
+form, escape the inner backquotes with backslashes.
+
+If the substitution appears within double quotes, word splitting and
+filename expansion are not performed on the results.
+
+@node Arithmetic Expansion
+@subsection Arithmetic Expansion
+@cindex expansion, arithmetic
+@cindex arithmetic expansion
+
+Arithmetic expansion allows the evaluation of an arithmetic expression
+and the substitution of the result.  The format for arithmetic expansion is:
+
+@example
+$(( @var{expression} ))
+@end example
+
+The expression is treated as if it were within double quotes, but
+a double quote inside the parentheses is not treated specially.
+All tokens in the expression undergo parameter expansion, command
+substitution, and quote removal.
+Arithmetic expansions may be nested. 
+
+The evaluation is performed according to the rules listed below
+(@pxref{Shell Arithmetic}).
+If the expression is invalid, Bash prints a message indicating
+failure to the standard error and no substitution occurs.
+
+@node Process Substitution
+@subsection Process Substitution
+@cindex process substitution
+
+Process substitution is supported on systems that support named
+pipes (@sc{fifo}s) or the @file{/dev/fd} method of naming open files.
+It takes the form of 
+@example
+<(@var{list})
+@end example
+@noindent
+or
+@example
+>(@var{list})
+@end example
+@noindent
+The process @var{list} is run with its input or output connected to a
+@sc{fifo} or some file in @file{/dev/fd}.  The name of this file is
+passed as an argument to the current command as the result of the
+expansion.  If the @code{>(@var{list})} form is used, writing to
+the file will provide input for @var{list}.  If the
+@code{<(@var{list})} form is used, the file passed as an
+argument should be read to obtain the output of @var{list}.
+Note that no space may appear between the @code{<} or @code{>}
+and the left parenthesis, otherwise the construct would be interpreted
+as a redirection.
+
+When available, process substitution is performed simultaneously with
+parameter and variable expansion, command substitution, and arithmetic
+expansion.
+
+@node Word Splitting
+@subsection Word Splitting
+@cindex word splitting
+
+The shell scans the results of parameter expansion, command substitution,
+and arithmetic expansion that did not occur within double quotes for
+word splitting.
+
+The shell treats each character of @env{$IFS} as a delimiter, and splits
+the results of the other expansions into words on these characters.
+If @env{IFS} is unset, or its value is exactly @code{<space><tab><newline>},
+the default, then sequences of
+@code{ <space>}, @code{<tab>}, and @code{<newline>}
+at the beginning and end of the results of the previous
+expansions are ignored, and any sequence of @env{IFS}
+characters not at the beginning or end serves to delimit words.
+If @env{IFS} has a value other than the default, then sequences of
+the whitespace characters @code{space} and @code{tab}
+are ignored at the beginning and end of the
+word, as long as the whitespace character is in the
+value of @env{IFS} (an @env{IFS} whitespace character).
+Any character in @env{IFS} that is not @env{IFS}
+whitespace, along with any adjacent @env{IFS}
+whitespace characters, delimits a field.  A sequence of @env{IFS}
+whitespace characters is also treated as a delimiter.
+If the value of @env{IFS} is null, no word splitting occurs.
+
+Explicit null arguments (@code{""} or @code{''}) are retained.
+Unquoted implicit null arguments, resulting from the expansion of
+parameters that have no values, are removed.
+If a parameter with no value is expanded within double quotes, a
+null argument results and is retained.
+
+Note that if no expansion occurs, no splitting
+is performed.
+
+@node Filename Expansion
+@subsection Filename Expansion
+@menu
+* Pattern Matching::   How the shell matches patterns.
+@end menu
+@cindex expansion, filename
+@cindex expansion, pathname
+@cindex filename expansion
+@cindex pathname expansion
+
+After word splitting, unless the @option{-f} option has been set
+(@pxref{The Set Builtin}), Bash scans each word for the characters
+@samp{*}, @samp{?}, and @samp{[}.
+If one of these characters appears, then the word is
+regarded as a @var{pattern},
+and replaced with an alphabetically sorted list of
+file names matching the pattern. If no matching file names are found,
+and the shell option @code{nullglob} is disabled, the word is left
+unchanged.
+If the @code{nullglob} option is set, and no matches are found, the word
+is removed.
+If the @code{failglob} shell option is set, and no matches are found,
+an error message is printed and the command is not executed.
+If the shell option @code{nocaseglob} is enabled, the match is performed
+without regard to the case of alphabetic characters.
+
+When a pattern is used for filename generation, the character @samp{.}
+at the start of a filename or immediately following a slash
+must be matched explicitly, unless the shell option @code{dotglob} is set.
+When matching a file name, the slash character must always be
+matched explicitly.
+In other cases, the @samp{.} character is not treated specially.
+
+See the description of @code{shopt} in @ref{The Shopt Builtin},
+for a description of the @code{nocaseglob}, @code{nullglob},
+@code{failglob}, and @code{dotglob} options.
+
+The @env{GLOBIGNORE}
+shell variable may be used to restrict the set of filenames matching a
+pattern.  If @env{GLOBIGNORE}
+is set, each matching filename that also matches one of the patterns in
+@env{GLOBIGNORE} is removed from the list of matches.  The filenames
+@file{.} and @file{..}
+are always ignored when @env{GLOBIGNORE}
+is set and not null.
+However, setting @env{GLOBIGNORE} to a non-null value has the effect of
+enabling the @code{dotglob}
+shell option, so all other filenames beginning with a
+@samp{.} will match.
+To get the old behavior of ignoring filenames beginning with a
+@samp{.}, make @samp{.*} one of the patterns in @env{GLOBIGNORE}.
+The @code{dotglob} option is disabled when @env{GLOBIGNORE}
+is unset.
+
+@node Pattern Matching
+@subsubsection Pattern Matching
+@cindex pattern matching
+@cindex matching, pattern
+
+Any character that appears in a pattern, other than the special pattern
+characters described below, matches itself.
+The @sc{nul} character may not occur in a pattern.
+A backslash escapes the following character; the
+escaping backslash is discarded when matching.
+The special pattern characters must be quoted if they are to be matched
+literally.
+
+The special pattern characters have the following meanings:
+@table @code
+@item *
+Matches any string, including the null string.
+@item ?
+Matches any single character.
+@item [@dots{}]
+Matches any one of the enclosed characters.  A pair of characters
+separated by a hyphen denotes a @var{range expression};
+any character that sorts between those two characters, inclusive,
+using the current locale's collating sequence and character set,
+is matched.  If the first character following the
+@samp{[} is a @samp{!}  or a @samp{^}
+then any character not enclosed is matched.  A @samp{@minus{}}
+may be matched by including it as the first or last character
+in the set.  A @samp{]} may be matched by including it as the first
+character in the set.
+The sorting order of characters in range expressions is determined by
+the current locale and the value of the @env{LC_COLLATE} shell variable,
+if set.
+
+For example, in the default C locale, @samp{[a-dx-z]} is equivalent to
+@samp{[abcdxyz]}.  Many locales sort characters in dictionary order, and in
+these locales @samp{[a-dx-z]} is typically not equivalent to @samp{[abcdxyz]};
+it might be equivalent to @samp{[aBbCcDdxXyYz]}, for example.  To obtain
+the traditional interpretation of ranges in bracket expressions, you can
+force the use of the C locale by setting the @env{LC_COLLATE} or
+@env{LC_ALL} environment variable to the value @samp{C}.
+
+Within @samp{[} and @samp{]}, @var{character classes} can be specified
+using the syntax
+@code{[:}@var{class}@code{:]}, where @var{class} is one of the
+following classes defined in the @sc{posix} standard:
+@example
+alnum   alpha   ascii   blank   cntrl   digit   graph   lower
+print   punct   space   upper   word    xdigit
+@end example
+@noindent
+A character class matches any character belonging to that class.
+The @code{word} character class matches letters, digits, and the character
+@samp{_}.
+
+Within @samp{[} and @samp{]}, an @var{equivalence class} can be
+specified using the syntax @code{[=}@var{c}@code{=]}, which
+matches all characters with the same collation weight (as defined
+by the current locale) as the character @var{c}.
+
+Within @samp{[} and @samp{]}, the syntax @code{[.}@var{symbol}@code{.]}
+matches the collating symbol @var{symbol}.
+@end table
+
+If the @code{extglob} shell option is enabled using the @code{shopt}
+builtin, several extended pattern matching operators are recognized.
+In the following description, a @var{pattern-list} is a list of one
+or more patterns separated by a @samp{|}.
+Composite patterns may be formed using one or more of the following
+sub-patterns:
+
+@table @code
+@item ?(@var{pattern-list})
+Matches zero or one occurrence of the given patterns.
+
+@item *(@var{pattern-list})
+Matches zero or more occurrences of the given patterns.
+
+@item +(@var{pattern-list})
+Matches one or more occurrences of the given patterns.
+
+@item @@(@var{pattern-list})
+Matches one of the given patterns.
+
+@item !(@var{pattern-list})
+Matches anything except one of the given patterns.
+@end table
+
+@node Quote Removal
+@subsection Quote Removal
+
+After the preceding expansions, all unquoted occurrences of the
+characters @samp{\}, @samp{'}, and @samp{"} that did not
+result from one of the above expansions are removed.
+
+@node Redirections
+@section Redirections
+@cindex redirection
+
+Before a command is executed, its input and output
+may be @var{redirected}
+using a special notation interpreted by the shell.
+Redirection may also be used to open and close files for the
+current shell execution environment.  The following redirection
+operators may precede or appear anywhere within a
+simple command or may follow a command.
+Redirections are processed in the order they appear, from
+left to right.
+
+In the following descriptions, if the file descriptor number is
+omitted, and the first character of the redirection operator is
+@samp{<}, the redirection refers to the standard input (file
+descriptor 0).  If the first character of the redirection operator
+is @samp{>}, the redirection refers to the standard output (file
+descriptor 1).
+
+The word following the redirection operator in the following
+descriptions, unless otherwise noted, is subjected to brace expansion,
+tilde expansion, parameter expansion, command substitution, arithmetic
+expansion, quote removal, filename expansion, and word splitting.
+If it expands to more than one word, Bash reports an error.
+
+Note that the order of redirections is significant.  For example,
+the command
+@example
+ls > @var{dirlist} 2>&1
+@end example
+@noindent
+directs both standard output (file descriptor 1) and standard error
+(file descriptor 2) to the file @var{dirlist}, while the command
+@example
+ls 2>&1 > @var{dirlist}
+@end example
+@noindent
+directs only the standard output to file @var{dirlist},
+because the standard error was duplicated as standard output
+before the standard output was redirected to @var{dirlist}.
+
+Bash handles several filenames specially when they are used in
+redirections, as described in the following table:
+
+@table @code
+@item /dev/fd/@var{fd}
+If @var{fd} is a valid integer, file descriptor @var{fd} is duplicated.
+
+@item /dev/stdin
+File descriptor 0 is duplicated.
+
+@item /dev/stdout
+File descriptor 1 is duplicated.
+
+@item /dev/stderr
+File descriptor 2 is duplicated.
+
+@item /dev/tcp/@var{host}/@var{port}
+If @var{host} is a valid hostname or Internet address, and @var{port}
+is an integer port number or service name, Bash attempts to open a TCP
+connection to the corresponding socket.
+
+@item /dev/udp/@var{host}/@var{port}
+If @var{host} is a valid hostname or Internet address, and @var{port}
+is an integer port number or service name, Bash attempts to open a UDP
+connection to the corresponding socket.
+
+@end table
+
+A failure to open or create a file causes the redirection to fail.
+
+Redirections using file descriptors greater than 9 should be used with
+care, as they may conflict with file descriptors the shell uses
+internally.
+
+@subsection Redirecting Input
+Redirection of input causes the file whose name results from
+the expansion of @var{word}
+to be opened for reading on file descriptor @code{n},
+or the standard input (file descriptor 0) if @code{n}
+is not specified.
+
+The general format for redirecting input is:
+@example
+[@var{n}]<@var{word}
+@end example
+
+@subsection Redirecting Output
+Redirection of output causes the file whose name results from
+the expansion of @var{word}
+to be opened for writing on file descriptor @var{n},
+or the standard output (file descriptor 1) if @var{n}
+is not specified.  If the file does not exist it is created;
+if it does exist it is truncated to zero size.
+
+The general format for redirecting output is:
+@example
+[@var{n}]>[|]@var{word}
+@end example
+
+If the redirection operator is @samp{>}, and the @code{noclobber}
+option to the @code{set} builtin has been enabled, the redirection
+will fail if the file whose name results from the expansion of
+@var{word} exists and is a regular file.
+If the redirection operator is @samp{>|}, or the redirection operator is
+@samp{>} and the @code{noclobber} option is not enabled, the redirection
+is attempted even if the file named by @var{word} exists.
+
+@subsection Appending Redirected Output
+Redirection of output in this fashion
+causes the file whose name results from
+the expansion of @var{word}
+to be opened for appending on file descriptor @var{n},
+or the standard output (file descriptor 1) if @var{n}
+is not specified.  If the file does not exist it is created.
+
+The general format for appending output is:
+@example
+[@var{n}]>>@var{word}
+@end example
+
+@subsection Redirecting Standard Output and Standard Error
+Bash allows both the
+standard output (file descriptor 1) and
+the standard error output (file descriptor 2)
+to be redirected to the file whose name is the
+expansion of @var{word} with this construct.
+
+There are two formats for redirecting standard output and
+standard error:
+@example
+&>@var{word}
+@end example
+@noindent
+and
+@example
+>&@var{word}
+@end example
+@noindent
+Of the two forms, the first is preferred.
+This is semantically equivalent to
+@example
+>@var{word} 2>&1
+@end example
+
+@subsection Here Documents
+This type of redirection instructs the shell to read input from the
+current source until a line containing only @var{word}
+(with no trailing blanks) is seen.  All of
+the lines read up to that point are then used as the standard
+input for a command.
+
+The format of here-documents is:
+@example
+<<[@minus{}]@var{word}
+        @var{here-document}
+@var{delimiter}
+@end example
+
+No parameter expansion, command substitution, arithmetic expansion,
+or filename expansion is performed on
+@var{word}.  If any characters in @var{word} are quoted, the
+@var{delimiter} is the result of quote removal on @var{word},
+and the lines in the here-document are not expanded.
+If @var{word} is unquoted,
+all lines of the here-document are subjected to parameter expansion,
+command substitution, and arithmetic expansion.  In the latter
+case, the character sequence @code{\newline} is ignored, and @samp{\}
+must be used to quote the characters
+@samp{\}, @samp{$}, and @samp{`}.
+
+If the redirection operator is @samp{<<-},
+then all leading tab characters are stripped from input lines and the
+line containing @var{delimiter}.
+This allows here-documents within shell scripts to be indented in a
+natural fashion.
+
+@subsection Here Strings
+A variant of here documents, the format is:
+@example
+<<< @var{word}
+@end example
+
+The @var{word} is expanded and supplied to the command on its standard
+input.
+
+@subsection Duplicating File Descriptors
+The redirection operator
+@example
+[@var{n}]<&@var{word}
+@end example
+@noindent
+is used to duplicate input file descriptors.
+If @var{word}
+expands to one or more digits, the file descriptor denoted by @var{n}
+is made to be a copy of that file descriptor.
+If the digits in @var{word} do not specify a file descriptor open for
+input, a redirection error occurs.
+If @var{word}
+evaluates to @samp{-}, file descriptor @var{n} is closed.  If
+@var{n} is not specified, the standard input (file descriptor 0) is used.
+
+The operator
+@example
+[@var{n}]>&@var{word}
+@end example
+@noindent
+is used similarly to duplicate output file descriptors.  If
+@var{n} is not specified, the standard output (file descriptor 1) is used.
+If the digits in @var{word} do not specify a file descriptor open for
+output, a redirection error occurs.
+As a special case, if @var{n} is omitted, and @var{word} does not
+expand to one or more digits, the standard output and standard
+error are redirected as described previously.
+
+@subsection Moving File Descriptors
+The redirection operator
+@example
+[@var{n}]<&@var{digit}-
+@end example
+@noindent
+moves the file descriptor @var{digit} to file descriptor @var{n},
+or the standard input (file descriptor 0) if @var{n} is not specified.
+@var{digit} is closed after being duplicated to @var{n}.
+
+Similarly, the redirection operator
+@example
+[@var{n}]>&@var{digit}-
+@end example
+@noindent
+moves the file descriptor @var{digit} to file descriptor @var{n},
+or the standard output (file descriptor 1) if @var{n} is not specified.
+
+@subsection Opening File Descriptors for Reading and Writing
+The redirection operator
+@example
+[@var{n}]<>@var{word}
+@end example
+@noindent
+causes the file whose name is the expansion of @var{word}
+to be opened for both reading and writing on file descriptor
+@var{n}, or on file descriptor 0 if @var{n}
+is not specified.  If the file does not exist, it is created.
+
+@node Executing Commands
+@section Executing Commands
+
+@menu
+* Simple Command Expansion::   How Bash expands simple commands before
+                               executing them.
+* Command Search and Execution::       How Bash finds commands and runs them.
+* Command Execution Environment::      The environment in which Bash
+                                       executes commands that are not
+                                       shell builtins.
+* Environment::                The environment given to a command.
+* Exit Status::                The status returned by commands and how Bash
+                       interprets it.
+* Signals::            What happens when Bash or a command it runs
+                       receives a signal.
+@end menu
+
+@node Simple Command Expansion
+@subsection Simple Command Expansion
+@cindex command expansion
+
+When a simple command is executed, the shell performs the following
+expansions, assignments, and redirections, from left to right.
+
+@enumerate
+@item
+The words that the parser has marked as variable assignments (those
+preceding the command name) and redirections are saved for later
+processing.
+
+@item
+The words that are not variable assignments or redirections are
+expanded (@pxref{Shell Expansions}).
+If any words remain after expansion, the first word
+is taken to be the name of the command and the remaining words are
+the arguments.
+
+@item
+Redirections are performed as described above (@pxref{Redirections}).
+
+@item
+The text after the @samp{=} in each variable assignment undergoes tilde
+expansion, parameter expansion, command substitution, arithmetic expansion,
+and quote removal before being assigned to the variable.
+@end enumerate
+
+If no command name results, the variable assignments affect the current
+shell environment.  Otherwise, the variables are added to the environment
+of the executed command and do not affect the current shell environment.
+If any of the assignments attempts to assign a value to a readonly variable,
+an error occurs, and the command exits with a non-zero status.
+
+If no command name results, redirections are performed, but do not
+affect the current shell environment.  A redirection error causes the
+command to exit with a non-zero status.
+
+If there is a command name left after expansion, execution proceeds as
+described below.  Otherwise, the command exits.  If one of the expansions
+contained a command substitution, the exit status of the command is
+the exit status of the last command substitution performed.  If there
+were no command substitutions, the command exits with a status of zero.
+
+@node Command Search and Execution
+@subsection Command Search and Execution
+@cindex command execution
+@cindex command search
+
+After a command has been split into words, if it results in a
+simple command and an optional list of arguments, the following
+actions are taken.
+
+@enumerate
+@item
+If the command name contains no slashes, the shell attempts to
+locate it.  If there exists a shell function by that name, that
+function is invoked as described in @ref{Shell Functions}.
+
+@item
+If the name does not match a function, the shell searches for
+it in the list of shell builtins.  If a match is found, that
+builtin is invoked.
+
+@item
+If the name is neither a shell function nor a builtin,
+and contains no slashes, Bash searches each element of
+@env{$PATH} for a directory containing an executable file
+by that name.  Bash uses a hash table to remember the full
+pathnames of executable files to avoid multiple @env{PATH} searches
+(see the description of @code{hash} in @ref{Bourne Shell Builtins}).
+A full search of the directories in @env{$PATH}
+is performed only if the command is not found in the hash table.
+If the search is unsuccessful, the shell prints an error
+message and returns an exit status of 127.
+
+@item
+If the search is successful, or if the command name contains
+one or more slashes, the shell executes the named program in
+a separate execution environment.
+Argument 0 is set to the name given, and the remaining arguments
+to the command are set to the arguments supplied, if any.
+
+@item
+If this execution fails because the file is not in executable
+format, and the file is not a directory, it is assumed to be a
+@var{shell script} and the shell executes it as described in
+@ref{Shell Scripts}.
+
+@item
+If the command was not begun asynchronously, the shell waits for
+the command to complete and collects its exit status.
+
+@end enumerate
+
+@node Command Execution Environment
+@subsection Command Execution Environment
+@cindex execution environment
+
+The shell has an @var{execution environment}, which consists of the
+following:
+
+@itemize @bullet
+@item
+open files inherited by the shell at invocation, as modified by
+redirections supplied to the @code{exec} builtin
+
+@item
+the current working directory as set by @code{cd}, @code{pushd}, or
+@code{popd}, or inherited by the shell at invocation
+
+@item
+the file creation mode mask as set by @code{umask} or inherited from
+the shell's parent
+
+@item
+current traps set by @code{trap}
+
+@item
+shell parameters that are set by variable assignment or with @code{set}
+or inherited from the shell's parent in the environment
+
+@item
+shell functions defined during execution or inherited from the shell's
+parent in the environment
+
+@item
+options enabled at invocation (either by default or with command-line
+arguments) or by @code{set}
+
+@item
+options enabled by @code{shopt} (@pxref{The Shopt Builtin})
+
+@item
+shell aliases defined with @code{alias} (@pxref{Aliases})
+
+@item
+various process @sc{id}s, including those of background jobs
+(@pxref{Lists}), the value of @code{$$}, and the value of
+@env{$PPID}
+
+@end itemize
+
+When a simple command other than a builtin or shell function
+is to be executed, it
+is invoked in a separate execution environment that consists of
+the following.  Unless otherwise noted, the values are inherited
+from the shell.
+
+@itemize @bullet
+@item
+the shell's open files, plus any modifications and additions specified
+by redirections to the command
+
+@item
+the current working directory
+
+@item
+the file creation mode mask
+
+@item
+shell variables and functions marked for export, along with variables
+exported for the command, passed in the environment (@pxref{Environment})
+
+@item
+traps caught by the shell are reset to the values inherited from the
+shell's parent, and traps ignored by the shell are ignored
+
+@end itemize
+
+A command invoked in this separate environment cannot affect the
+shell's execution environment. 
+
+Command substitution, commands grouped with parentheses,
+and asynchronous commands are invoked in a
+subshell environment that is a duplicate of the shell environment,
+except that traps caught by the shell are reset to the values
+that the shell inherited from its parent at invocation.  Builtin
+commands that are invoked as part of a pipeline are also executed
+in a subshell environment.  Changes made to the subshell environment
+cannot affect the shell's execution environment.
+
+If a command is followed by a @samp{&} and job control is not active, the
+default standard input for the command is the empty file @file{/dev/null}.
+Otherwise, the invoked command inherits the file descriptors of the calling
+shell as modified by redirections.
+
+@node Environment
+@subsection Environment
+@cindex environment
+
+When a program is invoked it is given an array of strings
+called the @var{environment}.
+This is a list of name-value pairs, of the form @code{name=value}.
+
+Bash provides several ways to manipulate the environment.
+On invocation, the shell scans its own environment and
+creates a parameter for each name found, automatically marking
+it for @var{export}
+to child processes.  Executed commands inherit the environment.
+The @code{export} and @samp{declare -x}
+commands allow parameters and functions to be added to and
+deleted from the environment.  If the value of a parameter
+in the environment is modified, the new value becomes part
+of the environment, replacing the old.  The environment
+inherited by any executed command consists of the shell's
+initial environment, whose values may be modified in the shell,
+less any pairs removed by the @code{unset} and @samp{export -n}
+commands, plus any additions via the @code{export} and
+@samp{declare -x} commands.
+
+The environment for any simple command
+or function may be augmented temporarily by prefixing it with
+parameter assignments, as described in @ref{Shell Parameters}.
+These assignment statements affect only the environment seen
+by that command.
+
+If the @option{-k} option is set (@pxref{The Set Builtin}), then all
+parameter assignments are placed in the environment for a command,
+not just those that precede the command name.
+
+When Bash invokes an external command, the variable @samp{$_}
+is set to the full path name of the command and passed to that
+command in its environment.
+
+@node Exit Status
+@subsection Exit Status
+@cindex exit status
+
+For the shell's purposes, a command which exits with a
+zero exit status has succeeded.
+A non-zero exit status indicates failure.
+This seemingly counter-intuitive scheme is used so there
+is one well-defined way to indicate success and a variety of
+ways to indicate various failure modes.
+When a command terminates on a fatal signal whose number is @var{N},
+Bash uses the value 128+@var{N} as the exit status.
+
+If a command is not found, the child process created to
+execute it returns a status of 127.  If a command is found  
+but is not executable, the return status is 126.
+
+If a command fails because of an error during expansion or redirection,
+the exit status is greater than zero.
+
+The exit status is used by the Bash conditional commands
+(@pxref{Conditional Constructs}) and some of the list
+constructs (@pxref{Lists}).
+
+All of the Bash builtins return an exit status of zero if they succeed
+and a non-zero status on failure, so they may be used by the
+conditional and list constructs.
+All builtins return an exit status of 2 to indicate incorrect usage.
+
+@node Signals
+@subsection Signals
+@cindex signal handling
+
+When Bash is interactive, in the absence of any traps, it ignores
+@code{SIGTERM} (so that @samp{kill 0} does not kill an interactive shell),
+and @code{SIGINT}
+is caught and handled (so that the @code{wait} builtin is interruptible).
+When Bash receives a @code{SIGINT}, it breaks out of any executing loops.
+In all cases, Bash ignores @code{SIGQUIT}.
+If job control is in effect (@pxref{Job Control}), Bash
+ignores @code{SIGTTIN}, @code{SIGTTOU}, and @code{SIGTSTP}.
+
+Non-builtin commands started by Bash have signal handlers set to the
+values inherited by the shell from its parent.
+When job control is not in effect, asynchronous commands
+ignore @code{SIGINT} and @code{SIGQUIT} in addition to these inherited
+handlers.
+Commands run as a result of
+command substitution ignore the keyboard-generated job control signals
+@code{SIGTTIN}, @code{SIGTTOU}, and @code{SIGTSTP}.
+
+The shell exits by default upon receipt of a @code{SIGHUP}.
+Before exiting, an interactive shell resends the @code{SIGHUP} to
+all jobs, running or stopped.
+Stopped jobs are sent @code{SIGCONT} to ensure that they receive
+the @code{SIGHUP}.
+To prevent the shell from sending the @code{SIGHUP} signal to a
+particular job, it should be removed
+from the jobs table with the @code{disown}
+builtin (@pxref{Job Control Builtins}) or marked
+to not receive @code{SIGHUP} using @code{disown -h}.
+
+If the  @code{huponexit} shell option has been set with @code{shopt}
+(@pxref{The Shopt Builtin}), Bash sends a @code{SIGHUP} to all jobs when
+an interactive login shell exits.
+
+If Bash is waiting for a command to complete and receives a signal
+for which a trap has been set, the trap will not be executed until
+the command completes. 
+When Bash is waiting for an asynchronous
+command via the @code{wait} builtin, the reception of a signal for
+which a trap has been set will cause the @code{wait} builtin to return
+immediately with an exit status greater than 128, immediately after
+which the trap is executed.
+
+@node Shell Scripts
+@section Shell Scripts
+@cindex shell script
+
+A shell script is a text file containing shell commands.  When such
+a file is used as the first non-option argument when invoking Bash,
+and neither the @option{-c} nor @option{-s} option is supplied
+(@pxref{Invoking Bash}), 
+Bash reads and executes commands from the file, then exits.  This
+mode of operation creates a non-interactive shell.  The shell first
+searches for the file in the current directory, and looks in the
+directories in @env{$PATH} if not found there.
+
+When Bash runs
+a shell script, it sets the special parameter @code{0} to the name
+of the file, rather than the name of the shell, and the positional
+parameters are set to the remaining arguments, if any are given.
+If no additional arguments are supplied, the positional parameters
+are unset.
+
+A shell script may be made executable by using the @code{chmod} command
+to turn on the execute bit.  When Bash finds such a file while
+searching the @env{$PATH} for a command, it spawns a subshell to
+execute it.  In other words, executing
+@example
+filename @var{arguments}
+@end example
+@noindent
+is equivalent to executing
+@example
+bash filename @var{arguments}
+@end example
+
+@noindent
+if @code{filename} is an executable shell script.
+This subshell reinitializes itself, so that the effect is as if a
+new shell had been invoked to interpret the script, with the
+exception that the locations of commands remembered by the parent
+(see the description of @code{hash} in @ref{Bourne Shell Builtins})
+are retained by the child.
+
+Most versions of Unix make this a part of the operating system's command
+execution mechanism.  If the first line of a script begins with
+the two characters @samp{#!}, the remainder of the line specifies
+an interpreter for the program.
+Thus, you can specify Bash, @code{awk}, Perl, or some other
+interpreter and write the rest of the script file in that language.
+
+The arguments to the interpreter
+consist of a single optional argument following the interpreter
+name on the first line of the script file, followed by the name of
+the script file, followed by the rest of the arguments.  Bash
+will perform this action on operating systems that do not handle it
+themselves.  Note that some older versions of Unix limit the interpreter
+name and argument to a maximum of 32 characters.
+
+Bash scripts often begin with @code{#! /bin/bash} (assuming that
+Bash has been installed in @file{/bin}), since this ensures that
+Bash will be used to interpret the script, even if it is executed
+under another shell.
+
+@node Shell Builtin Commands
+@chapter Shell Builtin Commands
+
+@menu
+* Bourne Shell Builtins::      Builtin commands inherited from the Bourne
+                               Shell.
+* Bash Builtins::              Table of builtins specific to Bash.
+* The Set Builtin::            Change the values of shell attributes and
+                               positional parameters.
+* The Shopt Builtin::          Modify shell optional behavior.
+* Special Builtins::           Builtin commands classified specially by
+                               POSIX.
+@end menu
+
+Builtin commands are contained within the shell itself.
+When the name of a builtin command is used as the first word of
+a simple command (@pxref{Simple Commands}), the shell executes
+the command directly, without invoking another program.
+Builtin commands are necessary to implement functionality impossible
+or inconvenient to obtain with separate utilities.
+
+This section briefly describes the builtins which Bash inherits from
+the Bourne Shell, as well as the builtin commands which are unique
+to or have been extended in Bash.
+
+Several builtin commands are described in other chapters:  builtin
+commands which provide the Bash interface to the job control
+facilities (@pxref{Job Control Builtins}), the directory stack
+(@pxref{Directory Stack Builtins}), the command history
+(@pxref{Bash History Builtins}), and the programmable completion
+facilities (@pxref{Programmable Completion Builtins}).
+
+Many of the builtins have been extended by @sc{posix} or Bash.
+
+Unless otherwise noted, each builtin command documented as accepting
+options preceded by @samp{-} accepts @samp{--}
+to signify the end of the options.
+For example, the @code{:}, @code{true}, @code{false}, and @code{test}
+builtins do not accept options.
+
+@node Bourne Shell Builtins
+@section Bourne Shell Builtins
+
+The following shell builtin commands are inherited from the Bourne Shell.
+These commands are implemented as specified by the @sc{posix} standard.
+
+@table @code
+@item :    @r{(a colon)}
+@btindex :
+@example
+: [@var{arguments}]
+@end example
+Do nothing beyond expanding @var{arguments} and performing redirections.
+The return status is zero.
+
+@item .    @r{(a period)}
+@btindex .
+@example
+. @var{filename} [@var{arguments}]
+@end example
+Read and execute commands from the @var{filename} argument in the
+current shell context.  If @var{filename} does not contain a slash,
+the @env{PATH} variable is used to find @var{filename}.
+When Bash is not in @sc{posix} mode, the current directory is searched
+if @var{filename} is not found in @env{$PATH}.
+If any @var{arguments} are supplied, they become the positional
+parameters when @var{filename} is executed.  Otherwise the positional
+parameters are unchanged.
+The return status is the exit status of the last command executed, or
+zero if no commands are executed.  If @var{filename} is not found, or
+cannot be read, the return status is non-zero.
+This builtin is equivalent to @code{source}.
+
+@item break
+@btindex break
+@example
+break [@var{n}]
+@end example
+Exit from a @code{for}, @code{while}, @code{until}, or @code{select} loop.
+If @var{n} is supplied, the @var{n}th enclosing loop is exited.
+@var{n} must be greater than or equal to 1.
+The return status is zero unless @var{n} is not greater than or equal to 1.
+
+@item cd
+@btindex cd
+@example
+cd [-L|-P] [@var{directory}]
+@end example
+Change the current working directory to @var{directory}.
+If @var{directory} is not given, the value of the @env{HOME} shell
+variable is used.
+If the shell variable @env{CDPATH} exists, it is used as a search path.
+If @var{directory} begins with a slash, @env{CDPATH} is not used.
+
+The @option{-P} option means to not follow symbolic links; symbolic
+links are followed by default or with the @option{-L} option.
+If @var{directory} is @samp{-}, it is equivalent to @env{$OLDPWD}.
+
+If a non-empty directory name from @env{CDPATH} is used, or if
+@samp{-} is the first argument, and the directory change is
+successful, the absolute pathname of the new working directory is
+written to the standard output.
+
+The return status is zero if the directory is successfully changed,
+non-zero otherwise.
+
+@item continue
+@btindex continue
+@example
+continue [@var{n}]
+@end example
+Resume the next iteration of an enclosing @code{for}, @code{while},
+@code{until}, or @code{select} loop.
+If @var{n} is supplied, the execution of the @var{n}th enclosing loop
+is resumed.
+@var{n} must be greater than or equal to 1.
+The return status is zero unless @var{n} is not greater than or equal to 1.
+
+@item eval
+@btindex eval
+@example
+eval [@var{arguments}]
+@end example
+The arguments are concatenated together into a single command, which is
+then read and executed, and its exit status returned as the exit status
+of @code{eval}.
+If there are no arguments or only empty arguments, the return status is
+zero.
+
+@item exec
+@btindex exec
+@example
+exec [-cl] [-a @var{name}] [@var{command} [@var{arguments}]]
+@end example
+If @var{command}
+is supplied, it replaces the shell without creating a new process.
+If the @option{-l} option is supplied, the shell places a dash at the
+beginning of the zeroth argument passed to @var{command}.
+This is what the @code{login} program does.
+The @option{-c} option causes @var{command} to be executed with an empty
+environment.
+If @option{-a} is supplied, the shell passes @var{name} as the zeroth
+argument to @var{command}.
+If no @var{command} is specified, redirections may be used to affect
+the current shell environment.  If there are no redirection errors, the
+return status is zero; otherwise the return status is non-zero.
+
+@item exit
+@btindex exit
+@example
+exit [@var{n}]
+@end example
+Exit the shell, returning a status of @var{n} to the shell's parent.
+If @var{n} is omitted, the exit status is that of the last command executed.
+Any trap on @code{EXIT} is executed before the shell terminates.
+
+@item export
+@btindex export
+@example
+export [-fn] [-p] [@var{name}[=@var{value}]]
+@end example
+Mark each @var{name} to be passed to child processes
+in the environment.  If the @option{-f} option is supplied, the @var{name}s
+refer to shell functions; otherwise the names refer to shell variables.
+The @option{-n} option means to no longer mark each @var{name} for export.
+If no @var{names} are supplied, or if the @option{-p} option is given, a
+list of exported names is displayed.
+The @option{-p} option displays output in a form that may be reused as input.
+If a variable name is followed by =@var{value}, the value of
+the variable is set to @var{value}.
+
+The return status is zero unless an invalid option is supplied, one of
+the names is not a valid shell variable name, or @option{-f} is supplied
+with a name that is not a shell function.
+
+@item getopts
+@btindex getopts
+@example
+getopts @var{optstring} @var{name} [@var{args}]
+@end example
+@code{getopts} is used by shell scripts to parse positional parameters.
+@var{optstring} contains the option characters to be recognized; if a
+character is followed by a colon, the option is expected to have an
+argument, which should be separated from it by white space.
+The colon (@samp{:}) and question mark (@samp{?}) may not be
+used as option characters.
+Each time it is invoked, @code{getopts}
+places the next option in the shell variable @var{name}, initializing
+@var{name} if it does not exist,
+and the index of the next argument to be processed into the
+variable @env{OPTIND}.
+@env{OPTIND} is initialized to 1 each time the shell or a shell script
+is invoked.
+When an option requires an argument,
+@code{getopts} places that argument into the variable @env{OPTARG}.
+The shell does not reset @env{OPTIND} automatically; it must be manually
+reset between multiple calls to @code{getopts} within the same shell
+invocation if a new set of parameters is to be used.
+
+When the end of options is encountered, @code{getopts} exits with a
+return value greater than zero.
+@env{OPTIND} is set to the index of the first non-option argument,
+and @code{name} is set to @samp{?}.
+
+@code{getopts}
+normally parses the positional parameters, but if more arguments are
+given in @var{args}, @code{getopts} parses those instead.
+
+@code{getopts} can report errors in two ways.  If the first character of
+@var{optstring} is a colon, @var{silent}
+error reporting is used.  In normal operation diagnostic messages
+are printed when invalid options or missing option arguments are
+encountered.
+If the variable @env{OPTERR}
+is set to 0, no error messages will be displayed, even if the first
+character of @code{optstring} is not a colon.
+
+If an invalid option is seen,
+@code{getopts} places @samp{?} into @var{name} and, if not silent,
+prints an error message and unsets @env{OPTARG}.
+If @code{getopts} is silent, the option character found is placed in
+@env{OPTARG} and no diagnostic message is printed.
+
+If a required argument is not found, and @code{getopts}
+is not silent, a question mark (@samp{?}) is placed in @var{name},
+@code{OPTARG} is unset, and a diagnostic message is printed.
+If @code{getopts} is silent, then a colon (@samp{:}) is placed in
+@var{name} and @env{OPTARG} is set to the option character found.
+
+@item hash
+@btindex hash
+@example
+hash [-r] [-p @var{filename}] [-dt] [@var{name}]
+@end example
+Remember the full pathnames of commands specified as @var{name} arguments,
+so they need not be searched for on subsequent invocations.
+The commands are found by searching through the directories listed in
+@env{$PATH}.
+The @option{-p} option inhibits the path search, and @var{filename} is
+used as the location of @var{name}.
+The @option{-r} option causes the shell to forget all remembered locations.
+The @option{-d} option causes the shell to forget the remembered location
+of each @var{name}.
+If the @option{-t} option is supplied, the full pathname to which each
+@var{name} corresponds is printed.  If multiple @var{name} arguments are
+supplied with @option{-t} the @var{name} is printed before the hashed
+full pathname.
+The @option{-l} option causes output to be displayed in a format
+that may be reused as input.
+If no arguments are given, or if only @option{-l} is supplied,
+information about remembered commands is printed.
+The return status is zero unless a @var{name} is not found or an invalid
+option is supplied.
+
+@item pwd
+@btindex pwd
+@example
+pwd [-LP]
+@end example
+Print the absolute pathname of the current working directory.
+If the @option{-P} option is supplied, the pathname printed will not
+contain symbolic links.
+If the @option{-L} option is supplied, the pathname printed may contain
+symbolic links.
+The return status is zero unless an error is encountered while
+determining the name of the current directory or an invalid option
+is supplied.
+
+@item readonly
+@btindex readonly
+@example
+readonly [-apf] [@var{name}[=@var{value}]] @dots{}
+@end example
+Mark each @var{name} as readonly.
+The values of these names may not be changed by subsequent assignment.
+If the @option{-f} option is supplied, each @var{name} refers to a shell
+function.
+The @option{-a} option means each @var{name} refers to an array variable.
+If no @var{name} arguments are given, or if the @option{-p}
+option is supplied, a list of all readonly names is printed.
+The @option{-p} option causes output to be displayed in a format that
+may be reused as input.
+If a variable name is followed by =@var{value}, the value of
+the variable is set to @var{value}.
+The return status is zero unless an invalid option is supplied, one of
+the @var{name} arguments is not a valid shell variable or function name,
+or the @option{-f} option is supplied with a name that is not a shell function.
+
+@item return
+@btindex return
+@example
+return [@var{n}]
+@end example
+Cause a shell function to exit with the return value @var{n}.
+If @var{n} is not supplied, the return value is the exit status of the
+last command executed in the function.
+This may also be used to terminate execution of a script being executed
+with the @code{.} (or @code{source}) builtin, returning either @var{n} or
+the exit status of the last command executed within the script as the exit
+status of the script.
+Any command associated with the @code{RETURN} trap is executed
+before execution resumes after the function or script.
+The return status is non-zero if @code{return} is used outside a function
+and not during the execution of a script by @code{.} or @code{source}.
+
+@item shift
+@btindex shift
+@example
+shift [@var{n}]
+@end example
+Shift the positional parameters to the left by @var{n}.
+The positional parameters from @var{n}+1 @dots{} @code{$#} are
+renamed to @code{$1} @dots{} @code{$#}-@var{n}+1.
+Parameters represented by the numbers @code{$#} to @var{n}+1 are unset.
+@var{n} must be a non-negative number less than or equal to @code{$#}.
+If @var{n} is zero or greater than @code{$#}, the positional parameters
+are not changed.
+If @var{n} is not supplied, it is assumed to be 1.
+The return status is zero unless @var{n} is greater than @code{$#} or
+less than zero, non-zero otherwise.
+
+@item test
+@itemx [
+@btindex test
+@btindex [
+Evaluate a conditional expression @var{expr}.
+Each operator and operand must be a separate argument.
+Expressions are composed of the primaries described below in
+@ref{Bash Conditional Expressions}.
+@code{test} does not accept any options, nor does it accept and ignore
+an argument of @option{--} as signifying the end of options.
+
+When the @code{[} form is used, the last argument to the command must
+be a @code{]}.
+
+Expressions may be combined using the following operators, listed in
+decreasing order of precedence.
+
+@table @code
+@item ! @var{expr}
+True if @var{expr} is false.
+
+@item ( @var{expr} )
+Returns the value of @var{expr}.
+This may be used to override the normal precedence of operators.
+
+@item @var{expr1} -a @var{expr2}
+True if both @var{expr1} and @var{expr2} are true.
+
+@item @var{expr1} -o @var{expr2}
+True if either @var{expr1} or @var{expr2} is true.
+@end table
+
+The @code{test} and @code{[} builtins evaluate conditional
+expressions using a set of rules based on the number of arguments.
+
+@table @asis
+@item 0 arguments
+The expression is false.
+
+@item 1 argument
+The expression is true if and only if the argument is not null.
+
+@item 2 arguments
+If the first argument is @samp{!}, the expression is true if and
+only if the second argument is null.
+If the first argument is one of the unary conditional operators
+(@pxref{Bash Conditional Expressions}), the expression
+is true if the unary test is true.
+If the first argument is not a valid unary operator, the expression is
+false.
+
+@item 3 arguments
+If the second argument is one of the binary conditional
+operators (@pxref{Bash Conditional Expressions}), the
+result of the expression is the result of the binary test using the
+first and third arguments as operands.
+If the first argument is @samp{!}, the value is the negation of
+the two-argument test using the second and third arguments.
+If the first argument is exactly @samp{(} and the third argument is
+exactly @samp{)}, the result is the one-argument test of the second
+argument.
+Otherwise, the expression is false.
+The @samp{-a} and @samp{-o} operators are considered binary operators
+in this case.  
+
+@item 4 arguments
+If the first argument is @samp{!}, the result is the negation of
+the three-argument expression composed of the remaining arguments.
+Otherwise, the expression is parsed and evaluated according to 
+precedence using the rules listed above.
+
+@item 5 or more arguments
+The expression is parsed and evaluated according to precedence
+using the rules listed above.
+@end table
+
+@item times
+@btindex times
+@example
+times
+@end example
+Print out the user and system times used by the shell and its children.
+The return status is zero.
+
+@item trap
+@btindex trap
+@example
+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 (and
+there is a single @var{sigspec}) or
+equal to @samp{-}, each specified signal's disposition is reset
+to the value it had when the shell was started.
+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 not present and @option{-p} has been supplied,
+the shell displays the trap commands associated with each @var{sigspec}.
+If no arguments are supplied, or
+only @option{-p} is given, @code{trap} prints the list of commands
+associated with each signal number in a form that may be reused as
+shell input.
+The @option{-l} option causes the shell to print a list of signal names
+and their corresponding numbers.
+Each @var{sigspec} is either a signal name or a signal number.
+Signal names are case insensitive and the @code{SIG} prefix is optional.
+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
+before every simple command, @code{for} command, @code{case} command,
+@code{select} command, every arithmetic @code{for} command, and before
+the first command executes in a shell function.
+Refer to the description of the @code{extglob} option to the
+@code{shopt} builtin (@pxref{The Shopt Builtin}) for details of its
+effect on the @code{DEBUG} trap.
+If a @var{sigspec} is @code{ERR}, the command @var{arg} 
+is executed whenever a simple command has a non-zero exit status,
+subject to the following conditions.
+The @code{ERR} trap is not executed if the failed command is part of the
+command list immediately following an @code{until} or @code{while} keyword,
+part of the test in an @code{if} statement,
+part of a @code{&&} or @code{||} list, or if the command's return
+status is being inverted using @code{!}.
+These are the same conditions obeyed by the @code{errexit} option.
+If a @var{sigspec} is @code{RETURN}, the command @var{arg} is executed
+each time a shell function or a script executed with the @code{.} or
+@code{source} builtins finishes executing.
+
+Signals ignored upon entry to the shell cannot be trapped or reset.
+Trapped signals that are not being ignored are reset to their original
+values in a child process when it is created.
+
+The return status is zero unless a @var{sigspec} does not specify a
+valid signal.
+
+@item umask
+@btindex umask
+@example
+umask [-p] [-S] [@var{mode}]
+@end example
+Set the shell process's file creation mask to @var{mode}.  If
+@var{mode} begins with a digit, it is interpreted as an octal number;
+if not, it is interpreted as a symbolic mode mask similar
+to that accepted by the @code{chmod} command.  If @var{mode} is
+omitted, the current value of the mask is printed.  If the @option{-S}
+option is supplied without a @var{mode} argument, the mask is printed
+in a symbolic format.
+If the  @option{-p} option is supplied, and @var{mode}
+is omitted, the output is in a form that may be reused as input.
+The return status is zero if the mode is successfully changed or if
+no @var{mode} argument is supplied, and non-zero otherwise.
+
+Note that when the mode is interpreted as an octal number, each number
+of the umask is subtracted from @code{7}.  Thus, a umask of @code{022}
+results in permissions of @code{755}.
+
+@item unset
+@btindex unset
+@example
+unset [-fv] [@var{name}]
+@end example
+Each variable or function @var{name} is removed.
+If no options are supplied, or the @option{-v} option is given, each
+@var{name} refers to a shell variable. 
+If the @option{-f} option is given, the @var{name}s refer to shell
+functions, and the function definition is removed.
+Readonly variables and functions may not be unset.
+The return status is zero unless a @var{name} is readonly.
+@end table
+
+@node Bash Builtins
+@section Bash Builtin Commands
+
+This section describes builtin commands which are unique to
+or have been extended in Bash.
+Some of these commands are specified in the @sc{posix} standard.
+
+@table @code
+
+@item alias
+@btindex alias
+@example
+alias [@code{-p}] [@var{name}[=@var{value}] @dots{}]
+@end example
+
+Without arguments or with the @option{-p} option, @code{alias} prints
+the list of aliases on the standard output in a form that allows
+them to be reused as input.
+If arguments are supplied, an alias is defined for each @var{name}
+whose @var{value} is given.  If no @var{value} is given, the name
+and value of the alias is printed.
+Aliases are described in @ref{Aliases}.
+
+@item bind
+@btindex bind
+@example
+bind [-m @var{keymap}] [-lpsvPSV]
+bind [-m @var{keymap}] [-q @var{function}] [-u @var{function}] [-r @var{keyseq}]
+bind [-m @var{keymap}] -f @var{filename}
+bind [-m @var{keymap}] -x @var{keyseq:shell-command}
+bind [-m @var{keymap}] @var{keyseq:function-name}
+bind @var{readline-command}
+@end example
+
+Display current Readline (@pxref{Command Line Editing})
+key and function bindings,
+bind a key sequence to a Readline function or macro,
+or set a Readline variable.
+Each non-option argument is a command as it would appear in a
+Readline initialization file (@pxref{Readline Init File}),
+but each binding or command must be passed as a separate argument;  e.g.,
+@samp{"\C-x\C-r":re-read-init-file}.
+Options, if supplied, have the following meanings:
+
+@table @code
+@item -m @var{keymap}
+Use @var{keymap} as the keymap to be affected by
+the subsequent bindings.  Acceptable @var{keymap}
+names are
+@code{emacs},
+@code{emacs-standard},
+@code{emacs-meta},
+@code{emacs-ctlx},
+@code{vi},
+@code{vi-move},
+@code{vi-command}, and
+@code{vi-insert}.
+@code{vi} is equivalent to @code{vi-command};
+@code{emacs} is equivalent to @code{emacs-standard}.
+
+@item -l
+List the names of all Readline functions.
+
+@item -p
+Display Readline function names and bindings in such a way that they
+can be used as input or in a Readline initialization file.
+
+@item -P
+List current Readline function names and bindings.
+
+@item -v
+Display Readline variable names and values in such a way that they
+can be used as input or in a Readline initialization file.
+
+@item -V
+List current Readline variable names and values.
+
+@item -s
+Display Readline key sequences bound to macros and the strings they output
+in such a way that they can be used as input or in a Readline
+initialization file.
+
+@item -S
+Display Readline key sequences bound to macros and the strings they output.
+
+@item -f @var{filename}
+Read key bindings from @var{filename}.
+
+@item -q @var{function}
+Query about which keys invoke the named @var{function}.
+
+@item -u @var{function}
+Unbind all keys bound to the named @var{function}.
+
+@item -r @var{keyseq}
+Remove any current binding for @var{keyseq}.
+
+@item -x @var{keyseq:shell-command}
+Cause @var{shell-command} to be executed whenever @var{keyseq} is
+entered.
+
+@end table
+
+@noindent
+The return status is zero unless an invalid option is supplied or an
+error occurs.
+
+@item builtin
+@btindex builtin
+@example
+builtin [@var{shell-builtin} [@var{args}]]
+@end example
+Run a shell builtin, passing it @var{args}, and return its exit status.
+This is useful when defining a shell function with the same
+name as a shell builtin, retaining the functionality of the builtin within
+the function.
+The return status is non-zero if @var{shell-builtin} is not a shell
+builtin command.
+
+@item caller
+@btindex caller
+@example
+caller [@var{expr}]
+@end example
+Returns the context of any active subroutine call (a shell function or
+a script executed with the @code{.} or @code{source} builtins).
+
+Without @var{expr}, @code{caller} displays the line number and source
+filename of the current subroutine call.
+If a non-negative integer is supplied as @var{expr}, @code{caller} 
+displays the line number, subroutine name, and source file corresponding
+to that position in the current execution call stack.  This extra
+information may be used, for example, to print a stack trace.  The
+current frame is frame 0.
+
+The return value is 0 unless the shell is not executing a subroutine
+call or @var{expr} does not correspond to a valid position in the
+call stack.
+
+@item command
+@btindex command
+@example
+command [-pVv] @var{command} [@var{arguments} @dots{}]
+@end example
+Runs @var{command} with @var{arguments} ignoring any shell function
+named @var{command}.
+Only shell builtin commands or commands found by searching the
+@env{PATH} are executed.
+If there is a shell function named @code{ls}, running @samp{command ls}
+within the function will execute the external command @code{ls}
+instead of calling the function recursively.
+The @option{-p} option means to use a default value for @env{PATH}
+that is guaranteed to find all of the standard utilities.
+The return status in this case is 127 if @var{command} cannot be
+found or an error occurred, and the exit status of @var{command}
+otherwise.
+
+If either the @option{-V} or @option{-v} option is supplied, a
+description of @var{command} is printed.  The @option{-v} option
+causes a single word indicating the command or file name used to
+invoke @var{command} to be displayed; the @option{-V} option produces
+a more verbose description.  In this case, the return status is
+zero if @var{command} is found, and non-zero if not.
+
+@item declare
+@btindex declare
+@example
+declare [-afFirtx] [-p] [@var{name}[=@var{value}] @dots{}]
+@end example
+
+Declare variables and give them attributes.  If no @var{name}s
+are given, then display the values of variables instead. 
+
+The @option{-p} option will display the attributes and values of each
+@var{name}.
+When @option{-p} is used, additional options are ignored.
+The @option{-F} option inhibits the display of function definitions;
+only the function name and attributes are printed.
+If the @code{extdebug} shell option is enabled using @code{shopt}
+(@pxref{The Shopt Builtin}), the source file name and line number where
+the function is defined are displayed as well.
+@option{-F} implies @option{-f}.
+The following options can be used to restrict output to variables with
+the specified attributes or to give variables attributes:
+
+@table @code
+@item -a
+Each @var{name} is an array variable (@pxref{Arrays}).
+
+@item -f
+Use function names only.
+
+@item -i
+The variable is to be treated as
+an integer; arithmetic evaluation (@pxref{Shell Arithmetic}) is
+performed when the variable is assigned a value.
+
+@item -r
+Make @var{name}s readonly.  These names cannot then be assigned values
+by subsequent assignment statements or unset.
+
+@item -t
+Give each @var{name} the @code{trace} attribute.
+Traced functions inherit the @code{DEBUG} and @code{RETURN} traps from
+the calling shell.
+The trace attribute has no special meaning for variables.
+
+@item -x
+Mark each @var{name} for export to subsequent commands via
+the environment.
+@end table
+
+Using @samp{+} instead of @samp{-} turns off the attribute instead,
+with the exceptions that @samp{+a}
+may not be used to destroy an array variable and @samp{+r} will not
+remove the readonly attribute.
+When used in a function, @code{declare} makes each @var{name} local,
+as with the @code{local} command.  If a variable name is followed by
+=@var{value}, the value of the variable is set to @var{value}.
+
+The return status is zero unless an invalid option is encountered,
+an attempt is made to define a function using @samp{-f foo=bar},
+an attempt is made to assign a value to a readonly variable,
+an attempt is made to assign a value to an array variable without
+using the compound assignment syntax (@pxref{Arrays}),
+one of the @var{names} is not a valid shell variable name,
+an attempt is made to turn off readonly status for a readonly variable,
+an attempt is made to turn off array status for an array variable,
+or an attempt is made to display a non-existent function with @option{-f}.
+
+@item echo
+@btindex echo
+@example
+echo [-neE] [@var{arg} @dots{}]
+@end example
+Output the @var{arg}s, separated by spaces, terminated with a
+newline.
+The return status is always 0.
+If @option{-n} is specified, the trailing newline is suppressed.
+If the @option{-e} option is given, interpretation of the following
+backslash-escaped characters is enabled.
+The @option{-E} option disables the interpretation of these escape characters,
+even on systems where they are interpreted by default.
+The @code{xpg_echo} shell option may be used to
+dynamically determine whether or not @code{echo} expands these
+escape characters by default.
+@code{echo} does not interpret @option{--} to mean the end of options.
+
+@code{echo} interprets the following escape sequences:
+@table @code
+@item \a
+alert (bell)
+@item \b
+backspace
+@item \c
+suppress trailing newline
+@item \e
+escape
+@item \f
+form feed
+@item \n
+new line
+@item \r
+carriage return
+@item \t 
+horizontal tab
+@item \v
+vertical tab
+@item \\
+backslash
+@item \0@var{nnn}
+the eight-bit character whose value is the octal value @var{nnn}
+(zero to three octal digits)
+@item \x@var{HH}
+the eight-bit character whose value is the hexadecimal value @var{HH}
+(one or two hex digits)
+@end table
+
+@item enable
+@btindex enable
+@example
+enable [-a] [-dnps] [-f @var{filename}] [@var{name} @dots{}]
+@end example
+Enable and disable builtin shell commands.
+Disabling a builtin allows a disk command which has the same name
+as a shell builtin to be executed without specifying a full pathname,
+even though the shell normally searches for builtins before disk commands.
+If @option{-n} is used, the @var{name}s become disabled.  Otherwise
+@var{name}s are enabled.  For example, to use the @code{test} binary
+found via @env{$PATH} instead of the shell builtin version, type
+@samp{enable -n test}.
+
+If the @option{-p} option is supplied, or no @var{name} arguments appear,
+a list of shell builtins is printed.  With no other arguments, the list
+consists of all enabled shell builtins.
+The @option{-a} option means to list
+each builtin with an indication of whether or not it is enabled. 
+
+The @option{-f} option means to load the new builtin command @var{name}
+from shared object @var{filename}, on systems that support dynamic loading.
+The @option{-d} option will delete a builtin loaded with @option{-f}.
+
+If there are no options, a list of the shell builtins is displayed.
+The @option{-s} option restricts @code{enable} to the @sc{posix} special
+builtins.  If @option{-s} is used with @option{-f}, the new builtin becomes
+a special builtin (@pxref{Special Builtins}).
+
+The return status is zero unless a @var{name} is not a shell builtin
+or there is an error loading a new builtin from a shared object.
+
+@item help
+@btindex help
+@example
+help [-s] [@var{pattern}]
+@end example
+Display helpful information about builtin commands.
+If @var{pattern} is specified, @code{help} gives detailed help
+on all commands matching @var{pattern}, otherwise a list of
+the builtins is printed.
+The @option{-s} option restricts the information displayed to a short
+usage synopsis.
+The return status is zero unless no command matches @var{pattern}.
+
+@item let
+@btindex let
+@example
+let @var{expression} [@var{expression}]
+@end example
+The @code{let} builtin allows arithmetic to be performed on shell
+variables.  Each @var{expression} is evaluated according to the
+rules given below in @ref{Shell Arithmetic}.  If the
+last @var{expression} evaluates to 0, @code{let} returns 1;
+otherwise 0 is returned.
+
+@item local
+@btindex local
+@example
+local [@var{option}] @var{name}[=@var{value}] @dots{}
+@end example
+For each argument, a local variable named @var{name} is created,
+and assigned @var{value}.
+The @var{option} can be any of the options accepted by @code{declare}.
+@code{local} can only be used within a function; it makes the variable
+@var{name} have a visible scope restricted to that function and its
+children.  The return status is zero unless @code{local} is used outside
+a function, an invalid @var{name} is supplied, or @var{name} is a
+readonly variable.
+
+@item logout
+@btindex logout
+@example
+logout [@var{n}]
+@end example
+Exit a login shell, returning a status of @var{n} to the shell's
+parent.
+
+@item printf
+@btindex printf
+@example
+@code{printf} [-v @var{var}] @var{format} [@var{arguments}]
+@end example
+Write the formatted @var{arguments} to the standard output under the
+control of the @var{format}.
+The @var{format} is a character string which contains three types of objects:
+plain characters, which are simply copied to standard output, character
+escape sequences, which are converted and copied to the standard output, and
+format specifications, each of which causes printing of the next successive
+@var{argument}.
+In addition to the standard @code{printf(1)} formats, @samp{%b} causes
+@code{printf} to expand backslash escape sequences in the corresponding
+@var{argument},
+(except that @samp{\c} terminates output, backslashes in
+@samp{\'}, @samp{\"}, and @samp{\?} are not removed, and octal escapes
+beginning with @samp{\0} may contain up to four digits),
+and @samp{%q} causes @code{printf} to output the
+corresponding @var{argument} in a format that can be reused as shell input.
+
+The @option{-v} option causes the output to be assigned to the variable
+@var{var} rather than being printed to the standard output.
+
+The @var{format} is reused as necessary to consume all of the @var{arguments}.
+If the @var{format} requires more @var{arguments} than are supplied, the
+extra format specifications behave as if a zero value or null string, as
+appropriate, had been supplied.  The return value is zero on success,
+non-zero on failure.
+
+@item read
+@btindex read
+@example
+read [-ers] [-a @var{aname}] [-d @var{delim}] [-n @var{nchars}] [-p @var{prompt}] [-t @var{timeout}] [-u @var{fd}] [@var{name} @dots{}]
+@end example
+One line is read from the standard input, or from the file descriptor
+@var{fd} supplied as an argument to the @option{-u} option, and the first word
+is assigned to the first @var{name}, the second word to the second @var{name},
+and so on, with leftover words and their intervening separators assigned
+to the last @var{name}.
+If there are fewer words read from the input stream than names,
+the remaining names are assigned empty values.
+The characters in the value of the @env{IFS} variable
+are used to split the line into words.
+The backslash character @samp{\} may be used to remove any special
+meaning for the next character read and for line continuation.
+If no names are supplied, the line read is assigned to the
+variable @env{REPLY}.
+The return code is zero, unless end-of-file is encountered, @code{read}
+times out, or an invalid file descriptor is supplied as the argument to
+@option{-u}.
+Options, if supplied, have the following meanings:
+
+@table @code
+@item -a @var{aname}
+The words are assigned to sequential indices of the array variable
+@var{aname}, starting at 0.
+All elements are removed from @var{aname} before the assignment.
+Other @var{name} arguments are ignored.
+
+@item -d @var{delim}
+The first character of @var{delim} is used to terminate the input line,
+rather than newline.
+
+@item -e
+Readline (@pxref{Command Line Editing}) is used to obtain the line.
+
+@item -n @var{nchars}
+@code{read} returns after reading @var{nchars} characters rather than
+waiting for a complete line of input.
+
+@item -p @var{prompt}
+Display @var{prompt}, without a trailing newline, before attempting
+to read any input.
+The prompt is displayed only if input is coming from a terminal.
+
+@item -r
+If this option is given, backslash does not act as an escape character.
+The backslash is considered to be part of the line.
+In particular, a backslash-newline pair may not be used as a line
+continuation.
+
+@item -s
+Silent mode.  If input is coming from a terminal, characters are
+not echoed.
+
+@item -t @var{timeout}
+Cause @code{read} to time out and return failure if a complete line of
+input is not read within @var{timeout} seconds.
+This option has no effect if @code{read} is not reading input from the
+terminal or a pipe.
+
+@item -u @var{fd}
+Read input from file descriptor @var{fd}.
+
+@end table
+
+@item source
+@btindex source
+@example
+source @var{filename}
+@end example
+A synonym for @code{.} (@pxref{Bourne Shell Builtins}).
+
+@item type
+@btindex type
+@example
+type [-afptP] [@var{name} @dots{}]
+@end example
+For each @var{name}, indicate how it would be interpreted if used as a
+command name.
+
+If the @option{-t} option is used, @code{type} prints a single word
+which is one of @samp{alias}, @samp{function}, @samp{builtin},
+@samp{file} or @samp{keyword},
+if @var{name} is an alias, shell function, shell builtin,
+disk file, or shell reserved word, respectively.
+If the @var{name} is not found, then nothing is printed, and
+@code{type} returns a failure status.
+
+If the @option{-p} option is used, @code{type} either returns the name
+of the disk file that would be executed, or nothing if @option{-t}
+would not return @samp{file}.
+
+The @option{-P} option forces a path search for each @var{name}, even if
+@option{-t} would not return @samp{file}.
+
+If a command is hashed, @option{-p} and @option{-P} print the hashed value,
+not necessarily the file that appears first in @code{$PATH}.
+
+If the @option{-a} option is used, @code{type} returns all of the places
+that contain an executable named @var{file}.
+This includes aliases and functions, if and only if the @option{-p} option
+is not also used.
+
+If the @option{-f} option is used, @code{type} does not attempt to find
+shell functions, as with the @code{command} builtin.
+
+The return status is zero if any of the @var{names} are found, non-zero
+if none are found.
+
+@item typeset
+@btindex typeset
+@example
+typeset [-afFrxi] [-p] [@var{name}[=@var{value}] @dots{}]
+@end example
+The @code{typeset} command is supplied for compatibility with the Korn
+shell; however, it has been deprecated in favor of the @code{declare}
+builtin command.
+
+@item ulimit
+@btindex ulimit
+@example
+ulimit [-acdefilmnpqrstuvxSH] [@var{limit}]
+@end example
+@code{ulimit} provides control over the resources available to processes
+started by the shell, on systems that allow such control.  If an
+option is given, it is interpreted as follows:
+@table @code
+@item -S
+Change and report the soft limit associated with a resource.
+
+@item -H
+Change and report the hard limit associated with a resource.
+
+@item -a
+All current limits are reported.
+
+@item -c
+The maximum size of core files created.
+
+@item -d
+The maximum size of a process's data segment.
+
+@item -e
+The maximum scheduling priority ("nice").
+
+@item -f
+The maximum size of files written by the shell and its children.
+
+@item -i
+The maximum number of pending signals.
+
+@item -l
+The maximum size that may be locked into memory.
+
+@item -m
+The maximum resident set size.
+
+@item -n
+The maximum number of open file descriptors.
+
+@item -p
+The pipe buffer size.
+
+@item -q
+The maximum number of bytes in POSIX message queues.
+
+@item -r
+The maximum real-time scheduling priority.
+
+@item -s
+The maximum stack size.
+
+@item -t
+The maximum amount of cpu time in seconds.
+
+@item -u
+The maximum number of processes available to a single user.
+
+@item -v
+The maximum amount of virtual memory available to the process.
+
+@item -x
+The maximum number of file locks.
+
+@end table
+
+If @var{limit} is given, it is the new value of the specified resource;
+the special @var{limit} values @code{hard}, @code{soft}, and
+@code{unlimited} stand for the current hard limit, the current soft limit,
+and no limit, respectively.
+Otherwise, the current value of the soft limit for the specified resource
+is printed, unless the @option{-H} option is supplied.
+When setting new limits, if neither @option{-H} nor @option{-S} is supplied,
+both the hard and soft limits are set.
+If no option is given, then @option{-f} is assumed.  Values are in 1024-byte
+increments, except for @option{-t}, which is in seconds, @option{-p},
+which is in units of 512-byte blocks, and @option{-n} and @option{-u}, which
+are unscaled values.
+
+The return status is zero unless an invalid option or argument is supplied,
+or an error occurs while setting a new limit.
+
+@item unalias
+@btindex unalias
+@example
+unalias [-a] [@var{name} @dots{} ]
+@end example
+
+Remove each @var{name} from the list of aliases.  If @option{-a} is
+supplied, all aliases are removed.
+Aliases are described in @ref{Aliases}.
+
+@end table
+
+@node The Set Builtin
+@section The Set Builtin
+
+This builtin is so complicated that it deserves its own section.  @code{set}
+allows you to change the values of shell options and set the positional
+parameters, or to display the names and values of shell variables.
+
+@table @code
+@item set
+@btindex set
+@example
+set [--abefhkmnptuvxBCEHPT] [-o @var{option}] [@var{argument} @dots{}]
+set [+abefhkmnptuvxBCEHPT] [+o @var{option}] [@var{argument} @dots{}]
+@end example
+
+If no options or arguments are supplied, @code{set} displays the names
+and values of all shell variables and functions, sorted according to the
+current locale, in a format that may be reused as input
+for setting or resetting the currently-set variables.
+Read-only variables cannot be reset.
+In @sc{posix} mode, only shell variables are listed.
+
+When options are supplied, they set or unset shell attributes.
+Options, if specified, have the following meanings:
+
+@table @code
+@item -a
+Mark variables and function which are modified or created for export
+to the environment of subsequent commands.
+
+@item -b
+Cause the status of terminated background jobs to be reported
+immediately, rather than before printing the next primary prompt.
+
+@item -e
+Exit immediately if a simple command (@pxref{Simple Commands}) exits
+with a non-zero status, unless the command that fails is part of the
+command list immediately following a @code{while} or @code{until} keyword,
+part of the test in an @code{if} statement,
+part of a @code{&&} or @code{||} list,
+any command in a pipeline but the last,
+or if the command's return status is being inverted using @code{!}.
+A trap on @code{ERR}, if set, is executed before the shell exits.
+
+@item -f
+Disable file name generation (globbing).
+
+@item -h
+Locate and remember (hash) commands as they are looked up for execution.
+This option is enabled by default.
+
+@item -k
+All arguments in the form of assignment statements are placed
+in the environment for a command, not just those that precede
+the command name.
+
+@item -m
+Job control is enabled (@pxref{Job Control}).
+
+@item -n
+Read commands but do not execute them; this may be used to check a
+script for syntax errors.
+This option is ignored by interactive shells.
+
+@item -o @var{option-name}
+
+Set the option corresponding to @var{option-name}:
+
+@table @code
+@item allexport
+Same as @code{-a}.
+
+@item braceexpand
+Same as @code{-B}.
+
+@item emacs
+Use an @code{emacs}-style line editing interface (@pxref{Command Line Editing}).
+
+@item errexit
+Same as @code{-e}.
+
+@item errtrace
+Same as @code{-E}.
+
+@item functrace
+Same as @code{-T}.
+
+@item hashall
+Same as @code{-h}.
+
+@item histexpand
+Same as @code{-H}.
+
+@item history
+Enable command history, as described in @ref{Bash History Facilities}.
+This option is on by default in interactive shells.
+
+@item ignoreeof
+An interactive shell will not exit upon reading EOF.
+
+@item keyword
+Same as @code{-k}.
+
+@item monitor
+Same as @code{-m}.
+
+@item noclobber
+Same as @code{-C}.
+
+@item noexec
+Same as @code{-n}.
+
+@item noglob
+Same as @code{-f}.
+
+@item nolog
+Currently ignored.
+
+@item notify
+Same as @code{-b}.
+
+@item nounset
+Same as @code{-u}.
+
+@item onecmd
+Same as @code{-t}.
+
+@item physical
+Same as @code{-P}.
+
+@item pipefail
+If set, the return value of a pipeline is the value of the last
+(rightmost) command to exit with a non-zero status, or zero if all
+commands in the pipeline exit successfully.
+This option is disabled by default.
+
+@item posix
+Change the behavior of Bash where the default operation differs
+from the @sc{posix} standard to match the standard
+(@pxref{Bash POSIX Mode}).
+This is intended to make Bash behave as a strict superset of that
+standard.
+
+@item privileged
+Same as @code{-p}.
+
+@item verbose
+Same as @code{-v}.
+
+@item vi
+Use a @code{vi}-style line editing interface.
+
+@item xtrace
+Same as @code{-x}.
+@end table
+
+@item -p
+Turn on privileged mode.
+In this mode, the @env{$BASH_ENV} and @env{$ENV} files are not
+processed, shell functions are not inherited from the environment,
+and the @env{SHELLOPTS} variable, if it appears in the environment,
+is ignored.
+If the shell is started with the effective user (group) id not equal to the
+real user (group) id, and the @code{-p} option is not supplied, these actions
+are taken and the effective user id is set to the real user id.
+If the @code{-p} option is supplied at startup, the effective user id is
+not reset.
+Turning this option off causes the effective user
+and group ids to be set to the real user and group ids.
+
+@item -t
+Exit after reading and executing one command.
+
+@item -u
+Treat unset variables as an error when performing parameter expansion.
+An error message will be written to the standard error, and a non-interactive
+shell will exit.
+
+@item -v
+Print shell input lines as they are read.
+
+@item -x
+Print a trace of simple commands, @code{for} commands, @code{case}
+commands, @code{select} commands, and arithmetic @code{for} commands
+and their arguments or associated word lists after they are
+expanded and before they are executed.  The value of the @env{PS4}
+variable is expanded and the resultant value is printed before
+the command and its expanded arguments.
+
+@item -B
+The shell will perform brace expansion (@pxref{Brace Expansion}).
+This option is on by default.
+
+@item -C
+Prevent output redirection using @samp{>}, @samp{>&}, and @samp{<>}
+from overwriting existing files.
+
+@item -E
+If set, any trap on @code{ERR} is inherited by shell functions, command
+substitutions, and commands executed in a subshell environment.
+The @code{ERR} trap is normally not inherited in such cases.
+
+@item -H
+Enable @samp{!} style history substitution (@pxref{History Interaction}).
+This option is on by default for interactive shells.
+
+@item -P
+If set, do not follow symbolic links when performing commands such as
+@code{cd} which change the current directory.  The physical directory
+is used instead.  By default, Bash follows
+the logical chain of directories when performing commands
+which change the current directory.
+
+For example, if @file{/usr/sys} is a symbolic link to @file{/usr/local/sys}
+then:
+@example
+$ cd /usr/sys; echo $PWD
+/usr/sys
+$ cd ..; pwd
+/usr
+@end example
+
+@noindent
+If @code{set -P} is on, then:
+@example
+$ cd /usr/sys; echo $PWD
+/usr/local/sys
+$ cd ..; pwd
+/usr/local
+@end example
+
+@item -T
+If set, any trap on @code{DEBUG} and @code{RETURN} are inherited by
+shell functions, command substitutions, and commands executed
+in a subshell environment.
+The @code{DEBUG} and @code{RETURN} traps are normally not inherited
+in such cases.
+
+@item --
+If no arguments follow this option, then the positional parameters are
+unset.  Otherwise, the positional parameters are set to the
+@var{arguments}, even if some of them begin with a @samp{-}.
+
+@item -
+Signal the end of options, cause all remaining @var{arguments}
+to be assigned to the positional parameters.  The @option{-x}
+and @option{-v}  options are turned off.
+If there are no arguments, the positional parameters remain unchanged.
+@end table
+
+Using @samp{+} rather than @samp{-} causes these options to be
+turned off.  The options can also be used upon invocation of the
+shell.  The current set of options may be found in @code{$-}.
+
+The remaining N @var{arguments} are positional parameters and are
+assigned, in order, to @code{$1}, @code{$2}, @dots{}  @code{$N}.
+The special parameter @code{#} is set to N.
+
+The return status is always zero unless an invalid option is supplied.
+@end table
+
+@node The Shopt Builtin
+@section The Shopt Builtin
+
+This builtin allows you to change additional shell optional behavior.
+
+@table @code
+
+@item shopt
+@btindex shopt
+@example
+shopt [-pqsu] [-o] [@var{optname} @dots{}]
+@end example
+Toggle the values of variables controlling optional shell behavior.
+With no options, or with the @option{-p} option, a list of all settable
+options is displayed, with an indication of whether or not each is set.
+The @option{-p} option causes output to be displayed in a form that
+may be reused as input.
+Other options have the following meanings:
+
+@table @code
+@item -s
+Enable (set) each @var{optname}.
+
+@item -u
+Disable (unset) each @var{optname}.
+
+@item -q
+Suppresses normal output; the return status
+indicates whether the @var{optname} is set or unset.
+If multiple @var{optname} arguments are given with @option{-q},
+the return status is zero if all @var{optnames} are enabled;
+non-zero otherwise.
+
+@item -o
+Restricts the values of
+@var{optname} to be those defined for the @option{-o} option to the
+@code{set} builtin (@pxref{The Set Builtin}).
+@end table
+
+If either @option{-s} or @option{-u}
+is used with no @var{optname} arguments, the display is limited to
+those options which are set or unset, respectively.
+
+Unless otherwise noted, the @code{shopt} options are disabled (off)
+by default.
+
+The return status when listing options is zero if all @var{optnames}
+are enabled, non-zero otherwise.  When setting or unsetting options,
+the return status is zero unless an @var{optname} is not a valid shell
+option.
+
+The list of @code{shopt} options is:
+@table @code
+@item cdable_vars
+If this is set, an argument to the @code{cd}
+builtin command that
+is not a directory is assumed to be the name of a variable whose
+value is the directory to change to.
+
+@item cdspell
+If set, minor errors in the spelling of a directory component in a
+@code{cd} command will be corrected.
+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 only used by interactive shells.
+
+@item checkhash
+If this is set, Bash checks that a command found in the hash
+table exists before trying to execute it.  If a hashed command no
+longer exists, a normal path search is performed.
+
+@item checkwinsize
+If set, Bash checks the window size after each command
+and, if necessary, updates the values of    
+@env{LINES} and @env{COLUMNS}.
+
+@item cmdhist
+If set, Bash
+attempts to save all lines of a multiple-line
+command in the same history entry.  This allows
+easy re-editing of multi-line commands.
+
+@item dotglob
+If set, Bash includes filenames beginning with a `.' in
+the results of filename expansion.
+
+@item execfail
+If this is set, a non-interactive shell will not exit if
+it cannot execute the file specified as an argument to the @code{exec}
+builtin command.  An interactive shell does not exit if @code{exec}
+fails.
+
+@item expand_aliases
+If set, aliases are expanded as described below under Aliases,
+@ref{Aliases}.
+This option is enabled by default for interactive shells.
+
+@item extdebug
+If set, behavior intended for use by debuggers is enabled:
+
+@enumerate
+@item
+The @option{-F} option to the @code{declare} builtin (@pxref{Bash Builtins})
+displays the source file name and line number corresponding to each function
+name supplied as an argument.
+
+@item
+If the command run by the @code{DEBUG} trap returns a non-zero value, the
+next command is skipped and not executed.
+
+@item
+If the command run by the @code{DEBUG} trap returns a value of 2, and the
+shell is executing in a subroutine (a shell function or a shell script
+executed by the @code{.} or @code{source} builtins), a call to
+@code{return} is simulated.
+
+@item
+@code{BASH_ARGC} and @code{BASH_ARGV} are updated as described in their
+descriptions (@pxref{Bash Variables}).
+
+@item
+Function tracing is enabled:  command substitution, shell functions, and
+subshells invoked with @code{( @var{command} )} inherit the
+@code{DEBUG} and @code{RETURN} traps.
+
+@item
+Error tracing is enabled:  command substitution, shell functions, and
+subshells invoked with @code{( @var{command} )} inherit the
+@code{ERROR} trap.
+@end enumerate
+
+@item extglob
+If set, the extended pattern matching features described above
+(@pxref{Pattern Matching}) are enabled.
+
+@item extquote
+If set, @code{$'@var{string}'} and @code{$"@var{string}"} quoting is  
+performed within @code{$@{@var{parameter}@}} expansions                     
+enclosed in double quotes.  This option is enabled by default. 
+
+@item failglob
+If set, patterns which fail to match filenames during pathname expansion
+result in an expansion error.
+
+@item force_fignore
+If set, the suffixes specified by the @env{FIGNORE} shell variable
+cause words to be ignored when performing word completion even if
+the ignored words are the only possible completions.
+@xref{Bash Variables}, for a description of @env{FIGNORE}.
+This option is enabled by default.
+
+@item gnu_errfmt
+If set, shell error messages are written in the standard @sc{gnu} error
+message format.
+
+@item histappend
+If set, the history list is appended to the file named by the value
+of the @env{HISTFILE}
+variable when the shell exits, rather than overwriting the file.
+
+@item histreedit
+If set, and Readline
+is being used, a user is given the opportunity to re-edit a
+failed history substitution.
+
+@item histverify
+If set, and Readline
+is being used, the results of history substitution are not immediately
+passed to the shell parser.  Instead, the resulting line is loaded into
+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 containing a @samp{@@} is being
+completed (@pxref{Commands For Completion}).  This option is enabled
+by default.
+
+@item huponexit
+If set, Bash will send @code{SIGHUP} to all jobs when an interactive
+login shell exits (@pxref{Signals}).
+
+@item interactive_comments
+Allow a word beginning with @samp{#}
+to cause that word and all remaining characters on that
+line to be ignored in an interactive shell.
+This option is enabled by default.
+
+@item lithist
+If enabled, and the @code{cmdhist}
+option is enabled, multi-line commands are saved to the history with
+embedded newlines rather than using semicolon separators where possible.
+
+@item login_shell
+The shell sets this option if it is started as a login shell
+(@pxref{Invoking Bash}).
+The value may not be changed.
+
+@item mailwarn
+If set, and a file that Bash is checking for mail has been  
+accessed since the last time it was checked, the message
+@code{"The mail in @var{mailfile} has been read"} is displayed.
+
+@item no_empty_cmd_completion
+If set, and Readline is being used, Bash will not attempt to search
+the @env{PATH} for possible completions when completion is attempted
+on an empty line.
+
+@item nocaseglob
+If set, Bash matches filenames in a case-insensitive fashion when
+performing filename expansion.
+
+@item nocasematch
+If set, Bash matches patterns in a case-insensitive fashion when
+performing matching while executing @code{case} or @code{[[}
+conditional commands.
+
+@item nullglob
+If set, Bash allows filename patterns which match no
+files to expand to a null string, rather than themselves.
+
+@item progcomp
+If set, the programmable completion facilities
+(@pxref{Programmable Completion}) are enabled.
+This option is enabled by default.
+
+@item promptvars
+If set, prompt strings undergo
+parameter expansion, command substitution, arithmetic
+expansion, and quote removal after being expanded
+as described below (@pxref{Printing a Prompt}).
+This option is enabled by default.
+
+@item restricted_shell
+The shell sets this option if it is started in restricted mode
+(@pxref{The Restricted Shell}).
+The value may not be changed.
+This is not reset when the startup files are executed, allowing
+the startup files to discover whether or not a shell is restricted.
+
+@item shift_verbose
+If this is set, the @code{shift}
+builtin prints an error message when the shift count exceeds the
+number of positional parameters.
+
+@item sourcepath
+If set, the @code{source} builtin uses the value of @env{PATH}
+to find the directory containing the file supplied as an argument.
+This option is enabled by default.
+
+@item xpg_echo
+If set, the @code{echo} builtin expands backslash-escape sequences
+by default.
+
+@end table
+
+@noindent
+The return status when listing options is zero if all @var{optnames}
+are enabled, non-zero otherwise.
+When setting or unsetting options, the return status is zero unless an
+@var{optname} is not a valid shell option.
+
+@end table
+
+@node Special Builtins
+@section Special Builtins
+@cindex special builtin
+
+For historical reasons, the @sc{posix} standard has classified
+several builtin commands as @emph{special}.
+When Bash is executing in @sc{posix} mode, the special builtins
+differ from other builtin commands in three respects:
+
+@enumerate
+@item
+Special builtins are found before shell functions during command lookup.
+
+@item
+If a special builtin returns an error status, a non-interactive shell exits.
+
+@item
+Assignment statements preceding the command stay in effect in the shell
+environment after the command completes.
+@end enumerate
+
+When Bash is not executing in @sc{posix} mode, these builtins behave no
+differently than the rest of the Bash builtin commands.
+The Bash @sc{posix} mode is described in @ref{Bash POSIX Mode}. 
+
+These are the @sc{posix} special builtins:
+@example
+@w{break : . continue eval exec exit export readonly return set}
+@w{shift trap unset}
+@end example
+
+@node Shell Variables
+@chapter Shell Variables
+
+@menu
+* Bourne Shell Variables::     Variables which Bash uses in the same way
+                               as the Bourne Shell.
+* Bash Variables::             List of variables that exist in Bash.
+@end menu
+
+This chapter describes the shell variables that Bash uses.
+Bash automatically assigns default values to a number of variables.
+
+@node Bourne Shell Variables
+@section Bourne Shell Variables
+
+Bash uses certain shell variables in the same way as the Bourne shell.
+In some cases, Bash assigns a default value to the variable.
+
+@vtable @code
+
+@item CDPATH
+A colon-separated list of directories used as a search path for
+the @code{cd} builtin command.
+
+@item HOME
+The current user's home directory; the default for the @code{cd} builtin
+command.
+The value of this variable is also used by tilde expansion
+(@pxref{Tilde Expansion}).
+
+@item IFS
+A list of characters that separate fields; used when the shell splits
+words as part of expansion.
+
+@item MAIL
+If this parameter is set to a filename and the @env{MAILPATH} variable
+is not set, Bash informs the user of the arrival of mail in
+the specified file.
+
+@item MAILPATH
+A colon-separated list of filenames which the shell periodically checks
+for new mail.
+Each list entry can specify the message that is printed when new mail
+arrives in the mail file by separating the file name from the message with
+a @samp{?}.
+When used in the text of the message, @code{$_} expands to the name of
+the current mail file.
+
+@item OPTARG
+The value of the last option argument processed by the @code{getopts} builtin.
+
+@item OPTIND
+The index of the last option argument processed by the @code{getopts} builtin.
+
+@item PATH
+A colon-separated list of directories in which the shell looks for
+commands.
+A zero-length (null) directory name in the value of @code{PATH} indicates the
+current directory.
+A null directory name may appear as two adjacent colons, or as an initial
+or trailing colon.
+
+
+@item PS1
+The primary prompt string.  The default value is @samp{\s-\v\$ }.
+@xref{Printing a Prompt}, for the complete list of escape
+sequences that are expanded before @env{PS1} is displayed.
+
+@item PS2
+The secondary prompt string.  The default value is @samp{> }.
+
+@end vtable
+
+@node Bash Variables
+@section Bash Variables
+
+These variables are set or used by Bash, but other shells
+do not normally treat them specially.
+
+A few variables used by Bash are described in different chapters:
+variables for controlling the job control facilities
+(@pxref{Job Control Variables}).
+
+@vtable @code
+
+@item BASH
+The full pathname used to execute the current instance of Bash.
+
+@item BASH_ARGC
+An array variable whose values are the number of parameters in each
+frame of the current bash execution call stack.  The number of
+parameters to the current subroutine (shell function or script executed
+with @code{.} or @code{source}) is at the top of the stack.  When a
+subroutine is executed, the number of parameters passed is pushed onto
+@code{BASH_ARGC}.
+The shell sets @code{BASH_ARGC} only when in extended debugging mode
+(see @ref{The Shopt Builtin}
+for a description of the @code{extdebug} option to the @code{shopt}
+builtin).
+
+@item BASH_ARGV
+An array variable containing all of the parameters in the current bash
+execution call stack.  The final parameter of the last subroutine call
+is at the top of the stack; the first parameter of the initial call is
+at the bottom.  When a subroutine is executed, the parameters supplied
+are pushed onto @code{BASH_ARGV}.
+The shell sets @code{BASH_ARGV} only when in extended debugging mode
+(see @ref{The Shopt Builtin}
+for a description of the @code{extdebug} option to the @code{shopt}
+builtin).
+
+@item BASH_COMMAND
+The command currently being executed or about to be executed, unless the
+shell is executing a command as the result of a trap,
+in which case it is the command executing at the time of the trap.
+
+@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 BASH_EXECUTION_STRING
+The command argument to the @option{-c} invocation option.
+
+@item BASH_LINENO
+An array variable whose members are the line numbers in source files
+corresponding to each member of @var{FUNCNAME}.
+@code{$@{BASH_LINENO[$i]@}} is the line number in the source file where
+@code{$@{FUNCNAME[$i]@}} was called.
+The corresponding source file name is @code{$@{BASH_SOURCE[$i]@}}.
+Use @code{LINENO} to obtain the current line number.
+
+@item BASH_REMATCH
+An array variable whose members are assigned by the @samp{=~} binary
+operator to the @code{[[} conditional command
+(@pxref{Conditional Constructs}).
+The element with index 0 is the portion of the string
+matching the entire regular expression.
+The element with index @var{n} is the portion of the
+string matching the @var{n}th parenthesized subexpression.
+This variable is read-only.
+
+@item BASH_SOURCE
+An array variable whose members are the source filenames corresponding
+to the elements in the @code{FUNCNAME} array variable.
+
+@item BASH_SUBSHELL
+Incremented by one each time a subshell or subshell environment is spawned.
+The initial value is 0.
+
+@item BASH_VERSINFO
+A readonly array variable (@pxref{Arrays})
+whose members hold version information for this instance of Bash.
+The values assigned to the array members are as follows:
+
+@table @code
+
+@item BASH_VERSINFO[0]
+The major version number (the @var{release}).
+
+@item BASH_VERSINFO[1]
+The minor version number (the @var{version}).
+
+@item BASH_VERSINFO[2]
+The patch level.
+
+@item BASH_VERSINFO[3]
+The build version.
+
+@item BASH_VERSINFO[4]
+The release status (e.g., @var{beta1}).
+
+@item BASH_VERSINFO[5]
+The value of @env{MACHTYPE}.
+
+@end table
+
+@item BASH_VERSION
+The version number of the current instance of Bash.
+
+@item COLUMNS
+Used by the @code{select} builtin command to determine the terminal width
+when printing selection lists.  Automatically set upon receipt of a
+@code{SIGWINCH}.
+
+@item COMP_CWORD
+An index into @env{$@{COMP_WORDS@}} of the word containing the current
+cursor position.
+This variable is available only in shell functions invoked by the
+programmable completion facilities (@pxref{Programmable Completion}).
+
+@item COMP_LINE
+The current command line.
+This variable is available only in shell functions and external
+commands invoked by the
+programmable completion facilities (@pxref{Programmable Completion}).
+
+@item COMP_POINT
+The index of the current cursor position relative to the beginning of
+the current command.
+If the current cursor position is at the end of the current command,
+the value of this variable is equal to @code{$@{#COMP_LINE@}}.
+This variable is available only in shell functions and external
+commands invoked by the
+programmable completion facilities (@pxref{Programmable Completion}).
+
+@item COMP_WORDBREAKS
+The set of characters that the Readline library treats as word
+separators when performing word completion.
+If @code{COMP_WORDBREAKS} is unset, it loses its special properties,
+even if it is subsequently reset.
+
+@item COMP_WORDS
+An array variable consisting of the individual
+words in the current command line.
+The words are split on shell metacharacters as the shell parser would
+separate them.
+This variable is available only in shell functions invoked by the
+programmable completion facilities (@pxref{Programmable Completion}).
+
+@item COMPREPLY
+An array variable from which Bash reads the possible completions
+generated by a shell function invoked by the programmable completion
+facility (@pxref{Programmable Completion}).
+
+@item DIRSTACK
+An array variable containing the current contents of the directory stack.
+Directories appear in the stack in the order they are displayed by the
+@code{dirs} builtin.
+Assigning to members of this array variable may be used to modify
+directories already in the stack, but the @code{pushd} and @code{popd}
+builtins must be used to add and remove directories.
+Assignment to this variable will not change the current directory.
+If @env{DIRSTACK} is unset, it loses its special properties, even if
+it is subsequently reset.
+
+@item EMACS
+If Bash finds this variable in the environment when the shell
+starts with value @samp{t}, it assumes that the shell is running in an
+emacs shell buffer and disables line editing.
+
+@item EUID
+The numeric effective user id of the current user.  This variable
+is readonly.
+
+@item FCEDIT
+The editor used as a default by the @option{-e} option to the @code{fc}
+builtin command.
+
+@item FIGNORE
+A colon-separated list of suffixes to ignore when performing
+filename completion.
+A file name whose suffix matches one of the entries in 
+@env{FIGNORE}
+is excluded from the list of matched file names.  A sample
+value is @samp{.o:~}
+
+@item FUNCNAME
+An array variable containing the names of all shell functions
+currently in the execution call stack.
+The element with index 0 is the name of any currently-executing
+shell function.
+The bottom-most element is @code{"main"}.
+This variable exists only when a shell function is executing.
+Assignments to @env{FUNCNAME} have no effect and return an error status.
+If @env{FUNCNAME} is unset, it loses its special properties, even if
+it is subsequently reset.
+
+@item GLOBIGNORE
+A colon-separated list of patterns defining the set of filenames to
+be ignored by filename expansion.
+If a filename matched by a filename expansion pattern also matches one
+of the patterns in @env{GLOBIGNORE}, it is removed from the list
+of matches.
+
+@item GROUPS
+An array variable containing the list of groups of which the current    
+user is a member.
+Assignments to @env{GROUPS} have no effect and return an error status.
+If @env{GROUPS} is unset, it loses its special properties, even if it is
+subsequently reset.
+
+@item histchars
+Up to three characters which control history expansion, quick
+substitution, and tokenization (@pxref{History Interaction}).
+The first character is the
+@var{history expansion} character, that is, the character which signifies the
+start of a history expansion, normally @samp{!}.  The second character is the
+character which signifies `quick substitution' when seen as the first
+character on a line, normally @samp{^}.  The optional third character is the
+character which indicates that the remainder of the line is a comment when
+found as the first character of a word, usually @samp{#}.  The history
+comment character causes history substitution to be skipped for the
+remaining words on the line.  It does not necessarily cause the shell
+parser to treat the rest of the line as a comment.
+
+@item HISTCMD
+The history number, or index in the history list, of the current
+command.  If @env{HISTCMD} is unset, it loses its special properties,
+even if it is subsequently reset.
+
+@item HISTCONTROL
+A colon-separated list of values controlling how commands are saved on
+the history list.
+If the list of values includes @samp{ignorespace}, lines which begin
+with a space character are not saved in the history list.
+A value of @samp{ignoredups} causes lines which match the previous
+history entry to not be saved.
+A value of @samp{ignoreboth} is shorthand for
+@samp{ignorespace} and @samp{ignoredups}.
+A value of @samp{erasedups} causes all previous lines matching the
+current line to be removed from the history list before that line
+is saved.
+Any value not in the above list is ignored.
+If @env{HISTCONTROL} is unset, or does not include a valid value, 
+all lines read by the shell parser are saved on the history list, 
+subject to the value of @env{HISTIGNORE}.
+The second and subsequent lines of a multi-line compound command are
+not tested, and are added to the history regardless of the value of
+@env{HISTCONTROL}.
+
+@item HISTFILE
+The name of the file to which the command history is saved.  The
+default value is @file{~/.bash_history}.
+
+@item HISTFILESIZE
+The maximum number of lines contained in the history file.  When this
+variable is assigned a value, the history file is truncated, if
+necessary, by removing the oldest entries,
+to contain no more than that number of lines.
+The history file is also truncated to this size after
+writing it when an interactive shell exits.
+The default value is 500.
+
+@item HISTIGNORE
+A colon-separated list of patterns used to decide which command
+lines should be saved on the history list.  Each pattern is
+anchored at the beginning of the line and must match the complete
+line (no implicit @samp{*} is appended).  Each pattern is tested
+against the line after the checks specified by @env{HISTCONTROL}
+are applied.  In addition to the normal shell pattern matching
+characters, @samp{&} matches the previous history line.  @samp{&}
+may be escaped using a backslash; the backslash is removed
+before attempting a match. 
+The second and subsequent lines of a multi-line compound command are
+not tested, and are added to the history regardless of the value of
+@env{HISTIGNORE}.
+
+@env{HISTIGNORE} subsumes the function of @env{HISTCONTROL}.  A
+pattern of @samp{&} is identical to @code{ignoredups}, and a
+pattern of @samp{[ ]*} is identical to @code{ignorespace}. 
+Combining these two patterns, separating them with a colon,
+provides the functionality of @code{ignoreboth}. 
+
+@item HISTSIZE
+The maximum number of commands to remember on the history list.
+The default value is 500.
+
+@item HISTTIMEFORMAT
+If this variable is set and not null, its value is used as a format string
+for @var{strftime} to print the time stamp associated with each history
+entry displayed by the @code{history} builtin.
+If this variable is set, time stamps are written to the history file so
+they may be preserved across shell sessions.
+
+@item HOSTFILE
+Contains the name of a file in the same format as @file{/etc/hosts} that
+should be read when the shell needs to complete a hostname.
+The list of possible hostname completions may be changed while the shell
+is running;
+the next time hostname completion is attempted after the
+value is changed, Bash adds the contents of the new file to the
+existing list.
+If @env{HOSTFILE} is set, but has no value, Bash attempts to read 
+@file{/etc/hosts} to obtain the list of possible hostname completions.
+When @env{HOSTFILE} is unset, the hostname list is cleared.
+
+@item HOSTNAME
+The name of the current host.
+
+@item HOSTTYPE
+A string describing the machine Bash is running on.
+
+@item IGNOREEOF
+Controls the action of the shell on receipt of an @code{EOF} character
+as the sole input.  If set, the value denotes the number
+of consecutive @code{EOF} characters that can be read as the
+first character on an input line
+before the shell will exit.  If the variable exists but does not
+have a numeric value (or has no value) then the default is 10.
+If the variable does not exist, then @code{EOF} signifies the end of 
+input to the shell.  This is only in effect for interactive shells.
+
+@item INPUTRC
+The name of the Readline initialization file, overriding the default
+of @file{~/.inputrc}.
+
+@item LANG  
+Used to determine the locale category for any category not specifically
+selected with a variable starting with @code{LC_}.
+
+@item LC_ALL
+This variable overrides the value of @env{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, and
+determines the behavior of range expressions, equivalence classes,
+and collating sequences within filename expansion and pattern matching
+(@pxref{Filename Expansion}).
+
+@item LC_CTYPE
+This variable determines the interpretation of characters and the
+behavior of character classes within filename expansion and pattern
+matching (@pxref{Filename Expansion}).
+
+@item LC_MESSAGES
+This variable determines the locale used to translate double-quoted
+strings preceded by a @samp{$} (@pxref{Locale Translation}).
+
+@item LC_NUMERIC
+This variable determines the locale category used for number formatting.
+
+@item LINENO
+The line number in the script or shell function currently executing.
+
+@item LINES
+Used by the @code{select} builtin command to determine the column length
+for printing selection lists.  Automatically set upon receipt of a
+@code{SIGWINCH}.
+
+@item MACHTYPE
+A string that fully describes the system type on which Bash
+is executing, in the standard @sc{gnu} @var{cpu-company-system} format.
+
+@item MAILCHECK
+How often (in seconds) that the shell should check for mail in the
+files specified in the @env{MAILPATH} or @env{MAIL} variables.
+The default is 60 seconds.  When it is time to check
+for mail, the shell does so before displaying the primary prompt.
+If this variable is unset, or set to a value that is not a number
+greater than or equal to zero, the shell disables mail checking.
+
+@item OLDPWD
+The previous working directory as set by the @code{cd} builtin.
+
+@item OPTERR
+If set to the value 1, Bash displays error messages
+generated by the @code{getopts} builtin command.
+
+@item OSTYPE
+A string describing the operating system Bash is running on.
+
+@item PIPESTATUS
+An array variable (@pxref{Arrays})
+containing a list of exit status values from the processes
+in the most-recently-executed foreground pipeline (which may
+contain only a single command).
+
+@item POSIXLY_CORRECT
+If this variable is in the environment when @code{bash} starts, the shell
+enters @sc{posix} mode (@pxref{Bash POSIX Mode}) before reading the
+startup files, as if the @option{--posix} invocation option had been supplied.
+If it is set while the shell is running, @code{bash} enables @sc{posix} mode,
+as if the command
+@example
+@code{set -o posix}
+@end example
+@noindent
+had been executed.  
+
+@item PPID
+The process @sc{id} of the shell's parent process.  This variable
+is readonly.
+
+@item PROMPT_COMMAND
+If set, the value is interpreted as a command to execute
+before the printing of each primary prompt (@env{$PS1}).
+
+@item PS3
+The value of this variable is used as the prompt for the
+@code{select} command.  If this variable is not set, the
+@code{select} command prompts with @samp{#? }
+
+@item PS4
+The value is the prompt printed before the command line is echoed
+when the @option{-x} option is set (@pxref{The Set Builtin}).
+The first character of @env{PS4} is replicated multiple times, as
+necessary, to indicate multiple levels of indirection.
+The default is @samp{+ }.
+
+@item PWD
+The current working directory as set by the @code{cd} builtin.
+
+@item RANDOM
+Each time this parameter is referenced, a random integer
+between 0 and 32767 is generated.  Assigning a value to this
+variable seeds the random number generator.
+
+@item REPLY
+The default variable for the @code{read} builtin.
+
+@item SECONDS
+This variable expands to the number of seconds since the
+shell was started.  Assignment to this variable resets
+the count to the value assigned, and the expanded value
+becomes the value assigned plus the number of seconds
+since the assignment.
+
+@item SHELL
+The full pathname to the shell is kept in this environment variable.
+If it is not set when the shell starts,
+Bash assigns to it the full pathname of the current user's login shell.
+
+@item SHELLOPTS
+A colon-separated list of enabled shell options.  Each word in
+the list is a valid argument for the @option{-o} option to the
+@code{set} builtin command (@pxref{The Set Builtin}).
+The options appearing in @env{SHELLOPTS} are those reported
+as @samp{on} by @samp{set -o}.
+If this variable is in the environment when Bash
+starts up, each shell option in the list will be enabled before
+reading any startup files.  This variable is readonly.
+
+@item SHLVL
+Incremented by one each time a new instance of Bash is started.  This is
+intended to be a count of how deeply your Bash shells are nested.
+
+@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}
+reserved word should be displayed.
+The @samp{%} character introduces an
+escape sequence that is expanded to a time value or other
+information.
+The escape sequences and their meanings are as
+follows; the braces denote optional portions. 
+
+@table @code
+
+@item %%
+A literal @samp{%}.
+
+@item %[@var{p}][l]R
+The elapsed time in seconds. 
+
+@item %[@var{p}][l]U
+The number of CPU seconds spent in user mode. 
+
+@item %[@var{p}][l]S
+The number of CPU seconds spent in system mode. 
+
+@item %P
+The CPU percentage, computed as (%U + %S) / %R. 
+@end table
+
+The optional @var{p} is a digit specifying the precision, the number of
+fractional digits after a decimal point.
+A value of 0 causes no decimal point or fraction to be output.
+At most three places after the decimal point may be specified; values
+of @var{p} greater than 3 are changed to 3.
+If @var{p} is not specified, the value 3 is used. 
+
+The optional @code{l} specifies a longer format, including minutes, of
+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.
+
+@item TMOUT
+If set to a value greater than zero, @code{TMOUT} is treated as the
+default timeout for the @code{read} builtin (@pxref{Bash Builtins}).
+The @code{select} command (@pxref{Conditional Constructs}) terminates
+if input does not arrive after @code{TMOUT} seconds when input is coming
+from a terminal.
+
+In an interactive shell, the value is interpreted as
+the number of seconds to wait for input after issuing the primary
+prompt when the shell is interactive.
+Bash terminates after that number of seconds if input does
+not arrive.
+
+@item TMPDIR
+If set, Bash uses its value as the name of a directory in which
+Bash creates temporary files for the shell's use.
+
+@item UID
+The numeric real user id of the current user.  This variable is readonly.
+
+@end vtable
+
+@node Bash Features
+@chapter Bash Features
+
+This section describes features unique to Bash.
+
+@menu
+* Invoking Bash::              Command line options that you can give
+                               to Bash.
+* Bash Startup Files::         When and how Bash executes scripts.
+* Interactive Shells::         What an interactive shell is.
+* Bash Conditional Expressions::       Primitives used in composing expressions for
+                               the @code{test} builtin.
+* Shell Arithmetic::           Arithmetic on shell variables.
+* Aliases::                    Substituting one command for another.
+* Arrays::                     Array Variables.
+* The Directory Stack::                History of visited directories.
+* Printing a Prompt::          Controlling the PS1 string.
+* The Restricted Shell::       A more controlled mode of shell execution.
+* Bash POSIX Mode::            Making Bash behave more closely to what
+                               the POSIX standard specifies.
+@end menu
+
+@node Invoking Bash
+@section Invoking Bash
+
+@example
+bash [long-opt] [-ir] [-abefhkmnptuvxdBCDHP] [-o @var{option}] [-O @var{shopt_option}] [@var{argument} @dots{}]
+bash [long-opt] [-abefhkmnptuvxdBCDHP] [-o @var{option}] [-O @var{shopt_option}] -c @var{string} [@var{argument} @dots{}]
+bash [long-opt] -s [-abefhkmnptuvxdBCDHP] [-o @var{option}] [-O @var{shopt_option}] [@var{argument} @dots{}]
+@end example
+
+In addition to the single-character shell command-line options
+(@pxref{The Set Builtin}), there are several multi-character
+options that you can use.  These options must appear on the command
+line before the single-character options to be recognized. 
+
+@table @code
+@item --debugger
+Arrange for the debugger profile to be executed before the shell
+starts.  Turns on extended debugging mode (see @ref{The Shopt Builtin}
+for a description of the @code{extdebug} option to the @code{shopt}
+builtin) and shell function tracing
+(see @ref{The Set Builtin} for a description of the @code{-o functrace}
+option).
+
+@item --dump-po-strings
+A list of all double-quoted strings preceded by @samp{$}
+is printed on the standard output
+in the @sc{gnu} @code{gettext} PO (portable object) file format.
+Equivalent to @option{-D} except for the output format.
+
+@item --dump-strings
+Equivalent to @option{-D}.
+
+@item --help
+Display a usage message on standard output and exit successfully.
+
+@item --init-file @var{filename}
+@itemx --rcfile @var{filename}
+Execute commands from @var{filename} (instead of @file{~/.bashrc})
+in an interactive shell.
+
+@item --login
+Equivalent to @option{-l}.
+
+@item --noediting
+Do not use the @sc{gnu} Readline library (@pxref{Command Line Editing})
+to read  command lines when the shell is interactive.
+
+@item --noprofile
+Don't load the system-wide startup file @file{/etc/profile}
+or any of the personal initialization files
+@file{~/.bash_profile}, @file{~/.bash_login}, or @file{~/.profile}
+when Bash is invoked as a login shell.
+
+@item --norc
+Don't read the @file{~/.bashrc} initialization file in an
+interactive shell.  This is on by default if the shell is
+invoked as @code{sh}.
+
+@item --posix
+Change the behavior of Bash where the default operation differs
+from the @sc{posix} standard to match the standard.  This
+is intended to make Bash behave as a strict superset of that
+standard.  @xref{Bash POSIX Mode}, for a description of the Bash
+@sc{posix} mode.
+
+@item --restricted
+Make the shell a restricted shell (@pxref{The Restricted Shell}).
+
+@item --verbose
+Equivalent to @option{-v}.  Print shell input lines as they're read.
+
+@item --version
+Show version information for this instance of
+Bash on the standard output and exit successfully.
+
+@end table
+
+There are several single-character options that may be supplied at
+invocation which are not available with the @code{set} builtin.
+
+@table @code
+@item -c @var{string}
+Read and execute commands from @var{string} after processing the
+options, then exit.  Any remaining arguments are assigned to the
+positional parameters, starting with @code{$0}.
+
+@item -i
+Force the shell to run interactively.  Interactive shells are
+described in @ref{Interactive Shells}.
+
+@item -l
+Make this shell act as if it had been directly invoked by login.
+When the shell is interactive, this is equivalent to starting a
+login shell with @samp{exec -l bash}.
+When the shell is not interactive, the login shell startup files will
+be executed.
+@samp{exec bash -l} or @samp{exec bash --login}
+will replace the current shell with a Bash login shell.
+@xref{Bash Startup Files}, for a description of the special behavior
+of a login shell.
+
+@item -r
+Make the shell a restricted shell (@pxref{The Restricted Shell}).
+
+@item -s
+If this option is present, or if no arguments remain after option
+processing, then commands are read from the standard input.
+This option allows the positional parameters to be set
+when invoking an interactive shell.
+
+@item -D
+A list of all double-quoted strings preceded by @samp{$}
+is printed on the standard output.
+These are the strings that
+are subject to language translation when the current locale
+is not @code{C} or @code{POSIX} (@pxref{Locale Translation}).
+This implies the @option{-n} option; no commands will be executed.
+
+@item [-+]O [@var{shopt_option}]
+@var{shopt_option} is one of the shell options accepted by the
+@code{shopt} builtin (@pxref{The Shopt Builtin}).
+If @var{shopt_option} is present, @option{-O} sets the value of that option;
+@option{+O} unsets it.  
+If @var{shopt_option} is not supplied, the names and values of the shell
+options accepted by @code{shopt} are printed on the standard output.
+If the invocation option is @option{+O}, the output is displayed in a format
+that may be reused as input.
+
+@item --
+A @code{--} signals the end of options and disables further option
+processing.
+Any arguments after the @code{--} are treated as filenames and arguments.
+
+@end table
+
+@cindex login shell
+A @emph{login} shell is one whose first character of argument zero is
+@samp{-}, or one invoked with the @option{--login} option.
+
+@cindex interactive shell
+An @emph{interactive} shell is one started without non-option arguments,
+unless @option{-s} is specified,
+without specifying the @option{-c} option, and whose input and output are both
+connected to terminals (as determined by @code{isatty(3)}), or one
+started with the @option{-i} option.  @xref{Interactive Shells}, for more
+information.
+
+If arguments remain after option processing, and neither the
+@option{-c} nor the @option{-s}
+option has been supplied, the first argument is assumed to
+be the name of a file containing shell commands (@pxref{Shell Scripts}).
+When Bash is invoked in this fashion, @code{$0}
+is set to the name of the file, and the positional parameters
+are set to the remaining arguments.
+Bash reads and executes commands from this file, then exits.   
+Bash's exit status is the exit status of the last command executed
+in the script.  If no commands are executed, the exit status is 0.
+
+@node Bash Startup Files
+@section Bash Startup Files
+@cindex startup files
+
+This section describes 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}).
+
+Interactive shells are described in @ref{Interactive Shells}.
+
+@subsubheading Invoked as an interactive login shell, or with @option{--login}
+
+When Bash is invoked as an interactive login shell, or as a
+non-interactive shell with the @option{--login} option, 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
+and executes commands from the first one that exists and is readable.
+The @option{--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 @file{~/.bash_logout}, if it exists.
+
+@subsubheading Invoked as an interactive non-login shell
+
+When an interactive shell that is not a login shell is started, Bash
+reads and executes commands from @file{~/.bashrc}, if that file exists.
+This may be inhibited by using the @option{--norc} option.
+The @option{--rcfile @var{file}} option will force Bash to read and
+execute commands from @var{file} instead of @file{~/.bashrc}.
+
+So, typically, your @file{~/.bash_profile} contains the line
+@example
+@code{if [ -f ~/.bashrc ]; then . ~/.bashrc; fi}
+@end example
+@noindent
+after (or before) any login-specific initializations.
+
+@subsubheading Invoked non-interactively
+
+When Bash is started non-interactively, to run a shell script,
+for example, it looks for the variable @env{BASH_ENV} in the environment,
+expands its value if it appears there, and uses the expanded value as
+the name of a file to read and execute.  Bash behaves as if the
+following command were executed:
+@example
+@code{if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi}
+@end example
+@noindent
+but the value of the @env{PATH} variable is not used to search for the
+file name.
+
+As noted above, if a non-interactive shell is invoked with the
+@option{--login} option, Bash attempts to read and execute commands from the
+login shell startup files. 
+
+@subsubheading Invoked with name @code{sh}
+
+If Bash is invoked with the name @code{sh}, it tries to mimic the
+startup behavior of historical versions of @code{sh} as closely as
+possible, while conforming to the @sc{posix} standard as well.
+
+When invoked as an interactive login shell, or as a non-interactive
+shell with the @option{--login} option, it first attempts to read
+and execute commands from @file{/etc/profile} and @file{~/.profile}, in
+that order.
+The @option{--noprofile} option may be used to inhibit this behavior.
+When invoked as an interactive shell with the name @code{sh}, Bash
+looks for the variable @env{ENV}, expands its value if it is defined,
+and uses the expanded value as the name of a file to read and execute.
+Since a shell invoked as @code{sh} does not attempt to read and execute
+commands from any other startup files, the @option{--rcfile} option has
+no effect.
+A non-interactive shell invoked with the name @code{sh} does not attempt
+to read any other startup files.
+
+When invoked as @code{sh}, Bash enters @sc{posix} mode after
+the startup files are read.
+
+@subsubheading Invoked in @sc{posix} mode
+
+When Bash is started in @sc{posix} mode, as with the
+@option{--posix} command line option, it follows the @sc{posix} standard
+for startup files.
+In this mode, interactive shells expand the @env{ENV} variable
+and commands are read and executed from the file whose name is the
+expanded value.
+No other startup files are read.
+
+@subsubheading Invoked by remote shell daemon
+
+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
+rshd, it reads and executes commands from @file{~/.bashrc}, if that
+file exists and is readable.
+It will not do this if invoked as @code{sh}.
+The @option{--norc} option may be used to inhibit this behavior, and the
+@option{--rcfile} option may be used to force another file to be read, but
+@code{rshd} does not generally invoke the shell with those options or
+allow them to be specified.
+
+@subsubheading Invoked with unequal effective and real @sc{uid/gid}s
+
+If Bash is started with the effective user (group) id not equal to the
+real user (group) id, and the @code{-p} option is not supplied, no startup
+files are read, shell functions are not inherited from the environment,
+the @env{SHELLOPTS} variable, if it appears in the environment, is ignored,
+and the effective user id is set to the real user id.
+If the @code{-p} option is supplied at invocation, the startup behavior is
+the same, but the effective user id is not reset.
+
+@node Interactive Shells
+@section Interactive Shells
+@cindex interactive shell
+@cindex shell, interactive
+
+@menu
+* What is an Interactive Shell?::      What determines whether a shell is Interactive.
+* Is this Shell Interactive?:: How to tell if a shell is interactive.
+* Interactive Shell Behavior:: What changes in a interactive shell?
+@end menu
+
+@node What is an Interactive Shell?
+@subsection What is an Interactive Shell?
+
+An interactive shell
+is one started without non-option arguments, unless @option{-s} is
+specified, without specifying the @option{-c} option, and
+whose input and error output are both
+connected to terminals (as determined by @code{isatty(3)}),
+or one started with the @option{-i} option.
+
+An interactive shell generally reads from and writes to a user's
+terminal.
+
+The @option{-s} invocation option may be used to set the positional parameters
+when an interactive shell is started.
+
+@node Is this Shell Interactive?
+@subsection Is this Shell Interactive?
+
+To determine within a startup script whether or not Bash is
+running interactively,
+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
+
+Alternatively, startup scripts may examine the variable
+@env{PS1}; it is unset in non-interactive shells, and set in
+interactive shells.  Thus:
+
+@example
+if [ -z "$PS1" ]; then
+        echo This shell is not interactive
+else
+        echo This shell is interactive
+fi
+@end example
+
+@node Interactive Shell Behavior
+@subsection Interactive Shell Behavior
+
+When the shell is running interactively, it changes its behavior in
+several ways.
+
+@enumerate
+@item
+Startup files are read and executed as described in @ref{Bash Startup Files}.
+
+@item
+Job Control (@pxref{Job Control}) is enabled by default.  When job
+control is in effect, Bash ignores the keyboard-generated job control
+signals @code{SIGTTIN}, @code{SIGTTOU}, and @code{SIGTSTP}.
+
+@item
+Bash expands and displays @env{PS1} before reading the first line
+of a command, and expands and displays @env{PS2} before reading the
+second and subsequent lines of a multi-line command.
+
+@item
+Bash executes the value of the @env{PROMPT_COMMAND} variable as a command
+before printing the primary prompt, @env{$PS1}
+(@pxref{Bash Variables}).
+
+@item
+Readline (@pxref{Command Line Editing}) is used to read commands from
+the user's terminal.
+
+@item
+Bash inspects the value of the @code{ignoreeof} option to @code{set -o}
+instead of exiting immediately when it receives an @code{EOF} on its
+standard input when reading a command (@pxref{The Set Builtin}).
+
+@item
+Command history (@pxref{Bash History Facilities})
+and history expansion (@pxref{History Interaction})
+are enabled by default.
+Bash will save the command history to the file named by @env{$HISTFILE}
+when an interactive shell exits.
+
+@item
+Alias expansion (@pxref{Aliases}) is performed by default.
+
+@item
+In the absence of any traps, Bash ignores @code{SIGTERM}
+(@pxref{Signals}).
+
+@item
+In the absence of any traps, @code{SIGINT} is caught and handled
+((@pxref{Signals}).
+@code{SIGINT} will interrupt some shell builtins.
+
+@item
+An interactive login shell sends a @code{SIGHUP} to all jobs on exit
+if the @code{huponexit} shell option has been enabled (@pxref{Signals}).
+
+@item
+The @option{-n} invocation option is ignored, and @samp{set -n} has
+no effect (@pxref{The Set Builtin}).
+
+@item
+Bash will check for mail periodically, depending on the values of the
+@env{MAIL}, @env{MAILPATH}, and @env{MAILCHECK} shell variables
+(@pxref{Bash Variables}).
+
+@item
+Expansion errors due to references to unbound shell variables after
+@samp{set -u} has been enabled will not cause the shell to exit
+(@pxref{The Set Builtin}).
+
+@item
+The shell will not exit on expansion errors caused by @var{var} being unset
+or null in @code{$@{@var{var}:?@var{word}@}} expansions
+(@pxref{Shell Parameter Expansion}).
+
+@item
+Redirection errors encountered by shell builtins will not cause the
+shell to exit.
+
+@item
+When running in @sc{posix} mode, a special builtin returning an error
+status will not cause the shell to exit (@pxref{Bash POSIX Mode}).
+
+@item
+A failed @code{exec} will not cause the shell to exit
+(@pxref{Bourne Shell Builtins}).
+
+@item
+Parser syntax errors will not cause the shell to exit.
+
+@item
+Simple spelling correction for directory arguments to the @code{cd}
+builtin is enabled by default (see the description of the @code{cdspell}
+option to the @code{shopt} builtin in @ref{The Shopt Builtin}).
+
+@item
+The shell will check the value of the @env{TMOUT} variable and exit
+if a command is not read within the specified number of seconds after
+printing @env{$PS1} (@pxref{Bash Variables}).
+
+@end enumerate
+
+@node Bash Conditional Expressions
+@section Bash Conditional Expressions
+@cindex expressions, conditional
+
+Conditional expressions are used by the @code{[[} compound command
+and the @code{test} and @code{[} builtin commands.
+
+Expressions may be unary or binary.
+Unary expressions are often used to examine the status of a file.
+There are string operators and numeric comparison operators as well.
+If the @var{file} argument to one of the primaries is of the form
+@file{/dev/fd/@var{N}}, then file descriptor @var{N} is checked.
+If the @var{file} argument to one of the primaries is one of
+@file{/dev/stdin}, @file{/dev/stdout}, or @file{/dev/stderr}, file
+descriptor 0, 1, or 2, respectively, is checked.
+
+Unless otherwise specified, primaries that operate on files follow symbolic
+links and operate on the target of the link, rather than the link itself.
+
+@table @code
+@item -a @var{file}
+True if @var{file} exists.
+
+@item -b @var{file}
+True if @var{file} exists and is a block special file.
+
+@item -c @var{file}
+True if @var{file} exists and is a character special file.
+
+@item -d @var{file}
+True if @var{file} exists and is a directory.
+
+@item -e @var{file}
+True if @var{file} exists.
+
+@item -f @var{file}
+True if @var{file} exists and is a regular file.
+
+@item -g @var{file}
+True if @var{file} exists and its set-group-id bit is set.
+
+@item -h @var{file}
+True if @var{file} exists and is a symbolic link.
+
+@item -k @var{file}
+True if @var{file} exists and its "sticky" bit is set.
+
+@item -p @var{file}
+True if @var{file} exists and is a named pipe (FIFO).
+
+@item -r @var{file}
+True if @var{file} exists and is readable.
+
+@item -s @var{file}
+True if @var{file} exists and has a size greater than zero.
+
+@item -t @var{fd}
+True if file descriptor @var{fd} is open and refers to a terminal.
+
+@item -u @var{file}
+True if @var{file} exists and its set-user-id bit is set.
+
+@item -w @var{file}
+True if @var{file} exists and is writable.
+
+@item -x @var{file}
+True if @var{file} exists and is executable.
+
+@item -O @var{file}
+True if @var{file} exists and is owned by the effective user id.
+
+@item -G @var{file}
+True if @var{file} exists and is owned by the effective group id.
+
+@item -L @var{file}
+True if @var{file} exists and is a symbolic link.
+
+@item -S @var{file}
+True if @var{file} exists and is a socket.
+
+@item -N @var{file}
+True if @var{file} exists and has been modified since it was last read.
+
+@item @var{file1} -nt @var{file2}
+True if @var{file1} is newer (according to modification date)
+than @var{file2}, or if @var{file1} exists and @var{file2} does not.
+
+@item @var{file1} -ot @var{file2}
+True if @var{file1} is older than @var{file2},
+or if @var{file2} exists and @var{file1} does not.
+
+@item @var{file1} -ef @var{file2}
+True if @var{file1} and @var{file2} refer to the same device and
+inode numbers.
+
+@item -o @var{optname}
+True if shell option @var{optname} is enabled.
+The list of options appears in the description of the @option{-o}
+option to the @code{set} builtin (@pxref{The Set Builtin}).
+
+@item -z @var{string}
+True if the length of @var{string} is zero.
+
+@item -n @var{string}
+@itemx @var{string}
+True if the length of @var{string} is non-zero.
+
+@item @var{string1} == @var{string2}
+True if the strings are equal.
+@samp{=} may be used in place of @samp{==} for strict @sc{posix} compliance.
+
+@item @var{string1} != @var{string2}
+True if the strings are not equal.
+
+@item @var{string1} < @var{string2}
+True if @var{string1} sorts before @var{string2} lexicographically
+in the current locale.
+
+@item @var{string1} > @var{string2}
+True if @var{string1} sorts after @var{string2} lexicographically
+in the current locale.
+
+@item @var{arg1} OP @var{arg2}
+@code{OP} is one of 
+@samp{-eq}, @samp{-ne}, @samp{-lt}, @samp{-le}, @samp{-gt}, or @samp{-ge}.
+These arithmetic binary operators return true if @var{arg1}
+is equal to, not equal to, less than, less than or equal to,
+greater than, or greater than or equal to @var{arg2},
+respectively.  @var{Arg1} and @var{arg2}
+may be positive or negative integers.
+
+@end table
+
+@node Shell Arithmetic
+@section Shell Arithmetic
+@cindex arithmetic, shell
+@cindex shell arithmetic
+@cindex expressions, arithmetic
+@cindex evaluation, arithmetic
+@cindex arithmetic evaluation
+
+The shell allows arithmetic expressions to be evaluated, as one of
+the shell expansions or by the @code{let} and the @option{-i} option
+to the @code{declare} builtins.
+
+Evaluation is done in fixed-width integers with no check for overflow,
+though division by 0 is trapped and flagged as an error.
+The operators and their precedence, associativity, and values
+are the same as in the C language.
+The following list of operators is grouped into levels of
+equal-precedence operators.
+The levels are listed in order of decreasing precedence. 
+
+@table @code
+
+@item @var{id}++ @var{id}--
+variable post-increment and post-decrement 
+
+@item ++@var{id} --@var{id}
+variable pre-increment and pre-decrement
+
+@item - +
+unary minus and plus
+
+@item ! ~
+logical and bitwise negation
+
+@item **
+exponentiation
+
+@item * / %
+multiplication, division, remainder
+
+@item + -
+addition, subtraction
+
+@item << >>
+left and right bitwise shifts
+
+@item <= >= < >
+comparison
+
+@item == !=
+equality and inequality
+
+@item &
+bitwise AND
+
+@item ^
+bitwise exclusive OR
+
+@item |
+bitwise OR
+
+@item &&
+logical AND
+
+@item ||
+logical OR
+
+@item expr ? expr : expr
+conditional operator
+
+@item = *= /= %= += -= <<= >>= &= ^= |=
+assignment
+
+@item expr1 , expr2
+comma
+@end table
+
+Shell variables are allowed as operands; parameter expansion is
+performed before the expression is evaluated. 
+Within an expression, shell variables may also be referenced by name
+without using the parameter expansion syntax.
+A shell variable that is null or unset evaluates to 0 when referenced
+by name without using the parameter expansion syntax.
+The value of a variable is evaluated as an arithmetic expression
+when it is referenced, or when a variable which has been given the  
+@var{integer} attribute using @samp{declare -i} is assigned a value.
+A null value evaluates to 0.
+A shell variable need not have its integer attribute turned on
+to be used in an expression.
+
+Constants with a leading 0 are interpreted as octal numbers.
+A leading @samp{0x} or @samp{0X} denotes hexadecimal.  Otherwise,
+numbers take the form [@var{base}@code{#}]@var{n}, where @var{base}
+is a decimal number between 2 and 64 representing the arithmetic
+base, and @var{n} is a number in that base.  If @var{base}@code{#} is
+omitted, then base 10 is used.
+The digits greater than 9 are represented by the lowercase letters,
+the uppercase letters, @samp{@@}, and @samp{_}, in that order.
+If @var{base} is less than or equal to 36, lowercase and uppercase
+letters may be used interchangeably to represent numbers between 10
+and 35.
+
+Operators are evaluated in order of precedence.  Sub-expressions in
+parentheses are evaluated first and may override the precedence
+rules above.
+
+@node Aliases
+@section Aliases
+@cindex alias expansion
+
+@var{Aliases} allow a string to be substituted for a word when it is used
+as the first word of a simple command.
+The shell maintains a list of aliases that may be set and unset with
+the @code{alias} and @code{unalias} builtin commands.
+
+The first word of each simple command, if unquoted, is checked to see
+if it has an alias.
+If so, that word is replaced by the text of the alias.
+The characters @samp{/}, @samp{$}, @samp{`}, @samp{=} and any of the
+shell metacharacters or quoting characters listed above may not appear
+in an alias name.
+The replacement text may contain any valid
+shell input, including shell metacharacters.
+The first word of the replacement text is tested for
+aliases, but a word that is identical to an alias being expanded
+is not expanded a second time.
+This means that one may alias @code{ls} to @code{"ls -F"},
+for instance, and Bash does not try to recursively expand the
+replacement text. If the last character of the alias value is a
+space or tab character, then the next command word following the
+alias is also checked for alias expansion.
+
+Aliases are created and listed with the @code{alias}
+command, and removed with the @code{unalias} command.
+
+There is no mechanism for using arguments in the replacement text,
+as in @code{csh}.
+If arguments are needed, a shell function should be used
+(@pxref{Shell Functions}).
+
+Aliases are not expanded when the shell is not interactive,
+unless the @code{expand_aliases} shell option is set using
+@code{shopt} (@pxref{The Shopt Builtin}).
+
+The rules concerning the definition and use of aliases are
+somewhat confusing.  Bash
+always reads at least one complete line
+of input before executing any
+of the commands on that line.  Aliases are expanded when a
+command is read, not when it is executed.  Therefore, an
+alias definition appearing on the same line as another
+command does not take effect until the next line of input is read.
+The commands following the alias definition
+on that line are not affected by the new alias.
+This behavior is also an issue when functions are executed.
+Aliases are expanded when a function definition is read,
+not when the function is executed, because a function definition
+is itself a compound command.  As a consequence, aliases
+defined in a function are not available until after that
+function is executed.  To be safe, always put
+alias definitions on a separate line, and do not use @code{alias}
+in compound commands.
+
+For almost every purpose, shell functions are preferred over aliases.
+
+@node Arrays
+@section Arrays
+@cindex arrays
+
+Bash provides one-dimensional array variables.  Any variable may be used as
+an array; the @code{declare} builtin will explicitly declare an array.
+There is no maximum
+limit on the size of an array, nor any requirement that members
+be indexed or assigned contiguously.  Arrays are zero-based.
+
+An array is created automatically if any variable is assigned to using
+the syntax
+@example
+name[@var{subscript}]=@var{value}
+@end example
+
+@noindent
+The @var{subscript}
+is treated as an arithmetic expression that must evaluate to a number
+greater than or equal to zero.  To explicitly declare an array, use
+@example
+declare -a @var{name}
+@end example
+@noindent
+The syntax
+@example
+declare -a @var{name}[@var{subscript}]
+@end example
+@noindent
+is also accepted; the @var{subscript} is ignored.  Attributes may be
+specified for an array variable using the @code{declare} and
+@code{readonly} builtins.  Each attribute applies to all members of
+an array.
+
+Arrays are assigned to using compound assignments of the form
+@example
+name=(value@var{1} @dots{} value@var{n})
+@end example
+@noindent
+where each
+@var{value} is of the form @code{[[@var{subscript}]=]}@var{string}.  If
+the optional subscript is supplied, that index is assigned to;
+otherwise the index of the element assigned is the last index assigned
+to by the statement plus one.  Indexing starts at zero.
+This syntax is also accepted by the @code{declare}
+builtin.  Individual array elements may be assigned to using the
+@code{name[}@var{subscript}@code{]=}@var{value} syntax introduced above.
+
+Any element of an array may be referenced using
+@code{$@{name[}@var{subscript}@code{]@}}.
+The braces are required to avoid
+conflicts with the shell's filename expansion operators.  If the
+@var{subscript} is @samp{@@} or @samp{*}, the word expands to all members
+of the array @var{name}.  These subscripts differ only when the word
+appears within double quotes.
+If the word is double-quoted,
+@code{$@{name[*]@}} expands to a single word with
+the value of each array member separated by the first character of the
+@env{IFS} variable, and @code{$@{name[@@]@}} expands each element of
+@var{name} to a separate word.  When there are no array members,
+@code{$@{name[@@]@}} expands to nothing.
+If the double-quoted expansion occurs within a word, the expansion of
+the first parameter is joined with the beginning part of the original
+word, and the expansion of the last parameter is joined with the last
+part of the original word.
+This is analogous to the
+expansion of the special parameters @samp{@@} and @samp{*}. 
+@code{$@{#name[}@var{subscript}@code{]@}} expands to the length of
+@code{$@{name[}@var{subscript}@code{]@}}.
+If @var{subscript} is @samp{@@} or
+@samp{*}, the expansion is the number of elements in the array. 
+Referencing an array variable without a subscript is equivalent to
+referencing element zero. 
+
+The @code{unset} builtin is used to destroy arrays.
+@code{unset} @var{name}[@var{subscript}]
+destroys the array element at index @var{subscript}.
+Care must be taken to avoid unwanted side effects caused by filename
+generation.
+@code{unset} @var{name}, where @var{name} is an array, removes the
+entire array. A subscript of @samp{*} or @samp{@@} also removes the
+entire array.
+
+The @code{declare}, @code{local}, and @code{readonly}
+builtins each accept a @option{-a}
+option to specify an array.  The @code{read}
+builtin accepts a @option{-a}
+option to assign a list of words read from the standard input
+to an array, and can read values from the standard input into
+individual array elements.  The @code{set} and @code{declare}
+builtins display array values in a way that allows them to be
+reused as input.
+
+@node The Directory Stack
+@section The Directory Stack
+@cindex directory stack
+
+@menu
+* Directory Stack Builtins::           Bash builtin commands to manipulate
+                                       the directory stack.
+@end menu
+
+The directory stack is a list of recently-visited directories.  The
+@code{pushd} builtin adds directories to the stack as it changes
+the current directory, and the @code{popd} builtin removes specified
+directories from the stack and changes the current directory to
+the directory removed.  The @code{dirs} builtin displays the contents
+of the directory stack.
+
+The contents of the directory stack are also visible
+as the value of the @env{DIRSTACK} shell variable.
+
+@node Directory Stack Builtins
+@subsection Directory Stack Builtins
+
+@table @code
+
+@item dirs
+@btindex dirs
+@example
+dirs [+@var{N} | -@var{N}] [-clpv]
+@end example
+Display the list of currently remembered directories.  Directories
+are added to the list with the @code{pushd} command; the
+@code{popd} command removes directories from the list.
+@table @code
+@item +@var{N}
+Displays the @var{N}th directory (counting from the left of the
+list printed by @code{dirs} when invoked without options), starting
+with zero.
+@item -@var{N}
+Displays the @var{N}th directory (counting from the right of the
+list printed by @code{dirs} when invoked without options), starting
+with zero.
+@item -c
+Clears the directory stack by deleting all of the elements.
+@item -l
+Produces a longer listing; the default listing format uses a 
+tilde to denote the home directory.
+@item -p
+Causes @code{dirs} to print the directory stack with one entry per
+line.
+@item -v
+Causes @code{dirs} to print the directory stack with one entry per
+line, prefixing each entry with its index in the stack.
+@end table
+
+@item popd
+@btindex popd
+@example
+popd [+@var{N} | -@var{N}] [-n]
+@end example
+
+Remove the top entry from the directory stack, and @code{cd}
+to the new top directory.
+When no arguments are given, @code{popd}
+removes the top directory from the stack and
+performs a @code{cd} to the new top directory.  The
+elements are numbered from 0 starting at the first directory listed with
+@code{dirs}; i.e., @code{popd} is equivalent to @code{popd +0}.
+@table @code
+@item +@var{N}
+Removes the @var{N}th directory (counting from the left of the
+list printed by @code{dirs}), starting with zero.
+@item -@var{N}
+Removes the @var{N}th directory (counting from the right of the
+list printed by @code{dirs}), starting with zero.
+@item -n
+Suppresses the normal change of directory when removing directories
+from the stack, so that only the stack is manipulated.
+@end table
+
+@btindex pushd
+@item pushd
+@example
+pushd [-n] [@var{+N} | @var{-N} | @var{dir} ]
+@end example
+
+Save the current directory on the top of the directory stack
+and then @code{cd} to @var{dir}.
+With no arguments, @code{pushd} exchanges the top two directories.
+
+@table @code
+@item -n
+Suppresses the normal change of directory when adding directories
+to the stack, so that only the stack is manipulated.
+@item +@var{N}
+Brings the @var{N}th directory (counting from the left of the
+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}, starting with zero) to the top of
+the list by rotating the stack.
+@item @var{dir}
+Makes the current working directory be the top of the stack, and then
+executes the equivalent of `@code{cd} @var{dir}'.
+@code{cd}s to @var{dir}.
+@end table
+
+@end table
+
+@node Printing a Prompt
+@section Controlling the Prompt
+@cindex prompting
+
+The value of the variable @env{PROMPT_COMMAND} is examined just before
+Bash prints each primary prompt.  If @env{PROMPT_COMMAND} is set and
+has a non-null value, then the
+value is executed just as if it had been typed on the command line.
+
+In addition, the following table describes the special characters which
+can appear in the prompt variables:
+
+@table @code
+@item \a
+A bell character.
+@item \d
+The date, in "Weekday Month Date" format (e.g., "Tue May 26").
+@item \D@{@var{format}@}
+The @var{format} is passed to @code{strftime}(3) and the result is inserted
+into the prompt string; an empty @var{format} results in a locale-specific
+time representation.  The braces are required.
+@item \e
+An escape character.
+@item \h
+The hostname, up to the first `.'.
+@item \H
+The hostname.
+@item \j
+The number of jobs currently managed by the shell.
+@item \l
+The basename of the shell's terminal device name.
+@item \n
+A newline.
+@item \r
+A carriage return.
+@item \s
+The name of the shell, the basename of @code{$0} (the portion
+following the final slash).
+@item \t
+The time, in 24-hour HH:MM:SS format.
+@item \T
+The time, in 12-hour HH:MM:SS format.
+@item \@@
+The time, in 12-hour am/pm format.
+@item \A
+The time, in 24-hour HH:MM format.
+@item \u
+The username of the current user.
+@item \v
+The version of Bash (e.g., 2.00)          
+@item \V
+The release of Bash, version + patchlevel (e.g., 2.00.0)
+@item \w
+The current working directory, with @env{$HOME} abbreviated with a tilde.
+@item \W
+The basename of @env{$PWD}, with @env{$HOME} abbreviated with a tilde.
+@item \!
+The history number of this command.
+@item \#
+The command number of this command.
+@item \$
+If the effective uid is 0, @code{#}, otherwise @code{$}.
+@item \@var{nnn}
+The character whose ASCII code is the octal value @var{nnn}.
+@item \\
+A backslash.
+@item \[
+Begin a sequence of non-printing characters.  This could be used to
+embed a terminal control sequence into the prompt.
+@item \]
+End a sequence of non-printing characters.
+@end table
+
+The command number and the history number are usually different:
+the history number of a command is its position in the history
+list, which may include commands restored from the history file
+(@pxref{Bash History Facilities}), while the command number is
+the position in the sequence of commands executed during the current
+shell session.
+
+After the string is decoded, it is expanded via
+parameter expansion, command substitution, arithmetic
+expansion, and quote removal, subject to the value of the
+@code{promptvars} shell option (@pxref{Bash Builtins}).
+
+@node The Restricted Shell
+@section The Restricted Shell
+@cindex restricted shell
+
+If Bash is started with the name @code{rbash}, or the
+@option{--restricted}
+or
+@option{-r}
+option is supplied at invocation, the shell becomes restricted.
+A restricted shell is used to
+set up an environment more controlled than the standard shell.
+A restricted shell behaves identically to @code{bash}
+with the exception that the following are disallowed or not performed:
+
+@itemize @bullet
+@item
+Changing directories with the @code{cd} builtin.
+@item
+Setting or unsetting the values of the @env{SHELL}, @env{PATH},
+@env{ENV}, or @env{BASH_ENV} variables.
+@item
+Specifying command names containing slashes.
+@item
+Specifying a filename containing a slash as an argument to the @code{.}
+builtin command.
+@item
+Specifying a filename containing a slash as an argument to the @option{-p}
+option to the @code{hash} builtin command.
+@item
+Importing function definitions from the shell environment at startup.
+@item
+Parsing the value of @env{SHELLOPTS} from the shell environment at startup.
+@item
+Redirecting output using the @samp{>}, @samp{>|}, @samp{<>}, @samp{>&},
+@samp{&>}, and @samp{>>} redirection operators.
+@item
+Using the @code{exec} builtin to replace the shell with another command.
+@item
+Adding or deleting builtin commands with the
+@option{-f} and @option{-d} options to the @code{enable} builtin.
+@item
+Using the @code{enable} builtin command to enable disabled shell builtins.
+@item
+Specifying the @option{-p} option to the @code{command} builtin.
+@item
+Turning off restricted mode with @samp{set +r} or @samp{set +o restricted}.
+@end itemize
+
+These restrictions are enforced after any startup files are read.
+
+When a command that is found to be a shell script is executed
+(@pxref{Shell Scripts}), @code{rbash} turns off any restrictions in
+the shell spawned to execute the script.
+
+@node Bash POSIX Mode
+@section Bash POSIX Mode
+@cindex POSIX Mode
+
+Starting Bash with the @option{--posix} command-line option or executing
+@samp{set -o posix} while Bash is running will cause Bash to conform more
+closely to the @sc{posix} standard by changing the behavior to
+match that specified by @sc{posix} in areas where the Bash default differs.
+
+When invoked as @code{sh}, Bash enters @sc{posix} mode after reading the
+startup files.
+
+The following list is what's changed when `@sc{posix} mode' is in effect:
+
+@enumerate
+@item
+When a command in the hash table no longer exists, Bash will re-search
+@env{$PATH} to find the new location.  This is also available with
+@samp{shopt -s checkhash}.
+
+@item
+The message printed by the job control code and builtins when a job
+exits with a non-zero status is `Done(status)'.
+
+@item
+The message printed by the job control code and builtins when a job
+is stopped is `Stopped(@var{signame})', where @var{signame} is, for
+example, @code{SIGTSTP}.
+
+@item
+The @code{bg} builtin uses the required format to describe each job placed
+in the background, which does not include an indication of whether the job
+is the current or previous job.
+
+@item
+Reserved words appearing in a context where reserved words are recognized
+do not undergo alias expansion.
+
+@item
+The @sc{posix} @env{PS1} and @env{PS2} expansions of @samp{!} to
+the history number and @samp{!!} to @samp{!} are enabled,
+and parameter expansion is performed on the values of @env{PS1} and
+@env{PS2} regardless of the setting of the @code{promptvars} option.
+
+@item
+The @sc{posix} startup files are executed (@env{$ENV}) rather than
+the normal Bash files.
+
+@item
+Tilde expansion is only performed on assignments preceding a command
+name, rather than on all assignment statements on the line.
+
+@item
+The default history file is @file{~/.sh_history} (this is the
+default value of @env{$HISTFILE}).
+
+@item
+The output of @samp{kill -l} prints all the signal names on a single line,
+separated by spaces, without the @samp{SIG} prefix.
+
+@item
+The @code{kill} builtin does not accept signal names with a @samp{SIG}
+prefix.
+
+@item
+Non-interactive shells exit if @var{filename} in @code{.} @var{filename}
+is not found.
+
+@item
+Non-interactive shells exit if a syntax error in an arithmetic expansion
+results in an invalid expression.
+
+@item
+Redirection operators do not perform filename expansion on the word
+in the redirection unless the shell is interactive.
+
+@item
+Redirection operators do not perform word splitting on the word in the
+redirection.
+
+@item
+Function names must be valid shell @code{name}s.  That is, they may not
+contain characters other than letters, digits, and underscores, and
+may not start with a digit.  Declaring a function with an invalid name
+causes a fatal syntax error in non-interactive shells.
+
+@item
+@sc{posix} special builtins are found before shell functions
+during command lookup.
+
+@item
+If a @sc{posix} special builtin returns an error status, a
+non-interactive shell exits.  The fatal errors are those listed in
+the POSIX standard, and include things like passing incorrect options,
+redirection errors, variable assignment errors for assignments preceding
+the command name, and so on.
+
+@item
+If @env{CDPATH} is set, the @code{cd} builtin will not implicitly
+append the current directory to it.  This means that @code{cd} will
+fail if no valid directory name can be constructed from
+any of the entries in @env{$CDPATH}, even if the a directory with
+the same name as the name given as an argument to @code{cd} exists
+in the current directory.
+
+@item
+A non-interactive shell exits with an error status if a variable
+assignment error occurs when no command name follows the assignment
+statements.
+A variable assignment error occurs, for example, when trying to assign
+a value to a readonly variable.
+
+@item
+A non-interactive shell exits with an error status if the iteration
+variable in a @code{for} statement or the selection variable in a
+@code{select} statement is a readonly variable.
+
+@item
+Process substitution is not available.
+
+@item
+Assignment statements preceding @sc{posix} special builtins
+persist in the shell environment after the builtin completes.
+
+@item
+Assignment statements preceding shell function calls persist in the
+shell environment after the function returns, as if a @sc{posix}
+special builtin command had been executed.
+
+@item
+The @code{export} and @code{readonly} builtin commands display their
+output in the format required by @sc{posix}.
+
+@item
+The @code{trap} builtin displays signal names without the leading
+@code{SIG}.
+
+@item
+The @code{trap} builtin doesn't check the first argument for a possible
+signal specification and revert the signal handling to the original
+disposition if it is, unless that argument consists solely of digits and
+is a valid signal number.  If users want to reset the handler for a given
+signal to the original disposition, they should use @samp{-} as the
+first argument.
+
+@item
+The @code{.} and @code{source} builtins do not search the current directory
+for the filename argument if it is not found by searching @env{PATH}.
+
+@item
+Subshells spawned to execute command substitutions inherit the value of
+the @option{-e} option from the parent shell.  When not in @sc{posix} mode,
+Bash clears the @option{-e} option in such subshells.
+
+@item
+Alias expansion is always enabled, even in non-interactive shells.
+
+@item
+When the @code{alias} builtin displays alias definitions, it does not
+display them with a leading @samp{alias } unless the @option{-p} option
+is supplied.
+
+@item
+When the @code{set} builtin is invoked without options, it does not display
+shell function names and definitions.
+
+@item
+When the @code{set} builtin is invoked without options, it displays
+variable values without quotes, unless they contain shell metacharacters,
+even if the result contains nonprinting characters.
+
+@item
+When the @code{cd} builtin is invoked in @var{logical} mode, and the pathname
+constructed from @code{$PWD} and the directory name supplied as an argument
+does not refer to an existing directory, @code{cd} will fail instead of
+falling back to @var{physical} mode.
+
+@item
+When the @code{pwd} builtin is supplied the @option{-P} option, it resets
+@code{$PWD} to a pathname containing no symlinks.
+
+@item
+The @code{pwd} builtin verifies that the value it prints is the same as the
+current directory, even if it is not asked to check the file system with the
+@option{-P} option.
+
+@item
+When listing the history, the @code{fc} builtin does not include an
+indication of whether or not a history entry has been modified.
+
+@item
+The default editor used by @code{fc} is @code{ed}.
+
+@item
+The @code{type} and @code{command} builtins will not report a non-executable
+file as having been found, though the shell will attempt to execute such a
+file if it is the only so-named file found in @code{$PATH}.
+
+@item
+The @code{vi} editing mode will invoke the @code{vi} editor directly when
+the @samp{v} command is run, instead of checking @code{$FCEDIT} and
+@code{$EDITOR}.
+
+@item
+When the @code{xpg_echo} option is enabled, Bash does not attempt to interpret
+any arguments to @code{echo} as options.  Each argument is displayed, after
+escape characters are converted.
+
+@end enumerate
+
+There is other @sc{posix} behavior that Bash does not implement by
+default even when in @sc{posix} mode.
+Specifically:
+
+@enumerate
+
+@item
+The @code{fc} builtin checks @code{$EDITOR} as a program to edit history
+entries if @code{FCEDIT} is unset, rather than defaulting directly to
+@code{ed}.  @code{fc} uses @code{ed} if @code{EDITOR} is unset.
+
+@item
+As noted above, Bash requires the @code{xpg_echo} option to be enabled for
+the @code{echo} builtin to be fully conformant.
+
+@end enumerate
+
+Bash can be configured to be @sc{posix}-conformant by default, by specifying
+the @option{--enable-strict-posix-default} to @code{configure} when building
+(@pxref{Optional Features}).
+
+@node Job Control
+@chapter Job Control
+
+This chapter discusses what job control is, how it works, and how
+Bash allows you to access its facilities.
+
+@menu
+* Job Control Basics::         How job control works.
+* Job Control Builtins::       Bash builtin commands used to interact
+                               with job control.
+* Job Control Variables::      Variables Bash uses to customize job
+                               control.
+@end menu
+
+@node Job Control Basics
+@section Job Control Basics
+@cindex job control
+@cindex foreground
+@cindex background
+@cindex suspending jobs
+
+Job control
+refers to the ability to selectively stop (suspend)
+the execution of processes and continue (resume)
+their execution at a later point.  A user typically employs
+this facility via an interactive interface supplied jointly
+by the system's terminal driver and Bash.
+
+The shell associates a @var{job} with each pipeline.  It keeps a
+table of currently executing jobs, which may be listed with the
+@code{jobs} command.  When Bash starts a job
+asynchronously, it prints a line that looks
+like:
+@example
+[1] 25647
+@end example
+@noindent
+indicating that this job is job number 1 and that the process @sc{id}
+of the last process in the pipeline associated with this job is
+25647.  All of the processes in a single pipeline are members of
+the same job.  Bash uses the @var{job} abstraction as the
+basis for job control. 
+
+To facilitate the implementation of the user interface to job
+control, the operating system maintains the notion of a current terminal
+process group @sc{id}.  Members of this process group (processes whose
+process group @sc{id} is equal to the current terminal process group
+@sc{id}) receive keyboard-generated signals such as @code{SIGINT}. 
+These processes are said to be in the foreground.  Background
+processes are those whose process group @sc{id} differs from the
+terminal's; such processes are immune to keyboard-generated
+signals.  Only foreground processes are allowed to read from or
+write to the terminal.  Background processes which attempt to
+read from (write to) the terminal are sent a @code{SIGTTIN}
+(@code{SIGTTOU}) signal by the terminal driver, which, unless
+caught, suspends the process. 
+
+If the operating system on which Bash is running supports
+job control, Bash contains facilities to use it.  Typing the
+@var{suspend} character (typically @samp{^Z}, Control-Z) while a
+process is running causes that process to be stopped and returns
+control to Bash.  Typing the @var{delayed suspend} character
+(typically @samp{^Y}, Control-Y) causes the process to be stopped
+when it attempts to read input from the terminal, and control to
+be returned to Bash.  The user then manipulates the state of
+this job, using the @code{bg} command to continue it in the
+background, the @code{fg} command to continue it in the
+foreground, or the @code{kill} command to kill it.  A @samp{^Z}
+takes effect immediately, and has the additional side effect of
+causing pending output and typeahead to be discarded. 
+
+There are a number of ways to refer to a job in the shell.  The
+character @samp{%} introduces a job name.
+
+Job number @code{n} may be referred to as @samp{%n}.
+The symbols @samp{%%} and  @samp{%+} refer to the shell's notion of the
+current job, which is the last job stopped while it was in the foreground
+or started in the background.
+A single @samp{%} (with no accompanying job specification) also refers
+to the current job.
+The previous job may be referenced using @samp{%-}.  In output
+pertaining to jobs (e.g., the output of the @code{jobs} command),
+the current job is always flagged with a @samp{+}, and the
+previous job with a @samp{-}. 
+
+A job may also be referred to
+using a prefix of the name used to start it, or using a substring
+that appears in its command line.  For example, @samp{%ce} refers
+to a stopped @code{ce} job. Using @samp{%?ce}, on the
+other hand, refers to any job containing the string @samp{ce} in
+its command line.  If the prefix or substring matches more than one job,
+Bash reports an error.
+
+Simply naming a job can be used to bring it into the foreground:
+@samp{%1} is a synonym for @samp{fg %1}, bringing job 1 from the
+background into the foreground.  Similarly, @samp{%1 &} resumes
+job 1 in the background, equivalent to @samp{bg %1}
+
+The shell learns immediately whenever a job changes state. 
+Normally, Bash waits until it is about to print a prompt
+before reporting changes in a job's status so as to not interrupt
+any other output.
+If the @option{-b} option to the @code{set} builtin is enabled,
+Bash reports such changes immediately (@pxref{The Set Builtin}).
+Any trap on @code{SIGCHLD} is executed for each child process
+that exits.
+
+If an attempt to exit Bash is made while jobs are stopped, the
+shell prints a message warning that there are stopped jobs.
+The @code{jobs} command may then be used to inspect their status.
+If a second attempt to exit is made without an intervening command,
+Bash does not print another warning, and the stopped jobs are terminated.
+
+@node Job Control Builtins
+@section Job Control Builtins
+
+@table @code
+
+@item bg
+@btindex bg
+@example
+bg [@var{jobspec} @dots{}]
+@end example
+Resume each suspended job @var{jobspec} in the background, as if it
+had been started with @samp{&}.
+If @var{jobspec} is not supplied, the current job is used.
+The return status is zero unless it is run when job control is not
+enabled, or, when run with job control enabled, any
+@var{jobspec} was not found or specifies a job
+that was started without job control.
+
+@item fg
+@btindex fg
+@example
+fg [@var{jobspec}]
+@end example
+Resume the job @var{jobspec} in the foreground and make it the current job.
+If @var{jobspec} is not supplied, the current job is used.
+The return status is that of the command placed into the foreground,
+or non-zero if run when job control is disabled or, when run with
+job control enabled, @var{jobspec} does not specify a valid job or
+@var{jobspec} specifies a job that was started without job control.
+
+@item jobs
+@btindex jobs
+@example
+jobs [-lnprs] [@var{jobspec}]
+jobs -x @var{command} [@var{arguments}]
+@end example
+
+The first form lists the active jobs.  The options have the
+following meanings:
+
+@table @code
+@item -l
+List process @sc{id}s in addition to the normal information.
+
+@item -n
+Display information only about jobs that have changed status since
+the user was last notified of their status.
+
+@item -p
+List only the process @sc{id} of the job's process group leader.
+
+@item -r
+Restrict output to running jobs.
+
+@item -s
+Restrict output to stopped jobs.
+@end table
+
+If @var{jobspec} is given,
+output is restricted to information about that job. 
+If @var{jobspec} is not supplied, the status of all jobs is
+listed.
+
+If the @option{-x} option is supplied, @code{jobs} replaces any
+@var{jobspec} found in @var{command} or @var{arguments} with the
+corresponding process group @sc{id}, and executes @var{command},
+passing it @var{argument}s, returning its exit status. 
+
+@item kill
+@btindex kill
+@example
+kill [-s @var{sigspec}] [-n @var{signum}] [-@var{sigspec}] @var{jobspec} or @var{pid}
+kill -l [@var{exit_status}]
+@end example
+Send a signal specified by @var{sigspec} or @var{signum} to the process
+named by job specification @var{jobspec} or process @sc{id} @var{pid}.
+@var{sigspec} is either a case-insensitive 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 @option{-l} option lists the signal names.
+If any arguments are supplied when @option{-l} is given, the names of the
+signals corresponding to the arguments are listed, and the return status
+is zero.
+@var{exit_status} is a number specifying a signal number or the exit
+status of a process terminated by a signal.
+The return status is zero if at least one signal was successfully sent,
+or non-zero if an error occurs or an invalid option is encountered.
+
+@item wait
+@btindex wait
+@example
+wait [@var{jobspec} or @var{pid} ...]
+@end example
+Wait until the child process specified by each process @sc{id} @var{pid}
+or job specification @var{jobspec} exits and return the exit status of the
+last command waited for.
+If a job spec is given, all processes in the job are waited for.
+If no arguments are given, all currently active child processes are
+waited for, and the return status is zero.
+If neither @var{jobspec} nor @var{pid} specifies an active child process
+of the shell, the return status is 127.
+
+@item disown
+@btindex disown
+@example
+disown [-ar] [-h] [@var{jobspec} @dots{}]
+@end example
+Without options, each @var{jobspec} is removed from the table of
+active jobs.
+If the @option{-h} option is given, the job is not removed from the table,
+but is marked so that @code{SIGHUP} is not sent to the job if the shell
+receives a @code{SIGHUP}.
+If @var{jobspec} is not present, and neither the @option{-a} nor @option{-r}
+option is supplied, the current job is used.
+If no @var{jobspec} is supplied, the @option{-a} option means to remove or
+mark all jobs; the @option{-r} option without a @var{jobspec}
+argument restricts operation to running jobs.
+
+@item suspend
+@btindex suspend
+@example
+suspend [-f]
+@end example
+Suspend the execution of this shell until it receives a
+@code{SIGCONT} signal.  The @option{-f} option means to suspend
+even if the shell is a login shell.
+
+@end table
+
+When job control is not active, the @code{kill} and @code{wait}
+builtins do not accept @var{jobspec} arguments.  They must be
+supplied process @sc{id}s.
+
+@node Job Control Variables
+@section Job Control Variables
+
+@vtable @code
+
+@item auto_resume
+This variable controls how the shell interacts with the user and
+job control.  If this variable exists then single word simple
+commands without redirections are treated as candidates for resumption
+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},
+the string supplied must match the name of a stopped job exactly;
+if set to @samp{substring},
+the string supplied needs to match a substring of the name of a
+stopped job.  The @samp{substring} value provides functionality
+analogous to the @samp{%?} job @sc{id} (@pxref{Job Control Basics}).
+If set to any other value, the supplied string must
+be a prefix of a stopped job's name; this provides functionality
+analogous to the @samp{%} job @sc{id}.
+
+@end vtable
+
+@set readline-appendix
+@set history-appendix
+@cindex Readline, how to use
+@include rluser.texi
+@cindex History, how to use
+@include hsuser.texi
+@clear readline-appendix
+@clear history-appendix
+
+@node Installing Bash
+@chapter Installing Bash
+
+This chapter provides basic instructions for installing Bash on
+the various supported platforms.  The distribution supports the
+@sc{gnu} operating systems, nearly every version of Unix, and several
+non-Unix systems such as BeOS and Interix.
+Other independent ports exist for
+@sc{ms-dos}, @sc{os/2}, and Windows platforms.
+
+@menu
+* Basic Installation:: Installation instructions.
+* Compilers and Options::      How to set special options for various
+                               systems.
+* Compiling For Multiple Architectures::       How to compile Bash for more
+                                               than one kind of system from
+                                               the same source tree.
+* Installation Names:: How to set the various paths used by the installation.
+* Specifying the System Type:: How to configure Bash for a particular system.
+* Sharing Defaults::   How to share default configuration values among GNU
+                       programs.
+* Operation Controls:: Options recognized by the configuration program.
+* Optional Features::  How to enable and disable optional features when
+                       building Bash.
+@end menu
+
+@node Basic Installation
+@section Basic Installation
+@cindex installation
+@cindex configuration
+@cindex Bash installation
+@cindex Bash configuration
+
+These are installation instructions for Bash.
+
+The simplest way to compile Bash is:
+
+@enumerate
+@item
+@code{cd} to the directory containing the source code and type
+@samp{./configure} to configure Bash for your system.  If you're
+using @code{csh} on an old version of System V, you might need to
+type @samp{sh ./configure} instead to prevent @code{csh} from trying
+to execute @code{configure} itself.
+
+Running @code{configure} takes some time.
+While running, it prints messages telling which features it is
+checking for.
+
+@item
+Type @samp{make} to compile Bash and build the @code{bashbug} bug
+reporting script.
+
+@item
+Optionally, type @samp{make tests} to run the Bash test suite.
+
+@item
+Type @samp{make install} to install @code{bash} and @code{bashbug}.
+This will also install the manual pages and Info file.
+
+@end enumerate
+
+The @code{configure} shell script attempts to guess correct
+values for various system-dependent variables used during
+compilation.  It uses those values to create a @file{Makefile} in
+each directory of the package (the top directory, the
+@file{builtins}, @file{doc}, and @file{support} directories,
+each directory under @file{lib}, and several others).  It also creates a
+@file{config.h} file containing system-dependent definitions. 
+Finally, it creates a shell script named @code{config.status} that you
+can run in the future to recreate the current configuration, a
+file @file{config.cache} that saves the results of its tests to
+speed up reconfiguring, and a file @file{config.log} containing
+compiler output (useful mainly for debugging @code{configure}). 
+If at some point
+@file{config.cache} contains results you don't want to keep, you
+may remove or edit it. 
+
+To find out more about the options and arguments that the
+@code{configure} script understands, type 
+
+@example
+bash-2.04$ ./configure --help
+@end example
+
+@noindent
+at the Bash prompt in your Bash source directory.
+
+If you need to do unusual things to compile Bash, please
+try to figure out how @code{configure} could check whether or not
+to do them, and mail diffs or instructions to
+@email{bash-maintainers@@gnu.org} so they can be
+considered for the next release.
+
+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.50 or
+newer.
+
+You can remove the program binaries and object files from the
+source code directory by typing @samp{make clean}.  To also remove the
+files that @code{configure} created (so you can compile Bash for
+a different kind of computer), type @samp{make distclean}.
+
+@node Compilers and Options
+@section Compilers and Options
+
+Some systems require unusual options for compilation or linking
+that the @code{configure} script does not know about.  You can
+give @code{configure} initial values for variables by setting
+them in the environment.  Using a Bourne-compatible shell, you
+can do that on the command line like this:
+
+@example
+CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
+@end example
+
+On systems that have the @code{env} program, you can do it like this:
+
+@example
+env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
+@end example
+
+The configuration process uses GCC to build Bash if it
+is available.
+
+@node Compiling For Multiple Architectures
+@section Compiling For Multiple Architectures
+
+You can compile Bash for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory.  To do this, you must use a version of @code{make} that
+supports the @code{VPATH} variable, such as GNU @code{make}.
+@code{cd} to the
+directory where you want the object files and executables to go and run
+the @code{configure} script from the source directory.  You may need to
+supply the @option{--srcdir=PATH} argument to tell @code{configure} where the
+source files are.  @code{configure} automatically checks for the
+source code in the directory that @code{configure} is in and in `..'.
+
+If you have to use a @code{make} that does not supports the @code{VPATH}
+variable, you can compile Bash for one architecture at a
+time in the source code directory.  After you have installed
+Bash for one architecture, use @samp{make distclean} before
+reconfiguring for another architecture.
+
+Alternatively, if your system supports symbolic links, you can use the
+@file{support/mkclone} script to create a build tree which has
+symbolic links back to each file in the source directory.  Here's an
+example that creates a build directory in the current directory from a
+source directory @file{/usr/gnu/src/bash-2.0}:
+
+@example
+bash /usr/gnu/src/bash-2.0/support/mkclone -s /usr/gnu/src/bash-2.0 .
+@end example
+
+@noindent
+The @code{mkclone} script requires Bash, so you must have already built
+Bash for at least one architecture before you can create build
+directories for other architectures.
+
+@node Installation Names
+@section Installation Names
+
+By default, @samp{make install} will install into
+@file{/usr/local/bin}, @file{/usr/local/man}, etc.  You can
+specify an installation prefix other than @file{/usr/local} by
+giving @code{configure} the option @option{--prefix=@var{PATH}},
+or by specifying a value for the @code{DESTDIR} @samp{make}
+variable when running @samp{make install}.
+
+You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files. 
+If you give @code{configure} the option
+@option{--exec-prefix=@var{PATH}}, @samp{make install} will use
+@var{PATH} as the prefix for installing programs and libraries.
+Documentation and other data files will still use the regular prefix. 
+
+@node Specifying the System Type
+@section Specifying the System Type
+
+There may be some features @code{configure} can not figure out
+automatically, but need to determine by the type of host Bash
+will run on.  Usually @code{configure} can figure that
+out, but if it prints a message saying it can not guess the host
+type, give it the @option{--host=TYPE} option.  @samp{TYPE} can
+either be a short name for the system type, such as @samp{sun4},
+or a canonical name with three fields: @samp{CPU-COMPANY-SYSTEM}
+(e.g., @samp{i386-unknown-freebsd4.2}).
+
+See the file @file{support/config.sub} for the possible
+values of each field. 
+
+@node Sharing Defaults
+@section Sharing Defaults
+
+If you want to set default values for @code{configure} scripts to
+share, you can create a site shell script called
+@code{config.site} that gives default values for variables like
+@code{CC}, @code{cache_file}, and @code{prefix}.  @code{configure}
+looks for @file{PREFIX/share/config.site} if it exists, then
+@file{PREFIX/etc/config.site} if it exists.  Or, you can set the
+@code{CONFIG_SITE} environment variable to the location of the site
+script.  A warning: the Bash @code{configure} looks for a site script,
+but not all @code{configure} scripts do.
+
+@node Operation Controls
+@section Operation Controls
+
+@code{configure} recognizes the following options to control how it
+operates.
+
+@table @code
+
+@item --cache-file=@var{file}
+Use and save the results of the tests in
+@var{file} instead of @file{./config.cache}.  Set @var{file} to
+@file{/dev/null} to disable caching, for debugging
+@code{configure}. 
+
+@item --help
+Print a summary of the options to @code{configure}, and exit.
+
+@item --quiet
+@itemx --silent
+@itemx -q
+Do not print messages saying which checks are being made.
+
+@item --srcdir=@var{dir}
+Look for the Bash source code in directory @var{dir}.  Usually
+@code{configure} can determine that directory automatically.
+
+@item --version
+Print the version of Autoconf used to generate the @code{configure}
+script, and exit.
+@end table
+
+@code{configure} also accepts some other, not widely used, boilerplate
+options.  @samp{configure --help} prints the complete list.
+
+@node Optional Features
+@section Optional Features
+
+The Bash @code{configure} has a number of @option{--enable-@var{feature}}
+options, where @var{feature} indicates an optional part of Bash.
+There are also several @option{--with-@var{package}} options,
+where @var{package} is something like @samp{bash-malloc} or @samp{purify}.
+To turn off the default use of a package, use
+@option{--without-@var{package}}.  To configure Bash without a feature
+that is enabled by default, use @option{--disable-@var{feature}}.
+
+Here is a complete list of the @option{--enable-} and
+@option{--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-bash-malloc
+Use the Bash version of
+@code{malloc} in the directory @file{lib/malloc}.  This is not the same
+@code{malloc} that appears in @sc{gnu} libc, but an older version
+originally derived from the 4.2 @sc{bsd} @code{malloc}.  This @code{malloc}
+is very fast, but wastes some space on each allocation.
+This option is enabled by default.
+The @file{NOTES} file contains a list of systems for
+which this should be turned off, and @code{configure} disables this
+option automatically for a number of systems.
+
+@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-gnu-malloc
+A synonym for @code{--with-bash-malloc}.
+
+@item --with-installed-readline[=@var{PREFIX}]
+Define this to make Bash link with a locally-installed version of Readline
+rather than the version in @file{lib/readline}.  This works only with
+Readline 5.0 and later versions.  If @var{PREFIX} is @code{yes} or not
+supplied, @code{configure} uses the values of the make variables
+@code{includedir} and @code{libdir}, which are subdirectories of @code{prefix}
+by default, to find the installed version of Readline if it is not in
+the standard system include and library directories.
+If @var{PREFIX} is @code{no}, Bash links with the version in
+@file{lib/readline}.
+If @var{PREFIX} is set to any other value, @code{configure} treats it as
+a directory pathname and looks for
+the installed version of Readline in subdirectories of that directory
+(include files in @var{PREFIX}/@code{include} and the library in
+@var{PREFIX}/@code{lib}).
+
+@item --with-purify
+Define this to use the Purify memory allocation checker from Rational
+Software.
+
+@item --enable-minimal-config
+This produces a shell with minimal features, close to the historical
+Bourne shell.
+@end table
+
+There are several @option{--enable-} options that alter how Bash is
+compiled and linked, rather than changing run-time features.
+
+@table @code
+@item --enable-largefile
+Enable support for @uref{http://www.sas.com/standards/large_file/x_open.20Mar96.html,
+large files} if the operating system requires special compiler options
+to build programs which can access large files.  This is enabled by
+default, if the operating system provides large file support.
+
+@item --enable-profiling
+This builds a Bash binary that produces profiling information to be
+processed by @code{gprof} each time it is executed.
+
+@item --enable-static-link
+This causes Bash to be linked statically, if @code{gcc} is being used.
+This could be used to build a version to use as root's shell.
+@end table
+
+The @samp{minimal-config} option can be used to disable all of
+the following options, but it is processed first, so individual
+options may be enabled using @samp{enable-@var{feature}}. 
+
+All of the following options except for @samp{disabled-builtins} and
+@samp{xpg-echo-default} are
+enabled by default, unless the operating system does not provide the
+necessary support.
+
+@table @code
+@item --enable-alias
+Allow alias expansion and include the @code{alias} and @code{unalias}
+builtins (@pxref{Aliases}).
+
+@item --enable-arith-for-command
+Include support for the alternate form of the @code{for} command
+that behaves like the C language @code{for} statement
+(@pxref{Looping Constructs}).
+
+@item --enable-array-variables
+Include support for one-dimensional array shell variables
+(@pxref{Arrays}).
+
+@item --enable-bang-history
+Include support for @code{csh}-like history substitution
+(@pxref{History Interaction}).
+
+@item --enable-brace-expansion
+Include @code{csh}-like brace expansion
+( @code{b@{a,b@}c} @expansion{} @code{bac bbc} ).
+See @ref{Brace Expansion}, for a complete description.
+
+@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}
+(@pxref{Pipelines}).
+This allows pipelines as well as shell builtins and functions to be timed.
+
+@item --enable-cond-command
+Include support for the @code{[[} conditional command.
+(@pxref{Conditional Constructs}).
+
+@item --enable-cond-regexp
+Include support for matching POSIX regular expressions using the
+@samp{=~} binary operator in the @code{[[} conditional command.
+(@pxref{Conditional Constructs}).
+
+@item --enable-debugger
+Include support for the bash debugger (distributed separately).
+
+@item --enable-directory-stack
+Include support for a @code{csh}-like directory stack and the
+@code{pushd}, @code{popd}, and @code{dirs} builtins
+(@pxref{The Directory Stack}).
+
+@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{((@dots{}))} command
+(@pxref{Conditional Constructs}).
+
+@item --enable-extended-glob
+Include support for the extended pattern matching features described
+above under @ref{Pattern Matching}.
+
+@item --enable-help-builtin
+Include the @code{help} builtin, which displays help on shell builtins and
+variables (@pxref{Bash Builtins}).
+
+@item --enable-history
+Include command history and the @code{fc} and @code{history}
+builtin commands (@pxref{Bash History Facilities}).
+
+@item --enable-job-control
+This enables the job control features (@pxref{Job Control}),
+if the operating system supports them.
+
+@item --enable-multibyte
+This enables support for multibyte characters if the operating
+system provides the necessary support.
+
+@item --enable-net-redirections
+This enables the special handling of filenames of the form
+@code{/dev/tcp/@var{host}/@var{port}} and
+@code{/dev/udp/@var{host}/@var{port}}
+when used in redirections (@pxref{Redirections}).
+
+@item --enable-process-substitution
+This enables process substitution (@pxref{Process Substitution}) if
+the operating system provides the necessary support.
+
+@item --enable-progcomp
+Enable the programmable completion facilities
+(@pxref{Programmable Completion}).
+If Readline is not enabled, this option has no effect.
+
+@item --enable-prompt-string-decoding
+Turn on the interpretation of a number of backslash-escaped characters
+in the @env{$PS1}, @env{$PS2}, @env{$PS3}, and @env{$PS4} prompt
+strings.  See @ref{Printing a Prompt}, for a complete list of prompt
+string escape sequences.
+
+@item --enable-readline
+Include support for command-line editing and history with the Bash
+version of the Readline library (@pxref{Command Line Editing}).
+
+@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{select} builtin, which allows the generation of simple
+menus (@pxref{Conditional Constructs}).
+
+@item --enable-separate-helpfiles
+Use external files for the documentation displayed by the @code{help} builtin
+instead of storing the text internally.
+
+@item --enable-single-help-strings
+Store the text displayed by the @code{help} builtin as a single string for
+each help topic.  This aids in translating the text to different languages.
+You may need to disable this if your compiler cannot handle very long string
+literals.
+
+@item --enable-strict-posix-default
+Make Bash @sc{posix}-conformant by default (@pxref{Bash POSIX Mode}).
+
+@item --enable-usg-echo-default
+A synonym for @code{--enable-xpg-echo-default}.
+
+@item --enable-xpg-echo-default
+Make the @code{echo} builtin expand backslash-escaped characters by default,
+without requiring the @option{-e} option.
+This sets the default value of the @code{xpg_echo} shell option to @code{on},
+which makes the Bash @code{echo} behave more like the version specified in
+the Single Unix Specification, version 3.
+@xref{Bash Builtins}, for a description of the escape sequences that
+@code{echo} recognizes.
+
+@end table
+
+The file @file{config-top.h} contains C Preprocessor
+@samp{#define} statements for options which are not settable from
+@code{configure}.
+Some of these are not meant to be changed; beware of the consequences if
+you do.
+Read the comments associated with each definition for more
+information about its effect.
+
+@node Reporting Bugs
+@appendix Reporting Bugs
+
+Please report all bugs you find in Bash.
+But first, you should
+make sure that it really is a bug, and that it appears in the latest
+version of Bash.
+The latest version of Bash is always available for FTP from
+@uref{ftp://ftp.gnu.org/pub/bash/}.
+
+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 encouraged to mail that as well!
+Suggestions and `philosophical' bug reports may be mailed
+to @email{bug-bash@@gnu.org} or posted to the Usenet
+newsgroup @code{gnu.bash.bug}.
+
+All bug reports should include:
+@itemize @bullet
+@item
+The version number of Bash.
+@item
+The hardware and operating system.
+@item
+The compiler used to compile Bash.
+@item
+A description of the bug behaviour.
+@item
+A short script or `recipe' which exercises the bug and may be used
+to reproduce it.
+@end itemize
+
+@noindent
+@code{bashbug} inserts the first three items automatically into
+the template it provides for filing a bug report.
+
+Please send all reports concerning this manual to
+@email{chet@@po.CWRU.Edu}.
+
+@node Major Differences From The Bourne Shell
+@appendix Major Differences From The Bourne Shell
+
+Bash implements essentially the same grammar, parameter and
+variable expansion, redirection, and quoting as the Bourne Shell. 
+Bash uses the @sc{posix} standard as the specification of
+how these features are to be implemented.  There are some
+differences between the traditional Bourne shell and Bash; this
+section quickly details the differences of significance.  A
+number of these differences are explained in greater depth in
+previous sections.
+This section uses the version of @code{sh} included in SVR4.2 (the
+last version of the historical Bourne shell) as the baseline reference.
+
+@itemize @bullet
+
+@item
+Bash is @sc{posix}-conformant, even where the @sc{posix} specification
+differs from traditional @code{sh} behavior (@pxref{Bash POSIX Mode}).
+
+@item
+Bash has multi-character invocation options (@pxref{Invoking Bash}).
+
+@item
+Bash has command-line editing (@pxref{Command Line Editing}) and
+the @code{bind} builtin.
+
+@item
+Bash provides a programmable word completion mechanism
+(@pxref{Programmable Completion}), and two builtin commands,
+@code{complete} and @code{compgen}, to manipulate it.
+
+@item
+Bash has command history (@pxref{Bash History Facilities}) and the
+@code{history} and @code{fc} builtins to manipulate it.
+The Bash history list maintains timestamp information and uses the
+value of the @code{HISTTIMEFORMAT} variable to display it.
+
+@item
+Bash implements @code{csh}-like history expansion
+(@pxref{History Interaction}).
+
+@item
+Bash has one-dimensional array variables (@pxref{Arrays}), and the
+appropriate variable expansions and assignment syntax to use them.
+Several of the Bash builtins take options to act on arrays.
+Bash provides a number of built-in array variables.
+
+@item
+The @code{$'@dots{}'} quoting syntax, which expands ANSI-C
+backslash-escaped characters in the text between the single quotes,
+is supported (@pxref{ANSI-C Quoting}).
+
+@item
+Bash supports the @code{$"@dots{}"} quoting syntax to do
+locale-specific translation of the characters between the double
+quotes.  The @option{-D}, @option{--dump-strings}, and @option{--dump-po-strings}
+invocation options list the translatable strings found in a script
+(@pxref{Locale Translation}).
+
+@item
+Bash implements the @code{!} keyword to negate the return value of
+a pipeline (@pxref{Pipelines}).
+Very useful when an @code{if} statement needs to act only if a test fails.
+The Bash @samp{-o pipefail} option to @code{set} will cause a pipeline to
+return a failure status if any command fails.
+
+@item
+Bash has the @code{time} reserved word and command timing (@pxref{Pipelines}).
+The display of the timing statistics may be controlled with the
+@env{TIMEFORMAT} variable.
+
+@item
+Bash implements the @code{for (( @var{expr1} ; @var{expr2} ; @var{expr3} ))}
+arithmetic for command, similar to the C language (@pxref{Looping Constructs}).
+
+@item
+Bash includes the @code{select} compound command, which allows the
+generation of simple menus (@pxref{Conditional Constructs}).
+
+@item
+Bash includes the @code{[[} compound command, which makes conditional
+testing part of the shell grammar (@pxref{Conditional Constructs}), including
+optional regular expression matching.
+
+@item
+Bash provides optional case-insensitive matching for the @code{case} and
+@code{[[} constructs.
+
+@item
+Bash includes brace expansion (@pxref{Brace Expansion}) and tilde
+expansion (@pxref{Tilde Expansion}).
+
+@item
+Bash implements command aliases and the @code{alias} and @code{unalias}
+builtins (@pxref{Aliases}).
+
+@item
+Bash provides shell arithmetic, the @code{((} compound command
+(@pxref{Conditional Constructs}),
+and arithmetic expansion (@pxref{Shell Arithmetic}).
+
+@item
+Variables present in the shell's initial environment are automatically
+exported to child processes.  The Bourne shell does not normally do
+this unless the variables are explicitly marked using the @code{export}
+command.
+
+@item
+Bash supports the @samp{+=} assignment operator, which appends to the value
+of the variable named on the left hand side.
+
+@item
+Bash includes the @sc{posix} pattern removal @samp{%}, @samp{#}, @samp{%%}
+and @samp{##} expansions to remove leading or trailing substrings from
+variable values (@pxref{Shell Parameter Expansion}).
+
+@item
+The expansion @code{$@{#xx@}}, which returns the length of @code{$@{xx@}},
+is supported (@pxref{Shell Parameter Expansion}).
+
+@item
+The expansion @code{$@{var:}@var{offset}@code{[:}@var{length}@code{]@}},
+which expands to the substring of @code{var}'s value of length
+@var{length}, beginning at @var{offset}, is present
+(@pxref{Shell Parameter Expansion}).
+
+@item
+The expansion
+@code{$@{var/[/]}@var{pattern}@code{[/}@var{replacement}@code{]@}},
+which matches @var{pattern} and replaces it with @var{replacement} in
+the value of @code{var}, is available (@pxref{Shell Parameter Expansion}).
+
+@item
+The expansion @code{$@{!@var{prefix@}*}} expansion, which expands to
+the names of all shell variables whose names begin with @var{prefix},
+is available (@pxref{Shell Parameter Expansion}).
+
+@item
+Bash has @var{indirect} variable expansion using @code{$@{!word@}}
+(@pxref{Shell Parameter Expansion}).
+
+@item
+Bash can expand positional parameters beyond @code{$9} using
+@code{$@{@var{num}@}}.
+
+@item
+The @sc{posix} @code{$()} form of command substitution
+is implemented (@pxref{Command Substitution}),
+and preferred to the Bourne shell's @code{``} (which
+is also implemented for backwards compatibility).
+
+@item
+Bash has process substitution (@pxref{Process Substitution}).
+
+@item
+Bash automatically assigns variables that provide information about the
+current user (@env{UID}, @env{EUID}, and @env{GROUPS}), the current host
+(@env{HOSTTYPE}, @env{OSTYPE}, @env{MACHTYPE}, and @env{HOSTNAME}),
+and the instance of Bash that is running (@env{BASH},
+@env{BASH_VERSION}, and @env{BASH_VERSINFO}).  @xref{Bash Variables},
+for details.
+
+@item
+The @env{IFS} variable is used to split only the results of expansion,
+not all words (@pxref{Word Splitting}).
+This closes a longstanding shell security hole.
+
+@item
+Bash implements the full set of @sc{posix} filename expansion operators,
+including @var{character classes}, @var{equivalence classes}, and
+@var{collating symbols} (@pxref{Filename Expansion}).
+
+@item
+Bash implements extended pattern matching features when the @code{extglob}
+shell option is enabled (@pxref{Pattern Matching}).
+
+@item
+It is possible to have a variable and a function with the same name;
+@code{sh} does not separate the two name spaces.
+
+@item
+Bash functions are permitted to have local variables using the
+@code{local} builtin, and thus useful recursive functions may be written
+(@pxref{Bash Builtins}).
+
+@item
+Variable assignments preceding commands affect only that command, even
+builtins and functions (@pxref{Environment}).
+In @code{sh}, all variable assignments 
+preceding commands are global unless the command is executed from the
+file system.
+
+@item
+Bash performs filename expansion on filenames specified as operands
+to input and output redirection operators (@pxref{Redirections}).
+
+@item
+Bash contains the @samp{<>} redirection operator, allowing a file to be
+opened for both reading and writing, and the @samp{&>} redirection
+operator, for directing standard output and standard error to the same
+file (@pxref{Redirections}).
+
+@item
+Bash includes the @samp{<<<} redirection operator, allowing a string to
+be used as the standard input to a command.
+
+@item
+Bash implements the @samp{[n]<&@var{word}} and @samp{[n]>&@var{word}}
+redirection operators, which move one file descriptor to another.
+
+@item
+Bash treats a number of filenames specially when they are
+used in redirection operators (@pxref{Redirections}).
+
+@item
+Bash can open network connections to arbitrary machines and services
+with the redirection operators (@pxref{Redirections}).
+
+@item
+The @code{noclobber} option is available to avoid overwriting existing
+files with output redirection (@pxref{The Set Builtin}).
+The @samp{>|} redirection operator may be used to override @code{noclobber}.
+
+@item
+The Bash @code{cd} and @code{pwd} builtins (@pxref{Bourne Shell Builtins})
+each take @option{-L} and @option{-P} options to switch between logical and
+physical modes.
+
+@item
+Bash allows a function to override a builtin with the same name, and provides
+access to that builtin's functionality within the function via the
+@code{builtin} and @code{command} builtins (@pxref{Bash Builtins}).
+
+@item
+The @code{command} builtin allows selective disabling of functions
+when command lookup is performed (@pxref{Bash Builtins}).
+
+@item
+Individual builtins may be enabled or disabled using the @code{enable}
+builtin (@pxref{Bash Builtins}).
+
+@item
+The Bash @code{exec} builtin takes additional options that allow users
+to control the contents of the environment passed to the executed
+command, and what the zeroth argument to the command is to be
+(@pxref{Bourne Shell Builtins}).
+
+@item
+Shell functions may be exported to children via the environment
+using @code{export -f} (@pxref{Shell Functions}).
+
+@item
+The Bash @code{export}, @code{readonly}, and @code{declare} builtins can
+take a @option{-f} option to act on shell functions, a @option{-p} option to
+display variables with various attributes set in a format that can be
+used as shell input, a @option{-n} option to remove various variable
+attributes, and @samp{name=value} arguments to set variable attributes
+and values simultaneously.
+
+@item
+The Bash @code{hash} builtin allows a name to be associated with
+an arbitrary filename, even when that filename cannot be found by
+searching the @env{$PATH}, using @samp{hash -p}
+(@pxref{Bourne Shell Builtins}).
+
+@item
+Bash includes a @code{help} builtin for quick reference to shell
+facilities (@pxref{Bash Builtins}).
+
+@item
+The @code{printf} builtin is available to display formatted output
+(@pxref{Bash Builtins}).
+
+@item
+The Bash @code{read} builtin (@pxref{Bash Builtins})
+will read a line ending in @samp{\} with
+the @option{-r} option, and will use the @env{REPLY} variable as a
+default if no non-option arguments are supplied.
+The Bash @code{read} builtin
+also accepts a prompt string with the @option{-p} option and will use
+Readline to obtain the line when given the @option{-e} option.
+The @code{read} builtin also has additional options to control input:
+the @option{-s} option will turn off echoing of input characters as
+they are read, the @option{-t} option will allow @code{read} to time out
+if input does not arrive within a specified number of seconds, the
+@option{-n} option will allow reading only a specified number of
+characters rather than a full line, and the @option{-d} option will read
+until a particular character rather than newline.
+
+@item
+The @code{return} builtin may be used to abort execution of scripts
+executed with the @code{.} or @code{source} builtins
+(@pxref{Bourne Shell Builtins}).
+
+@item
+Bash includes the @code{shopt} builtin, for finer control of shell
+optional capabilities (@pxref{The Shopt Builtin}), and allows these options
+to be set and unset at shell invocation (@pxref{Invoking Bash}).
+
+@item
+Bash has much more optional behavior controllable with the @code{set}
+builtin (@pxref{The Set Builtin}).
+
+@item
+The @samp{-x} (@code{xtrace}) option displays commands other than
+simple commands when performing an execution trace
+(@pxref{The Set Builtin}).
+
+@item
+The @code{test} builtin (@pxref{Bourne Shell Builtins})
+is slightly different, as it implements the @sc{posix} algorithm,
+which specifies the behavior based on the number of arguments.
+
+@item
+Bash includes the @code{caller} builtin, which displays the context of
+any active subroutine call (a shell function or a script executed with
+the @code{.} or @code{source} builtins).  This supports the bash
+debugger.
+
+@item
+The @code{trap} builtin (@pxref{Bourne Shell Builtins}) allows a
+@code{DEBUG} pseudo-signal specification, similar to @code{EXIT}.
+Commands specified with a @code{DEBUG} trap are executed before every
+simple command, @code{for} command, @code{case} command,
+@code{select} command, every arithmetic @code{for} command, and before
+the first command executes in a shell function.
+The @code{DEBUG} trap is not inherited by shell functions unless the
+function has been given the @code{trace} attribute or the
+@code{functrace} option has been enabled using the @code{shopt} builtin.
+The @code{extdebug} shell option has additional effects on the
+@code{DEBUG} trap.
+
+The @code{trap} builtin (@pxref{Bourne Shell Builtins}) allows an
+@code{ERR} pseudo-signal specification, similar to @code{EXIT} and @code{DEBUG}.
+Commands specified with an @code{ERR} trap are executed after a simple
+command fails, with a few exceptions.
+The @code{ERR} trap is not inherited by shell functions unless the
+@code{-o errtrace} option to the @code{set} builtin is enabled.
+
+The @code{trap} builtin (@pxref{Bourne Shell Builtins}) allows a
+@code{RETURN} pseudo-signal specification, similar to
+@code{EXIT} and @code{DEBUG}.
+Commands specified with an @code{RETURN} trap are executed before
+execution resumes after a shell function or a shell script executed with
+@code{.} or @code{source} returns.
+The @code{RETURN} trap is not inherited by shell functions unless the
+function has been given the @code{trace} attribute or the
+@code{functrace} option has been enabled using the @code{shopt} builtin.
+
+@item
+The Bash @code{type} builtin is more extensive and gives more information
+about the names it finds (@pxref{Bash Builtins}).
+
+@item
+The Bash @code{umask} builtin permits a @option{-p} option to cause
+the output to be displayed in the form of a @code{umask} command
+that may be reused as input (@pxref{Bourne Shell Builtins}).
+
+@item
+Bash implements a @code{csh}-like directory stack, and provides the
+@code{pushd}, @code{popd}, and @code{dirs} builtins to manipulate it
+(@pxref{The Directory Stack}).
+Bash also makes the directory stack visible as the value of the
+@env{DIRSTACK} shell variable.
+
+@item
+Bash interprets special backslash-escaped characters in the prompt
+strings when interactive (@pxref{Printing a Prompt}).
+
+@item
+The Bash restricted mode is more useful (@pxref{The Restricted Shell});
+the SVR4.2 shell restricted mode is too limited.
+
+@item
+The @code{disown} builtin can remove a job from the internal shell
+job table (@pxref{Job Control Builtins}) or suppress the sending
+of @code{SIGHUP} to a job when the shell exits as the result of a
+@code{SIGHUP}.
+
+@item
+Bash includes a number of features to support a separate debugger for
+shell scripts.
+
+@item
+The SVR4.2 shell has two privilege-related builtins
+(@code{mldmode} and @code{priv}) not present in Bash.
+
+@item
+Bash does not have the @code{stop} or @code{newgrp} builtins.
+
+@item
+Bash does not use the @env{SHACCT} variable or perform shell accounting.
+
+@item
+The SVR4.2 @code{sh} uses a @env{TIMEOUT} variable like Bash uses
+@env{TMOUT}.
+
+@end itemize
+
+@noindent
+More features unique to Bash may be found in @ref{Bash Features}.
+
+
+@appendixsec Implementation Differences From The SVR4.2 Shell
+
+Since Bash is a completely new implementation, it does not suffer from
+many of the limitations of the SVR4.2 shell.  For instance:
+
+@itemize @bullet
+
+@item
+Bash does not fork a subshell when redirecting into or out of
+a shell control structure such as  an @code{if} or @code{while}
+statement.
+
+@item
+Bash does not allow unbalanced quotes.  The SVR4.2 shell will silently
+insert a needed closing quote at @code{EOF} under certain circumstances.
+This can be the cause of some hard-to-find errors.
+
+@item
+The SVR4.2 shell uses a baroque memory management scheme based on
+trapping @code{SIGSEGV}.  If the shell is started from a process with
+@code{SIGSEGV} blocked (e.g., by using the @code{system()} C library
+function call), it misbehaves badly.
+
+@item
+In a questionable attempt at security, the SVR4.2 shell,
+when invoked without the @option{-p} option, will alter its real
+and effective @sc{uid} and @sc{gid} if they are less than some
+magic threshold value, commonly 100.
+This can lead to unexpected results.
+
+@item
+The SVR4.2 shell does not allow users to trap @code{SIGSEGV},
+@code{SIGALRM}, or @code{SIGCHLD}.
+
+@item
+The SVR4.2 shell does not allow the @env{IFS}, @env{MAILCHECK},
+@env{PATH}, @env{PS1}, or @env{PS2} variables to be unset.
+
+@item
+The SVR4.2 shell treats @samp{^} as the undocumented equivalent of
+@samp{|}.
+
+@item
+Bash allows multiple option arguments when it is invoked (@code{-x -v});
+the SVR4.2 shell allows only one option argument (@code{-xv}).  In
+fact, some versions of the shell dump core if the second argument begins
+with a @samp{-}.
+
+@item
+The SVR4.2 shell exits a script if any builtin fails; Bash exits
+a script only if one of the @sc{posix} special builtins fails, and
+only for certain failures, as enumerated in the @sc{posix} standard.
+
+@item 
+The SVR4.2 shell behaves differently when invoked as @code{jsh}
+(it turns on job control).
+@end itemize
+
+@node Copying This Manual
+@appendix Copying This Manual
+
+@menu
+* GNU Free Documentation License::      License for copying this manual.
+@end menu
+
+@include fdl.texi
+
+@node Builtin Index
+@unnumbered Index of Shell Builtin Commands
+@printindex bt
+
+@node Reserved Word Index
+@unnumbered Index of Shell Reserved Words
+@printindex rw
+
+@node Variable Index
+@unnumbered Parameter and Variable Index
+@printindex vr
+
+@node Function Index
+@unnumbered Function Index
+@printindex fn
+
+@node Concept Index
+@unnumbered Concept Index
+@printindex cp
+
+@bye
index 9298c4b5a1106793d0a935cc84b96d28081da2f2..bc296b603aad3ef940bf34e12bf0fd47db445705 100644 (file)
@@ -562,7 +562,7 @@ fashion:
 
 In a non-interactive shell, or an interactive shell in which the
 @code{interactive_comments} option to the @code{shopt}
-builtin is enabled (@pxref{Bash Builtins}),
+builtin is enabled (@pxref{The Shopt Builtin}),
 a word beginning with @samp{#}
 causes that word and all remaining characters on that line to
 be ignored.  An interactive shell without the @code{interactive_comments}
@@ -848,7 +848,7 @@ The syntax of the @code{case} command is:
 @code{case} will selectively execute the @var{command-list} corresponding to
 the first @var{pattern} that matches @var{word}.
 If the shell option @code{nocasematch}
-(see the description of @code{shopt} in @ref{Bash Builtins})
+(see the description of @code{shopt} in @ref{The Shopt Builtin})
 is enabled, the match is performed without regard to the case
 of alphabetic characters.
 The @samp{|} is used to separate multiple patterns, and the @samp{)}
@@ -960,7 +960,7 @@ When the @samp{==} and @samp{!=} operators are used, the string to the
 right of the operator is considered a pattern and matched according
 to the rules described below in @ref{Pattern Matching}.
 If the shell option @code{nocasematch}
-(see the description of @code{shopt} in @ref{Bash Builtins})
+(see the description of @code{shopt} in @ref{The Shopt Builtin})
 is enabled, the match is performed without regard to the case
 of alphabetic characters.
 The return value is 0 if the string matches (@samp{==}) or does not
@@ -977,7 +977,7 @@ the pattern, and 1 otherwise.
 If the regular expression is syntactically incorrect, the conditional
 expression's return value is 2.
 If the shell option @code{nocasematch}
-(see the description of @code{shopt} in @ref{Bash Builtins})
+(see the description of @code{shopt} in @ref{The Shopt Builtin})
 is enabled, the match is performed without regard to the case
 of alphabetic characters.
 Substrings matched by parenthesized subexpressions within the regular
@@ -1785,13 +1785,15 @@ The shell scans the results of parameter expansion, command substitution,
 and arithmetic expansion that did not occur within double quotes for
 word splitting.
 
-The shell treats each character of @env{$IFS}
-as a delimiter, and splits the results of the other
-expansions into words on these characters.  If
-@env{IFS} is unset, or its value is exactly @code{<space><tab><newline>},
-the default, then any sequence of @env{IFS}
-characters serves to delimit words.  If @env{IFS}
-has a value other than the default, then sequences of
+The shell treats each character of @env{$IFS} as a delimiter, and splits
+the results of the other expansions into words on these characters.
+If @env{IFS} is unset, or its value is exactly @code{<space><tab><newline>},
+the default, then sequences of
+@code{ <space>}, @code{<tab>}, and @code{<newline>}
+at the beginning and end of the results of the previous
+expansions are ignored, and any sequence of @env{IFS}
+characters not at the beginning or end serves to delimit words.
+If @env{IFS} has a value other than the default, then sequences of
 the whitespace characters @code{space} and @code{tab}
 are ignored at the beginning and end of the
 word, as long as the whitespace character is in the
@@ -1844,7 +1846,7 @@ When matching a file name, the slash character must always be
 matched explicitly.
 In other cases, the @samp{.} character is not treated specially.
 
-See the description of @code{shopt} in @ref{Bash Builtins},
+See the description of @code{shopt} in @ref{The Shopt Builtin},
 for a description of the @code{nocaseglob}, @code{nullglob},
 @code{failglob}, and @code{dotglob} options.
 
@@ -2355,7 +2357,7 @@ options enabled at invocation (either by default or with command-line
 arguments) or by @code{set}
 
 @item
-options enabled by @code{shopt}
+options enabled by @code{shopt} (@pxref{The Shopt Builtin})
 
 @item
 shell aliases defined with @code{alias} (@pxref{Aliases})
@@ -2512,7 +2514,7 @@ builtin (@pxref{Job Control Builtins}) or marked
 to not receive @code{SIGHUP} using @code{disown -h}.
 
 If the  @code{huponexit} shell option has been set with @code{shopt}
-(@pxref{Bash Builtins}), Bash sends a @code{SIGHUP} to all jobs when
+(@pxref{The Shopt Builtin}), Bash sends a @code{SIGHUP} to all jobs when
 an interactive login shell exits.
 
 If Bash is waiting for a command to complete and receives a signal
@@ -2592,8 +2594,8 @@ under another shell.
 * Bourne Shell Builtins::      Builtin commands inherited from the Bourne
                                Shell.
 * Bash Builtins::              Table of builtins specific to Bash.
-* The Set Builtin::            Change the values of shell attributes and
-                               positional parameters.
+* Modifying Shell Behavior::   Builtins to modify shell attributes and
+                               optional behavior.
 * Special Builtins::           Builtin commands classified specially by
                                POSIX.
 @end menu
@@ -2896,8 +2898,9 @@ shift [@var{n}]
 @end example
 Shift the positional parameters to the left by @var{n}.
 The positional parameters from @var{n}+1 @dots{} @code{$#} are
-renamed to @code{$1} @dots{} @code{$#}-@var{n}+1.
-Parameters represented by the numbers @code{$#} to @var{n}+1 are unset.
+renamed to @code{$1} @dots{} @code{$#}-@var{n}.
+Parameters represented by the numbers @code{$#} to @code{$#}-@var{n}+1
+are unset.
 @var{n} must be a non-negative number less than or equal to @code{$#}.
 If @var{n} is zero or greater than @code{$#}, the positional parameters
 are not changed.
@@ -3018,7 +3021,7 @@ before every simple command, @code{for} command, @code{case} command,
 @code{select} command, every arithmetic @code{for} command, and before
 the first command executes in a shell function.
 Refer to the description of the @code{extglob} option to the
-@code{shopt} builtin (@pxref{Bash Builtins}) for details of its
+@code{shopt} builtin (@pxref{The Shopt Builtin}) for details of its
 effect on the @code{DEBUG} trap.
 If a @var{sigspec} is @code{ERR}, the command @var{arg} 
 is executed whenever a simple command has a non-zero exit status,
@@ -3254,7 +3257,7 @@ When @option{-p} is used, additional options are ignored.
 The @option{-F} option inhibits the display of function definitions;
 only the function name and attributes are printed.
 If the @code{extdebug} shell option is enabled using @code{shopt}
-(@pxref{Bash Builtins}), the source file name and line number where
+(@pxref{The Shopt Builtin}), the source file name and line number where
 the function is defined are displayed as well.
 @option{-F} implies @option{-f}.
 The following options can be used to restrict output to variables with
@@ -3356,7 +3359,7 @@ the eight-bit character whose value is the hexadecimal value @var{HH}
 @item enable
 @btindex enable
 @example
-enable [-n] [-p] [-f @var{filename}] [-ads] [@var{name} @dots{}]
+enable [-a] [-dnps] [-f @var{filename}] [@var{name} @dots{}]
 @end example
 Enable and disable builtin shell commands.
 Disabling a builtin allows a disk command which has the same name
@@ -3528,421 +3531,177 @@ Read input from file descriptor @var{fd}.
 
 @end table
 
-@item shopt
-@btindex shopt
+@item source
+@btindex source
 @example
-shopt [-pqsu] [-o] [@var{optname} @dots{}]
+source @var{filename}
 @end example
-Toggle the values of variables controlling optional shell behavior.
-With no options, or with the @option{-p} option, a list of all settable
-options is displayed, with an indication of whether or not each is set.
-The @option{-p} option causes output to be displayed in a form that
-may be reused as input.
-Other options have the following meanings:
+A synonym for @code{.} (@pxref{Bourne Shell Builtins}).
 
-@table @code
-@item -s
-Enable (set) each @var{optname}.
+@item type
+@btindex type
+@example
+type [-afptP] [@var{name} @dots{}]
+@end example
+For each @var{name}, indicate how it would be interpreted if used as a
+command name.
 
-@item -u
-Disable (unset) each @var{optname}.
+If the @option{-t} option is used, @code{type} prints a single word
+which is one of @samp{alias}, @samp{function}, @samp{builtin},
+@samp{file} or @samp{keyword},
+if @var{name} is an alias, shell function, shell builtin,
+disk file, or shell reserved word, respectively.
+If the @var{name} is not found, then nothing is printed, and
+@code{type} returns a failure status.
 
-@item -q
-Suppresses normal output; the return status
-indicates whether the @var{optname} is set or unset.
-If multiple @var{optname} arguments are given with @option{-q},
-the return status is zero if all @var{optnames} are enabled;
-non-zero otherwise.
+If the @option{-p} option is used, @code{type} either returns the name
+of the disk file that would be executed, or nothing if @option{-t}
+would not return @samp{file}.
 
-@item -o
-Restricts the values of
-@var{optname} to be those defined for the @option{-o} option to the
-@code{set} builtin (@pxref{The Set Builtin}).
-@end table
+The @option{-P} option forces a path search for each @var{name}, even if
+@option{-t} would not return @samp{file}.
 
-If either @option{-s} or @option{-u}
-is used with no @var{optname} arguments, the display is limited to
-those options which are set or unset, respectively.
+If a command is hashed, @option{-p} and @option{-P} print the hashed value,
+not necessarily the file that appears first in @code{$PATH}.
 
-Unless otherwise noted, the @code{shopt} options are disabled (off)
-by default.
+If the @option{-a} option is used, @code{type} returns all of the places
+that contain an executable named @var{file}.
+This includes aliases and functions, if and only if the @option{-p} option
+is not also used.
 
-The return status when listing options is zero if all @var{optnames}
-are enabled, non-zero otherwise.  When setting or unsetting options,
-the return status is zero unless an @var{optname} is not a valid shell
-option.
+If the @option{-f} option is used, @code{type} does not attempt to find
+shell functions, as with the @code{command} builtin.
 
-The list of @code{shopt} options is:
+The return status is zero if any of the @var{names} are found, non-zero
+if none are found.
+
+@item typeset
+@btindex typeset
+@example
+typeset [-afFrxi] [-p] [@var{name}[=@var{value}] @dots{}]
+@end example
+The @code{typeset} command is supplied for compatibility with the Korn
+shell; however, it has been deprecated in favor of the @code{declare}
+builtin command.
+
+@item ulimit
+@btindex ulimit
+@example
+ulimit [-acdefilmnpqrstuvxSH] [@var{limit}]
+@end example
+@code{ulimit} provides control over the resources available to processes
+started by the shell, on systems that allow such control.  If an
+option is given, it is interpreted as follows:
 @table @code
-@item cdable_vars
-If this is set, an argument to the @code{cd}
-builtin command that
-is not a directory is assumed to be the name of a variable whose
-value is the directory to change to.
+@item -S
+Change and report the soft limit associated with a resource.
 
-@item cdspell
-If set, minor errors in the spelling of a directory component in a
-@code{cd} command will be corrected.
-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 only used by interactive shells.
+@item -H
+Change and report the hard limit associated with a resource.
 
-@item checkhash
-If this is set, Bash checks that a command found in the hash
-table exists before trying to execute it.  If a hashed command no
-longer exists, a normal path search is performed.
+@item -a
+All current limits are reported.
 
-@item checkwinsize
-If set, Bash checks the window size after each command
-and, if necessary, updates the values of    
-@env{LINES} and @env{COLUMNS}.
+@item -c
+The maximum size of core files created.
 
-@item cmdhist
-If set, Bash
-attempts to save all lines of a multiple-line
-command in the same history entry.  This allows
-easy re-editing of multi-line commands.
+@item -d
+The maximum size of a process's data segment.
 
-@item dotglob
-If set, Bash includes filenames beginning with a `.' in
-the results of filename expansion.
+@item -e
+The maximum scheduling priority ("nice").
 
-@item execfail
-If this is set, a non-interactive shell will not exit if
-it cannot execute the file specified as an argument to the @code{exec}
-builtin command.  An interactive shell does not exit if @code{exec}
-fails.
+@item -f
+The maximum size of files written by the shell and its children.
 
-@item expand_aliases
-If set, aliases are expanded as described below under Aliases,
-@ref{Aliases}.
-This option is enabled by default for interactive shells.
+@item -i
+The maximum number of pending signals.
 
-@item extdebug
-If set, behavior intended for use by debuggers is enabled:
+@item -l
+The maximum size that may be locked into memory.
 
-@enumerate
-@item
-The @option{-F} option to the @code{declare} builtin (@pxref{Bash Builtins})
-displays the source file name and line number corresponding to each function
-name supplied as an argument.
+@item -m
+The maximum resident set size.
 
-@item
-If the command run by the @code{DEBUG} trap returns a non-zero value, the
-next command is skipped and not executed.
+@item -n
+The maximum number of open file descriptors.
 
-@item
-If the command run by the @code{DEBUG} trap returns a value of 2, and the
-shell is executing in a subroutine (a shell function or a shell script
-executed by the @code{.} or @code{source} builtins), a call to
-@code{return} is simulated.
+@item -p
+The pipe buffer size.
 
-@item
-@code{BASH_ARGC} and @code{BASH_ARGV} are updated as described in their
-descriptions (@pxref{Bash Variables}).
+@item -q
+The maximum number of bytes in POSIX message queues.
 
-@item
-Function tracing is enabled:  command substitution, shell functions, and
-subshells invoked with @code{( @var{command} )} inherit the
-@code{DEBUG} and @code{RETURN} traps.
+@item -r
+The maximum real-time scheduling priority.
 
-@item
-Error tracing is enabled:  command substitution, shell functions, and
-subshells invoked with @code{( @var{command} )} inherit the
-@code{ERROR} trap.
-@end enumerate
+@item -s
+The maximum stack size.
 
-@item extglob
-If set, the extended pattern matching features described above
-(@pxref{Pattern Matching}) are enabled.
+@item -t
+The maximum amount of cpu time in seconds.
 
-@item extquote
-If set, @code{$'@var{string}'} and @code{$"@var{string}"} quoting is  
-performed within @code{$@{@var{parameter}@}} expansions                     
-enclosed in double quotes.  This option is enabled by default. 
+@item -u
+The maximum number of processes available to a single user.
 
-@item failglob
-If set, patterns which fail to match filenames during pathname expansion
-result in an expansion error.
+@item -v
+The maximum amount of virtual memory available to the process.
 
-@item force_fignore
-If set, the suffixes specified by the @env{FIGNORE} shell variable
-cause words to be ignored when performing word completion even if
-the ignored words are the only possible completions.
-@xref{Bash Variables}, for a description of @env{FIGNORE}.
-This option is enabled by default.
+@item -x
+The maximum number of file locks.
 
-@item gnu_errfmt
-If set, shell error messages are written in the standard @sc{gnu} error
-message format.
+@end table
 
-@item histappend
-If set, the history list is appended to the file named by the value
-of the @env{HISTFILE}
-variable when the shell exits, rather than overwriting the file.
+If @var{limit} is given, it is the new value of the specified resource;
+the special @var{limit} values @code{hard}, @code{soft}, and
+@code{unlimited} stand for the current hard limit, the current soft limit,
+and no limit, respectively.
+Otherwise, the current value of the soft limit for the specified resource
+is printed, unless the @option{-H} option is supplied.
+When setting new limits, if neither @option{-H} nor @option{-S} is supplied,
+both the hard and soft limits are set.
+If no option is given, then @option{-f} is assumed.  Values are in 1024-byte
+increments, except for @option{-t}, which is in seconds, @option{-p},
+which is in units of 512-byte blocks, and @option{-n} and @option{-u}, which
+are unscaled values.
 
-@item histreedit
-If set, and Readline
-is being used, a user is given the opportunity to re-edit a
-failed history substitution.
+The return status is zero unless an invalid option or argument is supplied,
+or an error occurs while setting a new limit.
 
-@item histverify
-If set, and Readline
-is being used, the results of history substitution are not immediately
-passed to the shell parser.  Instead, the resulting line is loaded into
-the Readline editing buffer, allowing further modification.
+@item unalias
+@btindex unalias
+@example
+unalias [-a] [@var{name} @dots{} ]
+@end example
 
-@item hostcomplete
-If set, and Readline is being used, Bash will attempt to perform
-hostname completion when a word containing a @samp{@@} is being
-completed (@pxref{Commands For Completion}).  This option is enabled
-by default.
+Remove each @var{name} from the list of aliases.  If @option{-a} is
+supplied, all aliases are removed.
+Aliases are described in @ref{Aliases}.
 
-@item huponexit
-If set, Bash will send @code{SIGHUP} to all jobs when an interactive
-login shell exits (@pxref{Signals}).
+@end table
 
-@item interactive_comments
-Allow a word beginning with @samp{#}
-to cause that word and all remaining characters on that
-line to be ignored in an interactive shell.
-This option is enabled by default.
-
-@item lithist
-If enabled, and the @code{cmdhist}
-option is enabled, multi-line commands are saved to the history with
-embedded newlines rather than using semicolon separators where possible.
-
-@item login_shell
-The shell sets this option if it is started as a login shell
-(@pxref{Invoking Bash}).
-The value may not be changed.
-
-@item mailwarn
-If set, and a file that Bash is checking for mail has been  
-accessed since the last time it was checked, the message
-@code{"The mail in @var{mailfile} has been read"} is displayed.
-
-@item no_empty_cmd_completion
-If set, and Readline is being used, Bash will not attempt to search
-the @env{PATH} for possible completions when completion is attempted
-on an empty line.
-
-@item nocaseglob
-If set, Bash matches filenames in a case-insensitive fashion when
-performing filename expansion.
-
-@item nocasematch
-If set, Bash matches patterns in a case-insensitive fashion when
-performing matching while executing @code{case} or @code{[[}
-conditional commands.
-
-@item nullglob
-If set, Bash allows filename patterns which match no
-files to expand to a null string, rather than themselves.
-
-@item progcomp
-If set, the programmable completion facilities
-(@pxref{Programmable Completion}) are enabled.
-This option is enabled by default.
-
-@item promptvars
-If set, prompt strings undergo
-parameter expansion, command substitution, arithmetic
-expansion, and quote removal after being expanded
-as described below (@pxref{Printing a Prompt}).
-This option is enabled by default.
-
-@item restricted_shell
-The shell sets this option if it is started in restricted mode
-(@pxref{The Restricted Shell}).
-The value may not be changed.
-This is not reset when the startup files are executed, allowing
-the startup files to discover whether or not a shell is restricted.
-
-@item shift_verbose
-If this is set, the @code{shift}
-builtin prints an error message when the shift count exceeds the
-number of positional parameters.
-
-@item sourcepath
-If set, the @code{source} builtin uses the value of @env{PATH}
-to find the directory containing the file supplied as an argument.
-This option is enabled by default.
-
-@item xpg_echo
-If set, the @code{echo} builtin expands backslash-escape sequences
-by default.
-
-@end table
-
-@noindent
-The return status when listing options is zero if all @var{optnames}
-are enabled, non-zero otherwise.
-When setting or unsetting options, the return status is zero unless an
-@var{optname} is not a valid shell option.
-
-@item source
-@btindex source
-@example
-source @var{filename}
-@end example
-A synonym for @code{.} (@pxref{Bourne Shell Builtins}).
-
-@item type
-@btindex type
-@example
-type [-afptP] [@var{name} @dots{}]
-@end example
-For each @var{name}, indicate how it would be interpreted if used as a
-command name.
-
-If the @option{-t} option is used, @code{type} prints a single word
-which is one of @samp{alias}, @samp{function}, @samp{builtin},
-@samp{file} or @samp{keyword},
-if @var{name} is an alias, shell function, shell builtin,
-disk file, or shell reserved word, respectively.
-If the @var{name} is not found, then nothing is printed, and
-@code{type} returns a failure status.
-
-If the @option{-p} option is used, @code{type} either returns the name
-of the disk file that would be executed, or nothing if @option{-t}
-would not return @samp{file}.
-
-The @option{-P} option forces a path search for each @var{name}, even if
-@option{-t} would not return @samp{file}.
-
-If a command is hashed, @option{-p} and @option{-P} print the hashed value,
-not necessarily the file that appears first in @code{$PATH}.
-
-If the @option{-a} option is used, @code{type} returns all of the places
-that contain an executable named @var{file}.
-This includes aliases and functions, if and only if the @option{-p} option
-is not also used.
-
-If the @option{-f} option is used, @code{type} does not attempt to find
-shell functions, as with the @code{command} builtin.
-
-The return status is zero if any of the @var{names} are found, non-zero
-if none are found.
-
-@item typeset
-@btindex typeset
-@example
-typeset [-afFrxi] [-p] [@var{name}[=@var{value}] @dots{}]
-@end example
-The @code{typeset} command is supplied for compatibility with the Korn
-shell; however, it has been deprecated in favor of the @code{declare}
-builtin command.
-
-@item ulimit
-@btindex ulimit
-@example
-ulimit [-acdefilmnpqrstuvxSH] [@var{limit}]
-@end example
-@code{ulimit} provides control over the resources available to processes
-started by the shell, on systems that allow such control.  If an
-option is given, it is interpreted as follows:
-@table @code
-@item -S
-Change and report the soft limit associated with a resource.
-
-@item -H
-Change and report the hard limit associated with a resource.
-
-@item -a
-All current limits are reported.
-
-@item -c
-The maximum size of core files created.
-
-@item -d
-The maximum size of a process's data segment.
-
-@item -e
-The maximum scheduling priority ("nice").
-
-@item -f
-The maximum size of files written by the shell and its children.
-
-@item -i
-The maximum number of pending signals.
-
-@item -l
-The maximum size that may be locked into memory.
-
-@item -m
-The maximum resident set size.
-
-@item -n
-The maximum number of open file descriptors.
-
-@item -p
-The pipe buffer size.
-
-@item -q
-The maximum number of bytes in POSIX message queues.
-
-@item -r
-The maximum real-time scheduling priority.
-
-@item -s
-The maximum stack size.
-
-@item -t
-The maximum amount of cpu time in seconds.
-
-@item -u
-The maximum number of processes available to a single user.
-
-@item -v
-The maximum amount of virtual memory available to the process.
-
-@item -x
-The maximum number of file locks.
-
-@end table
-
-If @var{limit} is given, it is the new value of the specified resource;
-the special @var{limit} values @code{hard}, @code{soft}, and
-@code{unlimited} stand for the current hard limit, the current soft limit,
-and no limit, respectively.
-Otherwise, the current value of the soft limit for the specified resource
-is printed, unless the @option{-H} option is supplied.
-When setting new limits, if neither @option{-H} nor @option{-S} is supplied,
-both the hard and soft limits are set.
-If no option is given, then @option{-f} is assumed.  Values are in 1024-byte
-increments, except for @option{-t}, which is in seconds, @option{-p},
-which is in units of 512-byte blocks, and @option{-n} and @option{-u}, which
-are unscaled values.
-
-The return status is zero unless an invalid option or argument is supplied,
-or an error occurs while setting a new limit.
-
-@item unalias
-@btindex unalias
-@example
-unalias [-a] [@var{name} @dots{} ]
-@end example
-
-Remove each @var{name} from the list of aliases.  If @option{-a} is
-supplied, all aliases are removed.
-Aliases are described in @ref{Aliases}.
-
-@end table
+@node Modifying Shell Behavior
+@section Modifying Shell Behavior
+@menu
+* The Set Builtin::            Change the values of shell attributes and
+                               positional parameters.
+* The Shopt Builtin::          Modify shell optional behavior.
+@end menu
 
 @node The Set Builtin
-@section The Set Builtin
+@subsection The Set Builtin
 
-This builtin is so complicated that it deserves its own section.
+This builtin is so complicated that it deserves its own section.  @code{set}
+allows you to change the values of shell options and set the positional
+parameters, or to display the names and values of shell variables.
 
 @table @code
 @item set
 @btindex set
 @example
 set [--abefhkmnptuvxBCEHPT] [-o @var{option}] [@var{argument} @dots{}]
+set [+abefhkmnptuvxBCEHPT] [+o @var{option}] [@var{argument} @dots{}]
 @end example
 
 If no options or arguments are supplied, @code{set} displays the names
@@ -4191,6 +3950,283 @@ The special parameter @code{#} is set to N.
 The return status is always zero unless an invalid option is supplied.
 @end table
 
+@node The Shopt Builtin
+@subsection The Shopt Builtin
+
+This builtin allows you to change additional shell optional behavior.
+
+@table @code
+
+@item shopt
+@btindex shopt
+@example
+shopt [-pqsu] [-o] [@var{optname} @dots{}]
+@end example
+Toggle the values of variables controlling optional shell behavior.
+With no options, or with the @option{-p} option, a list of all settable
+options is displayed, with an indication of whether or not each is set.
+The @option{-p} option causes output to be displayed in a form that
+may be reused as input.
+Other options have the following meanings:
+
+@table @code
+@item -s
+Enable (set) each @var{optname}.
+
+@item -u
+Disable (unset) each @var{optname}.
+
+@item -q
+Suppresses normal output; the return status
+indicates whether the @var{optname} is set or unset.
+If multiple @var{optname} arguments are given with @option{-q},
+the return status is zero if all @var{optnames} are enabled;
+non-zero otherwise.
+
+@item -o
+Restricts the values of
+@var{optname} to be those defined for the @option{-o} option to the
+@code{set} builtin (@pxref{The Set Builtin}).
+@end table
+
+If either @option{-s} or @option{-u}
+is used with no @var{optname} arguments, the display is limited to
+those options which are set or unset, respectively.
+
+Unless otherwise noted, the @code{shopt} options are disabled (off)
+by default.
+
+The return status when listing options is zero if all @var{optnames}
+are enabled, non-zero otherwise.  When setting or unsetting options,
+the return status is zero unless an @var{optname} is not a valid shell
+option.
+
+The list of @code{shopt} options is:
+@table @code
+
+@item autocd
+If set, a command name that is the name of a directory is executed as if
+it were the argument to the @code{cd} command.
+This option is only used by interactive shells.
+
+@item cdable_vars
+If this is set, an argument to the @code{cd} builtin command that
+is not a directory is assumed to be the name of a variable whose
+value is the directory to change to.
+
+@item cdspell
+If set, minor errors in the spelling of a directory component in a
+@code{cd} command will be corrected.
+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 only used by interactive shells.
+
+@item checkhash
+If this is set, Bash checks that a command found in the hash
+table exists before trying to execute it.  If a hashed command no
+longer exists, a normal path search is performed.
+
+@item checkjobs
+If set, Bash lists the status of any stopped and running jobs before
+exiting an interactive shell.  If any jobs are running, this causes
+the exit to be deferred until a second exit is attempted without an
+intervening command (@pxref{Job Control}).
+The shell always postpones exiting if any jobs are stopped.
+
+@item checkwinsize
+If set, Bash checks the window size after each command
+and, if necessary, updates the values of    
+@env{LINES} and @env{COLUMNS}.
+
+@item cmdhist
+If set, Bash
+attempts to save all lines of a multiple-line
+command in the same history entry.  This allows
+easy re-editing of multi-line commands.
+
+@item dotglob
+If set, Bash includes filenames beginning with a `.' in
+the results of filename expansion.
+
+@item execfail
+If this is set, a non-interactive shell will not exit if
+it cannot execute the file specified as an argument to the @code{exec}
+builtin command.  An interactive shell does not exit if @code{exec}
+fails.
+
+@item expand_aliases
+If set, aliases are expanded as described below under Aliases,
+@ref{Aliases}.
+This option is enabled by default for interactive shells.
+
+@item extdebug
+If set, behavior intended for use by debuggers is enabled:
+
+@enumerate
+@item
+The @option{-F} option to the @code{declare} builtin (@pxref{Bash Builtins})
+displays the source file name and line number corresponding to each function
+name supplied as an argument.
+
+@item
+If the command run by the @code{DEBUG} trap returns a non-zero value, the
+next command is skipped and not executed.
+
+@item
+If the command run by the @code{DEBUG} trap returns a value of 2, and the
+shell is executing in a subroutine (a shell function or a shell script
+executed by the @code{.} or @code{source} builtins), a call to
+@code{return} is simulated.
+
+@item
+@code{BASH_ARGC} and @code{BASH_ARGV} are updated as described in their
+descriptions (@pxref{Bash Variables}).
+
+@item
+Function tracing is enabled:  command substitution, shell functions, and
+subshells invoked with @code{( @var{command} )} inherit the
+@code{DEBUG} and @code{RETURN} traps.
+
+@item
+Error tracing is enabled:  command substitution, shell functions, and
+subshells invoked with @code{( @var{command} )} inherit the
+@code{ERROR} trap.
+@end enumerate
+
+@item extglob
+If set, the extended pattern matching features described above
+(@pxref{Pattern Matching}) are enabled.
+
+@item extquote
+If set, @code{$'@var{string}'} and @code{$"@var{string}"} quoting is  
+performed within @code{$@{@var{parameter}@}} expansions                     
+enclosed in double quotes.  This option is enabled by default. 
+
+@item failglob
+If set, patterns which fail to match filenames during pathname expansion
+result in an expansion error.
+
+@item force_fignore
+If set, the suffixes specified by the @env{FIGNORE} shell variable
+cause words to be ignored when performing word completion even if
+the ignored words are the only possible completions.
+@xref{Bash Variables}, for a description of @env{FIGNORE}.
+This option is enabled by default.
+
+@item gnu_errfmt
+If set, shell error messages are written in the standard @sc{gnu} error
+message format.
+
+@item histappend
+If set, the history list is appended to the file named by the value
+of the @env{HISTFILE}
+variable when the shell exits, rather than overwriting the file.
+
+@item histreedit
+If set, and Readline
+is being used, a user is given the opportunity to re-edit a
+failed history substitution.
+
+@item histverify
+If set, and Readline
+is being used, the results of history substitution are not immediately
+passed to the shell parser.  Instead, the resulting line is loaded into
+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 containing a @samp{@@} is being
+completed (@pxref{Commands For Completion}).  This option is enabled
+by default.
+
+@item huponexit
+If set, Bash will send @code{SIGHUP} to all jobs when an interactive
+login shell exits (@pxref{Signals}).
+
+@item interactive_comments
+Allow a word beginning with @samp{#}
+to cause that word and all remaining characters on that
+line to be ignored in an interactive shell.
+This option is enabled by default.
+
+@item lithist
+If enabled, and the @code{cmdhist}
+option is enabled, multi-line commands are saved to the history with
+embedded newlines rather than using semicolon separators where possible.
+
+@item login_shell
+The shell sets this option if it is started as a login shell
+(@pxref{Invoking Bash}).
+The value may not be changed.
+
+@item mailwarn
+If set, and a file that Bash is checking for mail has been  
+accessed since the last time it was checked, the message
+@code{"The mail in @var{mailfile} has been read"} is displayed.
+
+@item no_empty_cmd_completion
+If set, and Readline is being used, Bash will not attempt to search
+the @env{PATH} for possible completions when completion is attempted
+on an empty line.
+
+@item nocaseglob
+If set, Bash matches filenames in a case-insensitive fashion when
+performing filename expansion.
+
+@item nocasematch
+If set, Bash matches patterns in a case-insensitive fashion when
+performing matching while executing @code{case} or @code{[[}
+conditional commands.
+
+@item nullglob
+If set, Bash allows filename patterns which match no
+files to expand to a null string, rather than themselves.
+
+@item progcomp
+If set, the programmable completion facilities
+(@pxref{Programmable Completion}) are enabled.
+This option is enabled by default.
+
+@item promptvars
+If set, prompt strings undergo
+parameter expansion, command substitution, arithmetic
+expansion, and quote removal after being expanded
+as described below (@pxref{Printing a Prompt}).
+This option is enabled by default.
+
+@item restricted_shell
+The shell sets this option if it is started in restricted mode
+(@pxref{The Restricted Shell}).
+The value may not be changed.
+This is not reset when the startup files are executed, allowing
+the startup files to discover whether or not a shell is restricted.
+
+@item shift_verbose
+If this is set, the @code{shift}
+builtin prints an error message when the shift count exceeds the
+number of positional parameters.
+
+@item sourcepath
+If set, the @code{source} builtin uses the value of @env{PATH}
+to find the directory containing the file supplied as an argument.
+This option is enabled by default.
+
+@item xpg_echo
+If set, the @code{echo} builtin expands backslash-escape sequences
+by default.
+
+@end table
+
+@noindent
+The return status when listing options is zero if all @var{optnames}
+are enabled, non-zero otherwise.
+When setting or unsetting options, the return status is zero unless an
+@var{optname} is not a valid shell option.
+
+@end table
+
 @node Special Builtins
 @section Special Builtins
 @cindex special builtin
@@ -4310,6 +4346,11 @@ variables for controlling the job control facilities
 @item BASH
 The full pathname used to execute the current instance of Bash.
 
+@item BASHPID
+Expands to the process id of the current Bash process.
+This differs from @code{$$} under certain circumstances, such as subshells
+that do not require Bash to be re-initialized.
+
 @item BASH_ARGC
 An array variable whose values are the number of parameters in each
 frame of the current bash execution call stack.  The number of
@@ -4318,7 +4359,7 @@ with @code{.} or @code{source}) is at the top of the stack.  When a
 subroutine is executed, the number of parameters passed is pushed onto
 @code{BASH_ARGC}.
 The shell sets @code{BASH_ARGC} only when in extended debugging mode
-(see @ref{Bash Builtins}  
+(see @ref{The Shopt Builtin}
 for a description of the @code{extdebug} option to the @code{shopt}
 builtin).
 
@@ -4329,7 +4370,7 @@ is at the top of the stack; the first parameter of the initial call is
 at the bottom.  When a subroutine is executed, the parameters supplied
 are pushed onto @code{BASH_ARGV}.
 The shell sets @code{BASH_ARGV} only when in extended debugging mode
-(see @ref{Bash Builtins}  
+(see @ref{The Shopt Builtin}
 for a description of the @code{extdebug} option to the @code{shopt}
 builtin).
 
@@ -4428,6 +4469,19 @@ This variable is available only in shell functions and external
 commands invoked by the
 programmable completion facilities (@pxref{Programmable Completion}).
 
+@item COMP_TYPE
+Set to an integer value corresponding to the type of completion attempted
+that caused a completion function to be called:
+@var{TAB}, for normal completion,
+@samp{?}, for listing completions after successive tabs,
+@samp{!}, for listing alternatives on partial word completion,
+@samp{@@}, to list completions if the word is not unmodified,
+or
+@samp{%}, for menu completion.
+This variable is available only in shell functions and external
+commands invoked by the
+programmable completion facilities (@pxref{Programmable Completion}).
+
 @item COMP_WORDBREAKS
 The set of characters that the Readline library treats as word
 separators when performing word completion.
@@ -4858,7 +4912,7 @@ line before the single-character options to be recognized.
 @table @code
 @item --debugger
 Arrange for the debugger profile to be executed before the shell
-starts.  Turns on extended debugging mode (see @ref{Bash Builtins}
+starts.  Turns on extended debugging mode (see @ref{The Shopt Builtin}
 for a description of the @code{extdebug} option to the @code{shopt}
 builtin) and shell function tracing
 (see @ref{The Set Builtin} for a description of the @code{-o functrace}
@@ -4961,7 +5015,7 @@ This implies the @option{-n} option; no commands will be executed.
 
 @item [-+]O [@var{shopt_option}]
 @var{shopt_option} is one of the shell options accepted by the
-@code{shopt} builtin (@pxref{Shell Builtin Commands}).
+@code{shopt} builtin (@pxref{The Shopt Builtin}).
 If @var{shopt_option} is present, @option{-O} sets the value of that option;
 @option{+O} unsets it.  
 If @var{shopt_option} is not supplied, the names and values of the shell
@@ -5260,7 +5314,7 @@ Parser syntax errors will not cause the shell to exit.
 @item
 Simple spelling correction for directory arguments to the @code{cd}
 builtin is enabled by default (see the description of the @code{cdspell}
-option to the @code{shopt} builtin in @ref{Bash Builtins}).
+option to the @code{shopt} builtin in @ref{The Shopt Builtin}).
 
 @item
 The shell will check the value of the @env{TMOUT} variable and exit
@@ -5544,7 +5598,7 @@ If arguments are needed, a shell function should be used
 
 Aliases are not expanded when the shell is not interactive,
 unless the @code{expand_aliases} shell option is set using
-@code{shopt} (@pxref{Bash Builtins}).
+@code{shopt} (@pxref{The Shopt Builtin}).
 
 The rules concerning the definition and use of aliases are
 somewhat confusing.  Bash
@@ -6246,11 +6300,13 @@ Bash reports such changes immediately (@pxref{The Set Builtin}).
 Any trap on @code{SIGCHLD} is executed for each child process
 that exits.
 
-If an attempt to exit Bash is made while jobs are stopped, the
-shell prints a message warning that there are stopped jobs.
+If an attempt to exit Bash is made while jobs are stopped, (or running, if
+the @code{checkjobs} option is enabled -- see @ref{The Shopt Builtin}), the
+shell prints a warning message, and if the @code{checkjobs} option is
+enabled, lists the jobs and their statuses.
 The @code{jobs} command may then be used to inspect their status.
 If a second attempt to exit is made without an intervening command,
-Bash does not print another warning, and the stopped jobs are terminated.
+Bash does not print another warning, and any stopped jobs are terminated.
 
 @node Job Control Builtins
 @section Job Control Builtins
@@ -7233,7 +7289,7 @@ executed with the @code{.} or @code{source} builtins
 
 @item
 Bash includes the @code{shopt} builtin, for finer control of shell
-optional capabilities (@pxref{Bash Builtins}), and allows these options
+optional capabilities (@pxref{The Shopt Builtin}), and allows these options
 to be set and unset at shell invocation (@pxref{Invoking Bash}).
 
 @item
index 530e495b7f60f4c4211fd827dd9b4739e156e840..42375e301dacdb50260b661baa9332d62d26c02f 100644 (file)
@@ -2,9 +2,9 @@
 Copyright (C) 1988-2006 Free Software Foundation, Inc.
 @end ignore
 
-@set LASTCHANGE Mon Nov 27 12:02:15 EST 2006
+@set LASTCHANGE Sat Dec 30 19:31:54 EST 2006
 
 @set EDITION 3.2
 @set VERSION 3.2
-@set UPDATED 27 November 2006
-@set UPDATED-MONTH November 2006
+@set UPDATED 30 December 2006
+@set UPDATED-MONTH December 2006
index 484f616965894833140ef9154a211123b723286e..3e7083b49f0ca12eba76331f5baf32fabc7499cc 100644 (file)
@@ -2,9 +2,9 @@
 Copyright (C) 1988-2006 Free Software Foundation, Inc.
 @end ignore
 
-@set LASTCHANGE Wed Nov  8 11:21:28 EST 2006
+@set LASTCHANGE Tue Dec 26 16:58:41 EST 2006
 
 @set EDITION 3.2
 @set VERSION 3.2
-@set UPDATED 8 November 2006
-@set UPDATED-MONTH November 2006
+@set UPDATED 26 December 2006
+@set UPDATED-MONTH December 2006
diff --git a/error.c b/error.c
index c400f44963e1528dd7919cc37b7db53fadfab8cf..c83a9861195561906c2b9bc1a75b8a915c63658f 100644 (file)
--- a/error.c
+++ b/error.c
@@ -59,7 +59,7 @@ extern int give_terminal_to __P((pid_t, int));
 #endif /* JOB_CONTROL */
 
 #if defined (ARRAY_VARS)
-extern char *bash_badsub_errmsg;
+extern const char * const bash_badsub_errmsg;
 #endif
 
 static void error_prolog __P((int));
@@ -70,7 +70,7 @@ static void error_prolog __P((int));
 #define MAINTAINER "bash-maintainers@gnu.org"
 #endif
 
-char *the_current_maintainer = MAINTAINER;
+const char * const the_current_maintainer = MAINTAINER;
 
 int gnu_error_format = 0;
 
@@ -399,7 +399,7 @@ trace (format, va_alist)
 /* **************************************************************** */
 
 
-static char *cmd_error_table[] = {
+static const char * const cmd_error_table[] = {
        N_("unknown command error"),    /* CMDERR_DEFAULT */
        N_("bad command type"),         /* CMDERR_BADTYPE */
        N_("bad connector"),            /* CMDERR_BADCONN */
index 83f6a7a9fc6cb2983a59fcf6f64c25ce6cd5a91f..c400f44963e1528dd7919cc37b7db53fadfab8cf 100644 (file)
--- a/error.c~
+++ b/error.c~
@@ -1,5 +1,5 @@
 /* error.c -- Functions for handling errors. */
-/* Copyright (C) 1993-2003 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2006 Free Software Foundation, Inc.
 
    This file is part of GNU Bash, the Bourne Again SHell.
 
@@ -85,7 +85,7 @@ error_prolog (print_lineno)
   line = (print_lineno && interactive_shell == 0) ? executing_line_number () : -1;
 
   if (line > 0)
-    fprintf (stderr, "%s:%s%d: ", ename, gnu_error_format ? "" : " line ", line);
+    fprintf (stderr, "%s:%s%d: ", ename, gnu_error_format ? "" : _(" line "), line);
   else
     fprintf (stderr, "%s: ", ename);
 }
@@ -315,11 +315,11 @@ parser_error (lineno, format, va_alist)
   if (interactive)
     fprintf (stderr, "%s: ", ename);
   else if (interactive_shell)
-    fprintf (stderr, "%s: %s:%s%d: ", ename, iname, gnu_error_format ? "" : " line ", lineno);
+    fprintf (stderr, "%s: %s:%s%d: ", ename, iname, gnu_error_format ? "" : _(" line "), lineno);
   else if (STREQ (ename, iname))
-    fprintf (stderr, "%s:%s%d: ", ename, gnu_error_format ? "" : " line ", lineno);
+    fprintf (stderr, "%s:%s%d: ", ename, gnu_error_format ? "" : _(" line "), lineno);
   else
-    fprintf (stderr, "%s: %s:%s%d: ", ename, iname, gnu_error_format ? "" : " line ", lineno);
+    fprintf (stderr, "%s: %s:%s%d: ", ename, iname, gnu_error_format ? "" : _(" line "), lineno);
 
   SH_VA_START (args, format);
 
index 2cfe530eb1b5fe7f0c8ef3cebd93c1b58cca9f91..a0085d5cd090b33420e5e66c645bab707ee5fa0f 100644 (file)
@@ -96,8 +96,9 @@ extern int errno;
 #endif
 
 extern int posixly_correct;
-extern int breaking, continuing, loop_level;
 extern int expand_aliases;
+extern int autocd;
+extern int breaking, continuing, loop_level;
 extern int parse_and_execute_level, running_trap;
 extern int command_string_index, line_number;
 extern int dot_found_in_search;
@@ -907,7 +908,7 @@ extern int timeval_to_cpu __P((struct timeval *, struct timeval *, struct timeva
 #define POSIX_TIMEFORMAT "real %2R\nuser %2U\nsys %2S"
 #define BASH_TIMEFORMAT  "\nreal\t%3lR\nuser\t%3lU\nsys\t%3lS"
 
-static int precs[] = { 0, 100, 10, 1 };
+static const int precs[] = { 0, 100, 10, 1 };
 
 /* Expand one `%'-prefixed escape sequence from a time format string. */
 static int
@@ -2496,7 +2497,7 @@ execute_arith_command (arith_command)
 
 #if defined (COND_COMMAND)
 
-static char *nullstr = "";
+static char * const nullstr = "";
 
 static int
 execute_cond_node (cond)
@@ -2743,6 +2744,17 @@ fix_assignment_words (words)
       }
 }
 
+/* Return 1 if the file found by searching $PATH for PATHNAME, defaulting
+   to PATHNAME, is a directory.  Used by the autocd code below. */
+static int
+is_dirname (pathname)
+     char *pathname;
+{
+  char *temp;
+  temp = search_for_command (pathname);
+  return (temp ? file_isdir (temp) : file_isdir (pathname));
+}
+
 /* The meaty part of all the executions.  We have to start hacking the
    real execution of commands here.  Fork a process, set things up,
    execute the command. */
@@ -2792,7 +2804,7 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close)
 #endif
 
   first_word_quoted =
-    simple_command->words ? (simple_command->words->word->flags & W_QUOTED): 0;
+    simple_command->words ? (simple_command->words->word->flags & W_QUOTED) : 0;
 
   last_command_subst_pid = NO_PID;
   old_last_async_pid = last_asynchronous_pid;
@@ -2975,6 +2987,7 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close)
     }
 #endif /* JOB_CONTROL */
 
+run_builtin:
   /* Remember the name of this command globally. */
   this_command_name = words->word->word;
 
@@ -3048,6 +3061,13 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close)
        }
     }
 
+  if (autocd && interactive && words->word && is_dirname (words->word->word))
+    {
+      words = make_word_list (make_word ("cd"), words);
+      xtrace_print_word_list (words, 0);
+      goto run_builtin;
+    }
+
   if (command_line == 0)
     command_line = savestring (the_printed_command_except_trap);
 
index 586771a1bd65b48378287fdd396da7332932c32b..226b0dda3f99a3c66bd203cf7ec8378a370dcf9a 100644 (file)
@@ -1,6 +1,6 @@
 /* execute_cmd.c -- Execute a COMMAND structure. */
 
-/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2006 Free Software Foundation, Inc.
 
    This file is part of GNU Bash, the Bourne Again SHell.
 
@@ -96,8 +96,9 @@ extern int errno;
 #endif
 
 extern int posixly_correct;
-extern int breaking, continuing, loop_level;
 extern int expand_aliases;
+extern int autocd;
+extern int breaking, continuing, loop_level;
 extern int parse_and_execute_level, running_trap;
 extern int command_string_index, line_number;
 extern int dot_found_in_search;
@@ -1396,7 +1397,7 @@ execute_pipeline (command, asynchronous, pipe_in, pipe_out, fds_to_close)
       /* Make a pipeline between the two commands. */
       if (pipe (fildes) < 0)
        {
-         sys_error ("pipe error");
+         sys_error (_("pipe error"));
 #if defined (JOB_CONTROL)
          terminate_current_pipeline ();
          kill_current_pipeline ();
@@ -2743,6 +2744,17 @@ fix_assignment_words (words)
       }
 }
 
+/* Return 1 if the file found by searching $PATH for PATHNAME, defaulting
+   to PATHNAME, is a directory.  Used by the autocd code below. */
+static int
+is_dirname (pathname)
+     char *pathname;
+{
+  char *temp;
+  temp = search_for_command (pathname);
+  return (temp ? file_isdir (temp) : file_isdir (pathname));
+}
+
 /* The meaty part of all the executions.  We have to start hacking the
    real execution of commands here.  Fork a process, set things up,
    execute the command. */
@@ -2792,7 +2804,7 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close)
 #endif
 
   first_word_quoted =
-    simple_command->words ? (simple_command->words->word->flags & W_QUOTED): 0;
+    simple_command->words ? (simple_command->words->word->flags & W_QUOTED) : 0;
 
   last_command_subst_pid = NO_PID;
   old_last_async_pid = last_asynchronous_pid;
@@ -2975,6 +2987,7 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close)
     }
 #endif /* JOB_CONTROL */
 
+run_builtin:
   /* Remember the name of this command globally. */
   this_command_name = words->word->word;
 
@@ -3048,6 +3061,13 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close)
        }
     }
 
+  if (autocd && interactive && words->word && is_dirname (words->word->word))
+    {
+      words = make_word_list (make_word ("cd"), words);
+      xtrace_print_word_list (words, 0);
+      goto run_builtin;
+    }
+
   if (command_line == 0)
     command_line = savestring (the_printed_command_except_trap);
 
diff --git a/expr.c b/expr.c
index 90446759d74b093685eb0749fea8c323a5a32ad2..3ec64c010e3f1f035193ee22c18826736dd26a95 100644 (file)
--- a/expr.c
+++ b/expr.c
@@ -153,7 +153,7 @@ static void readtok __P((void));    /* lexical analyzer */
 
 static intmax_t        expr_streval __P((char *, int));
 static intmax_t        strlong __P((char *));
-static void    evalerror __P((char *));
+static void    evalerror __P((const char *));
 
 static void    pushexp __P((void));
 static void    popexp __P((void));
@@ -205,7 +205,7 @@ extern char *this_command_name;
 extern int unbound_vars_is_error;
 
 #if defined (ARRAY_VARS)
-extern char *bash_badsub_errmsg;
+extern const char * const bash_badsub_errmsg;
 #endif
 
 #define SAVETOK(X) \
@@ -1187,7 +1187,7 @@ readtok ()
 
 static void
 evalerror (msg)
-     char *msg;
+     const char *msg;
 {
   char *name, *t;
 
diff --git a/expr.c~ b/expr.c~
index 418f48d0ec8736701926a4c94320c3da9300df30..90446759d74b093685eb0749fea8c323a5a32ad2 100644 (file)
--- a/expr.c~
+++ b/expr.c~
@@ -1,6 +1,6 @@
 /* expr.c -- arithmetic expression evaluation. */
 
-/* Copyright (C) 1990-2004 Free Software Foundation, Inc.
+/* Copyright (C) 1990-2006 Free Software Foundation, Inc.
 
    This file is part of GNU Bash, the Bourne Again SHell.
 
@@ -1194,7 +1194,7 @@ evalerror (msg)
   name = this_command_name;
   for (t = expression; whitespace (*t); t++)
     ;
-  internal_error ("%s%s%s: %s (error token is \"%s\")",
+  internal_error (_("%s%s%s: %s (error token is \"%s\")"),
                   name ? name : "", name ? ": " : "", t,
                   msg, (lasttp && *lasttp) ? lasttp : "");
   longjmp (evalbuf, 1);
@@ -1321,7 +1321,7 @@ main (argc, argv)
     {
       v = evalexp (argv[i], &expok);
       if (expok == 0)
-       fprintf (stderr, "%s: expression error\n", argv[i]);
+       fprintf (stderr, _("%s: expression error\n"), argv[i]);
       else
        printf ("'%s' -> %ld\n", argv[i], v);
     }
diff --git a/flags.c b/flags.c
index 0c0868bcf6c7d264db219db953818a8837a0e581..c80aa03f3a0086fe16a68f2f6b0ca528d275250a 100644 (file)
--- a/flags.c
+++ b/flags.c
@@ -170,7 +170,7 @@ int pipefail_opt = 0;
 /*                                                                 */
 /* **************************************************************** */
 
-struct flags_alist shell_flags[] = {
+const struct flags_alist shell_flags[] = {
   /* Standard sh flags. */
   { 'a', &mark_modified_vars },
 #if defined (JOB_CONTROL)
diff --git a/flags.c~ b/flags.c~
new file mode 100644 (file)
index 0000000..0c0868b
--- /dev/null
+++ b/flags.c~
@@ -0,0 +1,355 @@
+/* flags.c -- Everything about flags except the `set' command.  That
+   is in builtins.c */
+
+/* Copyright (C) 1987,1989 Free Software Foundation, Inc.
+
+This file is part of GNU Bash, the Bourne Again SHell.
+
+Bash is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Bash is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License along
+with Bash; see the file COPYING.  If not, write to the Free Software
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+/* Flags hacking. */
+#include "config.h"
+#if defined (HAVE_UNISTD_H)
+#  include <unistd.h>
+#endif
+
+#include "shell.h"
+#include "flags.h"
+
+#if defined (BANG_HISTORY)
+#  include "bashhist.h"
+#endif
+
+#if defined (JOB_CONTROL)
+extern int set_job_control __P((int));
+#endif
+
+#if defined (RESTRICTED_SHELL)
+extern char *shell_name;
+#endif
+
+extern int shell_initialized;
+
+/* -c, -s invocation options -- not really flags, but they show up in $- */
+extern int want_pending_command, read_from_stdin;
+
+/* **************************************************************** */
+/*                                                                 */
+/*                     The Standard Sh Flags.                      */
+/*                                                                 */
+/* **************************************************************** */
+
+/* Non-zero means automatically mark variables which are modified or created
+   as auto export variables. */
+int mark_modified_vars = 0;
+
+/* Non-zero causes asynchronous job notification.  Otherwise, job state
+   notification only takes place just before a primary prompt is printed. */
+int asynchronous_notification = 0;
+
+/* Non-zero means exit immediately if a command exits with a non-zero
+   exit status. */
+int exit_immediately_on_error = 0;
+
+/* Non-zero means disable filename globbing. */
+int disallow_filename_globbing = 0;
+
+/* Non-zero means that all keyword arguments are placed into the environment
+   for a command, not just those that appear on the line before the command
+   name. */
+int place_keywords_in_env = 0;
+
+/* Non-zero means read commands, but don't execute them.  This is useful
+   for debugging shell scripts that should do something hairy and possibly
+   destructive. */
+int read_but_dont_execute = 0;
+
+/* Non-zero means end of file is after one command. */
+int just_one_command = 0;
+
+/* Non-zero means don't overwrite existing files while doing redirections. */
+int noclobber = 0;
+
+/* Non-zero means trying to get the value of $i where $i is undefined
+   causes an error, instead of a null substitution. */
+int unbound_vars_is_error = 0;
+
+/* Non-zero means type out input lines after you read them. */
+int echo_input_at_read = 0;
+
+/* Non-zero means type out the command definition after reading, but
+   before executing. */
+int echo_command_at_execute = 0;
+
+/* Non-zero means turn on the job control features. */
+int jobs_m_flag = 0;
+
+/* Non-zero means this shell is interactive, even if running under a
+   pipe. */
+int forced_interactive = 0;
+
+/* By default, follow the symbolic links as if they were real directories
+   while hacking the `cd' command.  This means that `cd ..' moves up in
+   the string of symbolic links that make up the current directory, instead
+   of the absolute directory.  The shell variable `nolinks' also controls
+   this flag. */
+int no_symbolic_links = 0;
+
+/* **************************************************************** */
+/*                                                                 */
+/*                  Non-Standard Flags Follow Here.                */
+/*                                                                 */
+/* **************************************************************** */
+
+#if 0
+/* Non-zero means do lexical scoping in the body of a FOR command. */
+int lexical_scoping = 0;
+#endif
+
+/* Non-zero means no such thing as invisible variables. */
+int no_invisible_vars = 0;
+
+/* Non-zero means look up and remember command names in a hash table, */
+int hashing_enabled = 1;
+
+#if defined (BANG_HISTORY)
+/* Non-zero means that we are doing history expansion.  The default.
+   This means !22 gets the 22nd line of history. */
+int history_expansion = 1;
+#endif /* BANG_HISTORY */
+
+/* Non-zero means that we allow comments to appear in interactive commands. */
+int interactive_comments = 1;
+
+#if defined (RESTRICTED_SHELL)
+/* Non-zero means that this shell is `restricted'.  A restricted shell
+   disallows: changing directories, command or path names containing `/',
+   unsetting or resetting the values of $PATH and $SHELL, and any type of
+   output redirection. */
+int restricted = 0;            /* currently restricted */
+int restricted_shell = 0;      /* shell was started in restricted mode. */
+#endif /* RESTRICTED_SHELL */
+
+/* Non-zero means that this shell is running in `privileged' mode.  This
+   is required if the shell is to run setuid.  If the `-p' option is
+   not supplied at startup, and the real and effective uids or gids
+   differ, disable_priv_mode is called to relinquish setuid status. */
+int privileged_mode = 0;
+
+#if defined (BRACE_EXPANSION)
+/* Zero means to disable brace expansion: foo{a,b} -> fooa foob */
+int brace_expansion = 1;
+#endif
+
+/* Non-zero means that shell functions inherit the DEBUG trap. */
+int function_trace_mode = 0;
+
+/* Non-zero means that shell functions inherit the ERR trap. */
+int error_trace_mode = 0;
+
+/* Non-zero means that the rightmost non-zero exit status in a pipeline
+   is the exit status of the entire pipeline.  If each processes exits
+   with a 0 status, the status of the pipeline is 0. */
+int pipefail_opt = 0;
+
+/* **************************************************************** */
+/*                                                                 */
+/*                     The Flags ALIST.                            */
+/*                                                                 */
+/* **************************************************************** */
+
+struct flags_alist shell_flags[] = {
+  /* Standard sh flags. */
+  { 'a', &mark_modified_vars },
+#if defined (JOB_CONTROL)
+  { 'b', &asynchronous_notification },
+#endif /* JOB_CONTROL */
+  { 'e', &exit_immediately_on_error },
+  { 'f', &disallow_filename_globbing },
+  { 'h', &hashing_enabled },
+  { 'i', &forced_interactive },
+  { 'k', &place_keywords_in_env },
+#if defined (JOB_CONTROL)
+  { 'm', &jobs_m_flag },
+#endif /* JOB_CONTROL */
+  { 'n', &read_but_dont_execute },
+  { 'p', &privileged_mode },
+#if defined (RESTRICTED_SHELL)
+  { 'r', &restricted },
+#endif /* RESTRICTED_SHELL */
+  { 't', &just_one_command },
+  { 'u', &unbound_vars_is_error },
+  { 'v', &echo_input_at_read },
+  { 'x', &echo_command_at_execute },
+
+  /* New flags that control non-standard things. */
+#if 0
+  { 'l', &lexical_scoping },
+#endif
+#if defined (BRACE_EXPANSION)
+  { 'B', &brace_expansion },
+#endif
+  { 'C', &noclobber },
+  { 'E', &error_trace_mode },
+#if defined (BANG_HISTORY)
+  { 'H', &history_expansion },
+#endif /* BANG_HISTORY */
+  { 'I', &no_invisible_vars },
+  { 'P', &no_symbolic_links },
+  { 'T', &function_trace_mode },
+  {0, (int *)NULL}
+};
+
+#define NUM_SHELL_FLAGS (sizeof (shell_flags) / sizeof (struct flags_alist))
+
+char optflags[NUM_SHELL_FLAGS+4] = { '+' };
+
+int *
+find_flag (name)
+     int name;
+{
+  int i;
+  for (i = 0; shell_flags[i].name; i++)
+    {
+      if (shell_flags[i].name == name)
+       return (shell_flags[i].value);
+    }
+  return (FLAG_UNKNOWN);
+}
+
+/* Change the state of a flag, and return it's original value, or return
+   FLAG_ERROR if there is no flag FLAG.  ON_OR_OFF must be either
+   FLAG_ON or FLAG_OFF. */
+int
+change_flag (flag, on_or_off)
+  int flag;
+  int on_or_off;
+{
+  int *value, old_value;
+
+#if defined (RESTRICTED_SHELL)
+  /* Don't allow "set +r" in a shell which is `restricted'. */
+  if (restricted && flag == 'r' && on_or_off == FLAG_OFF)
+    return (FLAG_ERROR);
+#endif /* RESTRICTED_SHELL */
+
+  value = find_flag (flag);
+
+  if ((value == (int *)FLAG_UNKNOWN) || (on_or_off != FLAG_ON && on_or_off != FLAG_OFF))
+    return (FLAG_ERROR);
+
+  old_value = *value;
+
+  *value = (on_or_off == FLAG_ON) ? 1 : 0;
+
+  /* Special cases for a few flags. */
+  switch (flag)
+    {
+#if defined (BANG_HISTORY)
+    case 'H':
+      if (on_or_off == FLAG_ON)
+       bash_initialize_history ();
+      break;
+#endif
+
+#if defined (JOB_CONTROL)
+    case 'm':
+      set_job_control (on_or_off == FLAG_ON);
+      break;
+#endif /* JOB_CONTROL */
+
+    case 'n':
+      if (interactive_shell)
+       read_but_dont_execute = 0;
+      break;
+
+    case 'p':
+      if (on_or_off == FLAG_OFF)
+       disable_priv_mode ();
+      break;
+
+#if defined (RESTRICTED_SHELL)
+    case 'r':
+      if (on_or_off == FLAG_ON && shell_initialized)
+       maybe_make_restricted (shell_name);
+      break;
+#endif
+
+    }
+
+  return (old_value);
+}
+
+/* Return a string which is the names of all the currently
+   set shell flags. */
+char *
+which_set_flags ()
+{
+  char *temp;
+  int i, string_index;
+
+  temp = (char *)xmalloc (1 + NUM_SHELL_FLAGS + read_from_stdin + want_pending_command);
+  for (i = string_index = 0; shell_flags[i].name; i++)
+    if (*(shell_flags[i].value))
+      temp[string_index++] = shell_flags[i].name;
+
+  if (want_pending_command)
+    temp[string_index++] = 'c';
+  if (read_from_stdin)
+    temp[string_index++] = 's';
+
+  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 = pipefail_opt = 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
+}
+
+void
+initialize_flags ()
+{
+  register int i;
+
+  for (i = 0; shell_flags[i].name; i++)
+    optflags[i+1] = shell_flags[i].name;
+  optflags[++i] = 'o';
+  optflags[++i] = ';';
+  optflags[i+1] = '\0';
+}
diff --git a/flags.h b/flags.h
index f16e60483ea2c4dff834a7d23ba717bf0d3527c4..9656d93982fb2b9480057563cbc123ce164a36e2 100644 (file)
--- a/flags.h
+++ b/flags.h
@@ -37,7 +37,7 @@ struct flags_alist {
   int *value;
 };
 
-extern struct flags_alist shell_flags[];
+extern const struct flags_alist shell_flags[];
 extern char optflags[];
 
 extern int
diff --git a/flags.h~ b/flags.h~
new file mode 100644 (file)
index 0000000..f16e604
--- /dev/null
+++ b/flags.h~
@@ -0,0 +1,79 @@
+/* flags.h -- a list of all the flags that the shell knows about.  You add
+   a flag to this program by adding the name here, and in flags.c. */
+
+/* Copyright (C) 1993 Free Software Foundation, Inc.
+
+   This file is part of GNU Bash, the Bourne Again SHell.
+
+   Bash is free software; you can redistribute it and/or modify it under
+   the terms of the GNU General Public License as published by the Free
+   Software Foundation; either version 2, or (at your option) any later
+   version.
+
+   Bash is distributed in the hope that it will be useful, but WITHOUT ANY
+   WARRANTY; without even the implied warranty of MERCHANTABILITY or
+   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+   for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with Bash; see the file COPYING.  If not, write to the Free Software
+   Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+#if !defined (_FLAGS_H_)
+#define _FLAGS_H_
+
+#include "stdc.h"
+
+/* Welcome to the world of Un*x, where everything is slightly backwards. */
+#define FLAG_ON '-'
+#define FLAG_OFF '+'
+
+#define FLAG_ERROR -1
+#define FLAG_UNKNOWN (int *)0
+
+/* The thing that we build the array of flags out of. */
+struct flags_alist {
+  char name;
+  int *value;
+};
+
+extern struct flags_alist shell_flags[];
+extern char optflags[];
+
+extern int
+  mark_modified_vars, exit_immediately_on_error, disallow_filename_globbing,
+  place_keywords_in_env, read_but_dont_execute,
+  just_one_command, unbound_vars_is_error, echo_input_at_read,
+  echo_command_at_execute, no_invisible_vars, noclobber,
+  hashing_enabled, forced_interactive, privileged_mode,
+  asynchronous_notification, interactive_comments, no_symbolic_links,
+  function_trace_mode, error_trace_mode, pipefail_opt;
+
+#if 0
+extern int lexical_scoping;
+#endif
+
+#if defined (BRACE_EXPANSION)
+extern int brace_expansion;
+#endif
+
+#if defined (BANG_HISTORY)
+extern int history_expansion;
+#endif /* BANG_HISTORY */
+
+#if defined (RESTRICTED_SHELL)
+extern int restricted;
+extern int restricted_shell;
+#endif /* RESTRICTED_SHELL */
+
+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));
+
+extern void initialize_flags __P((void));
+
+/* A macro for efficiency. */
+#define change_flag_char(flag, on_or_off)  change_flag (flag, on_or_off)
+
+#endif /* _FLAGS_H_ */
index 60439da91ee441b1a41b4f185a70b526de9894c0..944b482edc3a4029d7e34bcf0724158127a146f4 100644 (file)
--- a/general.c
+++ b/general.c
@@ -58,7 +58,7 @@ static int unquoted_tilde_word __P((const char *));
 static void initialize_group_array __P((void));
 
 /* A standard error message to use when getcwd() returns NULL. */
-char *bash_getcwd_errstr = N_("getcwd: cannot access parent directories");
+const char * const bash_getcwd_errstr = N_("getcwd: cannot access parent directories");
 
 /* Do whatever is necessary to initialize `Posix mode'. */
 void
index 4ac4de0419ca74f596ce6d852aa81293aa383c86..60439da91ee441b1a41b4f185a70b526de9894c0 100644 (file)
@@ -161,7 +161,7 @@ all_digits (string)
    not null. */
 int
 legal_number (string, result)
-     char *string;
+     const char *string;
      intmax_t *result;
 {
   intmax_t value;
diff --git a/jobs.h b/jobs.h
index 93a42fb2acebfe5aac15d0a31bec3639a22466f1..17f0387989a6b9901471f4602f091b5d2dc46725 100644 (file)
--- a/jobs.h
+++ b/jobs.h
@@ -74,7 +74,7 @@ typedef struct process {
 #define get_job_by_jid(ind)    (jobs[(ind)])
 
 /* A description of a pipeline's state. */
-typedef enum { JRUNNING, JSTOPPED, JDEAD, JMIXED } JOB_STATE;
+typedef enum { JRUNNING = 1, JSTOPPED = 2, JDEAD = 4, JMIXED = 8 } JOB_STATE;
 #define JOBSTATE(job)  (jobs[(job)]->state)
 #define J_JOBSTATE(j)  ((j)->state)
 
index 95108a44dc20c50fa055e4f12989865740c1f83f..6372a08f70e5c3fffc5efbc40e40eecef25d231e 100644 (file)
 
 #include "stdc.h"
 
-#define GX_MARKDIRS    0x01    /* mark directory names with trailing `/' */
-#define GX_NOCASE      0x02    /* ignore case */
-#define GX_MATCHDOT    0x04    /* match `.' literally */
+#define GX_MARKDIRS    0x001   /* mark directory names with trailing `/' */
+#define GX_NOCASE      0x002   /* ignore case */
+#define GX_MATCHDOT    0x004   /* match `.' literally */
+#define GX_ALLDIRS     0x008   /* match all directories */
+#define GX_MATCHDIRS   0x010   /* return only matching directory names */
 
 extern int glob_pattern_p __P((const char *));
 extern char **glob_vector __P((char *, char *, int));
diff --git a/lib/glob/glob.h~ b/lib/glob/glob.h~
new file mode 100644 (file)
index 0000000..95108a4
--- /dev/null
@@ -0,0 +1,35 @@
+/* File-name wildcard pattern matching for GNU.
+   Copyright (C) 1985, 1988, 1989 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.  */
+
+#ifndef        _GLOB_H_
+#define        _GLOB_H_
+
+#include "stdc.h"
+
+#define GX_MARKDIRS    0x01    /* mark directory names with trailing `/' */
+#define GX_NOCASE      0x02    /* ignore case */
+#define GX_MATCHDOT    0x04    /* match `.' literally */
+
+extern int glob_pattern_p __P((const char *));
+extern char **glob_vector __P((char *, char *, int));
+extern char **glob_filename __P((char *, int));
+
+extern char *glob_error_return;
+extern int noglob_dot_filenames;
+extern int glob_ignore_case;
+
+#endif /* _GLOB_H_ */
index 7953d55973c9ccf08963de5c2a3105e9cc15187d..75d911fdea6b53e40fe89ac5fdd912daac6973e5 100644 (file)
@@ -231,7 +231,7 @@ static int maxbuck; /* highest bucket receiving allocation request. */
 
 static char *memtop;   /* top of heap */
 
-static unsigned long binsizes[NBUCKETS] = {
+static const unsigned long binsizes[NBUCKETS] = {
        8UL, 16UL, 32UL, 64UL, 128UL, 256UL, 512UL, 1024UL, 2048UL, 4096UL,
        8192UL, 16384UL, 32768UL, 65536UL, 131072UL, 262144UL, 524288UL,
        1048576UL, 2097152UL, 4194304UL, 8388608UL, 16777216UL, 33554432UL,
index f9a08da113d6cd0d181b2c0b73bacc8e9ac1d84c..7953d55973c9ccf08963de5c2a3105e9cc15187d 100644 (file)
@@ -312,7 +312,7 @@ xbotch (mem, e, s, file, line)
      int line;
 {
   fprintf (stderr, _("\r\nmalloc: %s:%d: assertion botched\r\n"),
-                       file ? file : "unknown", line);
+                       file ? file : _("unknown"), line);
 #ifdef MALLOC_REGISTER
   if (mem != NULL && malloc_register)
     mregister_describe_mem (mem, stderr);
index b4b1e8799937fcc9f345618b41f45167450a5f21..ecec8b1b24c846559751d3548465d1dc0eafe4e5 100644 (file)
@@ -80,7 +80,7 @@ static int glean_key_from_name PARAMS((char *));
 static int find_boolean_var PARAMS((const char *));
 
 static char *_rl_get_string_variable_value PARAMS((const char *));
-static int substring_member_of_array PARAMS((char *, const char **));
+static int substring_member_of_array PARAMS((const char *, const char * const *));
 
 static int currently_reading_init_file;
 
@@ -936,11 +936,11 @@ _rl_init_file_error (msg)
 typedef int _rl_parser_func_t PARAMS((char *));
 
 /* Things that mean `Control'. */
-const char *_rl_possible_control_prefixes[] = {
+const char * const _rl_possible_control_prefixes[] = {
   "Control-", "C-", "CTRL-", (const char *)NULL
 };
 
-const char *_rl_possible_meta_prefixes[] = {
+const char * const _rl_possible_meta_prefixes[] = {
   "Meta", "M-", (const char *)NULL
 };
 
@@ -1099,8 +1099,8 @@ parser_include (args)
 }
   
 /* Associate textual names with actual functions. */
-static struct {
-  const char *name;
+static const struct {
+  const char * const name;
   _rl_parser_func_t *function;
 } parser_directives [] = {
   { "if", parser_if },
@@ -1406,8 +1406,8 @@ rl_parse_and_bind (string)
 
 #define V_SPECIAL      0x1
 
-static struct {
-  const char *name;
+static const struct {
+  const char * const name;
   int *value;
   int flags;
 } boolean_varlist [] = {
@@ -1494,8 +1494,8 @@ static int sv_editmode PARAMS((const char *));
 static int sv_isrchterm PARAMS((const char *));
 static int sv_keymap PARAMS((const char *));
 
-static struct {
-  const char *name;
+static const struct {
+  const char * const name;
   int flags;
   _rl_sv_func_t *set_func;
 } string_varlist[] = {
@@ -1701,11 +1701,11 @@ sv_isrchterm (value)
    For example, `Space' returns ' '. */
 
 typedef struct {
-  const char *name;
+  const char * const name;
   int value;
 } assoc_list;
 
-static assoc_list name_key_alist[] = {
+static const assoc_list name_key_alist[] = {
   { "DEL", 0x7f },
   { "ESC", '\033' },
   { "Escape", '\033' },
@@ -1734,8 +1734,8 @@ glean_key_from_name (name)
 }
 
 /* Auxiliary functions to manage keymaps. */
-static struct {
-  const char *name;
+static const struct {
+  const char * const name;
   Keymap map;
 } keymap_names[] = {
   { "emacs", emacs_standard_keymap },
@@ -2298,8 +2298,8 @@ rl_dump_variables (count, key)
 /* Return non-zero if any members of ARRAY are a substring in STRING. */
 static int
 substring_member_of_array (string, array)
-     char *string;
-     const char **array;
+     const char *string;
+     const char * const *array;
 {
   while (*array)
     {
diff --git a/lib/readline/bind.c~ b/lib/readline/bind.c~
new file mode 100644 (file)
index 0000000..4247f3e
--- /dev/null
@@ -0,0 +1,2311 @@
+/* bind.c -- key binding and startup file support for the readline library. */
+
+/* Copyright (C) 1987-2006 Free Software Foundation, Inc.
+
+   This file is part of the GNU Readline Library, a library for
+   reading lines of text with interactive input and history editing.
+
+   The GNU Readline Library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU General Public License
+   as published by the Free Software Foundation; either version 2, or
+   (at your option) any later version.
+
+   The GNU Readline Library 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.
+
+   The GNU General Public License is often shipped with GNU software, and
+   is generally kept in a file called COPYING or LICENSE.  If you do not
+   have a copy of the license, write to the Free Software Foundation,
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+#define READLINE_LIBRARY
+
+#if defined (__TANDEM)
+#  include <floss.h>
+#endif
+
+#if defined (HAVE_CONFIG_H)
+#  include <config.h>
+#endif
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#if defined (HAVE_SYS_FILE_H)
+#  include <sys/file.h>
+#endif /* HAVE_SYS_FILE_H */
+
+#if defined (HAVE_UNISTD_H)
+#  include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+
+#if defined (HAVE_STDLIB_H)
+#  include <stdlib.h>
+#else
+#  include "ansi_stdlib.h"
+#endif /* HAVE_STDLIB_H */
+
+#include <errno.h>
+
+#if !defined (errno)
+extern int errno;
+#endif /* !errno */
+
+#include "posixstat.h"
+
+/* System-specific feature definitions and include files. */
+#include "rldefs.h"
+
+/* Some standard library routines. */
+#include "readline.h"
+#include "history.h"
+
+#include "rlprivate.h"
+#include "rlshell.h"
+#include "xmalloc.h"
+
+#if !defined (strchr) && !defined (__STDC__)
+extern char *strchr (), *strrchr ();
+#endif /* !strchr && !__STDC__ */
+
+/* Variables exported by this file. */
+Keymap rl_binding_keymap;
+
+static char *_rl_read_file PARAMS((char *, size_t *));
+static void _rl_init_file_error PARAMS((const char *));
+static int _rl_read_init_file PARAMS((const char *, int));
+static int glean_key_from_name PARAMS((char *));
+static int find_boolean_var PARAMS((const char *));
+
+static char *_rl_get_string_variable_value PARAMS((const char *));
+static int substring_member_of_array PARAMS((const char *, const char **));
+
+static int currently_reading_init_file;
+
+/* used only in this file */
+static int _rl_prefer_visible_bell = 1;
+
+/* **************************************************************** */
+/*                                                                 */
+/*                     Binding keys                                */
+/*                                                                 */
+/* **************************************************************** */
+
+/* rl_add_defun (char *name, rl_command_func_t *function, int key)
+   Add NAME to the list of named functions.  Make FUNCTION be the function
+   that gets called.  If KEY is not -1, then bind it. */
+int
+rl_add_defun (name, function, key)
+     const char *name;
+     rl_command_func_t *function;
+     int key;
+{
+  if (key != -1)
+    rl_bind_key (key, function);
+  rl_add_funmap_entry (name, function);
+  return 0;
+}
+
+/* Bind KEY to FUNCTION.  Returns non-zero if KEY is out of range. */
+int
+rl_bind_key (key, function)
+     int key;
+     rl_command_func_t *function;
+{
+  if (key < 0)
+    return (key);
+
+  if (META_CHAR (key) && _rl_convert_meta_chars_to_ascii)
+    {
+      if (_rl_keymap[ESC].type == ISKMAP)
+       {
+         Keymap escmap;
+
+         escmap = FUNCTION_TO_KEYMAP (_rl_keymap, ESC);
+         key = UNMETA (key);
+         escmap[key].type = ISFUNC;
+         escmap[key].function = function;
+         return (0);
+       }
+      return (key);
+    }
+
+  _rl_keymap[key].type = ISFUNC;
+  _rl_keymap[key].function = function;
+  rl_binding_keymap = _rl_keymap;
+  return (0);
+}
+
+/* Bind KEY to FUNCTION in MAP.  Returns non-zero in case of invalid
+   KEY. */
+int
+rl_bind_key_in_map (key, function, map)
+     int key;
+     rl_command_func_t *function;
+     Keymap map;
+{
+  int result;
+  Keymap oldmap;
+
+  oldmap = _rl_keymap;
+  _rl_keymap = map;
+  result = rl_bind_key (key, function);
+  _rl_keymap = oldmap;
+  return (result);
+}
+
+/* Bind key sequence KEYSEQ to DEFAULT_FUNC if KEYSEQ is unbound.  Right
+   now, this is always used to attempt to bind the arrow keys, hence the
+   check for rl_vi_movement_mode. */
+int
+rl_bind_key_if_unbound_in_map (key, default_func, kmap)
+     int key;
+     rl_command_func_t *default_func;
+     Keymap kmap;
+{
+  char keyseq[2];
+
+  keyseq[0] = (unsigned char)key;
+  keyseq[1] = '\0';
+  return (rl_bind_keyseq_if_unbound_in_map (keyseq, default_func, kmap));
+}
+
+int
+rl_bind_key_if_unbound (key, default_func)
+     int key;
+     rl_command_func_t *default_func;
+{
+  char keyseq[2];
+
+  keyseq[0] = (unsigned char)key;
+  keyseq[1] = '\0';
+  return (rl_bind_keyseq_if_unbound_in_map (keyseq, default_func, _rl_keymap));
+}
+
+/* Make KEY do nothing in the currently selected keymap.
+   Returns non-zero in case of error. */
+int
+rl_unbind_key (key)
+     int key;
+{
+  return (rl_bind_key (key, (rl_command_func_t *)NULL));
+}
+
+/* Make KEY do nothing in MAP.
+   Returns non-zero in case of error. */
+int
+rl_unbind_key_in_map (key, map)
+     int key;
+     Keymap map;
+{
+  return (rl_bind_key_in_map (key, (rl_command_func_t *)NULL, map));
+}
+
+/* Unbind all keys bound to FUNCTION in MAP. */
+int
+rl_unbind_function_in_map (func, map)
+     rl_command_func_t *func;
+     Keymap map;
+{
+  register int i, rval;
+
+  for (i = rval = 0; i < KEYMAP_SIZE; i++)
+    {
+      if (map[i].type == ISFUNC && map[i].function == func)
+       {
+         map[i].function = (rl_command_func_t *)NULL;
+         rval = 1;
+       }
+    }
+  return rval;
+}
+
+int
+rl_unbind_command_in_map (command, map)
+     const char *command;
+     Keymap map;
+{
+  rl_command_func_t *func;
+
+  func = rl_named_function (command);
+  if (func == 0)
+    return 0;
+  return (rl_unbind_function_in_map (func, map));
+}
+
+/* Bind the key sequence represented by the string KEYSEQ to
+   FUNCTION, starting in the current keymap.  This makes new
+   keymaps as necessary. */
+int
+rl_bind_keyseq (keyseq, function)
+     const char *keyseq;
+     rl_command_func_t *function;
+{
+  return (rl_generic_bind (ISFUNC, keyseq, (char *)function, _rl_keymap));
+}
+
+/* Bind the key sequence represented by the string KEYSEQ to
+   FUNCTION.  This makes new keymaps as necessary.  The initial
+   place to do bindings is in MAP. */
+int
+rl_bind_keyseq_in_map (keyseq, function, map)
+     const char *keyseq;
+     rl_command_func_t *function;
+     Keymap map;
+{
+  return (rl_generic_bind (ISFUNC, keyseq, (char *)function, map));
+}
+
+/* Backwards compatibility; equivalent to rl_bind_keyseq_in_map() */
+int
+rl_set_key (keyseq, function, map)
+     const char *keyseq;
+     rl_command_func_t *function;
+     Keymap map;
+{
+  return (rl_generic_bind (ISFUNC, keyseq, (char *)function, map));
+}
+
+/* Bind key sequence KEYSEQ to DEFAULT_FUNC if KEYSEQ is unbound.  Right
+   now, this is always used to attempt to bind the arrow keys, hence the
+   check for rl_vi_movement_mode. */
+int
+rl_bind_keyseq_if_unbound_in_map (keyseq, default_func, kmap)
+     const char *keyseq;
+     rl_command_func_t *default_func;
+     Keymap kmap;
+{
+  rl_command_func_t *func;
+
+  if (keyseq)
+    {
+      func = rl_function_of_keyseq (keyseq, kmap, (int *)NULL);
+#if defined (VI_MODE)
+      if (!func || func == rl_do_lowercase_version || func == rl_vi_movement_mode)
+#else
+      if (!func || func == rl_do_lowercase_version)
+#endif
+       return (rl_bind_keyseq_in_map (keyseq, default_func, kmap));
+      else
+       return 1;
+    }
+  return 0;
+}
+
+int
+rl_bind_keyseq_if_unbound (keyseq, default_func)
+     const char *keyseq;
+     rl_command_func_t *default_func;
+{
+  return (rl_bind_keyseq_if_unbound_in_map (keyseq, default_func, _rl_keymap));
+}
+
+/* Bind the key sequence represented by the string KEYSEQ to
+   the string of characters MACRO.  This makes new keymaps as
+   necessary.  The initial place to do bindings is in MAP. */
+int
+rl_macro_bind (keyseq, macro, map)
+     const char *keyseq, *macro;
+     Keymap map;
+{
+  char *macro_keys;
+  int macro_keys_len;
+
+  macro_keys = (char *)xmalloc ((2 * strlen (macro)) + 1);
+
+  if (rl_translate_keyseq (macro, macro_keys, &macro_keys_len))
+    {
+      free (macro_keys);
+      return -1;
+    }
+  rl_generic_bind (ISMACR, keyseq, macro_keys, map);
+  return 0;
+}
+
+/* Bind the key sequence represented by the string KEYSEQ to
+   the arbitrary pointer DATA.  TYPE says what kind of data is
+   pointed to by DATA, right now this can be a function (ISFUNC),
+   a macro (ISMACR), or a keymap (ISKMAP).  This makes new keymaps
+   as necessary.  The initial place to do bindings is in MAP. */
+int
+rl_generic_bind (type, keyseq, data, map)
+     int type;
+     const char *keyseq;
+     char *data;
+     Keymap map;
+{
+  char *keys;
+  int keys_len;
+  register int i;
+  KEYMAP_ENTRY k;
+
+  k.function = 0;
+
+  /* If no keys to bind to, exit right away. */
+  if (keyseq == 0 || *keyseq == 0)
+    {
+      if (type == ISMACR)
+       free (data);
+      return -1;
+    }
+
+  keys = (char *)xmalloc (1 + (2 * strlen (keyseq)));
+
+  /* Translate the ASCII representation of KEYSEQ into an array of
+     characters.  Stuff the characters into KEYS, and the length of
+     KEYS into KEYS_LEN. */
+  if (rl_translate_keyseq (keyseq, keys, &keys_len))
+    {
+      free (keys);
+      return -1;
+    }
+
+  /* Bind keys, making new keymaps as necessary. */
+  for (i = 0; i < keys_len; i++)
+    {
+      unsigned char uc = keys[i];
+      int ic;
+
+      ic = uc;
+      if (ic < 0 || ic >= KEYMAP_SIZE)
+        {
+          free (keys);
+         return -1;
+        }
+
+      if (META_CHAR (ic) && _rl_convert_meta_chars_to_ascii)
+       {
+         ic = UNMETA (ic);
+         if (map[ESC].type == ISKMAP)
+           map = FUNCTION_TO_KEYMAP (map, ESC);
+       }
+
+      if ((i + 1) < keys_len)
+       {
+         if (map[ic].type != ISKMAP)
+           {
+             /* We allow subsequences of keys.  If a keymap is being
+                created that will `shadow' an existing function or macro
+                key binding, we save that keybinding into the ANYOTHERKEY
+                index in the new map.  The dispatch code will look there
+                to find the function to execute if the subsequence is not
+                matched.  ANYOTHERKEY was chosen to be greater than
+                UCHAR_MAX. */
+             k = map[ic];
+
+             map[ic].type = ISKMAP;
+             map[ic].function = KEYMAP_TO_FUNCTION (rl_make_bare_keymap());
+           }
+         map = FUNCTION_TO_KEYMAP (map, ic);
+         /* The dispatch code will return this function if no matching
+            key sequence is found in the keymap.  This (with a little
+            help from the dispatch code in readline.c) allows `a' to be
+            mapped to something, `abc' to be mapped to something else,
+            and the function bound  to `a' to be executed when the user
+            types `abx', leaving `bx' in the input queue. */
+         if (k.function && ((k.type == ISFUNC && k.function != rl_do_lowercase_version) || k.type == ISMACR))
+           {
+             map[ANYOTHERKEY] = k;
+             k.function = 0;
+           }
+       }
+      else
+       {
+         if (map[ic].type == ISMACR)
+           free ((char *)map[ic].function);
+         else if (map[ic].type == ISKMAP)
+           {
+             map = FUNCTION_TO_KEYMAP (map, ic);
+             ic = ANYOTHERKEY;
+           }
+
+         map[ic].function = KEYMAP_TO_FUNCTION (data);
+         map[ic].type = type;
+       }
+
+      rl_binding_keymap = map;
+    }
+  free (keys);
+  return 0;
+}
+
+/* Translate the ASCII representation of SEQ, stuffing the values into ARRAY,
+   an array of characters.  LEN gets the final length of ARRAY.  Return
+   non-zero if there was an error parsing SEQ. */
+int
+rl_translate_keyseq (seq, array, len)
+     const char *seq;
+     char *array;
+     int *len;
+{
+  register int i, c, l, temp;
+
+  for (i = l = 0; c = seq[i]; i++)
+    {
+      if (c == '\\')
+       {
+         c = seq[++i];
+
+         if (c == 0)
+           break;
+
+         /* Handle \C- and \M- prefixes. */
+         if ((c == 'C' || c == 'M') && seq[i + 1] == '-')
+           {
+             /* Handle special case of backwards define. */
+             if (strncmp (&seq[i], "C-\\M-", 5) == 0)
+               {
+                 array[l++] = ESC;     /* ESC is meta-prefix */
+                 i += 5;
+                 array[l++] = CTRL (_rl_to_upper (seq[i]));
+                 if (seq[i] == '\0')
+                   i--;
+               }
+             else if (c == 'M')
+               {
+                 i++;          /* seq[i] == '-' */
+                 /* XXX - obey convert-meta setting */
+                 if (_rl_convert_meta_chars_to_ascii && _rl_keymap[ESC].type == ISKMAP)
+                   array[l++] = ESC;   /* ESC is meta-prefix */
+                 else if (seq[i+1] == '\\' && seq[i+2] == 'C' && seq[i+3] == '-')
+                   {
+                     i += 4;
+                     temp = (seq[i] == '?') ? RUBOUT : CTRL (_rl_to_upper (seq[i]));
+                     array[l++] = META (temp);
+                   }
+                 else
+                   {
+                     /* This doesn't yet handle things like \M-\a, which may
+                        or may not have any reasonable meaning.  You're
+                        probably better off using straight octal or hex. */
+                     i++;
+                     array[l++] = META (seq[i]);
+                   }
+               }
+             else if (c == 'C')
+               {
+                 i += 2;
+                 /* Special hack for C-?... */
+                 array[l++] = (seq[i] == '?') ? RUBOUT : CTRL (_rl_to_upper (seq[i]));
+               }
+             continue;
+           }         
+
+         /* Translate other backslash-escaped characters.  These are the
+            same escape sequences that bash's `echo' and `printf' builtins
+            handle, with the addition of \d -> RUBOUT.  A backslash
+            preceding a character that is not special is stripped. */
+         switch (c)
+           {
+           case 'a':
+             array[l++] = '\007';
+             break;
+           case 'b':
+             array[l++] = '\b';
+             break;
+           case 'd':
+             array[l++] = RUBOUT;      /* readline-specific */
+             break;
+           case 'e':
+             array[l++] = ESC;
+             break;
+           case 'f':
+             array[l++] = '\f';
+             break;
+           case 'n':
+             array[l++] = NEWLINE;
+             break;
+           case 'r':
+             array[l++] = RETURN;
+             break;
+           case 't':
+             array[l++] = TAB;
+             break;
+           case 'v':
+             array[l++] = 0x0B;
+             break;
+           case '\\':
+             array[l++] = '\\';
+             break;
+           case '0': case '1': case '2': case '3':
+           case '4': case '5': case '6': case '7':
+             i++;
+             for (temp = 2, c -= '0'; ISOCTAL (seq[i]) && temp--; i++)
+               c = (c * 8) + OCTVALUE (seq[i]);
+             i--;      /* auto-increment in for loop */
+             array[l++] = c & largest_char;
+             break;
+           case 'x':
+             i++;
+             for (temp = 2, c = 0; ISXDIGIT ((unsigned char)seq[i]) && temp--; i++)
+               c = (c * 16) + HEXVALUE (seq[i]);
+             if (temp == 2)
+               c = 'x';
+             i--;      /* auto-increment in for loop */
+             array[l++] = c & largest_char;
+             break;
+           default:    /* backslashes before non-special chars just add the char */
+             array[l++] = c;
+             break;    /* the backslash is stripped */
+           }
+         continue;
+       }
+
+      array[l++] = c;
+    }
+
+  *len = l;
+  array[l] = '\0';
+  return (0);
+}
+
+char *
+rl_untranslate_keyseq (seq)
+     int seq;
+{
+  static char kseq[16];
+  int i, c;
+
+  i = 0;
+  c = seq;
+  if (META_CHAR (c))
+    {
+      kseq[i++] = '\\';
+      kseq[i++] = 'M';
+      kseq[i++] = '-';
+      c = UNMETA (c);
+    }
+  else if (c == ESC)
+    {
+      kseq[i++] = '\\';
+      c = 'e';
+    }
+  else if (CTRL_CHAR (c))
+    {
+      kseq[i++] = '\\';
+      kseq[i++] = 'C';
+      kseq[i++] = '-';
+      c = _rl_to_lower (UNCTRL (c));
+    }
+  else if (c == RUBOUT)
+    {
+      kseq[i++] = '\\';
+      kseq[i++] = 'C';
+      kseq[i++] = '-';
+      c = '?';
+    }
+
+  if (c == ESC)
+    {
+      kseq[i++] = '\\';
+      c = 'e';
+    }
+  else if (c == '\\' || c == '"')
+    {
+      kseq[i++] = '\\';
+    }
+
+  kseq[i++] = (unsigned char) c;
+  kseq[i] = '\0';
+  return kseq;
+}
+
+static char *
+_rl_untranslate_macro_value (seq)
+     char *seq;
+{
+  char *ret, *r, *s;
+  int c;
+
+  r = ret = (char *)xmalloc (7 * strlen (seq) + 1);
+  for (s = seq; *s; s++)
+    {
+      c = *s;
+      if (META_CHAR (c))
+       {
+         *r++ = '\\';
+         *r++ = 'M';
+         *r++ = '-';
+         c = UNMETA (c);
+       }
+      else if (c == ESC)
+       {
+         *r++ = '\\';
+         c = 'e';
+       }
+      else if (CTRL_CHAR (c))
+       {
+         *r++ = '\\';
+         *r++ = 'C';
+         *r++ = '-';
+         c = _rl_to_lower (UNCTRL (c));
+       }
+      else if (c == RUBOUT)
+       {
+         *r++ = '\\';
+         *r++ = 'C';
+         *r++ = '-';
+         c = '?';
+       }
+
+      if (c == ESC)
+       {
+         *r++ = '\\';
+         c = 'e';
+       }
+      else if (c == '\\' || c == '"')
+       *r++ = '\\';
+
+      *r++ = (unsigned char)c;
+    }
+  *r = '\0';
+  return ret;
+}
+
+/* Return a pointer to the function that STRING represents.
+   If STRING doesn't have a matching function, then a NULL pointer
+   is returned. */
+rl_command_func_t *
+rl_named_function (string)
+     const char *string;
+{
+  register int i;
+
+  rl_initialize_funmap ();
+
+  for (i = 0; funmap[i]; i++)
+    if (_rl_stricmp (funmap[i]->name, string) == 0)
+      return (funmap[i]->function);
+  return ((rl_command_func_t *)NULL);
+}
+
+/* Return the function (or macro) definition which would be invoked via
+   KEYSEQ if executed in MAP.  If MAP is NULL, then the current keymap is
+   used.  TYPE, if non-NULL, is a pointer to an int which will receive the
+   type of the object pointed to.  One of ISFUNC (function), ISKMAP (keymap),
+   or ISMACR (macro). */
+rl_command_func_t *
+rl_function_of_keyseq (keyseq, map, type)
+     const char *keyseq;
+     Keymap map;
+     int *type;
+{
+  register int i;
+
+  if (map == 0)
+    map = _rl_keymap;
+
+  for (i = 0; keyseq && keyseq[i]; i++)
+    {
+      unsigned char ic = keyseq[i];
+
+      if (META_CHAR (ic) && _rl_convert_meta_chars_to_ascii)
+       {
+         if (map[ESC].type == ISKMAP)
+           {
+             map = FUNCTION_TO_KEYMAP (map, ESC);
+             ic = UNMETA (ic);
+           }
+         /* XXX - should we just return NULL here, since this obviously
+            doesn't match? */
+         else
+           {
+             if (type)
+               *type = map[ESC].type;
+
+             return (map[ESC].function);
+           }
+       }
+
+      if (map[ic].type == ISKMAP)
+       {
+         /* If this is the last key in the key sequence, return the
+            map. */
+         if (keyseq[i + 1] == '\0')
+           {
+             if (type)
+               *type = ISKMAP;
+
+             return (map[ic].function);
+           }
+         else
+           map = FUNCTION_TO_KEYMAP (map, ic);
+       }
+      /* If we're not at the end of the key sequence, and the current key
+        is bound to something other than a keymap, then the entire key
+        sequence is not bound. */
+      else if (map[ic].type != ISKMAP && keyseq[i+1])
+       return ((rl_command_func_t *)NULL);
+      else     /* map[ic].type != ISKMAP && keyseq[i+1] == 0 */
+       {
+         if (type)
+           *type = map[ic].type;
+
+         return (map[ic].function);
+       }
+    }
+  return ((rl_command_func_t *) NULL);
+}
+
+/* The last key bindings file read. */
+static char *last_readline_init_file = (char *)NULL;
+
+/* The file we're currently reading key bindings from. */
+static const char *current_readline_init_file;
+static int current_readline_init_include_level;
+static int current_readline_init_lineno;
+
+/* Read FILENAME into a locally-allocated buffer and return the buffer.
+   The size of the buffer is returned in *SIZEP.  Returns NULL if any
+   errors were encountered. */
+static char *
+_rl_read_file (filename, sizep)
+     char *filename;
+     size_t *sizep;
+{
+  struct stat finfo;
+  size_t file_size;
+  char *buffer;
+  int i, file;
+
+  if ((stat (filename, &finfo) < 0) || (file = open (filename, O_RDONLY, 0666)) < 0)
+    return ((char *)NULL);
+
+  file_size = (size_t)finfo.st_size;
+
+  /* check for overflow on very large files */
+  if (file_size != finfo.st_size || file_size + 1 < file_size)
+    {
+      if (file >= 0)
+       close (file);
+#if defined (EFBIG)
+      errno = EFBIG;
+#endif
+      return ((char *)NULL);
+    }
+
+  /* Read the file into BUFFER. */
+  buffer = (char *)xmalloc (file_size + 1);
+  i = read (file, buffer, file_size);
+  close (file);
+
+  if (i < 0)
+    {
+      free (buffer);
+      return ((char *)NULL);
+    }
+
+  buffer[i] = '\0';
+  if (sizep)
+    *sizep = i;
+
+  return (buffer);
+}
+
+/* Re-read the current keybindings file. */
+int
+rl_re_read_init_file (count, ignore)
+     int count, ignore;
+{
+  int r;
+  r = rl_read_init_file ((const char *)NULL);
+  rl_set_keymap_from_edit_mode ();
+  return r;
+}
+
+/* Do key bindings from a file.  If FILENAME is NULL it defaults
+   to the first non-null filename from this list:
+     1. the filename used for the previous call
+     2. the value of the shell variable `INPUTRC'
+     3. ~/.inputrc
+     4. /etc/inputrc
+   If the file existed and could be opened and read, 0 is returned,
+   otherwise errno is returned. */
+int
+rl_read_init_file (filename)
+     const char *filename;
+{
+  /* Default the filename. */
+  if (filename == 0)
+    filename = last_readline_init_file;
+  if (filename == 0)
+    filename = sh_get_env_value ("INPUTRC");
+  if (filename == 0 || *filename == 0)
+    {
+      filename = DEFAULT_INPUTRC;
+      /* Try to read DEFAULT_INPUTRC; fall back to SYS_INPUTRC on failure */
+      if (_rl_read_init_file (filename, 0) == 0)
+       return 0;
+      filename = SYS_INPUTRC;
+    }
+
+#if defined (__MSDOS__)
+  if (_rl_read_init_file (filename, 0) == 0)
+    return 0;
+  filename = "~/_inputrc";
+#endif
+  return (_rl_read_init_file (filename, 0));
+}
+
+static int
+_rl_read_init_file (filename, include_level)
+     const char *filename;
+     int include_level;
+{
+  register int i;
+  char *buffer, *openname, *line, *end;
+  size_t file_size;
+
+  current_readline_init_file = filename;
+  current_readline_init_include_level = include_level;
+
+  openname = tilde_expand (filename);
+  buffer = _rl_read_file (openname, &file_size);
+  free (openname);
+
+  if (buffer == 0)
+    return (errno);
+  
+  if (include_level == 0 && filename != last_readline_init_file)
+    {
+      FREE (last_readline_init_file);
+      last_readline_init_file = savestring (filename);
+    }
+
+  currently_reading_init_file = 1;
+
+  /* Loop over the lines in the file.  Lines that start with `#' are
+     comments; all other lines are commands for readline initialization. */
+  current_readline_init_lineno = 1;
+  line = buffer;
+  end = buffer + file_size;
+  while (line < end)
+    {
+      /* Find the end of this line. */
+      for (i = 0; line + i != end && line[i] != '\n'; i++);
+
+#if defined (__CYGWIN__)
+      /* ``Be liberal in what you accept.'' */
+      if (line[i] == '\n' && line[i-1] == '\r')
+       line[i - 1] = '\0';
+#endif
+
+      /* Mark end of line. */
+      line[i] = '\0';
+
+      /* Skip leading whitespace. */
+      while (*line && whitespace (*line))
+        {
+         line++;
+         i--;
+        }
+
+      /* If the line is not a comment, then parse it. */
+      if (*line && *line != '#')
+       rl_parse_and_bind (line);
+
+      /* Move to the next line. */
+      line += i + 1;
+      current_readline_init_lineno++;
+    }
+
+  free (buffer);
+  currently_reading_init_file = 0;
+  return (0);
+}
+
+static void
+_rl_init_file_error (msg)
+     const char *msg;
+{
+  if (currently_reading_init_file)
+    _rl_errmsg ("%s: line %d: %s\n", current_readline_init_file,
+                    current_readline_init_lineno, msg);
+  else
+    _rl_errmsg ("%s", msg);
+}
+
+/* **************************************************************** */
+/*                                                                 */
+/*                     Parser Directives                           */
+/*                                                                 */
+/* **************************************************************** */
+
+typedef int _rl_parser_func_t PARAMS((char *));
+
+/* Things that mean `Control'. */
+const char * const _rl_possible_control_prefixes[] = {
+  "Control-", "C-", "CTRL-", (const char *)NULL
+};
+
+const char * const _rl_possible_meta_prefixes[] = {
+  "Meta", "M-", (const char *)NULL
+};
+
+/* Conditionals. */
+
+/* Calling programs set this to have their argv[0]. */
+const char *rl_readline_name = "other";
+
+/* Stack of previous values of parsing_conditionalized_out. */
+static unsigned char *if_stack = (unsigned char *)NULL;
+static int if_stack_depth;
+static int if_stack_size;
+
+/* Push _rl_parsing_conditionalized_out, and set parser state based
+   on ARGS. */
+static int
+parser_if (args)
+     char *args;
+{
+  register int i;
+
+  /* Push parser state. */
+  if (if_stack_depth + 1 >= if_stack_size)
+    {
+      if (!if_stack)
+       if_stack = (unsigned char *)xmalloc (if_stack_size = 20);
+      else
+       if_stack = (unsigned char *)xrealloc (if_stack, if_stack_size += 20);
+    }
+  if_stack[if_stack_depth++] = _rl_parsing_conditionalized_out;
+
+  /* If parsing is turned off, then nothing can turn it back on except
+     for finding the matching endif.  In that case, return right now. */
+  if (_rl_parsing_conditionalized_out)
+    return 0;
+
+  /* Isolate first argument. */
+  for (i = 0; args[i] && !whitespace (args[i]); i++);
+
+  if (args[i])
+    args[i++] = '\0';
+
+  /* Handle "$if term=foo" and "$if mode=emacs" constructs.  If this
+     isn't term=foo, or mode=emacs, then check to see if the first
+     word in ARGS is the same as the value stored in rl_readline_name. */
+  if (rl_terminal_name && _rl_strnicmp (args, "term=", 5) == 0)
+    {
+      char *tem, *tname;
+
+      /* Terminals like "aaa-60" are equivalent to "aaa". */
+      tname = savestring (rl_terminal_name);
+      tem = strchr (tname, '-');
+      if (tem)
+       *tem = '\0';
+
+      /* Test the `long' and `short' forms of the terminal name so that
+        if someone has a `sun-cmd' and does not want to have bindings
+        that will be executed if the terminal is a `sun', they can put
+        `$if term=sun-cmd' into their .inputrc. */
+      _rl_parsing_conditionalized_out = _rl_stricmp (args + 5, tname) &&
+                                       _rl_stricmp (args + 5, rl_terminal_name);
+      free (tname);
+    }
+#if defined (VI_MODE)
+  else if (_rl_strnicmp (args, "mode=", 5) == 0)
+    {
+      int mode;
+
+      if (_rl_stricmp (args + 5, "emacs") == 0)
+       mode = emacs_mode;
+      else if (_rl_stricmp (args + 5, "vi") == 0)
+       mode = vi_mode;
+      else
+       mode = no_mode;
+
+      _rl_parsing_conditionalized_out = mode != rl_editing_mode;
+    }
+#endif /* VI_MODE */
+  /* Check to see if the first word in ARGS is the same as the
+     value stored in rl_readline_name. */
+  else if (_rl_stricmp (args, rl_readline_name) == 0)
+    _rl_parsing_conditionalized_out = 0;
+  else
+    _rl_parsing_conditionalized_out = 1;
+  return 0;
+}
+
+/* Invert the current parser state if there is anything on the stack. */
+static int
+parser_else (args)
+     char *args;
+{
+  register int i;
+
+  if (if_stack_depth == 0)
+    {
+      _rl_init_file_error ("$else found without matching $if");
+      return 0;
+    }
+
+#if 0
+  /* Check the previous (n - 1) levels of the stack to make sure that
+     we haven't previously turned off parsing. */
+  for (i = 0; i < if_stack_depth - 1; i++)
+#else
+  /* Check the previous (n) levels of the stack to make sure that
+     we haven't previously turned off parsing. */
+  for (i = 0; i < if_stack_depth; i++)
+#endif
+    if (if_stack[i] == 1)
+      return 0;
+
+  /* Invert the state of parsing if at top level. */
+  _rl_parsing_conditionalized_out = !_rl_parsing_conditionalized_out;
+  return 0;
+}
+
+/* Terminate a conditional, popping the value of
+   _rl_parsing_conditionalized_out from the stack. */
+static int
+parser_endif (args)
+     char *args;
+{
+  if (if_stack_depth)
+    _rl_parsing_conditionalized_out = if_stack[--if_stack_depth];
+  else
+    _rl_init_file_error ("$endif without matching $if");
+  return 0;
+}
+
+static int
+parser_include (args)
+     char *args;
+{
+  const char *old_init_file;
+  char *e;
+  int old_line_number, old_include_level, r;
+
+  if (_rl_parsing_conditionalized_out)
+    return (0);
+
+  old_init_file = current_readline_init_file;
+  old_line_number = current_readline_init_lineno;
+  old_include_level = current_readline_init_include_level;
+
+  e = strchr (args, '\n');
+  if (e)
+    *e = '\0';
+  r = _rl_read_init_file ((const char *)args, old_include_level + 1);
+
+  current_readline_init_file = old_init_file;
+  current_readline_init_lineno = old_line_number;
+  current_readline_init_include_level = old_include_level;
+
+  return r;
+}
+  
+/* Associate textual names with actual functions. */
+static const struct {
+  const char * const name;
+  _rl_parser_func_t *function;
+} parser_directives [] = {
+  { "if", parser_if },
+  { "endif", parser_endif },
+  { "else", parser_else },
+  { "include", parser_include },
+  { (char *)0x0, (_rl_parser_func_t *)0x0 }
+};
+
+/* Handle a parser directive.  STATEMENT is the line of the directive
+   without any leading `$'. */
+static int
+handle_parser_directive (statement)
+     char *statement;
+{
+  register int i;
+  char *directive, *args;
+
+  /* Isolate the actual directive. */
+
+  /* Skip whitespace. */
+  for (i = 0; whitespace (statement[i]); i++);
+
+  directive = &statement[i];
+
+  for (; statement[i] && !whitespace (statement[i]); i++);
+
+  if (statement[i])
+    statement[i++] = '\0';
+
+  for (; statement[i] && whitespace (statement[i]); i++);
+
+  args = &statement[i];
+
+  /* Lookup the command, and act on it. */
+  for (i = 0; parser_directives[i].name; i++)
+    if (_rl_stricmp (directive, parser_directives[i].name) == 0)
+      {
+       (*parser_directives[i].function) (args);
+       return (0);
+      }
+
+  /* display an error message about the unknown parser directive */
+  _rl_init_file_error ("unknown parser directive");
+  return (1);
+}
+
+/* Read the binding command from STRING and perform it.
+   A key binding command looks like: Keyname: function-name\0,
+   a variable binding command looks like: set variable value.
+   A new-style keybinding looks like "\C-x\C-x": exchange-point-and-mark. */
+int
+rl_parse_and_bind (string)
+     char *string;
+{
+  char *funname, *kname;
+  register int c, i;
+  int key, equivalency;
+
+  while (string && whitespace (*string))
+    string++;
+
+  if (!string || !*string || *string == '#')
+    return 0;
+
+  /* If this is a parser directive, act on it. */
+  if (*string == '$')
+    {
+      handle_parser_directive (&string[1]);
+      return 0;
+    }
+
+  /* If we aren't supposed to be parsing right now, then we're done. */
+  if (_rl_parsing_conditionalized_out)
+    return 0;
+
+  i = 0;
+  /* If this keyname is a complex key expression surrounded by quotes,
+     advance to after the matching close quote.  This code allows the
+     backslash to quote characters in the key expression. */
+  if (*string == '"')
+    {
+      int passc = 0;
+
+      for (i = 1; c = string[i]; i++)
+       {
+         if (passc)
+           {
+             passc = 0;
+             continue;
+           }
+
+         if (c == '\\')
+           {
+             passc++;
+             continue;
+           }
+
+         if (c == '"')
+           break;
+       }
+      /* If we didn't find a closing quote, abort the line. */
+      if (string[i] == '\0')
+        {
+          _rl_init_file_error ("no closing `\"' in key binding");
+          return 1;
+        }
+    }
+
+  /* Advance to the colon (:) or whitespace which separates the two objects. */
+  for (; (c = string[i]) && c != ':' && c != ' ' && c != '\t'; i++ );
+
+  equivalency = (c == ':' && string[i + 1] == '=');
+
+  /* Mark the end of the command (or keyname). */
+  if (string[i])
+    string[i++] = '\0';
+
+  /* If doing assignment, skip the '=' sign as well. */
+  if (equivalency)
+    string[i++] = '\0';
+
+  /* If this is a command to set a variable, then do that. */
+  if (_rl_stricmp (string, "set") == 0)
+    {
+      char *var, *value, *e;
+
+      var = string + i;
+      /* Make VAR point to start of variable name. */
+      while (*var && whitespace (*var)) var++;
+
+      /* Make VALUE point to start of value string. */
+      value = var;
+      while (*value && !whitespace (*value)) value++;
+      if (*value)
+       *value++ = '\0';
+      while (*value && whitespace (*value)) value++;
+
+      /* Strip trailing whitespace from values to boolean variables.  Temp
+        fix until I get a real quoted-string parser here. */
+      i = find_boolean_var (var);
+      if (i >= 0)
+       {
+         /* remove trailing whitespace */
+         e = value + strlen (value) - 1;
+         while (e >= value && whitespace (*e))
+           e--;
+         e++;          /* skip back to whitespace or EOS */
+         if (*e && e >= value)
+           *e = '\0';
+       }
+
+      rl_variable_bind (var, value);
+      return 0;
+    }
+
+  /* Skip any whitespace between keyname and funname. */
+  for (; string[i] && whitespace (string[i]); i++);
+  funname = &string[i];
+
+  /* Now isolate funname.
+     For straight function names just look for whitespace, since
+     that will signify the end of the string.  But this could be a
+     macro definition.  In that case, the string is quoted, so skip
+     to the matching delimiter.  We allow the backslash to quote the
+     delimiter characters in the macro body. */
+  /* This code exists to allow whitespace in macro expansions, which
+     would otherwise be gobbled up by the next `for' loop.*/
+  /* XXX - it may be desirable to allow backslash quoting only if " is
+     the quoted string delimiter, like the shell. */
+  if (*funname == '\'' || *funname == '"')
+    {
+      int delimiter, passc;
+
+      delimiter = string[i++];
+      for (passc = 0; c = string[i]; i++)
+       {
+         if (passc)
+           {
+             passc = 0;
+             continue;
+           }
+
+         if (c == '\\')
+           {
+             passc = 1;
+             continue;
+           }
+
+         if (c == delimiter)
+           break;
+       }
+      if (c)
+       i++;
+    }
+
+  /* Advance to the end of the string.  */
+  for (; string[i] && !whitespace (string[i]); i++);
+
+  /* No extra whitespace at the end of the string. */
+  string[i] = '\0';
+
+  /* Handle equivalency bindings here.  Make the left-hand side be exactly
+     whatever the right-hand evaluates to, including keymaps. */
+  if (equivalency)
+    {
+      return 0;
+    }
+
+  /* If this is a new-style key-binding, then do the binding with
+     rl_bind_keyseq ().  Otherwise, let the older code deal with it. */
+  if (*string == '"')
+    {
+      char *seq;
+      register int j, k, passc;
+
+      seq = (char *)xmalloc (1 + strlen (string));
+      for (j = 1, k = passc = 0; string[j]; j++)
+       {
+         /* Allow backslash to quote characters, but leave them in place.
+            This allows a string to end with a backslash quoting another
+            backslash, or with a backslash quoting a double quote.  The
+            backslashes are left in place for rl_translate_keyseq (). */
+         if (passc || (string[j] == '\\'))
+           {
+             seq[k++] = string[j];
+             passc = !passc;
+             continue;
+           }
+
+         if (string[j] == '"')
+           break;
+
+         seq[k++] = string[j];
+       }
+      seq[k] = '\0';
+
+      /* Binding macro? */
+      if (*funname == '\'' || *funname == '"')
+       {
+         j = strlen (funname);
+
+         /* Remove the delimiting quotes from each end of FUNNAME. */
+         if (j && funname[j - 1] == *funname)
+           funname[j - 1] = '\0';
+
+         rl_macro_bind (seq, &funname[1], _rl_keymap);
+       }
+      else
+       rl_bind_keyseq (seq, rl_named_function (funname));
+
+      free (seq);
+      return 0;
+    }
+
+  /* Get the actual character we want to deal with. */
+  kname = strrchr (string, '-');
+  if (!kname)
+    kname = string;
+  else
+    kname++;
+
+  key = glean_key_from_name (kname);
+
+  /* Add in control and meta bits. */
+  if (substring_member_of_array (string, _rl_possible_control_prefixes))
+    key = CTRL (_rl_to_upper (key));
+
+  if (substring_member_of_array (string, _rl_possible_meta_prefixes))
+    key = META (key);
+
+  /* Temporary.  Handle old-style keyname with macro-binding. */
+  if (*funname == '\'' || *funname == '"')
+    {
+      char useq[2];
+      int fl = strlen (funname);
+
+      useq[0] = key; useq[1] = '\0';
+      if (fl && funname[fl - 1] == *funname)
+       funname[fl - 1] = '\0';
+
+      rl_macro_bind (useq, &funname[1], _rl_keymap);
+    }
+#if defined (PREFIX_META_HACK)
+  /* Ugly, but working hack to keep prefix-meta around. */
+  else if (_rl_stricmp (funname, "prefix-meta") == 0)
+    {
+      char seq[2];
+
+      seq[0] = key;
+      seq[1] = '\0';
+      rl_generic_bind (ISKMAP, seq, (char *)emacs_meta_keymap, _rl_keymap);
+    }
+#endif /* PREFIX_META_HACK */
+  else
+    rl_bind_key (key, rl_named_function (funname));
+  return 0;
+}
+
+/* Simple structure for boolean readline variables (i.e., those that can
+   have one of two values; either "On" or 1 for truth, or "Off" or 0 for
+   false. */
+
+#define V_SPECIAL      0x1
+
+static const struct {
+  const char * const name;
+  int *value;
+  int flags;
+} boolean_varlist [] = {
+  { "bind-tty-special-chars",  &_rl_bind_stty_chars,           0 },
+  { "blink-matching-paren",    &rl_blink_matching_paren,       V_SPECIAL },
+  { "byte-oriented",           &rl_byte_oriented,              0 },
+  { "completion-ignore-case",  &_rl_completion_case_fold,      0 },
+  { "convert-meta",            &_rl_convert_meta_chars_to_ascii, 0 },
+  { "disable-completion",      &rl_inhibit_completion,         0 },
+  { "enable-keypad",           &_rl_enable_keypad,             0 },
+  { "expand-tilde",            &rl_complete_with_tilde_expansion, 0 },
+  { "history-preserve-point",  &_rl_history_preserve_point,    0 },
+  { "horizontal-scroll-mode",  &_rl_horizontal_scroll_mode,    0 },
+  { "input-meta",              &_rl_meta_flag,                 0 },
+  { "mark-directories",                &_rl_complete_mark_directories, 0 },
+  { "mark-modified-lines",     &_rl_mark_modified_lines,       0 },
+  { "mark-symlinked-directories", &_rl_complete_mark_symlink_dirs, 0 },
+  { "match-hidden-files",      &_rl_match_hidden_files,        0 },
+  { "meta-flag",               &_rl_meta_flag,                 0 },
+  { "output-meta",             &_rl_output_meta_chars,         0 },
+  { "page-completions",                &_rl_page_completions,          0 },
+  { "prefer-visible-bell",     &_rl_prefer_visible_bell,       V_SPECIAL },
+  { "print-completions-horizontally", &_rl_print_completions_horizontally, 0 },
+  { "show-all-if-ambiguous",   &_rl_complete_show_all,         0 },
+  { "show-all-if-unmodified",  &_rl_complete_show_unmodified,  0 },
+#if defined (VISIBLE_STATS)
+  { "visible-stats",           &rl_visible_stats,              0 },
+#endif /* VISIBLE_STATS */
+  { (char *)NULL, (int *)NULL }
+};
+
+static int
+find_boolean_var (name)
+     const char *name;
+{
+  register int i;
+
+  for (i = 0; boolean_varlist[i].name; i++)
+    if (_rl_stricmp (name, boolean_varlist[i].name) == 0)
+      return i;
+  return -1;
+}
+
+/* Hooks for handling special boolean variables, where a
+   function needs to be called or another variable needs
+   to be changed when they're changed. */
+static void
+hack_special_boolean_var (i)
+     int i;
+{
+  const char *name;
+
+  name = boolean_varlist[i].name;
+
+  if (_rl_stricmp (name, "blink-matching-paren") == 0)
+    _rl_enable_paren_matching (rl_blink_matching_paren);
+  else if (_rl_stricmp (name, "prefer-visible-bell") == 0)
+    {
+      if (_rl_prefer_visible_bell)
+       _rl_bell_preference = VISIBLE_BELL;
+      else
+       _rl_bell_preference = AUDIBLE_BELL;
+    }
+}
+
+typedef int _rl_sv_func_t PARAMS((const char *));
+
+/* These *must* correspond to the array indices for the appropriate
+   string variable.  (Though they're not used right now.) */
+#define V_BELLSTYLE    0
+#define V_COMBEGIN     1
+#define V_EDITMODE     2
+#define V_ISRCHTERM    3
+#define V_KEYMAP       4
+
+#define        V_STRING        1
+#define V_INT          2
+
+/* Forward declarations */
+static int sv_bell_style PARAMS((const char *));
+static int sv_combegin PARAMS((const char *));
+static int sv_compquery PARAMS((const char *));
+static int sv_editmode PARAMS((const char *));
+static int sv_isrchterm PARAMS((const char *));
+static int sv_keymap PARAMS((const char *));
+
+static const struct {
+  const char * const name;
+  int flags;
+  _rl_sv_func_t *set_func;
+} string_varlist[] = {
+  { "bell-style",      V_STRING,       sv_bell_style },
+  { "comment-begin",   V_STRING,       sv_combegin },
+  { "completion-query-items", V_INT,   sv_compquery },
+  { "editing-mode",    V_STRING,       sv_editmode },
+  { "isearch-terminators", V_STRING,   sv_isrchterm },
+  { "keymap",          V_STRING,       sv_keymap },
+  { (char *)NULL,      0 }
+};
+
+static int
+find_string_var (name)
+     const char *name;
+{
+  register int i;
+
+  for (i = 0; string_varlist[i].name; i++)
+    if (_rl_stricmp (name, string_varlist[i].name) == 0)
+      return i;
+  return -1;
+}
+
+/* A boolean value that can appear in a `set variable' command is true if
+   the value is null or empty, `on' (case-insenstive), or "1".  Any other
+   values result in 0 (false). */
+static int
+bool_to_int (value)
+     const char *value;
+{
+  return (value == 0 || *value == '\0' ||
+               (_rl_stricmp (value, "on") == 0) ||
+               (value[0] == '1' && value[1] == '\0'));
+}
+
+char *
+rl_variable_value (name)
+     const char *name;
+{
+  register int i;
+
+  /* Check for simple variables first. */
+  i = find_boolean_var (name);
+  if (i >= 0)
+    return (*boolean_varlist[i].value ? "on" : "off");
+
+  i = find_string_var (name);
+  if (i >= 0)
+    return (_rl_get_string_variable_value (string_varlist[i].name));
+
+  /* Unknown variable names return NULL. */
+  return 0;
+}
+
+int
+rl_variable_bind (name, value)
+     const char *name, *value;
+{
+  register int i;
+  int  v;
+
+  /* Check for simple variables first. */
+  i = find_boolean_var (name);
+  if (i >= 0)
+    {
+      *boolean_varlist[i].value = bool_to_int (value);
+      if (boolean_varlist[i].flags & V_SPECIAL)
+       hack_special_boolean_var (i);
+      return 0;
+    }
+
+  i = find_string_var (name);
+
+  /* For the time being, unknown variable names or string names without a
+     handler function are simply ignored. */
+  if (i < 0 || string_varlist[i].set_func == 0)
+    return 0;
+
+  v = (*string_varlist[i].set_func) (value);
+  return v;
+}
+
+static int
+sv_editmode (value)
+     const char *value;
+{
+  if (_rl_strnicmp (value, "vi", 2) == 0)
+    {
+#if defined (VI_MODE)
+      _rl_keymap = vi_insertion_keymap;
+      rl_editing_mode = vi_mode;
+#endif /* VI_MODE */
+      return 0;
+    }
+  else if (_rl_strnicmp (value, "emacs", 5) == 0)
+    {
+      _rl_keymap = emacs_standard_keymap;
+      rl_editing_mode = emacs_mode;
+      return 0;
+    }
+  return 1;
+}
+
+static int
+sv_combegin (value)
+     const char *value;
+{
+  if (value && *value)
+    {
+      FREE (_rl_comment_begin);
+      _rl_comment_begin = savestring (value);
+      return 0;
+    }
+  return 1;
+}
+
+static int
+sv_compquery (value)
+     const char *value;
+{
+  int nval = 100;
+
+  if (value && *value)
+    {
+      nval = atoi (value);
+      if (nval < 0)
+       nval = 0;
+    }
+  rl_completion_query_items = nval;
+  return 0;
+}
+
+static int
+sv_keymap (value)
+     const char *value;
+{
+  Keymap kmap;
+
+  kmap = rl_get_keymap_by_name (value);
+  if (kmap)
+    {
+      rl_set_keymap (kmap);
+      return 0;
+    }
+  return 1;
+}
+
+static int
+sv_bell_style (value)
+     const char *value;
+{
+  if (value == 0 || *value == '\0')
+    _rl_bell_preference = AUDIBLE_BELL;
+  else if (_rl_stricmp (value, "none") == 0 || _rl_stricmp (value, "off") == 0)
+    _rl_bell_preference = NO_BELL;
+  else if (_rl_stricmp (value, "audible") == 0 || _rl_stricmp (value, "on") == 0)
+    _rl_bell_preference = AUDIBLE_BELL;
+  else if (_rl_stricmp (value, "visible") == 0)
+    _rl_bell_preference = VISIBLE_BELL;
+  else
+    return 1;
+  return 0;
+}
+
+static int
+sv_isrchterm (value)
+     const char *value;
+{
+  int beg, end, delim;
+  char *v;
+
+  if (value == 0)
+    return 1;
+
+  /* Isolate the value and translate it into a character string. */
+  v = savestring (value);
+  FREE (_rl_isearch_terminators);
+  if (v[0] == '"' || v[0] == '\'')
+    {
+      delim = v[0];
+      for (beg = end = 1; v[end] && v[end] != delim; end++)
+       ;
+    }
+  else
+    {
+      for (beg = end = 0; whitespace (v[end]) == 0; end++)
+       ;
+    }
+
+  v[end] = '\0';
+
+  /* The value starts at v + beg.  Translate it into a character string. */
+  _rl_isearch_terminators = (char *)xmalloc (2 * strlen (v) + 1);
+  rl_translate_keyseq (v + beg, _rl_isearch_terminators, &end);
+  _rl_isearch_terminators[end] = '\0';
+
+  free (v);
+  return 0;
+}
+      
+/* Return the character which matches NAME.
+   For example, `Space' returns ' '. */
+
+typedef struct {
+  const char * const name;
+  int value;
+} assoc_list;
+
+static const assoc_list name_key_alist[] = {
+  { "DEL", 0x7f },
+  { "ESC", '\033' },
+  { "Escape", '\033' },
+  { "LFD", '\n' },
+  { "Newline", '\n' },
+  { "RET", '\r' },
+  { "Return", '\r' },
+  { "Rubout", 0x7f },
+  { "SPC", ' ' },
+  { "Space", ' ' },
+  { "Tab", 0x09 },
+  { (char *)0x0, 0 }
+};
+
+static int
+glean_key_from_name (name)
+     char *name;
+{
+  register int i;
+
+  for (i = 0; name_key_alist[i].name; i++)
+    if (_rl_stricmp (name, name_key_alist[i].name) == 0)
+      return (name_key_alist[i].value);
+
+  return (*(unsigned char *)name);     /* XXX was return (*name) */
+}
+
+/* Auxiliary functions to manage keymaps. */
+static const struct {
+  const char * const name;
+  Keymap map;
+} keymap_names[] = {
+  { "emacs", emacs_standard_keymap },
+  { "emacs-standard", emacs_standard_keymap },
+  { "emacs-meta", emacs_meta_keymap },
+  { "emacs-ctlx", emacs_ctlx_keymap },
+#if defined (VI_MODE)
+  { "vi", vi_movement_keymap },
+  { "vi-move", vi_movement_keymap },
+  { "vi-command", vi_movement_keymap },
+  { "vi-insert", vi_insertion_keymap },
+#endif /* VI_MODE */
+  { (char *)0x0, (Keymap)0x0 }
+};
+
+Keymap
+rl_get_keymap_by_name (name)
+     const char *name;
+{
+  register int i;
+
+  for (i = 0; keymap_names[i].name; i++)
+    if (_rl_stricmp (name, keymap_names[i].name) == 0)
+      return (keymap_names[i].map);
+  return ((Keymap) NULL);
+}
+
+char *
+rl_get_keymap_name (map)
+     Keymap map;
+{
+  register int i;
+  for (i = 0; keymap_names[i].name; i++)
+    if (map == keymap_names[i].map)
+      return ((char *)keymap_names[i].name);
+  return ((char *)NULL);
+}
+  
+void
+rl_set_keymap (map)
+     Keymap map;
+{
+  if (map)
+    _rl_keymap = map;
+}
+
+Keymap
+rl_get_keymap ()
+{
+  return (_rl_keymap);
+}
+
+void
+rl_set_keymap_from_edit_mode ()
+{
+  if (rl_editing_mode == emacs_mode)
+    _rl_keymap = emacs_standard_keymap;
+#if defined (VI_MODE)
+  else if (rl_editing_mode == vi_mode)
+    _rl_keymap = vi_insertion_keymap;
+#endif /* VI_MODE */
+}
+
+char *
+rl_get_keymap_name_from_edit_mode ()
+{
+  if (rl_editing_mode == emacs_mode)
+    return "emacs";
+#if defined (VI_MODE)
+  else if (rl_editing_mode == vi_mode)
+    return "vi";
+#endif /* VI_MODE */
+  else
+    return "none";
+}
+
+/* **************************************************************** */
+/*                                                                 */
+/*               Key Binding and Function Information              */
+/*                                                                 */
+/* **************************************************************** */
+
+/* Each of the following functions produces information about the
+   state of keybindings and functions known to Readline.  The info
+   is always printed to rl_outstream, and in such a way that it can
+   be read back in (i.e., passed to rl_parse_and_bind ()). */
+
+/* Print the names of functions known to Readline. */
+void
+rl_list_funmap_names ()
+{
+  register int i;
+  const char **funmap_names;
+
+  funmap_names = rl_funmap_names ();
+
+  if (!funmap_names)
+    return;
+
+  for (i = 0; funmap_names[i]; i++)
+    fprintf (rl_outstream, "%s\n", funmap_names[i]);
+
+  free (funmap_names);
+}
+
+static char *
+_rl_get_keyname (key)
+     int key;
+{
+  char *keyname;
+  int i, c;
+
+  keyname = (char *)xmalloc (8);
+
+  c = key;
+  /* Since this is going to be used to write out keysequence-function
+     pairs for possible inclusion in an inputrc file, we don't want to
+     do any special meta processing on KEY. */
+
+#if 1
+  /* XXX - Experimental */
+  /* We might want to do this, but the old version of the code did not. */
+
+  /* If this is an escape character, we don't want to do any more processing.
+     Just add the special ESC key sequence and return. */
+  if (c == ESC)
+    {
+      keyname[0] = '\\';
+      keyname[1] = 'e';
+      keyname[2] = '\0';
+      return keyname;
+    }
+#endif
+
+  /* RUBOUT is translated directly into \C-? */
+  if (key == RUBOUT)
+    {
+      keyname[0] = '\\';
+      keyname[1] = 'C';
+      keyname[2] = '-';
+      keyname[3] = '?';
+      keyname[4] = '\0';
+      return keyname;
+    }
+
+  i = 0;
+  /* Now add special prefixes needed for control characters.  This can
+     potentially change C. */
+  if (CTRL_CHAR (c))
+    {
+      keyname[i++] = '\\';
+      keyname[i++] = 'C';
+      keyname[i++] = '-';
+      c = _rl_to_lower (UNCTRL (c));
+    }
+
+  /* XXX experimental code.  Turn the characters that are not ASCII or
+     ISO Latin 1 (128 - 159) into octal escape sequences (\200 - \237).
+     This changes C. */
+  if (c >= 128 && c <= 159)
+    {
+      keyname[i++] = '\\';
+      keyname[i++] = '2';
+      c -= 128;
+      keyname[i++] = (c / 8) + '0';
+      c = (c % 8) + '0';
+    }
+
+  /* Now, if the character needs to be quoted with a backslash, do that. */
+  if (c == '\\' || c == '"')
+    keyname[i++] = '\\';
+
+  /* Now add the key, terminate the string, and return it. */
+  keyname[i++] = (char) c;
+  keyname[i] = '\0';
+
+  return keyname;
+}
+
+/* Return a NULL terminated array of strings which represent the key
+   sequences that are used to invoke FUNCTION in MAP. */
+char **
+rl_invoking_keyseqs_in_map (function, map)
+     rl_command_func_t *function;
+     Keymap map;
+{
+  register int key;
+  char **result;
+  int result_index, result_size;
+
+  result = (char **)NULL;
+  result_index = result_size = 0;
+
+  for (key = 0; key < KEYMAP_SIZE; key++)
+    {
+      switch (map[key].type)
+       {
+       case ISMACR:
+         /* Macros match, if, and only if, the pointers are identical.
+            Thus, they are treated exactly like functions in here. */
+       case ISFUNC:
+         /* If the function in the keymap is the one we are looking for,
+            then add the current KEY to the list of invoking keys. */
+         if (map[key].function == function)
+           {
+             char *keyname;
+
+             keyname = _rl_get_keyname (key);
+
+             if (result_index + 2 > result_size)
+               {
+                 result_size += 10;
+                 result = (char **)xrealloc (result, result_size * sizeof (char *));
+               }
+
+             result[result_index++] = keyname;
+             result[result_index] = (char *)NULL;
+           }
+         break;
+
+       case ISKMAP:
+         {
+           char **seqs;
+           register int i;
+
+           /* Find the list of keyseqs in this map which have FUNCTION as
+              their target.  Add the key sequences found to RESULT. */
+           if (map[key].function)
+             seqs =
+               rl_invoking_keyseqs_in_map (function, FUNCTION_TO_KEYMAP (map, key));
+           else
+             break;
+
+           if (seqs == 0)
+             break;
+
+           for (i = 0; seqs[i]; i++)
+             {
+               char *keyname = (char *)xmalloc (6 + strlen (seqs[i]));
+
+               if (key == ESC)
+                 {
+                   /* If ESC is the meta prefix and we're converting chars
+                      with the eighth bit set to ESC-prefixed sequences, then
+                      we can use \M-.  Otherwise we need to use the sequence
+                      for ESC. */
+                   if (_rl_convert_meta_chars_to_ascii && map[ESC].type == ISKMAP)
+                     sprintf (keyname, "\\M-");
+                   else
+                     sprintf (keyname, "\\e");
+                 }
+               else if (CTRL_CHAR (key))
+                 sprintf (keyname, "\\C-%c", _rl_to_lower (UNCTRL (key)));
+               else if (key == RUBOUT)
+                 sprintf (keyname, "\\C-?");
+               else if (key == '\\' || key == '"')
+                 {
+                   keyname[0] = '\\';
+                   keyname[1] = (char) key;
+                   keyname[2] = '\0';
+                 }
+               else
+                 {
+                   keyname[0] = (char) key;
+                   keyname[1] = '\0';
+                 }
+               
+               strcat (keyname, seqs[i]);
+               free (seqs[i]);
+
+               if (result_index + 2 > result_size)
+                 {
+                   result_size += 10;
+                   result = (char **)xrealloc (result, result_size * sizeof (char *));
+                 }
+
+               result[result_index++] = keyname;
+               result[result_index] = (char *)NULL;
+             }
+
+           free (seqs);
+         }
+         break;
+       }
+    }
+  return (result);
+}
+
+/* Return a NULL terminated array of strings which represent the key
+   sequences that can be used to invoke FUNCTION using the current keymap. */
+char **
+rl_invoking_keyseqs (function)
+     rl_command_func_t *function;
+{
+  return (rl_invoking_keyseqs_in_map (function, _rl_keymap));
+}
+
+/* Print all of the functions and their bindings to rl_outstream.  If
+   PRINT_READABLY is non-zero, then print the output in such a way
+   that it can be read back in. */
+void
+rl_function_dumper (print_readably)
+     int print_readably;
+{
+  register int i;
+  const char **names;
+  const char *name;
+
+  names = rl_funmap_names ();
+
+  fprintf (rl_outstream, "\n");
+
+  for (i = 0; name = names[i]; i++)
+    {
+      rl_command_func_t *function;
+      char **invokers;
+
+      function = rl_named_function (name);
+      invokers = rl_invoking_keyseqs_in_map (function, _rl_keymap);
+
+      if (print_readably)
+       {
+         if (!invokers)
+           fprintf (rl_outstream, "# %s (not bound)\n", name);
+         else
+           {
+             register int j;
+
+             for (j = 0; invokers[j]; j++)
+               {
+                 fprintf (rl_outstream, "\"%s\": %s\n",
+                          invokers[j], name);
+                 free (invokers[j]);
+               }
+
+             free (invokers);
+           }
+       }
+      else
+       {
+         if (!invokers)
+           fprintf (rl_outstream, "%s is not bound to any keys\n",
+                    name);
+         else
+           {
+             register int j;
+
+             fprintf (rl_outstream, "%s can be found on ", name);
+
+             for (j = 0; invokers[j] && j < 5; j++)
+               {
+                 fprintf (rl_outstream, "\"%s\"%s", invokers[j],
+                          invokers[j + 1] ? ", " : ".\n");
+               }
+
+             if (j == 5 && invokers[j])
+               fprintf (rl_outstream, "...\n");
+
+             for (j = 0; invokers[j]; j++)
+               free (invokers[j]);
+
+             free (invokers);
+           }
+       }
+    }
+}
+
+/* Print all of the current functions and their bindings to
+   rl_outstream.  If an explicit argument is given, then print
+   the output in such a way that it can be read back in. */
+int
+rl_dump_functions (count, key)
+     int count, key;
+{
+  if (rl_dispatching)
+    fprintf (rl_outstream, "\r\n");
+  rl_function_dumper (rl_explicit_arg);
+  rl_on_new_line ();
+  return (0);
+}
+
+static void
+_rl_macro_dumper_internal (print_readably, map, prefix)
+     int print_readably;
+     Keymap map;
+     char *prefix;
+{
+  register int key;
+  char *keyname, *out;
+  int prefix_len;
+
+  for (key = 0; key < KEYMAP_SIZE; key++)
+    {
+      switch (map[key].type)
+       {
+       case ISMACR:
+         keyname = _rl_get_keyname (key);
+         out = _rl_untranslate_macro_value ((char *)map[key].function);
+
+         if (print_readably)
+           fprintf (rl_outstream, "\"%s%s\": \"%s\"\n", prefix ? prefix : "",
+                                                        keyname,
+                                                        out ? out : "");
+         else
+           fprintf (rl_outstream, "%s%s outputs %s\n", prefix ? prefix : "",
+                                                       keyname,
+                                                       out ? out : "");
+         free (keyname);
+         free (out);
+         break;
+       case ISFUNC:
+         break;
+       case ISKMAP:
+         prefix_len = prefix ? strlen (prefix) : 0;
+         if (key == ESC)
+           {
+             keyname = (char *)xmalloc (3 + prefix_len);
+             if (prefix)
+               strcpy (keyname, prefix);
+             keyname[prefix_len] = '\\';
+             keyname[prefix_len + 1] = 'e';
+             keyname[prefix_len + 2] = '\0';
+           }
+         else
+           {
+             keyname = _rl_get_keyname (key);
+             if (prefix)
+               {
+                 out = (char *)xmalloc (strlen (keyname) + prefix_len + 1);
+                 strcpy (out, prefix);
+                 strcpy (out + prefix_len, keyname);
+                 free (keyname);
+                 keyname = out;
+               }
+           }
+
+         _rl_macro_dumper_internal (print_readably, FUNCTION_TO_KEYMAP (map, key), keyname);
+         free (keyname);
+         break;
+       }
+    }
+}
+
+void
+rl_macro_dumper (print_readably)
+     int print_readably;
+{
+  _rl_macro_dumper_internal (print_readably, _rl_keymap, (char *)NULL);
+}
+
+int
+rl_dump_macros (count, key)
+     int count, key;
+{
+  if (rl_dispatching)
+    fprintf (rl_outstream, "\r\n");
+  rl_macro_dumper (rl_explicit_arg);
+  rl_on_new_line ();
+  return (0);
+}
+
+static char *
+_rl_get_string_variable_value (name)
+     const char *name;
+{
+  static char numbuf[32];
+  char *ret;
+
+  if (_rl_stricmp (name, "bell-style") == 0)
+    {
+      switch (_rl_bell_preference)
+       {
+         case NO_BELL:
+           return "none";
+         case VISIBLE_BELL:
+           return "visible";
+         case AUDIBLE_BELL:
+         default:
+           return "audible";
+       }
+    }
+  else if (_rl_stricmp (name, "comment-begin") == 0)
+    return (_rl_comment_begin ? _rl_comment_begin : RL_COMMENT_BEGIN_DEFAULT);
+  else if (_rl_stricmp (name, "completion-query-items") == 0)
+    {
+      sprintf (numbuf, "%d", rl_completion_query_items);
+      return (numbuf);
+    }
+  else if (_rl_stricmp (name, "editing-mode") == 0)
+    return (rl_get_keymap_name_from_edit_mode ());
+  else if (_rl_stricmp (name, "isearch-terminators") == 0)
+    {
+      if (_rl_isearch_terminators == 0)
+       return 0;
+      ret = _rl_untranslate_macro_value (_rl_isearch_terminators);
+      if (ret)
+       {
+         strncpy (numbuf, ret, sizeof (numbuf) - 1);
+         free (ret);
+         numbuf[sizeof(numbuf) - 1] = '\0';
+       }
+      else
+       numbuf[0] = '\0';
+      return numbuf;
+    }
+  else if (_rl_stricmp (name, "keymap") == 0)
+    {
+      ret = rl_get_keymap_name (_rl_keymap);
+      if (ret == 0)
+       ret = rl_get_keymap_name_from_edit_mode ();
+      return (ret ? ret : "none");
+    }
+  else
+    return (0);
+}
+
+void
+rl_variable_dumper (print_readably)
+     int print_readably;
+{
+  int i;
+  char *v;
+
+  for (i = 0; boolean_varlist[i].name; i++)
+    {
+      if (print_readably)
+        fprintf (rl_outstream, "set %s %s\n", boolean_varlist[i].name,
+                              *boolean_varlist[i].value ? "on" : "off");
+      else
+        fprintf (rl_outstream, "%s is set to `%s'\n", boolean_varlist[i].name,
+                              *boolean_varlist[i].value ? "on" : "off");
+    }
+
+  for (i = 0; string_varlist[i].name; i++)
+    {
+      v = _rl_get_string_variable_value (string_varlist[i].name);
+      if (v == 0)      /* _rl_isearch_terminators can be NULL */
+       continue;
+      if (print_readably)
+        fprintf (rl_outstream, "set %s %s\n", string_varlist[i].name, v);
+      else
+        fprintf (rl_outstream, "%s is set to `%s'\n", string_varlist[i].name, v);
+    }
+}
+
+/* Print all of the current variables and their values to
+   rl_outstream.  If an explicit argument is given, then print
+   the output in such a way that it can be read back in. */
+int
+rl_dump_variables (count, key)
+     int count, key;
+{
+  if (rl_dispatching)
+    fprintf (rl_outstream, "\r\n");
+  rl_variable_dumper (rl_explicit_arg);
+  rl_on_new_line ();
+  return (0);
+}
+
+/* Return non-zero if any members of ARRAY are a substring in STRING. */
+static int
+substring_member_of_array (string, array)
+     const char *string;
+     const char * const *array;
+{
+  while (*array)
+    {
+      if (_rl_strindex (string, *array))
+       return (1);
+      array++;
+    }
+  return (0);
+}
index 1598ad6a12ec7e926eeac58f1d8df8675163edae..90528bc63edad01c4d5a76d30e9adefdcc35ec37 100644 (file)
@@ -325,6 +325,12 @@ int rl_completion_mark_symlink_dirs;
 /* If non-zero, inhibit completion (temporarily). */
 int rl_inhibit_completion;
 
+/* Set to the last key used to invoke one of the completion functions */
+int rl_completion_invoking_key;
+
+/* If non-zero, sort the completion matches.  On by default. */
+int rl_sort_completion_matches = 1;
+
 /* Variables local to this file. */
 
 /* Local variable states what happened during the last completion attempt. */
@@ -343,6 +349,8 @@ int
 rl_complete (ignore, invoking_key)
      int ignore, invoking_key;
 {
+  rl_completion_invoking_key = invoking_key;
+
   if (rl_inhibit_completion)
     return (_rl_insert_char (ignore, invoking_key));
   else if (rl_last_func == rl_complete && !completion_changed_buffer)
@@ -360,6 +368,7 @@ int
 rl_possible_completions (ignore, invoking_key)
      int ignore, invoking_key;
 {
+  rl_completion_invoking_key = invoking_key;
   return (rl_complete_internal ('?'));
 }
 
@@ -367,6 +376,7 @@ int
 rl_insert_completions (ignore, invoking_key)
      int ignore, invoking_key;
 {
+  rl_completion_invoking_key = invoking_key;
   return (rl_complete_internal ('*'));
 }
 
@@ -999,7 +1009,7 @@ remove_duplicate_matches (matches)
 
   /* Sort the array without matches[0], since we need it to
      stay in place no matter what. */
-  if (i)
+  if (i && rl_sort_completion_matches)
     qsort (matches+1, i-1, sizeof (char *), (QSFUNC *)_rl_qsort_string_compare);
 
   /* Remember the lowest common denominator for it may be unique. */
@@ -1167,7 +1177,8 @@ compute_lcd_of_matches (match_list, matches, text)
            }
 
          /* sort the list to get consistent answers. */
-         qsort (match_list+1, matches, sizeof(char *), (QSFUNC *)_rl_qsort_string_compare);
+         if (rl_sort_completion_matches)
+           qsort (match_list+1, matches, sizeof(char *), (QSFUNC *)_rl_qsort_string_compare);
 
          si = strlen (text);
          if (si <= low)
@@ -1285,7 +1296,7 @@ rl_display_match_list (matches, len, max)
           0 < len <= limit  implies  count = 1. */
 
   /* Sort the items if they are not already sorted. */
-  if (rl_ignore_completion_duplicates == 0)
+  if (rl_ignore_completion_duplicates == 0 && rl_sort_completion_matches)
     qsort (matches + 1, len, sizeof (char *), (QSFUNC *)_rl_qsort_string_compare);
 
   rl_crlf ();
@@ -2116,8 +2127,8 @@ rl_filename_completion_function (text, state)
    hit the end of the match list, we restore the original unmatched text,
    ring the bell, and reset the counter to zero. */
 int
-rl_menu_complete (count, ignore)
-     int count, ignore;
+rl_menu_complete (count, invoking_key)
+     int count, invoking_key;
 {
   rl_compentry_func_t *our_func;
   int matching_filenames, found_quote;
@@ -2142,6 +2153,8 @@ rl_menu_complete (count, ignore)
       match_list_index = match_list_size = 0;
       matches = (char **)NULL;
 
+      rl_completion_invoking_key = invoking_key;
+
       /* Only the completion entry function can change these. */
       set_completion_defaults ('%');
 
index 75f3db9ec8cbb0d09fafda775aff2df564a7a326..1598ad6a12ec7e926eeac58f1d8df8675163edae 100644 (file)
@@ -1,6 +1,6 @@
 /* complete.c -- filename completion for readline. */
 
-/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2006 Free Software Foundation, Inc.
 
    This file is part of the GNU Readline Library, a library for
    reading lines of text with interactive input and history editing.
@@ -1749,7 +1749,7 @@ rl_complete_internal (what_to_do)
       break;
 
     default:
-      fprintf (stderr, "\r\nreadline: bad value %d for what_to_do in rl_complete\n", what_to_do);
+      _rl_ttymsg ("bad value %d for what_to_do in rl_complete", what_to_do);
       rl_ding ();
       FREE (saved_line_buffer);
       RL_UNSETSTATE(RL_STATE_COMPLETING);
index cc838bf023b90565a156bedce7eb378fb517226d..6536187e2b7a69f9d1b0e97f57ffb3a6ac7c3f1e 100644 (file)
@@ -1839,6 +1839,15 @@ if the application's completion function returns no matches.
 It should be set only by an application's completion function.
 @end deftypevar
 
+@deftypevar int rl_sort_completion_matches
+If an application sets this variable to 0, Readline will not sort the
+list of completions (which implies that it cannot remove any duplicate
+completions).  The default value is 1, which means that Readline will
+sort the completions and, depending on the value of
+@code{rl_ignore_completion_duplicates}, will attempt to remove duplicate
+matches.
+@end deftypevar
+
 @deftypevar int rl_completion_type
 Set to a character describing the type of completion Readline is currently
 attempting; see the description of @code{rl_complete_internal()}
@@ -1848,6 +1857,13 @@ completion function is called, allowing such functions to present
 the same interface as @code{rl_complete()}.
 @end deftypevar
 
+@deftypevar int rl_completion_invoking_key
+Set to the final character in the key sequence that invoked one of the
+completion functions that call @code{rl_complete_internal()}.  This is
+set to the appropriate value before any application-specific completion
+function is called.
+@end deftypevar
+
 @deftypevar int rl_inhibit_completion
 If this variable is non-zero, completion is inhibited.  The completion
 character will be inserted as any other bound to @code{self-insert}.
diff --git a/lib/readline/doc/rltech.texi~ b/lib/readline/doc/rltech.texi~
new file mode 100644 (file)
index 0000000..cc838bf
--- /dev/null
@@ -0,0 +1,2302 @@
+@comment %**start of header (This is for running Texinfo on a region.)
+@setfilename rltech.info
+@comment %**end of header (This is for running Texinfo on a region.)
+@setchapternewpage odd
+
+@ifinfo
+This document describes the GNU Readline Library, a utility for aiding
+in the consistency of user interface across discrete programs that need
+to provide a command line interface.
+
+Copyright (C) 1988-2006 Free Software Foundation, Inc.
+
+Permission is granted to make and distribute verbatim copies of
+this manual provided the copyright notice and this permission notice
+pare preserved on all copies.
+
+@ignore
+Permission is granted to process this file through TeX and print the
+results, provided the printed document carries copying permission
+notice identical to this one except for the removal of this paragraph
+(this paragraph not being relevant to the printed manual).
+@end ignore
+
+Permission is granted to copy and distribute modified versions of this
+manual under the conditions for verbatim copying, provided that the entire
+resulting derived work is distributed under the terms of a permission
+notice identical to this one.
+
+Permission is granted to copy and distribute translations of this manual
+into another language, under the above conditions for modified versions,
+except that this permission notice may be stated in a translation approved
+by the Foundation.
+@end ifinfo
+
+@node Programming with GNU Readline
+@chapter Programming with GNU Readline
+
+This chapter describes the interface between the @sc{gnu} Readline Library and
+other programs.  If you are a programmer, and you wish to include the
+features found in @sc{gnu} Readline
+such as completion, line editing, and interactive history manipulation
+in your own programs, this section is for you.
+
+@menu
+* Basic Behavior::     Using the default behavior of Readline.
+* Custom Functions::   Adding your own functions to Readline.
+* Readline Variables::                 Variables accessible to custom
+                                       functions.
+* Readline Convenience Functions::     Functions which Readline supplies to
+                                       aid in writing your own custom
+                                       functions.
+* Readline Signal Handling::   How Readline behaves when it receives signals.
+* Custom Completers::  Supplanting or supplementing Readline's
+                       completion functions.
+@end menu
+
+@node Basic Behavior
+@section Basic Behavior
+
+Many programs provide a command line interface, such as @code{mail},
+@code{ftp}, and @code{sh}.  For such programs, the default behaviour of
+Readline is sufficient.  This section describes how to use Readline in
+the simplest way possible, perhaps to replace calls in your code to
+@code{gets()} or @code{fgets()}.
+
+@findex readline
+@cindex readline, function
+
+The function @code{readline()} prints a prompt @var{prompt}
+and then reads and returns a single line of text from the user.
+If @var{prompt} is @code{NULL} or the empty string, no prompt is displayed.
+The line @code{readline} returns is allocated with @code{malloc()};
+the caller should @code{free()} the line when it has finished with it.
+The declaration for @code{readline} in ANSI C is
+
+@example
+@code{char *readline (const char *@var{prompt});}
+@end example
+
+@noindent
+So, one might say
+@example
+@code{char *line = readline ("Enter a line: ");}
+@end example
+@noindent
+in order to read a line of text from the user.
+The line returned has the final newline removed, so only the
+text remains.
+
+If @code{readline} encounters an @code{EOF} while reading the line, and the
+line is empty at that point, then @code{(char *)NULL} is returned.
+Otherwise, the line is ended just as if a newline had been typed.
+
+If you want the user to be able to get at the line later, (with
+@key{C-p} for example), you must call @code{add_history()} to save the
+line away in a @dfn{history} list of such lines.
+
+@example
+@code{add_history (line)};
+@end example
+
+@noindent
+For full details on the GNU History Library, see the associated manual.
+
+It is preferable to avoid saving empty lines on the history list, since
+users rarely have a burning need to reuse a blank line.  Here is
+a function which usefully replaces the standard @code{gets()} library
+function, and has the advantage of no static buffer to overflow:
+
+@example
+/* A static variable for holding the line. */
+static char *line_read = (char *)NULL;
+
+/* Read a string, and return a pointer to it.
+   Returns NULL on EOF. */
+char *
+rl_gets ()
+@{
+  /* If the buffer has already been allocated,
+     return the memory to the free pool. */
+  if (line_read)
+    @{
+      free (line_read);
+      line_read = (char *)NULL;
+    @}
+
+  /* Get a line from the user. */
+  line_read = readline ("");
+
+  /* If the line has any text in it,
+     save it on the history. */
+  if (line_read && *line_read)
+    add_history (line_read);
+
+  return (line_read);
+@}
+@end example
+
+This function gives the user the default behaviour of @key{TAB}
+completion: completion on file names.  If you do not want Readline to
+complete on filenames, you can change the binding of the @key{TAB} key
+with @code{rl_bind_key()}.
+
+@example
+@code{int rl_bind_key (int @var{key}, rl_command_func_t *@var{function});}
+@end example
+
+@code{rl_bind_key()} takes two arguments: @var{key} is the character that
+you want to bind, and @var{function} is the address of the function to
+call when @var{key} is pressed.  Binding @key{TAB} to @code{rl_insert()}
+makes @key{TAB} insert itself.
+@code{rl_bind_key()} returns non-zero if @var{key} is not a valid
+ASCII character code (between 0 and 255).
+
+Thus, to disable the default @key{TAB} behavior, the following suffices:
+@example
+@code{rl_bind_key ('\t', rl_insert);}
+@end example
+
+This code should be executed once at the start of your program; you
+might write a function called @code{initialize_readline()} which
+performs this and other desired initializations, such as installing
+custom completers (@pxref{Custom Completers}).
+
+@node Custom Functions
+@section Custom Functions
+
+Readline provides many functions for manipulating the text of
+the line, but it isn't possible to anticipate the needs of all
+programs.  This section describes the various functions and variables
+defined within the Readline library which allow a user program to add
+customized functionality to Readline.
+
+Before declaring any functions that customize Readline's behavior, or
+using any functionality Readline provides in other code, an
+application writer should include the file @code{<readline/readline.h>}
+in any file that uses Readline's features.  Since some of the definitions
+in @code{readline.h} use the @code{stdio} library, the file
+@code{<stdio.h>} should be included before @code{readline.h}.
+
+@code{readline.h} defines a C preprocessor variable that should
+be treated as an integer, @code{RL_READLINE_VERSION}, which may
+be used to conditionally compile application code depending on
+the installed Readline version.  The value is a hexadecimal
+encoding of the major and minor version numbers of the library,
+of the form 0x@var{MMmm}.  @var{MM} is the two-digit major
+version number; @var{mm} is the two-digit minor version number. 
+For Readline 4.2, for example, the value of
+@code{RL_READLINE_VERSION} would be @code{0x0402}. 
+
+@menu
+* Readline Typedefs::  C declarations to make code readable.
+* Function Writing::   Variables and calling conventions.
+@end menu
+
+@node Readline Typedefs
+@subsection Readline Typedefs
+
+For readabilty, we declare a number of new object types, all pointers
+to functions.
+
+The reason for declaring these new types is to make it easier to write
+code describing pointers to C functions with appropriately prototyped
+arguments and return values.
+
+For instance, say we want to declare a variable @var{func} as a pointer
+to a function which takes two @code{int} arguments and returns an
+@code{int} (this is the type of all of the Readline bindable functions).
+Instead of the classic C declaration
+
+@code{int (*func)();}
+
+@noindent
+or the ANSI-C style declaration
+
+@code{int (*func)(int, int);}
+
+@noindent
+we may write
+
+@code{rl_command_func_t *func;}
+
+The full list of function pointer types available is
+
+@table @code
+@item typedef int rl_command_func_t (int, int);
+
+@item typedef char *rl_compentry_func_t (const char *, int);
+
+@item typedef char **rl_completion_func_t (const char *, int, int);
+
+@item typedef char *rl_quote_func_t (char *, int, char *);
+
+@item typedef char *rl_dequote_func_t (char *, int);
+
+@item typedef int rl_compignore_func_t (char **);
+
+@item typedef void rl_compdisp_func_t (char **, int, int);
+
+@item typedef int rl_hook_func_t (void);
+
+@item typedef int rl_getc_func_t (FILE *);
+
+@item typedef int rl_linebuf_func_t (char *, int);
+
+@item typedef int rl_intfunc_t (int);
+@item #define rl_ivoidfunc_t rl_hook_func_t
+@item typedef int rl_icpfunc_t (char *);
+@item typedef int rl_icppfunc_t (char **);
+
+@item typedef void rl_voidfunc_t (void);
+@item typedef void rl_vintfunc_t (int);
+@item typedef void rl_vcpfunc_t (char *);
+@item typedef void rl_vcppfunc_t (char **);
+
+@end table
+
+@node Function Writing
+@subsection Writing a New Function
+
+In order to write new functions for Readline, you need to know the
+calling conventions for keyboard-invoked functions, and the names of the
+variables that describe the current state of the line read so far.
+
+The calling sequence for a command @code{foo} looks like
+
+@example
+@code{int foo (int count, int key)}
+@end example
+
+@noindent
+where @var{count} is the numeric argument (or 1 if defaulted) and
+@var{key} is the key that invoked this function.
+
+It is completely up to the function as to what should be done with the
+numeric argument.  Some functions use it as a repeat count, some
+as a flag, and others to choose alternate behavior (refreshing the current
+line as opposed to refreshing the screen, for example).  Some choose to
+ignore it.  In general, if a
+function uses the numeric argument as a repeat count, it should be able
+to do something useful with both negative and positive arguments.
+At the very least, it should be aware that it can be passed a
+negative argument.
+
+A command function should return 0 if its action completes successfully,
+and a non-zero value if some error occurs.
+This is the convention obeyed by all of the builtin Readline bindable
+command functions.
+
+@node Readline Variables
+@section Readline Variables
+
+These variables are available to function writers.
+
+@deftypevar {char *} rl_line_buffer
+This is the line gathered so far.  You are welcome to modify the
+contents of the line, but see @ref{Allowing Undoing}.  The
+function @code{rl_extend_line_buffer} is available to increase
+the memory allocated to @code{rl_line_buffer}.
+@end deftypevar
+
+@deftypevar int rl_point
+The offset of the current cursor position in @code{rl_line_buffer}
+(the @emph{point}).
+@end deftypevar
+
+@deftypevar int rl_end
+The number of characters present in @code{rl_line_buffer}.  When
+@code{rl_point} is at the end of the line, @code{rl_point} and
+@code{rl_end} are equal.
+@end deftypevar
+
+@deftypevar int rl_mark
+The @var{mark} (saved position) in the current line.  If set, the mark
+and point define a @emph{region}.
+@end deftypevar
+
+@deftypevar int rl_done
+Setting this to a non-zero value causes Readline to return the current
+line immediately.
+@end deftypevar
+
+@deftypevar int rl_num_chars_to_read
+Setting this to a positive value before calling @code{readline()} causes
+Readline to return after accepting that many characters, rather
+than reading up to a character bound to @code{accept-line}.
+@end deftypevar
+
+@deftypevar int rl_pending_input
+Setting this to a value makes it the next keystroke read.  This is a
+way to stuff a single character into the input stream.
+@end deftypevar
+
+@deftypevar int rl_dispatching
+Set to a non-zero value if a function is being called from a key binding;
+zero otherwise.  Application functions can test this to discover whether
+they were called directly or by Readline's dispatching mechanism.
+@end deftypevar
+
+@deftypevar int rl_erase_empty_line
+Setting this to a non-zero value causes Readline to completely erase
+the current line, including any prompt, any time a newline is typed as
+the only character on an otherwise-empty line.  The cursor is moved to
+the beginning of the newly-blank line.
+@end deftypevar
+
+@deftypevar {char *} rl_prompt
+The prompt Readline uses.  This is set from the argument to
+@code{readline()}, and should not be assigned to directly.
+The @code{rl_set_prompt()} function (@pxref{Redisplay}) may
+be used to modify the prompt string after calling @code{readline()}.
+@end deftypevar
+
+@deftypevar {char *} rl_display_prompt
+The string displayed as the prompt.  This is usually identical to
+@var{rl_prompt}, but may be changed temporarily by functions that
+use the prompt string as a message area, such as incremental search.
+@end deftypevar
+
+@deftypevar int rl_already_prompted
+If an application wishes to display the prompt itself, rather than have
+Readline do it the first time @code{readline()} is called, it should set
+this variable to a non-zero value after displaying the prompt.
+The prompt must also be passed as the argument to @code{readline()} so
+the redisplay functions can update the display properly.
+The calling application is responsible for managing the value; Readline
+never sets it.
+@end deftypevar
+
+@deftypevar {const char *} rl_library_version
+The version number of this revision of the library.
+@end deftypevar
+
+@deftypevar int rl_readline_version
+An integer encoding the current version of the library.  The encoding is
+of the form 0x@var{MMmm}, where @var{MM} is the two-digit major version
+number, and @var{mm} is the two-digit minor version number.
+For example, for Readline-4.2, @code{rl_readline_version} would have the
+value 0x0402.
+@end deftypevar
+
+@deftypevar {int} rl_gnu_readline_p
+Always set to 1, denoting that this is @sc{gnu} readline rather than some
+emulation.
+@end deftypevar
+
+@deftypevar {const char *} rl_terminal_name
+The terminal type, used for initialization.  If not set by the application,
+Readline sets this to the value of the @env{TERM} environment variable
+the first time it is called.
+@end deftypevar
+
+@deftypevar {const char *} rl_readline_name
+This variable is set to a unique name by each application using Readline.
+The value allows conditional parsing of the inputrc file
+(@pxref{Conditional Init Constructs}).
+@end deftypevar
+
+@deftypevar {FILE *} rl_instream
+The stdio stream from which Readline reads input.
+If @code{NULL}, Readline defaults to @var{stdin}.
+@end deftypevar
+
+@deftypevar {FILE *} rl_outstream
+The stdio stream to which Readline performs output.
+If @code{NULL}, Readline defaults to @var{stdout}.
+@end deftypevar
+
+@deftypevar int rl_prefer_env_winsize
+If non-zero, Readline gives values found in the @env{LINES} and
+@env{COLUMNS} environment variables greater precedence than values fetched
+from the kernel when computing the screen dimensions.
+@end deftypevar
+
+@deftypevar {rl_command_func_t *} rl_last_func
+The address of the last command function Readline executed.  May be used to
+test whether or not a function is being executed twice in succession, for
+example.
+@end deftypevar
+
+@deftypevar {rl_hook_func_t *} rl_startup_hook
+If non-zero, this is the address of a function to call just
+before @code{readline} prints the first prompt.
+@end deftypevar
+
+@deftypevar {rl_hook_func_t *} rl_pre_input_hook
+If non-zero, this is the address of a function to call after
+the first prompt has been printed and just before @code{readline}
+starts reading input characters.
+@end deftypevar
+
+@deftypevar {rl_hook_func_t *} rl_event_hook
+If non-zero, this is the address of a function to call periodically
+when Readline is waiting for terminal input.
+By default, this will be called at most ten times a second if there
+is no keyboard input.
+@end deftypevar
+
+@deftypevar {rl_getc_func_t *} rl_getc_function
+If non-zero, Readline will call indirectly through this pointer
+to get a character from the input stream.  By default, it is set to
+@code{rl_getc}, the default Readline character input function
+(@pxref{Character Input}).
+@end deftypevar
+
+@deftypevar {rl_voidfunc_t *} rl_redisplay_function
+If non-zero, Readline will call indirectly through this pointer
+to update the display with the current contents of the editing buffer.
+By default, it is set to @code{rl_redisplay}, the default Readline
+redisplay function (@pxref{Redisplay}).
+@end deftypevar
+
+@deftypevar {rl_vintfunc_t *} rl_prep_term_function
+If non-zero, Readline will call indirectly through this pointer
+to initialize the terminal.  The function takes a single argument, an
+@code{int} flag that says whether or not to use eight-bit characters.
+By default, this is set to @code{rl_prep_terminal}
+(@pxref{Terminal Management}).
+@end deftypevar
+
+@deftypevar {rl_voidfunc_t *} rl_deprep_term_function
+If non-zero, Readline will call indirectly through this pointer
+to reset the terminal.  This function should undo the effects of
+@code{rl_prep_term_function}.
+By default, this is set to @code{rl_deprep_terminal}
+(@pxref{Terminal Management}).
+@end deftypevar
+
+@deftypevar {Keymap} rl_executing_keymap
+This variable is set to the keymap (@pxref{Keymaps}) in which the
+currently executing readline function was found.
+@end deftypevar 
+
+@deftypevar {Keymap} rl_binding_keymap
+This variable is set to the keymap (@pxref{Keymaps}) in which the
+last key binding occurred.
+@end deftypevar 
+
+@deftypevar {char *} rl_executing_macro
+This variable is set to the text of any currently-executing macro.
+@end deftypevar
+
+@deftypevar {int} rl_readline_state
+A variable with bit values that encapsulate the current Readline state.
+A bit is set with the @code{RL_SETSTATE} macro, and unset with the
+@code{RL_UNSETSTATE} macro.  Use the @code{RL_ISSTATE} macro to test
+whether a particular state bit is set.  Current state bits include:
+
+@table @code
+@item RL_STATE_NONE
+Readline has not yet been called, nor has it begun to intialize.
+@item RL_STATE_INITIALIZING
+Readline is initializing its internal data structures.
+@item RL_STATE_INITIALIZED
+Readline has completed its initialization.
+@item RL_STATE_TERMPREPPED
+Readline has modified the terminal modes to do its own input and redisplay.
+@item RL_STATE_READCMD
+Readline is reading a command from the keyboard.
+@item RL_STATE_METANEXT
+Readline is reading more input after reading the meta-prefix character.
+@item RL_STATE_DISPATCHING
+Readline is dispatching to a command.
+@item RL_STATE_MOREINPUT
+Readline is reading more input while executing an editing command.
+@item RL_STATE_ISEARCH
+Readline is performing an incremental history search.
+@item RL_STATE_NSEARCH
+Readline is performing a non-incremental history search.
+@item RL_STATE_SEARCH
+Readline is searching backward or forward through the history for a string.
+@item RL_STATE_NUMERICARG
+Readline is reading a numeric argument.
+@item RL_STATE_MACROINPUT
+Readline is currently getting its input from a previously-defined keyboard
+macro.
+@item RL_STATE_MACRODEF
+Readline is currently reading characters defining a keyboard macro.
+@item RL_STATE_OVERWRITE
+Readline is in overwrite mode.
+@item RL_STATE_COMPLETING
+Readline is performing word completion.
+@item RL_STATE_SIGHANDLER
+Readline is currently executing the readline signal handler.
+@item RL_STATE_UNDOING
+Readline is performing an undo.
+@item RL_STATE_DONE
+Readline has read a key sequence bound to @code{accept-line}
+and is about to return the line to the caller.
+@end table
+
+@end deftypevar
+
+@deftypevar {int} rl_explicit_arg
+Set to a non-zero value if an explicit numeric argument was specified by
+the user.  Only valid in a bindable command function.
+@end deftypevar
+
+@deftypevar {int} rl_numeric_arg
+Set to the value of any numeric argument explicitly specified by the user
+before executing the current Readline function.  Only valid in a bindable
+command function.
+@end deftypevar
+
+@deftypevar {int} rl_editing_mode
+Set to a value denoting Readline's current editing mode.  A value of
+@var{1} means Readline is currently in emacs mode; @var{0}
+means that vi mode is active.
+@end deftypevar
+
+
+@node Readline Convenience Functions
+@section Readline Convenience Functions
+
+@menu
+* Function Naming::    How to give a function you write a name.
+* Keymaps::            Making keymaps.
+* Binding Keys::       Changing Keymaps.
+* Associating Function Names and Bindings::    Translate function names to
+                                               key sequences.
+* Allowing Undoing::   How to make your functions undoable.
+* Redisplay::          Functions to control line display.
+* Modifying Text::     Functions to modify @code{rl_line_buffer}.
+* Character Input::    Functions to read keyboard input.
+* Terminal Management::        Functions to manage terminal settings.
+* Utility Functions::  Generally useful functions and hooks.
+* Miscellaneous Functions::    Functions that don't fall into any category.
+* Alternate Interface::        Using Readline in a `callback' fashion.
+* A Readline Example::         An example Readline function.
+@end menu
+
+@node Function Naming
+@subsection Naming a Function
+
+The user can dynamically change the bindings of keys while using
+Readline.  This is done by representing the function with a descriptive
+name.  The user is able to type the descriptive name when referring to
+the function.  Thus, in an init file, one might find
+
+@example
+Meta-Rubout:   backward-kill-word
+@end example
+
+This binds the keystroke @key{Meta-Rubout} to the function
+@emph{descriptively} named @code{backward-kill-word}.  You, as the
+programmer, should bind the functions you write to descriptive names as
+well.  Readline provides a function for doing that:
+
+@deftypefun int rl_add_defun (const char *name, rl_command_func_t *function, int key)
+Add @var{name} to the list of named functions.  Make @var{function} be
+the function that gets called.  If @var{key} is not -1, then bind it to
+@var{function} using @code{rl_bind_key()}.
+@end deftypefun
+
+Using this function alone is sufficient for most applications.
+It is the recommended way to add a few functions to the default
+functions that Readline has built in.
+If you need to do something other than adding a function to Readline,
+you may need to use the underlying functions described below.
+
+@node Keymaps
+@subsection Selecting a Keymap
+
+Key bindings take place on a @dfn{keymap}.  The keymap is the
+association between the keys that the user types and the functions that
+get run.  You can make your own keymaps, copy existing keymaps, and tell
+Readline which keymap to use.
+
+@deftypefun Keymap rl_make_bare_keymap (void)
+Returns a new, empty keymap.  The space for the keymap is allocated with
+@code{malloc()}; the caller should free it by calling
+@code{rl_discard_keymap()} when done.
+@end deftypefun
+
+@deftypefun Keymap rl_copy_keymap (Keymap map)
+Return a new keymap which is a copy of @var{map}.
+@end deftypefun
+
+@deftypefun Keymap rl_make_keymap (void)
+Return a new keymap with the printing characters bound to rl_insert,
+the lowercase Meta characters bound to run their equivalents, and
+the Meta digits bound to produce numeric arguments.
+@end deftypefun
+
+@deftypefun void rl_discard_keymap (Keymap keymap)
+Free the storage associated with @var{keymap}.
+@end deftypefun
+
+Readline has several internal keymaps.  These functions allow you to
+change which keymap is active.
+
+@deftypefun Keymap rl_get_keymap (void)
+Returns the currently active keymap.
+@end deftypefun
+
+@deftypefun void rl_set_keymap (Keymap keymap)
+Makes @var{keymap} the currently active keymap.
+@end deftypefun
+
+@deftypefun Keymap rl_get_keymap_by_name (const char *name)
+Return the keymap matching @var{name}.  @var{name} is one which would
+be supplied in a @code{set keymap} inputrc line (@pxref{Readline Init File}).
+@end deftypefun
+
+@deftypefun {char *} rl_get_keymap_name (Keymap keymap)
+Return the name matching @var{keymap}.  @var{name} is one which would
+be supplied in a @code{set keymap} inputrc line (@pxref{Readline Init File}).
+@end deftypefun
+
+@node Binding Keys
+@subsection Binding Keys
+
+Key sequences are associate with functions through the keymap.
+Readline has several internal keymaps: @code{emacs_standard_keymap},
+@code{emacs_meta_keymap}, @code{emacs_ctlx_keymap},
+@code{vi_movement_keymap}, and @code{vi_insertion_keymap}.
+@code{emacs_standard_keymap} is the default, and the examples in
+this manual assume that.
+
+Since @code{readline()} installs a set of default key bindings the first
+time it is called, there is always the danger that a custom binding
+installed before the first call to @code{readline()} will be overridden.
+An alternate mechanism is to install custom key bindings in an
+initialization function assigned to the @code{rl_startup_hook} variable
+(@pxref{Readline Variables}).
+
+These functions manage key bindings.
+
+@deftypefun int rl_bind_key (int key, rl_command_func_t *function)
+Binds @var{key} to @var{function} in the currently active keymap.
+Returns non-zero in the case of an invalid @var{key}.
+@end deftypefun
+
+@deftypefun int rl_bind_key_in_map (int key, rl_command_func_t *function, Keymap map)
+Bind @var{key} to @var{function} in @var{map}.
+Returns non-zero in the case of an invalid @var{key}.
+@end deftypefun
+
+@deftypefun int rl_bind_key_if_unbound (int key, rl_command_func_t *function)
+Binds @var{key} to @var{function} if it is not already bound in the
+currently active keymap.
+Returns non-zero in the case of an invalid @var{key} or if @var{key} is
+already bound.
+@end deftypefun
+
+@deftypefun int rl_bind_key_if_unbound_in_map (int key, rl_command_func_t *function, Keymap map)
+Binds @var{key} to @var{function} if it is not already bound in @var{map}.
+Returns non-zero in the case of an invalid @var{key} or if @var{key} is
+already bound.
+@end deftypefun
+
+@deftypefun int rl_unbind_key (int key)
+Bind @var{key} to the null function in the currently active keymap.
+Returns non-zero in case of error.
+@end deftypefun
+
+@deftypefun int rl_unbind_key_in_map (int key, Keymap map)
+Bind @var{key} to the null function in @var{map}.
+Returns non-zero in case of error.
+@end deftypefun
+
+@deftypefun int rl_unbind_function_in_map (rl_command_func_t *function, Keymap map)
+Unbind all keys that execute @var{function} in @var{map}.
+@end deftypefun
+
+@deftypefun int rl_unbind_command_in_map (const char *command, Keymap map)
+Unbind all keys that are bound to @var{command} in @var{map}.
+@end deftypefun
+
+@deftypefun int rl_bind_keyseq (const char *keyseq, rl_command_func_t *function)
+Bind the key sequence represented by the string @var{keyseq} to the function
+@var{function}, beginning in the current keymap.
+This makes new keymaps as necessary.
+The return value is non-zero if @var{keyseq} is invalid.
+@end deftypefun
+
+@deftypefun int rl_bind_keyseq_in_map (const char *keyseq, rl_command_func_t *function, Keymap map)
+Bind the key sequence represented by the string @var{keyseq} to the function
+@var{function}.  This makes new keymaps as necessary.
+Initial bindings are performed in @var{map}.
+The return value is non-zero if @var{keyseq} is invalid.
+@end deftypefun
+
+@deftypefun int rl_set_key (const char *keyseq, rl_command_func_t *function, Keymap map)
+Equivalent to @code{rl_bind_keyseq_in_map}.
+@end deftypefun
+
+@deftypefun int rl_bind_keyseq_if_unbound (const char *keyseq, rl_command_func_t *function)
+Binds @var{keyseq} to @var{function} if it is not already bound in the
+currently active keymap.
+Returns non-zero in the case of an invalid @var{keyseq} or if @var{keyseq} is
+already bound.
+@end deftypefun
+
+@deftypefun int rl_bind_keyseq_if_unbound_in_map (const char *keyseq, rl_command_func_t *function, Keymap map)
+Binds @var{keyseq} to @var{function} if it is not already bound in @var{map}.
+Returns non-zero in the case of an invalid @var{keyseq} or if @var{keyseq} is
+already bound.
+@end deftypefun
+
+@deftypefun int rl_generic_bind (int type, const char *keyseq, char *data, Keymap map)
+Bind the key sequence represented by the string @var{keyseq} to the arbitrary
+pointer @var{data}.  @var{type} says what kind of data is pointed to by
+@var{data}; this can be a function (@code{ISFUNC}), a macro
+(@code{ISMACR}), or a keymap (@code{ISKMAP}).  This makes new keymaps as
+necessary.  The initial keymap in which to do bindings is @var{map}.
+@end deftypefun
+
+@deftypefun int rl_parse_and_bind (char *line)
+Parse @var{line} as if it had been read from the @code{inputrc} file and
+perform any key bindings and variable assignments found
+(@pxref{Readline Init File}).
+@end deftypefun
+
+@deftypefun int rl_read_init_file (const char *filename)
+Read keybindings and variable assignments from @var{filename}
+(@pxref{Readline Init File}).
+@end deftypefun
+
+@node Associating Function Names and Bindings
+@subsection Associating Function Names and Bindings
+
+These functions allow you to find out what keys invoke named functions
+and the functions invoked by a particular key sequence.  You may also
+associate a new function name with an arbitrary function.
+
+@deftypefun {rl_command_func_t *} rl_named_function (const char *name)
+Return the function with name @var{name}.
+@end deftypefun
+
+@deftypefun {rl_command_func_t *} rl_function_of_keyseq (const char *keyseq, Keymap map, int *type)
+Return the function invoked by @var{keyseq} in keymap @var{map}.
+If @var{map} is @code{NULL}, the current keymap is used.  If @var{type} is
+not @code{NULL}, the type of the object is returned in the @code{int} variable
+it points to (one of @code{ISFUNC}, @code{ISKMAP}, or @code{ISMACR}).
+@end deftypefun
+
+@deftypefun {char **} rl_invoking_keyseqs (rl_command_func_t *function)
+Return an array of strings representing the key sequences used to
+invoke @var{function} in the current keymap.
+@end deftypefun
+
+@deftypefun {char **} rl_invoking_keyseqs_in_map (rl_command_func_t *function, Keymap map)
+Return an array of strings representing the key sequences used to
+invoke @var{function} in the keymap @var{map}.
+@end deftypefun
+
+@deftypefun void rl_function_dumper (int readable)
+Print the readline function names and the key sequences currently
+bound to them to @code{rl_outstream}.  If @var{readable} is non-zero,
+the list is formatted in such a way that it can be made part of an
+@code{inputrc} file and re-read.
+@end deftypefun
+
+@deftypefun void rl_list_funmap_names (void)
+Print the names of all bindable Readline functions to @code{rl_outstream}.
+@end deftypefun
+
+@deftypefun {const char **} rl_funmap_names (void)
+Return a NULL terminated array of known function names.  The array is
+sorted.  The array itself is allocated, but not the strings inside.  You
+should free the array, but not the pointers, using @code{free} or
+@code{rl_free} when you are done.
+@end deftypefun
+
+@deftypefun int rl_add_funmap_entry (const char *name, rl_command_func_t *function)
+Add @var{name} to the list of bindable Readline command names, and make
+@var{function} the function to be called when @var{name} is invoked.
+@end deftypefun
+
+@node Allowing Undoing
+@subsection Allowing Undoing
+
+Supporting the undo command is a painless thing, and makes your
+functions much more useful.  It is certainly easy to try
+something if you know you can undo it.
+
+If your function simply inserts text once, or deletes text once, and
+uses @code{rl_insert_text()} or @code{rl_delete_text()} to do it, then
+undoing is already done for you automatically.
+
+If you do multiple insertions or multiple deletions, or any combination
+of these operations, you should group them together into one operation.
+This is done with @code{rl_begin_undo_group()} and
+@code{rl_end_undo_group()}.
+
+The types of events that can be undone are:
+
+@smallexample
+enum undo_code @{ UNDO_DELETE, UNDO_INSERT, UNDO_BEGIN, UNDO_END @}; 
+@end smallexample
+
+Notice that @code{UNDO_DELETE} means to insert some text, and
+@code{UNDO_INSERT} means to delete some text.  That is, the undo code
+tells what to undo, not how to undo it.  @code{UNDO_BEGIN} and
+@code{UNDO_END} are tags added by @code{rl_begin_undo_group()} and
+@code{rl_end_undo_group()}.
+
+@deftypefun int rl_begin_undo_group (void)
+Begins saving undo information in a group construct.  The undo
+information usually comes from calls to @code{rl_insert_text()} and
+@code{rl_delete_text()}, but could be the result of calls to
+@code{rl_add_undo()}.
+@end deftypefun
+
+@deftypefun int rl_end_undo_group (void)
+Closes the current undo group started with @code{rl_begin_undo_group
+()}.  There should be one call to @code{rl_end_undo_group()}
+for each call to @code{rl_begin_undo_group()}.
+@end deftypefun
+
+@deftypefun void rl_add_undo (enum undo_code what, int start, int end, char *text)
+Remember how to undo an event (according to @var{what}).  The affected
+text runs from @var{start} to @var{end}, and encompasses @var{text}.
+@end deftypefun
+
+@deftypefun void rl_free_undo_list (void)
+Free the existing undo list.
+@end deftypefun
+
+@deftypefun int rl_do_undo (void)
+Undo the first thing on the undo list.  Returns @code{0} if there was
+nothing to undo, non-zero if something was undone.
+@end deftypefun
+
+Finally, if you neither insert nor delete text, but directly modify the
+existing text (e.g., change its case), call @code{rl_modifying()}
+once, just before you modify the text.  You must supply the indices of
+the text range that you are going to modify.
+
+@deftypefun int rl_modifying (int start, int end)
+Tell Readline to save the text between @var{start} and @var{end} as a
+single undo unit.  It is assumed that you will subsequently modify
+that text.
+@end deftypefun
+
+@node Redisplay
+@subsection Redisplay
+
+@deftypefun void rl_redisplay (void)
+Change what's displayed on the screen to reflect the current contents
+of @code{rl_line_buffer}.
+@end deftypefun
+
+@deftypefun int rl_forced_update_display (void)
+Force the line to be updated and redisplayed, whether or not
+Readline thinks the screen display is correct.
+@end deftypefun
+
+@deftypefun int rl_on_new_line (void)
+Tell the update functions that we have moved onto a new (empty) line,
+usually after ouputting a newline.
+@end deftypefun
+
+@deftypefun int rl_on_new_line_with_prompt (void)
+Tell the update functions that we have moved onto a new line, with
+@var{rl_prompt} already displayed.
+This could be used by applications that want to output the prompt string
+themselves, but still need Readline to know the prompt string length for
+redisplay.
+It should be used after setting @var{rl_already_prompted}.
+@end deftypefun
+
+@deftypefun int rl_reset_line_state (void)
+Reset the display state to a clean state and redisplay the current line
+starting on a new line.
+@end deftypefun
+
+@deftypefun int rl_crlf (void)
+Move the cursor to the start of the next screen line.
+@end deftypefun
+
+@deftypefun int rl_show_char (int c)
+Display character @var{c} on @code{rl_outstream}.
+If Readline has not been set to display meta characters directly, this
+will convert meta characters to a meta-prefixed key sequence.
+This is intended for use by applications which wish to do their own
+redisplay.
+@end deftypefun
+
+@deftypefun int rl_message (const char *, @dots{})
+The arguments are a format string as would be supplied to @code{printf},
+possibly containing conversion specifications such as @samp{%d}, and
+any additional arguments necessary to satisfy the conversion specifications.
+The resulting string is displayed in the @dfn{echo area}.  The echo area
+is also used to display numeric arguments and search strings.
+You should call @code{rl_save_prompt} to save the prompt information
+before calling this function.
+@end deftypefun
+
+@deftypefun int rl_clear_message (void)
+Clear the message in the echo area.  If the prompt was saved with a call to
+@code{rl_save_prompt} before the last call to @code{rl_message},
+call @code{rl_restore_prompt} before calling this function.
+@end deftypefun
+
+@deftypefun void rl_save_prompt (void)
+Save the local Readline prompt display state in preparation for
+displaying a new message in the message area with @code{rl_message()}.
+@end deftypefun
+
+@deftypefun void rl_restore_prompt (void)
+Restore the local Readline prompt display state saved by the most
+recent call to @code{rl_save_prompt}.
+if @code{rl_save_prompt} was called to save the prompt before a call
+to @code{rl_message}, this function should be called before the
+corresponding call to @code{rl_clear_message}.
+@end deftypefun
+
+@deftypefun int rl_expand_prompt (char *prompt)
+Expand any special character sequences in @var{prompt} and set up the
+local Readline prompt redisplay variables.
+This function is called by @code{readline()}.  It may also be called to
+expand the primary prompt if the @code{rl_on_new_line_with_prompt()}
+function or @code{rl_already_prompted} variable is used.
+It returns the number of visible characters on the last line of the
+(possibly multi-line) prompt.
+Applications may indicate that the prompt contains characters that take
+up no physical screen space when displayed by bracketing a sequence of
+such characters with the special markers @code{RL_PROMPT_START_IGNORE}
+and @code{RL_PROMPT_END_IGNORE} (declared in @file{readline.h}.  This may
+be used to embed terminal-specific escape sequences in prompts.
+@end deftypefun
+
+@deftypefun int rl_set_prompt (const char *prompt)
+Make Readline use @var{prompt} for subsequent redisplay.  This calls
+@code{rl_expand_prompt()} to expand the prompt and sets @code{rl_prompt}
+to the result.
+@end deftypefun
+
+@node Modifying Text
+@subsection Modifying Text
+
+@deftypefun int rl_insert_text (const char *text)
+Insert @var{text} into the line at the current cursor position.
+Returns the number of characters inserted.
+@end deftypefun
+
+@deftypefun int rl_delete_text (int start, int end)
+Delete the text between @var{start} and @var{end} in the current line.
+Returns the number of characters deleted.
+@end deftypefun
+
+@deftypefun {char *} rl_copy_text (int start, int end)
+Return a copy of the text between @var{start} and @var{end} in
+the current line.
+@end deftypefun
+
+@deftypefun int rl_kill_text (int start, int end)
+Copy the text between @var{start} and @var{end} in the current line
+to the kill ring, appending or prepending to the last kill if the
+last command was a kill command.  The text is deleted.
+If @var{start} is less than @var{end},
+the text is appended, otherwise prepended.  If the last command was
+not a kill, a new kill ring slot is used.
+@end deftypefun
+
+@deftypefun int rl_push_macro_input (char *macro)
+Cause @var{macro} to be inserted into the line, as if it had been invoked
+by a key bound to a macro.  Not especially useful; use
+@code{rl_insert_text()} instead.
+@end deftypefun
+
+@node Character Input
+@subsection Character Input
+
+@deftypefun int rl_read_key (void)
+Return the next character available from Readline's current input stream.
+This handles input inserted into
+the input stream via @var{rl_pending_input} (@pxref{Readline Variables})
+and @code{rl_stuff_char()}, macros, and characters read from the keyboard.
+While waiting for input, this function will call any function assigned to
+the @code{rl_event_hook} variable.
+@end deftypefun
+
+@deftypefun int rl_getc (FILE *stream)
+Return the next character available from @var{stream}, which is assumed to
+be the keyboard.
+@end deftypefun
+
+@deftypefun int rl_stuff_char (int c)
+Insert @var{c} into the Readline input stream.  It will be "read"
+before Readline attempts to read characters from the terminal with
+@code{rl_read_key()}.  Up to 512 characters may be pushed back.
+@code{rl_stuff_char} returns 1 if the character was successfully inserted;
+0 otherwise.
+@end deftypefun
+
+@deftypefun int rl_execute_next (int c)
+Make @var{c} be the next command to be executed when @code{rl_read_key()}
+is called.  This sets @var{rl_pending_input}.
+@end deftypefun
+
+@deftypefun int rl_clear_pending_input (void)
+Unset @var{rl_pending_input}, effectively negating the effect of any
+previous call to @code{rl_execute_next()}.  This works only if the
+pending input has not already been read with @code{rl_read_key()}.
+@end deftypefun
+
+@deftypefun int rl_set_keyboard_input_timeout (int u)
+While waiting for keyboard input in @code{rl_read_key()}, Readline will
+wait for @var{u} microseconds for input before calling any function
+assigned to @code{rl_event_hook}.  @var{u} must be greater than or equal
+to zero (a zero-length timeout is equivalent to a poll).
+The default waiting period is one-tenth of a second.
+Returns the old timeout value.
+@end deftypefun
+
+@node Terminal Management
+@subsection Terminal Management
+
+@deftypefun void rl_prep_terminal (int meta_flag)
+Modify the terminal settings for Readline's use, so @code{readline()}
+can read a single character at a time from the keyboard.
+The @var{meta_flag} argument should be non-zero if Readline should
+read eight-bit input.
+@end deftypefun
+
+@deftypefun void rl_deprep_terminal (void)
+Undo the effects of @code{rl_prep_terminal()}, leaving the terminal in
+the state in which it was before the most recent call to
+@code{rl_prep_terminal()}.
+@end deftypefun
+
+@deftypefun void rl_tty_set_default_bindings (Keymap kmap)
+Read the operating system's terminal editing characters (as would be
+displayed by @code{stty}) to their Readline equivalents.
+The bindings are performed in @var{kmap}.
+@end deftypefun
+
+@deftypefun void rl_tty_unset_default_bindings (Keymap kmap)
+Reset the bindings manipulated by @code{rl_tty_set_default_bindings} so
+that the terminal editing characters are bound to @code{rl_insert}.
+The bindings are performed in @var{kmap}.
+@end deftypefun
+
+@deftypefun int rl_reset_terminal (const char *terminal_name)
+Reinitialize Readline's idea of the terminal settings using
+@var{terminal_name} as the terminal type (e.g., @code{vt100}).
+If @var{terminal_name} is @code{NULL}, the value of the @code{TERM}
+environment variable is used.
+@end deftypefun
+
+@node Utility Functions
+@subsection Utility Functions
+
+@deftypefun void rl_free (void *mem)
+Deallocate the memory pointed to by @var{mem}.  @var{mem} must have been
+allocated by @code{malloc}.
+@end
+
+@deftypefun void rl_replace_line (const char *text, int clear_undo)
+Replace the contents of @code{rl_line_buffer} with @var{text}.
+The point and mark are preserved, if possible.
+If @var{clear_undo} is non-zero, the undo list associated with the
+current line is cleared.
+@end deftypefun
+
+@deftypefun int rl_extend_line_buffer (int len)
+Ensure that @code{rl_line_buffer} has enough space to hold @var{len}
+characters, possibly reallocating it if necessary.
+@end deftypefun
+
+@deftypefun int rl_initialize (void)
+Initialize or re-initialize Readline's internal state.
+It's not strictly necessary to call this; @code{readline()} calls it before
+reading any input.
+@end deftypefun
+
+@deftypefun int rl_ding (void)
+Ring the terminal bell, obeying the setting of @code{bell-style}.
+@end deftypefun
+
+@deftypefun int rl_alphabetic (int c)
+Return 1 if @var{c} is an alphabetic character.
+@end deftypefun
+
+@deftypefun void rl_display_match_list (char **matches, int len, int max)
+A convenience function for displaying a list of strings in
+columnar format on Readline's output stream.  @code{matches} is the list
+of strings, in argv format, such as a list of completion matches.
+@code{len} is the number of strings in @code{matches}, and @code{max}
+is the length of the longest string in @code{matches}.  This function uses
+the setting of @code{print-completions-horizontally} to select how the
+matches are displayed (@pxref{Readline Init File Syntax}).
+@end deftypefun
+
+The following are implemented as macros, defined in @code{chardefs.h}.
+Applications should refrain from using them.
+
+@deftypefun int _rl_uppercase_p (int c)
+Return 1 if @var{c} is an uppercase alphabetic character.
+@end deftypefun
+
+@deftypefun int _rl_lowercase_p (int c)
+Return 1 if @var{c} is a lowercase alphabetic character.
+@end deftypefun
+
+@deftypefun int _rl_digit_p (int c)
+Return 1 if @var{c} is a numeric character.
+@end deftypefun
+
+@deftypefun int _rl_to_upper (int c)
+If @var{c} is a lowercase alphabetic character, return the corresponding
+uppercase character.
+@end deftypefun
+
+@deftypefun int _rl_to_lower (int c)
+If @var{c} is an uppercase alphabetic character, return the corresponding
+lowercase character.
+@end deftypefun
+
+@deftypefun int _rl_digit_value (int c)
+If @var{c} is a number, return the value it represents.
+@end deftypefun
+
+@node Miscellaneous Functions
+@subsection Miscellaneous Functions
+
+@deftypefun int rl_macro_bind (const char *keyseq, const char *macro, Keymap map)
+Bind the key sequence @var{keyseq} to invoke the macro @var{macro}.
+The binding is performed in @var{map}.  When @var{keyseq} is invoked, the
+@var{macro} will be inserted into the line.  This function is deprecated;
+use @code{rl_generic_bind()} instead.
+@end deftypefun
+
+@deftypefun void rl_macro_dumper (int readable)
+Print the key sequences bound to macros and their values, using
+the current keymap, to @code{rl_outstream}.
+If @var{readable} is non-zero, the list is formatted in such a way
+that it can be made part of an @code{inputrc} file and re-read.
+@end deftypefun
+
+@deftypefun int rl_variable_bind (const char *variable, const char *value)
+Make the Readline variable @var{variable} have @var{value}.
+This behaves as if the readline command
+@samp{set @var{variable} @var{value}} had been executed in an @code{inputrc}
+file (@pxref{Readline Init File Syntax}).
+@end deftypefun
+
+@deftypefun {char *} rl_variable_value (const char *variable)
+Return a string representing the value of the Readline variable @var{variable}.
+For boolean variables, this string is either @samp{on} or @samp{off}.
+@end deftypefun
+
+@deftypefun void rl_variable_dumper (int readable)
+Print the readline variable names and their current values
+to @code{rl_outstream}.
+If @var{readable} is non-zero, the list is formatted in such a way
+that it can be made part of an @code{inputrc} file and re-read.
+@end deftypefun
+
+@deftypefun int rl_set_paren_blink_timeout (int u)
+Set the time interval (in microseconds) that Readline waits when showing
+a balancing character when @code{blink-matching-paren} has been enabled.
+@end deftypefun
+
+@deftypefun {char *} rl_get_termcap (const char *cap)
+Retrieve the string value of the termcap capability @var{cap}.
+Readline fetches the termcap entry for the current terminal name and
+uses those capabilities to move around the screen line and perform other
+terminal-specific operations, like erasing a line.  Readline does not
+use all of a terminal's capabilities, and this function will return
+values for only those capabilities Readline uses.
+@end deftypefun
+
+@node Alternate Interface
+@subsection Alternate Interface
+
+An alternate interface is available to plain @code{readline()}.  Some
+applications need to interleave keyboard I/O with file, device, or
+window system I/O, typically by using a main loop to @code{select()}
+on various file descriptors.  To accomodate this need, readline can
+also be invoked as a `callback' function from an event loop.  There
+are functions available to make this easy.
+
+@deftypefun void rl_callback_handler_install (const char *prompt, rl_vcpfunc_t *lhandler)
+Set up the terminal for readline I/O and display the initial
+expanded value of @var{prompt}.  Save the value of @var{lhandler} to
+use as a function to call when a complete line of input has been entered.
+The function takes the text of the line as an argument.
+@end deftypefun
+
+@deftypefun void rl_callback_read_char (void)
+Whenever an application determines that keyboard input is available, it
+should call @code{rl_callback_read_char()}, which will read the next
+character from the current input source.
+If that character completes the line, @code{rl_callback_read_char} will
+invoke the @var{lhandler} function saved by @code{rl_callback_handler_install}
+to process the line.
+Before calling the @var{lhandler} function, the terminal settings are
+reset to the values they had before calling
+@code{rl_callback_handler_install}.
+If the @var{lhandler} function returns,
+the terminal settings are modified for Readline's use again.
+@code{EOF} is  indicated by calling @var{lhandler} with a
+@code{NULL} line.
+@end deftypefun
+
+@deftypefun void rl_callback_handler_remove (void)
+Restore the terminal to its initial state and remove the line handler.
+This may be called from within a callback as well as independently.
+If the @var{lhandler} installed by @code{rl_callback_handler_install}
+does not exit the program, either this function or the function referred
+to by the value of @code{rl_deprep_term_function} should be called before
+the program exits to reset the terminal settings.
+@end deftypefun
+
+@node A Readline Example
+@subsection A Readline Example
+
+Here is a function which changes lowercase characters to their uppercase
+equivalents, and uppercase characters to lowercase.  If
+this function was bound to @samp{M-c}, then typing @samp{M-c} would
+change the case of the character under point.  Typing @samp{M-1 0 M-c}
+would change the case of the following 10 characters, leaving the cursor on
+the last character changed.
+
+@example
+/* Invert the case of the COUNT following characters. */
+int
+invert_case_line (count, key)
+     int count, key;
+@{
+  register int start, end, i;
+
+  start = rl_point;
+
+  if (rl_point >= rl_end)
+    return (0);
+
+  if (count < 0)
+    @{
+      direction = -1;
+      count = -count;
+    @}
+  else
+    direction = 1;
+      
+  /* Find the end of the range to modify. */
+  end = start + (count * direction);
+
+  /* Force it to be within range. */
+  if (end > rl_end)
+    end = rl_end;
+  else if (end < 0)
+    end = 0;
+
+  if (start == end)
+    return (0);
+
+  if (start > end)
+    @{
+      int temp = start;
+      start = end;
+      end = temp;
+    @}
+
+  /* Tell readline that we are modifying the line,
+     so it will save the undo information. */
+  rl_modifying (start, end);
+
+  for (i = start; i != end; i++)
+    @{
+      if (_rl_uppercase_p (rl_line_buffer[i]))
+        rl_line_buffer[i] = _rl_to_lower (rl_line_buffer[i]);
+      else if (_rl_lowercase_p (rl_line_buffer[i]))
+        rl_line_buffer[i] = _rl_to_upper (rl_line_buffer[i]);
+    @}
+  /* Move point to on top of the last character changed. */
+  rl_point = (direction == 1) ? end - 1 : start;
+  return (0);
+@}
+@end example
+
+@node Readline Signal Handling
+@section Readline Signal Handling
+
+Signals are asynchronous events sent to a process by the Unix kernel,
+sometimes on behalf of another process.  They are intended to indicate
+exceptional events, like a user pressing the interrupt key on his terminal,
+or a network connection being broken.  There is a class of signals that can
+be sent to the process currently reading input from the keyboard.  Since
+Readline changes the terminal attributes when it is called, it needs to
+perform special processing when such a signal is received in order to
+restore the terminal to a sane state, or provide application writers with
+functions to do so manually. 
+
+Readline contains an internal signal handler that is installed for a
+number of signals (@code{SIGINT}, @code{SIGQUIT}, @code{SIGTERM},
+@code{SIGALRM}, @code{SIGTSTP}, @code{SIGTTIN}, and @code{SIGTTOU}).
+When one of these signals is received, the signal handler
+will reset the terminal attributes to those that were in effect before
+@code{readline()} was called, reset the signal handling to what it was
+before @code{readline()} was called, and resend the signal to the calling
+application.
+If and when the calling application's signal handler returns, Readline
+will reinitialize the terminal and continue to accept input.
+When a @code{SIGINT} is received, the Readline signal handler performs
+some additional work, which will cause any partially-entered line to be
+aborted (see the description of @code{rl_free_line_state()} below).
+
+There is an additional Readline signal handler, for @code{SIGWINCH}, which
+the kernel sends to a process whenever the terminal's size changes (for
+example, if a user resizes an @code{xterm}).  The Readline @code{SIGWINCH}
+handler updates Readline's internal screen size information, and then calls
+any @code{SIGWINCH} signal handler the calling application has installed. 
+Readline calls the application's @code{SIGWINCH} signal handler without
+resetting the terminal to its original state.  If the application's signal
+handler does more than update its idea of the terminal size and return (for
+example, a @code{longjmp} back to a main processing loop), it @emph{must}
+call @code{rl_cleanup_after_signal()} (described below), to restore the
+terminal state. 
+
+Readline provides two variables that allow application writers to
+control whether or not it will catch certain signals and act on them
+when they are received.  It is important that applications change the
+values of these variables only when calling @code{readline()}, not in
+a signal handler, so Readline's internal signal state is not corrupted.
+
+@deftypevar int rl_catch_signals
+If this variable is non-zero, Readline will install signal handlers for
+@code{SIGINT}, @code{SIGQUIT}, @code{SIGTERM}, @code{SIGALRM},
+@code{SIGTSTP}, @code{SIGTTIN}, and @code{SIGTTOU}.
+
+The default value of @code{rl_catch_signals} is 1.
+@end deftypevar
+
+@deftypevar int rl_catch_sigwinch
+If this variable is non-zero, Readline will install a signal handler for
+@code{SIGWINCH}.
+
+The default value of @code{rl_catch_sigwinch} is 1.
+@end deftypevar
+
+If an application does not wish to have Readline catch any signals, or
+to handle signals other than those Readline catches (@code{SIGHUP},
+for example), 
+Readline provides convenience functions to do the necessary terminal
+and internal state cleanup upon receipt of a signal.
+
+@deftypefun void rl_cleanup_after_signal (void)
+This function will reset the state of the terminal to what it was before
+@code{readline()} was called, and remove the Readline signal handlers for
+all signals, depending on the values of @code{rl_catch_signals} and
+@code{rl_catch_sigwinch}.
+@end deftypefun
+
+@deftypefun void rl_free_line_state (void)
+This will free any partial state associated with the current input line
+(undo information, any partial history entry, any partially-entered
+keyboard macro, and any partially-entered numeric argument).  This
+should be called before @code{rl_cleanup_after_signal()}.  The
+Readline signal handler for @code{SIGINT} calls this to abort the
+current input line.
+@end deftypefun
+
+@deftypefun void rl_reset_after_signal (void)
+This will reinitialize the terminal and reinstall any Readline signal
+handlers, depending on the values of @code{rl_catch_signals} and
+@code{rl_catch_sigwinch}.
+@end deftypefun
+
+If an application does not wish Readline to catch @code{SIGWINCH}, it may
+call @code{rl_resize_terminal()} or @code{rl_set_screen_size()} to force
+Readline to update its idea of the terminal size when a @code{SIGWINCH}
+is received.
+
+@deftypefun void rl_resize_terminal (void)
+Update Readline's internal screen size by reading values from the kernel.
+@end deftypefun
+
+@deftypefun void rl_set_screen_size (int rows, int cols)
+Set Readline's idea of the terminal size to @var{rows} rows and
+@var{cols} columns.  If either @var{rows} or @var{columns} is less than
+or equal to 0, Readline's idea of that terminal dimension is unchanged.
+@end deftypefun
+
+If an application does not want to install a @code{SIGWINCH} handler, but
+is still interested in the screen dimensions, Readline's idea of the screen
+size may be queried.
+
+@deftypefun void rl_get_screen_size (int *rows, int *cols)
+Return Readline's idea of the terminal's size in the
+variables pointed to by the arguments.
+@end deftypefun
+
+@deftypefun void rl_reset_screen_size (void)
+Cause Readline to reobtain the screen size and recalculate its dimensions.
+@end deftypefun
+
+The following functions install and remove Readline's signal handlers.
+
+@deftypefun int rl_set_signals (void)
+Install Readline's signal handler for @code{SIGINT}, @code{SIGQUIT},
+@code{SIGTERM}, @code{SIGALRM}, @code{SIGTSTP}, @code{SIGTTIN},
+@code{SIGTTOU}, and @code{SIGWINCH}, depending on the values of
+@code{rl_catch_signals} and @code{rl_catch_sigwinch}.
+@end deftypefun
+
+@deftypefun int rl_clear_signals (void)
+Remove all of the Readline signal handlers installed by
+@code{rl_set_signals()}.
+@end deftypefun
+
+@node Custom Completers
+@section Custom Completers
+@cindex application-specific completion functions
+
+Typically, a program that reads commands from the user has a way of
+disambiguating commands and data.  If your program is one of these, then
+it can provide completion for commands, data, or both.
+The following sections describe how your program and Readline
+cooperate to provide this service.
+
+@menu
+* How Completing Works::       The logic used to do completion.
+* Completion Functions::       Functions provided by Readline.
+* Completion Variables::       Variables which control completion.
+* A Short Completion Example:: An example of writing completer subroutines.
+@end menu
+
+@node How Completing Works
+@subsection How Completing Works
+
+In order to complete some text, the full list of possible completions
+must be available.  That is, it is not possible to accurately
+expand a partial word without knowing all of the possible words
+which make sense in that context.  The Readline library provides
+the user interface to completion, and two of the most common
+completion functions:  filename and username.  For completing other types
+of text, you must write your own completion function.  This section
+describes exactly what such functions must do, and provides an example.
+
+There are three major functions used to perform completion:
+
+@enumerate
+@item
+The user-interface function @code{rl_complete()}.  This function is
+called with the same arguments as other bindable Readline functions:
+@var{count} and @var{invoking_key}.
+It isolates the word to be completed and calls
+@code{rl_completion_matches()} to generate a list of possible completions.
+It then either lists the possible completions, inserts the possible
+completions, or actually performs the
+completion, depending on which behavior is desired.
+
+@item
+The internal function @code{rl_completion_matches()} uses an
+application-supplied @dfn{generator} function to generate the list of
+possible matches, and then returns the array of these matches.
+The caller should place the address of its generator function in
+@code{rl_completion_entry_function}.
+
+@item
+The generator function is called repeatedly from
+@code{rl_completion_matches()}, returning a string each time.  The
+arguments to the generator function are @var{text} and @var{state}.
+@var{text} is the partial word to be completed.  @var{state} is zero the
+first time the function is called, allowing the generator to perform
+any necessary initialization, and a positive non-zero integer for
+each subsequent call.  The generator function returns
+@code{(char *)NULL} to inform @code{rl_completion_matches()} that there are
+no more possibilities left.  Usually the generator function computes the
+list of possible completions when @var{state} is zero, and returns them
+one at a time on subsequent calls.  Each string the generator function
+returns as a match must be allocated with @code{malloc()}; Readline
+frees the strings when it has finished with them.
+Such a generator function is referred to as an
+@dfn{application-specific completion function}.
+
+@end enumerate
+
+@deftypefun int rl_complete (int ignore, int invoking_key)
+Complete the word at or before point.  You have supplied the function
+that does the initial simple matching selection algorithm (see
+@code{rl_completion_matches()}).  The default is to do filename completion.
+@end deftypefun
+
+@deftypevar {rl_compentry_func_t *} rl_completion_entry_function
+This is a pointer to the generator function for
+@code{rl_completion_matches()}.
+If the value of @code{rl_completion_entry_function} is
+@code{NULL} then the default filename generator
+function, @code{rl_filename_completion_function()}, is used.
+An @dfn{application-specific completion function} is a function whose
+address is assigned to @code{rl_completion_entry_function} and whose
+return values are used to  generate possible completions.
+@end deftypevar
+
+@node Completion Functions
+@subsection Completion Functions
+
+Here is the complete list of callable completion functions present in
+Readline.
+
+@deftypefun int rl_complete_internal (int what_to_do)
+Complete the word at or before point.  @var{what_to_do} says what to do
+with the completion.  A value of @samp{?} means list the possible
+completions.  @samp{TAB} means do standard completion.  @samp{*} means
+insert all of the possible completions.  @samp{!} means to display
+all of the possible completions, if there is more than one, as well as
+performing partial completion.  @samp{@@} is similar to @samp{!}, but
+possible completions are not listed if the possible completions share
+a common prefix.
+@end deftypefun
+
+@deftypefun int rl_complete (int ignore, int invoking_key)
+Complete the word at or before point.  You have supplied the function
+that does the initial simple matching selection algorithm (see
+@code{rl_completion_matches()} and @code{rl_completion_entry_function}).
+The default is to do filename
+completion.  This calls @code{rl_complete_internal()} with an
+argument depending on @var{invoking_key}.
+@end deftypefun
+
+@deftypefun int rl_possible_completions (int count, int invoking_key)
+List the possible completions.  See description of @code{rl_complete
+()}.  This calls @code{rl_complete_internal()} with an argument of
+@samp{?}.
+@end deftypefun
+
+@deftypefun int rl_insert_completions (int count, int invoking_key)
+Insert the list of possible completions into the line, deleting the
+partially-completed word.  See description of @code{rl_complete()}.
+This calls @code{rl_complete_internal()} with an argument of @samp{*}.
+@end deftypefun
+
+@deftypefun int rl_completion_mode (rl_command_func_t *cfunc)
+Returns the apppriate value to pass to @code{rl_complete_internal()}
+depending on whether @var{cfunc} was called twice in succession and
+the values of the @code{show-all-if-ambiguous} and
+@code{show-all-if-unmodified} variables.
+Application-specific completion functions may use this function to present
+the same interface as @code{rl_complete()}.
+@end deftypefun
+
+@deftypefun {char **} rl_completion_matches (const char *text, rl_compentry_func_t *entry_func)
+Returns an array of strings which is a list of completions for
+@var{text}.  If there are no completions, returns @code{NULL}.
+The first entry in the returned array is the substitution for @var{text}.
+The remaining entries are the possible completions.  The array is
+terminated with a @code{NULL} pointer.
+
+@var{entry_func} is a function of two args, and returns a
+@code{char *}.  The first argument is @var{text}.  The second is a
+state argument; it is zero on the first call, and non-zero on subsequent
+calls.  @var{entry_func} returns a @code{NULL}  pointer to the caller
+when there are no more matches.
+@end deftypefun
+
+@deftypefun {char *} rl_filename_completion_function (const char *text, int state)
+A generator function for filename completion in the general case.
+@var{text} is a partial filename.
+The Bash source is a useful reference for writing application-specific
+completion functions (the Bash completion functions call this and other
+Readline functions).
+@end deftypefun
+
+@deftypefun {char *} rl_username_completion_function (const char *text, int state)
+A completion generator for usernames.  @var{text} contains a partial
+username preceded by a random character (usually @samp{~}).  As with all
+completion generators, @var{state} is zero on the first call and non-zero
+for subsequent calls.
+@end deftypefun
+
+@node Completion Variables
+@subsection Completion Variables
+
+@deftypevar {rl_compentry_func_t *} rl_completion_entry_function
+A pointer to the generator function for @code{rl_completion_matches()}.
+@code{NULL} means to use @code{rl_filename_completion_function()},
+the default filename completer.
+@end deftypevar
+
+@deftypevar {rl_completion_func_t *} rl_attempted_completion_function
+A pointer to an alternative function to create matches.
+The function is called with @var{text}, @var{start}, and @var{end}.
+@var{start} and @var{end} are indices in @code{rl_line_buffer} defining
+the boundaries of @var{text}, which is a character string.
+If this function exists and returns @code{NULL}, or if this variable is
+set to @code{NULL}, then @code{rl_complete()} will call the value of
+@code{rl_completion_entry_function} to generate matches, otherwise the
+array of strings returned will be used.
+If this function sets the @code{rl_attempted_completion_over}
+variable to a non-zero value, Readline will not perform its default
+completion even if this function returns no matches.
+@end deftypevar
+
+@deftypevar {rl_quote_func_t *} rl_filename_quoting_function
+A pointer to a function that will quote a filename in an
+application-specific fashion.  This is called if filename completion is being
+attempted and one of the characters in @code{rl_filename_quote_characters}
+appears in a completed filename.  The function is called with
+@var{text}, @var{match_type}, and @var{quote_pointer}.  The @var{text}
+is the filename to be quoted.  The @var{match_type} is either
+@code{SINGLE_MATCH}, if there is only one completion match, or
+@code{MULT_MATCH}.  Some functions use this to decide whether or not to
+insert a closing quote character.  The @var{quote_pointer} is a pointer
+to any opening quote character the user typed.  Some functions choose
+to reset this character.
+@end deftypevar
+
+@deftypevar {rl_dequote_func_t *} rl_filename_dequoting_function
+A pointer to a function that will remove application-specific quoting
+characters from a filename before completion is attempted, so those
+characters do not interfere with matching the text against names in
+the filesystem.  It is called with @var{text}, the text of the word
+to be dequoted, and @var{quote_char}, which is the quoting character 
+that delimits the filename (usually @samp{'} or @samp{"}).  If
+@var{quote_char} is zero, the filename was not in an embedded string.
+@end deftypevar
+
+@deftypevar {rl_linebuf_func_t *} rl_char_is_quoted_p
+A pointer to a function to call that determines whether or not a specific
+character in the line buffer is quoted, according to whatever quoting
+mechanism the program calling Readline uses.  The function is called with
+two arguments: @var{text}, the text of the line, and @var{index}, the
+index of the character in the line.  It is used to decide whether a
+character found in @code{rl_completer_word_break_characters} should be
+used to break words for the completer.
+@end deftypevar
+
+@deftypevar {rl_compignore_func_t *} rl_ignore_some_completions_function
+This function, if defined, is called by the completer when real filename
+completion is done, after all the matching names have been generated.
+It is passed a @code{NULL} terminated array of matches.
+The first element (@code{matches[0]}) is the
+maximal substring common to all matches. This function can
+re-arrange the list of matches as required, but each element deleted
+from the array must be freed.
+@end deftypevar
+
+@deftypevar {rl_icppfunc_t *} rl_directory_completion_hook
+This function, if defined, is allowed to modify the directory portion
+of filenames Readline completes.  It is called with the address of a
+string (the current directory name) as an argument, and may modify that string.
+If the string is replaced with a new string, the old value should be freed.
+Any modified directory name should have a trailing slash.
+The modified value will be displayed as part of the completion, replacing
+the directory portion of the pathname the user typed.
+It returns an integer that should be non-zero if the function modifies
+its directory argument.
+It could be used to expand symbolic links or shell variables in pathnames.
+At the least, even if no other expansion is performed, this function should
+remove any quote characters from the directory name, because its result will
+be passed directly to @code{opendir()}.
+@end deftypevar
+
+@deftypevar {rl_compdisp_func_t *} rl_completion_display_matches_hook
+If non-zero, then this is the address of a function to call when
+completing a word would normally display the list of possible matches.
+This function is called in lieu of Readline displaying the list.
+It takes three arguments:
+(@code{char **}@var{matches}, @code{int} @var{num_matches}, @code{int} @var{max_length})
+where @var{matches} is the array of matching strings,
+@var{num_matches} is the number of strings in that array, and
+@var{max_length} is the length of the longest string in that array.
+Readline provides a convenience function, @code{rl_display_match_list},
+that takes care of doing the display to Readline's output stream.  That
+function may be called from this hook.
+@end deftypevar
+
+@deftypevar {const char *} rl_basic_word_break_characters
+The basic list of characters that signal a break between words for the
+completer routine.  The default value of this variable is the characters
+which break words for completion in Bash:
+@code{" \t\n\"\\'`@@$><=;|&@{("}.
+@end deftypevar
+
+@deftypevar {const char *} rl_basic_quote_characters
+A list of quote characters which can cause a word break.
+@end deftypevar
+
+@deftypevar {const char *} rl_completer_word_break_characters
+The list of characters that signal a break between words for
+@code{rl_complete_internal()}.  The default list is the value of
+@code{rl_basic_word_break_characters}.
+@end deftypevar
+
+@deftypevar {rl_cpvfunc_t *} rl_completion_word_break_hook
+If non-zero, this is the address of a function to call when Readline is
+deciding where to separate words for word completion.  It should return
+a character string like @code{rl_completer_word_break_characters} to be
+used to perform the current completion.  The function may choose to set
+@code{rl_completer_word_break_characters} itself.  If the function
+returns @code{NULL}, @code{rl_completer_word_break_characters} is used.
+@end deftypevar
+
+@deftypevar {const char *} rl_completer_quote_characters
+A list of characters which can be used to quote a substring of the line.
+Completion occurs on the entire substring, and within the substring
+@code{rl_completer_word_break_characters} are treated as any other character,
+unless they also appear within this list.
+@end deftypevar
+
+@deftypevar {const char *} rl_filename_quote_characters
+A list of characters that cause a filename to be quoted by the completer
+when they appear in a completed filename.  The default is the null string.
+@end deftypevar
+
+@deftypevar {const char *} rl_special_prefixes
+The list of characters that are word break characters, but should be
+left in @var{text} when it is passed to the completion function.
+Programs can use this to help determine what kind of completing to do.
+For instance, Bash sets this variable to "$@@" so that it can complete
+shell variables and hostnames.
+@end deftypevar
+
+@deftypevar int rl_completion_query_items
+Up to this many items will be displayed in response to a
+possible-completions call.  After that, readline asks the user if she is sure
+she wants to see them all.  The default value is 100.  A negative value 
+indicates that Readline should never ask the user.
+@end deftypevar
+
+@deftypevar {int} rl_completion_append_character
+When a single completion alternative matches at the end of the command
+line, this character is appended to the inserted completion text.  The
+default is a space character (@samp{ }).  Setting this to the null
+character (@samp{\0}) prevents anything being appended automatically.
+This can be changed in application-specific completion functions to
+provide the ``most sensible word separator character'' according to
+an application-specific command line syntax specification.
+@end deftypevar
+
+@deftypevar int rl_completion_suppress_append
+If non-zero, @var{rl_completion_append_character} is not appended to
+matches at the end of the command line, as described above.
+It is set to 0 before any application-specific completion function
+is called, and may only be changed within such a function.
+@end deftypevar
+
+@deftypevar int rl_completion_quote_character
+When Readline is completing quoted text, as delimited by one of the
+characters in @var{rl_completer_quote_characters}, it sets this variable
+to the quoting character found.
+This is set before any application-specific completion function is called.
+@end deftypevar
+
+@deftypevar int rl_completion_suppress_quote
+If non-zero, Readline does not append a matching quote character when
+performing completion on a quoted string.
+It is set to 0 before any application-specific completion function
+is called, and may only be changed within such a function.
+@end deftypevar
+
+@deftypevar int rl_completion_found_quote
+When Readline is completing quoted text, it sets this variable
+to a non-zero value if the word being completed contains or is delimited
+by any quoting characters, including backslashes.
+This is set before any application-specific completion function is called.
+@end deftypevar
+
+@deftypevar int rl_completion_mark_symlink_dirs
+If non-zero, a slash will be appended to completed filenames that are
+symbolic links to directory names, subject to the value of the
+user-settable @var{mark-directories} variable.
+This variable exists so that application-specific completion functions
+can override the user's global preference (set via the
+@var{mark-symlinked-directories} Readline variable) if appropriate.
+This variable is set to the user's preference before any
+application-specific completion function is called, so unless that
+function modifies the value, the user's preferences are honored.
+@end deftypevar
+
+@deftypevar int rl_ignore_completion_duplicates
+If non-zero, then duplicates in the matches are removed.
+The default is 1.
+@end deftypevar
+
+@deftypevar int rl_filename_completion_desired
+Non-zero means that the results of the matches are to be treated as
+filenames.  This is @emph{always} zero when completion is attempted,
+and can only be changed
+within an application-specific completion function.  If it is set to a
+non-zero value by such a function, directory names have a slash appended
+and Readline attempts to quote completed filenames if they contain any
+characters in @code{rl_filename_quote_characters} and
+@code{rl_filename_quoting_desired} is set to a non-zero value.
+@end deftypevar
+
+@deftypevar int rl_filename_quoting_desired
+Non-zero means that the results of the matches are to be quoted using
+double quotes (or an application-specific quoting mechanism) if the
+completed filename contains any characters in
+@code{rl_filename_quote_chars}.  This is @emph{always} non-zero
+when completion is attempted, and can only be changed within an
+application-specific completion function.
+The quoting is effected via a call to the function pointed to
+by @code{rl_filename_quoting_function}.
+@end deftypevar
+
+@deftypevar int rl_attempted_completion_over
+If an application-specific completion function assigned to
+@code{rl_attempted_completion_function} sets this variable to a non-zero
+value, Readline will not perform its default filename completion even
+if the application's completion function returns no matches.
+It should be set only by an application's completion function.
+@end deftypevar
+
+@deftypevar int rl_completion_type
+Set to a character describing the type of completion Readline is currently
+attempting; see the description of @code{rl_complete_internal()}
+(@pxref{Completion Functions}) for the list of characters.
+This is set to the appropriate value before any application-specific
+completion function is called, allowing such functions to present
+the same interface as @code{rl_complete()}.
+@end deftypevar
+
+@deftypevar int rl_inhibit_completion
+If this variable is non-zero, completion is inhibited.  The completion
+character will be inserted as any other bound to @code{self-insert}.
+@end deftypevar
+
+@node A Short Completion Example
+@subsection A Short Completion Example
+
+Here is a small application demonstrating the use of the GNU Readline
+library.  It is called @code{fileman}, and the source code resides in
+@file{examples/fileman.c}.  This sample application provides
+completion of command names, line editing features, and access to the
+history list.
+
+@page
+@smallexample
+/* fileman.c -- A tiny application which demonstrates how to use the
+   GNU Readline library.  This application interactively allows users
+   to manipulate files and their modes. */
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/file.h>
+#include <sys/stat.h>
+#include <sys/errno.h>
+
+#include <readline/readline.h>
+#include <readline/history.h>
+
+extern char *xmalloc ();
+
+/* The names of functions that actually do the manipulation. */
+int com_list __P((char *));
+int com_view __P((char *));
+int com_rename __P((char *));
+int com_stat __P((char *));
+int com_pwd __P((char *));
+int com_delete __P((char *));
+int com_help __P((char *));
+int com_cd __P((char *));
+int com_quit __P((char *));
+
+/* A structure which contains information on the commands this program
+   can understand. */
+
+typedef struct @{
+  char *name;                  /* User printable name of the function. */
+  rl_icpfunc_t *func;          /* Function to call to do the job. */
+  char *doc;                   /* Documentation for this function.  */
+@} COMMAND;
+
+COMMAND commands[] = @{
+  @{ "cd", com_cd, "Change to directory DIR" @},
+  @{ "delete", com_delete, "Delete FILE" @},
+  @{ "help", com_help, "Display this text" @},
+  @{ "?", com_help, "Synonym for `help'" @},
+  @{ "list", com_list, "List files in DIR" @},
+  @{ "ls", com_list, "Synonym for `list'" @},
+  @{ "pwd", com_pwd, "Print the current working directory" @},
+  @{ "quit", com_quit, "Quit using Fileman" @},
+  @{ "rename", com_rename, "Rename FILE to NEWNAME" @},
+  @{ "stat", com_stat, "Print out statistics on FILE" @},
+  @{ "view", com_view, "View the contents of FILE" @},
+  @{ (char *)NULL, (rl_icpfunc_t *)NULL, (char *)NULL @}
+@};
+
+/* Forward declarations. */
+char *stripwhite ();
+COMMAND *find_command ();
+
+/* The name of this program, as taken from argv[0]. */
+char *progname;
+
+/* When non-zero, this means the user is done using this program. */
+int done;
+
+char *
+dupstr (s)
+     int s;
+@{
+  char *r;
+
+  r = xmalloc (strlen (s) + 1);
+  strcpy (r, s);
+  return (r);
+@}
+
+main (argc, argv)
+     int argc;
+     char **argv;
+@{
+  char *line, *s;
+
+  progname = argv[0];
+
+  initialize_readline ();      /* Bind our completer. */
+
+  /* Loop reading and executing lines until the user quits. */
+  for ( ; done == 0; )
+    @{
+      line = readline ("FileMan: ");
+
+      if (!line)
+        break;
+
+      /* Remove leading and trailing whitespace from the line.
+         Then, if there is anything left, add it to the history list
+         and execute it. */
+      s = stripwhite (line);
+
+      if (*s)
+        @{
+          add_history (s);
+          execute_line (s);
+        @}
+
+      free (line);
+    @}
+  exit (0);
+@}
+
+/* Execute a command line. */
+int
+execute_line (line)
+     char *line;
+@{
+  register int i;
+  COMMAND *command;
+  char *word;
+
+  /* Isolate the command word. */
+  i = 0;
+  while (line[i] && whitespace (line[i]))
+    i++;
+  word = line + i;
+
+  while (line[i] && !whitespace (line[i]))
+    i++;
+
+  if (line[i])
+    line[i++] = '\0';
+
+  command = find_command (word);
+
+  if (!command)
+    @{
+      fprintf (stderr, "%s: No such command for FileMan.\n", word);
+      return (-1);
+    @}
+
+  /* Get argument to command, if any. */
+  while (whitespace (line[i]))
+    i++;
+
+  word = line + i;
+
+  /* Call the function. */
+  return ((*(command->func)) (word));
+@}
+
+/* Look up NAME as the name of a command, and return a pointer to that
+   command.  Return a NULL pointer if NAME isn't a command name. */
+COMMAND *
+find_command (name)
+     char *name;
+@{
+  register int i;
+
+  for (i = 0; commands[i].name; i++)
+    if (strcmp (name, commands[i].name) == 0)
+      return (&commands[i]);
+
+  return ((COMMAND *)NULL);
+@}
+
+/* Strip whitespace from the start and end of STRING.  Return a pointer
+   into STRING. */
+char *
+stripwhite (string)
+     char *string;
+@{
+  register char *s, *t;
+
+  for (s = string; whitespace (*s); s++)
+    ;
+    
+  if (*s == 0)
+    return (s);
+
+  t = s + strlen (s) - 1;
+  while (t > s && whitespace (*t))
+    t--;
+  *++t = '\0';
+
+  return s;
+@}
+
+/* **************************************************************** */
+/*                                                                  */
+/*                  Interface to Readline Completion                */
+/*                                                                  */
+/* **************************************************************** */
+
+char *command_generator __P((const char *, int));
+char **fileman_completion __P((const char *, int, int));
+
+/* Tell the GNU Readline library how to complete.  We want to try to
+   complete on command names if this is the first word in the line, or
+   on filenames if not. */
+initialize_readline ()
+@{
+  /* Allow conditional parsing of the ~/.inputrc file. */
+  rl_readline_name = "FileMan";
+
+  /* Tell the completer that we want a crack first. */
+  rl_attempted_completion_function = fileman_completion;
+@}
+
+/* Attempt to complete on the contents of TEXT.  START and END
+   bound the region of rl_line_buffer that contains the word to
+   complete.  TEXT is the word to complete.  We can use the entire
+   contents of rl_line_buffer in case we want to do some simple
+   parsing.  Returnthe array of matches, or NULL if there aren't any. */
+char **
+fileman_completion (text, start, end)
+     const char *text;
+     int start, end;
+@{
+  char **matches;
+
+  matches = (char **)NULL;
+
+  /* If this word is at the start of the line, then it is a command
+     to complete.  Otherwise it is the name of a file in the current
+     directory. */
+  if (start == 0)
+    matches = rl_completion_matches (text, command_generator);
+
+  return (matches);
+@}
+
+/* Generator function for command completion.  STATE lets us
+   know whether to start from scratch; without any state
+   (i.e. STATE == 0), then we start at the top of the list. */
+char *
+command_generator (text, state)
+     const char *text;
+     int state;
+@{
+  static int list_index, len;
+  char *name;
+
+  /* If this is a new word to complete, initialize now.  This
+     includes saving the length of TEXT for efficiency, and
+     initializing the index variable to 0. */
+  if (!state)
+    @{
+      list_index = 0;
+      len = strlen (text);
+    @}
+
+  /* Return the next name which partially matches from the
+     command list. */
+  while (name = commands[list_index].name)
+    @{
+      list_index++;
+
+      if (strncmp (name, text, len) == 0)
+        return (dupstr(name));
+    @}
+
+  /* If no names matched, then return NULL. */
+  return ((char *)NULL);
+@}
+
+/* **************************************************************** */
+/*                                                                  */
+/*                       FileMan Commands                           */
+/*                                                                  */
+/* **************************************************************** */
+
+/* String to pass to system ().  This is for the LIST, VIEW and RENAME
+   commands. */
+static char syscom[1024];
+
+/* List the file(s) named in arg. */
+com_list (arg)
+     char *arg;
+@{
+  if (!arg)
+    arg = "";
+
+  sprintf (syscom, "ls -FClg %s", arg);
+  return (system (syscom));
+@}
+
+com_view (arg)
+     char *arg;
+@{
+  if (!valid_argument ("view", arg))
+    return 1;
+
+  sprintf (syscom, "more %s", arg);
+  return (system (syscom));
+@}
+
+com_rename (arg)
+     char *arg;
+@{
+  too_dangerous ("rename");
+  return (1);
+@}
+
+com_stat (arg)
+     char *arg;
+@{
+  struct stat finfo;
+
+  if (!valid_argument ("stat", arg))
+    return (1);
+
+  if (stat (arg, &finfo) == -1)
+    @{
+      perror (arg);
+      return (1);
+    @}
+
+  printf ("Statistics for `%s':\n", arg);
+
+  printf ("%s has %d link%s, and is %d byte%s in length.\n", arg,
+          finfo.st_nlink,
+          (finfo.st_nlink == 1) ? "" : "s",
+          finfo.st_size,
+          (finfo.st_size == 1) ? "" : "s");
+  printf ("Inode Last Change at: %s", ctime (&finfo.st_ctime));
+  printf ("      Last access at: %s", ctime (&finfo.st_atime));
+  printf ("    Last modified at: %s", ctime (&finfo.st_mtime));
+  return (0);
+@}
+
+com_delete (arg)
+     char *arg;
+@{
+  too_dangerous ("delete");
+  return (1);
+@}
+
+/* Print out help for ARG, or for all of the commands if ARG is
+   not present. */
+com_help (arg)
+     char *arg;
+@{
+  register int i;
+  int printed = 0;
+
+  for (i = 0; commands[i].name; i++)
+    @{
+      if (!*arg || (strcmp (arg, commands[i].name) == 0))
+        @{
+          printf ("%s\t\t%s.\n", commands[i].name, commands[i].doc);
+          printed++;
+        @}
+    @}
+
+  if (!printed)
+    @{
+      printf ("No commands match `%s'.  Possibilties are:\n", arg);
+
+      for (i = 0; commands[i].name; i++)
+        @{
+          /* Print in six columns. */
+          if (printed == 6)
+            @{
+              printed = 0;
+              printf ("\n");
+            @}
+
+          printf ("%s\t", commands[i].name);
+          printed++;
+        @}
+
+      if (printed)
+        printf ("\n");
+    @}
+  return (0);
+@}
+
+/* Change to the directory ARG. */
+com_cd (arg)
+     char *arg;
+@{
+  if (chdir (arg) == -1)
+    @{
+      perror (arg);
+      return 1;
+    @}
+
+  com_pwd ("");
+  return (0);
+@}
+
+/* Print out the current working directory. */
+com_pwd (ignore)
+     char *ignore;
+@{
+  char dir[1024], *s;
+
+  s = getcwd (dir, sizeof(dir) - 1);
+  if (s == 0)
+    @{
+      printf ("Error getting pwd: %s\n", dir);
+      return 1;
+    @}
+
+  printf ("Current directory is %s\n", dir);
+  return 0;
+@}
+
+/* The user wishes to quit using this program.  Just set DONE
+   non-zero. */
+com_quit (arg)
+     char *arg;
+@{
+  done = 1;
+  return (0);
+@}
+
+/* Function which tells you that you can't do this. */
+too_dangerous (caller)
+     char *caller;
+@{
+  fprintf (stderr,
+           "%s: Too dangerous for me to distribute.\n",
+           caller);
+  fprintf (stderr, "Write it yourself.\n");
+@}
+
+/* Return non-zero if ARG is a valid argument for CALLER,
+   else print an error message and return zero. */
+int
+valid_argument (caller, arg)
+     char *caller, *arg;
+@{
+  if (!arg || !*arg)
+    @{
+      fprintf (stderr, "%s: Argument required.\n", caller);
+      return (0);
+    @}
+
+  return (1);
+@}
+@end smallexample
index e650907dcf941b730a68d62f314b339fb12d6a81..96b24ce38ee0c18651c2bb67245d187882f46606 100644 (file)
@@ -1559,9 +1559,9 @@ completed, and the matching words become the possible completions.
 
 After these matches have been generated, any shell function or command
 specified with the @option{-F} and @option{-C} options is invoked.
-When the command or function is invoked, the @env{COMP_LINE} and
-@env{COMP_POINT} variables are assigned values as described above
-(@pxref{Bash Variables}).
+When the command or function is invoked, the @env{COMP_LINE},
+@env{COMP_POINT}, @env{COMP_KEY}, and @env{COMP_TYPE} variables are
+assigned values as described above (@pxref{Bash Variables}).
 If a shell function is being invoked, the @env{COMP_WORDS} and
 @env{COMP_CWORD} variables are also set.
 When the function or command is invoked, the first argument is the
index 5c6467a9aa69a2accd35f2b88fed15cc00a53ea8..9ff4bea68dc00efecdbf57cac8905866dea699bc 100644 (file)
@@ -1559,9 +1559,9 @@ completed, and the matching words become the possible completions.
 
 After these matches have been generated, any shell function or command
 specified with the @option{-F} and @option{-C} options is invoked.
-When the command or function is invoked, the @env{COMP_LINE} and
-@env{COMP_POINT} variables are assigned values as described above
-(@pxref{Bash Variables}).
+When the command or function is invoked, the @env{COMP_LINE},
+@env{COMP_POINT}, and @env{COMP_TYPE} variables are assigned values
+as described above (@pxref{Bash Variables}).
 If a shell function is being invoked, the @env{COMP_WORDS} and
 @env{COMP_CWORD} variables are also set.
 When the function or command is invoked, the first argument is the
@@ -1662,8 +1662,8 @@ matches were generated.
 @btindex complete
 @example
 @code{complete [-abcdefgjksuv] [-o @var{comp-option}] [-A @var{action}] [-G @var{globpat}] [-W @var{wordlist}]
-[-P @var{prefix}] [-S @var{suffix}] [-X @var{filterpat}] [-F @var{function}]
-[-C @var{command}] @var{name} [@var{name} @dots{}]}
+[-F @var{function}] [-C @var{command}] [-X @var{filterpat}]
+[-P @var{prefix}] [-S @var{suffix}] @var{name} [@var{name} @dots{}]}
 @code{complete -pr [@var{name} @dots{}]}
 @end example
 
index 654e83777d50ba36044db30350de26f4cca68b64..42cc40360743b97c9985769b862ac67e6aacbf1e 100644 (file)
@@ -4,7 +4,7 @@ Copyright (C) 1988-2006 Free Software Foundation, Inc.
 
 @set EDITION 5.2
 @set VERSION 5.2
-@set UPDATED 26 April 2006
-@set UPDATED-MONTH April 2006
+@set UPDATED 30 December 2006
+@set UPDATED-MONTH December 2006
 
-@set LASTCHANGE Wed Apr 26 09:22:57 EDT 2006
+@set LASTCHANGE Sat Dec 30 19:17:22 EST 2006
diff --git a/lib/readline/doc/version.texi~ b/lib/readline/doc/version.texi~
new file mode 100644 (file)
index 0000000..654e837
--- /dev/null
@@ -0,0 +1,10 @@
+@ignore
+Copyright (C) 1988-2006 Free Software Foundation, Inc. 
+@end ignore
+
+@set EDITION 5.2
+@set VERSION 5.2
+@set UPDATED 26 April 2006
+@set UPDATED-MONTH April 2006
+
+@set LASTCHANGE Wed Apr 26 09:22:57 EDT 2006
index 9c760cc3475373ef42c1849e64c1bcbf3a61619a..0b11ea9277b0ddb511b2a3c3cd322d9153e793c4 100644 (file)
@@ -56,7 +56,7 @@ static int funmap_entry;
    program specific function. */
 int funmap_program_specific_entry_start;
 
-static FUNMAP default_funmap[] = {
+static const FUNMAP default_funmap[] = {
   { "abort", rl_abort },
   { "accept-line", rl_newline },
   { "arrow-key-prefix", rl_arrow_keys },
diff --git a/lib/readline/funmap.c~ b/lib/readline/funmap.c~
new file mode 100644 (file)
index 0000000..9c760cc
--- /dev/null
@@ -0,0 +1,255 @@
+/* funmap.c -- attach names to functions. */
+
+/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
+
+   This file is part of the GNU Readline Library, a library for
+   reading lines of text with interactive input and history editing.
+
+   The GNU Readline Library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU General Public License
+   as published by the Free Software Foundation; either version 2, or
+   (at your option) any later version.
+
+   The GNU Readline Library 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.
+
+   The GNU General Public License is often shipped with GNU software, and
+   is generally kept in a file called COPYING or LICENSE.  If you do not
+   have a copy of the license, write to the Free Software Foundation,
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+#define READLINE_LIBRARY
+
+#if defined (HAVE_CONFIG_H)
+#  include <config.h>
+#endif
+
+#if !defined (BUFSIZ)
+#include <stdio.h>
+#endif /* BUFSIZ */
+
+#if defined (HAVE_STDLIB_H)
+#  include <stdlib.h>
+#else
+#  include "ansi_stdlib.h"
+#endif /* HAVE_STDLIB_H */
+
+#include "rlconf.h"
+#include "readline.h"
+
+#include "xmalloc.h"
+
+#ifdef __STDC__
+typedef int QSFUNC (const void *, const void *);
+#else
+typedef int QSFUNC ();
+#endif
+
+extern int _rl_qsort_string_compare PARAMS((char **, char **));
+
+FUNMAP **funmap;
+static int funmap_size;
+static int funmap_entry;
+
+/* After initializing the function map, this is the index of the first
+   program specific function. */
+int funmap_program_specific_entry_start;
+
+static FUNMAP default_funmap[] = {
+  { "abort", rl_abort },
+  { "accept-line", rl_newline },
+  { "arrow-key-prefix", rl_arrow_keys },
+  { "backward-byte", rl_backward_byte },
+  { "backward-char", rl_backward_char },
+  { "backward-delete-char", rl_rubout },
+  { "backward-kill-line", rl_backward_kill_line },
+  { "backward-kill-word", rl_backward_kill_word },
+  { "backward-word", rl_backward_word },
+  { "beginning-of-history", rl_beginning_of_history },
+  { "beginning-of-line", rl_beg_of_line },
+  { "call-last-kbd-macro", rl_call_last_kbd_macro },
+  { "capitalize-word", rl_capitalize_word },
+  { "character-search", rl_char_search },
+  { "character-search-backward", rl_backward_char_search },
+  { "clear-screen", rl_clear_screen },
+  { "complete", rl_complete },
+  { "copy-backward-word", rl_copy_backward_word },
+  { "copy-forward-word", rl_copy_forward_word },
+  { "copy-region-as-kill", rl_copy_region_to_kill },
+  { "delete-char", rl_delete },
+  { "delete-char-or-list", rl_delete_or_show_completions },
+  { "delete-horizontal-space", rl_delete_horizontal_space },
+  { "digit-argument", rl_digit_argument },
+  { "do-lowercase-version", rl_do_lowercase_version },
+  { "downcase-word", rl_downcase_word },
+  { "dump-functions", rl_dump_functions },
+  { "dump-macros", rl_dump_macros },
+  { "dump-variables", rl_dump_variables },
+  { "emacs-editing-mode", rl_emacs_editing_mode },
+  { "end-kbd-macro", rl_end_kbd_macro },
+  { "end-of-history", rl_end_of_history },
+  { "end-of-line", rl_end_of_line },
+  { "exchange-point-and-mark", rl_exchange_point_and_mark },
+  { "forward-backward-delete-char", rl_rubout_or_delete },
+  { "forward-byte", rl_forward_byte },
+  { "forward-char", rl_forward_char },
+  { "forward-search-history", rl_forward_search_history },
+  { "forward-word", rl_forward_word },
+  { "history-search-backward", rl_history_search_backward },
+  { "history-search-forward", rl_history_search_forward },
+  { "insert-comment", rl_insert_comment },
+  { "insert-completions", rl_insert_completions },
+  { "kill-whole-line", rl_kill_full_line },
+  { "kill-line", rl_kill_line },
+  { "kill-region", rl_kill_region },
+  { "kill-word", rl_kill_word },
+  { "menu-complete", rl_menu_complete },
+  { "next-history", rl_get_next_history },
+  { "non-incremental-forward-search-history", rl_noninc_forward_search },
+  { "non-incremental-reverse-search-history", rl_noninc_reverse_search },
+  { "non-incremental-forward-search-history-again", rl_noninc_forward_search_again },
+  { "non-incremental-reverse-search-history-again", rl_noninc_reverse_search_again },
+  { "overwrite-mode", rl_overwrite_mode },
+#ifdef __CYGWIN__
+  { "paste-from-clipboard", rl_paste_from_clipboard },
+#endif
+  { "possible-completions", rl_possible_completions },
+  { "previous-history", rl_get_previous_history },
+  { "quoted-insert", rl_quoted_insert },
+  { "re-read-init-file", rl_re_read_init_file },
+  { "redraw-current-line", rl_refresh_line},
+  { "reverse-search-history", rl_reverse_search_history },
+  { "revert-line", rl_revert_line },
+  { "self-insert", rl_insert },
+  { "set-mark", rl_set_mark },
+  { "start-kbd-macro", rl_start_kbd_macro },
+  { "tab-insert", rl_tab_insert },
+  { "tilde-expand", rl_tilde_expand },
+  { "transpose-chars", rl_transpose_chars },
+  { "transpose-words", rl_transpose_words },
+  { "tty-status", rl_tty_status },
+  { "undo", rl_undo_command },
+  { "universal-argument", rl_universal_argument },
+  { "unix-filename-rubout", rl_unix_filename_rubout },
+  { "unix-line-discard", rl_unix_line_discard },
+  { "unix-word-rubout", rl_unix_word_rubout },
+  { "upcase-word", rl_upcase_word },
+  { "yank", rl_yank },
+  { "yank-last-arg", rl_yank_last_arg },
+  { "yank-nth-arg", rl_yank_nth_arg },
+  { "yank-pop", rl_yank_pop },
+
+#if defined (VI_MODE)
+  { "vi-append-eol", rl_vi_append_eol },
+  { "vi-append-mode", rl_vi_append_mode },
+  { "vi-arg-digit", rl_vi_arg_digit },
+  { "vi-back-to-indent", rl_vi_back_to_indent },
+  { "vi-bWord", rl_vi_bWord },
+  { "vi-bword", rl_vi_bword },
+  { "vi-change-case", rl_vi_change_case },
+  { "vi-change-char", rl_vi_change_char },
+  { "vi-change-to", rl_vi_change_to },
+  { "vi-char-search", rl_vi_char_search },
+  { "vi-column", rl_vi_column },
+  { "vi-complete", rl_vi_complete },
+  { "vi-delete", rl_vi_delete },
+  { "vi-delete-to", rl_vi_delete_to },
+  { "vi-eWord", rl_vi_eWord },
+  { "vi-editing-mode", rl_vi_editing_mode },
+  { "vi-end-word", rl_vi_end_word },
+  { "vi-eof-maybe", rl_vi_eof_maybe },
+  { "vi-eword", rl_vi_eword },
+  { "vi-fWord", rl_vi_fWord },
+  { "vi-fetch-history", rl_vi_fetch_history },
+  { "vi-first-print", rl_vi_first_print },
+  { "vi-fword", rl_vi_fword },
+  { "vi-goto-mark", rl_vi_goto_mark },
+  { "vi-insert-beg", rl_vi_insert_beg },
+  { "vi-insertion-mode", rl_vi_insertion_mode },
+  { "vi-match", rl_vi_match },
+  { "vi-movement-mode", rl_vi_movement_mode },
+  { "vi-next-word", rl_vi_next_word },
+  { "vi-overstrike", rl_vi_overstrike },
+  { "vi-overstrike-delete", rl_vi_overstrike_delete },
+  { "vi-prev-word", rl_vi_prev_word },
+  { "vi-put", rl_vi_put },
+  { "vi-redo", rl_vi_redo },
+  { "vi-replace", rl_vi_replace },
+  { "vi-rubout", rl_vi_rubout },
+  { "vi-search", rl_vi_search },
+  { "vi-search-again", rl_vi_search_again },
+  { "vi-set-mark", rl_vi_set_mark },
+  { "vi-subst", rl_vi_subst },
+  { "vi-tilde-expand", rl_vi_tilde_expand },
+  { "vi-yank-arg", rl_vi_yank_arg },
+  { "vi-yank-to", rl_vi_yank_to },
+#endif /* VI_MODE */
+
+ {(char *)NULL, (rl_command_func_t *)NULL }
+};
+
+int
+rl_add_funmap_entry (name, function)
+     const char *name;
+     rl_command_func_t *function;
+{
+  if (funmap_entry + 2 >= funmap_size)
+    {
+      funmap_size += 64;
+      funmap = (FUNMAP **)xrealloc (funmap, funmap_size * sizeof (FUNMAP *));
+    }
+  
+  funmap[funmap_entry] = (FUNMAP *)xmalloc (sizeof (FUNMAP));
+  funmap[funmap_entry]->name = name;
+  funmap[funmap_entry]->function = function;
+
+  funmap[++funmap_entry] = (FUNMAP *)NULL;
+  return funmap_entry;
+}
+
+static int funmap_initialized;
+
+/* Make the funmap contain all of the default entries. */
+void
+rl_initialize_funmap ()
+{
+  register int i;
+
+  if (funmap_initialized)
+    return;
+
+  for (i = 0; default_funmap[i].name; i++)
+    rl_add_funmap_entry (default_funmap[i].name, default_funmap[i].function);
+
+  funmap_initialized = 1;
+  funmap_program_specific_entry_start = i;
+}
+
+/* Produce a NULL terminated array of known function names.  The array
+   is sorted.  The array itself is allocated, but not the strings inside.
+   You should free () the array when you done, but not the pointrs. */
+const char **
+rl_funmap_names ()
+{
+  const char **result;
+  int result_size, result_index;
+
+  /* Make sure that the function map has been initialized. */
+  rl_initialize_funmap ();
+
+  for (result_index = result_size = 0, result = (const char **)NULL; funmap[result_index]; result_index++)
+    {
+      if (result_index + 2 > result_size)
+       {
+         result_size += 20;
+         result = (const char **)xrealloc (result, result_size * sizeof (char *));
+       }
+
+      result[result_index] = funmap[result_index]->name;
+      result[result_index + 1] = (char *)NULL;
+    }
+
+  qsort (result, result_index, sizeof (char *), (QSFUNC *)_rl_qsort_string_compare);
+  return (result);
+}
index 9928a51b60cf256943ad6a1d4437828e0f7c2371..5ba8bc47e138abd6485c1b8029dd5b82c5fa69f6 100644 (file)
@@ -75,7 +75,7 @@ static int _rl_isearch_cleanup PARAMS((_rl_search_cxt *, int));
 static char *last_isearch_string;
 static int last_isearch_string_len;
 
-static char *default_isearch_terminators = "\033\012";
+static char * const default_isearch_terminators = "\033\012";
 
 _rl_search_cxt *
 _rl_scxt_alloc (type, flags)
diff --git a/lib/readline/isearch.c~ b/lib/readline/isearch.c~
new file mode 100644 (file)
index 0000000..6d2db1e
--- /dev/null
@@ -0,0 +1,670 @@
+/* **************************************************************** */
+/*                                                                 */
+/*                     I-Search and Searching                      */
+/*                                                                 */
+/* **************************************************************** */
+
+/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
+
+   This file contains the Readline Library (the Library), a set of
+   routines for providing Emacs style line input to programs that ask
+   for it.
+
+   The Library is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   The Library 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.
+
+   The GNU General Public License is often shipped with GNU software, and
+   is generally kept in a file called COPYING or LICENSE.  If you do not
+   have a copy of the license, write to the Free Software Foundation,
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+#define READLINE_LIBRARY
+
+#if defined (HAVE_CONFIG_H)
+#  include <config.h>
+#endif
+
+#include <sys/types.h>
+
+#include <stdio.h>
+
+#if defined (HAVE_UNISTD_H)
+#  include <unistd.h>
+#endif
+
+#if defined (HAVE_STDLIB_H)
+#  include <stdlib.h>
+#else
+#  include "ansi_stdlib.h"
+#endif
+
+#include "rldefs.h"
+#include "rlmbutil.h"
+
+#include "readline.h"
+#include "history.h"
+
+#include "rlprivate.h"
+#include "xmalloc.h"
+
+/* Variables exported to other files in the readline library. */
+char *_rl_isearch_terminators = (char *)NULL;
+
+_rl_search_cxt *_rl_iscxt = 0;
+
+/* Variables imported from other files in the readline library. */
+extern HIST_ENTRY *_rl_saved_line_for_history;
+
+static int rl_search_history PARAMS((int, int));
+
+static _rl_search_cxt *_rl_isearch_init PARAMS((int));
+static void _rl_isearch_fini PARAMS((_rl_search_cxt *));
+static int _rl_isearch_cleanup PARAMS((_rl_search_cxt *, int));
+
+/* Last line found by the current incremental search, so we don't `find'
+   identical lines many times in a row.  Now part of isearch context. */
+/* static char *prev_line_found; */
+
+/* Last search string and its length. */
+static char *last_isearch_string;
+static int last_isearch_string_len;
+
+static char * const default_isearch_terminators = "\033\012";
+
+_rl_search_cxt *
+_rl_scxt_alloc (type, flags)
+     int type, flags;
+{
+  _rl_search_cxt *cxt;
+
+  cxt = (_rl_search_cxt *)xmalloc (sizeof (_rl_search_cxt));
+
+  cxt->type = type;
+  cxt->sflags = flags;
+
+  cxt->search_string = 0;
+  cxt->search_string_size = cxt->search_string_index = 0;
+
+  cxt->lines = 0;
+  cxt->allocated_line = 0;
+  cxt->hlen = cxt->hindex = 0;
+
+  cxt->save_point = rl_point;
+  cxt->save_mark = rl_mark;
+  cxt->save_line = where_history ();
+  cxt->last_found_line = cxt->save_line;
+  cxt->prev_line_found = 0;
+
+  cxt->save_undo_list = 0;
+
+  cxt->history_pos = 0;
+  cxt->direction = 0;
+
+  cxt->lastc = 0;
+
+  cxt->sline = 0;
+  cxt->sline_len = cxt->sline_index = 0;
+
+  cxt->search_terminators = 0;
+
+  return cxt;
+}
+
+void
+_rl_scxt_dispose (cxt, flags)
+     _rl_search_cxt *cxt;
+     int flags;
+{
+  FREE (cxt->search_string);
+  FREE (cxt->allocated_line);
+  FREE (cxt->lines);
+
+  xfree (cxt);
+}
+
+/* Search backwards through the history looking for a string which is typed
+   interactively.  Start with the current line. */
+int
+rl_reverse_search_history (sign, key)
+     int sign, key;
+{
+  return (rl_search_history (-sign, key));
+}
+
+/* Search forwards through the history looking for a string which is typed
+   interactively.  Start with the current line. */
+int
+rl_forward_search_history (sign, key)
+     int sign, key;
+{
+  return (rl_search_history (sign, key));
+}
+
+/* Display the current state of the search in the echo-area.
+   SEARCH_STRING contains the string that is being searched for,
+   DIRECTION is zero for forward, or non-zero for reverse,
+   WHERE is the history list number of the current line.  If it is
+   -1, then this line is the starting one. */
+static void
+rl_display_search (search_string, reverse_p, where)
+     char *search_string;
+     int reverse_p, where;
+{
+  char *message;
+  int msglen, searchlen;
+
+  searchlen = (search_string && *search_string) ? strlen (search_string) : 0;
+
+  message = (char *)xmalloc (searchlen + 33);
+  msglen = 0;
+
+#if defined (NOTDEF)
+  if (where != -1)
+    {
+      sprintf (message, "[%d]", where + history_base);
+      msglen = strlen (message);
+    }
+#endif /* NOTDEF */
+
+  message[msglen++] = '(';
+
+  if (reverse_p)
+    {
+      strcpy (message + msglen, "reverse-");
+      msglen += 8;
+    }
+
+  strcpy (message + msglen, "i-search)`");
+  msglen += 10;
+
+  if (search_string)
+    {
+      strcpy (message + msglen, search_string);
+      msglen += searchlen;
+    }
+
+  strcpy (message + msglen, "': ");
+
+  rl_message ("%s", message);
+  xfree (message);
+  (*rl_redisplay_function) ();
+}
+
+static _rl_search_cxt *
+_rl_isearch_init (direction)
+     int direction;
+{
+  _rl_search_cxt *cxt;
+  register int i;
+  HIST_ENTRY **hlist;
+
+  cxt = _rl_scxt_alloc (RL_SEARCH_ISEARCH, 0);
+  if (direction < 0)
+    cxt->sflags |= SF_REVERSE;
+
+  cxt->search_terminators = _rl_isearch_terminators ? _rl_isearch_terminators
+                                               : default_isearch_terminators;
+
+itrace("_rl_isearch_init: set search_terminators to %s", cxt->search_terminators);
+  /* Create an arrary of pointers to the lines that we want to search. */
+  hlist = history_list ();
+  rl_maybe_replace_line ();
+  i = 0;
+  if (hlist)
+    for (i = 0; hlist[i]; i++);
+
+  /* Allocate space for this many lines, +1 for the current input line,
+     and remember those lines. */
+  cxt->lines = (char **)xmalloc ((1 + (cxt->hlen = i)) * sizeof (char *));
+  for (i = 0; i < cxt->hlen; i++)
+    cxt->lines[i] = hlist[i]->line;
+
+  if (_rl_saved_line_for_history)
+    cxt->lines[i] = _rl_saved_line_for_history->line;
+  else
+    {
+      /* Keep track of this so we can free it. */
+      cxt->allocated_line = (char *)xmalloc (1 + strlen (rl_line_buffer));
+      strcpy (cxt->allocated_line, &rl_line_buffer[0]);
+      cxt->lines[i] = cxt->allocated_line;
+    }
+
+  cxt->hlen++;
+
+  /* The line where we start the search. */
+  cxt->history_pos = cxt->save_line;
+
+  rl_save_prompt ();
+
+  /* Initialize search parameters. */
+  cxt->search_string = (char *)xmalloc (cxt->search_string_size = 128);
+  cxt->search_string[cxt->search_string_index = 0] = '\0';
+
+  /* Normalize DIRECTION into 1 or -1. */
+  cxt->direction = (direction >= 0) ? 1 : -1;
+
+  cxt->sline = rl_line_buffer;
+  cxt->sline_len = strlen (cxt->sline);
+  cxt->sline_index = rl_point;
+
+  _rl_iscxt = cxt;             /* save globally */
+
+  return cxt;
+}
+
+static void
+_rl_isearch_fini (cxt)
+     _rl_search_cxt *cxt;
+{
+  /* First put back the original state. */
+  strcpy (rl_line_buffer, cxt->lines[cxt->save_line]);
+
+  rl_restore_prompt ();
+
+  /* Save the search string for possible later use. */
+  FREE (last_isearch_string);
+  last_isearch_string = cxt->search_string;
+  last_isearch_string_len = cxt->search_string_index;
+  cxt->search_string = 0;
+
+  if (cxt->last_found_line < cxt->save_line)
+    rl_get_previous_history (cxt->save_line - cxt->last_found_line, 0);
+  else
+    rl_get_next_history (cxt->last_found_line - cxt->save_line, 0);
+
+  /* If the string was not found, put point at the end of the last matching
+     line.  If last_found_line == orig_line, we didn't find any matching
+     history lines at all, so put point back in its original position. */
+  if (cxt->sline_index < 0)
+    {
+      if (cxt->last_found_line == cxt->save_line)
+       cxt->sline_index = cxt->save_point;
+      else
+       cxt->sline_index = strlen (rl_line_buffer);
+      rl_mark = cxt->save_mark;
+    }
+
+  rl_point = cxt->sline_index;
+  /* Don't worry about where to put the mark here; rl_get_previous_history
+     and rl_get_next_history take care of it. */
+
+  rl_clear_message ();
+}
+
+int
+_rl_search_getchar (cxt)
+     _rl_search_cxt *cxt;
+{
+  int c;
+
+  /* Read a key and decide how to proceed. */
+  RL_SETSTATE(RL_STATE_MOREINPUT);
+  c = cxt->lastc = rl_read_key ();
+  RL_UNSETSTATE(RL_STATE_MOREINPUT);
+
+#if defined (HANDLE_MULTIBYTE)
+  if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+    c = cxt->lastc = _rl_read_mbstring (cxt->lastc, cxt->mb, MB_LEN_MAX);
+#endif
+
+  return c;
+}
+
+/* Process just-read character C according to isearch context CXT.  Return
+   -1 if the caller should just free the context and return, 0 if we should
+   break out of the loop, and 1 if we should continue to read characters. */
+int
+_rl_isearch_dispatch (cxt, c)
+     _rl_search_cxt *cxt;
+     int c;
+{
+  int n, wstart, wlen, limit, cval;
+  rl_command_func_t *f;
+
+  f = (rl_command_func_t *)NULL;
+ /* Translate the keys we do something with to opcodes. */
+  if (c >= 0 && _rl_keymap[c].type == ISFUNC)
+    {
+      f = _rl_keymap[c].function;
+
+      if (f == rl_reverse_search_history)
+       cxt->lastc = (cxt->sflags & SF_REVERSE) ? -1 : -2;
+      else if (f == rl_forward_search_history)
+       cxt->lastc = (cxt->sflags & SF_REVERSE) ? -2 : -1;
+      else if (f == rl_rubout)
+       cxt->lastc = -3;
+      else if (c == CTRL ('G'))
+       cxt->lastc = -4;
+      else if (c == CTRL ('W'))        /* XXX */
+       cxt->lastc = -5;
+      else if (c == CTRL ('Y'))        /* XXX */
+       cxt->lastc = -6;
+    }
+
+itrace("_rl_isearch_dispatch: looking for %d in cxt->search_terminators", cxt->lastc);
+  /* The characters in isearch_terminators (set from the user-settable
+     variable isearch-terminators) are used to terminate the search but
+     not subsequently execute the character as a command.  The default
+     value is "\033\012" (ESC and C-J). */
+  if (strchr (cxt->search_terminators, cxt->lastc))
+    {
+itrace("_rl_isearch_dispatch: found %d in search_terminators", cxt->lastc);
+      /* ESC still terminates the search, but if there is pending
+        input or if input arrives within 0.1 seconds (on systems
+        with select(2)) it is used as a prefix character
+        with rl_execute_next.  WATCH OUT FOR THIS!  This is intended
+        to allow the arrow keys to be used like ^F and ^B are used
+        to terminate the search and execute the movement command.
+        XXX - since _rl_input_available depends on the application-
+        settable keyboard timeout value, this could alternatively
+        use _rl_input_queued(100000) */
+      if (cxt->lastc == ESC && _rl_input_available ())
+       rl_execute_next (ESC);
+itrace("_rl_isearch_dispatch: exiting search based on char %d", cxt->lastc);
+      return (0);
+    }
+
+#define ENDSRCH_CHAR(c) \
+  ((CTRL_CHAR (c) || META_CHAR (c) || (c) == RUBOUT) && ((c) != CTRL ('G')))
+
+#if defined (HANDLE_MULTIBYTE)
+  if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+    {
+      if (cxt->lastc >= 0 && (cxt->mb[0] && cxt->mb[1] == '\0') && ENDSRCH_CHAR (cxt->lastc))
+       {
+         /* This sets rl_pending_input to c; it will be picked up the next
+            time rl_read_key is called. */
+         rl_execute_next (cxt->lastc);
+         return (0);
+       }
+    }
+  else
+#endif
+    if (cxt->lastc >= 0 && ENDSRCH_CHAR (cxt->lastc))
+      {
+       /* This sets rl_pending_input to LASTC; it will be picked up the next
+          time rl_read_key is called. */
+       rl_execute_next (cxt->lastc);
+       return (0);
+      }
+
+  /* Now dispatch on the character.  `Opcodes' affect the search string or
+     state.  Other characters are added to the string.  */
+  switch (cxt->lastc)
+    {
+    /* search again */
+    case -1:
+      if (cxt->search_string_index == 0)
+       {
+         if (last_isearch_string)
+           {
+             cxt->search_string_size = 64 + last_isearch_string_len;
+             cxt->search_string = (char *)xrealloc (cxt->search_string, cxt->search_string_size);
+             strcpy (cxt->search_string, last_isearch_string);
+             cxt->search_string_index = last_isearch_string_len;
+             rl_display_search (cxt->search_string, (cxt->sflags & SF_REVERSE), -1);
+             break;
+           }
+         return (1);
+       }
+      else if (cxt->sflags & SF_REVERSE)
+       cxt->sline_index--;
+      else if (cxt->sline_index != cxt->sline_len)
+       cxt->sline_index++;
+      else
+       rl_ding ();
+      break;
+
+    /* switch directions */
+    case -2:
+      cxt->direction = -cxt->direction;
+      if (cxt->direction < 0)
+       cxt->sflags |= SF_REVERSE;
+      else
+       cxt->sflags &= ~SF_REVERSE;
+      break;
+
+    /* delete character from search string. */
+    case -3:   /* C-H, DEL */
+      /* This is tricky.  To do this right, we need to keep a
+        stack of search positions for the current search, with
+        sentinels marking the beginning and end.  But this will
+        do until we have a real isearch-undo. */
+      if (cxt->search_string_index == 0)
+       rl_ding ();
+      else
+       cxt->search_string[--cxt->search_string_index] = '\0';
+      break;
+
+    case -4:   /* C-G, abort */
+      rl_replace_line (cxt->lines[cxt->save_line], 0);
+      rl_point = cxt->save_point;
+      rl_mark = cxt->save_mark;
+      rl_restore_prompt();
+      rl_clear_message ();
+
+      return -1;
+
+    case -5:   /* C-W */
+      /* skip over portion of line we already matched and yank word */
+      wstart = rl_point + cxt->search_string_index;
+      if (wstart >= rl_end)
+       {
+         rl_ding ();
+         break;
+       }
+
+      /* if not in a word, move to one. */
+      cval = _rl_char_value (rl_line_buffer, wstart);
+      if (_rl_walphabetic (cval) == 0)
+       {
+         rl_ding ();
+         break;
+       }
+      n = MB_NEXTCHAR (rl_line_buffer, wstart, 1, MB_FIND_NONZERO);;
+      while (n < rl_end)
+       {
+         cval = _rl_char_value (rl_line_buffer, n);
+         if (_rl_walphabetic (cval) == 0)
+           break;
+         n = MB_NEXTCHAR (rl_line_buffer, n, 1, MB_FIND_NONZERO);;
+       }
+      wlen = n - wstart + 1;
+      if (cxt->search_string_index + wlen + 1 >= cxt->search_string_size)
+       {
+         cxt->search_string_size += wlen + 1;
+         cxt->search_string = (char *)xrealloc (cxt->search_string, cxt->search_string_size);
+       }
+      for (; wstart < n; wstart++)
+       cxt->search_string[cxt->search_string_index++] = rl_line_buffer[wstart];
+      cxt->search_string[cxt->search_string_index] = '\0';
+      break;
+
+    case -6:   /* C-Y */
+      /* skip over portion of line we already matched and yank rest */
+      wstart = rl_point + cxt->search_string_index;
+      if (wstart >= rl_end)
+       {
+         rl_ding ();
+         break;
+       }
+      n = rl_end - wstart + 1;
+      if (cxt->search_string_index + n + 1 >= cxt->search_string_size)
+       {
+         cxt->search_string_size += n + 1;
+         cxt->search_string = (char *)xrealloc (cxt->search_string, cxt->search_string_size);
+       }
+      for (n = wstart; n < rl_end; n++)
+       cxt->search_string[cxt->search_string_index++] = rl_line_buffer[n];
+      cxt->search_string[cxt->search_string_index] = '\0';
+      break;
+
+    /* Add character to search string and continue search. */
+    default:
+      if (cxt->search_string_index + 2 >= cxt->search_string_size)
+       {
+         cxt->search_string_size += 128;
+         cxt->search_string = (char *)xrealloc (cxt->search_string, cxt->search_string_size);
+       }
+#if defined (HANDLE_MULTIBYTE)
+      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+       {
+         int j, l;
+         for (j = 0, l = strlen (cxt->mb); j < l; )
+           cxt->search_string[cxt->search_string_index++] = cxt->mb[j++];
+       }
+      else
+#endif
+       cxt->search_string[cxt->search_string_index++] = c;
+      cxt->search_string[cxt->search_string_index] = '\0';
+      break;
+    }
+
+  for (cxt->sflags &= ~(SF_FOUND|SF_FAILED);; )
+    {
+      limit = cxt->sline_len - cxt->search_string_index + 1;
+
+      /* Search the current line. */
+      while ((cxt->sflags & SF_REVERSE) ? (cxt->sline_index >= 0) : (cxt->sline_index < limit))
+       {
+         if (STREQN (cxt->search_string, cxt->sline + cxt->sline_index, cxt->search_string_index))
+           {
+             cxt->sflags |= SF_FOUND;
+             break;
+           }
+         else
+           cxt->sline_index += cxt->direction;
+       }
+      if (cxt->sflags & SF_FOUND)
+       break;
+
+      /* Move to the next line, but skip new copies of the line
+        we just found and lines shorter than the string we're
+        searching for. */
+      do
+       {
+         /* Move to the next line. */
+         cxt->history_pos += cxt->direction;
+
+         /* At limit for direction? */
+         if ((cxt->sflags & SF_REVERSE) ? (cxt->history_pos < 0) : (cxt->history_pos == cxt->hlen))
+           {
+             cxt->sflags |= SF_FAILED;
+             break;
+           }
+
+         /* We will need these later. */
+         cxt->sline = cxt->lines[cxt->history_pos];
+         cxt->sline_len = strlen (cxt->sline);
+       }
+      while ((cxt->prev_line_found && STREQ (cxt->prev_line_found, cxt->lines[cxt->history_pos])) ||
+            (cxt->search_string_index > cxt->sline_len));
+
+      if (cxt->sflags & SF_FAILED)
+       break;
+
+      /* Now set up the line for searching... */
+      cxt->sline_index = (cxt->sflags & SF_REVERSE) ? cxt->sline_len - cxt->search_string_index : 0;
+    }
+
+  if (cxt->sflags & SF_FAILED)
+    {
+      /* We cannot find the search string.  Ding the bell. */
+      rl_ding ();
+      cxt->history_pos = cxt->last_found_line;
+      return 1;
+    }
+
+  /* We have found the search string.  Just display it.  But don't
+     actually move there in the history list until the user accepts
+     the location. */
+  if (cxt->sflags & SF_FOUND)
+    {
+      cxt->prev_line_found = cxt->lines[cxt->history_pos];
+      rl_replace_line (cxt->lines[cxt->history_pos], 0);
+      rl_point = cxt->sline_index;
+      cxt->last_found_line = cxt->history_pos;
+      rl_display_search (cxt->search_string, (cxt->sflags & SF_REVERSE), (cxt->history_pos == cxt->save_line) ? -1 : cxt->history_pos);
+    }
+
+  return 1;
+}
+
+static int
+_rl_isearch_cleanup (cxt, r)
+     _rl_search_cxt *cxt;
+     int r;
+{
+  if (r >= 0)
+    _rl_isearch_fini (cxt);
+  _rl_scxt_dispose (cxt, 0);
+  _rl_iscxt = 0;
+
+  RL_UNSETSTATE(RL_STATE_ISEARCH);
+
+  return (r != 0);
+}
+
+/* Search through the history looking for an interactively typed string.
+   This is analogous to i-search.  We start the search in the current line.
+   DIRECTION is which direction to search; >= 0 means forward, < 0 means
+   backwards. */
+static int
+rl_search_history (direction, invoking_key)
+     int direction, invoking_key;
+{
+  _rl_search_cxt *cxt;         /* local for now, but saved globally */
+  int c, r;
+
+  RL_SETSTATE(RL_STATE_ISEARCH);
+  cxt = _rl_isearch_init (direction);
+
+  rl_display_search (cxt->search_string, (cxt->sflags & SF_REVERSE), -1);
+
+  /* If we are using the callback interface, all we do is set up here and
+      return.  The key is that we leave RL_STATE_ISEARCH set. */
+  if (RL_ISSTATE (RL_STATE_CALLBACK))
+    return (0);
+
+  r = -1;
+  for (;;)
+    {
+      c = _rl_search_getchar (cxt);
+      /* We might want to handle EOF here (c == 0) */
+      r = _rl_isearch_dispatch (cxt, cxt->lastc);
+      if (r <= 0)
+        break;
+    }
+
+  /* The searching is over.  The user may have found the string that she
+     was looking for, or else she may have exited a failing search.  If
+     LINE_INDEX is -1, then that shows that the string searched for was
+     not found.  We use this to determine where to place rl_point. */
+  return (_rl_isearch_cleanup (cxt, r));
+}
+
+#if defined (READLINE_CALLBACKS)
+/* Called from the callback functions when we are ready to read a key.  The
+   callback functions know to call this because RL_ISSTATE(RL_STATE_ISEARCH).
+   If _rl_isearch_dispatch finishes searching, this function is responsible
+   for turning off RL_STATE_ISEARCH, which it does using _rl_isearch_cleanup. */
+int
+_rl_isearch_callback (cxt)
+     _rl_search_cxt *cxt;
+{
+  int c, r;
+
+  c = _rl_search_getchar (cxt);
+  /* We might want to handle EOF here */
+  r = _rl_isearch_dispatch (cxt, cxt->lastc);
+
+  return (r <= 0) ? _rl_isearch_cleanup (cxt, r) : 0;
+}
+#endif
index 8beb5ffc71be8419863f2da7dec5ba075d13c213..c47e3912ef8cc875f69dd434d2dc8e72d50396d0 100644 (file)
@@ -718,6 +718,9 @@ extern int rl_attempted_completion_over;
    functions. */
 extern int rl_completion_type;
 
+/* Set to the last key used to invoke one of the completion functions */
+extern int rl_completion_invoking_key;
+
 /* Up to this many items will be displayed in response to a
    possible-completions call.  After that, we ask the user if she
    is sure she wants to see them all.  The default value is 100. */
@@ -744,6 +747,9 @@ extern int rl_completion_found_quote;
    application-specific completion function. */
 extern int rl_completion_suppress_quote;
 
+/* If non-zero, readline will sort the completion matches.  On by default. */
+extern int rl_sort_completion_matches;
+
 /* If non-zero, a slash will be appended to completed filenames that are
    symbolic links to directory names, subject to the value of the
    mark-directories variable (which is user-settable).  This exists so
diff --git a/lib/readline/readline.h~ b/lib/readline/readline.h~
new file mode 100644 (file)
index 0000000..8beb5ff
--- /dev/null
@@ -0,0 +1,858 @@
+/* Readline.h -- the names of functions callable from within readline. */
+
+/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
+
+   This file is part of the GNU Readline Library, a library for
+   reading lines of text with interactive input and history editing.
+
+   The GNU Readline Library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU General Public License
+   as published by the Free Software Foundation; either version 2, or
+   (at your option) any later version.
+
+   The GNU Readline Library 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.
+
+   The GNU General Public License is often shipped with GNU software, and
+   is generally kept in a file called COPYING or LICENSE.  If you do not
+   have a copy of the license, write to the Free Software Foundation,
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+#if !defined (_READLINE_H_)
+#define _READLINE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined (READLINE_LIBRARY)
+#  include "rlstdc.h"
+#  include "rltypedefs.h"
+#  include "keymaps.h"
+#  include "tilde.h"
+#else
+#  include <readline/rlstdc.h>
+#  include <readline/rltypedefs.h>
+#  include <readline/keymaps.h>
+#  include <readline/tilde.h>
+#endif
+
+/* Hex-encoded Readline version number. */
+#define RL_READLINE_VERSION    0x0502          /* Readline 5.2 */
+#define RL_VERSION_MAJOR       5
+#define RL_VERSION_MINOR       2
+
+/* Readline data structures. */
+
+/* Maintaining the state of undo.  We remember individual deletes and inserts
+   on a chain of things to do. */
+
+/* The actions that undo knows how to undo.  Notice that UNDO_DELETE means
+   to insert some text, and UNDO_INSERT means to delete some text.   I.e.,
+   the code tells undo what to undo, not how to undo it. */
+enum undo_code { UNDO_DELETE, UNDO_INSERT, UNDO_BEGIN, UNDO_END };
+
+/* What an element of THE_UNDO_LIST looks like. */
+typedef struct undo_list {
+  struct undo_list *next;
+  int start, end;              /* Where the change took place. */
+  char *text;                  /* The text to insert, if undoing a delete. */
+  enum undo_code what;         /* Delete, Insert, Begin, End. */
+} UNDO_LIST;
+
+/* The current undo list for RL_LINE_BUFFER. */
+extern UNDO_LIST *rl_undo_list;
+
+/* The data structure for mapping textual names to code addresses. */
+typedef struct _funmap {
+  const char *name;
+  rl_command_func_t *function;
+} FUNMAP;
+
+extern FUNMAP **funmap;
+
+/* **************************************************************** */
+/*                                                                 */
+/*          Functions available to bind to key sequences           */
+/*                                                                 */
+/* **************************************************************** */
+
+/* Bindable commands for numeric arguments. */
+extern int rl_digit_argument PARAMS((int, int));
+extern int rl_universal_argument PARAMS((int, int));
+
+/* Bindable commands for moving the cursor. */
+extern int rl_forward_byte PARAMS((int, int));
+extern int rl_forward_char PARAMS((int, int));
+extern int rl_forward PARAMS((int, int));
+extern int rl_backward_byte PARAMS((int, int));
+extern int rl_backward_char PARAMS((int, int));
+extern int rl_backward PARAMS((int, int));
+extern int rl_beg_of_line PARAMS((int, int));
+extern int rl_end_of_line PARAMS((int, int));
+extern int rl_forward_word PARAMS((int, int));
+extern int rl_backward_word PARAMS((int, int));
+extern int rl_refresh_line PARAMS((int, int));
+extern int rl_clear_screen PARAMS((int, int));
+extern int rl_arrow_keys PARAMS((int, int));
+
+/* Bindable commands for inserting and deleting text. */
+extern int rl_insert PARAMS((int, int));
+extern int rl_quoted_insert PARAMS((int, int));
+extern int rl_tab_insert PARAMS((int, int));
+extern int rl_newline PARAMS((int, int));
+extern int rl_do_lowercase_version PARAMS((int, int));
+extern int rl_rubout PARAMS((int, int));
+extern int rl_delete PARAMS((int, int));
+extern int rl_rubout_or_delete PARAMS((int, int));
+extern int rl_delete_horizontal_space PARAMS((int, int));
+extern int rl_delete_or_show_completions PARAMS((int, int));
+extern int rl_insert_comment PARAMS((int, int));
+
+/* Bindable commands for changing case. */
+extern int rl_upcase_word PARAMS((int, int));
+extern int rl_downcase_word PARAMS((int, int));
+extern int rl_capitalize_word PARAMS((int, int));
+
+/* Bindable commands for transposing characters and words. */
+extern int rl_transpose_words PARAMS((int, int));
+extern int rl_transpose_chars PARAMS((int, int));
+
+/* Bindable commands for searching within a line. */
+extern int rl_char_search PARAMS((int, int));
+extern int rl_backward_char_search PARAMS((int, int));
+
+/* Bindable commands for readline's interface to the command history. */
+extern int rl_beginning_of_history PARAMS((int, int));
+extern int rl_end_of_history PARAMS((int, int));
+extern int rl_get_next_history PARAMS((int, int));
+extern int rl_get_previous_history PARAMS((int, int));
+
+/* Bindable commands for managing the mark and region. */
+extern int rl_set_mark PARAMS((int, int));
+extern int rl_exchange_point_and_mark PARAMS((int, int));
+
+/* Bindable commands to set the editing mode (emacs or vi). */
+extern int rl_vi_editing_mode PARAMS((int, int));
+extern int rl_emacs_editing_mode PARAMS((int, int));
+
+/* Bindable commands to change the insert mode (insert or overwrite) */
+extern int rl_overwrite_mode PARAMS((int, int));
+
+/* Bindable commands for managing key bindings. */
+extern int rl_re_read_init_file PARAMS((int, int));
+extern int rl_dump_functions PARAMS((int, int));
+extern int rl_dump_macros PARAMS((int, int));
+extern int rl_dump_variables PARAMS((int, int));
+
+/* Bindable commands for word completion. */
+extern int rl_complete PARAMS((int, int));
+extern int rl_possible_completions PARAMS((int, int));
+extern int rl_insert_completions PARAMS((int, int));
+extern int rl_menu_complete PARAMS((int, int));
+
+/* Bindable commands for killing and yanking text, and managing the kill ring. */
+extern int rl_kill_word PARAMS((int, int));
+extern int rl_backward_kill_word PARAMS((int, int));
+extern int rl_kill_line PARAMS((int, int));
+extern int rl_backward_kill_line PARAMS((int, int));
+extern int rl_kill_full_line PARAMS((int, int));
+extern int rl_unix_word_rubout PARAMS((int, int));
+extern int rl_unix_filename_rubout PARAMS((int, int));
+extern int rl_unix_line_discard PARAMS((int, int));
+extern int rl_copy_region_to_kill PARAMS((int, int));
+extern int rl_kill_region PARAMS((int, int));
+extern int rl_copy_forward_word PARAMS((int, int));
+extern int rl_copy_backward_word PARAMS((int, int));
+extern int rl_yank PARAMS((int, int));
+extern int rl_yank_pop PARAMS((int, int));
+extern int rl_yank_nth_arg PARAMS((int, int));
+extern int rl_yank_last_arg PARAMS((int, int));
+/* Not available unless __CYGWIN__ is defined. */
+#ifdef __CYGWIN__
+extern int rl_paste_from_clipboard PARAMS((int, int));
+#endif
+
+/* Bindable commands for incremental searching. */
+extern int rl_reverse_search_history PARAMS((int, int));
+extern int rl_forward_search_history PARAMS((int, int));
+
+/* Bindable keyboard macro commands. */
+extern int rl_start_kbd_macro PARAMS((int, int));
+extern int rl_end_kbd_macro PARAMS((int, int));
+extern int rl_call_last_kbd_macro PARAMS((int, int));
+
+/* Bindable undo commands. */
+extern int rl_revert_line PARAMS((int, int));
+extern int rl_undo_command PARAMS((int, int));
+
+/* Bindable tilde expansion commands. */
+extern int rl_tilde_expand PARAMS((int, int));
+
+/* Bindable terminal control commands. */
+extern int rl_restart_output PARAMS((int, int));
+extern int rl_stop_output PARAMS((int, int));
+
+/* Miscellaneous bindable commands. */
+extern int rl_abort PARAMS((int, int));
+extern int rl_tty_status PARAMS((int, int));
+
+/* Bindable commands for incremental and non-incremental history searching. */
+extern int rl_history_search_forward PARAMS((int, int));
+extern int rl_history_search_backward PARAMS((int, int));
+extern int rl_noninc_forward_search PARAMS((int, int));
+extern int rl_noninc_reverse_search PARAMS((int, int));
+extern int rl_noninc_forward_search_again PARAMS((int, int));
+extern int rl_noninc_reverse_search_again PARAMS((int, int));
+
+/* Bindable command used when inserting a matching close character. */
+extern int rl_insert_close PARAMS((int, int));
+
+/* Not available unless READLINE_CALLBACKS is defined. */
+extern void rl_callback_handler_install PARAMS((const char *, rl_vcpfunc_t *));
+extern void rl_callback_read_char PARAMS((void));
+extern void rl_callback_handler_remove PARAMS((void));
+
+/* Things for vi mode. Not available unless readline is compiled -DVI_MODE. */
+/* VI-mode bindable commands. */
+extern int rl_vi_redo PARAMS((int, int));
+extern int rl_vi_undo PARAMS((int, int));
+extern int rl_vi_yank_arg PARAMS((int, int));
+extern int rl_vi_fetch_history PARAMS((int, int));
+extern int rl_vi_search_again PARAMS((int, int));
+extern int rl_vi_search PARAMS((int, int));
+extern int rl_vi_complete PARAMS((int, int));
+extern int rl_vi_tilde_expand PARAMS((int, int));
+extern int rl_vi_prev_word PARAMS((int, int));
+extern int rl_vi_next_word PARAMS((int, int));
+extern int rl_vi_end_word PARAMS((int, int));
+extern int rl_vi_insert_beg PARAMS((int, int));
+extern int rl_vi_append_mode PARAMS((int, int));
+extern int rl_vi_append_eol PARAMS((int, int));
+extern int rl_vi_eof_maybe PARAMS((int, int));
+extern int rl_vi_insertion_mode PARAMS((int, int));
+extern int rl_vi_movement_mode PARAMS((int, int));
+extern int rl_vi_arg_digit PARAMS((int, int));
+extern int rl_vi_change_case PARAMS((int, int));
+extern int rl_vi_put PARAMS((int, int));
+extern int rl_vi_column PARAMS((int, int));
+extern int rl_vi_delete_to PARAMS((int, int));
+extern int rl_vi_change_to PARAMS((int, int));
+extern int rl_vi_yank_to PARAMS((int, int));
+extern int rl_vi_rubout PARAMS((int, int));
+extern int rl_vi_delete PARAMS((int, int));
+extern int rl_vi_back_to_indent PARAMS((int, int));
+extern int rl_vi_first_print PARAMS((int, int));
+extern int rl_vi_char_search PARAMS((int, int));
+extern int rl_vi_match PARAMS((int, int));
+extern int rl_vi_change_char PARAMS((int, int));
+extern int rl_vi_subst PARAMS((int, int));
+extern int rl_vi_overstrike PARAMS((int, int));
+extern int rl_vi_overstrike_delete PARAMS((int, int));
+extern int rl_vi_replace PARAMS((int, int));
+extern int rl_vi_set_mark PARAMS((int, int));
+extern int rl_vi_goto_mark PARAMS((int, int));
+
+/* VI-mode utility functions. */
+extern int rl_vi_check PARAMS((void));
+extern int rl_vi_domove PARAMS((int, int *));
+extern int rl_vi_bracktype PARAMS((int));
+
+extern void rl_vi_start_inserting PARAMS((int, int, int));
+
+/* VI-mode pseudo-bindable commands, used as utility functions. */
+extern int rl_vi_fWord PARAMS((int, int));
+extern int rl_vi_bWord PARAMS((int, int));
+extern int rl_vi_eWord PARAMS((int, int));
+extern int rl_vi_fword PARAMS((int, int));
+extern int rl_vi_bword PARAMS((int, int));
+extern int rl_vi_eword PARAMS((int, int));
+
+/* **************************************************************** */
+/*                                                                 */
+/*                     Well Published Functions                    */
+/*                                                                 */
+/* **************************************************************** */
+
+/* Readline functions. */
+/* Read a line of input.  Prompt with PROMPT.  A NULL PROMPT means none. */
+extern char *readline PARAMS((const char *));
+
+extern int rl_set_prompt PARAMS((const char *));
+extern int rl_expand_prompt PARAMS((char *));
+
+extern int rl_initialize PARAMS((void));
+
+/* Undocumented; unused by readline */
+extern int rl_discard_argument PARAMS((void));
+
+/* Utility functions to bind keys to readline commands. */
+extern int rl_add_defun PARAMS((const char *, rl_command_func_t *, int));
+extern int rl_bind_key PARAMS((int, rl_command_func_t *));
+extern int rl_bind_key_in_map PARAMS((int, rl_command_func_t *, Keymap));
+extern int rl_unbind_key PARAMS((int));
+extern int rl_unbind_key_in_map PARAMS((int, Keymap));
+extern int rl_bind_key_if_unbound PARAMS((int, rl_command_func_t *));
+extern int rl_bind_key_if_unbound_in_map PARAMS((int, rl_command_func_t *, Keymap));
+extern int rl_unbind_function_in_map PARAMS((rl_command_func_t *, Keymap));
+extern int rl_unbind_command_in_map PARAMS((const char *, Keymap));
+extern int rl_bind_keyseq PARAMS((const char *, rl_command_func_t *));
+extern int rl_bind_keyseq_in_map PARAMS((const char *, rl_command_func_t *, Keymap));
+extern int rl_bind_keyseq_if_unbound PARAMS((const char *, rl_command_func_t *));
+extern int rl_bind_keyseq_if_unbound_in_map PARAMS((const char *, rl_command_func_t *, Keymap));
+extern int rl_generic_bind PARAMS((int, const char *, char *, Keymap));
+
+extern char *rl_variable_value PARAMS((const char *));
+extern int rl_variable_bind PARAMS((const char *, const char *));
+
+/* Backwards compatibility, use rl_bind_keyseq_in_map instead. */
+extern int rl_set_key PARAMS((const char *, rl_command_func_t *, Keymap));
+
+/* Backwards compatibility, use rl_generic_bind instead. */
+extern int rl_macro_bind PARAMS((const char *, const char *, Keymap));
+
+/* Undocumented in the texinfo manual; not really useful to programs. */
+extern int rl_translate_keyseq PARAMS((const char *, char *, int *));
+extern char *rl_untranslate_keyseq PARAMS((int));
+
+extern rl_command_func_t *rl_named_function PARAMS((const char *));
+extern rl_command_func_t *rl_function_of_keyseq PARAMS((const char *, Keymap, int *));
+
+extern void rl_list_funmap_names PARAMS((void));
+extern char **rl_invoking_keyseqs_in_map PARAMS((rl_command_func_t *, Keymap));
+extern char **rl_invoking_keyseqs PARAMS((rl_command_func_t *));
+extern void rl_function_dumper PARAMS((int));
+extern void rl_macro_dumper PARAMS((int));
+extern void rl_variable_dumper PARAMS((int));
+
+extern int rl_read_init_file PARAMS((const char *));
+extern int rl_parse_and_bind PARAMS((char *));
+
+/* Functions for manipulating keymaps. */
+extern Keymap rl_make_bare_keymap PARAMS((void));
+extern Keymap rl_copy_keymap PARAMS((Keymap));
+extern Keymap rl_make_keymap PARAMS((void));
+extern void rl_discard_keymap PARAMS((Keymap));
+
+extern Keymap rl_get_keymap_by_name PARAMS((const char *));
+extern char *rl_get_keymap_name PARAMS((Keymap));
+extern void rl_set_keymap PARAMS((Keymap));
+extern Keymap rl_get_keymap PARAMS((void));
+/* Undocumented; used internally only. */
+extern void rl_set_keymap_from_edit_mode PARAMS((void));
+extern char *rl_get_keymap_name_from_edit_mode PARAMS((void));
+
+/* Functions for manipulating the funmap, which maps command names to functions. */
+extern int rl_add_funmap_entry PARAMS((const char *, rl_command_func_t *));
+extern const char **rl_funmap_names PARAMS((void));
+/* Undocumented, only used internally -- there is only one funmap, and this
+   function may be called only once. */
+extern void rl_initialize_funmap PARAMS((void));
+
+/* Utility functions for managing keyboard macros. */
+extern void rl_push_macro_input PARAMS((char *));
+
+/* Functions for undoing, from undo.c */
+extern void rl_add_undo PARAMS((enum undo_code, int, int, char *));
+extern void rl_free_undo_list PARAMS((void));
+extern int rl_do_undo PARAMS((void));
+extern int rl_begin_undo_group PARAMS((void));
+extern int rl_end_undo_group PARAMS((void));
+extern int rl_modifying PARAMS((int, int));
+
+/* Functions for redisplay. */
+extern void rl_redisplay PARAMS((void));
+extern int rl_on_new_line PARAMS((void));
+extern int rl_on_new_line_with_prompt PARAMS((void));
+extern int rl_forced_update_display PARAMS((void));
+extern int rl_clear_message PARAMS((void));
+extern int rl_reset_line_state PARAMS((void));
+extern int rl_crlf PARAMS((void));
+
+#if defined (USE_VARARGS) && defined (PREFER_STDARG)
+extern int rl_message (const char *, ...)  __attribute__((__format__ (printf, 1, 2)));
+#else
+extern int rl_message ();
+#endif
+
+extern int rl_show_char PARAMS((int));
+
+/* Undocumented in texinfo manual. */
+extern int rl_character_len PARAMS((int, int));
+
+/* Save and restore internal prompt redisplay information. */
+extern void rl_save_prompt PARAMS((void));
+extern void rl_restore_prompt PARAMS((void));
+
+/* Modifying text. */
+extern void rl_replace_line PARAMS((const char *, int));
+extern int rl_insert_text PARAMS((const char *));
+extern int rl_delete_text PARAMS((int, int));
+extern int rl_kill_text PARAMS((int, int));
+extern char *rl_copy_text PARAMS((int, int));
+
+/* Terminal and tty mode management. */
+extern void rl_prep_terminal PARAMS((int));
+extern void rl_deprep_terminal PARAMS((void));
+extern void rl_tty_set_default_bindings PARAMS((Keymap));
+extern void rl_tty_unset_default_bindings PARAMS((Keymap));
+
+extern int rl_reset_terminal PARAMS((const char *));
+extern void rl_resize_terminal PARAMS((void));
+extern void rl_set_screen_size PARAMS((int, int));
+extern void rl_get_screen_size PARAMS((int *, int *));
+extern void rl_reset_screen_size PARAMS((void));
+
+extern char *rl_get_termcap PARAMS((const char *));
+
+/* Functions for character input. */
+extern int rl_stuff_char PARAMS((int));
+extern int rl_execute_next PARAMS((int));
+extern int rl_clear_pending_input PARAMS((void));
+extern int rl_read_key PARAMS((void));
+extern int rl_getc PARAMS((FILE *));
+extern int rl_set_keyboard_input_timeout PARAMS((int));
+
+/* `Public' utility functions . */
+extern void rl_extend_line_buffer PARAMS((int));
+extern int rl_ding PARAMS((void));
+extern int rl_alphabetic PARAMS((int));
+extern void rl_free PARAMS((void *));
+
+/* Readline signal handling, from signals.c */
+extern int rl_set_signals PARAMS((void));
+extern int rl_clear_signals PARAMS((void));
+extern void rl_cleanup_after_signal PARAMS((void));
+extern void rl_reset_after_signal PARAMS((void));
+extern void rl_free_line_state PARAMS((void));
+extern int rl_set_paren_blink_timeout PARAMS((int));
+
+/* Undocumented. */
+extern int rl_maybe_save_line PARAMS((void));
+extern int rl_maybe_unsave_line PARAMS((void));
+extern int rl_maybe_replace_line PARAMS((void));
+
+/* Completion functions. */
+extern int rl_complete_internal PARAMS((int));
+extern void rl_display_match_list PARAMS((char **, int, int));
+
+extern char **rl_completion_matches PARAMS((const char *, rl_compentry_func_t *));
+extern char *rl_username_completion_function PARAMS((const char *, int));
+extern char *rl_filename_completion_function PARAMS((const char *, int));
+
+extern int rl_completion_mode PARAMS((rl_command_func_t *));
+
+#if 0
+/* Backwards compatibility (compat.c).  These will go away sometime. */
+extern void free_undo_list PARAMS((void));
+extern int maybe_save_line PARAMS((void));
+extern int maybe_unsave_line PARAMS((void));
+extern int maybe_replace_line PARAMS((void));
+
+extern int ding PARAMS((void));
+extern int alphabetic PARAMS((int));
+extern int crlf PARAMS((void));
+
+extern char **completion_matches PARAMS((char *, rl_compentry_func_t *));
+extern char *username_completion_function PARAMS((const char *, int));
+extern char *filename_completion_function PARAMS((const char *, int));
+#endif
+
+/* **************************************************************** */
+/*                                                                 */
+/*                     Well Published Variables                    */
+/*                                                                 */
+/* **************************************************************** */
+
+/* The version of this incarnation of the readline library. */
+extern const char *rl_library_version;         /* e.g., "4.2" */
+extern int rl_readline_version;                        /* e.g., 0x0402 */
+
+/* True if this is real GNU readline. */
+extern int rl_gnu_readline_p;
+
+/* Flags word encapsulating the current readline state. */
+extern int rl_readline_state;
+
+/* Says which editing mode readline is currently using.  1 means emacs mode;
+   0 means vi mode. */
+extern int rl_editing_mode;
+
+/* Insert or overwrite mode for emacs mode.  1 means insert mode; 0 means
+   overwrite mode.  Reset to insert mode on each input line. */
+extern int rl_insert_mode;
+
+/* The name of the calling program.  You should initialize this to
+   whatever was in argv[0].  It is used when parsing conditionals. */
+extern const char *rl_readline_name;
+
+/* The prompt readline uses.  This is set from the argument to
+   readline (), and should not be assigned to directly. */
+extern char *rl_prompt;
+
+/* The prompt string that is actually displayed by rl_redisplay.  Public so
+   applications can more easily supply their own redisplay functions. */
+extern char *rl_display_prompt;
+
+/* The line buffer that is in use. */
+extern char *rl_line_buffer;
+
+/* The location of point, and end. */
+extern int rl_point;
+extern int rl_end;
+
+/* The mark, or saved cursor position. */
+extern int rl_mark;
+
+/* Flag to indicate that readline has finished with the current input
+   line and should return it. */
+extern int rl_done;
+
+/* If set to a character value, that will be the next keystroke read. */
+extern int rl_pending_input;
+
+/* Non-zero if we called this function from _rl_dispatch().  It's present
+   so functions can find out whether they were called from a key binding
+   or directly from an application. */
+extern int rl_dispatching;
+
+/* Non-zero if the user typed a numeric argument before executing the
+   current function. */
+extern int rl_explicit_arg;
+
+/* The current value of the numeric argument specified by the user. */
+extern int rl_numeric_arg;
+
+/* The address of the last command function Readline executed. */
+extern rl_command_func_t *rl_last_func;
+
+/* The name of the terminal to use. */
+extern const char *rl_terminal_name;
+
+/* The input and output streams. */
+extern FILE *rl_instream;
+extern FILE *rl_outstream;
+
+/* If non-zero, Readline gives values of LINES and COLUMNS from the environment
+   greater precedence than values fetched from the kernel when computing the
+   screen dimensions. */
+extern int rl_prefer_env_winsize;
+
+/* If non-zero, then this is the address of a function to call just
+   before readline_internal () prints the first prompt. */
+extern rl_hook_func_t *rl_startup_hook;
+
+/* If non-zero, this is the address of a function to call just before
+   readline_internal_setup () returns and readline_internal starts
+   reading input characters. */
+extern rl_hook_func_t *rl_pre_input_hook;
+      
+/* The address of a function to call periodically while Readline is
+   awaiting character input, or NULL, for no event handling. */
+extern rl_hook_func_t *rl_event_hook;
+
+/* The address of the function to call to fetch a character from the current
+   Readline input stream */
+extern rl_getc_func_t *rl_getc_function;
+
+extern rl_voidfunc_t *rl_redisplay_function;
+
+extern rl_vintfunc_t *rl_prep_term_function;
+extern rl_voidfunc_t *rl_deprep_term_function;
+
+/* Dispatch variables. */
+extern Keymap rl_executing_keymap;
+extern Keymap rl_binding_keymap;
+
+/* Display variables. */
+/* If non-zero, readline will erase the entire line, including any prompt,
+   if the only thing typed on an otherwise-blank line is something bound to
+   rl_newline. */
+extern int rl_erase_empty_line;
+
+/* If non-zero, the application has already printed the prompt (rl_prompt)
+   before calling readline, so readline should not output it the first time
+   redisplay is done. */
+extern int rl_already_prompted;
+
+/* A non-zero value means to read only this many characters rather than
+   up to a character bound to accept-line. */
+extern int rl_num_chars_to_read;
+
+/* The text of a currently-executing keyboard macro. */
+extern char *rl_executing_macro;
+
+/* Variables to control readline signal handling. */
+/* If non-zero, readline will install its own signal handlers for
+   SIGINT, SIGTERM, SIGQUIT, SIGALRM, SIGTSTP, SIGTTIN, and SIGTTOU. */
+extern int rl_catch_signals;
+
+/* If non-zero, readline will install a signal handler for SIGWINCH
+   that also attempts to call any calling application's SIGWINCH signal
+   handler.  Note that the terminal is not cleaned up before the
+   application's signal handler is called; use rl_cleanup_after_signal()
+   to do that. */
+extern int rl_catch_sigwinch;
+
+/* Completion variables. */
+/* Pointer to the generator function for completion_matches ().
+   NULL means to use rl_filename_completion_function (), the default
+   filename completer. */
+extern rl_compentry_func_t *rl_completion_entry_function;
+
+/* If rl_ignore_some_completions_function is non-NULL it is the address
+   of a function to call after all of the possible matches have been
+   generated, but before the actual completion is done to the input line.
+   The function is called with one argument; a NULL terminated array
+   of (char *).  If your function removes any of the elements, they
+   must be free()'ed. */
+extern rl_compignore_func_t *rl_ignore_some_completions_function;
+
+/* Pointer to alternative function to create matches.
+   Function is called with TEXT, START, and END.
+   START and END are indices in RL_LINE_BUFFER saying what the boundaries
+   of TEXT are.
+   If this function exists and returns NULL then call the value of
+   rl_completion_entry_function to try to match, otherwise use the
+   array of strings returned. */
+extern rl_completion_func_t *rl_attempted_completion_function;
+
+/* The basic list of characters that signal a break between words for the
+   completer routine.  The initial contents of this variable is what
+   breaks words in the shell, i.e. "n\"\\'`@$>". */
+extern const char *rl_basic_word_break_characters;
+
+/* The list of characters that signal a break between words for
+   rl_complete_internal.  The default list is the contents of
+   rl_basic_word_break_characters.  */
+extern /*const*/ char *rl_completer_word_break_characters;
+
+/* Hook function to allow an application to set the completion word
+   break characters before readline breaks up the line.  Allows
+   position-dependent word break characters. */
+extern rl_cpvfunc_t *rl_completion_word_break_hook;
+
+/* List of characters which can be used to quote a substring of the line.
+   Completion occurs on the entire substring, and within the substring   
+   rl_completer_word_break_characters are treated as any other character,
+   unless they also appear within this list. */
+extern const char *rl_completer_quote_characters;
+
+/* List of quote characters which cause a word break. */
+extern const char *rl_basic_quote_characters;
+
+/* List of characters that need to be quoted in filenames by the completer. */
+extern const char *rl_filename_quote_characters;
+
+/* List of characters that are word break characters, but should be left
+   in TEXT when it is passed to the completion function.  The shell uses
+   this to help determine what kind of completing to do. */
+extern const char *rl_special_prefixes;
+
+/* If non-zero, then this is the address of a function to call when
+   completing on a directory name.  The function is called with
+   the address of a string (the current directory name) as an arg.  It
+   changes what is displayed when the possible completions are printed
+   or inserted. */
+extern rl_icppfunc_t *rl_directory_completion_hook;
+
+/* If non-zero, this is the address of a function to call when completing
+   a directory name.  This function takes the address of the directory name
+   to be modified as an argument.  Unlike rl_directory_completion_hook, it
+   only modifies the directory name used in opendir(2), not what is displayed
+   when the possible completions are printed or inserted.  It is called
+   before rl_directory_completion_hook.  I'm not happy with how this works
+   yet, so it's undocumented. */
+extern rl_icppfunc_t *rl_directory_rewrite_hook;
+
+/* Backwards compatibility with previous versions of readline. */
+#define rl_symbolic_link_hook rl_directory_completion_hook
+
+/* If non-zero, then this is the address of a function to call when
+   completing a word would normally display the list of possible matches.
+   This function is called instead of actually doing the display.
+   It takes three arguments: (char **matches, int num_matches, int max_length)
+   where MATCHES is the array of strings that matched, NUM_MATCHES is the
+   number of strings in that array, and MAX_LENGTH is the length of the
+   longest string in that array. */
+extern rl_compdisp_func_t *rl_completion_display_matches_hook;
+
+/* Non-zero means that the results of the matches are to be treated
+   as filenames.  This is ALWAYS zero on entry, and can only be changed
+   within a completion entry finder function. */
+extern int rl_filename_completion_desired;
+
+/* Non-zero means that the results of the matches are to be quoted using
+   double quotes (or an application-specific quoting mechanism) if the
+   filename contains any characters in rl_word_break_chars.  This is
+   ALWAYS non-zero on entry, and can only be changed within a completion
+   entry finder function. */
+extern int rl_filename_quoting_desired;
+
+/* Set to a function to quote a filename in an application-specific fashion.
+   Called with the text to quote, the type of match found (single or multiple)
+   and a pointer to the quoting character to be used, which the function can
+   reset if desired. */
+extern rl_quote_func_t *rl_filename_quoting_function;
+
+/* Function to call to remove quoting characters from a filename.  Called
+   before completion is attempted, so the embedded quotes do not interfere
+   with matching names in the file system. */
+extern rl_dequote_func_t *rl_filename_dequoting_function;
+
+/* Function to call to decide whether or not a word break character is
+   quoted.  If a character is quoted, it does not break words for the
+   completer. */
+extern rl_linebuf_func_t *rl_char_is_quoted_p;
+
+/* Non-zero means to suppress normal filename completion after the
+   user-specified completion function has been called. */
+extern int rl_attempted_completion_over;
+
+/* Set to a character describing the type of completion being attempted by
+   rl_complete_internal; available for use by application completion
+   functions. */
+extern int rl_completion_type;
+
+/* Up to this many items will be displayed in response to a
+   possible-completions call.  After that, we ask the user if she
+   is sure she wants to see them all.  The default value is 100. */
+extern int rl_completion_query_items;
+
+/* Character appended to completed words when at the end of the line.  The
+   default is a space.  Nothing is added if this is '\0'. */
+extern int rl_completion_append_character;
+
+/* If set to non-zero by an application completion function,
+   rl_completion_append_character will not be appended. */
+extern int rl_completion_suppress_append;
+
+/* Set to any quote character readline thinks it finds before any application
+   completion function is called. */
+extern int rl_completion_quote_character;
+
+/* Set to a non-zero value if readline found quoting anywhere in the word to
+   be completed; set before any application completion function is called. */
+extern int rl_completion_found_quote;
+
+/* If non-zero, the completion functions don't append any closing quote.
+   This is set to 0 by rl_complete_internal and may be changed by an
+   application-specific completion function. */
+extern int rl_completion_suppress_quote;
+
+/* If non-zero, a slash will be appended to completed filenames that are
+   symbolic links to directory names, subject to the value of the
+   mark-directories variable (which is user-settable).  This exists so
+   that application completion functions can override the user's preference
+   (set via the mark-symlinked-directories variable) if appropriate.
+   It's set to the value of _rl_complete_mark_symlink_dirs in
+   rl_complete_internal before any application-specific completion
+   function is called, so without that function doing anything, the user's
+   preferences are honored. */
+extern int rl_completion_mark_symlink_dirs;
+
+/* If non-zero, then disallow duplicates in the matches. */
+extern int rl_ignore_completion_duplicates;
+
+/* If this is non-zero, completion is (temporarily) inhibited, and the
+   completion character will be inserted as any other. */
+extern int rl_inhibit_completion;
+
+/* Input error; can be returned by (*rl_getc_function) if readline is reading
+   a top-level command (RL_ISSTATE (RL_STATE_READCMD)). */
+#define READERR                        (-2)
+
+/* Definitions available for use by readline clients. */
+#define RL_PROMPT_START_IGNORE '\001'
+#define RL_PROMPT_END_IGNORE   '\002'
+
+/* Possible values for do_replace argument to rl_filename_quoting_function,
+   called by rl_complete_internal. */
+#define NO_MATCH        0
+#define SINGLE_MATCH    1
+#define MULT_MATCH      2
+
+/* Possible state values for rl_readline_state */
+#define RL_STATE_NONE          0x000000                /* no state; before first call */
+
+#define RL_STATE_INITIALIZING  0x000001        /* initializing */
+#define RL_STATE_INITIALIZED   0x000002        /* initialization done */
+#define RL_STATE_TERMPREPPED   0x000004        /* terminal is prepped */
+#define RL_STATE_READCMD       0x000008        /* reading a command key */
+#define RL_STATE_METANEXT      0x000010        /* reading input after ESC */
+#define RL_STATE_DISPATCHING   0x000020        /* dispatching to a command */
+#define RL_STATE_MOREINPUT     0x000040        /* reading more input in a command function */
+#define RL_STATE_ISEARCH       0x000080        /* doing incremental search */
+#define RL_STATE_NSEARCH       0x000100        /* doing non-inc search */
+#define RL_STATE_SEARCH                0x000200        /* doing a history search */
+#define RL_STATE_NUMERICARG    0x000400        /* reading numeric argument */
+#define RL_STATE_MACROINPUT    0x000800        /* getting input from a macro */
+#define RL_STATE_MACRODEF      0x001000        /* defining keyboard macro */
+#define RL_STATE_OVERWRITE     0x002000        /* overwrite mode */
+#define RL_STATE_COMPLETING    0x004000        /* doing completion */
+#define RL_STATE_SIGHANDLER    0x008000        /* in readline sighandler */
+#define RL_STATE_UNDOING       0x010000        /* doing an undo */
+#define RL_STATE_INPUTPENDING  0x020000        /* rl_execute_next called */
+#define RL_STATE_TTYCSAVED     0x040000        /* tty special chars saved */
+#define RL_STATE_CALLBACK      0x080000        /* using the callback interface */
+#define RL_STATE_VIMOTION      0x100000        /* reading vi motion arg */
+#define RL_STATE_MULTIKEY      0x200000        /* reading multiple-key command */
+#define RL_STATE_VICMDONCE     0x400000        /* entered vi command mode at least once */
+
+#define RL_STATE_DONE          0x800000        /* done; accepted line */
+
+#define RL_SETSTATE(x)         (rl_readline_state |= (x))
+#define RL_UNSETSTATE(x)       (rl_readline_state &= ~(x))
+#define RL_ISSTATE(x)          (rl_readline_state & (x))
+
+struct readline_state {
+  /* line state */
+  int point;
+  int end;
+  int mark;
+  char *buffer;
+  int buflen;
+  UNDO_LIST *ul;
+  char *prompt;
+
+  /* global state */
+  int rlstate;
+  int done;
+  Keymap kmap;
+
+  /* input state */
+  rl_command_func_t *lastfunc;
+  int insmode;
+  int edmode;
+  int kseqlen;
+  FILE *inf;
+  FILE *outf;
+  int pendingin;
+  char *macro;
+
+  /* signal state */
+  int catchsigs;
+  int catchsigwinch;
+
+  /* search state */
+
+  /* completion state */
+
+  /* options state */
+
+  /* reserved for future expansion, so the struct size doesn't change */
+  char reserved[64];
+};
+
+extern int rl_save_state PARAMS((struct readline_state *));
+extern int rl_restore_state PARAMS((struct readline_state *));
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _READLINE_H_ */
index 247c1158463e8f63e4494747119a7ad663eab4b4..3f6362cf1b8b841bc256ed3974718aa10f9b3726 100644 (file)
@@ -347,8 +347,8 @@ extern void _rl_vi_done_inserting PARAMS((void));
  *************************************************************************/
 
 /* bind.c */
-extern const char *_rl_possible_control_prefixes[];
-extern const char *_rl_possible_meta_prefixes[];
+extern const char * const _rl_possible_control_prefixes[];
+extern const char * const _rl_possible_meta_prefixes[];
 
 /* callback.c */
 extern _rl_callback_func_t *_rl_callback_func;
index dd545a41221cfd81bc5c27036e5ea43355b86e0a..247c1158463e8f63e4494747119a7ad663eab4b4 100644 (file)
@@ -1,7 +1,7 @@
 /* rlprivate.h -- functions and variables global to the readline library,
                  but not intended for use by applications. */
 
-/* Copyright (C) 1999-2005 Free Software Foundation, Inc.
+/* Copyright (C) 1999-2006 Free Software Foundation, Inc.
 
    This file is part of the GNU Readline Library, a library for
    reading lines of text with interactive input and history editing.
@@ -316,6 +316,14 @@ extern UNDO_LIST *_rl_copy_undo_entry PARAMS((UNDO_LIST *));
 extern UNDO_LIST *_rl_copy_undo_list PARAMS((UNDO_LIST *));
 
 /* util.c */
+#if defined (USE_VARARGS) && defined (PREFER_STDARG)
+extern void _rl_ttymsg (const char *, ...)  __attribute__((__format__ (printf, 1, 2)));
+extern void _rl_errmsg (const char *, ...)  __attribute__((__format__ (printf, 1, 2)));
+#else
+extern void _rl_ttymsg ();
+extern void _rl_errmsg ();
+#endif
+
 extern int _rl_abort_internal PARAMS((void));
 extern char *_rl_strindex PARAMS((const char *, const char *));
 extern int _rl_qsort_string_compare PARAMS((char **, char **));
@@ -384,6 +392,7 @@ extern int _rl_meta_flag;
 extern int _rl_convert_meta_chars_to_ascii;
 extern int _rl_output_meta_chars;
 extern int _rl_bind_stty_chars;
+extern int _rl_revert_all_at_newline;
 extern char *_rl_comment_begin;
 extern unsigned char _rl_parsing_conditionalized_out;
 extern Keymap _rl_keymap;
index 547f6f5dfe5fa54c81be27807e507c2b26ab1491..413feec7453fc089208ae9b2459fb9388175bcbe 100644 (file)
@@ -361,13 +361,13 @@ rl_resize_terminal ()
 }
 
 struct _tc_string {
-     const char *tc_var;
+     const char * const tc_var;
      char **tc_value;
 };
 
 /* This should be kept sorted, just in case we decide to change the
    search algorithm to something smarter. */
-static struct _tc_string tc_strings[] =
+static const struct _tc_string tc_strings[] =
 {
   { "@7", &_rl_term_at7 },
   { "DC", &_rl_term_DC },
diff --git a/lib/readline/terminal.c~ b/lib/readline/terminal.c~
new file mode 100644 (file)
index 0000000..547f6f5
--- /dev/null
@@ -0,0 +1,731 @@
+/* terminal.c -- controlling the terminal with termcap. */
+
+/* Copyright (C) 1996-2006 Free Software Foundation, Inc.
+
+   This file is part of the GNU Readline Library, a library for
+   reading lines of text with interactive input and history editing.
+
+   The GNU Readline Library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU General Public License
+   as published by the Free Software Foundation; either version 2, or
+   (at your option) any later version.
+
+   The GNU Readline Library 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.
+
+   The GNU General Public License is often shipped with GNU software, and
+   is generally kept in a file called COPYING or LICENSE.  If you do not
+   have a copy of the license, write to the Free Software Foundation,
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+#define READLINE_LIBRARY
+
+#if defined (HAVE_CONFIG_H)
+#  include <config.h>
+#endif
+
+#include <sys/types.h>
+#include "posixstat.h"
+#include <fcntl.h>
+#if defined (HAVE_SYS_FILE_H)
+#  include <sys/file.h>
+#endif /* HAVE_SYS_FILE_H */
+
+#if defined (HAVE_UNISTD_H)
+#  include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+
+#if defined (HAVE_STDLIB_H)
+#  include <stdlib.h>
+#else
+#  include "ansi_stdlib.h"
+#endif /* HAVE_STDLIB_H */
+
+#if defined (HAVE_LOCALE_H)
+#  include <locale.h>
+#endif
+
+#include <stdio.h>
+
+/* System-specific feature definitions and include files. */
+#include "rldefs.h"
+
+#if defined (GWINSZ_IN_SYS_IOCTL) && !defined (TIOCGWINSZ)
+#  include <sys/ioctl.h>
+#endif /* GWINSZ_IN_SYS_IOCTL && !TIOCGWINSZ */
+
+#include "rltty.h"
+#include "tcap.h"
+
+/* Some standard library routines. */
+#include "readline.h"
+#include "history.h"
+
+#include "rlprivate.h"
+#include "rlshell.h"
+#include "xmalloc.h"
+
+#if defined (__MINGW32__)
+#  include <windows.h>
+#  include <wincon.h>
+
+static void _win_get_screensize PARAMS((int *, int *));
+#endif
+
+#if defined (__EMX__)
+static void _emx_get_screensize PARAMS((int *, int *));
+#endif
+
+#define CUSTOM_REDISPLAY_FUNC() (rl_redisplay_function != rl_redisplay)
+#define CUSTOM_INPUT_FUNC() (rl_getc_function != rl_getc)
+
+/*  If the calling application sets this to a non-zero value, readline will
+    use the $LINES and $COLUMNS environment variables to set its idea of the
+    window size before interrogating the kernel. */
+int rl_prefer_env_winsize = 0;
+
+/* **************************************************************** */
+/*                                                                 */
+/*                     Terminal and Termcap                        */
+/*                                                                 */
+/* **************************************************************** */
+
+static char *term_buffer = (char *)NULL;
+static char *term_string_buffer = (char *)NULL;
+
+static int tcap_initialized;
+
+#if !defined (__linux__)
+#  if defined (__EMX__) || defined (NEED_EXTERN_PC)
+extern 
+#  endif /* __EMX__ || NEED_EXTERN_PC */
+char PC, *BC, *UP;
+#endif /* __linux__ */
+
+/* Some strings to control terminal actions.  These are output by tputs (). */
+char *_rl_term_clreol;
+char *_rl_term_clrpag;
+char *_rl_term_cr;
+char *_rl_term_backspace;
+char *_rl_term_goto;
+char *_rl_term_pc;
+
+/* Non-zero if we determine that the terminal can do character insertion. */
+int _rl_terminal_can_insert = 0;
+
+/* How to insert characters. */
+char *_rl_term_im;
+char *_rl_term_ei;
+char *_rl_term_ic;
+char *_rl_term_ip;
+char *_rl_term_IC;
+
+/* How to delete characters. */
+char *_rl_term_dc;
+char *_rl_term_DC;
+
+char *_rl_term_forward_char;
+
+/* How to go up a line. */
+char *_rl_term_up;
+
+/* A visible bell; char if the terminal can be made to flash the screen. */
+static char *_rl_visible_bell;
+
+/* Non-zero means the terminal can auto-wrap lines. */
+int _rl_term_autowrap = -1;
+
+/* Non-zero means that this terminal has a meta key. */
+static int term_has_meta;
+
+/* The sequences to write to turn on and off the meta key, if this
+   terminal has one. */
+static char *_rl_term_mm;
+static char *_rl_term_mo;
+
+/* The key sequences output by the arrow keys, if this terminal has any. */
+static char *_rl_term_ku;
+static char *_rl_term_kd;
+static char *_rl_term_kr;
+static char *_rl_term_kl;
+
+/* How to initialize and reset the arrow keys, if this terminal has any. */
+static char *_rl_term_ks;
+static char *_rl_term_ke;
+
+/* The key sequences sent by the Home and End keys, if any. */
+static char *_rl_term_kh;
+static char *_rl_term_kH;
+static char *_rl_term_at7;     /* @7 */
+
+/* Delete key */
+static char *_rl_term_kD;
+
+/* Insert key */
+static char *_rl_term_kI;
+
+/* Cursor control */
+static char *_rl_term_vs;      /* very visible */
+static char *_rl_term_ve;      /* normal */
+
+static void bind_termcap_arrow_keys PARAMS((Keymap));
+
+/* Variables that hold the screen dimensions, used by the display code. */
+int _rl_screenwidth, _rl_screenheight, _rl_screenchars;
+
+/* Non-zero means the user wants to enable the keypad. */
+int _rl_enable_keypad;
+
+/* Non-zero means the user wants to enable a meta key. */
+int _rl_enable_meta = 1;
+
+#if defined (__EMX__)
+static void
+_emx_get_screensize (swp, shp)
+     int *swp, *shp;
+{
+  int sz[2];
+
+  _scrsize (sz);
+
+  if (swp)
+    *swp = sz[0];
+  if (shp)
+    *shp = sz[1];
+}
+#endif
+
+#if defined (__MINGW32__)
+static void
+_win_get_screensize (swp, shp)
+     int *swp, *shp;
+{
+  HANDLE hConOut;
+  CONSOLE_SCREEN_BUFFER_INFO scr;
+
+  hConOut = GetStdHandle (STD_OUTPUT_HANDLE);
+  if (hConOut != INVALID_HANDLE_VALUE)
+    {
+      if (GetConsoleScreenBufferInfo (hConOut, &scr))
+       {
+         *swp = scr.dwSize.X;
+         *shp = scr.srWindow.Bottom - scr.srWindow.Top + 1;
+       }
+    }
+}
+#endif
+
+/* Get readline's idea of the screen size.  TTY is a file descriptor open
+   to the terminal.  If IGNORE_ENV is true, we do not pay attention to the
+   values of $LINES and $COLUMNS.  The tests for TERM_STRING_BUFFER being
+   non-null serve to check whether or not we have initialized termcap. */
+void
+_rl_get_screen_size (tty, ignore_env)
+     int tty, ignore_env;
+{
+  char *ss;
+#if defined (TIOCGWINSZ)
+  struct winsize window_size;
+#endif /* TIOCGWINSZ */
+  int wr, wc;
+
+  wr = wc = -1;
+#if defined (TIOCGWINSZ)
+  if (ioctl (tty, TIOCGWINSZ, &window_size) == 0)
+    {
+      wc = (int) window_size.ws_col;
+      wr = (int) window_size.ws_row;
+    }
+#endif /* TIOCGWINSZ */
+
+#if defined (__EMX__)
+  _emx_get_screensize (&wc, &wr);
+#elif defined (__MINGW32__)
+  _win_get_screensize (&wc, &wr);
+#endif
+
+  if (ignore_env || rl_prefer_env_winsize == 0)
+    {
+      _rl_screenwidth = wc;
+      _rl_screenheight = wr;
+    }
+  else
+    _rl_screenwidth = _rl_screenheight = -1;
+
+  /* Environment variable COLUMNS overrides setting of "co" if IGNORE_ENV
+     is unset.  If we prefer the environment, check it first before
+     assigning the value returned by the kernel. */
+  if (_rl_screenwidth <= 0)
+    {
+      if (ignore_env == 0 && (ss = sh_get_env_value ("COLUMNS")))
+       _rl_screenwidth = atoi (ss);
+
+      if (_rl_screenwidth <= 0)
+        _rl_screenwidth = wc;
+
+#if !defined (__DJGPP__)
+      if (_rl_screenwidth <= 0 && term_string_buffer)
+       _rl_screenwidth = tgetnum ("co");
+#endif
+    }
+
+  /* Environment variable LINES overrides setting of "li" if IGNORE_ENV
+     is unset. */
+  if (_rl_screenheight <= 0)
+    {
+      if (ignore_env == 0 && (ss = sh_get_env_value ("LINES")))
+       _rl_screenheight = atoi (ss);
+
+      if (_rl_screenheight <= 0)
+        _rl_screenheight = wr;
+
+#if !defined (__DJGPP__)
+      if (_rl_screenheight <= 0 && term_string_buffer)
+       _rl_screenheight = tgetnum ("li");
+#endif
+    }
+
+  /* If all else fails, default to 80x24 terminal. */
+  if (_rl_screenwidth <= 1)
+    _rl_screenwidth = 80;
+
+  if (_rl_screenheight <= 0)
+    _rl_screenheight = 24;
+
+  /* If we're being compiled as part of bash, set the environment
+     variables $LINES and $COLUMNS to new values.  Otherwise, just
+     do a pair of putenv () or setenv () calls. */
+  sh_set_lines_and_columns (_rl_screenheight, _rl_screenwidth);
+
+  if (_rl_term_autowrap == 0)
+    _rl_screenwidth--;
+
+  _rl_screenchars = _rl_screenwidth * _rl_screenheight;
+}
+
+void
+_rl_set_screen_size (rows, cols)
+     int rows, cols;
+{
+  if (_rl_term_autowrap == -1)
+    _rl_init_terminal_io (rl_terminal_name);
+
+  if (rows > 0)
+    _rl_screenheight = rows;
+  if (cols > 0)
+    {
+      _rl_screenwidth = cols;
+      if (_rl_term_autowrap == 0)
+       _rl_screenwidth--;
+    }
+
+  if (rows > 0 || cols > 0)
+    _rl_screenchars = _rl_screenwidth * _rl_screenheight;
+}
+
+void
+rl_set_screen_size (rows, cols)
+     int rows, cols;
+{
+  _rl_set_screen_size (rows, cols);
+}
+
+void
+rl_get_screen_size (rows, cols)
+     int *rows, *cols;
+{
+  if (rows)
+    *rows = _rl_screenheight;
+  if (cols)
+    *cols = _rl_screenwidth;
+}
+
+void
+rl_reset_screen_size ()
+{
+  _rl_get_screen_size (fileno (rl_instream), 0);
+}
+     
+void
+rl_resize_terminal ()
+{
+  if (readline_echoing_p)
+    {
+      _rl_get_screen_size (fileno (rl_instream), 1);
+      if (CUSTOM_REDISPLAY_FUNC ())
+       rl_forced_update_display ();
+      else
+       _rl_redisplay_after_sigwinch ();
+    }
+}
+
+struct _tc_string {
+     const char *tc_var;
+     char **tc_value;
+};
+
+/* This should be kept sorted, just in case we decide to change the
+   search algorithm to something smarter. */
+static struct _tc_string tc_strings[] =
+{
+  { "@7", &_rl_term_at7 },
+  { "DC", &_rl_term_DC },
+  { "IC", &_rl_term_IC },
+  { "ce", &_rl_term_clreol },
+  { "cl", &_rl_term_clrpag },
+  { "cr", &_rl_term_cr },
+  { "dc", &_rl_term_dc },
+  { "ei", &_rl_term_ei },
+  { "ic", &_rl_term_ic },
+  { "im", &_rl_term_im },
+  { "kD", &_rl_term_kD },      /* delete */
+  { "kH", &_rl_term_kH },      /* home down ?? */
+  { "kI", &_rl_term_kI },      /* insert */
+  { "kd", &_rl_term_kd },
+  { "ke", &_rl_term_ke },      /* end keypad mode */
+  { "kh", &_rl_term_kh },      /* home */
+  { "kl", &_rl_term_kl },
+  { "kr", &_rl_term_kr },
+  { "ks", &_rl_term_ks },      /* start keypad mode */
+  { "ku", &_rl_term_ku },
+  { "le", &_rl_term_backspace },
+  { "mm", &_rl_term_mm },
+  { "mo", &_rl_term_mo },
+  { "nd", &_rl_term_forward_char },
+  { "pc", &_rl_term_pc },
+  { "up", &_rl_term_up },
+  { "vb", &_rl_visible_bell },
+  { "vs", &_rl_term_vs },
+  { "ve", &_rl_term_ve },
+};
+
+#define NUM_TC_STRINGS (sizeof (tc_strings) / sizeof (struct _tc_string))
+
+/* Read the desired terminal capability strings into BP.  The capabilities
+   are described in the TC_STRINGS table. */
+static void
+get_term_capabilities (bp)
+     char **bp;
+{
+#if !defined (__DJGPP__)       /* XXX - doesn't DJGPP have a termcap library? */
+  register int i;
+
+  for (i = 0; i < NUM_TC_STRINGS; i++)
+    *(tc_strings[i].tc_value) = tgetstr ((char *)tc_strings[i].tc_var, bp);
+#endif
+  tcap_initialized = 1;
+}
+
+int
+_rl_init_terminal_io (terminal_name)
+     const char *terminal_name;
+{
+  const char *term;
+  char *buffer;
+  int tty, tgetent_ret;
+
+  term = terminal_name ? terminal_name : sh_get_env_value ("TERM");
+  _rl_term_clrpag = _rl_term_cr = _rl_term_clreol = (char *)NULL;
+  tty = rl_instream ? fileno (rl_instream) : 0;
+
+  if (term == 0)
+    term = "dumb";
+
+  /* I've separated this out for later work on not calling tgetent at all
+     if the calling application has supplied a custom redisplay function,
+     (and possibly if the application has supplied a custom input function). */
+  if (CUSTOM_REDISPLAY_FUNC())
+    {
+      tgetent_ret = -1;
+    }
+  else
+    {
+      if (term_string_buffer == 0)
+       term_string_buffer = (char *)xmalloc(2032);
+
+      if (term_buffer == 0)
+       term_buffer = (char *)xmalloc(4080);
+
+      buffer = term_string_buffer;
+
+      tgetent_ret = tgetent (term_buffer, term);
+    }
+
+  if (tgetent_ret <= 0)
+    {
+      FREE (term_string_buffer);
+      FREE (term_buffer);
+      buffer = term_buffer = term_string_buffer = (char *)NULL;
+
+      _rl_term_autowrap = 0;   /* used by _rl_get_screen_size */
+
+      /* Allow calling application to set default height and width, using
+        rl_set_screen_size */
+      if (_rl_screenwidth <= 0 || _rl_screenheight <= 0)
+       {
+#if defined (__EMX__)
+         _emx_get_screensize (&_rl_screenwidth, &_rl_screenheight);
+         _rl_screenwidth--;
+#else /* !__EMX__ */
+         _rl_get_screen_size (tty, 0);
+#endif /* !__EMX__ */
+       }
+
+      /* Defaults. */
+      if (_rl_screenwidth <= 0 || _rl_screenheight <= 0)
+        {
+         _rl_screenwidth = 79;
+         _rl_screenheight = 24;
+        }
+
+      /* Everything below here is used by the redisplay code (tputs). */
+      _rl_screenchars = _rl_screenwidth * _rl_screenheight;
+      _rl_term_cr = "\r";
+      _rl_term_im = _rl_term_ei = _rl_term_ic = _rl_term_IC = (char *)NULL;
+      _rl_term_up = _rl_term_dc = _rl_term_DC = _rl_visible_bell = (char *)NULL;
+      _rl_term_ku = _rl_term_kd = _rl_term_kl = _rl_term_kr = (char *)NULL;
+      _rl_term_kh = _rl_term_kH = _rl_term_kI = _rl_term_kD = (char *)NULL;
+      _rl_term_ks = _rl_term_ke = _rl_term_at7 = (char *)NULL;
+      _rl_term_mm = _rl_term_mo = (char *)NULL;
+      _rl_term_ve = _rl_term_vs = (char *)NULL;
+      _rl_term_forward_char = (char *)NULL;
+      _rl_terminal_can_insert = term_has_meta = 0;
+
+      /* Reasonable defaults for tgoto().  Readline currently only uses
+         tgoto if _rl_term_IC or _rl_term_DC is defined, but just in case we
+         change that later... */
+      PC = '\0';
+      BC = _rl_term_backspace = "\b";
+      UP = _rl_term_up;
+
+      return 0;
+    }
+
+  get_term_capabilities (&buffer);
+
+  /* Set up the variables that the termcap library expects the application
+     to provide. */
+  PC = _rl_term_pc ? *_rl_term_pc : 0;
+  BC = _rl_term_backspace;
+  UP = _rl_term_up;
+
+  if (!_rl_term_cr)
+    _rl_term_cr = "\r";
+
+  _rl_term_autowrap = tgetflag ("am") && tgetflag ("xn");
+
+  /* Allow calling application to set default height and width, using
+     rl_set_screen_size */
+  if (_rl_screenwidth <= 0 || _rl_screenheight <= 0)
+    _rl_get_screen_size (tty, 0);
+
+  /* "An application program can assume that the terminal can do
+      character insertion if *any one of* the capabilities `IC',
+      `im', `ic' or `ip' is provided."  But we can't do anything if
+      only `ip' is provided, so... */
+  _rl_terminal_can_insert = (_rl_term_IC || _rl_term_im || _rl_term_ic);
+
+  /* Check to see if this terminal has a meta key and clear the capability
+     variables if there is none. */
+  term_has_meta = (tgetflag ("km") || tgetflag ("MT"));
+  if (!term_has_meta)
+    _rl_term_mm = _rl_term_mo = (char *)NULL;
+
+  /* Attempt to find and bind the arrow keys.  Do not override already
+     bound keys in an overzealous attempt, however. */
+
+  bind_termcap_arrow_keys (emacs_standard_keymap);
+
+#if defined (VI_MODE)
+  bind_termcap_arrow_keys (vi_movement_keymap);
+  bind_termcap_arrow_keys (vi_insertion_keymap);
+#endif /* VI_MODE */
+
+  return 0;
+}
+
+/* Bind the arrow key sequences from the termcap description in MAP. */
+static void
+bind_termcap_arrow_keys (map)
+     Keymap map;
+{
+  Keymap xkeymap;
+
+  xkeymap = _rl_keymap;
+  _rl_keymap = map;
+
+  rl_bind_keyseq_if_unbound (_rl_term_ku, rl_get_previous_history);
+  rl_bind_keyseq_if_unbound (_rl_term_kd, rl_get_next_history);
+  rl_bind_keyseq_if_unbound (_rl_term_kr, rl_forward_char);
+  rl_bind_keyseq_if_unbound (_rl_term_kl, rl_backward_char);
+
+  rl_bind_keyseq_if_unbound (_rl_term_kh, rl_beg_of_line);     /* Home */
+  rl_bind_keyseq_if_unbound (_rl_term_at7, rl_end_of_line);    /* End */
+
+  rl_bind_keyseq_if_unbound (_rl_term_kD, rl_delete);
+
+  _rl_keymap = xkeymap;
+}
+
+char *
+rl_get_termcap (cap)
+     const char *cap;
+{
+  register int i;
+
+  if (tcap_initialized == 0)
+    return ((char *)NULL);
+  for (i = 0; i < NUM_TC_STRINGS; i++)
+    {
+      if (tc_strings[i].tc_var[0] == cap[0] && strcmp (tc_strings[i].tc_var, cap) == 0)
+        return *(tc_strings[i].tc_value);
+    }
+  return ((char *)NULL);
+}
+
+/* Re-initialize the terminal considering that the TERM/TERMCAP variable
+   has changed. */
+int
+rl_reset_terminal (terminal_name)
+     const char *terminal_name;
+{
+  _rl_screenwidth = _rl_screenheight = 0;
+  _rl_init_terminal_io (terminal_name);
+  return 0;
+}
+
+/* A function for the use of tputs () */
+#ifdef _MINIX
+void
+_rl_output_character_function (c)
+     int c;
+{
+  putc (c, _rl_out_stream);
+}
+#else /* !_MINIX */
+int
+_rl_output_character_function (c)
+     int c;
+{
+  return putc (c, _rl_out_stream);
+}
+#endif /* !_MINIX */
+
+/* Write COUNT characters from STRING to the output stream. */
+void
+_rl_output_some_chars (string, count)
+     const char *string;
+     int count;
+{
+  fwrite (string, 1, count, _rl_out_stream);
+}
+
+/* Move the cursor back. */
+int
+_rl_backspace (count)
+     int count;
+{
+  register int i;
+
+  if (_rl_term_backspace)
+    for (i = 0; i < count; i++)
+      tputs (_rl_term_backspace, 1, _rl_output_character_function);
+  else
+    for (i = 0; i < count; i++)
+      putc ('\b', _rl_out_stream);
+  return 0;
+}
+
+/* Move to the start of the next line. */
+int
+rl_crlf ()
+{
+#if defined (NEW_TTY_DRIVER)
+  if (_rl_term_cr)
+    tputs (_rl_term_cr, 1, _rl_output_character_function);
+#endif /* NEW_TTY_DRIVER */
+  putc ('\n', _rl_out_stream);
+  return 0;
+}
+
+/* Ring the terminal bell. */
+int
+rl_ding ()
+{
+  if (readline_echoing_p)
+    {
+      switch (_rl_bell_preference)
+        {
+       case NO_BELL:
+       default:
+         break;
+       case VISIBLE_BELL:
+         if (_rl_visible_bell)
+           {
+             tputs (_rl_visible_bell, 1, _rl_output_character_function);
+             break;
+           }
+         /* FALLTHROUGH */
+       case AUDIBLE_BELL:
+         fprintf (stderr, "\007");
+         fflush (stderr);
+         break;
+        }
+      return (0);
+    }
+  return (-1);
+}
+
+/* **************************************************************** */
+/*                                                                 */
+/*             Controlling the Meta Key and Keypad                 */
+/*                                                                 */
+/* **************************************************************** */
+
+void
+_rl_enable_meta_key ()
+{
+#if !defined (__DJGPP__)
+  if (term_has_meta && _rl_term_mm)
+    tputs (_rl_term_mm, 1, _rl_output_character_function);
+#endif
+}
+
+void
+_rl_control_keypad (on)
+     int on;
+{
+#if !defined (__DJGPP__)
+  if (on && _rl_term_ks)
+    tputs (_rl_term_ks, 1, _rl_output_character_function);
+  else if (!on && _rl_term_ke)
+    tputs (_rl_term_ke, 1, _rl_output_character_function);
+#endif
+}
+
+/* **************************************************************** */
+/*                                                                 */
+/*                     Controlling the Cursor                      */
+/*                                                                 */
+/* **************************************************************** */
+
+/* Set the cursor appropriately depending on IM, which is one of the
+   insert modes (insert or overwrite).  Insert mode gets the normal
+   cursor.  Overwrite mode gets a very visible cursor.  Only does
+   anything if we have both capabilities. */
+void
+_rl_set_cursor (im, force)
+     int im, force;
+{
+  if (_rl_term_ve && _rl_term_vs)
+    {
+      if (force || im != rl_insert_mode)
+       {
+         if (im == RL_IM_OVERWRITE)
+           tputs (_rl_term_vs, 1, _rl_output_character_function);
+         else
+           tputs (_rl_term_ve, 1, _rl_output_character_function);
+       }
+    }
+}
index bdc2e13fbd6a91d35710c5847992776bbfb1228e..ad15394c40aeed86209e143788ac987c7e49fb56 100644 (file)
@@ -66,7 +66,7 @@
    in words, or 1 if it is. */
 
 int _rl_allow_pathname_alphabetic_chars = 0;
-static const char *pathname_alphabetic_chars = "/-_=~.#$";
+static const char * const pathname_alphabetic_chars = "/-_=~.#$";
 
 int
 rl_alphabetic (c)
diff --git a/lib/readline/util.c~ b/lib/readline/util.c~
new file mode 100644 (file)
index 0000000..bdc2e13
--- /dev/null
@@ -0,0 +1,445 @@
+/* util.c -- readline utility functions */
+
+/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
+
+   This file is part of the GNU Readline Library, a library for
+   reading lines of text with interactive input and history editing.
+
+   The GNU Readline Library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU General Public License
+   as published by the Free Software Foundation; either version 2, or
+   (at your option) any later version.
+
+   The GNU Readline Library 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.
+
+   The GNU General Public License is often shipped with GNU software, and
+   is generally kept in a file called COPYING or LICENSE.  If you do not
+   have a copy of the license, write to the Free Software Foundation,
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+#define READLINE_LIBRARY
+
+#if defined (HAVE_CONFIG_H)
+#  include <config.h>
+#endif
+
+#include <sys/types.h>
+#include <fcntl.h>
+#include "posixjmp.h"
+
+#if defined (HAVE_UNISTD_H)
+#  include <unistd.h>           /* for _POSIX_VERSION */
+#endif /* HAVE_UNISTD_H */
+
+#if defined (HAVE_STDLIB_H)
+#  include <stdlib.h>
+#else
+#  include "ansi_stdlib.h"
+#endif /* HAVE_STDLIB_H */
+
+#include <stdio.h>
+#include <ctype.h>
+
+/* System-specific feature definitions and include files. */
+#include "rldefs.h"
+#include "rlmbutil.h"
+
+#if defined (TIOCSTAT_IN_SYS_IOCTL)
+#  include <sys/ioctl.h>
+#endif /* TIOCSTAT_IN_SYS_IOCTL */
+
+/* Some standard library routines. */
+#include "readline.h"
+
+#include "rlprivate.h"
+#include "xmalloc.h"
+
+/* **************************************************************** */
+/*                                                                 */
+/*                     Utility Functions                           */
+/*                                                                 */
+/* **************************************************************** */
+
+/* Return 0 if C is not a member of the class of characters that belong
+   in words, or 1 if it is. */
+
+int _rl_allow_pathname_alphabetic_chars = 0;
+static const char *pathname_alphabetic_chars = "/-_=~.#$";
+
+int
+rl_alphabetic (c)
+     int c;
+{
+  if (ALPHABETIC (c))
+    return (1);
+
+  return (_rl_allow_pathname_alphabetic_chars &&
+           strchr (pathname_alphabetic_chars, c) != NULL);
+}
+
+#if defined (HANDLE_MULTIBYTE)
+int
+_rl_walphabetic (wc)
+     wchar_t wc;
+{
+  int c;
+
+  if (iswalnum (wc))
+    return (1);     
+
+  c = wc & 0177;
+  return (_rl_allow_pathname_alphabetic_chars &&
+           strchr (pathname_alphabetic_chars, c) != NULL);
+}
+#endif
+
+/* How to abort things. */
+int
+_rl_abort_internal ()
+{
+  rl_ding ();
+  rl_clear_message ();
+  _rl_reset_argument ();
+  rl_clear_pending_input ();
+
+  RL_UNSETSTATE (RL_STATE_MACRODEF);
+  while (rl_executing_macro)
+    _rl_pop_executing_macro ();
+
+  rl_last_func = (rl_command_func_t *)NULL;
+  longjmp (readline_top_level, 1);
+  return (0);
+}
+
+int
+rl_abort (count, key)
+     int count, key;
+{
+  return (_rl_abort_internal ());
+}
+
+int
+rl_tty_status (count, key)
+     int count, key;
+{
+#if defined (TIOCSTAT)
+  ioctl (1, TIOCSTAT, (char *)0);
+  rl_refresh_line (count, key);
+#else
+  rl_ding ();
+#endif
+  return 0;
+}
+
+/* Return a copy of the string between FROM and TO.
+   FROM is inclusive, TO is not. */
+char *
+rl_copy_text (from, to)
+     int from, to;
+{
+  register int length;
+  char *copy;
+
+  /* Fix it if the caller is confused. */
+  if (from > to)
+    SWAP (from, to);
+
+  length = to - from;
+  copy = (char *)xmalloc (1 + length);
+  strncpy (copy, rl_line_buffer + from, length);
+  copy[length] = '\0';
+  return (copy);
+}
+
+/* Increase the size of RL_LINE_BUFFER until it has enough space to hold
+   LEN characters. */
+void
+rl_extend_line_buffer (len)
+     int len;
+{
+  while (len >= rl_line_buffer_len)
+    {
+      rl_line_buffer_len += DEFAULT_BUFFER_SIZE;
+      rl_line_buffer = (char *)xrealloc (rl_line_buffer, rl_line_buffer_len);
+    }
+
+  _rl_set_the_line ();
+}
+
+
+/* A function for simple tilde expansion. */
+int
+rl_tilde_expand (ignore, key)
+     int ignore, key;
+{
+  register int start, end;
+  char *homedir, *temp;
+  int len;
+
+  end = rl_point;
+  start = end - 1;
+
+  if (rl_point == rl_end && rl_line_buffer[rl_point] == '~')
+    {
+      homedir = tilde_expand ("~");
+      _rl_replace_text (homedir, start, end);
+      return (0);
+    }
+  else if (rl_line_buffer[start] != '~')
+    {
+      for (; !whitespace (rl_line_buffer[start]) && start >= 0; start--)
+        ;
+      start++;
+    }
+
+  end = start;
+  do
+    end++;
+  while (whitespace (rl_line_buffer[end]) == 0 && end < rl_end);
+
+  if (whitespace (rl_line_buffer[end]) || end >= rl_end)
+    end--;
+
+  /* If the first character of the current word is a tilde, perform
+     tilde expansion and insert the result.  If not a tilde, do
+     nothing. */
+  if (rl_line_buffer[start] == '~')
+    {
+      len = end - start + 1;
+      temp = (char *)xmalloc (len + 1);
+      strncpy (temp, rl_line_buffer + start, len);
+      temp[len] = '\0';
+      homedir = tilde_expand (temp);
+      xfree (temp);
+
+      _rl_replace_text (homedir, start, end);
+    }
+
+  return (0);
+}
+
+#if defined (USE_VARARGS)
+void
+#if defined (PREFER_STDARG)
+_rl_ttymsg (const char *format, ...)
+#else
+_rl_ttymsg (va_alist)
+     va_dcl
+#endif
+{
+  va_list args;
+#if defined (PREFER_VARARGS)
+  char *format;
+#endif
+
+#if defined (PREFER_STDARG)
+  va_start (args, format);
+#else
+  va_start (args);
+  format = va_arg (args, char *);
+#endif
+
+  fprintf (stderr, "readline: ");
+  vfprintf (stderr, format, args);
+  fprintf (stderr, "\n");
+  fflush (stderr);
+
+  va_end (args);
+
+  rl_forced_update_display ();
+}
+
+void
+#if defined (PREFER_STDARG)
+_rl_errmsg (const char *format, ...)
+#else
+_rl_errmsg (va_alist)
+     va_dcl
+#endif
+{
+  va_list args;
+#if defined (PREFER_VARARGS)
+  char *format;
+#endif
+
+#if defined (PREFER_STDARG)
+  va_start (args, format);
+#else
+  va_start (args);
+  format = va_arg (args, char *);
+#endif
+
+  fprintf (stderr, "readline: ");
+  vfprintf (stderr, format, args);
+  fprintf (stderr, "\n");
+  fflush (stderr);
+
+  va_end (args);
+}
+#else /* !USE_VARARGS */
+void
+_rl_ttymsg (format, arg1, arg2)
+     char *format;
+{
+  fprintf (stderr, "readline: ");
+  fprintf (stderr, format, arg1, arg2);
+  fprintf (stderr, "\n");
+
+  rl_forced_update_display ();
+}
+
+void
+_rl_errmsg (format, arg1, arg2)
+     char *format;
+{
+  fprintf (stderr, "readline: ");
+  fprintf (stderr, format, arg1, arg2);
+  fprintf (stderr, "\n");
+}
+#endif /* !USE_VARARGS */
+
+/* **************************************************************** */
+/*                                                                 */
+/*                     String Utility Functions                    */
+/*                                                                 */
+/* **************************************************************** */
+
+/* Determine if s2 occurs in s1.  If so, return a pointer to the
+   match in s1.  The compare is case insensitive. */
+char *
+_rl_strindex (s1, s2)
+     register const char *s1, *s2;
+{
+  register int i, l, len;
+
+  for (i = 0, l = strlen (s2), len = strlen (s1); (len - i) >= l; i++)
+    if (_rl_strnicmp (s1 + i, s2, l) == 0)
+      return ((char *) (s1 + i));
+  return ((char *)NULL);
+}
+
+#ifndef HAVE_STRPBRK
+/* Find the first occurrence in STRING1 of any character from STRING2.
+   Return a pointer to the character in STRING1. */
+char *
+_rl_strpbrk (string1, string2)
+     const char *string1, *string2;
+{
+  register const char *scan;
+#if defined (HANDLE_MULTIBYTE)
+  mbstate_t ps;
+  register int i, v;
+
+  memset (&ps, 0, sizeof (mbstate_t));
+#endif
+
+  for (; *string1; string1++)
+    {
+      for (scan = string2; *scan; scan++)
+       {
+         if (*string1 == *scan)
+           return ((char *)string1);
+       }
+#if defined (HANDLE_MULTIBYTE)
+      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+       {
+         v = _rl_get_char_len (string1, &ps);
+         if (v > 1)
+           string1 += v - 1;   /* -1 to account for auto-increment in loop */
+       }
+#endif
+    }
+  return ((char *)NULL);
+}
+#endif
+
+#if !defined (HAVE_STRCASECMP)
+/* Compare at most COUNT characters from string1 to string2.  Case
+   doesn't matter. */
+int
+_rl_strnicmp (string1, string2, count)
+     char *string1, *string2;
+     int count;
+{
+  register char ch1, ch2;
+
+  while (count)
+    {
+      ch1 = *string1++;
+      ch2 = *string2++;
+      if (_rl_to_upper(ch1) == _rl_to_upper(ch2))
+       count--;
+      else
+        break;
+    }
+  return (count);
+}
+
+/* strcmp (), but caseless. */
+int
+_rl_stricmp (string1, string2)
+     char *string1, *string2;
+{
+  register char ch1, ch2;
+
+  while (*string1 && *string2)
+    {
+      ch1 = *string1++;
+      ch2 = *string2++;
+      if (_rl_to_upper(ch1) != _rl_to_upper(ch2))
+       return (1);
+    }
+  return (*string1 - *string2);
+}
+#endif /* !HAVE_STRCASECMP */
+
+/* Stupid comparison routine for qsort () ing strings. */
+int
+_rl_qsort_string_compare (s1, s2)
+  char **s1, **s2;
+{
+#if defined (HAVE_STRCOLL)
+  return (strcoll (*s1, *s2));
+#else
+  int result;
+
+  result = **s1 - **s2;
+  if (result == 0)
+    result = strcmp (*s1, *s2);
+
+  return result;
+#endif
+}
+
+/* Function equivalents for the macros defined in chardefs.h. */
+#define FUNCTION_FOR_MACRO(f)  int (f) (c) int c; { return f (c); }
+
+FUNCTION_FOR_MACRO (_rl_digit_p)
+FUNCTION_FOR_MACRO (_rl_digit_value)
+FUNCTION_FOR_MACRO (_rl_lowercase_p)
+FUNCTION_FOR_MACRO (_rl_pure_alphabetic)
+FUNCTION_FOR_MACRO (_rl_to_lower)
+FUNCTION_FOR_MACRO (_rl_to_upper)
+FUNCTION_FOR_MACRO (_rl_uppercase_p)
+
+/* A convenience function, to force memory deallocation to be performed
+   by readline.  DLLs on Windows apparently require this. */
+void
+rl_free (mem)
+     void *mem;
+{
+  if (mem)
+    free (mem);
+}
+
+/* Backwards compatibility, now that savestring has been removed from
+   all `public' readline header files. */
+#undef _rl_savestring
+char *
+_rl_savestring (s)
+     const char *s;
+{
+  return (strcpy ((char *)xmalloc (1 + (int)strlen (s)), (s)));
+}
index d0b7e330adc479191dcf6faa121aa2f681b405f3..14d95dc78fb71e9275a43c60240a8431bf4d76de 100644 (file)
@@ -1,7 +1,7 @@
 /* vi_mode.c -- A vi emulation mode for Bash.
    Derived from code written by Jeff Sparkes (jsparkes@bnr.ca).  */
 
-/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2006 Free Software Foundation, Inc.
 
    This file is part of the GNU Readline Library, a library for
    reading lines of text with interactive input and history editing.
@@ -69,7 +69,7 @@ int _rl_vi_last_command = 'i';        /* default `.' puts you in insert mode */
 static int _rl_vi_doing_insert;
 
 /* Command keys which do movement for xxx_to commands. */
-static const char *vi_motion = " hl^$0ftFT;,%wbeWBE|";
+static const char * const vi_motion = " hl^$0ftFT;,%wbeWBE|`";
 
 /* Keymap used for vi replace characters.  Created dynamically since
    rarely used. */
@@ -101,7 +101,7 @@ static int _rl_vi_last_key_before_insert;
 static int vi_redoing;
 
 /* Text modification commands.  These are the `redoable' commands. */
-static const char *vi_textmod = "_*\\AaIiCcDdPpYyRrSsXx~";
+static const char * const vi_textmod = "_*\\AaIiCcDdPpYyRrSsXx~";
 
 /* Arrays for the saved marks. */
 static int vi_mark_chars['z' - 'a' + 1];
@@ -1033,13 +1033,15 @@ int
 rl_vi_delete_to (count, key)
      int count, key;
 {
-  int c;
+  int c, start_pos;
 
   if (_rl_uppercase_p (key))
     rl_stuff_char ('$');
   else if (vi_redoing)
     rl_stuff_char (_rl_vi_last_motion);
 
+  start_pos = rl_point;
+
   if (rl_vi_domove (key, &c))
     {
       rl_ding ();
@@ -1048,7 +1050,8 @@ rl_vi_delete_to (count, key)
 
   /* These are the motion commands that do not require adjusting the
      mark. */
-  if ((strchr (" l|h^0bB", c) == 0) && (rl_mark < rl_end))
+  if (((strchr (" l|h^0bBFT`", c) == 0) && (rl_point >= start_pos)) &&
+      (rl_mark < rl_end))
     rl_mark++;
 
   rl_kill_text (rl_point, rl_mark);
@@ -1077,7 +1080,8 @@ rl_vi_change_to (count, key)
   /* These are the motion commands that do not require adjusting the
      mark.  c[wW] are handled by special-case code in rl_vi_domove(),
      and already leave the mark at the correct location. */
-  if ((strchr (" l|hwW^0bB", c) == 0) && (rl_mark < rl_end))
+  if (((strchr (" l|hwW^0bBFT`", c) == 0) && (rl_point >= start_pos)) &&
+      (rl_mark < rl_end))
     rl_mark++;
 
   /* The cursor never moves with c[wW]. */
@@ -1112,12 +1116,13 @@ int
 rl_vi_yank_to (count, key)
      int count, key;
 {
-  int c, save;
+  int c, start_pos;
 
-  save = rl_point;
   if (_rl_uppercase_p (key))
     rl_stuff_char ('$');
 
+  start_pos = rl_point;
+
   if (rl_vi_domove (key, &c))
     {
       rl_ding ();
@@ -1126,14 +1131,15 @@ rl_vi_yank_to (count, key)
 
   /* These are the motion commands that do not require adjusting the
      mark. */
-  if ((strchr (" l|h^0%bB", c) == 0) && (rl_mark < rl_end))
+  if (((strchr (" l|h^0%bBFT`", c) == 0) && (rl_point >= start_pos)) &&
+      (rl_mark < rl_end))
     rl_mark++;
 
   rl_begin_undo_group ();
   rl_kill_text (rl_point, rl_mark);
   rl_end_undo_group ();
   rl_do_undo ();
-  rl_point = save;
+  rl_point = start_pos;
 
   return (0);
 }
diff --git a/lib/readline/vi_mode.c~ b/lib/readline/vi_mode.c~
new file mode 100644 (file)
index 0000000..17fb21e
--- /dev/null
@@ -0,0 +1,1754 @@
+/* vi_mode.c -- A vi emulation mode for Bash.
+   Derived from code written by Jeff Sparkes (jsparkes@bnr.ca).  */
+
+/* Copyright (C) 1987-2006 Free Software Foundation, Inc.
+
+   This file is part of the GNU Readline Library, a library for
+   reading lines of text with interactive input and history editing.
+
+   The GNU Readline Library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU General Public License
+   as published by the Free Software Foundation; either version 2, or
+   (at your option) any later version.
+
+   The GNU Readline Library 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.
+
+   The GNU General Public License is often shipped with GNU software, and
+   is generally kept in a file called COPYING or LICENSE.  If you do not
+   have a copy of the license, write to the Free Software Foundation,
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+#define READLINE_LIBRARY
+
+/* **************************************************************** */
+/*                                                                 */
+/*                     VI Emulation Mode                           */
+/*                                                                 */
+/* **************************************************************** */
+#include "rlconf.h"
+
+#if defined (VI_MODE)
+
+#if defined (HAVE_CONFIG_H)
+#  include <config.h>
+#endif
+
+#include <sys/types.h>
+
+#if defined (HAVE_STDLIB_H)
+#  include <stdlib.h>
+#else
+#  include "ansi_stdlib.h"
+#endif /* HAVE_STDLIB_H */
+
+#if defined (HAVE_UNISTD_H)
+#  include <unistd.h>
+#endif
+
+#include <stdio.h>
+
+/* Some standard library routines. */
+#include "rldefs.h"
+#include "rlmbutil.h"
+
+#include "readline.h"
+#include "history.h"
+
+#include "rlprivate.h"
+#include "xmalloc.h"
+
+#ifndef member
+#define member(c, s) ((c) ? (char *)strchr ((s), (c)) != (char *)NULL : 0)
+#endif
+
+int _rl_vi_last_command = 'i'; /* default `.' puts you in insert mode */
+
+/* Non-zero means enter insertion mode. */
+static int _rl_vi_doing_insert;
+
+/* Command keys which do movement for xxx_to commands. */
+static const char * const vi_motion = " hl^$0ftFT;,%wbeWBE|`";
+
+/* Keymap used for vi replace characters.  Created dynamically since
+   rarely used. */
+static Keymap vi_replace_map;
+
+/* The number of characters inserted in the last replace operation. */
+static int vi_replace_count;
+
+/* If non-zero, we have text inserted after a c[motion] command that put
+   us implicitly into insert mode.  Some people want this text to be
+   attached to the command so that it is `redoable' with `.'. */
+static int vi_continued_command;
+static char *vi_insert_buffer;
+static int vi_insert_buffer_size;
+
+static int _rl_vi_last_repeat = 1;
+static int _rl_vi_last_arg_sign = 1;
+static int _rl_vi_last_motion;
+#if defined (HANDLE_MULTIBYTE)
+static char _rl_vi_last_search_mbchar[MB_LEN_MAX];
+static int _rl_vi_last_search_mblen;
+#else
+static int _rl_vi_last_search_char;
+#endif
+static int _rl_vi_last_replacement;
+
+static int _rl_vi_last_key_before_insert;
+
+static int vi_redoing;
+
+/* Text modification commands.  These are the `redoable' commands. */
+static const char *vi_textmod = "_*\\AaIiCcDdPpYyRrSsXx~";
+
+/* Arrays for the saved marks. */
+static int vi_mark_chars['z' - 'a' + 1];
+
+static void _rl_vi_stuff_insert PARAMS((int));
+static void _rl_vi_save_insert PARAMS((UNDO_LIST *));
+
+static void _rl_vi_backup PARAMS((void));
+
+static int _rl_vi_arg_dispatch PARAMS((int));
+static int rl_digit_loop1 PARAMS((void));
+
+static int _rl_vi_set_mark PARAMS((void));
+static int _rl_vi_goto_mark PARAMS((void));
+
+static void _rl_vi_append_forward PARAMS((int));
+
+static int _rl_vi_callback_getchar PARAMS((char *, int));
+
+#if defined (READLINE_CALLBACKS)
+static int _rl_vi_callback_set_mark PARAMS((_rl_callback_generic_arg *));
+static int _rl_vi_callback_goto_mark PARAMS((_rl_callback_generic_arg *));
+static int _rl_vi_callback_change_char PARAMS((_rl_callback_generic_arg *));
+static int _rl_vi_callback_char_search PARAMS((_rl_callback_generic_arg *));
+#endif
+
+void
+_rl_vi_initialize_line ()
+{
+  register int i;
+
+  for (i = 0; i < sizeof (vi_mark_chars) / sizeof (int); i++)
+    vi_mark_chars[i] = -1;
+
+  RL_UNSETSTATE(RL_STATE_VICMDONCE);
+}
+
+void
+_rl_vi_reset_last ()
+{
+  _rl_vi_last_command = 'i';
+  _rl_vi_last_repeat = 1;
+  _rl_vi_last_arg_sign = 1;
+  _rl_vi_last_motion = 0;
+}
+
+void
+_rl_vi_set_last (key, repeat, sign)
+     int key, repeat, sign;
+{
+  _rl_vi_last_command = key;
+  _rl_vi_last_repeat = repeat;
+  _rl_vi_last_arg_sign = sign;
+}
+
+/* A convenience function that calls _rl_vi_set_last to save the last command
+   information and enters insertion mode. */
+void
+rl_vi_start_inserting (key, repeat, sign)
+     int key, repeat, sign;
+{
+  _rl_vi_set_last (key, repeat, sign);
+  rl_vi_insertion_mode (1, key);
+}
+
+/* Is the command C a VI mode text modification command? */
+int
+_rl_vi_textmod_command (c)
+     int c;
+{
+  return (member (c, vi_textmod));
+}
+
+static void
+_rl_vi_stuff_insert (count)
+     int count;
+{
+  rl_begin_undo_group ();
+  while (count--)
+    rl_insert_text (vi_insert_buffer);
+  rl_end_undo_group ();
+}
+
+/* Bound to `.'.  Called from command mode, so we know that we have to
+   redo a text modification command.  The default for _rl_vi_last_command
+   puts you back into insert mode. */
+int
+rl_vi_redo (count, c)
+     int count, c;
+{
+  int r;
+
+  if (!rl_explicit_arg)
+    {
+      rl_numeric_arg = _rl_vi_last_repeat;
+      rl_arg_sign = _rl_vi_last_arg_sign;
+    }
+
+  r = 0;
+  vi_redoing = 1;
+  /* If we're redoing an insert with `i', stuff in the inserted text
+     and do not go into insertion mode. */
+  if (_rl_vi_last_command == 'i' && vi_insert_buffer && *vi_insert_buffer)
+    {
+      _rl_vi_stuff_insert (count);
+      /* And back up point over the last character inserted. */
+      if (rl_point > 0)
+       _rl_vi_backup ();
+    }
+  /* Ditto for redoing an insert with `a', but move forward a character first
+     like the `a' command does. */
+  else if (_rl_vi_last_command == 'a' && vi_insert_buffer && *vi_insert_buffer)
+    {
+      _rl_vi_append_forward ('a');
+      _rl_vi_stuff_insert (count);
+      if (rl_point > 0)
+       _rl_vi_backup ();
+    }
+  else
+    r = _rl_dispatch (_rl_vi_last_command, _rl_keymap);
+  vi_redoing = 0;
+
+  return (r);
+}
+
+/* A placeholder for further expansion. */
+int
+rl_vi_undo (count, key)
+     int count, key;
+{
+  return (rl_undo_command (count, key));
+}
+    
+/* Yank the nth arg from the previous line into this line at point. */
+int
+rl_vi_yank_arg (count, key)
+     int count, key;
+{
+  /* Readline thinks that the first word on a line is the 0th, while vi
+     thinks the first word on a line is the 1st.  Compensate. */
+  if (rl_explicit_arg)
+    rl_yank_nth_arg (count - 1, 0);
+  else
+    rl_yank_nth_arg ('$', 0);
+
+  return (0);
+}
+
+/* With an argument, move back that many history lines, else move to the
+   beginning of history. */
+int
+rl_vi_fetch_history (count, c)
+     int count, c;
+{
+  int wanted;
+
+  /* Giving an argument of n means we want the nth command in the history
+     file.  The command number is interpreted the same way that the bash
+     `history' command does it -- that is, giving an argument count of 450
+     to this command would get the command listed as number 450 in the
+     output of `history'. */
+  if (rl_explicit_arg)
+    {
+      wanted = history_base + where_history () - count;
+      if (wanted <= 0)
+        rl_beginning_of_history (0, 0);
+      else
+        rl_get_previous_history (wanted, c);
+    }
+  else
+    rl_beginning_of_history (count, 0);
+  return (0);
+}
+
+/* Search again for the last thing searched for. */
+int
+rl_vi_search_again (count, key)
+     int count, key;
+{
+  switch (key)
+    {
+    case 'n':
+      rl_noninc_reverse_search_again (count, key);
+      break;
+
+    case 'N':
+      rl_noninc_forward_search_again (count, key);
+      break;
+    }
+  return (0);
+}
+
+/* Do a vi style search. */
+int
+rl_vi_search (count, key)
+     int count, key;
+{
+  switch (key)
+    {
+    case '?':
+      _rl_free_saved_history_line ();
+      rl_noninc_forward_search (count, key);
+      break;
+
+    case '/':
+      _rl_free_saved_history_line ();
+      rl_noninc_reverse_search (count, key);
+      break;
+
+    default:
+      rl_ding ();
+      break;
+    }
+  return (0);
+}
+
+/* Completion, from vi's point of view. */
+int
+rl_vi_complete (ignore, key)
+     int ignore, key;
+{
+  if ((rl_point < rl_end) && (!whitespace (rl_line_buffer[rl_point])))
+    {
+      if (!whitespace (rl_line_buffer[rl_point + 1]))
+       rl_vi_end_word (1, 'E');
+      rl_point++;
+    }
+
+  if (key == '*')
+    rl_complete_internal ('*');        /* Expansion and replacement. */
+  else if (key == '=')
+    rl_complete_internal ('?');        /* List possible completions. */
+  else if (key == '\\')
+    rl_complete_internal (TAB);        /* Standard Readline completion. */
+  else
+    rl_complete (0, key);
+
+  if (key == '*' || key == '\\')
+    rl_vi_start_inserting (key, 1, rl_arg_sign);
+
+  return (0);
+}
+
+/* Tilde expansion for vi mode. */
+int
+rl_vi_tilde_expand (ignore, key)
+     int ignore, key;
+{
+  rl_tilde_expand (0, key);
+  rl_vi_start_inserting (key, 1, rl_arg_sign);
+  return (0);
+}
+
+/* Previous word in vi mode. */
+int
+rl_vi_prev_word (count, key)
+     int count, key;
+{
+  if (count < 0)
+    return (rl_vi_next_word (-count, key));
+
+  if (rl_point == 0)
+    {
+      rl_ding ();
+      return (0);
+    }
+
+  if (_rl_uppercase_p (key))
+    rl_vi_bWord (count, key);
+  else
+    rl_vi_bword (count, key);
+
+  return (0);
+}
+
+/* Next word in vi mode. */
+int
+rl_vi_next_word (count, key)
+     int count, key;
+{
+  if (count < 0)
+    return (rl_vi_prev_word (-count, key));
+
+  if (rl_point >= (rl_end - 1))
+    {
+      rl_ding ();
+      return (0);
+    }
+
+  if (_rl_uppercase_p (key))
+    rl_vi_fWord (count, key);
+  else
+    rl_vi_fword (count, key);
+  return (0);
+}
+
+/* Move to the end of the ?next? word. */
+int
+rl_vi_end_word (count, key)
+     int count, key;
+{
+  if (count < 0)
+    {
+      rl_ding ();
+      return -1;
+    }
+
+  if (_rl_uppercase_p (key))
+    rl_vi_eWord (count, key);
+  else
+    rl_vi_eword (count, key);
+  return (0);
+}
+
+/* Move forward a word the way that 'W' does. */
+int
+rl_vi_fWord (count, ignore)
+     int count, ignore;
+{
+  while (count-- && rl_point < (rl_end - 1))
+    {
+      /* Skip until whitespace. */
+      while (!whitespace (rl_line_buffer[rl_point]) && rl_point < rl_end)
+       rl_point++;
+
+      /* Now skip whitespace. */
+      while (whitespace (rl_line_buffer[rl_point]) && rl_point < rl_end)
+       rl_point++;
+    }
+  return (0);
+}
+
+int
+rl_vi_bWord (count, ignore)
+     int count, ignore;
+{
+  while (count-- && rl_point > 0)
+    {
+      /* If we are at the start of a word, move back to whitespace so
+        we will go back to the start of the previous word. */
+      if (!whitespace (rl_line_buffer[rl_point]) &&
+         whitespace (rl_line_buffer[rl_point - 1]))
+       rl_point--;
+
+      while (rl_point > 0 && whitespace (rl_line_buffer[rl_point]))
+       rl_point--;
+
+      if (rl_point > 0)
+       {
+         while (--rl_point >= 0 && !whitespace (rl_line_buffer[rl_point]));
+         rl_point++;
+       }
+    }
+  return (0);
+}
+
+int
+rl_vi_eWord (count, ignore)
+     int count, ignore;
+{
+  while (count-- && rl_point < (rl_end - 1))
+    {
+      if (!whitespace (rl_line_buffer[rl_point]))
+       rl_point++;
+
+      /* Move to the next non-whitespace character (to the start of the
+        next word). */
+      while (rl_point < rl_end && whitespace (rl_line_buffer[rl_point]))
+       rl_point++;
+
+      if (rl_point && rl_point < rl_end)
+       {
+         /* Skip whitespace. */
+         while (rl_point < rl_end && whitespace (rl_line_buffer[rl_point]))
+           rl_point++;
+
+         /* Skip until whitespace. */
+         while (rl_point < rl_end && !whitespace (rl_line_buffer[rl_point]))
+           rl_point++;
+
+         /* Move back to the last character of the word. */
+         rl_point--;
+       }
+    }
+  return (0);
+}
+
+int
+rl_vi_fword (count, ignore)
+     int count, ignore;
+{
+  while (count-- && rl_point < (rl_end - 1))
+    {
+      /* Move to white space (really non-identifer). */
+      if (_rl_isident (rl_line_buffer[rl_point]))
+       {
+         while (_rl_isident (rl_line_buffer[rl_point]) && rl_point < rl_end)
+           rl_point++;
+       }
+      else /* if (!whitespace (rl_line_buffer[rl_point])) */
+       {
+         while (!_rl_isident (rl_line_buffer[rl_point]) &&
+                !whitespace (rl_line_buffer[rl_point]) && rl_point < rl_end)
+           rl_point++;
+       }
+
+      /* Move past whitespace. */
+      while (whitespace (rl_line_buffer[rl_point]) && rl_point < rl_end)
+       rl_point++;
+    }
+  return (0);
+}
+
+int
+rl_vi_bword (count, ignore)
+     int count, ignore;
+{
+  while (count-- && rl_point > 0)
+    {
+      int last_is_ident;
+
+      /* If we are at the start of a word, move back to whitespace
+        so we will go back to the start of the previous word. */
+      if (!whitespace (rl_line_buffer[rl_point]) &&
+         whitespace (rl_line_buffer[rl_point - 1]))
+       rl_point--;
+
+      /* If this character and the previous character are `opposite', move
+        back so we don't get messed up by the rl_point++ down there in
+        the while loop.  Without this code, words like `l;' screw up the
+        function. */
+      last_is_ident = _rl_isident (rl_line_buffer[rl_point - 1]);
+      if ((_rl_isident (rl_line_buffer[rl_point]) && !last_is_ident) ||
+         (!_rl_isident (rl_line_buffer[rl_point]) && last_is_ident))
+       rl_point--;
+
+      while (rl_point > 0 && whitespace (rl_line_buffer[rl_point]))
+       rl_point--;
+
+      if (rl_point > 0)
+       {
+         if (_rl_isident (rl_line_buffer[rl_point]))
+           while (--rl_point >= 0 && _rl_isident (rl_line_buffer[rl_point]));
+         else
+           while (--rl_point >= 0 && !_rl_isident (rl_line_buffer[rl_point]) &&
+                  !whitespace (rl_line_buffer[rl_point]));
+         rl_point++;
+       }
+    }
+  return (0);
+}
+
+int
+rl_vi_eword (count, ignore)
+     int count, ignore;
+{
+  while (count-- && rl_point < rl_end - 1)
+    {
+      if (!whitespace (rl_line_buffer[rl_point]))
+       rl_point++;
+
+      while (rl_point < rl_end && whitespace (rl_line_buffer[rl_point]))
+       rl_point++;
+
+      if (rl_point < rl_end)
+       {
+         if (_rl_isident (rl_line_buffer[rl_point]))
+           while (++rl_point < rl_end && _rl_isident (rl_line_buffer[rl_point]));
+         else
+           while (++rl_point < rl_end && !_rl_isident (rl_line_buffer[rl_point])
+                  && !whitespace (rl_line_buffer[rl_point]));
+       }
+      rl_point--;
+    }
+  return (0);
+}
+
+int
+rl_vi_insert_beg (count, key)
+     int count, key;
+{
+  rl_beg_of_line (1, key);
+  rl_vi_insertion_mode (1, key);
+  return (0);
+}
+
+static void
+_rl_vi_append_forward (key)
+     int key;
+{
+  int point;
+
+  if (rl_point < rl_end)
+    {
+      if (MB_CUR_MAX == 1 || rl_byte_oriented)
+       rl_point++;
+      else
+        {
+          point = rl_point;
+          rl_forward_char (1, key);
+          if (point == rl_point)
+            rl_point = rl_end;
+        }
+    }
+}
+
+int
+rl_vi_append_mode (count, key)
+     int count, key;
+{
+  _rl_vi_append_forward (key);
+  rl_vi_start_inserting (key, 1, rl_arg_sign);
+  return (0);
+}
+
+int
+rl_vi_append_eol (count, key)
+     int count, key;
+{
+  rl_end_of_line (1, key);
+  rl_vi_append_mode (1, key);
+  return (0);
+}
+
+/* What to do in the case of C-d. */
+int
+rl_vi_eof_maybe (count, c)
+     int count, c;
+{
+  return (rl_newline (1, '\n'));
+}
+
+/* Insertion mode stuff. */
+
+/* Switching from one mode to the other really just involves
+   switching keymaps. */
+int
+rl_vi_insertion_mode (count, key)
+     int count, key;
+{
+  _rl_keymap = vi_insertion_keymap;
+  _rl_vi_last_key_before_insert = key;
+  return (0);
+}
+
+static void
+_rl_vi_save_insert (up)
+      UNDO_LIST *up;
+{
+  int len, start, end;
+
+  if (up == 0 || up->what != UNDO_INSERT)
+    {
+      if (vi_insert_buffer_size >= 1)
+       vi_insert_buffer[0] = '\0';
+      return;
+    }
+
+  start = up->start;
+  end = up->end;
+  len = end - start + 1;
+  if (len >= vi_insert_buffer_size)
+    {
+      vi_insert_buffer_size += (len + 32) - (len % 32);
+      vi_insert_buffer = (char *)xrealloc (vi_insert_buffer, vi_insert_buffer_size);
+    }
+  strncpy (vi_insert_buffer, rl_line_buffer + start, len - 1);
+  vi_insert_buffer[len-1] = '\0';
+}
+    
+void
+_rl_vi_done_inserting ()
+{
+  if (_rl_vi_doing_insert)
+    {
+      /* The `C', `s', and `S' commands set this. */
+      rl_end_undo_group ();
+      /* Now, the text between rl_undo_list->next->start and
+        rl_undo_list->next->end is what was inserted while in insert
+        mode.  It gets copied to VI_INSERT_BUFFER because it depends
+        on absolute indices into the line which may change (though they
+        probably will not). */
+      _rl_vi_doing_insert = 0;
+      _rl_vi_save_insert (rl_undo_list->next);
+      vi_continued_command = 1;
+    }
+  else
+    {
+      if ((_rl_vi_last_key_before_insert == 'i' || _rl_vi_last_key_before_insert == 'a') && rl_undo_list)
+        _rl_vi_save_insert (rl_undo_list);
+      /* XXX - Other keys probably need to be checked. */
+      else if (_rl_vi_last_key_before_insert == 'C')
+       rl_end_undo_group ();
+      while (_rl_undo_group_level > 0)
+       rl_end_undo_group ();
+      vi_continued_command = 0;
+    }
+}
+
+int
+rl_vi_movement_mode (count, key)
+     int count, key;
+{
+  if (rl_point > 0)
+    rl_backward_char (1, key);
+
+  _rl_keymap = vi_movement_keymap;
+  _rl_vi_done_inserting ();
+
+  /* This is how POSIX.2 says `U' should behave -- everything up until the
+     first time you go into command mode should not be undone. */
+  if (RL_ISSTATE (RL_STATE_VICMDONCE) == 0)
+    rl_free_undo_list ();
+
+  RL_SETSTATE (RL_STATE_VICMDONCE);
+  return (0);
+}
+
+int
+rl_vi_arg_digit (count, c)
+     int count, c;
+{
+  if (c == '0' && rl_numeric_arg == 1 && !rl_explicit_arg)
+    return (rl_beg_of_line (1, c));
+  else
+    return (rl_digit_argument (count, c));
+}
+
+/* Change the case of the next COUNT characters. */
+#if defined (HANDLE_MULTIBYTE)
+static int
+_rl_vi_change_mbchar_case (count)
+     int count;
+{
+  wchar_t wc;
+  char mb[MB_LEN_MAX+1];
+  int mlen, p;
+  mbstate_t ps;
+
+  memset (&ps, 0, sizeof (mbstate_t));
+  if (_rl_adjust_point (rl_line_buffer, rl_point, &ps) > 0)
+    count--;
+  while (count-- && rl_point < rl_end)
+    {
+      mbrtowc (&wc, rl_line_buffer + rl_point, rl_end - rl_point, &ps);
+      if (iswupper (wc))
+       wc = towlower (wc);
+      else if (iswlower (wc))
+       wc = towupper (wc);
+      else
+       {
+         /* Just skip over chars neither upper nor lower case */
+         rl_forward_char (1, 0);
+         continue;
+       }
+
+      /* Vi is kind of strange here. */
+      if (wc)
+       {
+         p = rl_point;
+         mlen = wcrtomb (mb, wc, &ps);
+         if (mlen >= 0)
+           mb[mlen] = '\0';
+         rl_begin_undo_group ();
+         rl_vi_delete (1, 0);
+         if (rl_point < p)     /* Did we retreat at EOL? */
+           rl_point++; /* XXX - should we advance more than 1 for mbchar? */
+         rl_insert_text (mb);
+         rl_end_undo_group ();
+         rl_vi_check ();
+       }
+      else
+        rl_forward_char (1, 0);
+    }
+
+  return 0;
+}
+#endif
+
+int
+rl_vi_change_case (count, ignore)
+     int count, ignore;
+{
+  int c, p;
+
+  /* Don't try this on an empty line. */
+  if (rl_point >= rl_end)
+    return (0);
+
+  c = 0;
+#if defined (HANDLE_MULTIBYTE)
+  if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+    return (_rl_vi_change_mbchar_case (count));
+#endif
+
+  while (count-- && rl_point < rl_end)
+    {
+      if (_rl_uppercase_p (rl_line_buffer[rl_point]))
+       c = _rl_to_lower (rl_line_buffer[rl_point]);
+      else if (_rl_lowercase_p (rl_line_buffer[rl_point]))
+       c = _rl_to_upper (rl_line_buffer[rl_point]);
+      else
+       {
+         /* Just skip over characters neither upper nor lower case. */
+         rl_forward_char (1, c);
+         continue;
+       }
+
+      /* Vi is kind of strange here. */
+      if (c)
+       {
+         p = rl_point;
+         rl_begin_undo_group ();
+         rl_vi_delete (1, c);
+         if (rl_point < p)     /* Did we retreat at EOL? */
+           rl_point++;
+         _rl_insert_char (1, c);
+         rl_end_undo_group ();
+         rl_vi_check ();
+        }
+      else
+       rl_forward_char (1, c);
+    }
+  return (0);
+}
+
+int
+rl_vi_put (count, key)
+     int count, key;
+{
+  if (!_rl_uppercase_p (key) && (rl_point + 1 <= rl_end))
+    rl_point = _rl_find_next_mbchar (rl_line_buffer, rl_point, 1, MB_FIND_NONZERO);
+
+  while (count--)
+    rl_yank (1, key);
+
+  rl_backward_char (1, key);
+  return (0);
+}
+
+static void
+_rl_vi_backup ()
+{
+  if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+    rl_point = _rl_find_prev_mbchar (rl_line_buffer, rl_point, MB_FIND_NONZERO);
+  else
+    rl_point--;
+}
+
+int
+rl_vi_check ()
+{
+  if (rl_point && rl_point == rl_end)
+    {
+      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+       rl_point = _rl_find_prev_mbchar (rl_line_buffer, rl_point, MB_FIND_NONZERO);
+      else
+        rl_point--;
+    }
+  return (0);
+}
+
+int
+rl_vi_column (count, key)
+     int count, key;
+{
+  if (count > rl_end)
+    rl_end_of_line (1, key);
+  else
+    rl_point = count - 1;
+  return (0);
+}
+
+int
+rl_vi_domove (key, nextkey)
+     int key, *nextkey;
+{
+  int c, save;
+  int old_end;
+
+  rl_mark = rl_point;
+  RL_SETSTATE(RL_STATE_MOREINPUT);
+  c = rl_read_key ();
+  RL_UNSETSTATE(RL_STATE_MOREINPUT);
+  *nextkey = c;
+
+  if (!member (c, vi_motion))
+    {
+      if (_rl_digit_p (c))
+       {
+         save = rl_numeric_arg;
+         rl_numeric_arg = _rl_digit_value (c);
+         rl_explicit_arg = 1;
+         RL_SETSTATE (RL_STATE_NUMERICARG|RL_STATE_VIMOTION);
+         rl_digit_loop1 ();
+         RL_UNSETSTATE (RL_STATE_VIMOTION);
+         rl_numeric_arg *= save;
+         RL_SETSTATE(RL_STATE_MOREINPUT);
+         c = rl_read_key ();   /* real command */
+         RL_UNSETSTATE(RL_STATE_MOREINPUT);
+         *nextkey = c;
+       }
+      else if (key == c && (key == 'd' || key == 'y' || key == 'c'))
+       {
+         rl_mark = rl_end;
+         rl_beg_of_line (1, c);
+         _rl_vi_last_motion = c;
+         return (0);
+       }
+      else
+       return (-1);
+    }
+
+  _rl_vi_last_motion = c;
+
+  /* Append a blank character temporarily so that the motion routines
+     work right at the end of the line. */
+  old_end = rl_end;
+  rl_line_buffer[rl_end++] = ' ';
+  rl_line_buffer[rl_end] = '\0';
+
+  _rl_dispatch (c, _rl_keymap);
+
+  /* Remove the blank that we added. */
+  rl_end = old_end;
+  rl_line_buffer[rl_end] = '\0';
+  if (rl_point > rl_end)
+    rl_point = rl_end;
+
+  /* No change in position means the command failed. */
+  if (rl_mark == rl_point)
+    return (-1);
+
+  /* rl_vi_f[wW]ord () leaves the cursor on the first character of the next
+     word.  If we are not at the end of the line, and we are on a
+     non-whitespace character, move back one (presumably to whitespace). */
+  if ((_rl_to_upper (c) == 'W') && rl_point < rl_end && rl_point > rl_mark &&
+      !whitespace (rl_line_buffer[rl_point]))
+    rl_point--;
+
+  /* If cw or cW, back up to the end of a word, so the behaviour of ce
+     or cE is the actual result.  Brute-force, no subtlety. */
+  if (key == 'c' && rl_point >= rl_mark && (_rl_to_upper (c) == 'W'))
+    {
+      /* Don't move farther back than where we started. */
+      while (rl_point > rl_mark && whitespace (rl_line_buffer[rl_point]))
+       rl_point--;
+
+      /* Posix.2 says that if cw or cW moves the cursor towards the end of
+        the line, the character under the cursor should be deleted. */
+      if (rl_point == rl_mark)
+        rl_point++;
+      else
+       {
+         /* Move past the end of the word so that the kill doesn't
+            remove the last letter of the previous word.  Only do this
+            if we are not at the end of the line. */
+         if (rl_point >= 0 && rl_point < (rl_end - 1) && !whitespace (rl_line_buffer[rl_point]))
+           rl_point++;
+       }
+    }
+
+  if (rl_mark < rl_point)
+    SWAP (rl_point, rl_mark);
+
+  return (0);
+}
+
+/* Process C as part of the current numeric argument.  Return -1 if the
+   argument should be aborted, 0 if we should not read any more chars, and
+   1 if we should continue to read chars. */
+static int
+_rl_vi_arg_dispatch (c)
+     int c;
+{
+  int key;
+
+  key = c;
+  if (c >= 0 && _rl_keymap[c].type == ISFUNC && _rl_keymap[c].function == rl_universal_argument)
+    {
+      rl_numeric_arg *= 4;
+      return 1;
+    }
+
+  c = UNMETA (c);
+
+  if (_rl_digit_p (c))
+    {
+      if (rl_explicit_arg)
+       rl_numeric_arg = (rl_numeric_arg * 10) + _rl_digit_value (c);
+      else
+       rl_numeric_arg = _rl_digit_value (c);
+      rl_explicit_arg = 1;
+      return 1;
+    }
+  else
+    {
+      rl_clear_message ();
+      rl_stuff_char (key);
+      return 0;
+    }
+}
+
+/* A simplified loop for vi. Don't dispatch key at end.
+   Don't recognize minus sign?
+   Should this do rl_save_prompt/rl_restore_prompt? */
+static int
+rl_digit_loop1 ()
+{
+  int c, r;
+
+  while (1)
+    {
+      if (_rl_arg_overflow ())
+       return 1;
+
+      c = _rl_arg_getchar ();
+
+      r = _rl_vi_arg_dispatch (c);
+      if (r <= 0)
+       break;
+    }
+
+  RL_UNSETSTATE(RL_STATE_NUMERICARG);
+  return (0);
+}
+
+int
+rl_vi_delete_to (count, key)
+     int count, key;
+{
+  int c, start_pos;
+
+  if (_rl_uppercase_p (key))
+    rl_stuff_char ('$');
+  else if (vi_redoing)
+    rl_stuff_char (_rl_vi_last_motion);
+
+  start_pos = rl_point;
+
+  if (rl_vi_domove (key, &c))
+    {
+      rl_ding ();
+      return -1;
+    }
+
+  /* These are the motion commands that do not require adjusting the
+     mark. */
+  if (((strchr (" l|h^0bBFT`", c) == 0) && (rl_point >= start_pos)) &&
+      (rl_mark < rl_end))
+    rl_mark++;
+
+  rl_kill_text (rl_point, rl_mark);
+  return (0);
+}
+
+int
+rl_vi_change_to (count, key)
+     int count, key;
+{
+  int c, start_pos;
+
+  if (_rl_uppercase_p (key))
+    rl_stuff_char ('$');
+  else if (vi_redoing)
+    rl_stuff_char (_rl_vi_last_motion);
+
+  start_pos = rl_point;
+
+  if (rl_vi_domove (key, &c))
+    {
+      rl_ding ();
+      return -1;
+    }
+
+  /* These are the motion commands that do not require adjusting the
+     mark.  c[wW] are handled by special-case code in rl_vi_domove(),
+     and already leave the mark at the correct location. */
+  if (((strchr (" l|hwW^0bBFT`", c) == 0) && (rl_point >= start_pos)) &&
+      (rl_mark < rl_end))
+    rl_mark++;
+
+  /* The cursor never moves with c[wW]. */
+  if ((_rl_to_upper (c) == 'W') && rl_point < start_pos)
+    rl_point = start_pos;
+
+  if (vi_redoing)
+    {
+      if (vi_insert_buffer && *vi_insert_buffer)
+       rl_begin_undo_group ();
+      rl_delete_text (rl_point, rl_mark);
+      if (vi_insert_buffer && *vi_insert_buffer)
+       {
+         rl_insert_text (vi_insert_buffer);
+         rl_end_undo_group ();
+       }
+    }
+  else
+    {
+      rl_begin_undo_group ();          /* to make the `u' command work */
+      rl_kill_text (rl_point, rl_mark);
+      /* `C' does not save the text inserted for undoing or redoing. */
+      if (_rl_uppercase_p (key) == 0)
+        _rl_vi_doing_insert = 1;
+      rl_vi_start_inserting (key, rl_numeric_arg, rl_arg_sign);
+    }
+
+  return (0);
+}
+
+int
+rl_vi_yank_to (count, key)
+     int count, key;
+{
+  int c, start_pos;
+
+  if (_rl_uppercase_p (key))
+    rl_stuff_char ('$');
+
+  start_pos = rl_point;
+
+  if (rl_vi_domove (key, &c))
+    {
+      rl_ding ();
+      return -1;
+    }
+
+  /* These are the motion commands that do not require adjusting the
+     mark. */
+  if (((strchr (" l|h^0%bBFT`", c) == 0) && (rl_point >= start_pos)) &&
+      (rl_mark < rl_end))
+    rl_mark++;
+
+  rl_begin_undo_group ();
+  rl_kill_text (rl_point, rl_mark);
+  rl_end_undo_group ();
+  rl_do_undo ();
+  rl_point = start_pos;
+
+  return (0);
+}
+
+int
+rl_vi_rubout (count, key)
+     int count, key;
+{
+  int opoint;
+
+  if (count < 0)
+    return (rl_vi_delete (-count, key));
+
+  if (rl_point == 0)
+    {
+      rl_ding ();
+      return -1;
+    }
+
+  opoint = rl_point;
+  if (count > 1 && MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+    rl_backward_char (count, key);
+  else if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+    rl_point = _rl_find_prev_mbchar (rl_line_buffer, rl_point, MB_FIND_NONZERO);
+  else
+    rl_point -= count;
+
+  if (rl_point < 0)
+    rl_point = 0;
+
+  rl_kill_text (rl_point, opoint);
+  
+  return (0);
+}
+
+int
+rl_vi_delete (count, key)
+     int count, key;
+{
+  int end;
+
+  if (count < 0)
+    return (rl_vi_rubout (-count, key));
+
+  if (rl_end == 0)
+    {
+      rl_ding ();
+      return -1;
+    }
+
+  if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+    end = _rl_find_next_mbchar (rl_line_buffer, rl_point, count, MB_FIND_NONZERO);
+  else
+    end = rl_point + count;
+
+  if (end >= rl_end)
+    end = rl_end;
+
+  rl_kill_text (rl_point, end);
+  
+  if (rl_point > 0 && rl_point == rl_end)
+    rl_backward_char (1, key);
+
+  return (0);
+}
+
+int
+rl_vi_back_to_indent (count, key)
+     int count, key;
+{
+  rl_beg_of_line (1, key);
+  while (rl_point < rl_end && whitespace (rl_line_buffer[rl_point]))
+    rl_point++;
+  return (0);
+}
+
+int
+rl_vi_first_print (count, key)
+     int count, key;
+{
+  return (rl_vi_back_to_indent (1, key));
+}
+
+static int _rl_cs_dir, _rl_cs_orig_dir;
+
+#if defined (READLINE_CALLBACKS)
+static int
+_rl_vi_callback_char_search (data)
+     _rl_callback_generic_arg *data;
+{
+#if defined (HANDLE_MULTIBYTE)
+  _rl_vi_last_search_mblen = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
+#else
+  RL_SETSTATE(RL_STATE_MOREINPUT);
+  _rl_vi_last_search_char = rl_read_key ();
+  RL_UNSETSTATE(RL_STATE_MOREINPUT);
+#endif
+
+  _rl_callback_func = 0;
+  _rl_want_redisplay = 1;
+
+#if defined (HANDLE_MULTIBYTE)
+  return (_rl_char_search_internal (data->count, _rl_cs_dir, _rl_vi_last_search_mbchar, _rl_vi_last_search_mblen));
+#else
+  return (_rl_char_search_internal (data->count, _rl_cs_dir, _rl_vi_last_search_char));
+#endif  
+}
+#endif
+
+int
+rl_vi_char_search (count, key)
+     int count, key;
+{
+#if defined (HANDLE_MULTIBYTE)
+  static char *target;
+  static int tlen;
+#else
+  static char target;
+#endif
+
+  if (key == ';' || key == ',')
+    _rl_cs_dir = (key == ';') ? _rl_cs_orig_dir : -_rl_cs_orig_dir;
+  else
+    {
+      switch (key)
+        {
+        case 't':
+          _rl_cs_orig_dir = _rl_cs_dir = FTO;
+          break;
+
+        case 'T':
+          _rl_cs_orig_dir = _rl_cs_dir = BTO;
+          break;
+
+        case 'f':
+          _rl_cs_orig_dir = _rl_cs_dir = FFIND;
+          break;
+
+        case 'F':
+          _rl_cs_orig_dir = _rl_cs_dir = BFIND;
+          break;
+        }
+
+      if (vi_redoing)
+       {
+         /* set target and tlen below */
+       }
+#if defined (READLINE_CALLBACKS)
+      else if (RL_ISSTATE (RL_STATE_CALLBACK))
+        {
+          _rl_callback_data = _rl_callback_data_alloc (count);
+          _rl_callback_data->i1 = _rl_cs_dir;
+          _rl_callback_func = _rl_vi_callback_char_search;
+          return (0);
+        }
+#endif
+      else
+       {
+#if defined (HANDLE_MULTIBYTE)
+         _rl_vi_last_search_mblen = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
+#else
+         RL_SETSTATE(RL_STATE_MOREINPUT);
+         _rl_vi_last_search_char = rl_read_key ();
+         RL_UNSETSTATE(RL_STATE_MOREINPUT);
+#endif
+       }
+    }
+
+#if defined (HANDLE_MULTIBYTE)
+  target = _rl_vi_last_search_mbchar;
+  tlen = _rl_vi_last_search_mblen;
+#else
+  target = _rl_vi_last_search_char;
+#endif
+
+#if defined (HANDLE_MULTIBYTE)
+  return (_rl_char_search_internal (count, _rl_cs_dir, target, tlen));
+#else
+  return (_rl_char_search_internal (count, _rl_cs_dir, target));
+#endif
+}
+
+/* Match brackets */
+int
+rl_vi_match (ignore, key)
+     int ignore, key;
+{
+  int count = 1, brack, pos, tmp, pre;
+
+  pos = rl_point;
+  if ((brack = rl_vi_bracktype (rl_line_buffer[rl_point])) == 0)
+    {
+      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+       {
+         while ((brack = rl_vi_bracktype (rl_line_buffer[rl_point])) == 0)
+           {
+             pre = rl_point;
+             rl_forward_char (1, key);
+             if (pre == rl_point)
+               break;
+           }
+       }
+      else
+       while ((brack = rl_vi_bracktype (rl_line_buffer[rl_point])) == 0 &&
+               rl_point < rl_end - 1)
+         rl_forward_char (1, key);
+
+      if (brack <= 0)
+       {
+         rl_point = pos;
+         rl_ding ();
+         return -1;
+       }
+    }
+
+  pos = rl_point;
+
+  if (brack < 0)
+    {
+      while (count)
+       {
+         tmp = pos;
+         if (MB_CUR_MAX == 1 || rl_byte_oriented)
+           pos--;
+         else
+           {
+             pos = _rl_find_prev_mbchar (rl_line_buffer, pos, MB_FIND_ANY);
+             if (tmp == pos)
+               pos--;
+           }
+         if (pos >= 0)
+           {
+             int b = rl_vi_bracktype (rl_line_buffer[pos]);
+             if (b == -brack)
+               count--;
+             else if (b == brack)
+               count++;
+           }
+         else
+           {
+             rl_ding ();
+             return -1;
+           }
+       }
+    }
+  else
+    {                  /* brack > 0 */
+      while (count)
+       {
+         if (MB_CUR_MAX == 1 || rl_byte_oriented)
+           pos++;
+         else
+           pos = _rl_find_next_mbchar (rl_line_buffer, pos, 1, MB_FIND_ANY);
+
+         if (pos < rl_end)
+           {
+             int b = rl_vi_bracktype (rl_line_buffer[pos]);
+             if (b == -brack)
+               count--;
+             else if (b == brack)
+               count++;
+           }
+         else
+           {
+             rl_ding ();
+             return -1;
+           }
+       }
+    }
+  rl_point = pos;
+  return (0);
+}
+
+int
+rl_vi_bracktype (c)
+     int c;
+{
+  switch (c)
+    {
+    case '(': return  1;
+    case ')': return -1;
+    case '[': return  2;
+    case ']': return -2;
+    case '{': return  3;
+    case '}': return -3;
+    default:  return  0;
+    }
+}
+
+static int
+_rl_vi_change_char (count, c, mb)
+     int count, c;
+     char *mb;
+{
+  int p;
+
+  if (c == '\033' || c == CTRL ('C'))
+    return -1;
+
+  rl_begin_undo_group ();
+  while (count-- && rl_point < rl_end)
+    {
+      p = rl_point;
+      rl_vi_delete (1, c);
+      if (rl_point < p)                /* Did we retreat at EOL? */
+       rl_point++;
+#if defined (HANDLE_MULTIBYTE)
+      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+       rl_insert_text (mb);
+      else
+#endif
+       _rl_insert_char (1, c);
+    }
+
+  /* The cursor shall be left on the last character changed. */
+  rl_backward_char (1, c);
+
+  rl_end_undo_group ();
+
+  return (0);
+}
+
+static int
+_rl_vi_callback_getchar (mb, mlen)
+     char *mb;
+     int mlen;
+{
+  int c;
+
+  RL_SETSTATE(RL_STATE_MOREINPUT);
+  c = rl_read_key ();
+  RL_UNSETSTATE(RL_STATE_MOREINPUT);
+
+#if defined (HANDLE_MULTIBYTE)
+  if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+    c = _rl_read_mbstring (c, mb, mlen);
+#endif
+
+  return c;
+}
+
+#if defined (READLINE_CALLBACKS)
+static int
+_rl_vi_callback_change_char (data)
+     _rl_callback_generic_arg *data;
+{
+  int c;
+  char mb[MB_LEN_MAX];
+
+  _rl_vi_last_replacement = c = _rl_vi_callback_getchar (mb, MB_LEN_MAX);
+
+  _rl_callback_func = 0;
+  _rl_want_redisplay = 1;
+
+  return (_rl_vi_change_char (data->count, c, mb));
+}
+#endif
+
+int
+rl_vi_change_char (count, key)
+     int count, key;
+{
+  int c;
+  char mb[MB_LEN_MAX];
+
+  if (vi_redoing)
+    {
+      c = _rl_vi_last_replacement;
+      mb[0] = c;
+      mb[1] = '\0';
+    }
+#if defined (READLINE_CALLBACKS)
+  else if (RL_ISSTATE (RL_STATE_CALLBACK))
+    {
+      _rl_callback_data = _rl_callback_data_alloc (count);
+      _rl_callback_func = _rl_vi_callback_change_char;
+      return (0);
+    }
+#endif
+  else
+    _rl_vi_last_replacement = c = _rl_vi_callback_getchar (mb, MB_LEN_MAX);
+
+  return (_rl_vi_change_char (count, c, mb));
+}
+
+int
+rl_vi_subst (count, key)
+     int count, key;
+{
+  /* If we are redoing, rl_vi_change_to will stuff the last motion char */
+  if (vi_redoing == 0)
+    rl_stuff_char ((key == 'S') ? 'c' : 'l');  /* `S' == `cc', `s' == `cl' */
+
+  return (rl_vi_change_to (count, 'c'));
+}
+
+int
+rl_vi_overstrike (count, key)
+     int count, key;
+{
+  if (_rl_vi_doing_insert == 0)
+    {
+      _rl_vi_doing_insert = 1;
+      rl_begin_undo_group ();
+    }
+
+  if (count > 0)
+    {
+      _rl_overwrite_char (count, key);
+      vi_replace_count += count;
+    }
+
+  return (0);
+}
+
+int
+rl_vi_overstrike_delete (count, key)
+     int count, key;
+{
+  int i, s;
+
+  for (i = 0; i < count; i++)
+    {
+      if (vi_replace_count == 0)
+       {
+         rl_ding ();
+         break;
+       }
+      s = rl_point;
+
+      if (rl_do_undo ())
+       vi_replace_count--;
+
+      if (rl_point == s)
+       rl_backward_char (1, key);
+    }
+
+  if (vi_replace_count == 0 && _rl_vi_doing_insert)
+    {
+      rl_end_undo_group ();
+      rl_do_undo ();
+      _rl_vi_doing_insert = 0;
+    }
+  return (0);
+}
+
+int
+rl_vi_replace (count, key)
+     int count, key;
+{
+  int i;
+
+  vi_replace_count = 0;
+
+  if (!vi_replace_map)
+    {
+      vi_replace_map = rl_make_bare_keymap ();
+
+      for (i = ' '; i < KEYMAP_SIZE; i++)
+       vi_replace_map[i].function = rl_vi_overstrike;
+
+      vi_replace_map[RUBOUT].function = rl_vi_overstrike_delete;
+      vi_replace_map[ESC].function = rl_vi_movement_mode;
+      vi_replace_map[RETURN].function = rl_newline;
+      vi_replace_map[NEWLINE].function = rl_newline;
+
+      /* If the normal vi insertion keymap has ^H bound to erase, do the
+         same here.  Probably should remove the assignment to RUBOUT up
+         there, but I don't think it will make a difference in real life. */
+      if (vi_insertion_keymap[CTRL ('H')].type == ISFUNC &&
+         vi_insertion_keymap[CTRL ('H')].function == rl_rubout)
+       vi_replace_map[CTRL ('H')].function = rl_vi_overstrike_delete;
+
+    }
+  _rl_keymap = vi_replace_map;
+  return (0);
+}
+
+#if 0
+/* Try to complete the word we are standing on or the word that ends with
+   the previous character.  A space matches everything.  Word delimiters are
+   space and ;. */
+int
+rl_vi_possible_completions()
+{
+  int save_pos = rl_point;
+
+  if (rl_line_buffer[rl_point] != ' ' && rl_line_buffer[rl_point] != ';')
+    {
+      while (rl_point < rl_end && rl_line_buffer[rl_point] != ' ' &&
+            rl_line_buffer[rl_point] != ';')
+       rl_point++;
+    }
+  else if (rl_line_buffer[rl_point - 1] == ';')
+    {
+      rl_ding ();
+      return (0);
+    }
+
+  rl_possible_completions ();
+  rl_point = save_pos;
+
+  return (0);
+}
+#endif
+
+/* Functions to save and restore marks. */
+static int
+_rl_vi_set_mark ()
+{
+  int ch;
+
+  RL_SETSTATE(RL_STATE_MOREINPUT);
+  ch = rl_read_key ();
+  RL_UNSETSTATE(RL_STATE_MOREINPUT);
+
+  if (ch < 'a' || ch > 'z')
+    {
+      rl_ding ();
+      return -1;
+    }
+  ch -= 'a';
+  vi_mark_chars[ch] = rl_point;
+  return 0;
+}
+
+#if defined (READLINE_CALLBACKS)
+static int
+_rl_vi_callback_set_mark (data)
+     _rl_callback_generic_arg *data;
+{
+  _rl_callback_func = 0;
+  _rl_want_redisplay = 1;
+
+  return (_rl_vi_set_mark ());
+}
+#endif
+
+int
+rl_vi_set_mark (count, key)
+     int count, key;
+{
+#if defined (READLINE_CALLBACKS)
+  if (RL_ISSTATE (RL_STATE_CALLBACK))
+    {
+      _rl_callback_data = 0;
+      _rl_callback_func = _rl_vi_callback_set_mark;
+      return (0);
+    }
+#endif
+
+  return (_rl_vi_set_mark ());
+}
+
+static int
+_rl_vi_goto_mark ()
+{
+  int ch;
+
+  RL_SETSTATE(RL_STATE_MOREINPUT);
+  ch = rl_read_key ();
+  RL_UNSETSTATE(RL_STATE_MOREINPUT);
+
+  if (ch == '`')
+    {
+      rl_point = rl_mark;
+      return 0;
+    }
+  else if (ch < 'a' || ch > 'z')
+    {
+      rl_ding ();
+      return -1;
+    }
+
+  ch -= 'a';
+  if (vi_mark_chars[ch] == -1)
+    {
+      rl_ding ();
+      return -1;
+    }
+  rl_point = vi_mark_chars[ch];
+  return 0;
+}
+
+#if defined (READLINE_CALLBACKS)
+static int
+_rl_vi_callback_goto_mark (data)
+     _rl_callback_generic_arg *data;
+{
+  _rl_callback_func = 0;
+  _rl_want_redisplay = 1;
+
+  return (_rl_vi_goto_mark ());
+}
+#endif
+
+int
+rl_vi_goto_mark (count, key)
+     int count, key;
+{
+#if defined (READLINE_CALLBACKS)
+  if (RL_ISSTATE (RL_STATE_CALLBACK))
+    {
+      _rl_callback_data = 0;
+      _rl_callback_func = _rl_vi_callback_goto_mark;
+      return (0);
+    }
+#endif
+
+  return (_rl_vi_goto_mark ());
+}
+#endif /* VI_MODE */
diff --git a/parse.y b/parse.y
index 7a83d46fb9b8939d38eb6cf93869d42eba0108b5..b8d6372de964bc49f0298c55f5e81d851012529a 100644 (file)
--- a/parse.y
+++ b/parse.y
@@ -3859,7 +3859,7 @@ reset_readline_prompt ()
 /* A list of tokens which can be followed by newlines, but not by
    semi-colons.  When concatenating multiple lines of history, the
    newline separator for such tokens is replaced with a space. */
-static int no_semi_successors[] = {
+static const int no_semi_successors[] = {
   '\n', '{', '(', ')', ';', '&', '|',
   CASE, DO, ELSE, IF, SEMI_SEMI, THEN, UNTIL, WHILE, AND_AND, OR_OR, IN,
   0
index 1de7380b10bd1fb9d98dd20fe4f5df20d32eaacd..7a83d46fb9b8939d38eb6cf93869d42eba0108b5 100644 (file)
--- a/parse.y~
+++ b/parse.y~
@@ -2593,10 +2593,7 @@ read_token (command)
     }
 
   if (parser_state & PST_REGEXP)
-{
-itrace("read_token: parser_state & PST_REGEXP; goto tokword");
     goto tokword;
-}
 
   /* Shell meta-characters. */
   if MBTEST(shellmeta (character) && ((parser_state & PST_DBLPAREN) == 0))
@@ -3211,10 +3208,10 @@ cond_term ()
        op = yylval.word;
 #if defined (COND_REGEXP)
       else if (tok == WORD && STREQ (yylval.word->word, "=~"))
-{
-       op = yylval.word;
-parser_state |= PST_REGEXP;
-}
+       {
+         op = yylval.word;
+         parser_state |= PST_REGEXP;
+       }
 #endif
       else if (tok == '<' || tok == '>')
        op = make_word_from_token (tok);  /* ( */
@@ -3245,7 +3242,7 @@ parser_state |= PST_REGEXP;
 
       /* rhs */
       tok = read_token (READ);
-parser_state &= ~PST_REGEXP;
+      parser_state &= ~PST_REGEXP;
       if (tok == WORD)
        {
          tright = make_cond_node (COND_TERM, yylval.word, (COND_COM *)NULL, (COND_COM *)NULL);
@@ -3436,9 +3433,9 @@ read_token_word (character)
         we need to special-case characters special to both the shell and
         regular expressions.  Right now, that is only '(' and '|'. */ /*)*/
       if MBTEST((parser_state & PST_REGEXP) && (character == '(' || character == '|'))         /*)*/
-        {
-          if (character == '|')
-            goto got_character;
+       {
+         if (character == '|')
+           goto got_character;
 
          push_delimiter (dstack, character);
          ttok = parse_matched_pair (cd, '(', ')', &ttoklen, 0);
@@ -3453,7 +3450,7 @@ read_token_word (character)
          FREE (ttok);
          dollar_present = all_digit_token = 0;
          goto next_character;
-        }
+       }
 #endif /* COND_REGEXP */
 
 #ifdef EXTENDED_GLOB
index 471fb54f95b5116f0442734f89bce94554413c29..d250cd88053e76d02531e3357e5fe7a3609a3827 100644 (file)
@@ -894,6 +894,16 @@ bind_compfunc_variables (line, ind, lwords, cw, exported)
   if (v && exported)
     VSETATTR(v, att_exported);
 
+  value = inttostr (rl_completion_type, ibuf, sizeof (ibuf));
+  v = bind_int_variable ("COMP_TYPE", value);
+  if (v && exported)
+    VSETATTR(v, att_exported);
+
+  value = inttostr (rl_completion_invoking_key, ibuf, sizeof (ibuf));
+  v = bind_int_variable ("COMP_KEY", value);
+  if (v && exported)
+    VSETATTR(v, att_exported);
+
   /* Since array variables can't be exported, we don't bother making the
      array of words. */
   if (exported == 0)
@@ -914,6 +924,8 @@ unbind_compfunc_variables (exported)
 {
   unbind_variable ("COMP_LINE");
   unbind_variable ("COMP_POINT");
+  unbind_variable ("COMP_TYPE");
+  unbind_variable ("COMP_KEY");
 #ifdef ARRAY_VARS
   unbind_variable ("COMP_WORDS");
   unbind_variable ("COMP_CWORD");
diff --git a/pcomplete.c~ b/pcomplete.c~
new file mode 100644 (file)
index 0000000..7eb1a2c
--- /dev/null
@@ -0,0 +1,1405 @@
+/* pcomplete.c - functions to generate lists of matches for programmable
+                completion. */
+
+/* Copyright (C) 1999-2005 Free Software Foundation, Inc.
+
+   This file is part of GNU Bash, the Bourne Again SHell.
+
+   Bash is free software; you can redistribute it and/or modify it under
+   the terms of the GNU General Public License as published by the Free
+   Software Foundation; either version 2, or (at your option) any later
+   version.
+
+   Bash is distributed in the hope that it will be useful, but WITHOUT ANY
+   WARRANTY; without even the implied warranty of MERCHANTABILITY or
+   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+   for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with Bash; see the file COPYING.  If not, write to the Free Software
+   Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+#include <config.h>
+
+#if defined (PROGRAMMABLE_COMPLETION)
+
+#include "bashtypes.h"
+#include "posixstat.h"
+
+#if defined (HAVE_UNISTD_H)
+#  include <unistd.h>
+#endif
+
+#include <signal.h>
+
+#if defined (PREFER_STDARG)
+#  include <stdarg.h>
+#else
+#  include <varargs.h>
+#endif
+
+#include <stdio.h>
+#include "bashansi.h"
+#include "bashintl.h"
+
+#include "shell.h"
+#include "pcomplete.h"
+#include "alias.h"
+#include "bashline.h"
+#include "execute_cmd.h"
+#include "pathexp.h"
+
+#if defined (JOB_CONTROL)
+#  include "jobs.h"
+#endif
+
+#if !defined (NSIG)
+#  include "trap.h"
+#endif
+
+#include "builtins.h"
+#include "builtins/common.h"
+
+#include <glob/glob.h>
+#include <glob/strmatch.h>
+
+#include <readline/rlconf.h>
+#include <readline/readline.h>
+#include <readline/history.h>
+
+#ifdef STRDUP
+#  undef STRDUP
+#endif
+#define STRDUP(x)      ((x) ? savestring (x) : (char *)NULL)
+
+typedef SHELL_VAR **SVFUNC ();
+
+#ifndef HAVE_STRPBRK
+extern char *strpbrk __P((char *, char *));
+#endif
+
+extern int array_needs_making;
+extern STRING_INT_ALIST word_token_alist[];
+extern char *signal_names[];
+
+#if defined (DEBUG)
+#if defined (PREFER_STDARG)
+static void debug_printf (const char *, ...)  __attribute__((__format__ (printf, 1, 2)));
+#endif
+#endif /* DEBUG */
+
+static int it_init_joblist __P((ITEMLIST *, int));
+
+static int it_init_aliases __P((ITEMLIST *));
+static int it_init_arrayvars __P((ITEMLIST *));
+static int it_init_bindings __P((ITEMLIST *));
+static int it_init_builtins __P((ITEMLIST *));
+static int it_init_disabled __P((ITEMLIST *));
+static int it_init_enabled __P((ITEMLIST *));
+static int it_init_exported __P((ITEMLIST *));
+static int it_init_functions __P((ITEMLIST *));
+static int it_init_hostnames __P((ITEMLIST *));
+static int it_init_jobs __P((ITEMLIST *));
+static int it_init_running __P((ITEMLIST *));
+static int it_init_stopped __P((ITEMLIST *));
+static int it_init_keywords __P((ITEMLIST *));
+static int it_init_signals __P((ITEMLIST *));
+static int it_init_variables __P((ITEMLIST *));
+static int it_init_setopts __P((ITEMLIST *));
+static int it_init_shopts __P((ITEMLIST *));
+
+static int shouldexp_filterpat __P((char *));
+static char *preproc_filterpat __P((char *, char *));
+
+static void init_itemlist_from_varlist __P((ITEMLIST *, SVFUNC *));
+
+static STRINGLIST *gen_matches_from_itemlist __P((ITEMLIST *, const char *));
+static STRINGLIST *gen_action_completions __P((COMPSPEC *, const char *));
+static STRINGLIST *gen_globpat_matches __P((COMPSPEC *, const char *));
+static STRINGLIST *gen_wordlist_matches __P((COMPSPEC *, const char *));
+static STRINGLIST *gen_shell_function_matches __P((COMPSPEC *, const char *,
+                                                  char *, int, WORD_LIST *,
+                                                  int, int));
+static STRINGLIST *gen_command_matches __P((COMPSPEC *, const char *, char *,
+                                           int, WORD_LIST *, int, int));
+
+static char *pcomp_filename_completion_function __P((const char *, int));
+
+#if defined (ARRAY_VARS)
+static SHELL_VAR *bind_comp_words __P((WORD_LIST *));
+#endif
+static void bind_compfunc_variables __P((char *, int, WORD_LIST *, int, int));
+static void unbind_compfunc_variables __P((int));
+static WORD_LIST *build_arg_list __P((char *, const char *, WORD_LIST *, int));
+static WORD_LIST *command_line_to_word_list __P((char *, int, int, int *, int *));
+
+#ifdef DEBUG
+static int progcomp_debug = 0;
+#endif
+
+int prog_completion_enabled = 1;
+
+/* These are used to manage the arrays of strings for possible completions. */
+ITEMLIST it_aliases = { 0, it_init_aliases, (STRINGLIST *)0 };
+ITEMLIST it_arrayvars  = { LIST_DYNAMIC, it_init_arrayvars, (STRINGLIST *)0 };
+ITEMLIST it_bindings  = { 0, it_init_bindings, (STRINGLIST *)0 };
+ITEMLIST it_builtins  = { 0, it_init_builtins, (STRINGLIST *)0 };
+ITEMLIST it_commands = { LIST_DYNAMIC };       /* unused */
+ITEMLIST it_directories = { LIST_DYNAMIC };    /* unused */
+ITEMLIST it_disabled = { 0, it_init_disabled, (STRINGLIST *)0 };
+ITEMLIST it_enabled = { 0, it_init_enabled, (STRINGLIST *)0 };
+ITEMLIST it_exports  = { LIST_DYNAMIC, it_init_exported, (STRINGLIST *)0 };
+ITEMLIST it_files = { LIST_DYNAMIC };          /* unused */
+ITEMLIST it_functions  = { 0, it_init_functions, (STRINGLIST *)0 };
+ITEMLIST it_hostnames  = { LIST_DYNAMIC, it_init_hostnames, (STRINGLIST *)0 };
+ITEMLIST it_groups = { LIST_DYNAMIC };         /* unused */
+ITEMLIST it_jobs = { LIST_DYNAMIC, it_init_jobs, (STRINGLIST *)0 };
+ITEMLIST it_keywords = { 0, it_init_keywords, (STRINGLIST *)0 };
+ITEMLIST it_running = { LIST_DYNAMIC, it_init_running, (STRINGLIST *)0 };
+ITEMLIST it_services = { LIST_DYNAMIC };       /* unused */
+ITEMLIST it_setopts = { 0, it_init_setopts, (STRINGLIST *)0 };
+ITEMLIST it_shopts = { 0, it_init_shopts, (STRINGLIST *)0 };
+ITEMLIST it_signals = { 0, it_init_signals, (STRINGLIST *)0 };
+ITEMLIST it_stopped = { LIST_DYNAMIC, it_init_stopped, (STRINGLIST *)0 };
+ITEMLIST it_users = { LIST_DYNAMIC };          /* unused */
+ITEMLIST it_variables = { LIST_DYNAMIC, it_init_variables, (STRINGLIST *)0 };
+
+#ifdef DEBUG
+/* Debugging code */
+static void
+#if defined (PREFER_STDARG)
+debug_printf (const char *format, ...)
+#else
+debug_printf (format, va_alist)
+     const char *format;
+     va_dcl
+#endif
+{
+  va_list args;
+
+  if (progcomp_debug == 0)
+    return;
+
+  SH_VA_START (args, format);
+
+  fprintf (stdout, "DEBUG: ");
+  vfprintf (stdout, format, args);
+  fprintf (stdout, "\n");
+
+  rl_on_new_line ();
+
+  va_end (args);
+}
+#endif
+
+/* Functions to manage the item lists */
+
+void
+set_itemlist_dirty (it)
+     ITEMLIST *it;
+{
+  it->flags |= LIST_DIRTY;
+}
+
+void
+initialize_itemlist (itp)
+     ITEMLIST *itp;
+{
+  (*itp->list_getter) (itp);
+  itp->flags |= LIST_INITIALIZED;
+  itp->flags &= ~LIST_DIRTY;
+}
+
+void
+clean_itemlist (itp)
+     ITEMLIST *itp;
+{
+  STRINGLIST *sl;
+
+  sl = itp->slist;
+  if (sl)
+    {
+      if ((itp->flags & (LIST_DONTFREEMEMBERS|LIST_DONTFREE)) == 0)
+       strvec_flush (sl->list);
+      if ((itp->flags & LIST_DONTFREE) == 0)
+       free (sl->list);
+      free (sl);
+    }
+  itp->slist = (STRINGLIST *)NULL;
+  itp->flags &= ~(LIST_DONTFREE|LIST_DONTFREEMEMBERS|LIST_INITIALIZED|LIST_DIRTY);
+}
+
+
+static int
+shouldexp_filterpat (s)
+     char *s;
+{
+  register char *p;
+
+  for (p = s; p && *p; p++)
+    {
+      if (*p == '\\')
+       p++;
+      else if (*p == '&')
+       return 1;
+    }
+  return 0;
+}
+
+/* Replace any instance of `&' in PAT with TEXT.  Backslash may be used to
+   quote a `&' and inhibit substitution.  Returns a new string.  This just
+   calls stringlib.c:strcreplace(). */
+static char *
+preproc_filterpat (pat, text)
+     char *pat;
+     char *text;
+{
+  char *ret;
+
+  ret = strcreplace (pat, '&', text, 1);
+  return ret;
+}
+       
+/* Remove any match of FILTERPAT from SL.  A `&' in FILTERPAT is replaced by
+   TEXT.  A leading `!' in FILTERPAT negates the pattern; in this case
+   any member of SL->list that does *not* match will be removed.  This returns
+   a new STRINGLIST with the matching members of SL *copied*.  Any
+   non-matching members of SL->list are *freed*. */   
+STRINGLIST *
+filter_stringlist (sl, filterpat, text)
+     STRINGLIST *sl;
+     char *filterpat, *text;
+{
+  int i, m, not;
+  STRINGLIST *ret;
+  char *npat, *t;
+
+  if (sl == 0 || sl->list == 0 || sl->list_len == 0)
+    return sl;
+
+  npat = shouldexp_filterpat (filterpat) ? preproc_filterpat (filterpat, text) : filterpat;
+
+  not = (npat[0] == '!');
+  t = not ? npat + 1 : npat;
+
+  ret = strlist_create (sl->list_size);
+  for (i = 0; i < sl->list_len; i++)
+    {
+      m = strmatch (t, sl->list[i], FNMATCH_EXTFLAG);
+      if ((not && m == FNM_NOMATCH) || (not == 0 && m != FNM_NOMATCH))
+       free (sl->list[i]);
+      else
+       ret->list[ret->list_len++] = sl->list[i];
+    }
+
+  ret->list[ret->list_len] = (char *)NULL;
+  if (npat != filterpat)
+    free (npat);
+
+  return ret;
+}
+
+/* Turn an array of strings returned by rl_completion_matches into a STRINGLIST.
+   This understands how rl_completion_matches sets matches[0] (the lcd of the
+   strings in the list, unless it's the only match). */
+STRINGLIST *
+completions_to_stringlist (matches)
+     char **matches;
+{
+  STRINGLIST *sl;
+  int mlen, i, n;
+
+  mlen = (matches == 0) ? 0 : strvec_len (matches);
+  sl = strlist_create (mlen + 1);
+
+  if (matches == 0 || matches[0] == 0)
+    return sl;
+
+  if (matches[1] == 0)
+    {
+      sl->list[0] = STRDUP (matches[0]);
+      sl->list[sl->list_len = 1] = (char *)NULL;
+      return sl;
+    }
+
+  for (i = 1, n = 0; i < mlen; i++, n++)
+    sl->list[n] = STRDUP (matches[i]);
+  sl->list_len = n;
+  sl->list[n] = (char *)NULL;
+
+  return sl;
+}
+
+/* Functions to manage the various ITEMLISTs that we populate internally.
+   The caller is responsible for setting ITP->flags correctly. */
+
+static int
+it_init_aliases (itp)
+     ITEMLIST *itp;
+{
+#ifdef ALIAS
+  alias_t **alias_list;
+  register int i, n;
+  STRINGLIST *sl;
+
+  alias_list = all_aliases ();
+  if (alias_list == 0)
+    {
+      itp->slist = (STRINGLIST *)NULL;
+      return 0;
+    }
+  for (n = 0; alias_list[n]; n++)
+    ;
+  sl = strlist_create (n+1);
+  for (i = 0; i < n; i++)
+    sl->list[i] = STRDUP (alias_list[i]->name);
+  sl->list[n] = (char *)NULL;
+  sl->list_size = sl->list_len = n;
+  itp->slist = sl;
+#else
+  itp->slist = (STRINGLIST *)NULL;
+#endif
+  return 1;
+}
+
+static void
+init_itemlist_from_varlist (itp, svfunc)
+     ITEMLIST *itp;
+     SVFUNC *svfunc;
+{
+  SHELL_VAR **vlist;
+  STRINGLIST *sl;
+  register int i, n;
+
+  vlist = (*svfunc) ();
+  if (vlist == 0)
+    {
+      itp->slist = (STRINGLIST *)NULL;
+      return;
+    }    
+  for (n = 0; vlist[n]; n++)
+    ;
+  sl = strlist_create (n+1);
+  for (i = 0; i < n; i++)
+    sl->list[i] = savestring (vlist[i]->name);
+  sl->list[sl->list_len = n] = (char *)NULL;
+  itp->slist = sl;
+}
+
+static int
+it_init_arrayvars (itp)
+     ITEMLIST *itp;
+{
+#if defined (ARRAY_VARS)
+  init_itemlist_from_varlist (itp, all_array_variables);
+  return 1;
+#else
+  return 0;
+#endif
+}
+
+static int
+it_init_bindings (itp)
+     ITEMLIST *itp;
+{
+  char **blist;
+  STRINGLIST *sl;
+
+  /* rl_funmap_names allocates blist, but not its members */
+  blist = (char **)rl_funmap_names (); /* XXX fix const later */
+  sl = strlist_create (0);
+  sl->list = blist;
+  sl->list_size = 0;
+  sl->list_len = strvec_len (sl->list);
+  itp->flags |= LIST_DONTFREEMEMBERS;
+  itp->slist = sl;
+
+  return 0;
+}
+
+static int
+it_init_builtins (itp)
+     ITEMLIST *itp;
+{
+  STRINGLIST *sl;
+  register int i, n;
+
+  sl = strlist_create (num_shell_builtins);
+  for (i = n = 0; i < num_shell_builtins; i++)
+    if (shell_builtins[i].function)
+      sl->list[n++] = shell_builtins[i].name;
+  sl->list[sl->list_len = n] = (char *)NULL;
+  itp->flags |= LIST_DONTFREEMEMBERS;
+  itp->slist = sl;
+  return 0;
+}
+
+static int
+it_init_enabled (itp)
+     ITEMLIST *itp;
+{
+  STRINGLIST *sl;
+  register int i, n;
+
+  sl = strlist_create (num_shell_builtins);
+  for (i = n = 0; i < num_shell_builtins; i++)
+    {
+      if (shell_builtins[i].function && (shell_builtins[i].flags & BUILTIN_ENABLED))
+       sl->list[n++] = shell_builtins[i].name;
+    }
+  sl->list[sl->list_len = n] = (char *)NULL;
+  itp->flags |= LIST_DONTFREEMEMBERS;
+  itp->slist = sl;
+  return 0;
+}
+
+static int
+it_init_disabled (itp)
+     ITEMLIST *itp;
+{
+  STRINGLIST *sl;
+  register int i, n;
+
+  sl = strlist_create (num_shell_builtins);
+  for (i = n = 0; i < num_shell_builtins; i++)
+    {
+      if (shell_builtins[i].function && ((shell_builtins[i].flags & BUILTIN_ENABLED) == 0))
+       sl->list[n++] = shell_builtins[i].name;
+    }
+  sl->list[sl->list_len = n] = (char *)NULL;
+  itp->flags |= LIST_DONTFREEMEMBERS;
+  itp->slist = sl;
+  return 0;
+}
+
+static int
+it_init_exported (itp)
+     ITEMLIST *itp;
+{
+  init_itemlist_from_varlist (itp, all_exported_variables);
+  return 0;
+}
+
+static int
+it_init_functions (itp)
+     ITEMLIST *itp;
+{
+  init_itemlist_from_varlist (itp, all_visible_functions);
+  return 0;
+}
+
+static int
+it_init_hostnames (itp)
+     ITEMLIST *itp;
+{
+  STRINGLIST *sl;
+
+  sl = strlist_create (0);
+  sl->list = get_hostname_list ();
+  sl->list_len = sl->list ? strvec_len (sl->list) : 0;
+  sl->list_size = sl->list_len;
+  itp->slist = sl;
+  itp->flags |= LIST_DONTFREEMEMBERS|LIST_DONTFREE;
+  return 0;
+}
+
+static int
+it_init_joblist (itp, jstate)
+     ITEMLIST *itp;
+     int jstate;
+{
+#if defined (JOB_CONTROL)
+  STRINGLIST *sl;
+  register int i;
+  register PROCESS *p;
+  char *s, *t;
+  JOB *j;
+  JOB_STATE ws;                /* wanted state */
+
+  if (jstate == 0)
+    ws = JRUNNING;
+  else if (jstate == 1)
+    ws = JSTOPPED;
+
+  sl = strlist_create (js.j_jobslots);
+  for (i = js.j_jobslots - 1; i >= 0; i--)
+    {
+      j = get_job_by_jid (i);
+      if (j == 0)
+       continue;
+      p = j->pipe;
+      if (jstate == -1 || JOBSTATE(i) == ws)
+       {
+         s = savestring (p->command);
+         t = strpbrk (s, " \t\n");
+         if (t)
+           *t = '\0';
+         sl->list[sl->list_len++] = s;
+       }
+    }
+  itp->slist = sl;
+#else
+  itp->slist = (STRINGLIST *)NULL;
+#endif
+  return 0;
+}
+
+static int
+it_init_jobs (itp)
+     ITEMLIST *itp;
+{
+  return (it_init_joblist (itp, -1));
+}
+
+static int
+it_init_running (itp)
+     ITEMLIST *itp;
+{
+  return (it_init_joblist (itp, 0));
+}
+
+static int
+it_init_stopped (itp)
+     ITEMLIST *itp;
+{
+  return (it_init_joblist (itp, 1));
+}
+
+static int
+it_init_keywords (itp)
+     ITEMLIST *itp;
+{
+  STRINGLIST *sl;
+  register int i, n;
+
+  for (n = 0; word_token_alist[n].word; n++)
+    ;
+  sl = strlist_create (n);
+  for (i = 0; i < n; i++)
+    sl->list[i] = word_token_alist[i].word;
+  sl->list[sl->list_len = i] = (char *)NULL;
+  itp->flags |= LIST_DONTFREEMEMBERS;
+  itp->slist = sl;
+  return 0;
+}
+
+static int
+it_init_signals (itp)
+     ITEMLIST *itp;
+{
+  STRINGLIST *sl;
+
+  sl = strlist_create (0);
+  sl->list = signal_names;
+  sl->list_len = strvec_len (sl->list);
+  itp->flags |= LIST_DONTFREE;
+  itp->slist = sl;
+  return 0;
+}
+
+static int
+it_init_variables (itp)
+     ITEMLIST *itp;
+{
+  init_itemlist_from_varlist (itp, all_visible_variables);
+  return 0;
+}
+
+static int
+it_init_setopts (itp)
+     ITEMLIST *itp;
+{
+  STRINGLIST *sl;
+
+  sl = strlist_create (0);
+  sl->list = get_minus_o_opts ();
+  sl->list_len = strvec_len (sl->list);
+  itp->slist = sl;
+  itp->flags |= LIST_DONTFREEMEMBERS;
+  return 0;
+}
+
+static int
+it_init_shopts (itp)
+     ITEMLIST *itp;
+{
+  STRINGLIST *sl;
+
+  sl = strlist_create (0);
+  sl->list = get_shopt_options ();
+  sl->list_len = strvec_len (sl->list);
+  itp->slist = sl;
+  itp->flags |= LIST_DONTFREEMEMBERS;
+  return 0;
+}
+
+/* Generate a list of all matches for TEXT using the STRINGLIST in itp->slist
+   as the list of possibilities.  If the itemlist has been marked dirty or
+   it should be regenerated every time, destroy the old STRINGLIST and make a
+   new one before trying the match.  TEXT is dequoted before attempting a
+   match. */
+static STRINGLIST *
+gen_matches_from_itemlist (itp, text)
+     ITEMLIST *itp;
+     const char *text;
+{
+  STRINGLIST *ret, *sl;
+  int tlen, i, n;
+  char *ntxt;
+
+  if ((itp->flags & (LIST_DIRTY|LIST_DYNAMIC)) ||
+      (itp->flags & LIST_INITIALIZED) == 0)
+    {
+      if (itp->flags & (LIST_DIRTY | LIST_DYNAMIC))
+       clean_itemlist (itp);
+      if ((itp->flags & LIST_INITIALIZED) == 0)
+       initialize_itemlist (itp);
+    }
+  if (itp->slist == 0)
+    return ((STRINGLIST *)NULL);
+  ret = strlist_create (itp->slist->list_len+1);
+  sl = itp->slist;
+
+  ntxt = bash_dequote_text (text);
+  tlen = STRLEN (ntxt);
+
+  for (i = n = 0; i < sl->list_len; i++)
+    {
+      if (tlen == 0 || STREQN (sl->list[i], ntxt, tlen))
+       ret->list[n++] = STRDUP (sl->list[i]);
+    }
+  ret->list[ret->list_len = n] = (char *)NULL;
+
+  FREE (ntxt);
+  return ret;
+}
+
+/* A wrapper for rl_filename_completion_function that dequotes the filename
+   before attempting completions. */
+static char *
+pcomp_filename_completion_function (text, state)
+     const char *text;
+     int state;
+{
+  static char *dfn;    /* dequoted filename */
+  int qc;
+
+  if (state == 0)
+    {
+      FREE (dfn);
+      /* remove backslashes quoting special characters in filenames. */
+      if (rl_filename_dequoting_function)
+       {
+#if 0
+         qc = (text[0] == '"' || text[0] == '\'') ? text[0] : 0;
+#else
+         /* Use rl_completion_quote_character because any single or
+            double quotes have been removed by the time TEXT makes it
+            here, and we don't want to remove backslashes inside
+            quoted strings. */
+         qc = rl_dispatching ? rl_completion_quote_character : 0;
+#endif
+         dfn = (*rl_filename_dequoting_function) ((char *)text, qc);
+       }
+      else
+       dfn = savestring (text);
+    }
+
+  return (rl_filename_completion_function (dfn, state));
+}
+
+#define GEN_COMPS(bmap, flag, it, text, glist, tlist) \
+  do { \
+    if (bmap & flag) \
+      { \
+       tlist = gen_matches_from_itemlist (it, text); \
+       if (tlist) \
+         { \
+           glist = strlist_append (glist, tlist); \
+           strlist_dispose (tlist); \
+         } \
+      } \
+  } while (0)
+
+#define GEN_XCOMPS(bmap, flag, text, func, cmatches, glist, tlist) \
+  do { \
+    if (bmap & flag) \
+      { \
+       cmatches = rl_completion_matches (text, func); \
+       tlist = completions_to_stringlist (cmatches); \
+       glist = strlist_append (glist, tlist); \
+       strvec_dispose (cmatches); \
+       strlist_dispose (tlist); \
+      } \
+  } while (0)
+
+/* Functions to generate lists of matches from the actions member of CS. */
+
+static STRINGLIST *
+gen_action_completions (cs, text)
+     COMPSPEC *cs;
+     const char *text;
+{
+  STRINGLIST *ret, *tmatches;
+  char **cmatches;     /* from rl_completion_matches ... */
+  unsigned long flags;
+
+  ret = tmatches = (STRINGLIST *)NULL;
+  flags = cs->actions;
+
+  GEN_COMPS (flags, CA_ALIAS, &it_aliases, text, ret, tmatches);
+  GEN_COMPS (flags, CA_ARRAYVAR, &it_arrayvars, text, ret, tmatches);
+  GEN_COMPS (flags, CA_BINDING, &it_bindings, text, ret, tmatches);
+  GEN_COMPS (flags, CA_BUILTIN, &it_builtins, text, ret, tmatches);
+  GEN_COMPS (flags, CA_DISABLED, &it_disabled, text, ret, tmatches);
+  GEN_COMPS (flags, CA_ENABLED, &it_enabled, text, ret, tmatches);
+  GEN_COMPS (flags, CA_EXPORT, &it_exports, text, ret, tmatches);
+  GEN_COMPS (flags, CA_FUNCTION, &it_functions, text, ret, tmatches);
+  GEN_COMPS (flags, CA_HOSTNAME, &it_hostnames, text, ret, tmatches);
+  GEN_COMPS (flags, CA_JOB, &it_jobs, text, ret, tmatches);
+  GEN_COMPS (flags, CA_KEYWORD, &it_keywords, text, ret, tmatches);
+  GEN_COMPS (flags, CA_RUNNING, &it_running, text, ret, tmatches);
+  GEN_COMPS (flags, CA_SETOPT, &it_setopts, text, ret, tmatches);
+  GEN_COMPS (flags, CA_SHOPT, &it_shopts, text, ret, tmatches);
+  GEN_COMPS (flags, CA_SIGNAL, &it_signals, text, ret, tmatches);
+  GEN_COMPS (flags, CA_STOPPED, &it_stopped, text, ret, tmatches);
+  GEN_COMPS (flags, CA_VARIABLE, &it_variables, text, ret, tmatches);
+
+  GEN_XCOMPS(flags, CA_COMMAND, text, command_word_completion_function, cmatches, ret, tmatches);
+  GEN_XCOMPS(flags, CA_FILE, text, pcomp_filename_completion_function, cmatches, ret, tmatches);
+  GEN_XCOMPS(flags, CA_USER, text, rl_username_completion_function, cmatches, ret, tmatches);
+  GEN_XCOMPS(flags, CA_GROUP, text, bash_groupname_completion_function, cmatches, ret, tmatches);
+  GEN_XCOMPS(flags, CA_SERVICE, text, bash_servicename_completion_function, cmatches, ret, tmatches);
+
+  /* And lastly, the special case for directories */
+  if (flags & CA_DIRECTORY)
+    {
+      rl_completion_mark_symlink_dirs = 1;     /* override user preference */
+      cmatches = bash_directory_completion_matches (text);
+      tmatches = completions_to_stringlist (cmatches);
+      ret = strlist_append (ret, tmatches);
+      strvec_dispose (cmatches);
+      strlist_dispose (tmatches);
+    }
+
+  return ret;
+}
+
+/* Generate a list of matches for CS->globpat.  Unresolved: should this use
+   TEXT as a match prefix, or just go without?  Currently, the code does not
+   use TEXT, just globs CS->globpat and returns the results.  If we do decide
+   to use TEXT, we should call quote_string_for_globbing before the call to
+   glob_filename. */
+static STRINGLIST *
+gen_globpat_matches (cs, text)
+      COMPSPEC *cs;
+      const char *text;
+{
+  STRINGLIST *sl;
+
+  sl = strlist_create (0);
+  sl->list = glob_filename (cs->globpat, 0);
+  if (GLOB_FAILED (sl->list))
+    sl->list = (char **)NULL;
+  if (sl->list)
+    sl->list_len = sl->list_size = strvec_len (sl->list);
+  return sl;
+}
+
+/* Perform the shell word expansions on CS->words and return the results.
+   Again, this ignores TEXT. */
+static STRINGLIST *
+gen_wordlist_matches (cs, text)
+     COMPSPEC *cs;
+     const char *text;
+{
+  WORD_LIST *l, *l2;
+  STRINGLIST *sl;
+  int nw, tlen;
+  char *ntxt;          /* dequoted TEXT to use in comparisons */
+
+  if (cs->words == 0 || cs->words[0] == '\0')
+    return ((STRINGLIST *)NULL);
+
+  /* This used to be a simple expand_string(cs->words, 0), but that won't
+     do -- there's no way to split a simple list into individual words
+     that way, since the shell semantics say that word splitting is done
+     only on the results of expansion. */
+  l = split_at_delims (cs->words, strlen (cs->words), (char *)NULL, -1, (int *)NULL, (int *)NULL);
+  if (l == 0)
+    return ((STRINGLIST *)NULL);
+  /* This will jump back to the top level if the expansion fails... */
+  l2 = expand_words_shellexp (l);
+  dispose_words (l);
+
+  nw = list_length (l2);
+  sl = strlist_create (nw + 1);
+
+  ntxt = bash_dequote_text (text);
+  tlen = STRLEN (ntxt);
+
+  for (nw = 0, l = l2; l; l = l->next)
+    {
+      if (tlen == 0 || STREQN (l->word->word, ntxt, tlen))
+       sl->list[nw++] = STRDUP (l->word->word);
+    }
+  sl->list[sl->list_len = nw] = (char *)NULL;
+
+  dispose_words (l2);
+  FREE (ntxt);
+  return sl;
+}
+
+#ifdef ARRAY_VARS
+
+static SHELL_VAR *
+bind_comp_words (lwords)
+     WORD_LIST *lwords;
+{
+  SHELL_VAR *v;
+
+  v = find_variable ("COMP_WORDS");
+  if (v == 0)
+    v = make_new_array_variable ("COMP_WORDS");
+  if (readonly_p (v))
+    VUNSETATTR (v, att_readonly);
+  if (array_p (v) == 0)
+    v = convert_var_to_array (v);
+  v = assign_array_var_from_word_list (v, lwords, 0);
+
+  VUNSETATTR (v, att_invisible);
+  return v;
+}
+#endif /* ARRAY_VARS */
+
+static void
+bind_compfunc_variables (line, ind, lwords, cw, exported)
+     char *line;
+     int ind;
+     WORD_LIST *lwords;
+     int cw, exported;
+{
+  char ibuf[INT_STRLEN_BOUND(int) + 1];
+  char *value;
+  SHELL_VAR *v;
+
+  /* Set the variables that the function expects while it executes.  Maybe
+     these should be in the function environment (temporary_env). */
+  v = bind_variable ("COMP_LINE", line, 0);
+  if (v && exported)
+    VSETATTR(v, att_exported);
+
+  value = inttostr (ind, ibuf, sizeof(ibuf));
+  v = bind_int_variable ("COMP_POINT", value);
+  if (v && exported)
+    VSETATTR(v, att_exported);
+
+  value = inttostr (rl_completion_type, ibuf, sizeof (ibuf));
+  v = bind_int_variable ("COMP_TYPE", value);
+  if (v && exported)
+    VSETATTR(v, att_exported);
+
+  value = inttostr (rl_completion_invoking_key, ibuf, sizeof (ibuf));
+  v = bind_int_variable ("COMP_KEY", value);
+  if (v && exported)
+    VSETATTR(v, att_exported);
+
+  /* Since array variables can't be exported, we don't bother making the
+     array of words. */
+  if (exported == 0)
+    {
+#ifdef ARRAY_VARS
+      v = bind_comp_words (lwords);
+      value = inttostr (cw, ibuf, sizeof(ibuf));
+      bind_int_variable ("COMP_CWORD", value);
+#endif
+    }
+  else
+    array_needs_making = 1;
+}
+
+static void
+unbind_compfunc_variables (exported)
+     int exported;
+{
+  unbind_variable ("COMP_LINE");
+  unbind_variable ("COMP_POINT");
+  unbind_variable ("COMP_TYPE");
+#ifdef ARRAY_VARS
+  unbind_variable ("COMP_WORDS");
+  unbind_variable ("COMP_CWORD");
+#endif
+  if (exported)
+    array_needs_making = 1;
+}
+
+/* Build the list of words to pass to a function or external command
+   as arguments.  When the function or command is invoked,
+
+       $0 == function or command being invoked
+       $1 == command name
+       $2 = word to be completed (possibly null)
+       $3 = previous word
+
+   Functions can access all of the words in the current command line
+   with the COMP_WORDS array.  External commands cannot. */
+
+static WORD_LIST *
+build_arg_list (cmd, text, lwords, ind)
+     char *cmd;
+     const char *text;
+     WORD_LIST *lwords;
+     int ind;
+{
+  WORD_LIST *ret, *cl, *l;
+  WORD_DESC *w;
+  int i;
+
+  ret = (WORD_LIST *)NULL;
+  w = make_word (cmd);
+  ret = make_word_list (w, (WORD_LIST *)NULL);
+
+  w = (lwords && lwords->word) ? copy_word (lwords->word) : make_word ("");
+  cl = ret->next = make_word_list (w, (WORD_LIST *)NULL);
+
+  w = make_word (text);
+  cl->next = make_word_list (w, (WORD_LIST *)NULL);
+  cl = cl->next;
+
+  /* Search lwords for current word */
+  for (l = lwords, i = 1; l && i < ind-1; l = l->next, i++)
+    ;
+  w = (l && l->word) ? copy_word (l->word) : make_word ("");
+  cl->next = make_word_list (w, (WORD_LIST *)NULL);
+
+  return ret;
+}
+
+/* Build a command string with
+       $0 == cs->funcname      (function to execute for completion list)
+       $1 == command name      (command being completed)
+       $2 = word to be completed (possibly null)
+       $3 = previous word
+   and run in the current shell.  The function should put its completion
+   list into the array variable COMPREPLY.  We build a STRINGLIST
+   from the results and return it.
+
+   Since the shell function should return its list of matches in an array
+   variable, this does nothing if arrays are not compiled into the shell. */
+
+static STRINGLIST *
+gen_shell_function_matches (cs, text, line, ind, lwords, nw, cw)
+     COMPSPEC *cs;
+     const char *text;
+     char *line;
+     int ind;
+     WORD_LIST *lwords;
+     int nw, cw;
+{
+  char *funcname;
+  STRINGLIST *sl;
+  SHELL_VAR *f, *v;
+  WORD_LIST *cmdlist;
+  int fval;
+  sh_parser_state_t ps;
+#if defined (ARRAY_VARS)
+  ARRAY *a;
+#endif
+
+  funcname = cs->funcname;
+  f = find_function (funcname);
+  if (f == 0)
+    {
+      internal_error (_("completion: function `%s' not found"), funcname);
+      rl_ding ();
+      rl_on_new_line ();
+      return ((STRINGLIST *)NULL);
+    }
+
+#if !defined (ARRAY_VARS)
+  return ((STRINGLIST *)NULL);
+#else
+
+  /* We pass cw - 1 because command_line_to_word_list returns indices that are
+     1-based, while bash arrays are 0-based. */
+  bind_compfunc_variables (line, ind, lwords, cw - 1, 0);
+
+  cmdlist = build_arg_list (funcname, text, lwords, cw);
+
+  save_parser_state (&ps);  
+  fval = execute_shell_function (f, cmdlist);  
+  restore_parser_state (&ps);
+
+  /* Now clean up and destroy everything. */
+  dispose_words (cmdlist);
+  unbind_compfunc_variables (0);
+
+  /* The list of completions is returned in the array variable COMPREPLY. */
+  v = find_variable ("COMPREPLY");
+  if (v == 0)
+    return ((STRINGLIST *)NULL);
+  if (array_p (v) == 0)
+    v = convert_var_to_array (v);
+
+  VUNSETATTR (v, att_invisible);
+
+  a = array_cell (v);
+  if (a == 0 || array_empty (a))
+    sl = (STRINGLIST *)NULL;
+  else
+    {
+      /* XXX - should we filter the list of completions so only those matching
+        TEXT are returned?  Right now, we do not. */
+      sl = strlist_create (0);
+      sl->list = array_to_argv (a);
+      sl->list_len = sl->list_size = array_num_elements (a);
+    }
+
+  /* XXX - should we unbind COMPREPLY here? */
+  unbind_variable ("COMPREPLY");
+
+  return (sl);
+#endif
+}
+
+/* Build a command string with
+       $0 == cs->command       (command to execute for completion list)
+       $1 == command name      (command being completed)
+       $2 = word to be completed (possibly null)
+       $3 = previous word
+   and run in with command substitution.  Parse the results, one word
+   per line, with backslashes allowed to escape newlines.  Build a
+   STRINGLIST from the results and return it. */
+
+static STRINGLIST *
+gen_command_matches (cs, text, line, ind, lwords, nw, cw)
+     COMPSPEC *cs;
+     const char *text;
+     char *line;
+     int ind;
+     WORD_LIST *lwords;
+     int nw, cw;
+{
+  char *csbuf, *cscmd, *t;
+  int cmdlen, cmdsize, n, ws, we;
+  WORD_LIST *cmdlist, *cl;
+  STRINGLIST *sl;
+
+  bind_compfunc_variables (line, ind, lwords, cw, 1);
+  cmdlist = build_arg_list (cs->command, text, lwords, cw);
+
+  /* Estimate the size needed for the buffer. */
+  n = strlen (cs->command);
+  cmdsize = n + 1;
+  for (cl = cmdlist->next; cl; cl = cl->next)
+    cmdsize += STRLEN (cl->word->word) + 3;
+  cmdsize += 2;
+
+  /* allocate the string for the command and fill it in. */
+  cscmd = (char *)xmalloc (cmdsize + 1);
+
+  strcpy (cscmd, cs->command);                 /* $0 */
+  cmdlen = n;
+  cscmd[cmdlen++] = ' ';
+  for (cl = cmdlist->next; cl; cl = cl->next)   /* $1, $2, $3, ... */
+    {
+      t = sh_single_quote (cl->word->word ? cl->word->word : "");
+      n = strlen (t);
+      RESIZE_MALLOCED_BUFFER (cscmd, cmdlen, n + 2, cmdsize, 64);
+      strcpy (cscmd + cmdlen, t);
+      cmdlen += n;
+      if (cl->next)
+       cscmd[cmdlen++] = ' ';
+      free (t);
+    }
+  cscmd[cmdlen] = '\0';
+
+  csbuf = command_substitute (cscmd, 0);
+
+  /* Now clean up and destroy everything. */
+  dispose_words (cmdlist);
+  free (cscmd);
+  unbind_compfunc_variables (1);
+
+  if (csbuf == 0 || *csbuf == '\0')
+    {
+      FREE (csbuf);
+      return ((STRINGLIST *)NULL);
+    }
+
+  /* Now break CSBUF up at newlines, with backslash allowed to escape a
+     newline, and put the individual words into a STRINGLIST. */
+  sl = strlist_create (16);
+  for (ws = 0; csbuf[ws]; )
+    {
+      we = ws;
+      while (csbuf[we] && csbuf[we] != '\n')
+       {
+         if (csbuf[we] == '\\' && csbuf[we+1] == '\n')
+           we++;
+         we++;
+       }
+      t = substring (csbuf, ws, we);
+      if (sl->list_len >= sl->list_size - 1)
+       strlist_resize (sl, sl->list_size + 16);
+      sl->list[sl->list_len++] = t;
+      while (csbuf[we] == '\n') we++;
+      ws = we;
+    }
+  sl->list[sl->list_len] = (char *)NULL;
+
+  free (csbuf);
+  return (sl);
+}
+
+static WORD_LIST *
+command_line_to_word_list (line, llen, sentinel, nwp, cwp)
+     char *line;
+     int llen, sentinel, *nwp, *cwp;
+{
+  WORD_LIST *ret;
+  char *delims;
+
+  delims = "()<>;&| \t\n";     /* shell metacharacters break words */
+  ret = split_at_delims (line, llen, delims, sentinel, nwp, cwp);
+  return (ret);
+}
+
+/* Evaluate COMPSPEC *cs and return all matches for WORD. */
+
+STRINGLIST *
+gen_compspec_completions (cs, cmd, word, start, end)
+     COMPSPEC *cs;
+     const char *cmd;
+     const char *word;
+     int start, end;
+{
+  STRINGLIST *ret, *tmatches;
+  char *line;
+  int llen, nw, cw;
+  WORD_LIST *lwords;
+  COMPSPEC *tcs;
+
+#ifdef DEBUG
+  debug_printf ("gen_compspec_completions (%s, %s, %d, %d)", cmd, word, start, end);
+  debug_printf ("gen_compspec_completions: %s -> %p", cmd, cs);
+#endif
+  ret = gen_action_completions (cs, word);
+#ifdef DEBUG
+  if (ret && progcomp_debug)
+    {
+      debug_printf ("gen_action_completions (%p, %s) -->", cs, word);
+      strlist_print (ret, "\t");
+      rl_on_new_line ();
+    }
+#endif
+
+  /* Now we start generating completions based on the other members of CS. */
+  if (cs->globpat)
+    {
+      tmatches = gen_globpat_matches (cs, word);
+      if (tmatches)
+       {
+#ifdef DEBUG
+         if (progcomp_debug)
+           {
+             debug_printf ("gen_globpat_matches (%p, %s) -->", cs, word);
+             strlist_print (tmatches, "\t");
+             rl_on_new_line ();
+           }
+#endif
+         ret = strlist_append (ret, tmatches);
+         strlist_dispose (tmatches);
+         rl_filename_completion_desired = 1;
+       }
+    }
+
+  if (cs->words)
+    {
+      tmatches = gen_wordlist_matches (cs, word);
+      if (tmatches)
+       {
+#ifdef DEBUG
+         if (progcomp_debug)
+           {
+             debug_printf ("gen_wordlist_matches (%p, %s) -->", cs, word);
+             strlist_print (tmatches, "\t");
+             rl_on_new_line ();
+           }
+#endif
+         ret = strlist_append (ret, tmatches);
+         strlist_dispose (tmatches);
+       }
+    }
+
+  lwords = (WORD_LIST *)NULL;
+  line = (char *)NULL;
+  if (cs->command || cs->funcname)
+    {
+      /* If we have a command or function to execute, we need to first break
+        the command line into individual words, find the number of words,
+        and find the word in the list containing the word to be completed. */
+      line = substring (rl_line_buffer, start, end);
+      llen = end - start;
+
+#ifdef DEBUG
+      debug_printf ("command_line_to_word_list (%s, %d, %d, %p, %p)",
+               line, llen, rl_point - start, &nw, &cw);
+#endif
+      lwords = command_line_to_word_list (line, llen, rl_point - start, &nw, &cw);
+#ifdef DEBUG
+      if (lwords == 0 && llen > 0)
+       debug_printf ("ERROR: command_line_to_word_list returns NULL");
+      else if (progcomp_debug)
+       {
+         debug_printf ("command_line_to_word_list -->");
+         printf ("\t");
+         print_word_list (lwords, "!");
+         printf ("\n");
+         fflush(stdout);
+         rl_on_new_line ();
+       }
+#endif
+    }
+
+  if (cs->funcname)
+    {
+      tmatches = gen_shell_function_matches (cs, word, line, rl_point - start, lwords, nw, cw);
+      if (tmatches)
+       {
+#ifdef DEBUG
+         if (progcomp_debug)
+           {
+             debug_printf ("gen_shell_function_matches (%p, %s, %p, %d, %d) -->", cs, word, lwords, nw, cw);
+             strlist_print (tmatches, "\t");
+             rl_on_new_line ();
+           }
+#endif
+         ret = strlist_append (ret, tmatches);
+         strlist_dispose (tmatches);
+       }
+    }
+
+  if (cs->command)
+    {
+      tmatches = gen_command_matches (cs, word, line, rl_point - start, lwords, nw, cw);
+      if (tmatches)
+       {
+#ifdef DEBUG
+         if (progcomp_debug)
+           {
+             debug_printf ("gen_command_matches (%p, %s, %p, %d, %d) -->", cs, word, lwords, nw, cw);
+             strlist_print (tmatches, "\t");
+             rl_on_new_line ();
+           }
+#endif
+         ret = strlist_append (ret, tmatches);
+         strlist_dispose (tmatches);
+       }
+    }
+
+  if (cs->command || cs->funcname)
+    {
+      if (lwords)
+       dispose_words (lwords);
+      FREE (line);
+    }
+
+  if (cs->filterpat)
+    {
+      tmatches = filter_stringlist (ret, cs->filterpat, word);
+#ifdef DEBUG
+      if (progcomp_debug)
+       {
+         debug_printf ("filter_stringlist (%p, %s, %s) -->", ret, cs->filterpat, word);
+         strlist_print (tmatches, "\t");
+         rl_on_new_line ();
+       }
+#endif
+      if (ret && ret != tmatches)
+       {
+         FREE (ret->list);
+         free (ret);
+       }
+      ret = tmatches;
+    }
+
+  if (cs->prefix || cs->suffix)
+    ret = strlist_prefix_suffix (ret, cs->prefix, cs->suffix);
+
+  /* If no matches have been generated and the user has specified that
+      directory completion should be done as a default, call
+      gen_action_completions again to generate a list of matching directory
+      names. */
+  if ((ret == 0 || ret->list_len == 0) && (cs->options & COPT_DIRNAMES))
+    {
+      tcs = compspec_create ();
+      tcs->actions = CA_DIRECTORY;
+      ret = gen_action_completions (tcs, word);
+      compspec_dispose (tcs);
+    }
+  else if (cs->options & COPT_PLUSDIRS)
+    {
+      tcs = compspec_create ();
+      tcs->actions = CA_DIRECTORY;
+      tmatches = gen_action_completions (tcs, word);
+      ret = strlist_append (ret, tmatches);
+      strlist_dispose (tmatches);
+      compspec_dispose (tcs);
+    }
+
+  return (ret);
+}
+
+/* The driver function for the programmable completion code.  Returns a list
+   of matches for WORD, which is an argument to command CMD.  START and END
+   bound the command currently being completed in rl_line_buffer. */
+char **
+programmable_completions (cmd, word, start, end, foundp)
+     const char *cmd;
+     const char *word;
+     int start, end, *foundp;
+{
+  COMPSPEC *cs;
+  STRINGLIST *ret;
+  char **rmatches, *t;
+
+  /* We look at the basename of CMD if the full command does not have
+     an associated COMPSPEC. */
+  cs = progcomp_search (cmd);
+  if (cs == 0)
+    {
+      t = strrchr (cmd, '/');
+      if (t)
+       cs = progcomp_search (++t);
+    }
+  if (cs == 0)
+    {
+      if (foundp)
+       *foundp = 0;
+      return ((char **)NULL);
+    }
+
+  cs = compspec_copy (cs);
+
+  /* Signal the caller that we found a COMPSPEC for this command, and pass
+     back any meta-options associated with the compspec. */
+  if (foundp)
+    *foundp = 1|cs->options;
+
+  ret = gen_compspec_completions (cs, cmd, word, start, end);
+
+  compspec_dispose (cs);
+
+  if (ret)
+    {
+      rmatches = ret->list;
+      free (ret);
+    }
+  else
+    rmatches = (char **)NULL;
+
+  return (rmatches);
+}
+
+#endif /* PROGRAMMABLE_COMPLETION */
diff --git a/redir.c b/redir.c
index 0bd2d5f51355d5f39d27a3e61f53c437e1ae9920..acde46f4a3a3b84607c0b3233a501c0adee83f87 100644 (file)
--- a/redir.c
+++ b/redir.c
@@ -375,7 +375,7 @@ here_document_to_fd (redirectee, ri)
   char *filename;
   int r, fd, fd2;
 
-  fd = sh_mktmpfd ("sh-thd", MT_USERANDOM, &filename);
+  fd = sh_mktmpfd ("sh-thd", MT_USERANDOM|MT_USETMPDIR, &filename);
 
   /* If we failed for some reason other than the file existing, abort */
   if (fd < 0)
diff --git a/redir.c~ b/redir.c~
new file mode 100644 (file)
index 0000000..0bd2d5f
--- /dev/null
+++ b/redir.c~
@@ -0,0 +1,1086 @@
+/* redir.c -- Functions to perform input and output redirection. */
+
+/* Copyright (C) 1997-2005 Free Software Foundation, Inc.
+
+   This file is part of GNU Bash, the Bourne Again SHell.
+
+   Bash is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   Bash is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+   License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with Bash; see the file COPYING.  If not, write to the Free
+   Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+#include "config.h"
+
+#if !defined (__GNUC__) && !defined (HAVE_ALLOCA_H) && defined (_AIX)
+  #pragma alloca
+#endif /* _AIX && RISC6000 && !__GNUC__ */
+
+#include <stdio.h>
+#include "bashtypes.h"
+#if !defined (_MINIX) && defined (HAVE_SYS_FILE_H)
+#  include <sys/file.h>
+#endif
+#include "filecntl.h"
+#include "posixstat.h"
+
+#if defined (HAVE_UNISTD_H)
+#  include <unistd.h>
+#endif
+
+#include <errno.h>
+
+#if !defined (errno)
+extern int errno;
+#endif
+
+#include "bashansi.h"
+#include "bashintl.h"
+
+#include "memalloc.h"
+#include "shell.h"
+#include "flags.h"
+#include "execute_cmd.h"
+#include "redir.h"
+
+#if defined (BUFFERED_INPUT)
+#  include "input.h"
+#endif
+
+int expanding_redir;
+
+extern int posixly_correct;
+extern REDIRECT *redirection_undo_list;
+extern REDIRECT *exec_redirection_undo_list;
+
+/* Static functions defined and used in this file. */
+static void add_undo_close_redirect __P((int));
+static void add_exec_redirect __P((REDIRECT *));
+static int add_undo_redirect __P((int, enum r_instruction));
+static int expandable_redirection_filename __P((REDIRECT *));
+static int stdin_redirection __P((enum r_instruction, int));
+static int do_redirection_internal __P((REDIRECT *, int));
+
+static int write_here_document __P((int, WORD_DESC *));
+static int write_here_string __P((int, WORD_DESC *));
+static int here_document_to_fd __P((WORD_DESC *, enum r_instruction));
+
+static int redir_special_open __P((int, char *, int, int, enum r_instruction));
+static int noclobber_open __P((char *, int, int, enum r_instruction));
+static int redir_open __P((char *, int, int, enum r_instruction));
+
+/* 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;
+
+void
+redirection_error (temp, error)
+     REDIRECT *temp;
+     int error;
+{
+  char *filename, *allocname;
+  int oflags;
+
+  allocname = 0;
+  if (temp->redirector < 0)
+    /* This can happen when read_token_word encounters overflow, like in
+       exec 4294967297>x */
+    filename = _("file descriptor out of range");
+#ifdef EBADF
+  else if (temp->redirector >= 0 && errno == EBADF)
+    {
+      /* If we're dealing with two file descriptors, we have to guess about
+         which one is invalid; in the cases of r_{duplicating,move}_input and
+         r_{duplicating,move}_output we're here because dup2() failed. */
+      switch (temp->instruction)
+        {
+        case r_duplicating_input:
+        case r_duplicating_output:
+        case r_move_input:
+        case r_move_output:
+         filename = allocname = itos (temp->redirectee.dest);
+         break;
+       default:
+         filename = allocname = itos (temp->redirector);
+         break;
+        }
+    }
+#endif
+  else if (expandable_redirection_filename (temp))
+    {
+      if (posixly_correct && interactive_shell == 0)
+       {
+         oflags = temp->redirectee.filename->flags;
+         temp->redirectee.filename->flags |= W_NOGLOB;
+       }
+      filename = allocname = redirection_expand (temp->redirectee.filename);
+      if (posixly_correct && interactive_shell == 0)
+       temp->redirectee.filename->flags = oflags;
+      if (filename == 0)
+       filename = temp->redirectee.filename->word;
+    }
+  else if (temp->redirectee.dest < 0)
+    filename = "file descriptor out of range";
+  else
+    filename = allocname = itos (temp->redirectee.dest);
+
+  switch (error)
+    {
+    case AMBIGUOUS_REDIRECT:
+      internal_error (_("%s: ambiguous redirect"), filename);
+      break;
+
+    case NOCLOBBER_REDIRECT:
+      internal_error (_("%s: cannot overwrite existing file"), filename);
+      break;
+
+#if defined (RESTRICTED_SHELL)
+    case RESTRICTED_REDIRECT:
+      internal_error (_("%s: restricted: cannot redirect output"), filename);
+      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;
+    }
+
+  FREE (allocname);
+}
+
+/* Perform the redirections on LIST.  If flags & RX_ACTIVE, then actually
+   make input and output file descriptors, otherwise just do whatever is
+   neccessary for side effecting.  flags & RX_UNDOABLE says to remember
+   how to undo the redirections later, if non-zero.  If flags & RX_CLEXEC
+   is non-zero, file descriptors opened in do_redirection () have their
+   close-on-exec flag set. */
+int
+do_redirections (list, flags)
+     REDIRECT *list;
+     int flags;
+{
+  int error;
+  REDIRECT *temp;
+
+  if (flags & RX_UNDOABLE)
+    {
+      if (redirection_undo_list)
+       {
+         dispose_redirects (redirection_undo_list);
+         redirection_undo_list = (REDIRECT *)NULL;
+       }
+      if (exec_redirection_undo_list)
+       dispose_exec_redirects ();
+    }
+
+  for (temp = list; temp; temp = temp->next)
+    {
+      error = do_redirection_internal (temp, flags);
+      if (error)
+       {
+         redirection_error (temp, error);
+         return (error);
+       }
+    }
+  return (0);
+}
+
+/* Return non-zero if the redirection pointed to by REDIRECT has a
+   redirectee.filename that can be expanded. */
+static int
+expandable_redirection_filename (redirect)
+     REDIRECT *redirect;
+{
+  switch (redirect->instruction)
+    {
+    case r_output_direction:
+    case r_appending_to:
+    case r_input_direction:
+    case r_inputa_direction:
+    case r_err_and_out:
+    case r_input_output:
+    case r_output_force:
+    case r_duplicating_input_word:
+    case r_duplicating_output_word:
+    case r_move_input_word:
+    case r_move_output_word:
+      return 1;
+
+    default:
+      return 0;
+    }
+}
+
+/* Expand the word in WORD returning a string.  If WORD expands to
+   multiple words (or no words), then return NULL. */
+char *
+redirection_expand (word)
+     WORD_DESC *word;
+{
+  char *result;
+  WORD_LIST *tlist1, *tlist2;
+  WORD_DESC *w;
+
+  w = copy_word (word);
+  if (posixly_correct)
+    w->flags |= W_NOSPLIT;
+
+  tlist1 = make_word_list (w, (WORD_LIST *)NULL);
+  expanding_redir = 1;
+  tlist2 = expand_words_no_vars (tlist1);
+  expanding_redir = 0;
+  dispose_words (tlist1);
+
+  if (!tlist2 || tlist2->next)
+    {
+      /* We expanded to no words, or to more than a single word.
+        Dispose of the word list and return NULL. */
+      if (tlist2)
+       dispose_words (tlist2);
+      return ((char *)NULL);
+    }
+  result = string_list (tlist2);  /* XXX savestring (tlist2->word->word)? */
+  dispose_words (tlist2);
+  return (result);
+}
+
+static int
+write_here_string (fd, redirectee)
+     int fd;
+     WORD_DESC *redirectee;
+{
+  char *herestr;
+  int herelen, n, e;
+
+  herestr = expand_string_to_string (redirectee->word, 0);
+  herelen = STRLEN (herestr);
+
+  n = write (fd, herestr, herelen);
+  if (n == herelen)
+    {
+      n = write (fd, "\n", 1);
+      herelen = 1;
+    }
+  e = errno;
+  FREE (herestr);
+  if (n != herelen)
+    {
+      if (e == 0)
+       e = ENOSPC;
+      return e;
+    }
+  return 0;
+}  
+
+/* 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;
+     WORD_DESC *redirectee;
+{
+  char *document;
+  int document_len, fd2;
+  FILE *fp;
+  register WORD_LIST *t, *tlist;
+
+  /* Expand the text if the word that was specified had
+     no quoting.  The text that we expand is treated
+     exactly as if it were surrounded by double quotes. */
+
+  if (redirectee->flags & W_QUOTED)
+    {
+      document = redirectee->word;
+      document_len = strlen (document);
+      /* Set errno to something reasonable if the write fails. */
+      if (write (fd, document, document_len) < document_len)
+       {
+         if (errno == 0)
+           errno = ENOSPC;
+         return (errno);
+       }
+      else
+       return 0;
+    }
+
+  tlist = expand_string (redirectee->word, Q_HERE_DOCUMENT);
+  if (tlist)
+    {
+      /* Try using buffered I/O (stdio) and writing a word
+        at a time, letting stdio do the work of buffering
+        for us rather than managing our own strings.  Most
+        stdios are not particularly fast, however -- this
+        may need to be reconsidered later. */
+      if ((fd2 = dup (fd)) < 0 || (fp = fdopen (fd2, "w")) == NULL)
+       {
+         if (fd2 >= 0)
+           close (fd2);
+         return (errno);
+       }
+      errno = 0;
+      for (t = tlist; t; t = t->next)
+       {
+         /* This is essentially the body of
+            string_list_internal expanded inline. */
+         document = t->word->word;
+         document_len = strlen (document);
+         if (t != tlist)
+           putc (' ', fp);     /* separator */
+         fwrite (document, document_len, 1, fp);
+         if (ferror (fp))
+           {
+             if (errno == 0)
+               errno = ENOSPC;
+             fd2 = errno;
+             fclose(fp);
+             dispose_words (tlist);
+             return (fd2);
+           }
+       }
+      dispose_words (tlist);
+      if (fclose (fp) != 0)
+       {
+         if (errno == 0)
+           errno = ENOSPC;
+         return (errno);
+       }
+    }
+  return 0;
+}
+
+/* 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, ri)
+     WORD_DESC *redirectee;
+     enum r_instruction ri;
+{
+  char *filename;
+  int r, fd, fd2;
+
+  fd = sh_mktmpfd ("sh-thd", MT_USERANDOM, &filename);
+
+  /* If we failed for some reason other than the file existing, abort */
+  if (fd < 0)
+    {
+      FREE (filename);
+      return (fd);
+    }
+
+  errno = r = 0;               /* XXX */
+  /* write_here_document returns 0 on success, errno on failure. */
+  if (redirectee->word)
+    r = (ri != r_reading_string) ? write_here_document (fd, redirectee)
+                                : write_here_string (fd, redirectee);
+
+  if (r)
+    {
+      close (fd);
+      unlink (filename);
+      free (filename);
+      errno = r;
+      return (-1);
+    }
+
+  /* In an attempt to avoid races, we close the first fd only after opening
+     the second. */
+  /* Make the document really temporary.  Also make it the input. */
+  fd2 = open (filename, O_RDONLY, 0600);
+
+  if (fd2 < 0)
+    {
+      r = errno;
+      unlink (filename);
+      free (filename);
+      close (fd);
+      errno = r;
+      return -1;
+    }
+
+  close (fd);
+  if (unlink (filename) < 0)
+    {
+      r = errno;
+#if defined (__CYGWIN__)
+      /* Under CygWin 1.1.0, the unlink will fail if the file is
+        open. This hack will allow the previous action of silently
+        ignoring the error, but will still leave the file there. This
+        needs some kind of magic. */
+      if (r == EACCES)
+       return (fd2);
+#endif /* __CYGWIN__ */
+      close (fd2);
+      free (filename);
+      errno = r;
+      return (-1);
+    }
+
+  free (filename);
+  return (fd2);
+}
+
+#define RF_DEVFD       1
+#define RF_DEVSTDERR   2
+#define RF_DEVSTDIN    3
+#define RF_DEVSTDOUT   4
+#define RF_DEVTCP      5
+#define RF_DEVUDP      6
+
+/* A list of pattern/value pairs for filenames that the redirection
+   code handles specially. */
+static STRING_INT_ALIST _redir_special_filenames[] = {
+#if !defined (HAVE_DEV_FD)
+  { "/dev/fd/[0-9]*", RF_DEVFD },
+#endif
+#if !defined (HAVE_DEV_STDIN)
+  { "/dev/stderr", RF_DEVSTDERR },
+  { "/dev/stdin", RF_DEVSTDIN },
+  { "/dev/stdout", RF_DEVSTDOUT },
+#endif
+#if defined (NETWORK_REDIRECTIONS)
+  { "/dev/tcp/*/*", RF_DEVTCP },
+  { "/dev/udp/*/*", RF_DEVUDP },
+#endif
+  { (char *)NULL, -1 }
+};
+
+static int
+redir_special_open (spec, filename, flags, mode, ri)
+     int spec;
+     char *filename;
+     int flags, mode;
+     enum r_instruction ri;
+{
+  int fd;
+#if !defined (HAVE_DEV_FD)
+  intmax_t lfd;
+#endif
+
+  fd = -1;
+  switch (spec)
+    {
+#if !defined (HAVE_DEV_FD)
+    case RF_DEVFD:
+      if (all_digits (filename+8) && legal_number (filename+8, &lfd) && lfd == (int)lfd)
+       {
+         fd = lfd;
+         fd = fcntl (fd, F_DUPFD, 10);
+       }
+      else
+       fd = AMBIGUOUS_REDIRECT;
+      break;
+#endif
+
+#if !defined (HAVE_DEV_STDIN)
+    case RF_DEVSTDIN:
+      fd = fcntl (0, F_DUPFD, 10);
+      break;
+    case RF_DEVSTDOUT:
+      fd = fcntl (1, F_DUPFD, 10);
+      break;
+    case RF_DEVSTDERR:
+      fd = fcntl (2, F_DUPFD, 10);
+      break;
+#endif
+
+#if defined (NETWORK_REDIRECTIONS)
+    case RF_DEVTCP:
+    case RF_DEVUDP:
+#if defined (HAVE_NETWORK)
+      fd = netopen (filename);
+#else
+      internal_warning (_("/dev/(tcp|udp)/host/port not supported without networking"));
+      fd = open (filename, flags, mode);
+#endif
+      break;
+#endif /* NETWORK_REDIRECTIONS */
+    }
+
+  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, mode, ri)
+     char *filename;
+     int flags, mode;
+     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, mode);
+      return ((fd < 0 && errno == EEXIST) ? NOCLOBBER_REDIRECT : fd);
+    }
+  fd = open (filename, flags, mode);
+
+  /* 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);
+}
+
+static int
+redir_open (filename, flags, mode, ri)
+     char *filename;
+     int flags, mode;
+     enum r_instruction ri;
+{
+  int fd, r;
+
+  r = find_string_in_alist (filename, _redir_special_filenames, 1);
+  if (r >= 0)
+    return (redir_special_open (r, filename, flags, mode, ri));
+
+  /* If we are in noclobber mode, you are not allowed to overwrite
+     existing files.  Check before opening. */
+  if (noclobber && CLOBBERING_REDIRECT (ri))
+    {
+      fd = noclobber_open (filename, flags, mode, ri);
+      if (fd == NOCLOBBER_REDIRECT)
+       return (NOCLOBBER_REDIRECT);
+    }
+  else
+    {
+      fd = open (filename, flags, mode);
+#if defined (AFS)
+      if ((fd < 0) && (errno == EACCES))
+       {
+         fd = open (filename, flags & ~O_CREAT, mode);
+         errno = EACCES;       /* restore errno */
+       }
+#endif /* AFS */
+    }
+
+  return fd;
+}
+
+/* Do the specific redirection requested.  Returns errno or one of the
+   special redirection errors (*_REDIRECT) in case of error, 0 on success.
+   If flags & RX_ACTIVE is zero, then just do whatever is neccessary to
+   produce the appropriate side effects.   flags & RX_UNDOABLE, if non-zero,
+   says to remember how to undo each redirection.  If flags & RX_CLEXEC is
+   non-zero, then we set all file descriptors > 2 that we open to be
+   close-on-exec.  */
+static int
+do_redirection_internal (redirect, flags)
+     REDIRECT *redirect;
+     int flags;
+{
+  WORD_DESC *redirectee;
+  int redir_fd, fd, redirector, r, oflags;
+  intmax_t lfd;
+  char *redirectee_word;
+  enum r_instruction ri;
+  REDIRECT *new_redirect;
+
+  redirectee = redirect->redirectee.filename;
+  redir_fd = redirect->redirectee.dest;
+  redirector = redirect->redirector;
+  ri = redirect->instruction;
+
+  if (redirect->flags & RX_INTERNAL)
+    flags |= RX_INTERNAL;
+
+  if (TRANSLATE_REDIRECT (ri))
+    {
+      /* We have [N]>&WORD[-] or [N]<&WORD[-].  Expand WORD, then translate
+        the redirection into a new one and continue. */
+      redirectee_word = redirection_expand (redirectee);
+
+      /* XXX - what to do with [N]<&$w- where w is unset or null?  ksh93
+              closes N. */
+      if (redirectee_word == 0)
+       return (AMBIGUOUS_REDIRECT);
+      else if (redirectee_word[0] == '-' && redirectee_word[1] == '\0')
+       {
+         rd.dest = 0;
+         new_redirect = make_redirection (redirector, r_close_this, rd);
+       }
+      else if (all_digits (redirectee_word))
+       {
+         if (legal_number (redirectee_word, &lfd) && (int)lfd == lfd)
+           rd.dest = lfd;
+         else
+           rd.dest = -1;       /* XXX */
+         switch (ri)
+           {
+           case r_duplicating_input_word:
+             new_redirect = make_redirection (redirector, r_duplicating_input, rd);
+             break;
+           case r_duplicating_output_word:
+             new_redirect = make_redirection (redirector, r_duplicating_output, rd);
+             break;
+           case r_move_input_word:
+             new_redirect = make_redirection (redirector, r_move_input, rd);
+             break;
+           case r_move_output_word:
+             new_redirect = make_redirection (redirector, r_move_output, rd);
+             break;
+           }
+       }
+      else if (ri == r_duplicating_output_word && redirector == 1)
+       {
+         rd.filename = make_bare_word (redirectee_word);
+         new_redirect = make_redirection (1, r_err_and_out, rd);
+       }
+      else
+       {
+         free (redirectee_word);
+         return (AMBIGUOUS_REDIRECT);
+       }
+
+      free (redirectee_word);
+
+      /* Set up the variables needed by the rest of the function from the
+        new redirection. */
+      if (new_redirect->instruction == r_err_and_out)
+       {
+         char *alloca_hack;
+
+         /* Copy the word without allocating any memory that must be
+            explicitly freed. */
+         redirectee = (WORD_DESC *)alloca (sizeof (WORD_DESC));
+         xbcopy ((char *)new_redirect->redirectee.filename,
+                (char *)redirectee, sizeof (WORD_DESC));
+
+         alloca_hack = (char *)
+           alloca (1 + strlen (new_redirect->redirectee.filename->word));
+         redirectee->word = alloca_hack;
+         strcpy (redirectee->word, new_redirect->redirectee.filename->word);
+       }
+      else
+       /* It's guaranteed to be an integer, and shouldn't be freed. */
+       redirectee = new_redirect->redirectee.filename;
+
+      redir_fd = new_redirect->redirectee.dest;
+      redirector = new_redirect->redirector;
+      ri = new_redirect->instruction;
+
+      /* Overwrite the flags element of the old redirect with the new value. */
+      redirect->flags = new_redirect->flags;
+      dispose_redirects (new_redirect);
+    }
+
+  switch (ri)
+    {
+    case r_output_direction:
+    case r_appending_to:
+    case r_input_direction:
+    case r_inputa_direction:
+    case r_err_and_out:                /* command &>filename */
+    case r_input_output:
+    case r_output_force:
+      if (posixly_correct && interactive_shell == 0)
+       {
+         oflags = redirectee->flags;
+         redirectee->flags |= W_NOGLOB;
+       }
+      redirectee_word = redirection_expand (redirectee);
+      if (posixly_correct && interactive_shell == 0)
+       redirectee->flags = oflags;
+
+      if (redirectee_word == 0)
+       return (AMBIGUOUS_REDIRECT);
+
+#if defined (RESTRICTED_SHELL)
+      if (restricted && (WRITE_REDIRECT (ri)))
+       {
+         free (redirectee_word);
+         return (RESTRICTED_REDIRECT);
+       }
+#endif /* RESTRICTED_SHELL */
+
+      fd = redir_open (redirectee_word, redirect->flags, 0666, ri);
+      free (redirectee_word);
+
+      if (fd == NOCLOBBER_REDIRECT)
+       return (fd);
+
+      if (fd < 0)
+       return (errno);
+
+      if (flags & RX_ACTIVE)
+       {
+         if (flags & RX_UNDOABLE)
+           {
+             /* Only setup to undo it if the thing to undo is active. */
+             if ((fd != redirector) && (fcntl (redirector, F_GETFD, 0) != -1))
+               add_undo_redirect (redirector, ri);
+             else
+               add_undo_close_redirect (redirector);
+           }
+
+#if defined (BUFFERED_INPUT)
+         check_bash_input (redirector);
+#endif
+
+         if ((fd != redirector) && (dup2 (fd, redirector) < 0))
+           return (errno);
+
+#if defined (BUFFERED_INPUT)
+         /* Do not change the buffered stream for an implicit redirection
+            of /dev/null to fd 0 for asynchronous commands without job
+            control (r_inputa_direction). */
+         if (ri == r_input_direction || ri == r_input_output)
+           duplicate_buffered_stream (fd, redirector);
+#endif /* BUFFERED_INPUT */
+
+         /*
+          * If we're remembering, then this is the result of a while, for
+          * or until loop with a loop redirection, or a function/builtin
+          * executing in the parent shell with a redirection.  In the
+          * function/builtin case, we want to set all file descriptors > 2
+          * to be close-on-exec to duplicate the effect of the old
+          * for i = 3 to NOFILE close(i) loop.  In the case of the loops,
+          * both sh and ksh leave the file descriptors open across execs.
+          * The Posix standard mentions only the exec builtin.
+          */
+         if ((flags & RX_CLEXEC) && (redirector > 2))
+           SET_CLOSE_ON_EXEC (redirector);
+       }
+
+      if (fd != redirector)
+       {
+#if defined (BUFFERED_INPUT)
+         if (INPUT_REDIRECT (ri))
+           close_buffered_fd (fd);
+         else
+#endif /* !BUFFERED_INPUT */
+           close (fd);         /* Don't close what we just opened! */
+       }
+
+      /* If we are hacking both stdout and stderr, do the stderr
+        redirection here. */
+      if (ri == r_err_and_out)
+       {
+         if (flags & RX_ACTIVE)
+           {
+             if (flags & RX_UNDOABLE)
+               add_undo_redirect (2, ri);
+             if (dup2 (1, 2) < 0)
+               return (errno);
+           }
+       }
+      break;
+
+    case r_reading_until:
+    case r_deblank_reading_until:
+    case r_reading_string:
+      /* REDIRECTEE is a pointer to a WORD_DESC containing the text of
+        the new input.  Place it in a temporary file. */
+      if (redirectee)
+       {
+         fd = here_document_to_fd (redirectee, ri);
+
+         if (fd < 0)
+           {
+             heredoc_errno = errno;
+             return (HEREDOC_REDIRECT);
+           }
+
+         if (flags & RX_ACTIVE)
+           {
+             if (flags & RX_UNDOABLE)
+               {
+                 /* Only setup to undo it if the thing to undo is active. */
+                 if ((fd != redirector) && (fcntl (redirector, F_GETFD, 0) != -1))
+                   add_undo_redirect (redirector, ri);
+                 else
+                   add_undo_close_redirect (redirector);
+               }
+
+#if defined (BUFFERED_INPUT)
+             check_bash_input (redirector);
+#endif
+             if (fd != redirector && dup2 (fd, redirector) < 0)
+               {
+                 r = errno;
+                 close (fd);
+                 return (r);
+               }
+
+#if defined (BUFFERED_INPUT)
+             duplicate_buffered_stream (fd, redirector);
+#endif
+
+             if ((flags & RX_CLEXEC) && (redirector > 2))
+               SET_CLOSE_ON_EXEC (redirector);
+           }
+
+         if (fd != redirector)
+#if defined (BUFFERED_INPUT)
+           close_buffered_fd (fd);
+#else
+           close (fd);
+#endif
+       }
+      break;
+
+    case r_duplicating_input:
+    case r_duplicating_output:
+    case r_move_input:
+    case r_move_output:
+      if ((flags & RX_ACTIVE) && (redir_fd != redirector))
+       {
+         if (flags & RX_UNDOABLE)
+           {
+             /* Only setup to undo it if the thing to undo is active. */
+             if (fcntl (redirector, F_GETFD, 0) != -1)
+               add_undo_redirect (redirector, ri);
+             else
+               add_undo_close_redirect (redirector);
+           }
+
+#if defined (BUFFERED_INPUT)
+         check_bash_input (redirector);
+#endif
+         /* This is correct.  2>&1 means dup2 (1, 2); */
+         if (dup2 (redir_fd, redirector) < 0)
+           return (errno);
+
+#if defined (BUFFERED_INPUT)
+         if (ri == r_duplicating_input || ri == r_move_input)
+           duplicate_buffered_stream (redir_fd, redirector);
+#endif /* BUFFERED_INPUT */
+
+         /* First duplicate the close-on-exec state of redirectee.  dup2
+            leaves the flag unset on the new descriptor, which means it
+            stays open.  Only set the close-on-exec bit for file descriptors
+            greater than 2 in any case, since 0-2 should always be open
+            unless closed by something like `exec 2<&-'.  It should always
+            be safe to set fds > 2 to close-on-exec if they're being used to
+            save file descriptors < 2, since we don't need to preserve the
+            state of the close-on-exec flag for those fds -- they should
+            always be open. */
+         /* if ((already_set || set_unconditionally) && (ok_to_set))
+               set_it () */
+#if 0
+         if (((fcntl (redir_fd, F_GETFD, 0) == 1) || redir_fd < 2 || (flags & RX_CLEXEC)) &&
+              (redirector > 2))
+#else
+         if (((fcntl (redir_fd, F_GETFD, 0) == 1) || (redir_fd < 2 && (flags & RX_INTERNAL)) || (flags & RX_CLEXEC)) &&
+              (redirector > 2))
+#endif
+           SET_CLOSE_ON_EXEC (redirector);
+
+         /* dup-and-close redirection */
+         if (ri == r_move_input || ri == r_move_output)
+           close (redir_fd);
+       }
+      break;
+
+    case r_close_this:
+      if (flags & RX_ACTIVE)
+       {
+         if ((flags & RX_UNDOABLE) && (fcntl (redirector, F_GETFD, 0) != -1))
+           add_undo_redirect (redirector, ri);
+
+#if defined (BUFFERED_INPUT)
+         check_bash_input (redirector);
+         close_buffered_fd (redirector);
+#else /* !BUFFERED_INPUT */
+         close (redirector);
+#endif /* !BUFFERED_INPUT */
+       }
+      break;
+
+    case r_duplicating_input_word:
+    case r_duplicating_output_word:
+      break;
+    }
+  return (0);
+}
+
+#define SHELL_FD_BASE  10
+
+/* Remember the file descriptor associated with the slot FD,
+   on REDIRECTION_UNDO_LIST.  Note that the list will be reversed
+   before it is executed.  Any redirections that need to be undone
+   even if REDIRECTION_UNDO_LIST is discarded by the exec builtin
+   are also saved on EXEC_REDIRECTION_UNDO_LIST. */
+static int
+add_undo_redirect (fd, ri)
+     int fd;
+     enum r_instruction ri;
+{
+  int new_fd, clexec_flag;
+  REDIRECT *new_redirect, *closer, *dummy_redirect;
+
+  new_fd = fcntl (fd, F_DUPFD, SHELL_FD_BASE);
+
+  if (new_fd < 0)
+    {
+      sys_error (_("redirection error: cannot duplicate fd"));
+      return (-1);
+    }
+
+  clexec_flag = fcntl (fd, F_GETFD, 0);
+
+  rd.dest = 0;
+  closer = make_redirection (new_fd, r_close_this, rd);
+  closer->flags |= RX_INTERNAL;
+  dummy_redirect = copy_redirects (closer);
+
+  rd.dest = new_fd;
+  if (fd == 0)
+    new_redirect = make_redirection (fd, r_duplicating_input, rd);
+  else
+    new_redirect = make_redirection (fd, r_duplicating_output, rd);
+  new_redirect->flags |= RX_INTERNAL;
+  new_redirect->next = closer;
+
+  closer->next = redirection_undo_list;
+  redirection_undo_list = new_redirect;
+
+  /* Save redirections that need to be undone even if the undo list
+     is thrown away by the `exec' builtin. */
+  add_exec_redirect (dummy_redirect);
+
+  /* experimental:  if we're saving a redirection to undo for a file descriptor
+     above SHELL_FD_BASE, add a redirection to be undone if the exec builtin
+     causes redirections to be discarded. */
+  if (fd >= SHELL_FD_BASE && ri != r_close_this)
+    {
+      rd.dest = new_fd;
+      new_redirect = make_redirection (fd, r_duplicating_output, rd);
+#if 0
+      closer = copy_redirects (new_redirect);
+      add_exec_redirect (closer);
+#else
+      add_exec_redirect (new_redirect);
+#endif     
+    }
+
+  /* File descriptors used only for saving others should always be
+     marked close-on-exec.  Unfortunately, we have to preserve the
+     close-on-exec state of the file descriptor we are saving, since
+     fcntl (F_DUPFD) sets the new file descriptor to remain open
+     across execs.  If, however, the file descriptor whose state we
+     are saving is <= 2, we can just set the close-on-exec flag,
+     because file descriptors 0-2 should always be open-on-exec,
+     and the restore above in do_redirection() will take care of it. */
+  if (clexec_flag || fd < 3)
+    SET_CLOSE_ON_EXEC (new_fd);
+
+  return (0);
+}
+
+/* Set up to close FD when we are finished with the current command
+   and its redirections. */
+static void
+add_undo_close_redirect (fd)
+     int fd;
+{
+  REDIRECT *closer;
+
+  rd.dest = 0;
+  closer = make_redirection (fd, r_close_this, rd);
+  closer->flags |= RX_INTERNAL;
+  closer->next = redirection_undo_list;
+  redirection_undo_list = closer;
+}
+
+static void
+add_exec_redirect (dummy_redirect)
+     REDIRECT *dummy_redirect;
+{
+  dummy_redirect->next = exec_redirection_undo_list;
+  exec_redirection_undo_list = dummy_redirect;
+}
+
+/* Return 1 if the redirection specified by RI and REDIRECTOR alters the
+   standard input. */
+static int
+stdin_redirection (ri, redirector)
+     enum r_instruction ri;
+     int redirector;
+{
+  switch (ri)
+    {
+    case r_input_direction:
+    case r_inputa_direction:
+    case r_input_output:
+    case r_reading_until:
+    case r_deblank_reading_until:
+    case r_reading_string:
+      return (1);
+    case r_duplicating_input:
+    case r_duplicating_input_word:
+    case r_close_this:
+      return (redirector == 0);
+    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:
+      return (0);
+    }
+  return (0);
+}
+
+/* Return non-zero if any of the redirections in REDIRS alter the standard
+   input. */
+int
+stdin_redirects (redirs)
+     REDIRECT *redirs;
+{
+  REDIRECT *rp;
+  int n;
+
+  for (n = 0, rp = redirs; rp; rp = rp->next)
+    n += stdin_redirection (rp->instruction, rp->redirector);
+  return n;
+}
diff --git a/shell.c b/shell.c
index 73b422bc89da454f147ae2758840dcef1b04e7b4..87a357361ab7eaec18988935d37b04e6de590f82 100644 (file)
--- a/shell.c
+++ b/shell.c
@@ -139,6 +139,12 @@ int interactive_shell = 0;
    shell exits. */
 int hup_on_exit = 0;
 
+/* Non-zero means to list status of running and stopped jobs at shell exit */
+int check_jobs_at_exit = 0;
+
+/* Non-zero means to change to a directory name supplied as a command name */
+int autocd = 1;
+
 /* Tells what state the shell was in when it started:
        0 = non-interactive shell script
        1 = interactive
@@ -172,6 +178,9 @@ time_t shell_start_time;
 /* Are we running in an emacs shell window? */
 int running_under_emacs;
 
+/* Do we have /dev/fd? */
+int have_devfd = HAVE_DEV_FD;
+
 /* The name of the .(shell)rc file. */
 static char *bashrc_file = "~/.bashrc";
 
@@ -212,8 +221,8 @@ int posixly_correct = 0;    /* Non-zero means posix.2 superset. */
 /* Some long-winded argument names.  These are obviously new. */
 #define Int 1
 #define Charp 2
-struct {
-  char *name;
+static const struct {
+  const char *name;
   int type;
   int *int_value;
   char **char_value;
index f8d32e277dad74faf766da099ce0dd6180da8423..8191819cd1a95e0a233937a1316c159231c46591 100644 (file)
--- a/shell.c~
+++ b/shell.c~
@@ -1,6 +1,6 @@
 /* shell.c -- GNU's idea of the POSIX shell specification. */
 
-/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2006 Free Software Foundation, Inc.
 
    This file is part of GNU Bash, the Bourne Again SHell.
 
@@ -139,6 +139,12 @@ int interactive_shell = 0;
    shell exits. */
 int hup_on_exit = 0;
 
+/* Non-zero means to list status of running and stopped jobs at shell exit */
+int check_jobs_at_exit = 0;
+
+/* Non-zero means to change to a directory name supplied as a command name */
+int autocd = 1;
+
 /* Tells what state the shell was in when it started:
        0 = non-interactive shell script
        1 = interactive
@@ -172,6 +178,9 @@ time_t shell_start_time;
 /* Are we running in an emacs shell window? */
 int running_under_emacs;
 
+/* Do we have /dev/fd? */
+int have_devfd = HAVE_DEV_FD;
+
 /* The name of the .(shell)rc file. */
 static char *bashrc_file = "~/.bashrc";
 
@@ -1731,7 +1740,7 @@ show_shell_usage (fp, extra)
   char *set_opts, *s, *t;
 
   if (extra)
-    fprintf (fp, "GNU bash, version %s-(%s)\n", shell_version_string (), MACHTYPE);
+    fprintf (fp, _("GNU bash, version %s-(%s)\n"), shell_version_string (), MACHTYPE);
   fprintf (fp, _("Usage:\t%s [GNU long option] [option] ...\n\t%s [GNU long option] [option] script-file ...\n"),
             shell_name, shell_name);
   fputs (_("GNU long options:\n"), fp);
diff --git a/subst.c b/subst.c
index d5026e0b98814ecc04853620dd88289c186db2a7..fe95cdd94e429f14f3b9f0c63e43ef5af3800e67 100644 (file)
--- a/subst.c
+++ b/subst.c
@@ -4134,7 +4134,7 @@ make_named_pipe ()
 {
   char *tname;
 
-  tname = sh_mktmpname ("sh-np", MT_USERANDOM);
+  tname = sh_mktmpname ("sh-np", MT_USERANDOM|MT_USETMPDIR);
   if (mkfifo (tname, 0600) < 0)
     {
       free (tname);
index 03edfde085a7b568715be0e376632879bc99ded4..d5026e0b98814ecc04853620dd88289c186db2a7 100644 (file)
--- a/subst.c~
+++ b/subst.c~
@@ -6970,7 +6970,7 @@ add_string:
                    sindex = t_index;
                    goto add_character;
                  }
-               report_error (_("bad substitution: no closing \"`\" in %s"), string+t_index);
+               report_error (_("bad substitution: no closing \"`\" in %s") , string+t_index);
                free (string);
                free (istring);
                return ((temp == &extract_string_error) ? &expand_word_error
index 72ec06a2c1fd8dde92acea5e8ac773e35f1d061b..3efcf32d68e9722024b6ca9d67f9e81b2aa5ac04 100755 (executable)
@@ -1,4 +1,4 @@
-BUILD_DIR=/usr/local/build/bash/bash-current
+BUILD_DIR=/usr/local/build/chet/bash/bash-current
 THIS_SH=$BUILD_DIR/bash
 PATH=$PATH:$BUILD_DIR
 
index 5fd9d0e992e30ff419df63af981d1081770f732e..f8b1d3e21e9b2c3cfec6056e51c3c87c09e3e4df 100644 (file)
@@ -192,6 +192,8 @@ static SHELL_VAR *get_lineno __P((SHELL_VAR *));
 static SHELL_VAR *assign_subshell __P((SHELL_VAR *, char *, arrayind_t));
 static SHELL_VAR *get_subshell __P((SHELL_VAR *));
 
+static SHELL_VAR *get_bashpid __P((SHELL_VAR *));
+
 #if defined (HISTORY)
 static SHELL_VAR *get_histcmd __P((SHELL_VAR *));
 #endif
@@ -1271,6 +1273,22 @@ get_subshell (var)
   return (var);
 }
 
+static SHELL_VAR *
+get_bashpid (var)
+     SHELL_VAR *var;
+{
+  int pid;
+  char *p;
+
+  pid = getpid ();
+  p = itos (pid);
+
+  FREE (value_cell (var));
+  VSETATTR (var, att_integer|att_readonly);
+  var_setvalue (var, p);
+  return (var);
+}
+
 static SHELL_VAR *
 get_bash_command (var)
      SHELL_VAR *var;
@@ -1452,6 +1470,9 @@ initialize_dynamic_variables ()
   INIT_DYNAMIC_VAR ("LINENO", (char *)NULL, get_lineno, assign_lineno);
   VSETATTR (v, att_integer);
 
+  INIT_DYNAMIC_VAR ("BASHPID", (char *)NULL, get_bashpid, null_assign);
+  VSETATTR (v, att_integer|att_readonly);
+
 #if defined (HISTORY)
   INIT_DYNAMIC_VAR ("HISTCMD", (char *)NULL, get_histcmd, (sh_var_assign_func_t *)NULL);
   VSETATTR (v, att_integer);
diff --git a/variables.c~ b/variables.c~
new file mode 100644 (file)
index 0000000..5fd9d0e
--- /dev/null
@@ -0,0 +1,4270 @@
+/* variables.c -- Functions for hacking shell variables. */
+
+/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
+
+   This file is part of GNU Bash, the Bourne Again SHell.
+
+   Bash is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   Bash is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+   License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with Bash; see the file COPYING.  If not, write to the Free
+   Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+#include "config.h"
+
+#include "bashtypes.h"
+#include "posixstat.h"
+#include "posixtime.h"
+
+#if defined (qnx)
+#  if defined (qnx6)
+#    include <sy/netmgr.h>
+#  else
+#    include <sys/vc.h>
+#  endif /* !qnx6 */
+#endif /* qnx */
+
+#if defined (HAVE_UNISTD_H)
+#  include <unistd.h>
+#endif
+
+#include <stdio.h>
+#include "chartypes.h"
+#include <pwd.h>
+#include "bashansi.h"
+#include "bashintl.h"
+
+#include "shell.h"
+#include "flags.h"
+#include "execute_cmd.h"
+#include "findcmd.h"
+#include "mailcheck.h"
+#include "input.h"
+#include "hashcmd.h"
+#include "pathexp.h"
+
+#include "builtins/getopt.h"
+#include "builtins/common.h"
+
+#if defined (READLINE)
+#  include "bashline.h"
+#  include <readline/readline.h>
+#else
+#  include <tilde/tilde.h>
+#endif
+
+#if defined (HISTORY)
+#  include "bashhist.h"
+#  include <readline/history.h>
+#endif /* HISTORY */
+
+#if defined (PROGRAMMABLE_COMPLETION)
+#  include "pcomplete.h"
+#endif
+
+#define TEMPENV_HASH_BUCKETS   4       /* must be power of two */
+
+#define ifsname(s)     ((s)[0] == 'I' && (s)[1] == 'F' && (s)[2] == 'S' && (s)[3] == '\0')
+
+extern char **environ;
+
+/* Variables used here and defined in other files. */
+extern int posixly_correct;
+extern int line_number;
+extern int subshell_environment, indirection_level, subshell_level;
+extern int build_version, patch_level;
+extern int expanding_redir;
+extern char *dist_version, *release_status;
+extern char *shell_name;
+extern char *primary_prompt, *secondary_prompt;
+extern char *current_host_name;
+extern sh_builtin_func_t *this_shell_builtin;
+extern SHELL_VAR *this_shell_function;
+extern char *the_printed_command_except_trap;
+extern char *this_command_name;
+extern char *command_execution_string;
+extern time_t shell_start_time;
+
+#if defined (READLINE)
+extern int no_line_editing;
+extern int perform_hostname_completion;
+#endif
+
+/* The list of shell variables that the user has created at the global
+   scope, or that came from the environment. */
+VAR_CONTEXT *global_variables = (VAR_CONTEXT *)NULL;
+
+/* The current list of shell variables, including function scopes */
+VAR_CONTEXT *shell_variables = (VAR_CONTEXT *)NULL;
+
+/* The list of shell functions that the user has created, or that came from
+   the environment. */
+HASH_TABLE *shell_functions = (HASH_TABLE *)NULL;
+
+#if defined (DEBUGGER)
+/* The table of shell function definitions that the user defined or that
+   came from the environment. */
+HASH_TABLE *shell_function_defs = (HASH_TABLE *)NULL;
+#endif
+
+/* The current variable context.  This is really a count of how deep into
+   executing functions we are. */
+int variable_context = 0;
+
+/* The set of shell assignments which are made only in the environment
+   for a single command. */
+HASH_TABLE *temporary_env = (HASH_TABLE *)NULL;
+
+/* Set to non-zero if an assignment error occurs while putting variables
+   into the temporary environment. */
+int tempenv_assign_error;
+
+/* Some funky variables which are known about specially.  Here is where
+   "$*", "$1", and all the cruft is kept. */
+char *dollar_vars[10];
+WORD_LIST *rest_of_args = (WORD_LIST *)NULL;
+
+/* The value of $$. */
+pid_t dollar_dollar_pid;
+
+/* An array which is passed to commands as their environment.  It is
+   manufactured from the union of the initial environment and the
+   shell variables that are marked for export. */
+char **export_env = (char **)NULL;
+static int export_env_index;
+static int export_env_size;
+
+#if defined (READLINE)
+static int winsize_assignment;         /* currently assigning to LINES or COLUMNS */
+static int winsize_assigned;           /* assigned to LINES or COLUMNS */
+#endif
+
+/* Non-zero means that we have to remake EXPORT_ENV. */
+int array_needs_making = 1;
+
+/* The number of times BASH has been executed.  This is set
+   by initialize_variables (). */
+int shell_level = 0;
+
+/* Some forward declarations. */
+static void create_variable_tables __P((void));
+
+static void set_machine_vars __P((void));
+static void set_home_var __P((void));
+static void set_shell_var __P((void));
+static char *get_bash_name __P((void));
+static void initialize_shell_level __P((void));
+static void uidset __P((void));
+#if defined (ARRAY_VARS)
+static void make_vers_array __P((void));
+#endif
+
+static SHELL_VAR *null_assign __P((SHELL_VAR *, char *, arrayind_t));
+#if defined (ARRAY_VARS)
+static SHELL_VAR *null_array_assign __P((SHELL_VAR *, char *, arrayind_t));
+#endif
+static SHELL_VAR *get_self __P((SHELL_VAR *));
+
+#if defined (ARRAY_VARS)
+static SHELL_VAR *init_dynamic_array_var __P((char *, sh_var_value_func_t *, sh_var_assign_func_t *, int));
+#endif
+
+static SHELL_VAR *assign_seconds __P((SHELL_VAR *, char *, arrayind_t));
+static SHELL_VAR *get_seconds __P((SHELL_VAR *));
+static SHELL_VAR *init_seconds_var __P((void));
+
+static int brand __P((void));
+static void sbrand __P((unsigned long));               /* set bash random number generator. */
+static SHELL_VAR *assign_random __P((SHELL_VAR *, char *, arrayind_t));
+static SHELL_VAR *get_random __P((SHELL_VAR *));
+
+static SHELL_VAR *assign_lineno __P((SHELL_VAR *, char *, arrayind_t));
+static SHELL_VAR *get_lineno __P((SHELL_VAR *));
+
+static SHELL_VAR *assign_subshell __P((SHELL_VAR *, char *, arrayind_t));
+static SHELL_VAR *get_subshell __P((SHELL_VAR *));
+
+#if defined (HISTORY)
+static SHELL_VAR *get_histcmd __P((SHELL_VAR *));
+#endif
+
+#if defined (PUSHD_AND_POPD) && defined (ARRAY_VARS)
+static SHELL_VAR *assign_dirstack __P((SHELL_VAR *, char *, arrayind_t));
+static SHELL_VAR *get_dirstack __P((SHELL_VAR *));
+#endif
+
+#if defined (ARRAY_VARS)
+static SHELL_VAR *get_groupset __P((SHELL_VAR *));
+#endif
+
+static SHELL_VAR *get_funcname __P((SHELL_VAR *));
+static SHELL_VAR *init_funcname_var __P((void));
+
+static void initialize_dynamic_variables __P((void));
+
+static SHELL_VAR *hash_lookup __P((const char *, HASH_TABLE *));
+static SHELL_VAR *new_shell_variable __P((const char *));
+static SHELL_VAR *make_new_variable __P((const char *, HASH_TABLE *));
+static SHELL_VAR *bind_variable_internal __P((const char *, char *, HASH_TABLE *, int, int));
+
+static void free_variable_hash_data __P((PTR_T));
+
+static VARLIST *vlist_alloc __P((int));
+static VARLIST *vlist_realloc __P((VARLIST *, int));
+static void vlist_add __P((VARLIST *, SHELL_VAR *, int));
+
+static void flatten __P((HASH_TABLE *, sh_var_map_func_t *, VARLIST *, int));
+
+static int qsort_var_comp __P((SHELL_VAR **, SHELL_VAR **));
+
+static SHELL_VAR **vapply __P((sh_var_map_func_t *));
+static SHELL_VAR **fapply __P((sh_var_map_func_t *));
+
+static int visible_var __P((SHELL_VAR *));
+static int visible_and_exported __P((SHELL_VAR *));
+static int local_and_exported __P((SHELL_VAR *));
+static int variable_in_context __P((SHELL_VAR *));
+#if defined (ARRAY_VARS)
+static int visible_array_vars __P((SHELL_VAR *));
+#endif
+
+static SHELL_VAR *bind_tempenv_variable __P((const char *, char *));
+static void push_temp_var __P((PTR_T));
+static void propagate_temp_var __P((PTR_T));
+static void dispose_temporary_env __P((sh_free_func_t *));     
+
+static inline char *mk_env_string __P((const char *, const char *));
+static char **make_env_array_from_var_list __P((SHELL_VAR **));
+static char **make_var_export_array __P((VAR_CONTEXT *));
+static char **make_func_export_array __P((void));
+static void add_temp_array_to_env __P((char **, int, int));
+
+static int n_shell_variables __P((void));
+static int set_context __P((SHELL_VAR *));
+
+static void push_func_var __P((PTR_T));
+static void push_exported_var __P((PTR_T));
+
+static inline int find_special_var __P((const char *));
+
+static void
+create_variable_tables ()
+{
+  if (shell_variables == 0)
+    {
+      shell_variables = global_variables = new_var_context ((char *)NULL, 0);
+      shell_variables->scope = 0;
+      shell_variables->table = hash_create (0);
+    }
+
+  if (shell_functions == 0)
+    shell_functions = hash_create (0);
+
+#if defined (DEBUGGER)
+  if (shell_function_defs == 0)
+    shell_function_defs = hash_create (0);
+#endif
+}
+
+/* Initialize the shell variables from the current environment.
+   If PRIVMODE is nonzero, don't import functions from ENV or
+   parse $SHELLOPTS. */
+void
+initialize_shell_variables (env, privmode)
+     char **env;
+     int privmode;
+{
+  char *name, *string, *temp_string;
+  int c, char_index, string_index, string_length;
+  SHELL_VAR *temp_var;
+
+  create_variable_tables ();
+
+  for (string_index = 0; string = env[string_index++]; )
+    {
+      char_index = 0;
+      name = string;
+      while ((c = *string++) && c != '=')
+       ;
+      if (string[-1] == '=')
+       char_index = string - name - 1;
+
+      /* If there are weird things in the environment, like `=xxx' or a
+        string without an `=', just skip them. */
+      if (char_index == 0)
+       continue;
+
+      /* ASSERT(name[char_index] == '=') */
+      name[char_index] = '\0';
+      /* Now, name = env variable name, string = env variable value, and
+        char_index == strlen (name) */
+
+      /* If exported function, define it now.  Don't import functions from
+        the environment in privileged mode. */
+      if (privmode == 0 && read_but_dont_execute == 0 && STREQN ("() {", string, 4))
+       {
+         string_length = strlen (string);
+         temp_string = (char *)xmalloc (3 + string_length + char_index);
+
+         strcpy (temp_string, name);
+         temp_string[char_index] = ' ';
+         strcpy (temp_string + char_index + 1, string);
+
+         parse_and_execute (temp_string, name, SEVAL_NONINT|SEVAL_NOHIST);
+
+         /* Ancient backwards compatibility.  Old versions of bash exported
+            functions like name()=() {...} */
+         if (name[char_index - 1] == ')' && name[char_index - 2] == '(')
+           name[char_index - 2] = '\0';
+
+         if (temp_var = find_function (name))
+           {
+             VSETATTR (temp_var, (att_exported|att_imported));
+             array_needs_making = 1;
+           }
+         else
+           report_error (_("error importing function definition for `%s'"), name);
+
+         /* ( */
+         if (name[char_index - 1] == ')' && name[char_index - 2] == '\0')
+           name[char_index - 2] = '(';         /* ) */
+       }
+#if defined (ARRAY_VARS)
+#  if 0
+      /* Array variables may not yet be exported. */
+      else if (*string == '(' && string[1] == '[' && string[strlen (string) - 1] == ')')
+       {
+         string_length = 1;
+         temp_string = extract_array_assignment_list (string, &string_length);
+         temp_var = assign_array_from_string (name, temp_string);
+         FREE (temp_string);
+         VSETATTR (temp_var, (att_exported | att_imported));
+         array_needs_making = 1;
+       }
+#  endif
+#endif
+      else
+       {
+         temp_var = bind_variable (name, string, 0);
+         VSETATTR (temp_var, (att_exported | att_imported));
+         array_needs_making = 1;
+       }
+
+      name[char_index] = '=';
+      /* temp_var can be NULL if it was an exported function with a syntax
+        error (a different bug, but it still shouldn't dump core). */
+      if (temp_var && function_p (temp_var) == 0)      /* XXX not yet */
+       {
+         CACHE_IMPORTSTR (temp_var, name);
+       }
+    }
+
+  set_pwd ();
+
+  /* Set up initial value of $_ */
+  temp_var = set_if_not ("_", dollar_vars[0]);
+
+  /* Remember this pid. */
+  dollar_dollar_pid = getpid ();
+
+  /* Now make our own defaults in case the vars that we think are
+     important are missing. */
+  temp_var = set_if_not ("PATH", DEFAULT_PATH_VALUE);
+#if 0
+  set_auto_export (temp_var);  /* XXX */
+#endif
+
+  temp_var = set_if_not ("TERM", "dumb");
+#if 0
+  set_auto_export (temp_var);  /* XXX */
+#endif
+
+#if defined (qnx)
+  /* set node id -- don't import it from the environment */
+  {
+    char node_name[22];
+#  if defined (qnx6)
+    netmgr_ndtostr(ND2S_LOCAL_STR, ND_LOCAL_NODE, node_name, sizeof(node_name));
+#  else
+    qnx_nidtostr (getnid (), node_name, sizeof (node_name));
+#  endif
+    temp_var = bind_variable ("NODE", node_name, 0);
+    set_auto_export (temp_var);
+  }
+#endif
+
+  /* set up the prompts. */
+  if (interactive_shell)
+    {
+#if defined (PROMPT_STRING_DECODE)
+      set_if_not ("PS1", primary_prompt);
+#else
+      if (current_user.uid == -1)
+       get_current_user_info ();
+      set_if_not ("PS1", current_user.euid == 0 ? "# " : primary_prompt);
+#endif
+      set_if_not ("PS2", secondary_prompt);
+    }
+  set_if_not ("PS4", "+ ");
+
+  /* Don't allow IFS to be imported from the environment. */
+  temp_var = bind_variable ("IFS", " \t\n", 0);
+  setifs (temp_var);
+
+  /* Magic machine types.  Pretty convenient. */
+  set_machine_vars ();
+
+  /* Default MAILCHECK for interactive shells.  Defer the creation of a
+     default MAILPATH until the startup files are read, because MAIL
+     names a mail file if MAILPATH is not set, and we should provide a
+     default only if neither is set. */
+  if (interactive_shell)
+    {
+      temp_var = set_if_not ("MAILCHECK", posixly_correct ? "600" : "60");
+      VSETATTR (temp_var, att_integer);
+    }
+
+  /* Do some things with shell level. */
+  initialize_shell_level ();
+
+  set_ppid ();
+
+  /* Initialize the `getopts' stuff. */
+  temp_var = bind_variable ("OPTIND", "1", 0);
+  VSETATTR (temp_var, att_integer);
+  getopts_reset (0);
+  bind_variable ("OPTERR", "1", 0);
+  sh_opterr = 1;
+
+  if (login_shell == 1 && posixly_correct == 0)
+    set_home_var ();
+
+  /* Get the full pathname to THIS shell, and set the BASH variable
+     to it. */
+  name = get_bash_name ();
+  temp_var = bind_variable ("BASH", name, 0);
+  free (name);
+
+  /* Make the exported environment variable SHELL be the user's login
+     shell.  Note that the `tset' command looks at this variable
+     to determine what style of commands to output; if it ends in "csh",
+     then C-shell commands are output, else Bourne shell commands. */
+  set_shell_var ();
+
+  /* Make a variable called BASH_VERSION which contains the version info. */
+  bind_variable ("BASH_VERSION", shell_version_string (), 0);
+#if defined (ARRAY_VARS)
+  make_vers_array ();
+#endif
+
+  if (command_execution_string)
+    bind_variable ("BASH_EXECUTION_STRING", command_execution_string, 0);
+
+  /* Find out if we're supposed to be in Posix.2 mode via an
+     environment variable. */
+  temp_var = find_variable ("POSIXLY_CORRECT");
+  if (!temp_var)
+    temp_var = find_variable ("POSIX_PEDANTIC");
+  if (temp_var && imported_p (temp_var))
+    sv_strict_posix (temp_var->name);
+
+#if defined (HISTORY)
+  /* Set history variables to defaults, and then do whatever we would
+     do if the variable had just been set.  Do this only in the case
+     that we are remembering commands on the history list. */
+  if (remember_on_history)
+    {
+      name = bash_tilde_expand (posixly_correct ? "~/.sh_history" : "~/.bash_history", 0);
+
+      set_if_not ("HISTFILE", name);
+      free (name);
+
+#if 0
+      set_if_not ("HISTSIZE", "500");
+      sv_histsize ("HISTSIZE");
+#endif
+    }
+#endif /* HISTORY */
+
+  /* Seed the random number generator. */
+  sbrand (dollar_dollar_pid + shell_start_time);
+
+  /* Handle some "special" variables that we may have inherited from a
+     parent shell. */
+  if (interactive_shell)
+    {
+      temp_var = find_variable ("IGNOREEOF");
+      if (!temp_var)
+       temp_var = find_variable ("ignoreeof");
+      if (temp_var && imported_p (temp_var))
+       sv_ignoreeof (temp_var->name);
+    }
+
+#if defined (HISTORY)
+  if (interactive_shell && remember_on_history)
+    {
+      sv_history_control ("HISTCONTROL");
+      sv_histignore ("HISTIGNORE");
+    }
+#endif /* HISTORY */
+
+#if defined (READLINE) && defined (STRICT_POSIX)
+  /* POSIXLY_CORRECT will only be 1 here if the shell was compiled
+     -DSTRICT_POSIX */
+  if (interactive_shell && posixly_correct && no_line_editing == 0)
+    rl_prefer_env_winsize = 1;
+#endif /* READLINE && STRICT_POSIX */
+
+     /*
+      * 24 October 2001
+      *
+      * I'm tired of the arguing and bug reports.  Bash now leaves SSH_CLIENT
+      * and SSH2_CLIENT alone.  I'm going to rely on the shell_level check in
+      * isnetconn() to avoid running the startup files more often than wanted.
+      * That will, of course, only work if the user's login shell is bash, so
+      * I've made that behavior conditional on SSH_SOURCE_BASHRC being defined
+      * in config-top.h.
+      */
+#if 0
+  temp_var = find_variable ("SSH_CLIENT");
+  if (temp_var && imported_p (temp_var))
+    {
+      VUNSETATTR (temp_var, att_exported);
+      array_needs_making = 1;
+    }
+  temp_var = find_variable ("SSH2_CLIENT");
+  if (temp_var && imported_p (temp_var))
+    {
+      VUNSETATTR (temp_var, att_exported);
+      array_needs_making = 1;
+    }
+#endif
+
+  /* Get the user's real and effective user ids. */
+  uidset ();
+
+  /* Initialize the dynamic variables, and seed their values. */
+  initialize_dynamic_variables ();
+}
+
+/* **************************************************************** */
+/*                                                                 */
+/*          Setting values for special shell variables             */
+/*                                                                 */
+/* **************************************************************** */
+
+static void
+set_machine_vars ()
+{
+  SHELL_VAR *temp_var;
+
+  temp_var = set_if_not ("HOSTTYPE", HOSTTYPE);
+  temp_var = set_if_not ("OSTYPE", OSTYPE);
+  temp_var = set_if_not ("MACHTYPE", MACHTYPE);
+
+  temp_var = set_if_not ("HOSTNAME", current_host_name);
+}
+
+/* Set $HOME to the information in the password file if we didn't get
+   it from the environment. */
+
+/* This function is not static so the tilde and readline libraries can
+   use it. */
+char *
+sh_get_home_dir ()
+{
+  if (current_user.home_dir == 0)
+    get_current_user_info ();
+  return current_user.home_dir;
+}
+
+static void
+set_home_var ()
+{
+  SHELL_VAR *temp_var;
+
+  temp_var = find_variable ("HOME");
+  if (temp_var == 0)
+    temp_var = bind_variable ("HOME", sh_get_home_dir (), 0);
+#if 0
+  VSETATTR (temp_var, att_exported);
+#endif
+}
+
+/* Set $SHELL to the user's login shell if it is not already set.  Call
+   get_current_user_info if we haven't already fetched the shell. */
+static void
+set_shell_var ()
+{
+  SHELL_VAR *temp_var;
+
+  temp_var = find_variable ("SHELL");
+  if (temp_var == 0)
+    {
+      if (current_user.shell == 0)
+       get_current_user_info ();
+      temp_var = bind_variable ("SHELL", current_user.shell, 0);
+    }
+#if 0
+  VSETATTR (temp_var, att_exported);
+#endif
+}
+
+static char *
+get_bash_name ()
+{
+  char *name;
+
+  if ((login_shell == 1) && RELPATH(shell_name))
+    {
+      if (current_user.shell == 0)
+       get_current_user_info ();
+      name = savestring (current_user.shell);
+    }
+  else if (ABSPATH(shell_name))
+    name = savestring (shell_name);
+  else if (shell_name[0] == '.' && shell_name[1] == '/')
+    {
+      /* Fast path for common case. */
+      char *cdir;
+      int len;
+
+      cdir = get_string_value ("PWD");
+      if (cdir)
+       {
+         len = strlen (cdir);
+         name = (char *)xmalloc (len + strlen (shell_name) + 1);
+         strcpy (name, cdir);
+         strcpy (name + len, shell_name + 1);
+       }
+      else
+       name = savestring (shell_name);
+    }
+  else
+    {
+      char *tname;
+      int s;
+
+      tname = find_user_command (shell_name);
+
+      if (tname == 0)
+       {
+         /* Try the current directory.  If there is not an executable
+            there, just punt and use the login shell. */
+         s = file_status (shell_name);
+         if (s & FS_EXECABLE)
+           {
+             tname = make_absolute (shell_name, get_string_value ("PWD"));
+             if (*shell_name == '.')
+               {
+                 name = sh_canonpath (tname, PATH_CHECKDOTDOT|PATH_CHECKEXISTS);
+                 if (name == 0)
+                   name = tname;
+                 else
+                   free (tname);
+               }
+            else
+               name = tname;
+           }
+         else
+           {
+             if (current_user.shell == 0)
+               get_current_user_info ();
+             name = savestring (current_user.shell);
+           }
+       }
+      else
+       {
+         name = full_pathname (tname);
+         free (tname);
+       }
+    }
+
+  return (name);
+}
+
+void
+adjust_shell_level (change)
+     int change;
+{
+  char new_level[5], *old_SHLVL;
+  intmax_t old_level;
+  SHELL_VAR *temp_var;
+
+  old_SHLVL = get_string_value ("SHLVL");
+  if (old_SHLVL == 0 || *old_SHLVL == '\0' || legal_number (old_SHLVL, &old_level) == 0)
+    old_level = 0;
+
+  shell_level = old_level + change;
+  if (shell_level < 0)
+    shell_level = 0;
+  else if (shell_level > 1000)
+    {
+      internal_warning (_("shell level (%d) too high, resetting to 1"), shell_level);
+      shell_level = 1;
+    }
+
+  /* We don't need the full generality of itos here. */
+  if (shell_level < 10)
+    {
+      new_level[0] = shell_level + '0';
+      new_level[1] = '\0';
+    }
+  else if (shell_level < 100)
+    {
+      new_level[0] = (shell_level / 10) + '0';
+      new_level[1] = (shell_level % 10) + '0';
+      new_level[2] = '\0';
+    }
+  else if (shell_level < 1000)
+    {
+      new_level[0] = (shell_level / 100) + '0';
+      old_level = shell_level % 100;
+      new_level[1] = (old_level / 10) + '0';
+      new_level[2] = (old_level % 10) + '0';
+      new_level[3] = '\0';
+    }
+
+  temp_var = bind_variable ("SHLVL", new_level, 0);
+  set_auto_export (temp_var);
+}
+
+static void
+initialize_shell_level ()
+{
+  adjust_shell_level (1);
+}
+
+/* If we got PWD from the environment, update our idea of the current
+   working directory.  In any case, make sure that PWD exists before
+   checking it.  It is possible for getcwd () to fail on shell startup,
+   and in that case, PWD would be undefined.  If this is an interactive
+   login shell, see if $HOME is the current working directory, and if
+   that's not the same string as $PWD, set PWD=$HOME. */
+
+void
+set_pwd ()
+{
+  SHELL_VAR *temp_var, *home_var;
+  char *temp_string, *home_string;
+
+  home_var = find_variable ("HOME");
+  home_string = home_var ? value_cell (home_var) : (char *)NULL;
+
+  temp_var = find_variable ("PWD");
+  if (temp_var && imported_p (temp_var) &&
+      (temp_string = value_cell (temp_var)) &&
+      same_file (temp_string, ".", (struct stat *)NULL, (struct stat *)NULL))
+    set_working_directory (temp_string);
+  else if (home_string && interactive_shell && login_shell &&
+          same_file (home_string, ".", (struct stat *)NULL, (struct stat *)NULL))
+    {
+      set_working_directory (home_string);
+      temp_var = bind_variable ("PWD", home_string, 0);
+      set_auto_export (temp_var);
+    }
+  else
+    {
+      temp_string = get_working_directory ("shell-init");
+      if (temp_string)
+       {
+         temp_var = bind_variable ("PWD", temp_string, 0);
+         set_auto_export (temp_var);
+         free (temp_string);
+       }
+    }
+
+  /* According to the Single Unix Specification, v2, $OLDPWD is an
+     `environment variable' and therefore should be auto-exported.
+     Make a dummy invisible variable for OLDPWD, and mark it as exported. */
+  temp_var = bind_variable ("OLDPWD", (char *)NULL, 0);
+  VSETATTR (temp_var, (att_exported | att_invisible));
+}
+
+/* Make a variable $PPID, which holds the pid of the shell's parent.  */
+void
+set_ppid ()
+{
+  char namebuf[INT_STRLEN_BOUND(pid_t) + 1], *name;
+  SHELL_VAR *temp_var;
+
+  name = inttostr (getppid (), namebuf, sizeof(namebuf));
+  temp_var = find_variable ("PPID");
+  if (temp_var)
+    VUNSETATTR (temp_var, (att_readonly | att_exported));
+  temp_var = bind_variable ("PPID", name, 0);
+  VSETATTR (temp_var, (att_readonly | att_integer));
+}
+
+static void
+uidset ()
+{
+  char buff[INT_STRLEN_BOUND(uid_t) + 1], *b;
+  register SHELL_VAR *v;
+
+  b = inttostr (current_user.uid, buff, sizeof (buff));
+  v = find_variable ("UID");
+  if (v == 0)
+    {
+      v = bind_variable ("UID", b, 0);
+      VSETATTR (v, (att_readonly | att_integer));
+    }
+
+  if (current_user.euid != current_user.uid)
+    b = inttostr (current_user.euid, buff, sizeof (buff));
+
+  v = find_variable ("EUID");
+  if (v == 0)
+    {
+      v = bind_variable ("EUID", b, 0);
+      VSETATTR (v, (att_readonly | att_integer));
+    }
+}
+
+#if defined (ARRAY_VARS)
+static void
+make_vers_array ()
+{
+  SHELL_VAR *vv;
+  ARRAY *av;
+  char *s, d[32], b[INT_STRLEN_BOUND(int) + 1];
+
+  unbind_variable ("BASH_VERSINFO");
+
+  vv = make_new_array_variable ("BASH_VERSINFO");
+  av = array_cell (vv);
+  strcpy (d, dist_version);
+  s = xstrchr (d, '.');
+  if (s)
+    *s++ = '\0';
+  array_insert (av, 0, d);
+  array_insert (av, 1, s);
+  s = inttostr (patch_level, b, sizeof (b));
+  array_insert (av, 2, s);
+  s = inttostr (build_version, b, sizeof (b));
+  array_insert (av, 3, s);
+  array_insert (av, 4, release_status);
+  array_insert (av, 5, MACHTYPE);
+
+  VSETATTR (vv, att_readonly);
+}
+#endif /* ARRAY_VARS */
+
+/* Set the environment variables $LINES and $COLUMNS in response to
+   a window size change. */
+void
+sh_set_lines_and_columns (lines, cols)
+     int lines, cols;
+{
+  char val[INT_STRLEN_BOUND(int) + 1], *v;
+
+#if defined (READLINE)
+  /* If we are currently assigning to LINES or COLUMNS, don't do anything. */
+  if (winsize_assignment)
+    return;
+#endif
+
+  v = inttostr (lines, val, sizeof (val));
+  bind_variable ("LINES", v, 0);
+
+  v = inttostr (cols, val, sizeof (val));
+  bind_variable ("COLUMNS", v, 0);
+}
+
+/* **************************************************************** */
+/*                                                                 */
+/*                Printing variables and values                    */
+/*                                                                 */
+/* **************************************************************** */
+
+/* Print LIST (a list of shell variables) to stdout in such a way that
+   they can be read back in. */
+void
+print_var_list (list)
+     register SHELL_VAR **list;
+{
+  register int i;
+  register SHELL_VAR *var;
+
+  for (i = 0; list && (var = list[i]); i++)
+    if (invisible_p (var) == 0)
+      print_assignment (var);
+}
+
+/* Print LIST (a list of shell functions) to stdout in such a way that
+   they can be read back in. */
+void
+print_func_list (list)
+     register SHELL_VAR **list;
+{
+  register int i;
+  register SHELL_VAR *var;
+
+  for (i = 0; list && (var = list[i]); i++)
+    {
+      printf ("%s ", var->name);
+      print_var_function (var);
+      printf ("\n");
+    }
+}
+      
+/* Print the value of a single SHELL_VAR.  No newline is
+   output, but the variable is printed in such a way that
+   it can be read back in. */
+void
+print_assignment (var)
+     SHELL_VAR *var;
+{
+  if (var_isset (var) == 0)
+    return;
+
+  if (function_p (var))
+    {
+      printf ("%s", var->name);
+      print_var_function (var);
+      printf ("\n");
+    }
+#if defined (ARRAY_VARS)
+  else if (array_p (var))
+    print_array_assignment (var, 0);
+#endif /* ARRAY_VARS */
+  else
+    {
+      printf ("%s=", var->name);
+      print_var_value (var, 1);
+      printf ("\n");
+    }
+}
+
+/* Print the value cell of VAR, a shell variable.  Do not print
+   the name, nor leading/trailing newline.  If QUOTE is non-zero,
+   and the value contains shell metacharacters, quote the value
+   in such a way that it can be read back in. */
+void
+print_var_value (var, quote)
+     SHELL_VAR *var;
+     int quote;
+{
+  char *t;
+
+  if (var_isset (var) == 0)
+    return;
+
+  if (quote && posixly_correct == 0 && ansic_shouldquote (value_cell (var)))
+    {
+      t = ansic_quote (value_cell (var), 0, (int *)0);
+      printf ("%s", t);
+      free (t);
+    }
+  else if (quote && sh_contains_shell_metas (value_cell (var)))
+    {
+      t = sh_single_quote (value_cell (var));
+      printf ("%s", t);
+      free (t);
+    }
+  else
+    printf ("%s", value_cell (var));
+}
+
+/* Print the function cell of VAR, a shell variable.  Do not
+   print the name, nor leading/trailing newline. */
+void
+print_var_function (var)
+     SHELL_VAR *var;
+{
+  if (function_p (var) && var_isset (var))
+    printf ("%s", named_function_string ((char *)NULL, function_cell(var), 1));
+}
+
+/* **************************************************************** */
+/*                                                                 */
+/*                     Dynamic Variables                           */
+/*                                                                 */
+/* **************************************************************** */
+
+/* DYNAMIC VARIABLES
+
+   These are variables whose values are generated anew each time they are
+   referenced.  These are implemented using a pair of function pointers
+   in the struct variable: assign_func, which is called from bind_variable
+   and, if arrays are compiled into the shell, some of the functions in
+   arrayfunc.c, and dynamic_value, which is called from find_variable.
+
+   assign_func is called from bind_variable_internal, if
+   bind_variable_internal discovers that the variable being assigned to
+   has such a function.  The function is called as
+       SHELL_VAR *temp = (*(entry->assign_func)) (entry, value, ind)
+   and the (SHELL_VAR *)temp is returned as the value of bind_variable.  It
+   is usually ENTRY (self).  IND is an index for an array variable, and
+   unused otherwise.
+
+   dynamic_value is called from find_variable_internal to return a `new'
+   value for the specified dynamic varible.  If this function is NULL,
+   the variable is treated as a `normal' shell variable.  If it is not,
+   however, then this function is called like this:
+       tempvar = (*(var->dynamic_value)) (var);
+
+   Sometimes `tempvar' will replace the value of `var'.  Other times, the
+   shell will simply use the string value.  Pretty object-oriented, huh?
+
+   Be warned, though: if you `unset' a special variable, it loses its
+   special meaning, even if you subsequently set it.
+
+   The special assignment code would probably have been better put in
+   subst.c: do_assignment_internal, in the same style as
+   stupidly_hack_special_variables, but I wanted the changes as
+   localized as possible.  */
+
+#define INIT_DYNAMIC_VAR(var, val, gfunc, afunc) \
+  do \
+    { \
+      v = bind_variable (var, (val), 0); \
+      v->dynamic_value = gfunc; \
+      v->assign_func = afunc; \
+    } \
+  while (0)
+
+#define INIT_DYNAMIC_ARRAY_VAR(var, gfunc, afunc) \
+  do \
+    { \
+      v = make_new_array_variable (var); \
+      v->dynamic_value = gfunc; \
+      v->assign_func = afunc; \
+    } \
+  while (0)
+
+static SHELL_VAR *
+null_assign (self, value, unused)
+     SHELL_VAR *self;
+     char *value;
+     arrayind_t unused;
+{
+  return (self);
+}
+
+#if defined (ARRAY_VARS)
+static SHELL_VAR *
+null_array_assign (self, value, ind)
+     SHELL_VAR *self;
+     char *value;
+     arrayind_t ind;
+{
+  return (self);
+}
+#endif
+
+/* Degenerate `dynamic_value' function; just returns what's passed without
+   manipulation. */
+static SHELL_VAR *
+get_self (self)
+     SHELL_VAR *self;
+{
+  return (self);
+}
+
+#if defined (ARRAY_VARS)
+/* A generic dynamic array variable initializer.  Intialize array variable
+   NAME with dynamic value function GETFUNC and assignment function SETFUNC. */
+static SHELL_VAR *
+init_dynamic_array_var (name, getfunc, setfunc, attrs)
+     char *name;
+     sh_var_value_func_t *getfunc;
+     sh_var_assign_func_t *setfunc;
+     int attrs;
+{
+  SHELL_VAR *v;
+
+  v = find_variable (name);
+  if (v)
+    return (v);
+  INIT_DYNAMIC_ARRAY_VAR (name, getfunc, setfunc);
+  if (attrs)
+    VSETATTR (v, attrs);
+  return v;
+}
+#endif
+
+
+/* The value of $SECONDS.  This is the number of seconds since shell
+   invocation, or, the number of seconds since the last assignment + the
+   value of the last assignment. */
+static intmax_t seconds_value_assigned;
+
+static SHELL_VAR *
+assign_seconds (self, value, unused)
+     SHELL_VAR *self;
+     char *value;
+     arrayind_t unused;
+{
+  if (legal_number (value, &seconds_value_assigned) == 0)
+    seconds_value_assigned = 0;
+  shell_start_time = NOW;
+  return (self);
+}
+
+static SHELL_VAR *
+get_seconds (var)
+     SHELL_VAR *var;
+{
+  time_t time_since_start;
+  char *p;
+
+  time_since_start = NOW - shell_start_time;
+  p = itos(seconds_value_assigned + time_since_start);
+
+  FREE (value_cell (var));
+
+  VSETATTR (var, att_integer);
+  var_setvalue (var, p);
+  return (var);
+}
+
+static SHELL_VAR *
+init_seconds_var ()
+{
+  SHELL_VAR *v;
+
+  v = find_variable ("SECONDS");
+  if (v)
+    {
+      if (legal_number (value_cell(v), &seconds_value_assigned) == 0)
+       seconds_value_assigned = 0;
+    }
+  INIT_DYNAMIC_VAR ("SECONDS", (v ? value_cell (v) : (char *)NULL), get_seconds, assign_seconds);
+  return v;      
+}
+     
+/* The random number seed.  You can change this by setting RANDOM. */
+static unsigned long rseed = 1;
+static int last_random_value;
+static int seeded_subshell = 0;
+
+/* A linear congruential random number generator based on the example
+   one in the ANSI C standard.  This one isn't very good, but a more
+   complicated one is overkill. */
+
+/* Returns a pseudo-random number between 0 and 32767. */
+static int
+brand ()
+{
+  rseed = rseed * 1103515245 + 12345;
+  return ((unsigned int)((rseed >> 16) & 32767));      /* was % 32768 */
+}
+
+/* Set the random number generator seed to SEED. */
+static void
+sbrand (seed)
+     unsigned long seed;
+{
+  rseed = seed;
+  last_random_value = 0;
+}
+
+static SHELL_VAR *
+assign_random (self, value, unused)
+     SHELL_VAR *self;
+     char *value;
+     arrayind_t unused;
+{
+  sbrand (strtoul (value, (char **)NULL, 10));
+  if (subshell_environment)
+    seeded_subshell = 1;
+  return (self);
+}
+
+int
+get_random_number ()
+{
+  int rv;
+
+  /* Reset for command and process substitution. */
+  if (subshell_environment && seeded_subshell == 0)
+    {
+      sbrand (rseed + getpid() + NOW);
+      seeded_subshell = 1;
+    }
+
+  do
+    rv = brand ();
+  while (rv == last_random_value);
+  return rv;
+}
+
+static SHELL_VAR *
+get_random (var)
+     SHELL_VAR *var;
+{
+  int rv;
+  char *p;
+
+  rv = get_random_number ();
+  last_random_value = rv;
+  p = itos (rv);
+
+  FREE (value_cell (var));
+
+  VSETATTR (var, att_integer);
+  var_setvalue (var, p);
+  return (var);
+}
+
+static SHELL_VAR *
+assign_lineno (var, value, unused)
+     SHELL_VAR *var;
+     char *value;
+     arrayind_t unused;
+{
+  intmax_t new_value;
+
+  if (value == 0 || *value == '\0' || legal_number (value, &new_value) == 0)
+    new_value = 0;
+  line_number = new_value;
+  return var;
+}
+
+/* Function which returns the current line number. */
+static SHELL_VAR *
+get_lineno (var)
+     SHELL_VAR *var;
+{
+  char *p;
+  int ln;
+
+  ln = executing_line_number ();
+  p = itos (ln);
+  FREE (value_cell (var));
+  var_setvalue (var, p);
+  return (var);
+}
+
+static SHELL_VAR *
+assign_subshell (var, value, unused)
+     SHELL_VAR *var;
+     char *value;
+     arrayind_t unused;
+{
+  intmax_t new_value;
+
+  if (value == 0 || *value == '\0' || legal_number (value, &new_value) == 0)
+    new_value = 0;
+  subshell_level = new_value;
+  return var;
+}
+
+static SHELL_VAR *
+get_subshell (var)
+     SHELL_VAR *var;
+{
+  char *p;
+
+  p = itos (subshell_level);
+  FREE (value_cell (var));
+  var_setvalue (var, p);
+  return (var);
+}
+
+static SHELL_VAR *
+get_bash_command (var)
+     SHELL_VAR *var;
+{
+  char *p;
+
+  
+  if (the_printed_command_except_trap)
+    p = savestring (the_printed_command_except_trap);
+  else
+    {
+      p = (char *)xmalloc (1);
+      p[0] = '\0';
+    }
+  FREE (value_cell (var));
+  var_setvalue (var, p);
+  return (var);
+}
+
+#if defined (HISTORY)
+static SHELL_VAR *
+get_histcmd (var)
+     SHELL_VAR *var;
+{
+  char *p;
+
+  p = itos (history_number ());
+  FREE (value_cell (var));
+  var_setvalue (var, p);
+  return (var);
+}
+#endif
+
+#if defined (READLINE)
+/* When this function returns, VAR->value points to malloced memory. */
+static SHELL_VAR *
+get_comp_wordbreaks (var)
+     SHELL_VAR *var;
+{
+  /* If we don't have anything yet, assign a default value. */
+  if (rl_completer_word_break_characters == 0 && bash_readline_initialized == 0)
+    enable_hostname_completion (perform_hostname_completion);
+
+  var_setvalue (var, rl_completer_word_break_characters);
+
+  return (var);
+}
+
+/* When this function returns, rl_completer_word_break_characters points to
+   malloced memory. */
+static SHELL_VAR *
+assign_comp_wordbreaks (self, value, unused)
+     SHELL_VAR *self;
+     char *value;
+     arrayind_t unused;
+{
+  if (rl_completer_word_break_characters &&
+      rl_completer_word_break_characters != rl_basic_word_break_characters)
+    free (rl_completer_word_break_characters);
+
+  rl_completer_word_break_characters = savestring (value);
+  return self;
+}
+#endif /* READLINE */
+
+#if defined (PUSHD_AND_POPD) && defined (ARRAY_VARS)
+static SHELL_VAR *
+assign_dirstack (self, value, ind)
+     SHELL_VAR *self;
+     char *value;
+     arrayind_t ind;
+{
+  set_dirstack_element (ind, 1, value);
+  return self;
+}
+
+static SHELL_VAR *
+get_dirstack (self)
+     SHELL_VAR *self;
+{
+  ARRAY *a;
+  WORD_LIST *l;
+
+  l = get_directory_stack (0);
+  a = array_from_word_list (l);
+  array_dispose (array_cell (self));
+  dispose_words (l);
+  var_setarray (self, a);
+  return self;
+}
+#endif /* PUSHD AND POPD && ARRAY_VARS */
+
+#if defined (ARRAY_VARS)
+/* We don't want to initialize the group set with a call to getgroups()
+   unless we're asked to, but we only want to do it once. */
+static SHELL_VAR *
+get_groupset (self)
+     SHELL_VAR *self;
+{
+  register int i;
+  int ng;
+  ARRAY *a;
+  static char **group_set = (char **)NULL;
+
+  if (group_set == 0)
+    {
+      group_set = get_group_list (&ng);
+      a = array_cell (self);
+      for (i = 0; i < ng; i++)
+       array_insert (a, i, group_set[i]);
+    }
+  return (self);
+}
+#endif /* ARRAY_VARS */
+
+/* If ARRAY_VARS is not defined, this just returns the name of any
+   currently-executing function.  If we have arrays, it's a call stack. */
+static SHELL_VAR *
+get_funcname (self)
+     SHELL_VAR *self;
+{
+#if ! defined (ARRAY_VARS)
+  char *t;
+  if (variable_context && this_shell_function)
+    {
+      FREE (value_cell (self));
+      t = savestring (this_shell_function->name);
+      var_setvalue (self, t);
+    }
+#endif
+  return (self);
+}
+
+void
+make_funcname_visible (on_or_off)
+     int on_or_off;
+{
+  SHELL_VAR *v;
+
+  v = find_variable ("FUNCNAME");
+  if (v == 0 || v->dynamic_value == 0)
+    return;
+
+  if (on_or_off)
+    VUNSETATTR (v, att_invisible);
+  else
+    VSETATTR (v, att_invisible);
+}
+
+static SHELL_VAR *
+init_funcname_var ()
+{
+  SHELL_VAR *v;
+
+  v = find_variable ("FUNCNAME");
+  if (v)
+    return v;
+#if defined (ARRAY_VARS)
+  INIT_DYNAMIC_ARRAY_VAR ("FUNCNAME", get_funcname, null_array_assign);
+#else
+  INIT_DYNAMIC_VAR ("FUNCNAME", (char *)NULL, get_funcname, null_assign);
+#endif
+  VSETATTR (v, att_invisible|att_noassign);
+  return v;
+}
+
+static void
+initialize_dynamic_variables ()
+{
+  SHELL_VAR *v;
+
+  v = init_seconds_var ();
+
+  INIT_DYNAMIC_VAR ("BASH_COMMAND", (char *)NULL, get_bash_command, (sh_var_assign_func_t *)NULL);
+  INIT_DYNAMIC_VAR ("BASH_SUBSHELL", (char *)NULL, get_subshell, assign_subshell);
+
+  INIT_DYNAMIC_VAR ("RANDOM", (char *)NULL, get_random, assign_random);
+  VSETATTR (v, att_integer);
+  INIT_DYNAMIC_VAR ("LINENO", (char *)NULL, get_lineno, assign_lineno);
+  VSETATTR (v, att_integer);
+
+#if defined (HISTORY)
+  INIT_DYNAMIC_VAR ("HISTCMD", (char *)NULL, get_histcmd, (sh_var_assign_func_t *)NULL);
+  VSETATTR (v, att_integer);
+#endif
+
+#if defined (READLINE)
+  INIT_DYNAMIC_VAR ("COMP_WORDBREAKS", (char *)NULL, get_comp_wordbreaks, assign_comp_wordbreaks);
+#endif
+
+#if defined (PUSHD_AND_POPD) && defined (ARRAY_VARS)
+  v = init_dynamic_array_var ("DIRSTACK", get_dirstack, assign_dirstack, 0);
+#endif /* PUSHD_AND_POPD && ARRAY_VARS */
+
+#if defined (ARRAY_VARS)
+  v = init_dynamic_array_var ("GROUPS", get_groupset, null_array_assign, att_noassign);
+
+#  if defined (DEBUGGER)
+  v = init_dynamic_array_var ("BASH_ARGC", get_self, null_array_assign, att_noassign|att_nounset);
+  v = init_dynamic_array_var ("BASH_ARGV", get_self, null_array_assign, att_noassign|att_nounset);
+#  endif /* DEBUGGER */
+  v = init_dynamic_array_var ("BASH_SOURCE", get_self, null_array_assign, att_noassign|att_nounset);
+  v = init_dynamic_array_var ("BASH_LINENO", get_self, null_array_assign, att_noassign|att_nounset);
+#endif
+
+  v = init_funcname_var ();
+}
+
+/* **************************************************************** */
+/*                                                                 */
+/*             Retrieving variables and values                     */
+/*                                                                 */
+/* **************************************************************** */
+
+/* How to get a pointer to the shell variable or function named NAME.
+   HASHED_VARS is a pointer to the hash table containing the list
+   of interest (either variables or functions). */
+
+static SHELL_VAR *
+hash_lookup (name, hashed_vars)
+     const char *name;
+     HASH_TABLE *hashed_vars;
+{
+  BUCKET_CONTENTS *bucket;
+
+  bucket = hash_search (name, hashed_vars, 0);
+  return (bucket ? (SHELL_VAR *)bucket->data : (SHELL_VAR *)NULL);
+}
+
+SHELL_VAR *
+var_lookup (name, vcontext)
+     const char *name;
+     VAR_CONTEXT *vcontext;
+{
+  VAR_CONTEXT *vc;
+  SHELL_VAR *v;
+
+  v = (SHELL_VAR *)NULL;
+  for (vc = vcontext; vc; vc = vc->down)
+    if (v = hash_lookup (name, vc->table))
+      break;
+
+  return v;
+}
+
+/* Look up the variable entry named NAME.  If SEARCH_TEMPENV is non-zero,
+   then also search the temporarily built list of exported variables.
+   The lookup order is:
+       temporary_env
+        shell_variables list
+*/
+
+SHELL_VAR *
+find_variable_internal (name, force_tempenv)
+     const char *name;
+     int force_tempenv;
+{
+  SHELL_VAR *var;
+  int search_tempenv;
+
+  var = (SHELL_VAR *)NULL;
+
+  /* If explicitly requested, first look in the temporary environment for
+     the variable.  This allows constructs such as "foo=x eval 'echo $foo'"
+     to get the `exported' value of $foo.  This happens if we are executing
+     a function or builtin, or if we are looking up a variable in a
+     "subshell environment". */
+  search_tempenv = force_tempenv || (expanding_redir == 0 && subshell_environment);
+
+  if (search_tempenv && temporary_env)         
+    var = hash_lookup (name, temporary_env);
+
+  if (var == 0)
+    var = var_lookup (name, shell_variables);
+
+  if (var == 0)
+    return ((SHELL_VAR *)NULL);
+
+  return (var->dynamic_value ? (*(var->dynamic_value)) (var) : var);
+}
+
+/* Look up the variable entry named NAME.  Returns the entry or NULL. */
+SHELL_VAR *
+find_variable (name)
+     const char *name;
+{
+  return (find_variable_internal (name, (expanding_redir == 0 && this_shell_builtin != 0)));
+}
+
+/* Look up the function entry whose name matches STRING.
+   Returns the entry or NULL. */
+SHELL_VAR *
+find_function (name)
+     const char *name;
+{
+  return (hash_lookup (name, shell_functions));
+}
+
+/* Find the function definition for the shell function named NAME.  Returns
+   the entry or NULL. */
+FUNCTION_DEF *
+find_function_def (name)
+     const char *name;
+{
+  return ((FUNCTION_DEF *)hash_lookup (name, shell_function_defs));
+}
+
+/* Return the value of VAR.  VAR is assumed to have been the result of a
+   lookup without any subscript, if arrays are compiled into the shell. */
+char *
+get_variable_value (var)
+     SHELL_VAR *var;
+{
+  if (var == 0)
+    return ((char *)NULL);
+#if defined (ARRAY_VARS)
+  else if (array_p (var))
+    return (array_reference (array_cell (var), 0));
+#endif
+  else
+    return (value_cell (var));
+}
+
+/* Return the string value of a variable.  Return NULL if the variable
+   doesn't exist.  Don't cons a new string.  This is a potential memory
+   leak if the variable is found in the temporary environment.  Since
+   functions and variables have separate name spaces, returns NULL if
+   var_name is a shell function only. */
+char *
+get_string_value (var_name)
+     const char *var_name;
+{
+  SHELL_VAR *var;
+
+  var = find_variable (var_name);
+  return ((var) ? get_variable_value (var) : (char *)NULL);
+}
+
+/* This is present for use by the tilde and readline libraries. */
+char *
+sh_get_env_value (v)
+     const char *v;
+{
+  return get_string_value (v);
+}
+
+/* **************************************************************** */
+/*                                                                 */
+/*               Creating and setting variables                    */
+/*                                                                 */
+/* **************************************************************** */
+
+/* Set NAME to VALUE if NAME has no value. */
+SHELL_VAR *
+set_if_not (name, value)
+     char *name, *value;
+{
+  SHELL_VAR *v;
+
+  if (shell_variables == 0)
+    create_variable_tables ();
+
+  v = find_variable (name);
+  if (v == 0)
+    v = bind_variable_internal (name, value, global_variables->table, HASH_NOSRCH, 0);
+  return (v);
+}
+
+/* Create a local variable referenced by NAME. */
+SHELL_VAR *
+make_local_variable (name)
+     const char *name;
+{
+  SHELL_VAR *new_var, *old_var;
+  VAR_CONTEXT *vc;
+  int was_tmpvar;
+  char *tmp_value;
+
+  /* local foo; local foo;  is a no-op. */
+  old_var = find_variable (name);
+  if (old_var && local_p (old_var) && old_var->context == variable_context)
+    {
+      VUNSETATTR (old_var, att_invisible);
+      return (old_var);
+    }
+
+  was_tmpvar = old_var && tempvar_p (old_var);
+  if (was_tmpvar)
+    tmp_value = value_cell (old_var);
+
+  for (vc = shell_variables; vc; vc = vc->down)
+    if (vc_isfuncenv (vc) && vc->scope == variable_context)
+      break;
+
+  if (vc == 0)
+    {
+      internal_error (_("make_local_variable: no function context at current scope"));
+      return ((SHELL_VAR *)NULL);
+    }
+  else if (vc->table == 0)
+    vc->table = hash_create (TEMPENV_HASH_BUCKETS);
+
+  /* Since this is called only from the local/declare/typeset code, we can
+     call builtin_error here without worry (of course, it will also work
+     for anything that sets this_command_name).  Variables with the `noassign'
+     attribute may not be made local.  The test against old_var's context
+     level is to disallow local copies of readonly global variables (since I
+     believe that this could be a security hole).  Readonly copies of calling
+     function local variables are OK. */
+  if (old_var && (noassign_p (old_var) ||
+                (readonly_p (old_var) && old_var->context == 0)))
+    {
+      if (readonly_p (old_var))
+       sh_readonly (name);
+      return ((SHELL_VAR *)NULL);
+    }
+
+  if (old_var == 0)
+    new_var = bind_variable_internal (name, "", vc->table, HASH_NOSRCH, 0);
+  else
+    {
+      new_var = make_new_variable (name, vc->table);
+
+      /* If we found this variable in one of the temporary environments,
+        inherit its value.  Watch to see if this causes problems with
+        things like `x=4 local x'. */
+      if (was_tmpvar)
+        var_setvalue (new_var, savestring (tmp_value));
+
+      new_var->attributes = exported_p (old_var) ? att_exported : 0;
+    }
+
+  vc->flags |= VC_HASLOCAL;
+
+  new_var->context = variable_context;
+  VSETATTR (new_var, att_local);
+
+  if (ifsname (name))
+    setifs (new_var);
+
+  return (new_var);
+}
+
+#if defined (ARRAY_VARS)
+SHELL_VAR *
+make_local_array_variable (name)
+     char *name;
+{
+  SHELL_VAR *var;
+  ARRAY *array;
+
+  var = make_local_variable (name);
+  if (var == 0 || array_p (var))
+    return var;
+
+  array = array_create ();
+
+  FREE (value_cell(var));
+  var_setarray (var, array);
+  VSETATTR (var, att_array);
+  return var;
+}
+#endif /* ARRAY_VARS */
+
+/* Create a new shell variable with name NAME. */
+static SHELL_VAR *
+new_shell_variable (name)
+     const char *name;
+{
+  SHELL_VAR *entry;
+
+  entry = (SHELL_VAR *)xmalloc (sizeof (SHELL_VAR));
+
+  entry->name = savestring (name);
+  var_setvalue (entry, (char *)NULL);
+  CLEAR_EXPORTSTR (entry);
+
+  entry->dynamic_value = (sh_var_value_func_t *)NULL;
+  entry->assign_func = (sh_var_assign_func_t *)NULL;
+
+  entry->attributes = 0;
+
+  /* Always assume variables are to be made at toplevel!
+     make_local_variable has the responsibilty of changing the
+     variable context. */
+  entry->context = 0;
+
+  return (entry);
+}
+
+/* Create a new shell variable with name NAME and add it to the hash table
+   TABLE. */
+static SHELL_VAR *
+make_new_variable (name, table)
+     const char *name;
+     HASH_TABLE *table;
+{
+  SHELL_VAR *entry;
+  BUCKET_CONTENTS *elt;
+
+  entry = new_shell_variable (name);
+
+  /* Make sure we have a shell_variables hash table to add to. */
+  if (shell_variables == 0)
+    create_variable_tables ();
+
+  elt = hash_insert (savestring (name), table, HASH_NOSRCH);
+  elt->data = (PTR_T)entry;
+
+  return entry;
+}
+
+#if defined (ARRAY_VARS)
+SHELL_VAR *
+make_new_array_variable (name)
+     char *name;
+{
+  SHELL_VAR *entry;
+  ARRAY *array;
+
+  entry = make_new_variable (name, global_variables->table);
+  array = array_create ();
+  var_setarray (entry, array);
+  VSETATTR (entry, att_array);
+  return entry;
+}
+#endif
+
+char *
+make_variable_value (var, value, flags)
+     SHELL_VAR *var;
+     char *value;
+     int flags;
+{
+  char *retval, *oval;
+  intmax_t lval, rval;
+  int expok, olen;
+
+  /* If this variable has had its type set to integer (via `declare -i'),
+     then do expression evaluation on it and store the result.  The
+     functions in expr.c (evalexp()) and bind_int_variable() are responsible
+     for turning off the integer flag if they don't want further
+     evaluation done. */
+  if (integer_p (var))
+    {
+      if (flags & ASS_APPEND)
+       {
+         oval = value_cell (var);
+         lval = evalexp (oval, &expok);        /* ksh93 seems to do this */
+         if (expok == 0)
+           jump_to_top_level (DISCARD);
+       }
+      rval = evalexp (value, &expok);
+      if (expok == 0)
+       jump_to_top_level (DISCARD);
+      if (flags & ASS_APPEND)
+       rval += lval;
+      retval = itos (rval);
+    }
+  else if (value)
+    {
+      if (flags & ASS_APPEND)
+       {
+         oval = get_variable_value (var);
+         if (oval == 0)        /* paranoia */
+           oval = "";
+         olen = STRLEN (oval);
+         retval = (char *)xmalloc (olen + (value ? STRLEN (value) : 0) + 1);
+         strcpy (retval, oval);
+         if (value)
+           strcpy (retval+olen, value);
+       }
+      else if (*value)
+       retval = savestring (value);
+      else
+       {
+         retval = (char *)xmalloc (1);
+         retval[0] = '\0';
+       }
+    }
+  else
+    retval = (char *)NULL;
+
+  return retval;
+}
+
+/* Bind a variable NAME to VALUE in the HASH_TABLE TABLE, which may be the
+   temporary environment (but usually is not). */
+static SHELL_VAR *
+bind_variable_internal (name, value, table, hflags, aflags)
+     const char *name;
+     char *value;
+     HASH_TABLE *table;
+     int hflags, aflags;
+{
+  char *newval;
+  SHELL_VAR *entry;
+
+  entry = (hflags & HASH_NOSRCH) ? (SHELL_VAR *)NULL : hash_lookup (name, table);
+
+  if (entry == 0)
+    {
+      entry = make_new_variable (name, table);
+      var_setvalue (entry, make_variable_value (entry, value, 0)); /* XXX */
+    }
+  else if (entry->assign_func) /* array vars have assign functions now */
+    {
+      INVALIDATE_EXPORTSTR (entry);
+      newval = (aflags & ASS_APPEND) ? make_variable_value (entry, value, aflags) : value;
+      entry = (*(entry->assign_func)) (entry, newval, -1);
+      if (newval != value)
+        free (newval);
+      return (entry);
+    }
+  else
+    {
+      if (readonly_p (entry) || noassign_p (entry))
+       {
+         if (readonly_p (entry))
+           err_readonly (name);
+         return (entry);
+       }
+
+      /* Variables which are bound are visible. */
+      VUNSETATTR (entry, att_invisible);
+
+      newval = make_variable_value (entry, value, aflags);     /* XXX */
+
+      /* Invalidate any cached export string */
+      INVALIDATE_EXPORTSTR (entry);
+
+#if defined (ARRAY_VARS)
+      /* XXX -- this bears looking at again -- XXX */
+      /* If an existing array variable x is being assigned to with x=b or
+        `read x' or something of that nature, silently convert it to
+        x[0]=b or `read x[0]'. */
+      if (array_p (entry))
+       {
+         array_insert (array_cell (entry), 0, newval);
+         free (newval);
+       }
+      else
+#endif
+       {
+         FREE (value_cell (entry));
+         var_setvalue (entry, newval);
+       }
+    }
+
+  if (mark_modified_vars)
+    VSETATTR (entry, att_exported);
+
+  if (exported_p (entry))
+    array_needs_making = 1;
+
+  return (entry);
+}
+       
+/* Bind a variable NAME to VALUE.  This conses up the name
+   and value strings.  If we have a temporary environment, we bind there
+   first, then we bind into shell_variables. */
+
+SHELL_VAR *
+bind_variable (name, value, flags)
+     const char *name;
+     char *value;
+     int flags;
+{
+  SHELL_VAR *v;
+  VAR_CONTEXT *vc;
+
+  if (shell_variables == 0)
+    create_variable_tables ();
+
+  /* If we have a temporary environment, look there first for the variable,
+     and, if found, modify the value there before modifying it in the
+     shell_variables table.  This allows sourced scripts to modify values
+     given to them in a temporary environment while modifying the variable
+     value that the caller sees. */
+  if (temporary_env)
+    bind_tempenv_variable (name, value);
+
+  /* XXX -- handle local variables here. */
+  for (vc = shell_variables; vc; vc = vc->down)
+    {
+      if (vc_isfuncenv (vc) || vc_isbltnenv (vc))
+        {
+          v = hash_lookup (name, vc->table);
+          if (v)
+           return (bind_variable_internal (name, value, vc->table, 0, flags));
+        }
+    }
+  return (bind_variable_internal (name, value, global_variables->table, 0, flags));
+}
+
+/* Make VAR, a simple shell variable, have value VALUE.  Once assigned a
+   value, variables are no longer invisible.  This is a duplicate of part
+   of the internals of bind_variable.  If the variable is exported, or
+   all modified variables should be exported, mark the variable for export
+   and note that the export environment needs to be recreated. */
+SHELL_VAR *
+bind_variable_value (var, value, aflags)
+     SHELL_VAR *var;
+     char *value;
+     int aflags;
+{
+  char *t;
+
+  VUNSETATTR (var, att_invisible);
+
+  if (var->assign_func)
+    {
+      /* If we're appending, we need the old value, so use
+        make_variable_value */
+      t = (aflags & ASS_APPEND) ? make_variable_value (var, value, aflags) : value;
+      (*(var->assign_func)) (var, t, -1);
+      if (t != value && t)
+       free (t);      
+    }
+  else
+    {
+      t = make_variable_value (var, value, aflags);
+      FREE (value_cell (var));
+      var_setvalue (var, t);
+    }
+
+  INVALIDATE_EXPORTSTR (var);
+
+  if (mark_modified_vars)
+    VSETATTR (var, att_exported);
+
+  if (exported_p (var))
+    array_needs_making = 1;
+
+  return (var);
+}
+
+/* Bind/create a shell variable with the name LHS to the RHS.
+   This creates or modifies a variable such that it is an integer.
+
+   This used to be in expr.c, but it is here so that all of the
+   variable binding stuff is localized.  Since we don't want any
+   recursive evaluation from bind_variable() (possible without this code,
+   since bind_variable() calls the evaluator for variables with the integer
+   attribute set), we temporarily turn off the integer attribute for each
+   variable we set here, then turn it back on after binding as necessary. */
+
+SHELL_VAR *
+bind_int_variable (lhs, rhs)
+     char *lhs, *rhs;
+{
+  register SHELL_VAR *v;
+  int isint, isarr;
+
+  isint = isarr = 0;
+#if defined (ARRAY_VARS)
+  if (valid_array_reference (lhs))
+    {
+      isarr = 1;
+      v = array_variable_part (lhs, (char **)0, (int *)0);
+    }
+  else
+#endif
+    v = find_variable (lhs);
+
+  if (v)
+    {
+      isint = integer_p (v);
+      VUNSETATTR (v, att_integer);
+    }
+
+#if defined (ARRAY_VARS)
+  if (isarr)
+    v = assign_array_element (lhs, rhs, 0);
+  else
+#endif
+    v = bind_variable (lhs, rhs, 0);
+
+  if (isint)
+    VSETATTR (v, att_integer);
+
+  return (v);
+}
+
+SHELL_VAR *
+bind_var_to_int (var, val)
+     char *var;
+     intmax_t val;
+{
+  char ibuf[INT_STRLEN_BOUND (intmax_t) + 1], *p;
+
+  p = fmtulong (val, 10, ibuf, sizeof (ibuf), 0);
+  return (bind_int_variable (var, p));
+}
+
+/* Do a function binding to a variable.  You pass the name and
+   the command to bind to.  This conses the name and command. */
+SHELL_VAR *
+bind_function (name, value)
+     const char *name;
+     COMMAND *value;
+{
+  SHELL_VAR *entry;
+
+  entry = find_function (name);
+  if (entry == 0)
+    {
+      BUCKET_CONTENTS *elt;
+
+      elt = hash_insert (savestring (name), shell_functions, HASH_NOSRCH);
+      entry = new_shell_variable (name);
+      elt->data = (PTR_T)entry;
+    }
+  else
+    INVALIDATE_EXPORTSTR (entry);
+
+  if (var_isset (entry))
+    dispose_command (function_cell (entry));
+
+  if (value)
+    var_setfunc (entry, copy_command (value));
+  else
+    var_setfunc (entry, 0);
+
+  VSETATTR (entry, att_function);
+
+  if (mark_modified_vars)
+    VSETATTR (entry, att_exported);
+
+  VUNSETATTR (entry, att_invisible);           /* Just to be sure */
+
+  if (exported_p (entry))
+    array_needs_making = 1;
+
+#if defined (PROGRAMMABLE_COMPLETION)
+  set_itemlist_dirty (&it_functions);
+#endif
+
+  return (entry);
+}
+
+/* Bind a function definition, which includes source file and line number
+   information in addition to the command, into the FUNCTION_DEF hash table.*/
+void
+bind_function_def (name, value)
+     const char *name;
+     FUNCTION_DEF *value;
+{
+  FUNCTION_DEF *entry;
+  BUCKET_CONTENTS *elt;
+  COMMAND *cmd;
+
+  entry = find_function_def (name);
+  if (entry)
+    {
+      dispose_function_def_contents (entry);
+      entry = copy_function_def_contents (value, entry);
+    }
+  else
+    {
+      cmd = value->command;
+      value->command = 0;
+      entry = copy_function_def (value);
+      value->command = cmd;
+
+      elt = hash_insert (savestring (name), shell_function_defs, HASH_NOSRCH);
+      elt->data = (PTR_T *)entry;
+    }
+}
+
+/* Add STRING, which is of the form foo=bar, to the temporary environment
+   HASH_TABLE (temporary_env).  The functions in execute_cmd.c are
+   responsible for moving the main temporary env to one of the other
+   temporary environments.  The expansion code in subst.c calls this. */
+int
+assign_in_env (word)
+     WORD_DESC *word;
+{
+  int offset;
+  char *name, *temp, *value;
+  SHELL_VAR *var;
+  const char *string;
+
+  string = word->word;
+
+  offset = assignment (string, 0);
+  name = savestring (string);
+  value = (char *)NULL;
+
+  if (name[offset] == '=')
+    {
+      name[offset] = 0;
+
+      /* ignore the `+' when assigning temporary environment */
+      if (name[offset - 1] == '+')
+       name[offset - 1] = '\0';
+
+      var = find_variable (name);
+      if (var && (readonly_p (var) || noassign_p (var)))
+       {
+         if (readonly_p (var))
+           err_readonly (name);
+         free (name);
+         return (0);
+       }
+
+      temp = name + offset + 1;
+#if 0
+      temp = (xstrchr (temp, '~') != 0) ? bash_tilde_expand (temp, 1) : savestring (temp);
+      value = expand_string_unsplit_to_string (temp, 0);
+      free (temp);
+#else
+      value = expand_assignment_string_to_string (temp, 0);
+#endif
+    }
+
+  if (temporary_env == 0)
+    temporary_env = hash_create (TEMPENV_HASH_BUCKETS);
+
+  var = hash_lookup (name, temporary_env);
+  if (var == 0)
+    var = make_new_variable (name, temporary_env);
+  else
+    FREE (value_cell (var));
+
+  if (value == 0)
+    {
+      value = (char *)xmalloc (1);     /* like do_assignment_internal */
+      value[0] = '\0';
+    }
+
+  var_setvalue (var, value);
+  var->attributes |= (att_exported|att_tempvar);
+  var->context = variable_context;     /* XXX */
+
+  INVALIDATE_EXPORTSTR (var);
+  var->exportstr = mk_env_string (name, value);
+
+  array_needs_making = 1;
+
+  if (ifsname (name))
+    setifs (var);
+
+  if (echo_command_at_execute)
+    /* The Korn shell prints the `+ ' in front of assignment statements,
+       so we do too. */
+    xtrace_print_assignment (name, value, 0, 1);
+
+  free (name);
+  return 1;
+}
+
+/* **************************************************************** */
+/*                                                                 */
+/*                     Copying variables                           */
+/*                                                                 */
+/* **************************************************************** */
+
+#ifdef INCLUDE_UNUSED
+/* Copy VAR to a new data structure and return that structure. */
+SHELL_VAR *
+copy_variable (var)
+     SHELL_VAR *var;
+{
+  SHELL_VAR *copy = (SHELL_VAR *)NULL;
+
+  if (var)
+    {
+      copy = (SHELL_VAR *)xmalloc (sizeof (SHELL_VAR));
+
+      copy->attributes = var->attributes;
+      copy->name = savestring (var->name);
+
+      if (function_p (var))
+       var_setfunc (copy, copy_command (function_cell (var)));
+#if defined (ARRAY_VARS)
+      else if (array_p (var))
+       var_setarray (copy, dup_array (array_cell (var)));
+#endif
+      else if (value_cell (var))
+       var_setvalue (copy, savestring (value_cell (var)));
+      else
+       var_setvalue (copy, (char *)NULL);
+
+      copy->dynamic_value = var->dynamic_value;
+      copy->assign_func = var->assign_func;
+
+      copy->exportstr = COPY_EXPORTSTR (var);
+
+      copy->context = var->context;
+    }
+  return (copy);
+}
+#endif
+
+/* **************************************************************** */
+/*                                                                 */
+/*               Deleting and unsetting variables                  */
+/*                                                                 */
+/* **************************************************************** */
+
+/* Dispose of the information attached to VAR. */
+void
+dispose_variable (var)
+     SHELL_VAR *var;
+{
+  if (var == 0)
+    return;
+
+  if (function_p (var))
+    dispose_command (function_cell (var));
+#if defined (ARRAY_VARS)
+  else if (array_p (var))
+    array_dispose (array_cell (var));
+#endif
+  else
+    FREE (value_cell (var));
+
+  FREE_EXPORTSTR (var);
+
+  free (var->name);
+
+  if (exported_p (var))
+    array_needs_making = 1;
+
+  free (var);
+}
+
+/* Unset the shell variable referenced by NAME. */
+int
+unbind_variable (name)
+     const char *name;
+{
+  return makunbound (name, shell_variables);
+}
+
+/* Unset the shell function named NAME. */
+int
+unbind_func (name)
+     const char *name;
+{
+  BUCKET_CONTENTS *elt;
+  SHELL_VAR *func;
+
+  elt = hash_remove (name, shell_functions, 0);
+
+  if (elt == 0)
+    return -1;
+
+#if defined (PROGRAMMABLE_COMPLETION)
+  set_itemlist_dirty (&it_functions);
+#endif
+
+  func = (SHELL_VAR *)elt->data;
+  if (func)
+    {
+      if (exported_p (func))
+       array_needs_making++;
+      dispose_variable (func);
+    }
+
+  free (elt->key);
+  free (elt);
+
+  return 0;  
+}
+
+int
+unbind_function_def (name)
+     const char *name;
+{
+  BUCKET_CONTENTS *elt;
+  FUNCTION_DEF *funcdef;
+
+  elt = hash_remove (name, shell_function_defs, 0);
+
+  if (elt == 0)
+    return -1;
+
+  funcdef = (FUNCTION_DEF *)elt->data;
+  if (funcdef)
+    dispose_function_def (funcdef);
+
+  free (elt->key);
+  free (elt);
+
+  return 0;  
+}
+
+/* Make the variable associated with NAME go away.  HASH_LIST is the
+   hash table from which this variable should be deleted (either
+   shell_variables or shell_functions).
+   Returns non-zero if the variable couldn't be found. */
+int
+makunbound (name, vc)
+     const char *name;
+     VAR_CONTEXT *vc;
+{
+  BUCKET_CONTENTS *elt, *new_elt;
+  SHELL_VAR *old_var;
+  VAR_CONTEXT *v;
+  char *t;
+
+  for (elt = (BUCKET_CONTENTS *)NULL, v = vc; v; v = v->down)
+    if (elt = hash_remove (name, v->table, 0))
+      break;
+
+  if (elt == 0)
+    return (-1);
+
+  old_var = (SHELL_VAR *)elt->data;
+
+  if (old_var && exported_p (old_var))
+    array_needs_making++;
+
+  /* If we're unsetting a local variable and we're still executing inside
+     the function, just mark the variable as invisible.  The function
+     eventually called by pop_var_context() will clean it up later.  This
+     must be done so that if the variable is subsequently assigned a new
+     value inside the function, the `local' attribute is still present.
+     We also need to add it back into the correct hash table. */
+  if (old_var && local_p (old_var) && variable_context == old_var->context)
+    {
+#if defined (ARRAY_VARS)
+      if (array_p (old_var))
+       array_dispose (array_cell (old_var));
+      else
+#endif
+       FREE (value_cell (old_var));
+      /* Reset the attributes.  Preserve the export attribute if the variable
+         came from a temporary environment.  Make sure it stays local, and
+         make it invisible. */ 
+      old_var->attributes = (exported_p (old_var) && tempvar_p (old_var)) ? att_exported : 0;
+      VSETATTR (old_var, att_local);
+      VSETATTR (old_var, att_invisible);
+      var_setvalue (old_var, (char *)NULL);
+      INVALIDATE_EXPORTSTR (old_var);
+
+      new_elt = hash_insert (savestring (old_var->name), v->table, 0);
+      new_elt->data = (PTR_T)old_var;
+      stupidly_hack_special_variables (old_var->name);
+
+      free (elt->key);
+      free (elt);
+      return (0);
+    }
+
+  /* Have to save a copy of name here, because it might refer to
+     old_var->name.  If so, stupidly_hack_special_variables will
+     reference freed memory. */
+  t = savestring (name);
+
+  free (elt->key);
+  free (elt);
+
+  dispose_variable (old_var);
+  stupidly_hack_special_variables (t);
+  free (t);
+
+  return (0);
+}
+
+/* Get rid of all of the variables in the current context. */
+void
+kill_all_local_variables ()
+{
+  VAR_CONTEXT *vc;
+
+  for (vc = shell_variables; vc; vc = vc->down)
+    if (vc_isfuncenv (vc) && vc->scope == variable_context)
+      break;
+  if (vc == 0)
+    return;            /* XXX */
+
+  if (vc->table && vc_haslocals (vc))
+    {
+      delete_all_variables (vc->table);
+      hash_dispose (vc->table);
+    }
+  vc->table = (HASH_TABLE *)NULL;
+}
+
+static void
+free_variable_hash_data (data)
+     PTR_T data;
+{
+  SHELL_VAR *var;
+
+  var = (SHELL_VAR *)data;
+  dispose_variable (var);
+}
+
+/* Delete the entire contents of the hash table. */
+void
+delete_all_variables (hashed_vars)
+     HASH_TABLE *hashed_vars;
+{
+  hash_flush (hashed_vars, free_variable_hash_data);
+}
+
+/* **************************************************************** */
+/*                                                                 */
+/*                  Setting variable attributes                    */
+/*                                                                 */
+/* **************************************************************** */
+
+#define FIND_OR_MAKE_VARIABLE(name, entry) \
+  do \
+    { \
+      entry = find_variable (name); \
+      if (!entry) \
+       { \
+         entry = bind_variable (name, "", 0); \
+         if (!no_invisible_vars) entry->attributes |= att_invisible; \
+       } \
+    } \
+  while (0)
+
+/* Make the variable associated with NAME be readonly.
+   If NAME does not exist yet, create it. */
+void
+set_var_read_only (name)
+     char *name;
+{
+  SHELL_VAR *entry;
+
+  FIND_OR_MAKE_VARIABLE (name, entry);
+  VSETATTR (entry, att_readonly);
+}
+
+#ifdef INCLUDE_UNUSED
+/* Make the function associated with NAME be readonly.
+   If NAME does not exist, we just punt, like auto_export code below. */
+void
+set_func_read_only (name)
+     const char *name;
+{
+  SHELL_VAR *entry;
+
+  entry = find_function (name);
+  if (entry)
+    VSETATTR (entry, att_readonly);
+}
+
+/* Make the variable associated with NAME be auto-exported.
+   If NAME does not exist yet, create it. */
+void
+set_var_auto_export (name)
+     char *name;
+{
+  SHELL_VAR *entry;
+
+  FIND_OR_MAKE_VARIABLE (name, entry);
+  set_auto_export (entry);
+}
+
+/* Make the function associated with NAME be auto-exported. */
+void
+set_func_auto_export (name)
+     const char *name;
+{
+  SHELL_VAR *entry;
+
+  entry = find_function (name);
+  if (entry)
+    set_auto_export (entry);
+}
+#endif
+
+/* **************************************************************** */
+/*                                                                 */
+/*                  Creating lists of variables                    */
+/*                                                                 */
+/* **************************************************************** */
+
+static VARLIST *
+vlist_alloc (nentries)
+     int nentries;
+{
+  VARLIST  *vlist;
+
+  vlist = (VARLIST *)xmalloc (sizeof (VARLIST));
+  vlist->list = (SHELL_VAR **)xmalloc ((nentries + 1) * sizeof (SHELL_VAR *));
+  vlist->list_size = nentries;
+  vlist->list_len = 0;
+  vlist->list[0] = (SHELL_VAR *)NULL;
+
+  return vlist;
+}
+
+static VARLIST *
+vlist_realloc (vlist, n)
+     VARLIST *vlist;
+     int n;
+{
+  if (vlist == 0)
+    return (vlist = vlist_alloc (n));
+  if (n > vlist->list_size)
+    {
+      vlist->list_size = n;
+      vlist->list = (SHELL_VAR **)xrealloc (vlist->list, (vlist->list_size + 1) * sizeof (SHELL_VAR *));
+    }
+  return vlist;
+}
+
+static void
+vlist_add (vlist, var, flags)
+     VARLIST *vlist;
+     SHELL_VAR *var;
+     int flags;
+{
+  register int i;
+
+  for (i = 0; i < vlist->list_len; i++)
+    if (STREQ (var->name, vlist->list[i]->name))
+      break;
+  if (i < vlist->list_len)
+    return;
+
+  if (i >= vlist->list_size)
+    vlist = vlist_realloc (vlist, vlist->list_size + 16);
+
+  vlist->list[vlist->list_len++] = var;
+  vlist->list[vlist->list_len] = (SHELL_VAR *)NULL;
+}
+
+/* Map FUNCTION over the variables in VAR_HASH_TABLE.  Return an array of the
+   variables for which FUNCTION returns a non-zero value.  A NULL value
+   for FUNCTION means to use all variables. */
+SHELL_VAR **
+map_over (function, vc)
+     sh_var_map_func_t *function;
+     VAR_CONTEXT *vc;
+{
+  VAR_CONTEXT *v;
+  VARLIST *vlist;
+  SHELL_VAR **ret;
+  int nentries;
+
+  for (nentries = 0, v = vc; v; v = v->down)
+    nentries += HASH_ENTRIES (v->table);
+
+  if (nentries == 0)
+    return (SHELL_VAR **)NULL;
+
+  vlist = vlist_alloc (nentries);
+
+  for (v = vc; v; v = v->down)
+    flatten (v->table, function, vlist, 0);
+
+  ret = vlist->list;
+  free (vlist);
+  return ret;
+}
+
+SHELL_VAR **
+map_over_funcs (function)
+     sh_var_map_func_t *function;
+{
+  VARLIST *vlist;
+  SHELL_VAR **ret;
+
+  if (shell_functions == 0 || HASH_ENTRIES (shell_functions) == 0)
+    return ((SHELL_VAR **)NULL);
+
+  vlist = vlist_alloc (HASH_ENTRIES (shell_functions));
+
+  flatten (shell_functions, function, vlist, 0);
+
+  ret = vlist->list;
+  free (vlist);
+  return ret;
+}
+
+/* Flatten VAR_HASH_TABLE, applying FUNC to each member and adding those
+   elements for which FUNC succeeds to VLIST->list.  FLAGS is reserved
+   for future use.  Only unique names are added to VLIST.  If FUNC is
+   NULL, each variable in VAR_HASH_TABLE is added to VLIST.  If VLIST is
+   NULL, FUNC is applied to each SHELL_VAR in VAR_HASH_TABLE.  If VLIST
+   and FUNC are both NULL, nothing happens. */
+static void
+flatten (var_hash_table, func, vlist, flags)
+     HASH_TABLE *var_hash_table;
+     sh_var_map_func_t *func;
+     VARLIST *vlist;
+     int flags;
+{
+  register int i;
+  register BUCKET_CONTENTS *tlist;
+  int r;
+  SHELL_VAR *var;
+
+  if (var_hash_table == 0 || (HASH_ENTRIES (var_hash_table) == 0) || (vlist == 0 && func == 0))
+    return;
+
+  for (i = 0; i < var_hash_table->nbuckets; i++)
+    {
+      for (tlist = hash_items (i, var_hash_table); tlist; tlist = tlist->next)
+       {
+         var = (SHELL_VAR *)tlist->data;
+
+         r = func ? (*func) (var) : 1;
+         if (r && vlist)
+           vlist_add (vlist, var, flags);
+       }
+    }
+}
+
+void
+sort_variables (array)
+     SHELL_VAR **array;
+{
+  qsort (array, strvec_len ((char **)array), sizeof (SHELL_VAR *), (QSFUNC *)qsort_var_comp);
+}
+
+static int
+qsort_var_comp (var1, var2)
+     SHELL_VAR **var1, **var2;
+{
+  int result;
+
+  if ((result = (*var1)->name[0] - (*var2)->name[0]) == 0)
+    result = strcmp ((*var1)->name, (*var2)->name);
+
+  return (result);
+}
+
+/* Apply FUNC to each variable in SHELL_VARIABLES, adding each one for
+   which FUNC succeeds to an array of SHELL_VAR *s.  Returns the array. */
+static SHELL_VAR **
+vapply (func)
+     sh_var_map_func_t *func;
+{
+  SHELL_VAR **list;
+
+  list = map_over (func, shell_variables);
+  if (list /* && posixly_correct */)
+    sort_variables (list);
+  return (list);
+}
+
+/* Apply FUNC to each variable in SHELL_FUNCTIONS, adding each one for
+   which FUNC succeeds to an array of SHELL_VAR *s.  Returns the array. */
+static SHELL_VAR **
+fapply (func)
+     sh_var_map_func_t *func;
+{
+  SHELL_VAR **list;
+
+  list = map_over_funcs (func);
+  if (list /* && posixly_correct */)
+    sort_variables (list);
+  return (list);
+}
+
+/* Create a NULL terminated array of all the shell variables. */
+SHELL_VAR **
+all_shell_variables ()
+{
+  return (vapply ((sh_var_map_func_t *)NULL));
+}
+
+/* Create a NULL terminated array of all the shell functions. */
+SHELL_VAR **
+all_shell_functions ()
+{
+  return (fapply ((sh_var_map_func_t *)NULL));
+}
+
+static int
+visible_var (var)
+     SHELL_VAR *var;
+{
+  return (invisible_p (var) == 0);
+}
+
+SHELL_VAR **
+all_visible_functions ()
+{
+  return (fapply (visible_var));
+}
+
+SHELL_VAR **
+all_visible_variables ()
+{
+  return (vapply (visible_var));
+}
+
+/* Return non-zero if the variable VAR is visible and exported.  Array
+   variables cannot be exported. */
+static int
+visible_and_exported (var)
+     SHELL_VAR *var;
+{
+  return (invisible_p (var) == 0 && exported_p (var));
+}
+
+/* Return non-zero if VAR is a local variable in the current context and
+   is exported. */
+static int
+local_and_exported (var)
+     SHELL_VAR *var;
+{
+  return (invisible_p (var) == 0 && local_p (var) && var->context == variable_context && exported_p (var));
+}
+
+SHELL_VAR **
+all_exported_variables ()
+{
+  return (vapply (visible_and_exported));
+}
+
+SHELL_VAR **
+local_exported_variables ()
+{
+  return (vapply (local_and_exported));
+}
+
+static int
+variable_in_context (var)
+     SHELL_VAR *var;
+{
+  return (invisible_p (var) == 0 && local_p (var) && var->context == variable_context);
+}
+
+SHELL_VAR **
+all_local_variables ()
+{
+  VARLIST *vlist;
+  SHELL_VAR **ret;
+  VAR_CONTEXT *vc;
+
+  vc = shell_variables;
+  for (vc = shell_variables; vc; vc = vc->down)
+    if (vc_isfuncenv (vc) && vc->scope == variable_context)
+      break;
+
+  if (vc == 0)
+    {
+      internal_error (_("all_local_variables: no function context at current scope"));
+      return (SHELL_VAR **)NULL;
+    }
+  if (vc->table == 0 || HASH_ENTRIES (vc->table) == 0 || vc_haslocals (vc) == 0)
+    return (SHELL_VAR **)NULL;
+    
+  vlist = vlist_alloc (HASH_ENTRIES (vc->table));
+
+  flatten (vc->table, variable_in_context, vlist, 0);
+
+  ret = vlist->list;
+  free (vlist);
+  if (ret)
+    sort_variables (ret);
+  return ret;
+}
+
+#if defined (ARRAY_VARS)
+/* Return non-zero if the variable VAR is visible and an array. */
+static int
+visible_array_vars (var)
+     SHELL_VAR *var;
+{
+  return (invisible_p (var) == 0 && array_p (var));
+}
+
+SHELL_VAR **
+all_array_variables ()
+{
+  return (vapply (visible_array_vars));
+}
+#endif /* ARRAY_VARS */
+
+char **
+all_variables_matching_prefix (prefix)
+     const char *prefix;
+{
+  SHELL_VAR **varlist;
+  char **rlist;
+  int vind, rind, plen;
+
+  plen = STRLEN (prefix);
+  varlist = all_visible_variables ();
+  for (vind = 0; varlist && varlist[vind]; vind++)
+    ;
+  if (varlist == 0 || vind == 0)
+    return ((char **)NULL);
+  rlist = strvec_create (vind + 1);
+  for (vind = rind = 0; varlist[vind]; vind++)
+    {
+      if (plen == 0 || STREQN (prefix, varlist[vind]->name, plen))
+       rlist[rind++] = savestring (varlist[vind]->name);
+    }
+  rlist[rind] = (char *)0;
+  free (varlist);
+
+  return rlist;
+}
+
+/* **************************************************************** */
+/*                                                                 */
+/*              Managing temporary variable scopes                 */
+/*                                                                 */
+/* **************************************************************** */
+
+/* Make variable NAME have VALUE in the temporary environment. */
+static SHELL_VAR *
+bind_tempenv_variable (name, value)
+     const char *name;
+     char *value;
+{
+  SHELL_VAR *var;
+
+  var = temporary_env ? hash_lookup (name, temporary_env) : (SHELL_VAR *)NULL;
+
+  if (var)
+    {
+      FREE (value_cell (var));
+      var_setvalue (var, savestring (value));
+      INVALIDATE_EXPORTSTR (var);
+    }
+
+  return (var);
+}
+
+/* Find a variable in the temporary environment that is named NAME.
+   Return the SHELL_VAR *, or NULL if not found. */
+SHELL_VAR *
+find_tempenv_variable (name)
+     const char *name;
+{
+  return (temporary_env ? hash_lookup (name, temporary_env) : (SHELL_VAR *)NULL);
+}
+
+/* Push the variable described by (SHELL_VAR *)DATA down to the next
+   variable context from the temporary environment. */
+static void
+push_temp_var (data)
+     PTR_T data;
+{
+  SHELL_VAR *var, *v;
+  HASH_TABLE *binding_table;
+
+  var = (SHELL_VAR *)data;
+
+  binding_table = shell_variables->table;
+  if (binding_table == 0)
+    {
+      if (shell_variables == global_variables)
+       /* shouldn't happen */
+       binding_table = shell_variables->table = global_variables->table = hash_create (0);
+      else
+       binding_table = shell_variables->table = hash_create (TEMPENV_HASH_BUCKETS);
+    }
+
+  v = bind_variable_internal (var->name, value_cell (var), binding_table, 0, 0);
+
+  /* XXX - should we set the context here?  It shouldn't matter because of how
+     assign_in_env works, but might want to check. */
+  if (binding_table == global_variables->table)                /* XXX */
+    var->attributes &= ~(att_tempvar|att_propagate);
+  else
+    {
+      var->attributes |= att_propagate;
+      if  (binding_table == shell_variables->table)
+       shell_variables->flags |= VC_HASTMPVAR;
+    }
+  v->attributes |= var->attributes;
+
+  dispose_variable (var);
+}
+
+static void
+propagate_temp_var (data)
+     PTR_T data;
+{
+  SHELL_VAR *var;
+
+  var = (SHELL_VAR *)data;
+  if (tempvar_p (var) && (var->attributes & att_propagate))
+    push_temp_var (data);
+  else
+    dispose_variable (var);
+}
+
+/* Free the storage used in the hash table for temporary
+   environment variables.  PUSHF is a function to be called
+   to free each hash table entry.  It takes care of pushing variables
+   to previous scopes if appropriate. */
+static void
+dispose_temporary_env (pushf)
+     sh_free_func_t *pushf;
+{
+  hash_flush (temporary_env, pushf);
+  hash_dispose (temporary_env);
+  temporary_env  = (HASH_TABLE *)NULL;
+
+  array_needs_making = 1;
+
+  sv_ifs ("IFS");              /* XXX here for now */
+}
+
+void
+dispose_used_env_vars ()
+{
+  if (temporary_env)
+    {
+      dispose_temporary_env (propagate_temp_var);
+      maybe_make_export_env ();
+    }
+}
+
+/* Take all of the shell variables in the temporary environment HASH_TABLE
+   and make shell variables from them at the current variable context. */
+void
+merge_temporary_env ()
+{
+  if (temporary_env)
+    dispose_temporary_env (push_temp_var);
+}
+
+/* **************************************************************** */
+/*                                                                 */
+/*          Creating and manipulating the environment              */
+/*                                                                 */
+/* **************************************************************** */
+
+static inline char *
+mk_env_string (name, value)
+     const char *name, *value;
+{
+  int name_len, value_len;
+  char *p;
+
+  name_len = strlen (name);
+  value_len = STRLEN (value);
+  p = (char *)xmalloc (2 + name_len + value_len);
+  strcpy (p, name);
+  p[name_len] = '=';
+  if (value && *value)
+    strcpy (p + name_len + 1, value);
+  else
+    p[name_len + 1] = '\0';
+  return (p);
+}
+
+#ifdef DEBUG
+/* Debugging */
+static int
+valid_exportstr (v)
+     SHELL_VAR *v;
+{
+  char *s;
+
+  s = v->exportstr;
+  if (legal_variable_starter ((unsigned char)*s) == 0)
+    {
+      internal_error (_("invalid character %d in exportstr for %s"), *s, v->name);
+      return (0);
+    }
+  for (s = v->exportstr + 1; s && *s; s++)
+    {
+      if (*s == '=')
+       break;
+      if (legal_variable_char ((unsigned char)*s) == 0)
+       {
+         internal_error (_("invalid character %d in exportstr for %s"), *s, v->name);
+         return (0);
+       }
+    }
+  if (*s != '=')
+    {
+      internal_error (_("no `=' in exportstr for %s"), v->name);
+      return (0);
+    }
+  return (1);
+}
+#endif
+
+static char **
+make_env_array_from_var_list (vars)
+     SHELL_VAR **vars;
+{
+  register int i, list_index;
+  register SHELL_VAR *var;
+  char **list, *value;
+
+  list = strvec_create ((1 + strvec_len ((char **)vars)));
+
+#define USE_EXPORTSTR (value == var->exportstr)
+
+  for (i = 0, list_index = 0; var = vars[i]; i++)
+    {
+#if defined (__CYGWIN__)
+      /* We don't use the exportstr stuff on Cygwin at all. */
+      INVALIDATE_EXPORTSTR (var);
+#endif
+      if (var->exportstr)
+       value = var->exportstr;
+      else if (function_p (var))
+       value = named_function_string ((char *)NULL, function_cell (var), 0);
+#if defined (ARRAY_VARS)
+      else if (array_p (var))
+#  if 0
+       value = array_to_assignment_string (array_cell (var));
+#  else
+       continue;       /* XXX array vars cannot yet be exported */
+#  endif
+#endif
+      else
+       value = value_cell (var);
+
+      if (value)
+       {
+         /* Gee, I'd like to get away with not using savestring() if we're
+            using the cached exportstr... */
+         list[list_index] = USE_EXPORTSTR ? savestring (value)
+                                          : mk_env_string (var->name, value);
+
+         if (USE_EXPORTSTR == 0)
+           SAVE_EXPORTSTR (var, list[list_index]);
+
+         list_index++;
+#undef USE_EXPORTSTR
+
+#if 0  /* not yet */
+#if defined (ARRAY_VARS)
+         if (array_p (var))
+           free (value);
+#endif
+#endif
+       }
+    }
+
+  list[list_index] = (char *)NULL;
+  return (list);
+}
+
+/* Make an array of assignment statements from the hash table
+   HASHED_VARS which contains SHELL_VARs.  Only visible, exported
+   variables are eligible. */
+static char **
+make_var_export_array (vcxt)
+     VAR_CONTEXT *vcxt;
+{
+  char **list;
+  SHELL_VAR **vars;
+
+  vars = map_over (visible_and_exported, vcxt);
+
+  if (vars == 0)
+    return (char **)NULL;
+
+  list = make_env_array_from_var_list (vars);
+
+  free (vars);
+  return (list);
+}
+
+static char **
+make_func_export_array ()
+{
+  char **list;
+  SHELL_VAR **vars;
+
+  vars = map_over_funcs (visible_and_exported);
+  if (vars == 0)
+    return (char **)NULL;
+
+  list = make_env_array_from_var_list (vars);
+
+  free (vars);
+  return (list);
+}
+
+/* Add ENVSTR to the end of the exported environment, EXPORT_ENV. */
+#define add_to_export_env(envstr,do_alloc) \
+do \
+  { \
+    if (export_env_index >= (export_env_size - 1)) \
+      { \
+       export_env_size += 16; \
+       export_env = strvec_resize (export_env, export_env_size); \
+       environ = export_env; \
+      } \
+    export_env[export_env_index++] = (do_alloc) ? savestring (envstr) : envstr; \
+    export_env[export_env_index] = (char *)NULL; \
+  } while (0)
+
+/* Add ASSIGN to EXPORT_ENV, or supercede a previous assignment in the
+   array with the same left-hand side.  Return the new EXPORT_ENV. */
+char **
+add_or_supercede_exported_var (assign, do_alloc)
+     char *assign;
+     int do_alloc;
+{
+  register int i;
+  int equal_offset;
+
+  equal_offset = assignment (assign, 0);
+  if (equal_offset == 0)
+    return (export_env);
+
+  /* If this is a function, then only supersede the function definition.
+     We do this by including the `=() {' in the comparison, like
+     initialize_shell_variables does. */
+  if (assign[equal_offset + 1] == '(' &&
+     strncmp (assign + equal_offset + 2, ") {", 3) == 0)               /* } */
+    equal_offset += 4;
+
+  for (i = 0; i < export_env_index; i++)
+    {
+      if (STREQN (assign, export_env[i], equal_offset + 1))
+       {
+         free (export_env[i]);
+         export_env[i] = do_alloc ? savestring (assign) : assign;
+         return (export_env);
+       }
+    }
+  add_to_export_env (assign, do_alloc);
+  return (export_env);
+}
+
+static void
+add_temp_array_to_env (temp_array, do_alloc, do_supercede)
+     char **temp_array;
+     int do_alloc, do_supercede;
+{
+  register int i;
+
+  if (temp_array == 0)
+    return;
+
+  for (i = 0; temp_array[i]; i++)
+    {
+      if (do_supercede)
+       export_env = add_or_supercede_exported_var (temp_array[i], do_alloc);
+      else
+       add_to_export_env (temp_array[i], do_alloc);
+    }
+
+  free (temp_array);
+}
+
+/* Make the environment array for the command about to be executed, if the
+   array needs making.  Otherwise, do nothing.  If a shell action could
+   change the array that commands receive for their environment, then the
+   code should `array_needs_making++'.
+
+   The order to add to the array is:
+       temporary_env
+       list of var contexts whose head is shell_variables
+       shell_functions
+
+  This is the shell variable lookup order.  We add only new variable
+  names at each step, which allows local variables and variables in
+  the temporary environments to shadow variables in the global (or
+  any previous) scope.
+*/
+
+static int
+n_shell_variables ()
+{
+  VAR_CONTEXT *vc;
+  int n;
+
+  for (n = 0, vc = shell_variables; vc; vc = vc->down)
+    n += HASH_ENTRIES (vc->table);
+  return n;
+}
+
+void
+maybe_make_export_env ()
+{
+  register char **temp_array;
+  int new_size;
+  VAR_CONTEXT *tcxt;
+
+  if (array_needs_making)
+    {
+      if (export_env)
+        strvec_flush (export_env);
+
+      /* Make a guess based on how many shell variables and functions we
+        have.  Since there will always be array variables, and array
+        variables are not (yet) exported, this will always be big enough
+        for the exported variables and functions. */
+      new_size = n_shell_variables () + HASH_ENTRIES (shell_functions) + 1 +
+                HASH_ENTRIES (temporary_env);
+      if (new_size > export_env_size)
+       {
+         export_env_size = new_size;
+         export_env = strvec_resize (export_env, export_env_size);
+         environ = export_env;
+       }
+      export_env[export_env_index = 0] = (char *)NULL;
+
+      /* Make a dummy variable context from the  temporary_env, stick it on
+         the front of shell_variables, call make_var_export_array on the
+         whole thing to flatten it, and convert the list of SHELL_VAR *s
+         to the form needed by the environment. */
+      if (temporary_env)
+        {
+          tcxt = new_var_context ((char *)NULL, 0);
+          tcxt->table = temporary_env;
+          tcxt->down = shell_variables;
+        }
+      else
+        tcxt = shell_variables;
+      
+      temp_array = make_var_export_array (tcxt);
+      if (temp_array)
+       add_temp_array_to_env (temp_array, 0, 0);
+
+      if (tcxt != shell_variables)
+        free (tcxt);
+
+#if defined (RESTRICTED_SHELL)
+      /* Restricted shells may not export shell functions. */
+      temp_array = restricted ? (char **)0 : make_func_export_array ();
+#else
+      temp_array = make_func_export_array ();
+#endif
+      if (temp_array)
+       add_temp_array_to_env (temp_array, 0, 0);
+
+      array_needs_making = 0;
+    }
+}
+
+/* This is an efficiency hack.  PWD and OLDPWD are auto-exported, so
+   we will need to remake the exported environment every time we
+   change directories.  `_' is always put into the environment for
+   every external command, so without special treatment it will always
+   cause the environment to be remade.
+
+   If there is no other reason to make the exported environment, we can
+   just update the variables in place and mark the exported environment
+   as no longer needing a remake. */
+void
+update_export_env_inplace (env_prefix, preflen, value)
+     char *env_prefix;
+     int preflen;
+     char *value;
+{
+  char *evar;
+
+  evar = (char *)xmalloc (STRLEN (value) + preflen + 1);
+  strcpy (evar, env_prefix);
+  if (value)
+    strcpy (evar + preflen, value);
+  export_env = add_or_supercede_exported_var (evar, 0);
+}
+
+/* We always put _ in the environment as the name of this command. */
+void
+put_command_name_into_env (command_name)
+     char *command_name;
+{
+  update_export_env_inplace ("_=", 2, command_name);
+}
+
+#if 0  /* UNUSED -- it caused too many problems */
+void
+put_gnu_argv_flags_into_env (pid, flags_string)
+     intmax_t pid;
+     char *flags_string;
+{
+  char *dummy, *pbuf;
+  int l, fl;
+
+  pbuf = itos (pid);
+  l = strlen (pbuf);
+
+  fl = strlen (flags_string);
+
+  dummy = (char *)xmalloc (l + fl + 30);
+  dummy[0] = '_';
+  strcpy (dummy + 1, pbuf);
+  strcpy (dummy + 1 + l, "_GNU_nonoption_argv_flags_");
+  dummy[l + 27] = '=';
+  strcpy (dummy + l + 28, flags_string);
+
+  free (pbuf);
+
+  export_env = add_or_supercede_exported_var (dummy, 0);
+}
+#endif
+
+/* **************************************************************** */
+/*                                                                 */
+/*                   Managing variable contexts                    */
+/*                                                                 */
+/* **************************************************************** */
+
+/* Allocate and return a new variable context with NAME and FLAGS.
+   NAME can be NULL. */
+
+VAR_CONTEXT *
+new_var_context (name, flags)
+     char *name;
+     int flags;
+{
+  VAR_CONTEXT *vc;
+
+  vc = (VAR_CONTEXT *)xmalloc (sizeof (VAR_CONTEXT));
+  vc->name = name ? savestring (name) : (char *)NULL;
+  vc->scope = variable_context;
+  vc->flags = flags;
+
+  vc->up = vc->down = (VAR_CONTEXT *)NULL;
+  vc->table = (HASH_TABLE *)NULL;
+
+  return vc;
+}
+
+/* Free a variable context and its data, including the hash table.  Dispose
+   all of the variables. */
+void
+dispose_var_context (vc)
+     VAR_CONTEXT *vc;
+{
+  FREE (vc->name);
+
+  if (vc->table)
+    {
+      delete_all_variables (vc->table);
+      hash_dispose (vc->table);
+    }
+
+  free (vc);
+}
+
+/* Set VAR's scope level to the current variable context. */
+static int
+set_context (var)
+     SHELL_VAR *var;
+{
+  return (var->context = variable_context);
+}
+
+/* Make a new variable context with NAME and FLAGS and a HASH_TABLE of
+   temporary variables, and push it onto shell_variables.  This is
+   for shell functions. */
+VAR_CONTEXT *
+push_var_context (name, flags, tempvars)
+     char *name;
+     int flags;
+     HASH_TABLE *tempvars;
+{
+  VAR_CONTEXT *vc;
+
+  vc = new_var_context (name, flags);
+  vc->table = tempvars;
+  if (tempvars)
+    {
+      /* Have to do this because the temp environment was created before
+        variable_context was incremented. */
+      flatten (tempvars, set_context, (VARLIST *)NULL, 0);
+      vc->flags |= VC_HASTMPVAR;
+    }
+  vc->down = shell_variables;
+  shell_variables->up = vc;
+
+  return (shell_variables = vc);
+}
+
+static void
+push_func_var (data)
+     PTR_T data;
+{
+  SHELL_VAR *var, *v;
+
+  var = (SHELL_VAR *)data;
+
+  if (tempvar_p (var) && (posixly_correct || (var->attributes & att_propagate)))
+    {
+      /* XXX - should we set v->context here? */
+      v = bind_variable_internal (var->name, value_cell (var), shell_variables->table, 0, 0);
+      if (shell_variables == global_variables)
+       var->attributes &= ~(att_tempvar|att_propagate);
+      else
+        shell_variables->flags |= VC_HASTMPVAR;
+      v->attributes |= var->attributes;
+    }
+
+  dispose_variable (var);
+}
+
+/* Pop the top context off of VCXT and dispose of it, returning the rest of
+   the stack. */
+void
+pop_var_context ()
+{
+  VAR_CONTEXT *ret, *vcxt;
+
+  vcxt = shell_variables;
+  if (vc_isfuncenv (vcxt) == 0)
+    {
+      internal_error (_("pop_var_context: head of shell_variables not a function context"));
+      return;
+    }
+
+  if (ret = vcxt->down)
+    {
+      ret->up = (VAR_CONTEXT *)NULL;
+      shell_variables = ret;
+      if (vcxt->table)
+       hash_flush (vcxt->table, push_func_var);
+      dispose_var_context (vcxt);
+    }
+  else
+    internal_error (_("pop_var_context: no global_variables context"));
+}
+
+/* Delete the HASH_TABLEs for all variable contexts beginning at VCXT, and
+   all of the VAR_CONTEXTs except GLOBAL_VARIABLES. */
+void
+delete_all_contexts (vcxt)
+     VAR_CONTEXT *vcxt;
+{
+  VAR_CONTEXT *v, *t;
+
+  for (v = vcxt; v != global_variables; v = t)
+    {
+      t = v->down;
+      dispose_var_context (v);
+    }            
+
+  delete_all_variables (global_variables->table);
+  shell_variables = global_variables;
+}
+
+/* **************************************************************** */
+/*                                                                 */
+/*        Pushing and Popping temporary variable scopes            */
+/*                                                                 */
+/* **************************************************************** */
+
+VAR_CONTEXT *
+push_scope (flags, tmpvars)
+     int flags;
+     HASH_TABLE *tmpvars;
+{
+  return (push_var_context ((char *)NULL, flags, tmpvars));
+}
+
+static void
+push_exported_var (data)
+     PTR_T data;
+{
+  SHELL_VAR *var, *v;
+
+  var = (SHELL_VAR *)data;
+
+  /* If a temp var had its export attribute set, or it's marked to be
+     propagated, bind it in the previous scope before disposing it. */
+  /* XXX - This isn't exactly right, because all tempenv variables have the
+    export attribute set. */
+#if 0
+  if (exported_p (var) || (var->attributes & att_propagate))
+#else
+  if (tempvar_p (var) && exported_p (var) && (var->attributes & att_propagate))
+#endif
+    {
+      var->attributes &= ~att_tempvar;         /* XXX */
+      v = bind_variable_internal (var->name, value_cell (var), shell_variables->table, 0, 0);
+      if (shell_variables == global_variables)
+       var->attributes &= ~att_propagate;
+      v->attributes |= var->attributes;
+    }
+
+  dispose_variable (var);
+}
+
+void
+pop_scope (is_special)
+     int is_special;
+{
+  VAR_CONTEXT *vcxt, *ret;
+
+  vcxt = shell_variables;
+  if (vc_istempscope (vcxt) == 0)
+    {
+      internal_error (_("pop_scope: head of shell_variables not a temporary environment scope"));
+      return;
+    }
+
+  ret = vcxt->down;
+  if (ret)
+    ret->up = (VAR_CONTEXT *)NULL;
+
+  shell_variables = ret;
+
+  /* Now we can take care of merging variables in VCXT into set of scopes
+     whose head is RET (shell_variables). */
+  FREE (vcxt->name);
+  if (vcxt->table)
+    {
+      if (is_special)
+       hash_flush (vcxt->table, push_func_var);
+      else
+       hash_flush (vcxt->table, push_exported_var);
+      hash_dispose (vcxt->table);
+    }
+  free (vcxt);
+
+  sv_ifs ("IFS");      /* XXX here for now */
+}
+
+/* **************************************************************** */
+/*                                                                 */
+/*              Pushing and Popping function contexts              */
+/*                                                                 */
+/* **************************************************************** */
+
+static WORD_LIST **dollar_arg_stack = (WORD_LIST **)NULL;
+static int dollar_arg_stack_slots;
+static int dollar_arg_stack_index;
+
+/* XXX - we might want to consider pushing and popping the `getopts' state
+   when we modify the positional parameters. */
+void
+push_context (name, is_subshell, tempvars)
+     char *name;       /* function name */
+     int is_subshell;
+     HASH_TABLE *tempvars;
+{
+  if (is_subshell == 0)
+    push_dollar_vars ();
+  variable_context++;
+  push_var_context (name, VC_FUNCENV, tempvars);
+}
+
+/* Only called when subshell == 0, so we don't need to check, and can
+   unconditionally pop the dollar vars off the stack. */
+void
+pop_context ()
+{
+  pop_dollar_vars ();
+  variable_context--;
+  pop_var_context ();
+
+  sv_ifs ("IFS");              /* XXX here for now */
+}
+
+/* Save the existing positional parameters on a stack. */
+void
+push_dollar_vars ()
+{
+  if (dollar_arg_stack_index + 2 > dollar_arg_stack_slots)
+    {
+      dollar_arg_stack = (WORD_LIST **)
+       xrealloc (dollar_arg_stack, (dollar_arg_stack_slots += 10)
+                 * sizeof (WORD_LIST **));
+    }
+  dollar_arg_stack[dollar_arg_stack_index++] = list_rest_of_args ();
+  dollar_arg_stack[dollar_arg_stack_index] = (WORD_LIST *)NULL;
+}
+
+/* Restore the positional parameters from our stack. */
+void
+pop_dollar_vars ()
+{
+  if (!dollar_arg_stack || dollar_arg_stack_index == 0)
+    return;
+
+  remember_args (dollar_arg_stack[--dollar_arg_stack_index], 1);
+  dispose_words (dollar_arg_stack[dollar_arg_stack_index]);
+  dollar_arg_stack[dollar_arg_stack_index] = (WORD_LIST *)NULL;
+  set_dollar_vars_unchanged ();
+}
+
+void
+dispose_saved_dollar_vars ()
+{
+  if (!dollar_arg_stack || dollar_arg_stack_index == 0)
+    return;
+
+  dispose_words (dollar_arg_stack[dollar_arg_stack_index]);
+  dollar_arg_stack[dollar_arg_stack_index] = (WORD_LIST *)NULL;
+}
+
+/* Manipulate the special BASH_ARGV and BASH_ARGC variables. */
+
+void
+push_args (list)
+     WORD_LIST *list;
+{
+#if defined (ARRAY_VARS) && defined (DEBUGGER)
+  SHELL_VAR *bash_argv_v, *bash_argc_v;
+  ARRAY *bash_argv_a, *bash_argc_a;
+  WORD_LIST *l;
+  arrayind_t i;
+  char *t;
+
+  GET_ARRAY_FROM_VAR ("BASH_ARGV", bash_argv_v, bash_argv_a);
+  GET_ARRAY_FROM_VAR ("BASH_ARGC", bash_argc_v, bash_argc_a);
+
+  for (l = list, i = 0; l; l = l->next, i++)
+    array_push (bash_argv_a, l->word->word);
+
+  t = itos (i);
+  array_push (bash_argc_a, t);
+  free (t);
+#endif /* ARRAY_VARS && DEBUGGER */
+}
+
+/* Remove arguments from BASH_ARGV array.  Pop top element off BASH_ARGC
+   array and use that value as the count of elements to remove from
+   BASH_ARGV. */
+void
+pop_args ()
+{
+#if defined (ARRAY_VARS) && defined (DEBUGGER)
+  SHELL_VAR *bash_argv_v, *bash_argc_v;
+  ARRAY *bash_argv_a, *bash_argc_a;
+  ARRAY_ELEMENT *ce;
+  intmax_t i;
+
+  GET_ARRAY_FROM_VAR ("BASH_ARGV", bash_argv_v, bash_argv_a);
+  GET_ARRAY_FROM_VAR ("BASH_ARGC", bash_argc_v, bash_argc_a);
+
+  ce = array_shift (bash_argc_a, 1, 0);
+  if (ce == 0 || legal_number (element_value (ce), &i) == 0)
+    i = 0;
+
+  for ( ; i > 0; i--)
+    array_pop (bash_argv_a);
+  array_dispose_element (ce);
+#endif /* ARRAY_VARS && DEBUGGER */
+}
+
+/*************************************************
+ *                                              *
+ *     Functions to manage special variables    *
+ *                                              *
+ *************************************************/
+
+/* Extern declarations for variables this code has to manage. */
+extern int eof_encountered, eof_encountered_limit, ignoreeof;
+
+#if defined (READLINE)
+extern int hostname_list_initialized;
+#endif
+
+/* An alist of name.function for each special variable.  Most of the
+   functions don't do much, and in fact, this would be faster with a
+   switch statement, but by the end of this file, I am sick of switch
+   statements. */
+
+#define SET_INT_VAR(name, intvar)  intvar = find_variable (name) != 0
+
+/* This table will be sorted with qsort() the first time it's accessed. */
+struct name_and_function {
+  char *name;
+  sh_sv_func_t *function;
+};
+
+static struct name_and_function special_vars[] = {
+#if defined (READLINE)
+#  if defined (STRICT_POSIX)
+  { "COLUMNS", sv_winsize },
+#  endif
+  { "COMP_WORDBREAKS", sv_comp_wordbreaks },
+#endif
+
+  { "GLOBIGNORE", sv_globignore },
+
+#if defined (HISTORY)
+  { "HISTCONTROL", sv_history_control },
+  { "HISTFILESIZE", sv_histsize },
+  { "HISTIGNORE", sv_histignore },
+  { "HISTSIZE", sv_histsize },
+  { "HISTTIMEFORMAT", sv_histtimefmt },
+#endif
+
+#if defined (__CYGWIN__)
+  { "HOME", sv_home },
+#endif
+
+#if defined (READLINE)
+  { "HOSTFILE", sv_hostfile },
+#endif
+
+  { "IFS", sv_ifs },
+  { "IGNOREEOF", sv_ignoreeof },
+
+  { "LANG", sv_locale },
+  { "LC_ALL", sv_locale },
+  { "LC_COLLATE", sv_locale },
+  { "LC_CTYPE", sv_locale },
+  { "LC_MESSAGES", sv_locale },
+  { "LC_NUMERIC", sv_locale },
+  { "LC_TIME", sv_locale },
+
+#if defined (READLINE) && defined (STRICT_POSIX)
+  { "LINES", sv_winsize },
+#endif
+
+  { "MAIL", sv_mail },
+  { "MAILCHECK", sv_mail },
+  { "MAILPATH", sv_mail },
+
+  { "OPTERR", sv_opterr },
+  { "OPTIND", sv_optind },
+
+  { "PATH", sv_path },
+  { "POSIXLY_CORRECT", sv_strict_posix },
+
+#if defined (READLINE)
+  { "TERM", sv_terminal },
+  { "TERMCAP", sv_terminal },
+  { "TERMINFO", sv_terminal },
+#endif /* READLINE */
+
+  { "TEXTDOMAIN", sv_locale },
+  { "TEXTDOMAINDIR", sv_locale },
+
+#if defined (HAVE_TZSET) && defined (PROMPT_STRING_DECODE)
+  { "TZ", sv_tz },
+#endif
+
+#if defined (HISTORY) && defined (BANG_HISTORY)
+  { "histchars", sv_histchars },
+#endif /* HISTORY && BANG_HISTORY */
+
+  { "ignoreeof", sv_ignoreeof },
+
+  { (char *)0, (sh_sv_func_t *)0 }
+};
+
+#define N_SPECIAL_VARS (sizeof (special_vars) / sizeof (special_vars[0]) - 1)
+
+static int
+sv_compare (sv1, sv2)
+     struct name_and_function *sv1, *sv2;
+{
+  int r;
+
+  if ((r = sv1->name[0] - sv2->name[0]) == 0)
+    r = strcmp (sv1->name, sv2->name);
+  return r;
+}
+
+static inline int
+find_special_var (name)
+     const char *name;
+{
+  register int i, r;
+
+  for (i = 0; special_vars[i].name; i++)
+    {
+      r = special_vars[i].name[0] - name[0];
+      if (r == 0)
+       r = strcmp (special_vars[i].name, name);
+      if (r == 0)
+       return i;
+      else if (r > 0)
+       /* Can't match any of rest of elements in sorted list.  Take this out
+          if it causes problems in certain environments. */
+        break;
+    }
+  return -1;
+}
+
+/* The variable in NAME has just had its state changed.  Check to see if it
+   is one of the special ones where something special happens. */
+void
+stupidly_hack_special_variables (name)
+     char *name;
+{
+  static int sv_sorted = 0;
+  int i;
+
+  if (sv_sorted == 0)  /* shouldn't need, but it's fairly cheap. */
+    {
+      qsort (special_vars, N_SPECIAL_VARS, sizeof (special_vars[0]),
+               (QSFUNC *)sv_compare);
+      sv_sorted = 1;
+    }
+
+  i = find_special_var (name);
+  if (i != -1)
+    (*(special_vars[i].function)) (name);
+}
+
+void
+sv_ifs (name)
+     char *name;
+{
+  SHELL_VAR *v;
+
+  v = find_variable ("IFS");
+  setifs (v);
+}
+
+/* What to do just after the PATH variable has changed. */
+void
+sv_path (name)
+     char *name;
+{
+  /* hash -r */
+  phash_flush ();
+}
+
+/* What to do just after one of the MAILxxxx variables has changed.  NAME
+   is the name of the variable.  This is called with NAME set to one of
+   MAIL, MAILCHECK, or MAILPATH.  */
+void
+sv_mail (name)
+     char *name;
+{
+  /* If the time interval for checking the files has changed, then
+     reset the mail timer.  Otherwise, one of the pathname vars
+     to the users mailbox has changed, so rebuild the array of
+     filenames. */
+  if (name[4] == 'C')  /* if (strcmp (name, "MAILCHECK") == 0) */
+    reset_mail_timer ();
+  else
+    {
+      free_mail_files ();
+      remember_mail_dates ();
+    }
+}
+
+/* What to do when GLOBIGNORE changes. */
+void
+sv_globignore (name)
+     char *name;
+{
+  setup_glob_ignore (name);
+}
+
+#if defined (READLINE)
+void
+sv_comp_wordbreaks (name)
+     char *name;
+{
+  SHELL_VAR *sv;
+
+  sv = find_variable (name);
+  if (sv == 0)
+    rl_completer_word_break_characters = (char *)NULL;
+}
+
+/* What to do just after one of the TERMxxx variables has changed.
+   If we are an interactive shell, then try to reset the terminal
+   information in readline. */
+void
+sv_terminal (name)
+     char *name;
+{
+  if (interactive_shell && no_line_editing == 0)
+    rl_reset_terminal (get_string_value ("TERM"));
+}
+
+void
+sv_hostfile (name)
+     char *name;
+{
+  SHELL_VAR *v;
+
+  v = find_variable (name);
+  if (v == 0)
+    clear_hostname_list ();
+  else
+    hostname_list_initialized = 0;
+}
+
+#if defined (STRICT_POSIX)
+/* In strict posix mode, we allow assignments to LINES and COLUMNS (and values
+   found in the initial environment) to override the terminal size reported by
+   the kernel. */
+void
+sv_winsize (name)
+     char *name;
+{
+  SHELL_VAR *v;
+  intmax_t xd;
+  int d;
+
+  if (posixly_correct == 0 || interactive_shell == 0 || no_line_editing)
+    return;
+
+  v = find_variable (name);
+  if (v == 0 || var_isnull (v))
+    rl_reset_screen_size ();
+  else
+    {
+      if (legal_number (value_cell (v), &xd) == 0)
+       return;
+      winsize_assignment = winsize_assigned = 1;
+      d = xd;                  /* truncate */
+      if (name[0] == 'L')      /* LINES */
+       rl_set_screen_size (d, -1);
+      else                     /* COLUMNS */
+       rl_set_screen_size (-1, d);
+      winsize_assignment = 0;
+    }
+}
+#endif /* STRICT_POSIX */
+#endif /* READLINE */
+
+/* Update the value of HOME in the export environment so tilde expansion will
+   work on cygwin. */
+#if defined (__CYGWIN__)
+sv_home (name)
+     char *name;
+{
+  array_needs_making = 1;
+  maybe_make_export_env ();
+}
+#endif
+
+#if defined (HISTORY)
+/* What to do after the HISTSIZE or HISTFILESIZE variables change.
+   If there is a value for this HISTSIZE (and it is numeric), then stifle
+   the history.  Otherwise, if there is NO value for this variable,
+   unstifle the history.  If name is HISTFILESIZE, and its value is
+   numeric, truncate the history file to hold no more than that many
+   lines. */
+void
+sv_histsize (name)
+     char *name;
+{
+  char *temp;
+  intmax_t num;
+  int hmax;
+
+  temp = get_string_value (name);
+
+  if (temp && *temp)
+    {
+      if (legal_number (temp, &num))
+       {
+         hmax = num;
+         if (name[4] == 'S')
+           {
+             stifle_history (hmax);
+             hmax = where_history ();
+             if (history_lines_this_session > hmax)
+               history_lines_this_session = hmax;
+           }
+         else
+           {
+             history_truncate_file (get_string_value ("HISTFILE"), hmax);
+             if (hmax <= history_lines_in_file)
+               history_lines_in_file = hmax;
+           }
+       }
+    }
+  else if (name[4] == 'S')
+    unstifle_history ();
+}
+
+/* What to do after the HISTIGNORE variable changes. */
+void
+sv_histignore (name)
+     char *name;
+{
+  setup_history_ignore (name);
+}
+
+/* What to do after the HISTCONTROL variable changes. */
+void
+sv_history_control (name)
+     char *name;
+{
+  char *temp;
+  char *val;
+  int tptr;
+
+  history_control = 0;
+  temp = get_string_value (name);
+
+  if (temp == 0 || *temp == 0)
+    return;
+
+  tptr = 0;
+  while (val = extract_colon_unit (temp, &tptr))
+    {
+      if (STREQ (val, "ignorespace"))
+       history_control |= HC_IGNSPACE;
+      else if (STREQ (val, "ignoredups"))
+       history_control |= HC_IGNDUPS;
+      else if (STREQ (val, "ignoreboth"))
+       history_control |= HC_IGNBOTH;
+      else if (STREQ (val, "erasedups"))
+       history_control |= HC_ERASEDUPS;
+
+      free (val);
+    }
+}
+
+#if defined (BANG_HISTORY)
+/* Setting/unsetting of the history expansion character. */
+void
+sv_histchars (name)
+     char *name;
+{
+  char *temp;
+
+  temp = get_string_value (name);
+  if (temp)
+    {
+      history_expansion_char = *temp;
+      if (temp[0] && temp[1])
+       {
+         history_subst_char = temp[1];
+         if (temp[2])
+             history_comment_char = temp[2];
+       }
+    }
+  else
+    {
+      history_expansion_char = '!';
+      history_subst_char = '^';
+      history_comment_char = '#';
+    }
+}
+#endif /* BANG_HISTORY */
+
+void
+sv_histtimefmt (name)
+     char *name;
+{
+  SHELL_VAR *v;
+
+  v = find_variable (name);
+  history_write_timestamps = (v != 0);
+}
+#endif /* HISTORY */
+
+#if defined (HAVE_TZSET) && defined (PROMPT_STRING_DECODE)
+void
+sv_tz (name)
+     char *name;
+{
+  tzset ();
+}
+#endif
+
+/* If the variable exists, then the value of it can be the number
+   of times we actually ignore the EOF.  The default is small,
+   (smaller than csh, anyway). */
+void
+sv_ignoreeof (name)
+     char *name;
+{
+  SHELL_VAR *tmp_var;
+  char *temp;
+
+  eof_encountered = 0;
+
+  tmp_var = find_variable (name);
+  ignoreeof = tmp_var != 0;
+  temp = tmp_var ? value_cell (tmp_var) : (char *)NULL;
+  if (temp)
+    eof_encountered_limit = (*temp && all_digits (temp)) ? atoi (temp) : 10;
+  set_shellopts ();    /* make sure `ignoreeof' is/is not in $SHELLOPTS */
+}
+
+void
+sv_optind (name)
+     char *name;
+{
+  char *tt;
+  int s;
+
+  tt = get_string_value ("OPTIND");
+  if (tt && *tt)
+    {
+      s = atoi (tt);
+
+      /* According to POSIX, setting OPTIND=1 resets the internal state
+        of getopt (). */
+      if (s < 0 || s == 1)
+       s = 0;
+    }
+  else
+    s = 0;
+  getopts_reset (s);
+}
+
+void
+sv_opterr (name)
+     char *name;
+{
+  char *tt;
+
+  tt = get_string_value ("OPTERR");
+  sh_opterr = (tt && *tt) ? atoi (tt) : 1;
+}
+
+void
+sv_strict_posix (name)
+     char *name;
+{
+  SET_INT_VAR (name, posixly_correct);
+  posix_initialize (posixly_correct);
+#if defined (READLINE)
+  if (interactive_shell)
+    posix_readline_initialize (posixly_correct);
+#endif /* READLINE */
+  set_shellopts ();    /* make sure `posix' is/is not in $SHELLOPTS */
+}
+
+void
+sv_locale (name)
+     char *name;
+{
+  char *v;
+
+  v = get_string_value (name);
+  if (name[0] == 'L' && name[1] == 'A')        /* LANG */
+    set_lang (name, v);
+  else
+    set_locale_var (name, v);          /* LC_*, TEXTDOMAIN* */
+}
+
+#if defined (ARRAY_VARS)
+void
+set_pipestatus_array (ps, nproc)
+     int *ps;
+     int nproc;
+{
+  SHELL_VAR *v;
+  ARRAY *a;
+  ARRAY_ELEMENT *ae;
+  register int i;
+  char *t, tbuf[INT_STRLEN_BOUND(int) + 1];
+
+  v = find_variable ("PIPESTATUS");
+  if (v == 0)
+    v = make_new_array_variable ("PIPESTATUS");
+  if (array_p (v) == 0)
+    return;            /* Do nothing if not an array variable. */
+  a = array_cell (v);
+
+  if (a == 0 || array_num_elements (a) == 0)
+    {
+      for (i = 0; i < nproc; i++)      /* was ps[i] != -1, not i < nproc */
+       {
+         t = inttostr (ps[i], tbuf, sizeof (tbuf));
+         array_insert (a, i, t);
+       }
+      return;
+    }
+
+  /* Fast case */
+  if (array_num_elements (a) == nproc && nproc == 1)
+    {
+      ae = element_forw (a->head);
+      free (element_value (ae));
+      ae->value = itos (ps[0]);
+    }
+  else if (array_num_elements (a) <= nproc)
+    {
+      /* modify in array_num_elements members in place, then add */
+      ae = a->head;
+      for (i = 0; i < array_num_elements (a); i++)
+       {
+         ae = element_forw (ae);
+         free (element_value (ae));
+         ae->value = itos (ps[i]);
+       }
+      /* add any more */
+      for ( ; i < nproc; i++)
+       {
+         t = inttostr (ps[i], tbuf, sizeof (tbuf));
+         array_insert (a, i, t);
+       }
+    }
+  else
+    {
+      /* deleting elements.  it's faster to rebuild the array. */        
+      array_flush (a);
+      for (i = 0; ps[i] != -1; i++)
+       {
+         t = inttostr (ps[i], tbuf, sizeof (tbuf));
+         array_insert (a, i, t);
+       }
+    }
+}
+#endif
+
+void
+set_pipestatus_from_exit (s)
+     int s;
+{
+#if defined (ARRAY_VARS)
+  static int v[2] = { 0, -1 };
+
+  v[0] = s;
+  set_pipestatus_array (v, 1);
+#endif
+}
index d484738c3b38067b4f8969287200e8b24f7af0d2..d16e6e3c38ab8b24c6c0c41d67b53494dc722d0e 100644 (file)
--- a/version.c
+++ b/version.c
 extern char *shell_name;
 
 /* Defines from version.h */
-const char *dist_version = DISTVERSION;
-int patch_level = PATCHLEVEL;
-int build_version = BUILDVERSION;
+const char * const dist_version = DISTVERSION;
+const int patch_level = PATCHLEVEL;
+const int build_version = BUILDVERSION;
 #ifdef RELSTATUS
-const char *release_status = RELSTATUS;
+const char * const release_status = RELSTATUS;
 #else
-const char *release_status = (char *)0;
+const char * const release_status = (char *)0;
 #endif
-const char *sccs_version = SCCSVERSION;
+const char * const sccs_version = SCCSVERSION;
 
 /* Functions for getting, setting, and displaying the shell version. */
 
index b0cefe98d338295d65f1ddb2fc1b50be4824203a..d484738c3b38067b4f8969287200e8b24f7af0d2 100644 (file)
@@ -77,7 +77,7 @@ void
 show_shell_version (extended)
      int extended;
 {
-  printf ("GNU bash, version %s (%s)\n", shell_version_string (), MACHTYPE);
+  printf (_("GNU bash, version %s (%s)\n"), shell_version_string (), MACHTYPE);
   if (extended)
     printf (_("Copyright (C) 2006 Free Software Foundation, Inc.\n"));
 }